Change optic ... uns XML files ==> more portable
This commit is contained in:
parent
6137705009
commit
bbef8c86d5
2
Makefile
2
Makefile
@ -93,7 +93,9 @@ DEFINE+= -DVERSION_BUILD_TIME="\"$(VERSION_BUILD_TIME)\""
|
||||
|
||||
X11FLAGS= -lX11 -lGL -lGLU
|
||||
# some X11 mode availlable :
|
||||
# install package : libxxf86vm-dev
|
||||
X11FLAGS+= -DEWOL_X11_MODE__XF86V -lXxf86vm
|
||||
# install package : libxrender-dev
|
||||
#X11FLAGS+= -DEWOL_X11_MODE__XRENDER -lXrandr
|
||||
|
||||
|
||||
|
@ -94,6 +94,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
ewol::Init(argc, argv);
|
||||
ewol::ChangeSize(800, 600);
|
||||
/*
|
||||
if (true == ewol::AddFont("dataTest/TextMonospace.ebt", true, true, true) ) {
|
||||
//fontID = GetFontIdWithFileName("dataTest/TextMonospace.ebt");
|
||||
|
@ -273,6 +273,8 @@ namespace guiAbstraction {
|
||||
XSetWMProtocols(m_display, WindowHandle, &m_delAtom, 1);
|
||||
}
|
||||
|
||||
ChangeSize(400, 300);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -206,6 +206,7 @@ class FTFontInternal
|
||||
{
|
||||
// 300dpi (hight quality) 96 dpi (normal quality)
|
||||
int32_t fontQuality = 96;
|
||||
//int32_t fontQuality = 150;
|
||||
//int32_t fontQuality = 300;
|
||||
// Select Size ...
|
||||
// note tha <<6==*64 corespond with the 1/64th of points calculation of freetype
|
||||
@ -291,6 +292,7 @@ class FTFontInternal
|
||||
for(int32_t i=0; i < tmpWidth; i++){
|
||||
int32_t position = 2*( (tmpRowId *glyphMaxWidth + i /*+ (slot->metrics.horiBearingX>>6)*/ )
|
||||
+ (tmpLineId*glyphMaxHeight + j + (size-(slot->metrics.horiBearingY>>6)) ) * textureWidth);
|
||||
//EWOL_DEBUG(" BEARING=(" << i << "," << j << ") pos=" << position);
|
||||
expanded_data[position+0] = slot->bitmap.buffer[i + tmpWidth*j];
|
||||
expanded_data[position+1] = slot->bitmap.buffer[i + tmpWidth*j];
|
||||
}
|
||||
@ -298,8 +300,8 @@ class FTFontInternal
|
||||
listElement[iii].width = glyphMaxWidth;
|
||||
listElement[iii].posStart.u = (etkFloat_t)(tmpRowId *glyphMaxWidth) / (etkFloat_t)textureWidth;
|
||||
listElement[iii].posStart.v = (etkFloat_t)(tmpLineId*glyphMaxHeight) / (etkFloat_t)textureHeight;
|
||||
listElement[iii].posStop.u = (etkFloat_t)(tmpRowId *glyphMaxWidth + glyphMaxWidth) / (etkFloat_t)textureWidth;;
|
||||
listElement[iii].posStop.v = (etkFloat_t)(tmpLineId*glyphMaxHeight + glyphMaxHeight) / (etkFloat_t)textureHeight;
|
||||
listElement[iii].posStop.u = (etkFloat_t)(tmpRowId *glyphMaxWidth + glyphMaxWidth ) / (etkFloat_t)textureWidth;
|
||||
listElement[iii].posStop.v = (etkFloat_t)(tmpLineId*glyphMaxHeight + glyphMaxHeight ) / (etkFloat_t)textureHeight;
|
||||
}
|
||||
// Now We Just Setup Some Texture Parameters.
|
||||
glBindTexture( GL_TEXTURE_2D, textureId);
|
||||
|
@ -43,14 +43,9 @@ ewol::theme::Theme::~Theme(void)
|
||||
static bool IsComment(char * line)
|
||||
{
|
||||
for(int32_t iii=0; iii<MAX_LINE_SIZE; iii++) {
|
||||
if( line[iii]=='\r'
|
||||
if( line[iii]=='\0'
|
||||
|| line[iii]=='\r'
|
||||
|| line[iii]=='\n') {
|
||||
line[iii]='\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(int32_t iii=0; iii<MAX_LINE_SIZE; iii++) {
|
||||
if( line[iii]=='\0') {
|
||||
// enpty line ...
|
||||
return true; //==> same a a comment ...
|
||||
}
|
||||
@ -68,19 +63,17 @@ static bool IsComment(char * line)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int32_t ClipOffset(char * line)
|
||||
|
||||
static int32_t Offset(char * line)
|
||||
{
|
||||
int32_t offset = 0;
|
||||
int32_t spaceCount = 0;
|
||||
int32_t copyOffset = 0;
|
||||
for(int32_t iii=0; iii<MAX_LINE_SIZE; iii++) {
|
||||
if( line[iii]=='\0') {
|
||||
break;
|
||||
}
|
||||
if( line[iii]!='\t'
|
||||
&& line[iii]!=' ') {
|
||||
// end of parsing
|
||||
copyOffset = iii;
|
||||
break;
|
||||
} else {
|
||||
if(line[iii]==' ') {
|
||||
@ -98,10 +91,56 @@ static int32_t ClipOffset(char * line)
|
||||
if (spaceCount != 0) {
|
||||
return -1;
|
||||
}
|
||||
memmove(line, line + copyOffset, MAX_LINE_SIZE-copyOffset);
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
static int32_t LineLen(char * pointer)
|
||||
{
|
||||
int32_t nbElement = 0;
|
||||
while( *pointer != '\0'
|
||||
&& *pointer != '\n'
|
||||
&& *pointer != '\r') {
|
||||
nbElement++;
|
||||
pointer++;
|
||||
}
|
||||
return nbElement;
|
||||
}
|
||||
|
||||
|
||||
static char* NextLineStart(char * pointer)
|
||||
{
|
||||
bool find = false;
|
||||
while(*pointer != '\0') {
|
||||
if( *pointer == '\n'
|
||||
|| *pointer == '\r') {
|
||||
find = true;
|
||||
} else if (true==find){
|
||||
return pointer;
|
||||
}
|
||||
pointer++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int32_t LenSpecificIndent(char * pointer, int32_t identSize)
|
||||
{
|
||||
char * pointerStart = pointer;
|
||||
while(NULL!=pointer) {
|
||||
// check comment //
|
||||
if (false == IsComment(pointer)) {
|
||||
// need to parse the element...
|
||||
int32_t offset = Offset(pointer);
|
||||
if (identSize > offset) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
pointer=NextLineStart(pointer);
|
||||
}
|
||||
return pointer - pointerStart;
|
||||
}
|
||||
|
||||
|
||||
void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
|
||||
{
|
||||
if (newFile.HasExtention() == false) {
|
||||
@ -116,47 +155,149 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
|
||||
EWOL_ERROR("File does not Exist ... " << newFile);
|
||||
return;
|
||||
} else {
|
||||
char elementLine[MAX_LINE_SIZE];
|
||||
int32_t fileSize = newFile.Size();
|
||||
char * fileData;
|
||||
int32_t lineID=1;
|
||||
FILE * file = fopen(newFile.GetCompleateName().c_str(),"r");
|
||||
if(NULL == file) {
|
||||
EWOL_ERROR("Can not OPEN the file name=\"" << newFile << "\"");
|
||||
return;
|
||||
}
|
||||
// load all element of the file ...
|
||||
if (NULL != fgets(elementLine, MAX_LINE_SIZE, file)) {
|
||||
if( elementLine[0] != 'e'
|
||||
|| elementLine[1] != 'o'
|
||||
|| elementLine[2] != 'l') {
|
||||
EWOL_ERROR("Start file in error " << newFile << " ==> will start with eol \\n");
|
||||
return;
|
||||
}
|
||||
fileData = new char[fileSize+1];
|
||||
if (NULL == fileData) {
|
||||
fclose(file);
|
||||
EWOL_ERROR("Can not Allocate DATA ... file=\"" << newFile << "\"");
|
||||
return;
|
||||
}
|
||||
if (fileSize != (int64_t)fread(fileData, 1, fileSize, file) ) {
|
||||
fclose(file);
|
||||
EWOL_ERROR("Error to load file DATA ... file=\"" << newFile << "\"");
|
||||
return;
|
||||
}
|
||||
// end of the string ...
|
||||
fileData[fileSize] = '\0';
|
||||
// close unneded open file
|
||||
fclose(file);
|
||||
// get the next line :
|
||||
char * elementLine = fileData;
|
||||
int32_t lineLen = LineLen(elementLine);
|
||||
// load all element of the file ...
|
||||
if( 3 > lineLen
|
||||
&& ( elementLine[0] != 'e'
|
||||
|| elementLine[1] != 'o'
|
||||
|| elementLine[2] != 'l') ) {
|
||||
EWOL_ERROR("Start file in error " << newFile << " ==> will start with eol \\n");
|
||||
delete[] fileData;
|
||||
return;
|
||||
}
|
||||
// TODO : On devrait décapitalise le fichier ... pour eviter toutes erreur de CAST ... (A voir ... maais je ne suis pas sur...)
|
||||
// TODO : Remove comment Lines ...
|
||||
enum {MODE_UNKNOW, MODE_TEXT, MODE_BINARY} fileMode = MODE_UNKNOW;
|
||||
bool SupportedVersion=false;
|
||||
lineID++;
|
||||
while (NULL != fgets(elementLine, MAX_LINE_SIZE, file) )
|
||||
{
|
||||
elementLine=NextLineStart(elementLine);
|
||||
while(NULL!=elementLine) {
|
||||
// get the current Line lenght:
|
||||
lineLen = LineLen(elementLine);
|
||||
// check comment //
|
||||
if (true == IsComment(elementLine)) {
|
||||
EWOL_VERBOSE("(l=" << lineID << ") Find a comment : \"" << elementLine << "\"");
|
||||
EWOL_VERBOSE("(l=" << lineID << ") Find a comment : \"" << etk::String(elementLine, lineLen) << "\"");
|
||||
} else {
|
||||
// need to parse the element...
|
||||
int32_t offset = ClipOffset(elementLine);
|
||||
if (offset == -1) {
|
||||
EWOL_ERROR("(l=" << lineID << ") indentation error 4 spaces or 1 tab : \"" << elementLine << "\"");
|
||||
int32_t offset = Offset(elementLine);
|
||||
if (-1 == offset) {
|
||||
EWOL_ERROR("(l=" << lineID << ") indentation error 4 spaces or 1 tab : \"" << etk::String(elementLine, lineLen) << "\"");
|
||||
delete[] fileData;
|
||||
return;
|
||||
} else {
|
||||
if (elementLine[0] == '<') {
|
||||
EWOL_INFO("(l=" << lineID << ") getting ELEMENT <> (indent=" << offset << ") : \"" << elementLine << "\"");
|
||||
} else if (elementLine[0] == '[') {
|
||||
EWOL_INFO("(l=" << lineID << ") getting block [] (indent=" << offset << ") : \"" << elementLine << "\"");
|
||||
} else if (elementLine[0] == '{') {
|
||||
EWOL_INFO("(l=" << lineID << ") getting drawing basic {} (indent=" << offset << ") : \"" << elementLine << "\"");
|
||||
} else {
|
||||
EWOL_DEBUG("(l=" << lineID << ") data OTHER ... (indent=" << offset << ") : \"" << elementLine << "\"");
|
||||
} else if (0==offset) {
|
||||
if (0==strncmp(elementLine, "Mode=Text", 9)) {
|
||||
fileMode = MODE_TEXT;
|
||||
EWOL_INFO("(l=" << lineID << ") getting Mode : Text");
|
||||
} else if (0==strncmp(elementLine, "Mode=Bin", 8)) {
|
||||
fileMode = MODE_BINARY;
|
||||
EWOL_INFO("(l=" << lineID << ") getting Mode : Binary");
|
||||
} else if (0==strncmp(elementLine, "Version=1.0", 11)) {
|
||||
SupportedVersion = true;
|
||||
EWOL_INFO("(l=" << lineID << ") getting Version 1.0");
|
||||
} else if (lineLen>=3 && elementLine[0] == '<') {
|
||||
break;
|
||||
EWOL_INFO("(l=" << lineID << ") getting ELEMENT <> (indent=" << offset << ") : \"" << etk::String(elementLine,lineLen) << "\"");
|
||||
} else{
|
||||
EWOL_WARNING("(l=" << lineID << ") Un-Interpreted Line : \"" << etk::String(elementLine, lineLen) << "\"");
|
||||
}
|
||||
} else {
|
||||
EWOL_ERROR("(l=" << lineID << ") Not Permeted before the first <...> : \"" << etk::String(elementLine, lineLen) << "\"");
|
||||
delete[] fileData;
|
||||
return;
|
||||
}
|
||||
}
|
||||
lineID++;
|
||||
elementLine=NextLineStart(elementLine);
|
||||
}
|
||||
// Check Version And mode ...
|
||||
|
||||
if (fileMode != MODE_TEXT || SupportedVersion==false) {
|
||||
EWOL_ERROR("==> Not Supported Type of file Mode and/or version of file Mode .... ");
|
||||
delete[] fileData;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while(NULL!=elementLine) {
|
||||
// get the current Line lenght:
|
||||
lineLen = LineLen(elementLine);
|
||||
// check comment //
|
||||
if (true == IsComment(elementLine)) {
|
||||
EWOL_VERBOSE("(l=" << lineID << ") Find a comment : \"" << etk::String(elementLine, lineLen) << "\"");
|
||||
} else {
|
||||
// need to parse the element...
|
||||
int32_t offset = Offset(elementLine);
|
||||
if (-1 == offset) {
|
||||
EWOL_ERROR("(l=" << lineID << ") indentation error 4 spaces or 1 tab : \"" << etk::String(elementLine, lineLen) << "\"");
|
||||
delete[] fileData;
|
||||
return;
|
||||
} else if (0==offset) {
|
||||
if (lineLen>=3 && elementLine[0] == '<') {
|
||||
int32_t nbElement = 1;
|
||||
bool find = false;
|
||||
while(nbElement < lineLen) {
|
||||
if (elementLine[nbElement] == '>') {
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
nbElement++;
|
||||
}
|
||||
if (true == find) {
|
||||
EWOL_INFO("(l=" << lineID << ") getting ELEMENT <" << etk::String(&elementLine[1],nbElement-1)<< ">");
|
||||
int32_t lenMM = LenSpecificIndent(NextLineStart(elementLine), 1);
|
||||
EWOL_INFO("(l=" << lineID+1 << ") sub Parse : \"" << etk::String(NextLineStart(elementLine), lenMM)<< "\"");
|
||||
|
||||
} else {
|
||||
EWOL_WARNING("(l=" << lineID << ") Un-Interpreted Line : \"" << etk::String(elementLine, lineLen) << "\"");
|
||||
}
|
||||
} else {
|
||||
EWOL_WARNING("(l=" << lineID << ") Un-Interpreted Line : \"" << etk::String(elementLine, lineLen) << "\"");
|
||||
}
|
||||
} else {
|
||||
/*elementLine += offset;
|
||||
lineLen -= offset:
|
||||
if (elementLine[0] == '<') {
|
||||
|
||||
} else if (elementLine[0] == '[') {
|
||||
EWOL_INFO("(l=" << lineID << ") getting block [] (indent=" << offset << ") : \"" << etk::String(elementLine,lineLen) << "\"");
|
||||
} else if (elementLine[0] == '{') {
|
||||
EWOL_INFO("(l=" << lineID << ") getting drawing basic {} (indent=" << offset << ") : \"" << etk::String(elementLine,lineLen) << "\"");
|
||||
} else {
|
||||
EWOL_DEBUG("(l=" << lineID << ") data OTHER ... (indent=" << offset << ") : \"" << etk::String(elementLine,lineLen) << "\"");
|
||||
}
|
||||
*/
|
||||
//EWOL_WARNING("(l=" << lineID << ") Un-Interpreted Line : (indent=" << offset << ") : \"" << etk::String(elementLine,lineLen) << "\"");
|
||||
}
|
||||
}
|
||||
lineID++;
|
||||
elementLine=NextLineStart(elementLine);
|
||||
}
|
||||
delete[] fileData;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,69 +1,58 @@
|
||||
eol
|
||||
# Mode of reading file: "Text" / "Bin"
|
||||
Mode=Text
|
||||
# type of the file : "Single" / "Multiple"
|
||||
FileType=Single
|
||||
# Version :
|
||||
version=1.0
|
||||
|
||||
<plop> # name of the ELEMENT ....
|
||||
# Number of sub frame of the element (default 1)
|
||||
NbFrame=2
|
||||
# Element display Ratio : ratio = x/y (default 1.0)
|
||||
Ratio=1.0
|
||||
# Clipping mode of the element
|
||||
ClipX=false
|
||||
ClipY=false
|
||||
# Position of internal Elements ... (use only if clipping is enable
|
||||
internalElemXStart=0.25
|
||||
internalElemXStop=0.75
|
||||
internalElemYStart=0.25
|
||||
internalElemYStop=0.75
|
||||
# note we have 5 methode to reference a color :
|
||||
# - #RRGGBB ==> in hexa 0x00<=x<=0xFF
|
||||
# - #RRGGBBAA ==> in hexa 0x00<=x<=0xFF
|
||||
# - R.R;G.G;B.B ==> in double 0<=x<=1
|
||||
# - R.R;G.G;B.B;A.A ==> in double 0<=x<=1
|
||||
# - &NameColor ==> search internal color of the element and after global color ...
|
||||
[Colors]
|
||||
colorName=1.0;1.0;1.0;1.0
|
||||
Background=0.0;0.000512;1.0;0.755562535
|
||||
Border=#536254FF
|
||||
[grp=basicRect]
|
||||
{Rect}
|
||||
color=#536254FF
|
||||
position=0.53;0.56
|
||||
size=0.22;0.12
|
||||
{Rect}
|
||||
color=&Background
|
||||
position=0.10;0.10
|
||||
size=0.22;0.22
|
||||
#decription of the object:
|
||||
[Frame=0=basic]
|
||||
{Circle}
|
||||
name=plop et plop
|
||||
thickness=0.01
|
||||
# Start
|
||||
color=#51625351
|
||||
point=0.2562;0.4532
|
||||
# Stop
|
||||
color=#51625351
|
||||
point=0.5245;0.5356
|
||||
{Rect}
|
||||
color=#536254FF
|
||||
position=0.53;0.56
|
||||
size=0.22;0.12
|
||||
[Frame=1=clicked]
|
||||
{Circle}
|
||||
thickness=0.01
|
||||
color=#51625351
|
||||
point=0.2562;0.4532
|
||||
color=#51625351
|
||||
point=0.5245;0.5356
|
||||
{Rect}
|
||||
color=&Border
|
||||
position=0.53;0.56
|
||||
size=0.22;0.12
|
||||
# load a generic group of the object or the theme
|
||||
{grp}
|
||||
name=basicRect
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<eol>
|
||||
<!-- can have "color" and "group" that is consider as global ... -->
|
||||
|
||||
<!-- example of a single element -->
|
||||
<element name="plop"
|
||||
ratio="1.0"
|
||||
ClipX="false"
|
||||
ClipY="false"
|
||||
internalElemXStart="0.25"
|
||||
internalElemXStop="0.75"
|
||||
internalElemYStart="0.25"
|
||||
internalElemYStop="0.75">
|
||||
<!--
|
||||
note we have 5 methode to reference a color :
|
||||
- #RRGGBB ==> in hexa 0x00<=x<=0xFF
|
||||
- #RRGGBBAA ==> in hexa 0x00<=x<=0xFF
|
||||
- R.R;G.G;B.B ==> in double 0<=x<=1
|
||||
- R.R;G.G;B.B;A.A ==> in double 0<=x<=1
|
||||
- &NameColor ==> search internal color of the element and after global color ...
|
||||
-->
|
||||
<color name="Background" val="#151515"/>
|
||||
<color name="Border" val="0.0;0.000512;1.0;0.755562535"/>
|
||||
<!--...-->
|
||||
|
||||
|
||||
<group name="basicRect">
|
||||
<rect color="..."
|
||||
position="0.53;0.56"
|
||||
size="0.22;0.11"
|
||||
/>
|
||||
<Line color="..."
|
||||
positionStart="0.53;0.56"
|
||||
positionStop="0.22;0.11"
|
||||
thickness="0.05"
|
||||
/>
|
||||
<!-- and more basic display -->
|
||||
</group>
|
||||
<!--...-->
|
||||
|
||||
<frame id=0 name="basic">
|
||||
<rect color="..."
|
||||
position="0.53;0.56"
|
||||
size="0.22;0.11"
|
||||
/>
|
||||
</frame>
|
||||
<frame id=0 name="hover">
|
||||
<rect color="..."
|
||||
position="0.53;0.56"
|
||||
size="0.22;0.11"
|
||||
/>
|
||||
<group name="basicRect"/>
|
||||
</frame>
|
||||
<!--...-->
|
||||
|
||||
</element>
|
||||
<!--...-->
|
||||
</eol>
|
||||
|
Loading…
x
Reference in New Issue
Block a user