Change optic ... uns XML files ==> more portable

This commit is contained in:
Edouard Dupin 2011-11-25 14:47:09 +01:00
parent 6137705009
commit bbef8c86d5
6 changed files with 244 additions and 107 deletions

View File

@ -93,7 +93,9 @@ DEFINE+= -DVERSION_BUILD_TIME="\"$(VERSION_BUILD_TIME)\""
X11FLAGS= -lX11 -lGL -lGLU X11FLAGS= -lX11 -lGL -lGLU
# some X11 mode availlable : # some X11 mode availlable :
# install package : libxxf86vm-dev
X11FLAGS+= -DEWOL_X11_MODE__XF86V -lXxf86vm X11FLAGS+= -DEWOL_X11_MODE__XF86V -lXxf86vm
# install package : libxrender-dev
#X11FLAGS+= -DEWOL_X11_MODE__XRENDER -lXrandr #X11FLAGS+= -DEWOL_X11_MODE__XRENDER -lXrandr

View File

@ -94,6 +94,7 @@ int main(int argc, char *argv[])
{ {
ewol::Init(argc, argv); ewol::Init(argc, argv);
ewol::ChangeSize(800, 600);
/* /*
if (true == ewol::AddFont("dataTest/TextMonospace.ebt", true, true, true) ) { if (true == ewol::AddFont("dataTest/TextMonospace.ebt", true, true, true) ) {
//fontID = GetFontIdWithFileName("dataTest/TextMonospace.ebt"); //fontID = GetFontIdWithFileName("dataTest/TextMonospace.ebt");

View File

@ -273,6 +273,8 @@ namespace guiAbstraction {
XSetWMProtocols(m_display, WindowHandle, &m_delAtom, 1); XSetWMProtocols(m_display, WindowHandle, &m_delAtom, 1);
} }
ChangeSize(400, 300);
return true; return true;
} }

View File

@ -206,6 +206,7 @@ class FTFontInternal
{ {
// 300dpi (hight quality) 96 dpi (normal quality) // 300dpi (hight quality) 96 dpi (normal quality)
int32_t fontQuality = 96; int32_t fontQuality = 96;
//int32_t fontQuality = 150;
//int32_t fontQuality = 300; //int32_t fontQuality = 300;
// Select Size ... // Select Size ...
// note tha <<6==*64 corespond with the 1/64th of points calculation of freetype // 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++){ for(int32_t i=0; i < tmpWidth; i++){
int32_t position = 2*( (tmpRowId *glyphMaxWidth + i /*+ (slot->metrics.horiBearingX>>6)*/ ) int32_t position = 2*( (tmpRowId *glyphMaxWidth + i /*+ (slot->metrics.horiBearingX>>6)*/ )
+ (tmpLineId*glyphMaxHeight + j + (size-(slot->metrics.horiBearingY>>6)) ) * textureWidth); + (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+0] = slot->bitmap.buffer[i + tmpWidth*j];
expanded_data[position+1] = 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].width = glyphMaxWidth;
listElement[iii].posStart.u = (etkFloat_t)(tmpRowId *glyphMaxWidth) / (etkFloat_t)textureWidth; listElement[iii].posStart.u = (etkFloat_t)(tmpRowId *glyphMaxWidth) / (etkFloat_t)textureWidth;
listElement[iii].posStart.v = (etkFloat_t)(tmpLineId*glyphMaxHeight) / (etkFloat_t)textureHeight; 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.u = (etkFloat_t)(tmpRowId *glyphMaxWidth + glyphMaxWidth ) / (etkFloat_t)textureWidth;
listElement[iii].posStop.v = (etkFloat_t)(tmpLineId*glyphMaxHeight + glyphMaxHeight) / (etkFloat_t)textureHeight; listElement[iii].posStop.v = (etkFloat_t)(tmpLineId*glyphMaxHeight + glyphMaxHeight ) / (etkFloat_t)textureHeight;
} }
// Now We Just Setup Some Texture Parameters. // Now We Just Setup Some Texture Parameters.
glBindTexture( GL_TEXTURE_2D, textureId); glBindTexture( GL_TEXTURE_2D, textureId);

View File

@ -43,14 +43,9 @@ ewol::theme::Theme::~Theme(void)
static bool IsComment(char * line) static bool IsComment(char * line)
{ {
for(int32_t iii=0; iii<MAX_LINE_SIZE; iii++) { 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]=='\n') {
line[iii]='\0';
break;
}
}
for(int32_t iii=0; iii<MAX_LINE_SIZE; iii++) {
if( line[iii]=='\0') {
// enpty line ... // enpty line ...
return true; //==> same a a comment ... return true; //==> same a a comment ...
} }
@ -68,19 +63,17 @@ static bool IsComment(char * line)
return true; return true;
} }
static int32_t ClipOffset(char * line)
static int32_t Offset(char * line)
{ {
int32_t offset = 0; int32_t offset = 0;
int32_t spaceCount = 0; int32_t spaceCount = 0;
int32_t copyOffset = 0;
for(int32_t iii=0; iii<MAX_LINE_SIZE; iii++) { for(int32_t iii=0; iii<MAX_LINE_SIZE; iii++) {
if( line[iii]=='\0') { if( line[iii]=='\0') {
break; break;
} }
if( line[iii]!='\t' if( line[iii]!='\t'
&& line[iii]!=' ') { && line[iii]!=' ') {
// end of parsing
copyOffset = iii;
break; break;
} else { } else {
if(line[iii]==' ') { if(line[iii]==' ') {
@ -98,10 +91,56 @@ static int32_t ClipOffset(char * line)
if (spaceCount != 0) { if (spaceCount != 0) {
return -1; return -1;
} }
memmove(line, line + copyOffset, MAX_LINE_SIZE-copyOffset);
return offset; 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) void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
{ {
if (newFile.HasExtention() == false) { 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); EWOL_ERROR("File does not Exist ... " << newFile);
return; return;
} else { } else {
char elementLine[MAX_LINE_SIZE]; int32_t fileSize = newFile.Size();
char * fileData;
int32_t lineID=1; int32_t lineID=1;
FILE * file = fopen(newFile.GetCompleateName().c_str(),"r"); FILE * file = fopen(newFile.GetCompleateName().c_str(),"r");
if(NULL == file) { if(NULL == file) {
EWOL_ERROR("Can not OPEN the file name=\"" << newFile << "\""); EWOL_ERROR("Can not OPEN the file name=\"" << newFile << "\"");
return; return;
} }
// load all element of the file ... fileData = new char[fileSize+1];
if (NULL != fgets(elementLine, MAX_LINE_SIZE, file)) { if (NULL == fileData) {
if( elementLine[0] != 'e' fclose(file);
|| elementLine[1] != 'o' EWOL_ERROR("Can not Allocate DATA ... file=\"" << newFile << "\"");
|| elementLine[2] != 'l') { return;
EWOL_ERROR("Start file in error " << newFile << " ==> will start with eol \\n");
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++; 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)) { if (true == IsComment(elementLine)) {
EWOL_VERBOSE("(l=" << lineID << ") Find a comment : \"" << elementLine << "\""); EWOL_VERBOSE("(l=" << lineID << ") Find a comment : \"" << etk::String(elementLine, lineLen) << "\"");
} else { } else {
// need to parse the element... // need to parse the element...
int32_t offset = ClipOffset(elementLine); int32_t offset = Offset(elementLine);
if (offset == -1) { if (-1 == offset) {
EWOL_ERROR("(l=" << lineID << ") indentation error 4 spaces or 1 tab : \"" << elementLine << "\""); EWOL_ERROR("(l=" << lineID << ") indentation error 4 spaces or 1 tab : \"" << etk::String(elementLine, lineLen) << "\"");
delete[] fileData;
return; return;
} else { } else if (0==offset) {
if (elementLine[0] == '<') { if (0==strncmp(elementLine, "Mode=Text", 9)) {
EWOL_INFO("(l=" << lineID << ") getting ELEMENT <> (indent=" << offset << ") : \"" << elementLine << "\""); fileMode = MODE_TEXT;
} else if (elementLine[0] == '[') { EWOL_INFO("(l=" << lineID << ") getting Mode : Text");
EWOL_INFO("(l=" << lineID << ") getting block [] (indent=" << offset << ") : \"" << elementLine << "\""); } else if (0==strncmp(elementLine, "Mode=Bin", 8)) {
} else if (elementLine[0] == '{') { fileMode = MODE_BINARY;
EWOL_INFO("(l=" << lineID << ") getting drawing basic {} (indent=" << offset << ") : \"" << elementLine << "\""); EWOL_INFO("(l=" << lineID << ") getting Mode : Binary");
} else { } else if (0==strncmp(elementLine, "Version=1.0", 11)) {
EWOL_DEBUG("(l=" << lineID << ") data OTHER ... (indent=" << offset << ") : \"" << elementLine << "\""); 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++; 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;
} }
} }

View File

@ -1,69 +1,58 @@
eol <?xml version="1.0" encoding="UTF-8"?>
# Mode of reading file: "Text" / "Bin" <eol>
Mode=Text <!-- can have "color" and "group" that is consider as global ... -->
# type of the file : "Single" / "Multiple"
FileType=Single <!-- example of a single element -->
# Version : <element name="plop"
version=1.0 ratio="1.0"
ClipX="false"
<plop> # name of the ELEMENT .... ClipY="false"
# Number of sub frame of the element (default 1) internalElemXStart="0.25"
NbFrame=2 internalElemXStop="0.75"
# Element display Ratio : ratio = x/y (default 1.0) internalElemYStart="0.25"
Ratio=1.0 internalElemYStop="0.75">
# Clipping mode of the element <!--
ClipX=false note we have 5 methode to reference a color :
ClipY=false - #RRGGBB ==> in hexa 0x00<=x<=0xFF
# Position of internal Elements ... (use only if clipping is enable - #RRGGBBAA ==> in hexa 0x00<=x<=0xFF
internalElemXStart=0.25 - R.R;G.G;B.B ==> in double 0<=x<=1
internalElemXStop=0.75 - R.R;G.G;B.B;A.A ==> in double 0<=x<=1
internalElemYStart=0.25 - &NameColor ==> search internal color of the element and after global color ...
internalElemYStop=0.75 -->
# note we have 5 methode to reference a color : <color name="Background" val="#151515"/>
# - #RRGGBB ==> in hexa 0x00<=x<=0xFF <color name="Border" val="0.0;0.000512;1.0;0.755562535"/>
# - #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 ... <group name="basicRect">
[Colors] <rect color="..."
colorName=1.0;1.0;1.0;1.0 position="0.53;0.56"
Background=0.0;0.000512;1.0;0.755562535 size="0.22;0.11"
Border=#536254FF />
[grp=basicRect] <Line color="..."
{Rect} positionStart="0.53;0.56"
color=#536254FF positionStop="0.22;0.11"
position=0.53;0.56 thickness="0.05"
size=0.22;0.12 />
{Rect} <!-- and more basic display -->
color=&Background </group>
position=0.10;0.10 <!--...-->
size=0.22;0.22
#decription of the object: <frame id=0 name="basic">
[Frame=0=basic] <rect color="..."
{Circle} position="0.53;0.56"
name=plop et plop size="0.22;0.11"
thickness=0.01 />
# Start </frame>
color=#51625351 <frame id=0 name="hover">
point=0.2562;0.4532 <rect color="..."
# Stop position="0.53;0.56"
color=#51625351 size="0.22;0.11"
point=0.5245;0.5356 />
{Rect} <group name="basicRect"/>
color=#536254FF </frame>
position=0.53;0.56 <!--...-->
size=0.22;0.12
[Frame=1=clicked] </element>
{Circle} <!--...-->
thickness=0.01 </eol>
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