diff --git a/Sources/Main.cpp b/Sources/Main.cpp index d906c8ed..2b7f9ae2 100644 --- a/Sources/Main.cpp +++ b/Sources/Main.cpp @@ -103,7 +103,7 @@ int main(int argc, char *argv[]) ewol::SetFontFolder("Font"); ewol::SetDefaultFont("freefont/FreeMono", 14); ewol::theme::LoadDefault("dataTest/exemple.eol"); - ewol::theme::LoadDefault("dataTest/exemple.eol"); + //ewol::theme::LoadDefault("dataTest/exemple.eol"); exit(0); Plop * myWindowsExample = new Plop(); diff --git a/Sources/ewol/theme/EolBase.cpp b/Sources/ewol/theme/EolBase.cpp index 5bb032eb..ebb8dd87 100644 --- a/Sources/ewol/theme/EolBase.cpp +++ b/Sources/ewol/theme/EolBase.cpp @@ -30,7 +30,7 @@ ewol::theme::EolBase::EolBase(void) { - + //EWOL_DEBUG("new..."); } ewol::theme::EolBase::~EolBase(void) @@ -41,25 +41,5 @@ ewol::theme::EolBase::~EolBase(void) void ewol::theme::EolBase::Parse(TiXmlNode * pNode) { - m_name = pNode->ToElement()->Attribute("name"); - EWOL_INFO("Group name=\"" << m_name << "\" " ); + EWOL_INFO("Element Base .. Generic ... nothing to parse..." ); } - - -etk::String ewol::theme::EolBase::GetName(void) -{ - return m_name; -} - - -void ewol::theme::EolBase::SetName(etk::String & newName) -{ - m_name = newName; -} - - -bool ewol::theme::EolBase::HasName(etk::String & newName) -{ - return m_name == newName; -} - diff --git a/Sources/ewol/theme/EolBase.h b/Sources/ewol/theme/EolBase.h index 6d2f6ef4..93d58c88 100644 --- a/Sources/ewol/theme/EolBase.h +++ b/Sources/ewol/theme/EolBase.h @@ -39,13 +39,7 @@ namespace ewol { public: EolBase(void); virtual ~EolBase(void); - - void Parse(TiXmlNode * pNode); - etk::String GetName(void); - void SetName(etk::String & newName); - bool HasName(etk::String & newName); - private: - etk::String m_name; + virtual void Parse(TiXmlNode * pNode); }; }; }; diff --git a/Sources/ewol/theme/EolBaseLine.cpp b/Sources/ewol/theme/EolBaseLine.cpp index b43d78eb..b664b6ab 100644 --- a/Sources/ewol/theme/EolBaseLine.cpp +++ b/Sources/ewol/theme/EolBaseLine.cpp @@ -22,7 +22,57 @@ ******************************************************************************* */ +#include #undef __class__ #define __class__ "ewol::theme::EolBaseLine" + +ewol::theme::EolBaseLine::EolBaseLine(void) +{ + //EWOL_DEBUG("new element Base : Line ..."); +} + +ewol::theme::EolBaseLine::~EolBaseLine(void) +{ + +} + + +void ewol::theme::EolBaseLine::Parse(TiXmlNode * pNode) +{ + m_color = pNode->ToElement()->Attribute("color"); + + const char * tmp = pNode->ToElement()->Attribute("positionStart"); + if (NULL == tmp) { + m_posStart.x=0; + m_posStart.y=0; + } else { + double xxx,yyy; + // optimize for multiple type input ... + sscanf(tmp, "%lf;%lf", &xxx,&yyy); + m_posStart.x=xxx; + m_posStart.y=yyy; + } + tmp = pNode->ToElement()->Attribute("positionStop"); + if (NULL == tmp) { + m_posStop.x=0; + m_posStop.y=0; + } else { + double xxx,yyy; + // optimize for multiple type input ... + sscanf(tmp, "%lf;%lf", &xxx,&yyy); + m_posStop.x=xxx; + m_posStop.y=yyy; + } + tmp = pNode->ToElement()->Attribute("thickness"); + if (NULL == tmp) { + m_thickness=0; + } else { + double th; + // optimize for multiple type input ... + sscanf(tmp, "%lf", &th); + m_thickness=th; + } + EWOL_DEBUG("(l " << pNode->Row() << ") Parse Base Element : \"line\" : pos(" << m_posStart.x << "," << m_posStart.y << ") to pos(" << m_posStop.x << "," << m_posStop.y << ") thickness=" << m_thickness); +} diff --git a/Sources/ewol/theme/EolBaseLine.h b/Sources/ewol/theme/EolBaseLine.h index 0f766c3b..a100a338 100644 --- a/Sources/ewol/theme/EolBaseLine.h +++ b/Sources/ewol/theme/EolBaseLine.h @@ -24,9 +24,34 @@ #include +#include #ifndef __EWOL_THEME_EOL_BASE_LINE_H__ #define __EWOL_THEME_EOL_BASE_LINE_H__ +namespace ewol { + namespace theme { + class EolBaseLine : public EolBase { + public: + EolBaseLine(void); + virtual ~EolBaseLine(void); + /* + + */ + virtual void Parse(TiXmlNode * pNode); + private: + etk::String m_color; + coord2D_ts m_posStart; + coord2D_ts m_posStop; + etkFloat_t m_thickness; + }; + }; +}; + + #endif diff --git a/Sources/ewol/theme/EolBaseRect.cpp b/Sources/ewol/theme/EolBaseRect.cpp index 8c772157..c02b9c35 100644 --- a/Sources/ewol/theme/EolBaseRect.cpp +++ b/Sources/ewol/theme/EolBaseRect.cpp @@ -22,7 +22,48 @@ ******************************************************************************* */ +#include #undef __class__ #define __class__ "ewol::theme::EolBaseRect" + + +ewol::theme::EolBaseRect::EolBaseRect(void) +{ + //EWOL_DEBUG("new element Base : Rectangle ..."); +} + +ewol::theme::EolBaseRect::~EolBaseRect(void) +{ + +} + + +void ewol::theme::EolBaseRect::Parse(TiXmlNode * pNode) +{ + const char * tmp = pNode->ToElement()->Attribute("position"); + if (NULL == tmp) { + m_position.x=0; + m_position.y=0; + } else { + double xxx,yyy; + // optimize for multiple type input ... + sscanf(tmp, "%lf;%lf", &xxx,&yyy); + m_position.x=xxx; + m_position.y=yyy; + } + tmp = pNode->ToElement()->Attribute("size"); + if (NULL == tmp) { + m_size.x=0; + m_size.y=0; + } else { + double xxx,yyy; + // optimize for multiple type input ... + sscanf(tmp, "%lf;%lf", &xxx,&yyy); + m_size.x=xxx; + m_size.y=yyy; + } + m_color = pNode->ToElement()->Attribute("color"); + EWOL_DEBUG("(l " << pNode->Row() << ") Parse Base Element : \"rect\" : pos(" << m_position.x << "," << m_position.y << ") size(" << m_size.x << "," << m_size.y << ") colorName=\"" << m_color << "\""); +} diff --git a/Sources/ewol/theme/EolBaseRect.h b/Sources/ewol/theme/EolBaseRect.h index ab8b2157..de721c5d 100644 --- a/Sources/ewol/theme/EolBaseRect.h +++ b/Sources/ewol/theme/EolBaseRect.h @@ -24,9 +24,31 @@ #include +#include #ifndef __EWOL_THEME_EOL_BASE_RECT_H__ #define __EWOL_THEME_EOL_BASE_RECT_H__ +namespace ewol { + namespace theme { + class EolBaseRect : public EolBase { + public: + EolBaseRect(void); + virtual ~EolBaseRect(void); + /* + + */ + virtual void Parse(TiXmlNode * pNode); + private: + etk::String m_color; + coord2D_ts m_position; + coord2D_ts m_size; + }; + }; +}; + #endif diff --git a/Sources/ewol/theme/EolColor.cpp b/Sources/ewol/theme/EolColor.cpp index fb478ddf..1cb8e123 100644 --- a/Sources/ewol/theme/EolColor.cpp +++ b/Sources/ewol/theme/EolColor.cpp @@ -81,9 +81,9 @@ void ewol::theme::EolColor::Parse(TiXmlNode * pNode) } } if (NULL != color) { - EWOL_INFO("COLOR name=\"" << m_name << "\" \"" << color << "\" ==> red="<< m_color.red <<" green="<< m_color.green <<" blue="<< m_color.blue <<" alpha="<< m_color.alpha ); + EWOL_INFO("(l " << pNode->Row() << ") color name=\"" << m_name << "\" \"" << color << "\" ==> red="<< m_color.red <<" green="<< m_color.green <<" blue="<< m_color.blue <<" alpha="<< m_color.alpha ); } else { - EWOL_INFO("COLOR name=\"" << m_name << "\" \"\"???? ==> red="<< m_color.red <<" green="<< m_color.green <<" blue="<< m_color.blue <<" alpha="<< m_color.alpha ); + EWOL_INFO("(l " << pNode->Row() << ") color name=\"" << m_name << "\" \"\"???? ==> red="<< m_color.red <<" green="<< m_color.green <<" blue="<< m_color.blue <<" alpha="<< m_color.alpha ); } } diff --git a/Sources/ewol/theme/EolElement.cpp b/Sources/ewol/theme/EolElement.cpp index 81aae2b9..bd06f041 100644 --- a/Sources/ewol/theme/EolElement.cpp +++ b/Sources/ewol/theme/EolElement.cpp @@ -22,8 +22,266 @@ ******************************************************************************* */ +#include #undef __class__ #define __class__ "ewol::theme::EolElement" +ewol::theme::EolElement::EolElement(void) +{ + //EWOL_DEBUG("new..."); +} + +ewol::theme::EolElement::~EolElement(void) +{ + RemoveAll(); +} + +void ewol::theme::EolElement::RemoveAll(void) +{ + for(int32_t iii=0; iiiToElement()->Attribute("name"); + const char * tmp = root->ToElement()->Attribute("ratio"); + if (NULL == tmp) { + m_ratio=1.0; + } else { + double xxx; + // optimize for multiple type input ... + sscanf(tmp, "%lf", &xxx); + m_ratio=xxx; + } + etk::String tmpString = root->ToElement()->Attribute("ClipX"); + if (tmpString == "true") { + m_clipX = true; + } else { + m_clipX = false; + } + etk::String tmpString2 = root->ToElement()->Attribute("ClipY"); + if (tmpString2 == "true") { + m_clipY = true; + } else { + m_clipY = false; + } + + tmp = root->ToElement()->Attribute("internalElemStart"); + if (NULL == tmp) { + m_internalElemStart.x=0; + m_internalElemStart.y=0; + } else { + double xxx,yyy; + // optimize for multiple type input ... + sscanf(tmp, "%lf;%lf", &xxx,&yyy); + m_internalElemStart.x=xxx; + m_internalElemStart.y=yyy; + } + tmp = root->ToElement()->Attribute("internalElemStop"); + if (NULL == tmp) { + m_internalElemStop.x=0; + m_internalElemStop.y=0; + } else { + double xxx,yyy; + // optimize for multiple type input ... + sscanf(tmp, "%lf;%lf", &xxx,&yyy); + m_internalElemStop.x=xxx; + m_internalElemStop.y=yyy; + } + EWOL_INFO("(l " << root->Row() << ") ELEMENT name=\"" << m_name << "\" internalStart(" << m_internalElemStart.x << "," << m_internalElemStart.y << ") to internalStop(" << m_internalElemStop.x << "," << m_internalElemStop.y << ") ratio=" << m_ratio ); + EWOL_INFO(" --------------------- START ---------------------"); + for(TiXmlNode * pNode=root->FirstChild(); NULL!=pNode; pNode = pNode->NextSibling()) { + if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) { + continue; + } + etk::String nodeValue = pNode->Value(); + if (nodeValue == "group") { + //EWOL_INFO("Find group ... "); + etk::String groupNameTmp = pNode->ToElement()->Attribute("name"); + if (groupNameTmp == "") { + EWOL_ERROR("(l " << pNode->Row() << ") Group with NO name ... (not parsed)"); + // not added it + } else { + bool findASameName = false; + // check if existed ... + for (int32_t iii=0; iii < m_listGroup.Size(); iii++) { + if(NULL!=m_listGroup[iii]) { + if(m_listGroup[iii]->HasName(groupNameTmp) == true) { + findASameName = true; + EWOL_WARNING("(l " << pNode->Row() << ") Find a Group with the same Name : \"" << groupNameTmp <<"\""); + m_listGroup[iii]->Parse(pNode); + break; + } + } + } + if (findASameName == false) { + //EWOL_DEBUG("(l " << pNode->Row() << ") Add a new Group : \"" << groupNameTmp <<"\""); + ewol::theme::EolElementFrame * myGroupTmp = new ewol::theme::EolElementFrame(); + if (NULL != myGroupTmp) { + myGroupTmp->Parse(pNode); + m_listGroup.PushBack(myGroupTmp); + } else { + EWOL_ERROR("(l " << pNode->Row() << ") Error Allocation : \"" << nodeValue <<"\""); + } + } + } + } else if (nodeValue == "frame") { + //EWOL_INFO("Find frame ... "); + etk::String groupNameTmp = pNode->ToElement()->Attribute("name"); + if (groupNameTmp == "") { + EWOL_ERROR("(l " << pNode->Row() << ") Group with NO name ... (not parsed)"); + // not added it + } else { + bool findASameName = false; + // check if existed ... + for (int32_t iii=0; iii < m_listElement.Size(); iii++) { + if(NULL!=m_listElement[iii]) { + if(m_listElement[iii]->HasName(groupNameTmp) == true) { + findASameName = true; + EWOL_WARNING("(l " << pNode->Row() << ") Find a Frame with the same Name : \"" << groupNameTmp <<"\""); + m_listGroup[iii]->Parse(pNode); + break; + } + } + } + if (findASameName == false) { + //EWOL_DEBUG("(l " << pNode->Row() << ") Add a new Frame : \"" << groupNameTmp <<"\""); + ewol::theme::EolElementFrame * myGroupTmp = new ewol::theme::EolElementFrame(); + if (NULL != myGroupTmp) { + myGroupTmp->Parse(pNode); + m_listElement.PushBack(myGroupTmp); + } else { + EWOL_ERROR("(l " << pNode->Row() << ") Error Allocation : \"" << nodeValue <<"\""); + } + } + } + } else if (nodeValue == "color") { + etk::String colorNameTmp = pNode->ToElement()->Attribute("name"); + if (colorNameTmp == "") { + EWOL_ERROR("(l " << pNode->Row() << ") Color with NO name ... (not parsed)"); + // not added it + } else { + bool findASameName = false; + // check if existed ... + for (int32_t iii=0; iii < m_listColor.Size(); iii++) { + if(NULL!=m_listColor[iii]) { + if(m_listColor[iii]->HasName(colorNameTmp) == true) { + findASameName = true; + EWOL_WARNING("(l " << pNode->Row() << ") Find a color with the same Name : \"" << colorNameTmp <<"\""); + m_listColor[iii]->Parse(pNode); + break; + } + } + } + if (findASameName == false) { + //EWOL_DEBUG("(l " << pNode->Row() << ") Add a new COLOR : \"" << colorNameTmp <<"\""); + ewol::theme::EolColor * myColorTmp = new ewol::theme::EolColor(); + if (NULL != myColorTmp) { + myColorTmp->Parse(pNode); + m_listColor.PushBack(myColorTmp); + } else { + EWOL_ERROR("(l " << pNode->Row() << ") Error Allocation : \"" << nodeValue <<"\""); + } + } + } + } else { + EWOL_ERROR("(l " << pNode->Row() << ") node not suported : \"" << nodeValue <<"\" must be [group,color,frame]"); + } + } + EWOL_INFO(" --------------------- STOP ---------------------"); +} + + + +bool ewol::theme::EolElement::GetColor(etk::String colorName, color_ts & selectedColor) +{ + for (int32_t iii=0; iii < m_listColor.Size(); iii++) { + if(NULL!=m_listColor[iii]) { + if(m_listColor[iii]->HasName(colorName) == true) { + selectedColor = m_listColor[iii]->Get(); + return true; + } + } + } + selectedColor.red = 0.0; + selectedColor.green = 0.0; + selectedColor.blue = 0.0; + selectedColor.alpha = 1.0; + return false; +} + +int32_t ewol::theme::EolElement::GetNbFrame(void) +{ + return m_listElement.Size(); +} + + +int32_t ewol::theme::EolElement::GetFrameId(etk::String & frameName) +{ + for (int32_t iii=0; iii < m_listElement.Size(); iii++) { + if(NULL!=m_listElement[iii]) { + if(m_listElement[iii]->HasName(frameName) == true) { + return iii;; + } + } + } + return -1; +} + + +etk::String ewol::theme::EolElement::GetName(void) +{ + return m_name; +} + + +void ewol::theme::EolElement::SetName(etk::String & newName) +{ + m_name = newName; +} + + +bool ewol::theme::EolElement::HasName(etk::String & newName) +{ + return m_name == newName; +} + + +void ewol::theme::EolElement::Generate(const ewol::theme::Theme * myTheme, int32_t frameId, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) +{ + if (0 > frameId || frameId > m_listElement.Size()) { + EWOL_ERROR("Did not find the frame id=" << frameId); + return; + } + if (NULL != m_listElement[frameId]) { + m_listElement[frameId]->Generate(myTheme, this, newObject, posX, posY, sizeX, sizeY); + } +} + + + diff --git a/Sources/ewol/theme/EolElement.h b/Sources/ewol/theme/EolElement.h index df60d16b..0f45fa7e 100644 --- a/Sources/ewol/theme/EolElement.h +++ b/Sources/ewol/theme/EolElement.h @@ -39,8 +39,22 @@ namespace ewol { namespace theme { class EolElement { public: - EolElement(void) { }; - virtual ~EolElement(void) { }; + EolElement(void); + virtual ~EolElement(void); + void Parse(TiXmlNode * pNode); + etk::String GetName(void); + void SetName(etk::String & newName); + bool HasName(etk::String & newName); + + void Generate(const ewol::theme::Theme * myTheme, int32_t frameId, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); + bool GenerateGroup(const ewol::theme::Theme * myTheme, etk::String groupName, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); + bool GetColor(etk::String colorName, color_ts & selectedColor); + + int32_t GetNbFrame(void); + int32_t GetFrameId(etk::String & frameName); + private: + void RemoveAll(void); + etk::String m_name; /* void Load(etk::File & newFile) { }; void Generate(int32_t id, int32_t frameId, OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) {}; @@ -50,13 +64,13 @@ namespace ewol { */ private: etk::VectorType m_listColor; - etk::VectorType m_listGroup; + etk::VectorType m_listGroup; etk::VectorType m_listElement; etkFloat_t m_ratio; bool m_clipX; bool m_clipY; - coord2D_ts m_internalElemX; - coord2D_ts m_internalElemY; + coord2D_ts m_internalElemStart; + coord2D_ts m_internalElemStop; public: // acces to manage and create object ==> drawing system diff --git a/Sources/ewol/theme/EolElementFrame.cpp b/Sources/ewol/theme/EolElementFrame.cpp index 95045bd2..990e5f3f 100644 --- a/Sources/ewol/theme/EolElementFrame.cpp +++ b/Sources/ewol/theme/EolElementFrame.cpp @@ -23,7 +23,105 @@ */ + +#include +#include + #undef __class__ #define __class__ "ewol::theme::EolElementFrame" + +ewol::theme::EolElementFrame::EolElementFrame(void) +{ + //EWOL_DEBUG("new..."); +} + +ewol::theme::EolElementFrame::~EolElementFrame(void) +{ + RemoveAll(); +} + +void ewol::theme::EolElementFrame::RemoveAll(void) +{ + for(int32_t iii=0; iiiToElement()->Attribute("name"); + EWOL_INFO("(l " << root->Row() << ") Group name=\"" << m_name << "\" " ); + for(TiXmlNode * pNode=root->FirstChild(); NULL!=pNode; pNode = pNode->NextSibling()) { + if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) { + continue; + } + etk::String nodeValue = pNode->Value(); + ewol::theme::EolBase * myBaseTmp = NULL; + if (nodeValue == "line") { + //EWOL_INFO("Find baseElement Line"); + myBaseTmp = new ewol::theme::EolBaseLine(); + if (NULL == myBaseTmp) { + EWOL_ERROR("(l " << pNode->Row() << ") Error Allocation : \"" << nodeValue <<"\""); + } + } else if (nodeValue == "rect") { + //EWOL_INFO("Find baseElement Rectangle"); + myBaseTmp = new ewol::theme::EolBaseRect(); + if (NULL == myBaseTmp) { + EWOL_ERROR("(l " << pNode->Row() << ") Error Allocation : \"" << nodeValue <<"\""); + } + } else if (nodeValue == "link") { + EWOL_WARNING("(l " << pNode->Row() << ") Not Parsed now : \"" << nodeValue <<"\""); + } else if (nodeValue == "triangle") { + EWOL_WARNING("(l " << pNode->Row() << ") Not Parsed now : \"" << nodeValue <<"\""); + } else if (nodeValue == "polygone") { + EWOL_WARNING("(l " << pNode->Row() << ") Not Parsed now : \"" << nodeValue <<"\""); + } else if (nodeValue == "circle") { + EWOL_WARNING("(l " << pNode->Row() << ") Not Parsed now : \"" << nodeValue <<"\""); + } else if (nodeValue == "circlePart") { + EWOL_WARNING("(l " << pNode->Row() << ") Not Parsed now : \"" << nodeValue <<"\""); + } else { + EWOL_ERROR("(l " << pNode->Row() << ") Node not suported : \"" << nodeValue <<"\" must be [line,rect,link,triangle,polygone,circle,circlePart]"); + } + if (NULL != myBaseTmp) { + myBaseTmp->Parse(pNode); + m_description.PushBack(myBaseTmp); + } + } + +} + + +etk::String ewol::theme::EolElementFrame::GetName(void) +{ + return m_name; +} + + +void ewol::theme::EolElementFrame::SetName(etk::String & newName) +{ + m_name = newName; +} + + +bool ewol::theme::EolElementFrame::HasName(etk::String & newName) +{ + return m_name == newName; +} + + +void ewol::theme::EolElementFrame::Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) +{ + +} + + + + + diff --git a/Sources/ewol/theme/EolElementFrame.h b/Sources/ewol/theme/EolElementFrame.h index 0e4d42c6..3fb8fcaa 100644 --- a/Sources/ewol/theme/EolElementFrame.h +++ b/Sources/ewol/theme/EolElementFrame.h @@ -32,22 +32,27 @@ #include #include #include +#include +#include +#include namespace ewol { namespace theme { class EolElementFrame { public: - EolElementFrame(void) { }; - virtual ~EolElementFrame(void) { }; - /* - void Load(etk::File & newFile) { }; - void Generate(int32_t id, int32_t frameId, OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) {}; - int32_t GetNbFrame(int32_t id) {return 0;}; - int32_t GetFrameId(int32_t id, etk::String & frameName) {return 0;}; - int32_t GetObjectId(etk::String name) { return -1; }; - */ + EolElementFrame(void); + virtual ~EolElementFrame(void); + + void Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); + + void Parse(TiXmlNode * pNode); + etk::String GetName(void); + void SetName(etk::String & newName); + bool HasName(etk::String & newName); private: + void RemoveAll(void); + etk::String m_name; etk::VectorType m_description; // all element to draw the image ... public: // acces to manage and create object ==> drawing system diff --git a/Sources/ewol/theme/Theme.cpp b/Sources/ewol/theme/Theme.cpp index 5a008fbc..4df2945c 100644 --- a/Sources/ewol/theme/Theme.cpp +++ b/Sources/ewol/theme/Theme.cpp @@ -70,11 +70,37 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme) } etk::String nodeValue = pNode->Value(); if (nodeValue == "element") { - EWOL_INFO("Find ELEMENT ... "); - // Need to call the sub parser ... - // TODO ... + //EWOL_INFO("Find ELEMENT ... "); + etk::String elementNameTmp = pNode->ToElement()->Attribute("name"); + if (elementNameTmp == "") { + EWOL_ERROR("(l " << pNode->Row() << ") Element with NO name ... (not parsed)"); + // not added it + } else { + bool findASameName = false; + // check if existed ... + for (int32_t iii=0; iii < m_listElement.Size(); iii++) { + if(NULL!=m_listElement[iii]) { + if(m_listElement[iii]->HasName(elementNameTmp) == true) { + findASameName = true; + EWOL_WARNING("(l " << pNode->Row() << ") Find a Group with the same Name : \"" << elementNameTmp <<"\""); + m_listElement[iii]->Parse(pNode); + break; + } + } + } + if (findASameName == false) { + //EWOL_DEBUG("(l " << pNode->Row() << ") Add a new Element : \"" << elementNameTmp <<"\""); + ewol::theme::EolElement * myElementTmp = new ewol::theme::EolElement(); + if (NULL != myElementTmp) { + myElementTmp->Parse(pNode); + m_listElement.PushBack(myElementTmp); + } else { + EWOL_ERROR("(l " << pNode->Row() << ") Error Allocation : \"" << nodeValue <<"\""); + } + } + } } else if (nodeValue == "group") { - EWOL_INFO("Find group ... "); + //EWOL_INFO("Find group ... "); etk::String groupNameTmp = pNode->ToElement()->Attribute("name"); if (groupNameTmp == "") { EWOL_ERROR("(l " << pNode->Row() << ") Group with NO name ... (not parsed)"); @@ -93,8 +119,8 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme) } } if (findASameName == false) { - EWOL_DEBUG("(l " << pNode->Row() << ") Add a new COLOR : \"" << groupNameTmp <<"\""); - ewol::theme::EolBase * myGroupTmp = new ewol::theme::EolBase(); + //EWOL_DEBUG("(l " << pNode->Row() << ") Add a new Group : \"" << groupNameTmp <<"\""); + ewol::theme::EolElementFrame * myGroupTmp = new ewol::theme::EolElementFrame(); if (NULL != myGroupTmp) { myGroupTmp->Parse(pNode); m_listGroup.PushBack(myGroupTmp); @@ -122,7 +148,7 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme) } } if (findASameName == false) { - EWOL_DEBUG("(l " << pNode->Row() << ") Add a new COLOR : \"" << colorNameTmp <<"\""); + //EWOL_DEBUG("(l " << pNode->Row() << ") Add a new COLOR : \"" << colorNameTmp <<"\""); ewol::theme::EolColor * myColorTmp = new ewol::theme::EolColor(); if (NULL != myColorTmp) { myColorTmp->Parse(pNode); @@ -141,23 +167,88 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme) } -void ewol::theme::Theme::Generate(int32_t id, int32_t frameId, OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) +bool ewol::theme::Theme::GetColor(etk::String colorName, color_ts & selectedColor) { - + for (int32_t iii=0; iii < m_listColor.Size(); iii++) { + if(NULL!=m_listColor[iii]) { + if(m_listColor[iii]->HasName(colorName) == true) { + selectedColor = m_listColor[iii]->Get(); + return true; + } + } + } + selectedColor.red = 0.0; + selectedColor.green = 0.0; + selectedColor.blue = 0.0; + selectedColor.alpha = 1.0; + return false; } +void ewol::theme::Theme::Generate(int32_t id, int32_t frameId, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) +{ + if (0 > id || id > m_listElement.Size()) { + return; + } + if (NULL != m_listElement[id]) { + m_listElement[id]->Generate(this, frameId, newObject, posX, posY, sizeX, sizeY); + } +} + +bool ewol::theme::Theme::GenerateGroup(etk::String groupName, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) +{ + if (groupName == "") { + EWOL_ERROR("Did not find the group name=" << groupName); + return -1; + } + for (int32_t iii=0; iii < m_listGroup.Size(); iii++) { + if(NULL!=m_listGroup[iii]) { + if(m_listGroup[iii]->HasName(groupName) == true) { + // TODO : Call Group display ... + return true; + } + } + } + return false; +} + + int32_t ewol::theme::Theme::GetNbFrame(int32_t id) { + if (0 > id || id > m_listElement.Size()) { + EWOL_ERROR("Did not find the Element id=" << id); + return 0; + } + if (NULL != m_listElement[id]) { + return m_listElement[id]->GetNbFrame(); + } return 0; } int32_t ewol::theme::Theme::GetFrameId(int32_t id, etk::String & frameName) { - return 0; + if (0 > id || id > m_listElement.Size()) { + EWOL_ERROR("Did not find the Element named=" << frameName); + return -1; + } + if (NULL != m_listElement[id]) { + return m_listElement[id]->GetFrameId(frameName); + } + return -1; } int32_t ewol::theme::Theme::GetObjectId(etk::String name) { + if (name == "") { + return -1; + } + for (int32_t iii=0; iii < m_listElement.Size(); iii++) { + if(NULL!=m_listElement[iii]) { + if(m_listElement[iii]->HasName(name) == true) { + return iii; + } + } + } + EWOL_ERROR("Did not find the Element named=" << name); return -1; } diff --git a/Sources/ewol/theme/Theme.h b/Sources/ewol/theme/Theme.h index a358054e..c78e7682 100644 --- a/Sources/ewol/theme/Theme.h +++ b/Sources/ewol/theme/Theme.h @@ -26,6 +26,12 @@ #ifndef __EWOL_EOL_THEME_H__ #define __EWOL_EOL_THEME_H__ +namespace ewol { + namespace theme { + class Theme; + class EolElement; + } +} #include #include @@ -44,14 +50,16 @@ namespace ewol { Theme(void); virtual ~Theme(void); void Load(etk::File & newFile, bool defaultTheme=false); - void Generate(int32_t id, int32_t frameId, OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); + void Generate(int32_t id, int32_t frameId, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); + bool GenerateGroup(etk::String groupName, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); + bool GetColor(etk::String colorName, color_ts & selectedColor); int32_t GetNbFrame(int32_t id); int32_t GetFrameId(int32_t id, etk::String & frameName); int32_t GetObjectId(etk::String name); private: - etk::VectorType m_listColor; - etk::VectorType m_listGroup; // TODO : we need really to star a frame here ... - etk::VectorType m_listElement; + etk::VectorType m_listColor; + etk::VectorType m_listGroup; + etk::VectorType m_listElement; public: // acces to manage and create object ==> drawing system diff --git a/dataTest/exemple.eol b/dataTest/exemple.eol index 455c381a..b50dfccf 100644 --- a/dataTest/exemple.eol +++ b/dataTest/exemple.eol @@ -13,7 +13,7 @@ position="0.53;0.56" size="0.22;0.11" /> - + internalElemStart="0.25;0.75" + internalElemStop="0.75;0.75"> - + - + - +