From eddb65de5641ed38f25829bdba7f920ffa849fb5 Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Tue, 29 Nov 2011 10:12:14 +0100 Subject: [PATCH] First dusplay EOL element with basic form ... --- Sources/Main.cpp | 2 +- Sources/ewol/theme/EolBase.cpp | 4 +++- Sources/ewol/theme/EolBase.h | 3 ++- Sources/ewol/theme/EolBaseLine.cpp | 23 +++++++++++++++++++++++ Sources/ewol/theme/EolBaseLine.h | 1 + Sources/ewol/theme/EolBaseRect.cpp | 21 +++++++++++++++++++++ Sources/ewol/theme/EolBaseRect.h | 1 + Sources/ewol/theme/EolColor.cpp | 6 +++--- Sources/ewol/theme/EolColor.h | 6 +++--- Sources/ewol/theme/EolElement.cpp | 13 +++++++------ Sources/ewol/theme/EolElement.h | 14 +++++++------- Sources/ewol/theme/EolElementFrame.cpp | 6 ++++-- Sources/ewol/theme/EolElementFrame.h | 2 +- Sources/ewol/theme/Theme.cpp | 4 ++-- Sources/ewol/theme/Theme.h | 4 ++-- Sources/ewol/themeManager.cpp | 2 +- Sources/ewol/themeManager.h | 2 +- Sources/ewol/widget/Test.cpp | 14 +++++++++++++- dataTest/exemple.eol | 15 +++++++++++++-- 19 files changed, 109 insertions(+), 34 deletions(-) diff --git a/Sources/Main.cpp b/Sources/Main.cpp index 2b7f9ae2..e39b55bf 100644 --- a/Sources/Main.cpp +++ b/Sources/Main.cpp @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) ewol::SetDefaultFont("freefont/FreeMono", 14); ewol::theme::LoadDefault("dataTest/exemple.eol"); //ewol::theme::LoadDefault("dataTest/exemple.eol"); - exit(0); + //exit(0); Plop * myWindowsExample = new Plop(); diff --git a/Sources/ewol/theme/EolBase.cpp b/Sources/ewol/theme/EolBase.cpp index ebb8dd87..bafa9863 100644 --- a/Sources/ewol/theme/EolBase.cpp +++ b/Sources/ewol/theme/EolBase.cpp @@ -22,6 +22,7 @@ ******************************************************************************* */ +#include #include #undef __class__ @@ -38,8 +39,9 @@ ewol::theme::EolBase::~EolBase(void) } - +/* void ewol::theme::EolBase::Parse(TiXmlNode * pNode) { EWOL_INFO("Element Base .. Generic ... nothing to parse..." ); } +*/ \ No newline at end of file diff --git a/Sources/ewol/theme/EolBase.h b/Sources/ewol/theme/EolBase.h index 93d58c88..166dbf91 100644 --- a/Sources/ewol/theme/EolBase.h +++ b/Sources/ewol/theme/EolBase.h @@ -39,7 +39,8 @@ namespace ewol { public: EolBase(void); virtual ~EolBase(void); - virtual void Parse(TiXmlNode * pNode); + virtual void Parse(TiXmlNode * pNode) = 0; + virtual void Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) = 0; }; }; }; diff --git a/Sources/ewol/theme/EolBaseLine.cpp b/Sources/ewol/theme/EolBaseLine.cpp index b664b6ab..af68c956 100644 --- a/Sources/ewol/theme/EolBaseLine.cpp +++ b/Sources/ewol/theme/EolBaseLine.cpp @@ -22,6 +22,7 @@ ******************************************************************************* */ +#include #include #undef __class__ @@ -76,3 +77,25 @@ void ewol::theme::EolBaseLine::Parse(TiXmlNode * pNode) } 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); } + + +void ewol::theme::EolBaseLine::Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) +{ + bool res = false; + color_ts selectedColor = {0.0, 0.0, 0.0, 1.0}; + // try get color for current element + if (NULL != myElement) { + res = myElement->GetColor(m_color, selectedColor); + } + // try from theme if not existed + if( false == res + && NULL != myTheme ) { + myElement->GetColor(m_color, selectedColor); + } + newObject.SetColor(selectedColor); + newObject.Line(posX + m_posStart.x*sizeX, posY + m_posStart.y*sizeY, posX + m_posStop.x*sizeX, posY + m_posStop.y*sizeY, m_thickness*(sizeX+sizeY)/2); +} + + + + diff --git a/Sources/ewol/theme/EolBaseLine.h b/Sources/ewol/theme/EolBaseLine.h index a100a338..d82ad5cb 100644 --- a/Sources/ewol/theme/EolBaseLine.h +++ b/Sources/ewol/theme/EolBaseLine.h @@ -43,6 +43,7 @@ namespace ewol { /> */ virtual void Parse(TiXmlNode * pNode); + virtual void Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); private: etk::String m_color; coord2D_ts m_posStart; diff --git a/Sources/ewol/theme/EolBaseRect.cpp b/Sources/ewol/theme/EolBaseRect.cpp index c02b9c35..4c3e90bc 100644 --- a/Sources/ewol/theme/EolBaseRect.cpp +++ b/Sources/ewol/theme/EolBaseRect.cpp @@ -22,6 +22,7 @@ ******************************************************************************* */ +#include #include #undef __class__ @@ -67,3 +68,23 @@ void ewol::theme::EolBaseRect::Parse(TiXmlNode * pNode) 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 << "\""); } + +void ewol::theme::EolBaseRect::Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) +{ + bool res = false; + color_ts selectedColor = {0.0, 0.0, 0.0, 1.0}; + // try get color for current element + if (NULL != myElement) { + res = myElement->GetColor(m_color, selectedColor); + } + // try from theme if not existed + if( false == res + && NULL != myTheme ) { + myElement->GetColor(m_color, selectedColor); + } + newObject.SetColor(selectedColor); + newObject.Rectangle(posX + m_position.x*sizeX, posY + m_position.y*sizeY, m_size.x*sizeX, m_size.y*sizeY); +} + + + diff --git a/Sources/ewol/theme/EolBaseRect.h b/Sources/ewol/theme/EolBaseRect.h index de721c5d..05099a52 100644 --- a/Sources/ewol/theme/EolBaseRect.h +++ b/Sources/ewol/theme/EolBaseRect.h @@ -42,6 +42,7 @@ namespace ewol { /> */ virtual void Parse(TiXmlNode * pNode); + virtual void Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); private: etk::String m_color; coord2D_ts m_position; diff --git a/Sources/ewol/theme/EolColor.cpp b/Sources/ewol/theme/EolColor.cpp index 1cb8e123..ebdc4037 100644 --- a/Sources/ewol/theme/EolColor.cpp +++ b/Sources/ewol/theme/EolColor.cpp @@ -88,7 +88,7 @@ void ewol::theme::EolColor::Parse(TiXmlNode * pNode) } -etk::String ewol::theme::EolColor::GetName(void) +etk::String ewol::theme::EolColor::GetName(void) const { return m_name; } @@ -100,13 +100,13 @@ void ewol::theme::EolColor::SetName(etk::String & newName) } -bool ewol::theme::EolColor::HasName(etk::String & newName) +bool ewol::theme::EolColor::HasName(etk::String & newName) const { return m_name == newName; } -color_ts ewol::theme::EolColor::Get(void) +color_ts ewol::theme::EolColor::Get(void) const { return m_color; } diff --git a/Sources/ewol/theme/EolColor.h b/Sources/ewol/theme/EolColor.h index 89c8c59f..29ad99ab 100644 --- a/Sources/ewol/theme/EolColor.h +++ b/Sources/ewol/theme/EolColor.h @@ -42,10 +42,10 @@ namespace ewol { virtual ~EolColor(void); void Parse(TiXmlNode * pNode); - etk::String GetName(void); + etk::String GetName(void) const; void SetName(etk::String & newName); - bool HasName(etk::String & newName); - color_ts Get(void); + bool HasName(etk::String & newName) const; + color_ts Get(void) const; void Set(color_ts newColor); void Set(etkFloat_t red, etkFloat_t green, etkFloat_t blue, etkFloat_t alpha = 1); private: diff --git a/Sources/ewol/theme/EolElement.cpp b/Sources/ewol/theme/EolElement.cpp index bd06f041..c4adc3eb 100644 --- a/Sources/ewol/theme/EolElement.cpp +++ b/Sources/ewol/theme/EolElement.cpp @@ -218,7 +218,7 @@ void ewol::theme::EolElement::Parse(TiXmlNode * root) -bool ewol::theme::EolElement::GetColor(etk::String colorName, color_ts & selectedColor) +bool ewol::theme::EolElement::GetColor(etk::String colorName, color_ts & selectedColor) const { for (int32_t iii=0; iii < m_listColor.Size(); iii++) { if(NULL!=m_listColor[iii]) { @@ -235,13 +235,13 @@ bool ewol::theme::EolElement::GetColor(etk::String colorName, color_ts & selecte return false; } -int32_t ewol::theme::EolElement::GetNbFrame(void) +int32_t ewol::theme::EolElement::GetNbFrame(void) const { return m_listElement.Size(); } -int32_t ewol::theme::EolElement::GetFrameId(etk::String & frameName) +int32_t ewol::theme::EolElement::GetFrameId(etk::String & frameName) const { for (int32_t iii=0; iii < m_listElement.Size(); iii++) { if(NULL!=m_listElement[iii]) { @@ -254,7 +254,7 @@ int32_t ewol::theme::EolElement::GetFrameId(etk::String & frameName) } -etk::String ewol::theme::EolElement::GetName(void) +etk::String ewol::theme::EolElement::GetName(void) const { return m_name; } @@ -266,13 +266,13 @@ void ewol::theme::EolElement::SetName(etk::String & newName) } -bool ewol::theme::EolElement::HasName(etk::String & newName) +bool ewol::theme::EolElement::HasName(etk::String & newName) const { 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) +void ewol::theme::EolElement::Generate(const ewol::theme::Theme * myTheme, int32_t frameId, ewol::OObject2DColored & 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); @@ -281,6 +281,7 @@ void ewol::theme::EolElement::Generate(const ewol::theme::Theme * myTheme, int32 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 0f45fa7e..100de87a 100644 --- a/Sources/ewol/theme/EolElement.h +++ b/Sources/ewol/theme/EolElement.h @@ -42,16 +42,16 @@ namespace ewol { EolElement(void); virtual ~EolElement(void); void Parse(TiXmlNode * pNode); - etk::String GetName(void); + etk::String GetName(void) const; void SetName(etk::String & newName); - bool HasName(etk::String & newName); + bool HasName(etk::String & newName) const; - 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); + void Generate(const ewol::theme::Theme * myTheme, int32_t frameId, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); + bool GenerateGroup(const ewol::theme::Theme * myTheme, etk::String groupName, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); + bool GetColor(etk::String colorName, color_ts & selectedColor) const; - int32_t GetNbFrame(void); - int32_t GetFrameId(etk::String & frameName); + int32_t GetNbFrame(void) const; + int32_t GetFrameId(etk::String & frameName) const; private: void RemoveAll(void); etk::String m_name; diff --git a/Sources/ewol/theme/EolElementFrame.cpp b/Sources/ewol/theme/EolElementFrame.cpp index 990e5f3f..a13522ec 100644 --- a/Sources/ewol/theme/EolElementFrame.cpp +++ b/Sources/ewol/theme/EolElementFrame.cpp @@ -116,9 +116,11 @@ bool ewol::theme::EolElementFrame::HasName(etk::String & 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) +void ewol::theme::EolElementFrame::Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) { - + for (int32_t iii=0; iiiGenerate(myTheme, myElement, newObject, posX, posY, sizeX, sizeY); + } } diff --git a/Sources/ewol/theme/EolElementFrame.h b/Sources/ewol/theme/EolElementFrame.h index 3fb8fcaa..bf1242af 100644 --- a/Sources/ewol/theme/EolElementFrame.h +++ b/Sources/ewol/theme/EolElementFrame.h @@ -44,7 +44,7 @@ namespace ewol { 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 Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); void Parse(TiXmlNode * pNode); etk::String GetName(void); diff --git a/Sources/ewol/theme/Theme.cpp b/Sources/ewol/theme/Theme.cpp index 4df2945c..2ef7bad7 100644 --- a/Sources/ewol/theme/Theme.cpp +++ b/Sources/ewol/theme/Theme.cpp @@ -184,7 +184,7 @@ bool ewol::theme::Theme::GetColor(etk::String colorName, color_ts & selectedColo 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) +void ewol::theme::Theme::Generate(int32_t id, int32_t frameId, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) { if (0 > id || id > m_listElement.Size()) { return; @@ -194,7 +194,7 @@ void ewol::theme::Theme::Generate(int32_t id, int32_t frameId, ewol::OObject2DTe } } -bool ewol::theme::Theme::GenerateGroup(etk::String groupName, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) +bool ewol::theme::Theme::GenerateGroup(etk::String groupName, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) { if (groupName == "") { EWOL_ERROR("Did not find the group name=" << groupName); diff --git a/Sources/ewol/theme/Theme.h b/Sources/ewol/theme/Theme.h index c78e7682..e4d0685f 100644 --- a/Sources/ewol/theme/Theme.h +++ b/Sources/ewol/theme/Theme.h @@ -50,8 +50,8 @@ namespace ewol { Theme(void); virtual ~Theme(void); void Load(etk::File & newFile, bool defaultTheme=false); - 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); + void Generate(int32_t id, int32_t frameId, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); + bool GenerateGroup(etk::String groupName, ewol::OObject2DColored & 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); diff --git a/Sources/ewol/themeManager.cpp b/Sources/ewol/themeManager.cpp index 570a55d3..d2a4c723 100644 --- a/Sources/ewol/themeManager.cpp +++ b/Sources/ewol/themeManager.cpp @@ -65,7 +65,7 @@ int32_t ewol::theme::GetObjectId(etk::String name) // ???? GetObjectType(int32_t id); -void ewol::theme::Generate(int32_t id, int32_t frameId, OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) +void ewol::theme::Generate(int32_t id, int32_t frameId, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) { if (id<0) { return; diff --git a/Sources/ewol/themeManager.h b/Sources/ewol/themeManager.h index 8336d237..18b847b5 100644 --- a/Sources/ewol/themeManager.h +++ b/Sources/ewol/themeManager.h @@ -40,7 +40,7 @@ namespace ewol { void Load(etk::File filename); // add a user theme at the list ==> this remove previous declaration by the user... int32_t GetObjectId(etk::String name); // ???? GetObjectType(int32_t id); - 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::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY); int32_t GetNbFrame(int32_t id); int32_t GetFrameId(int32_t id, etk::String & frameName); diff --git a/Sources/ewol/widget/Test.cpp b/Sources/ewol/widget/Test.cpp index 99319f04..47a8600f 100644 --- a/Sources/ewol/widget/Test.cpp +++ b/Sources/ewol/widget/Test.cpp @@ -25,6 +25,7 @@ #include #include +#include @@ -57,7 +58,9 @@ void ewol::Test::OnRegenerateDisplay(void) { // clean the object list ... ClearOObjectList(); - ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored; + ewol::OObject2DColored * tmpOObjects = NULL; + + tmpOObjects = new ewol::OObject2DColored; tmpOObjects->SetColor(1.0, 0.0, 0.0, 1.0); tmpOObjects->Rectangle( 0, 0, m_size.x, m_size.y); @@ -134,6 +137,15 @@ void ewol::Test::OnRegenerateDisplay(void) AddOObject(tmpOObjects, "BouttonDecoration"); + tmpOObjects = new ewol::OObject2DColored; + + ewol::theme::Generate(0, 0, *tmpOObjects, 50, 50, m_size.x*0.75, m_size.y*0.75); + + AddOObject(tmpOObjects, "themeObject"); + + + + // Regenerate the event Area: EventAreaRemoveAll(); coord origin; diff --git a/dataTest/exemple.eol b/dataTest/exemple.eol index b50dfccf..23ff8c33 100644 --- a/dataTest/exemple.eol +++ b/dataTest/exemple.eol @@ -5,6 +5,7 @@ + @@ -36,7 +37,8 @@ - R.R;G.G;B.B;A.A ==> in double 0<=x<=1 - &NameColor ==> search internal color of the element and after global color ... --> - + + @@ -56,10 +58,19 @@ - + +