From 100fbd43e249a4620f7c720c9b84a5739768f246 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 9 Apr 2013 21:17:47 +0200 Subject: [PATCH] [DEV] start to reworks the widget class to simplify and normalize it (last rework) --- external/etk | 2 +- sources/ewol/renderer/os/eSystem.cpp | 4 +- sources/ewol/widget/Button.cpp | 113 ++++++++----- sources/ewol/widget/Button.h | 31 +++- sources/ewol/widget/ButtonColor.cpp | 21 ++- sources/ewol/widget/ButtonColor.h | 26 ++- sources/ewol/widget/CheckBox.cpp | 31 ++-- sources/ewol/widget/CheckBox.h | 34 ++-- sources/ewol/widget/ColorBar.cpp | 3 +- sources/ewol/widget/ColorBar.h | 6 +- sources/ewol/widget/Composer.cpp | 154 +++++++++++++++--- sources/ewol/widget/Composer.h | 52 ++++-- sources/ewol/widget/ContextMenu.cpp | 27 ++-- sources/ewol/widget/ContextMenu.h | 35 ++-- sources/ewol/widget/Entry.cpp | 18 ++- sources/ewol/widget/Entry.h | 20 +-- sources/ewol/widget/Gird.cpp | 39 +++-- sources/ewol/widget/Gird.h | 7 +- sources/ewol/widget/Image.cpp | 26 +-- sources/ewol/widget/Image.h | 25 ++- sources/ewol/widget/Joystick.cpp | 5 +- sources/ewol/widget/Joystick.h | 8 +- sources/ewol/widget/Label.cpp | 30 +++- sources/ewol/widget/Label.h | 11 +- sources/ewol/widget/Layer.cpp | 56 +++---- sources/ewol/widget/Layer.h | 22 ++- sources/ewol/widget/List.cpp | 3 +- sources/ewol/widget/List.h | 12 +- sources/ewol/widget/Menu.cpp | 2 +- sources/ewol/widget/Menu.h | 21 ++- sources/ewol/widget/PopUp.cpp | 24 +-- sources/ewol/widget/PopUp.h | 15 +- sources/ewol/widget/ProgressBar.cpp | 21 ++- sources/ewol/widget/ProgressBar.h | 21 +-- sources/ewol/widget/Sizer.cpp | 63 ++++---- sources/ewol/widget/Sizer.h | 27 ++-- sources/ewol/widget/Slider.cpp | 21 ++- sources/ewol/widget/Slider.h | 22 +-- sources/ewol/widget/Spacer.cpp | 20 ++- sources/ewol/widget/Spacer.h | 17 +- sources/ewol/widget/Widget.cpp | 197 ++++++++++++++++------- sources/ewol/widget/Widget.h | 213 ++++++++++++------------- sources/ewol/widget/WidgetManager.cpp | 116 +++++++++++++- sources/ewol/widget/WidgetManager.h | 36 +++-- sources/ewol/widget/Windows.cpp | 13 +- sources/ewol/widget/Windows.h | 10 +- sources/ewol/widget/meta/FileChooser.h | 4 +- sources/file.mk | 1 + 48 files changed, 1066 insertions(+), 619 deletions(-) diff --git a/external/etk b/external/etk index 64812713..f9951e9f 160000 --- a/external/etk +++ b/external/etk @@ -1 +1 @@ -Subproject commit 64812713c7bfa87ab1f3368cf58cca7d6d996007 +Subproject commit f9951e9f5566eca104348a1bbf84f5721f5ce63d diff --git a/sources/ewol/renderer/os/eSystem.cpp b/sources/ewol/renderer/os/eSystem.cpp index f4e4938e..ce54a63e 100644 --- a/sources/ewol/renderer/os/eSystem.cpp +++ b/sources/ewol/renderer/os/eSystem.cpp @@ -576,8 +576,8 @@ void eSystem::ForceRedrawAll(void) { ewol::Windows* tmpWindows = eSystem::GetCurrentWindows(); if (NULL != tmpWindows) { - ivec2 tmpSize = eSystem::GetSize(); - tmpWindows->CalculateSize(tmpSize.x(), tmpSize.y()); + ivec2 systemSize = eSystem::GetSize(); + tmpWindows->CalculateSize(vec2(systemSize.x(), systemSize.y())); } } diff --git a/sources/ewol/widget/Button.cpp b/sources/ewol/widget/Button.cpp index e8f78b66..0f5848ba 100644 --- a/sources/ewol/widget/Button.cpp +++ b/sources/ewol/widget/Button.cpp @@ -29,6 +29,23 @@ extern const char * const ewolEventButtonValue = "ewol-button-value"; #define STATUS_DOWN (3) +static ewol::Widget* Create(void) +{ + return new widget::Button(); +} + +void widget::Button::Init(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,&Create); +} + +void widget::Button::UnInit(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,NULL); +} + + + widget::Button::Button(const etk::UString& shaperName) : m_shaper(shaperName), m_toggleMode(false), @@ -68,16 +85,9 @@ void widget::Button::SetShaperName(const etk::UString& shaperName) m_shaper.SetSource(shaperName); } -void widget::Button::SetSubWidget(ewol::Widget* subWidget, bool forToggle) +void widget::Button::SetSubWidget(ewol::Widget* subWidget) { - if (subWidget==NULL) { - EWOL_WARNING("try to set an empty widget in the Button entity"); - return; - } int32_t idWidget=0; - if (forToggle==true) { - idWidget = 1; - } if (NULL!=m_subWidget[idWidget]) { delete(m_subWidget[idWidget]); // the pointer might already set at NULL: @@ -91,17 +101,36 @@ void widget::Button::SetSubWidget(ewol::Widget* subWidget, bool forToggle) // element change ... We need to recalculate all the subElments : ewol::RequestUpdateSize(); } -ewol::Widget* widget::Button::GetSubWidget(bool fromToggle) + +void widget::Button::SetSubWidgetToggle(ewol::Widget* subWidget) { - int32_t idWidget=0; - if (fromToggle==true) { - idWidget = 1; + int32_t idWidget=1; + if (NULL!=m_subWidget[idWidget]) { + delete(m_subWidget[idWidget]); + // the pointer might already set at NULL: + if (NULL != m_subWidget[idWidget]) { + EWOL_ERROR("error while removing previous widget..."); + m_subWidget[idWidget]=NULL; + } } - return m_subWidget[idWidget]; + EWOL_DEBUG("Add button : " << idWidget << " element : " << (int64_t)subWidget); + m_subWidget[idWidget] = subWidget; + // element change ... We need to recalculate all the subElments : + ewol::RequestUpdateSize(); +} + +ewol::Widget* widget::Button::GetSubWidget(void) +{ + return m_subWidget[0]; +} + +ewol::Widget* widget::Button::GetSubWidgetToggle(void) +{ + return m_subWidget[1]; } -bool widget::Button::CalculateSize(float availlableX, float availlableY) +void widget::Button::CalculateSize(const vec2& availlable) { vec2 padding = m_shaper.GetPadding(); // set minimal size @@ -111,10 +140,10 @@ bool widget::Button::CalculateSize(float availlableX, float availlableY) vec2 minimumSizeToggle(0,0); // Checking the expend properties : if (m_userExpend.x() == true) { - m_size.setX(availlableX); + m_size.setX(availlable.x()); } if (m_userExpend.y() == true) { - m_size.setY(availlableY); + m_size.setY(availlable.y()); } // Checkin the filling properties ==> for the subElements: vec2 subElementSize = m_minSize; @@ -127,22 +156,21 @@ bool widget::Button::CalculateSize(float availlableX, float availlableY) vec2 origin = (m_size - subElementSize)/2.0f + padding; subElementSize -= padding*2.0f; if (NULL!=m_subWidget[0]) { - m_subWidget[0]->SetOrigin(m_origin.x()+origin.x(), m_origin.y()+origin.y()); - m_subWidget[0]->CalculateSize(subElementSize.x(), subElementSize.y()); + m_subWidget[0]->SetOrigin(m_origin+origin); + m_subWidget[0]->CalculateSize(subElementSize); } if (NULL!=m_subWidget[1]) { - m_subWidget[1]->SetOrigin(m_origin.x()+origin.x(), m_origin.y()+origin.y()); - m_subWidget[1]->CalculateSize(subElementSize.x(), subElementSize.y()); + m_subWidget[1]->SetOrigin(m_origin+origin); + m_subWidget[1]->CalculateSize(subElementSize); } //EWOL_DEBUG(" configuring : origin=" << origin << " size=" << subElementSize << ""); m_selectableAreaSize = subElementSize + (padding*2.0f); m_selectableAreaPos = origin-padding; MarkToRedraw(); - return true; } -bool widget::Button::CalculateMinSize(void) +void widget::Button::CalculateMinSize(void) { vec2 padding = m_shaper.GetPadding(); vec2 minimumSizeBase(0,0); @@ -164,7 +192,6 @@ bool widget::Button::CalculateMinSize(void) // verify the min max of the min size ... CheckMinSize(); MarkToRedraw(); - return true; } void widget::Button::OnDraw(ewol::DrawProperty& displayProp) @@ -189,10 +216,10 @@ void widget::Button::OnRegenerateDisplay(void) if (true == NeedRedraw()) { vec2 padding = m_shaper.GetPadding(); m_shaper.Clear(); - m_shaper.SetOrigin(m_selectableAreaPos); - m_shaper.SetSize(m_selectableAreaSize); - m_shaper.SetInsidePos(m_selectableAreaPos+padding ); - m_shaper.SetInsideSize(m_selectableAreaSize-padding*2.0f); + m_shaper.SetOrigin(vec2ClipInt32(m_selectableAreaPos)); + m_shaper.SetSize(vec2ClipInt32(m_selectableAreaSize)); + m_shaper.SetInsidePos(vec2ClipInt32(m_selectableAreaPos+padding)); + m_shaper.SetInsideSize(vec2ClipInt32(m_selectableAreaSize-padding*2.0f)); } if( false == m_toggleMode || false == m_value) { @@ -227,6 +254,7 @@ void widget::Button::SetToggleMode(bool togg) m_value = false; // TODO : Change display and send event ... } + CheckStatus(); MarkToRedraw(); } } @@ -286,19 +314,7 @@ bool widget::Button::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, } if( m_mouseHover != previousHoverState || m_buttonPressed != previousPressed) { - if (true==m_buttonPressed) { - ChangeStatusIn(STATUS_PRESSED); - } else { - if (true==m_mouseHover) { - ChangeStatusIn(STATUS_HOVER); - } else { - if (true == m_value) { - ChangeStatusIn(STATUS_DOWN); - } else { - ChangeStatusIn(STATUS_UP); - } - } - } + CheckStatus(); } return m_mouseHover; } @@ -314,7 +330,22 @@ bool widget::Button::OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t un return false; } - +void widget::Button::CheckStatus(void) +{ + if (true==m_buttonPressed) { + ChangeStatusIn(STATUS_PRESSED); + } else { + if (true==m_mouseHover) { + ChangeStatusIn(STATUS_HOVER); + } else { + if (true == m_value) { + ChangeStatusIn(STATUS_DOWN); + } else { + ChangeStatusIn(STATUS_UP); + } + } + } +} void widget::Button::ChangeStatusIn(int32_t newStatusId) { diff --git a/sources/ewol/widget/Button.h b/sources/ewol/widget/Button.h index 7ef00f94..5dfcf03b 100644 --- a/sources/ewol/widget/Button.h +++ b/sources/ewol/widget/Button.h @@ -31,6 +31,9 @@ namespace widget { */ class Button : public ewol::Widget { + public: + static void Init(void); + static void UnInit(void); private: ewol::Shaper m_shaper; //!< Compositing theme. ewol::Widget* m_subWidget[2]; //!< subwidget of the button @@ -58,15 +61,25 @@ namespace widget { */ void SetShaperName(const etk::UString& shaperName); /** - * @brief Specify the current composition string - * @param[in] newLabel The string that might be displayed + * @brief Specify the current widget + * @param[in] subWidget Widget to add normal */ - void SetSubWidget(ewol::Widget* subWidget, bool forToggle=false); + void SetSubWidget(ewol::Widget* subWidget); + /** + * @brief Specify the current widget + * @param[in] subWidget Widget to add Toggle + */ + void SetSubWidgetToggle(ewol::Widget* subWidget); /** * @brief Get the current displayed composition - * @return The displayed string. + * @return The base widget */ - ewol::Widget* GetSubWidget(bool fromToggle=false); + ewol::Widget* GetSubWidget(void); + /** + * @brief Get the current displayed composition + * @return The toggle widget + */ + ewol::Widget* GetSubWidgetToggle(void); /** * @brief Set the currentValue of the Button (pressed or not) * @note Work only in toggle mode @@ -90,11 +103,15 @@ namespace widget { * @param[in] new state */ void ChangeStatusIn(int32_t newStatusId); + /** + * @brief update the status with the internal satte of the button ... + */ + void CheckStatus(void); public: // Derived function virtual const char * const GetObjectType(void) { return "widget::Button"; }; - virtual bool CalculateMinSize(void); - virtual bool CalculateSize(float availlableX, float availlableY); + virtual void CalculateMinSize(void); + virtual void CalculateSize(const vec2& availlable); virtual void OnRegenerateDisplay(void); virtual void OnDraw(ewol::DrawProperty& displayProp); virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos); diff --git a/sources/ewol/widget/ButtonColor.cpp b/sources/ewol/widget/ButtonColor.cpp index e51aba77..bfb0c5ae 100644 --- a/sources/ewol/widget/ButtonColor.cpp +++ b/sources/ewol/widget/ButtonColor.cpp @@ -28,6 +28,24 @@ extern const char * const ewolEventButtonColorChange = "ewol-Button-Color-Cha #undef __class__ #define __class__ "ButtonColor" + + +static ewol::Widget* Create(void) +{ + return new widget::ButtonColor(); +} + +void widget::ButtonColor::Init(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,&Create); +} + +void widget::ButtonColor::UnInit(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,NULL); +} + + widget::ButtonColor::ButtonColor(draw::Color baseColor, etk::UString shaperName) : m_shaper(shaperName), m_textColorFg(baseColor), @@ -53,7 +71,7 @@ void widget::ButtonColor::SetShaperName(etk::UString shaperName) } -bool widget::ButtonColor::CalculateMinSize(void) +void widget::ButtonColor::CalculateMinSize(void) { vec2 padding = m_shaper.GetPadding(); etk::UString label = draw::GetString(m_textColorFg); @@ -61,7 +79,6 @@ bool widget::ButtonColor::CalculateMinSize(void) m_minSize.setX(padding.x()*2 + minSize.x() + 7); m_minSize.setY(padding.y()*2 + minSize.y() ); MarkToRedraw(); - return true; } diff --git a/sources/ewol/widget/ButtonColor.h b/sources/ewol/widget/ButtonColor.h index e56ba266..fd729d23 100644 --- a/sources/ewol/widget/ButtonColor.h +++ b/sources/ewol/widget/ButtonColor.h @@ -22,16 +22,19 @@ extern const char * const ewolEventButtonColorChange; namespace widget { class ButtonColor : public ewol::Widget { + public: + static void Init(void); + static void UnInit(void); private: - ewol::Shaper m_shaper; //!< Compositing theme. - ewol::Text m_text; //!< Compositing Test display. - draw::Color m_textColorFg; //!< Current color. - widget::ContextMenu* m_widgetContextMenu; //!< Specific context menu. - bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). - bool m_buttonPressed; //!< Flag to know if the button is curently pressed. + ewol::Shaper m_shaper; //!< Compositing theme. + ewol::Text m_text; //!< Compositing Test display. + draw::Color m_textColorFg; //!< Current color. + widget::ContextMenu* m_widgetContextMenu; //!< Specific context menu. + bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). + bool m_buttonPressed; //!< Flag to know if the button is curently pressed. // hover area : - vec2 m_selectableAreaPos; //!< Start position of the events - vec2 m_selectableAreaSize; //!< Size of the event positions + vec2 m_selectableAreaPos; //!< Start position of the events + vec2 m_selectableAreaSize; //!< Size of the event positions public: /** * @brief Main constructor. @@ -60,16 +63,11 @@ namespace widget { void SetValue(draw::Color color); public: // Derived function - virtual bool CalculateMinSize(void); - // Derived function + virtual void CalculateMinSize(void); virtual const char * const GetObjectType(void) { return "widget::ButtonColor"; }; - // Derived function virtual void OnRegenerateDisplay(void); - // Derived function virtual void OnDraw(ewol::DrawProperty& displayProp); - // Derived function virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos); - // Derived function virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data); private: /** diff --git a/sources/ewol/widget/CheckBox.cpp b/sources/ewol/widget/CheckBox.cpp index f520ded9..72eeb507 100644 --- a/sources/ewol/widget/CheckBox.cpp +++ b/sources/ewol/widget/CheckBox.cpp @@ -15,9 +15,25 @@ extern const char * const ewolEventCheckBoxClicked = "ewol CheckBox Clicked"; #undef __class__ #define __class__ "CheckBox" +static ewol::Widget* Create(void) +{ + return new widget::CheckBox(); +} void widget::CheckBox::Init(void) { + ewol::widgetManager::AddWidgetCreator(__class__,&Create); +} + +void widget::CheckBox::UnInit(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,NULL); +} + + +widget::CheckBox::CheckBox(const etk::UString& newLabel) +{ + m_label = newLabel; AddEventId(ewolEventCheckBoxClicked); m_textColorFg = draw::color::black; m_textColorBg = draw::color::white; @@ -26,18 +42,6 @@ void widget::CheckBox::Init(void) SetMouseLimit(1); } -widget::CheckBox::CheckBox(void) -{ - m_label = "No Label"; - Init(); -} - -widget::CheckBox::CheckBox(etk::UString newLabel) -{ - m_label = newLabel; - Init(); -} - widget::CheckBox::~CheckBox(void) { @@ -45,14 +49,13 @@ widget::CheckBox::~CheckBox(void) } -bool widget::CheckBox::CalculateMinSize(void) +void widget::CheckBox::CalculateMinSize(void) { vec3 minSize = m_oObjectText.CalculateSize(m_label); float boxSize = etk_max(20, minSize.y()) + 5; m_minSize.setX(boxSize+minSize.x()); m_minSize.setY(etk_max(boxSize, minSize.y())+3); MarkToRedraw(); - return true; } diff --git a/sources/ewol/widget/CheckBox.h b/sources/ewol/widget/CheckBox.h index 53188302..9155d51b 100644 --- a/sources/ewol/widget/CheckBox.h +++ b/sources/ewol/widget/CheckBox.h @@ -21,32 +21,28 @@ namespace widget { class CheckBox : public ewol::Widget { public: - CheckBox(void); - CheckBox(etk::UString newLabel); - // Derived function - virtual const char * const GetObjectType(void) { return "EwolCheckBox"; }; - void Init(void); + static void Init(void); + static void UnInit(void); + public: + CheckBox(const etk::UString& newLabel = "No Label"); virtual ~CheckBox(void); - // Derived function - virtual bool CalculateMinSize(void); - void SetLabel(etk::UString newLabel); - void SetValue(bool val); - bool GetValue(void); + void SetLabel(etk::UString newLabel); + void SetValue(bool val); + bool GetValue(void); private: - ewol::Text m_oObjectText; - ewol::Drawing m_oObjectDecoration; - etk::UString m_label; - bool m_value; - draw::Color m_textColorFg; //!< Text color - draw::Color m_textColorBg; //!< Background color + ewol::Text m_oObjectText; + ewol::Drawing m_oObjectDecoration; + etk::UString m_label; + bool m_value; + draw::Color m_textColorFg; //!< Text color + draw::Color m_textColorBg; //!< Background color public: // Derived function + virtual const char * const GetObjectType(void) { return "Ewol::CheckBox"; }; + virtual void CalculateMinSize(void); virtual void OnRegenerateDisplay(void); - // Derived function virtual void OnDraw(ewol::DrawProperty& displayProp); - // Derived function virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos); - // Derived function virtual bool OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData); }; diff --git a/sources/ewol/widget/ColorBar.cpp b/sources/ewol/widget/ColorBar.cpp index c0785f83..bf8eacd5 100644 --- a/sources/ewol/widget/ColorBar.cpp +++ b/sources/ewol/widget/ColorBar.cpp @@ -35,11 +35,10 @@ widget::ColorBar::~ColorBar(void) } -bool widget::ColorBar::CalculateMinSize(void) +void widget::ColorBar::CalculateMinSize(void) { m_minSize.setValue(160, 80); MarkToRedraw(); - return true; } static draw::Color s_listColorWhite(0xFFFFFFFF); static draw::Color s_listColorBlack(0x000000FF); diff --git a/sources/ewol/widget/ColorBar.h b/sources/ewol/widget/ColorBar.h index 31b232e2..a9fa1c17 100644 --- a/sources/ewol/widget/ColorBar.h +++ b/sources/ewol/widget/ColorBar.h @@ -32,13 +32,9 @@ namespace widget { public: // Derived function virtual const char * const GetObjectType(void) { return "widget::ColorBar"; }; - // Derived function - virtual bool CalculateMinSize(void); - // Derived function + virtual void CalculateMinSize(void); virtual void OnRegenerateDisplay(void); - // Derived function virtual void OnDraw(ewol::DrawProperty& displayProp); - // Derived function virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos); }; diff --git a/sources/ewol/widget/Composer.cpp b/sources/ewol/widget/Composer.cpp index b939f0d5..639c1589 100644 --- a/sources/ewol/widget/Composer.cpp +++ b/sources/ewol/widget/Composer.cpp @@ -8,25 +8,28 @@ #include -#include +#include +#include +#include -/* - ewol::Widget* m_widget; - etk::UString composerString; - etk::Vector m_list; -*/ -widget::XmlComposer::XmlComposer(const etk::UString& composerXmlString) +widget::Composer::Composer(void) : + m_subWidget(NULL) { - // TODO ... + // nothing to do ... } -widget::XmlComposer::~XmlComposer(void) +widget::Composer::~Composer(void) { - if (NULL != m_widget) { - delete(m_widget); + Clean(); +} + +void widget::Composer::Clean(void) +{ + if (NULL != m_subWidget) { + delete(m_subWidget); // might have been destroy first here : - if (m_widget!=NULL) { + if (m_subWidget!=NULL) { EWOL_ERROR("Composer : An error Occured when removing main node"); } } @@ -36,13 +39,99 @@ widget::XmlComposer::~XmlComposer(void) } } -ewol::Widget* widget::XmlComposer::GetMainWidget(void) + +bool widget::Composer::LoadFromFile(const etk::UString& _fileName) { - // nothing else to do ... - return m_widget; + // open the curent File + etk::FSNode fileName(_fileName); + if (false == fileName.Exist()) { + EWOL_ERROR("File Does not exist : " << fileName); + return false; + } + int32_t fileSize = fileName.FileSize(); + if (0==fileSize) { + EWOL_ERROR("This file is empty : " << fileName); + return false; + } + if (false == fileName.FileOpenRead()) { + EWOL_ERROR("Can not open the file : " << fileName); + return false; + } + // allocate data + char * fileBuffer = new char[fileSize+5]; + if (NULL == fileBuffer) { + EWOL_ERROR("Error Memory allocation size=" << fileSize); + return false; + } + memset(fileBuffer, 0, (fileSize+5)*sizeof(char)); + // load data from the file : + fileName.FileRead(fileBuffer, 1, fileSize); + // close the file: + fileName.FileClose(); + + bool ret = CommonLoadXML((const char*)fileBuffer); + + if (NULL != fileBuffer) { + delete[] fileBuffer; + } + return ret; } -ewol::Widget* widget::XmlComposer::GetWidgetNamed(const etk::UString& widgetName) +bool widget::Composer::LoadFromString(const etk::UString& composerXmlString) +{ + etk::Char tmpData = composerXmlString.c_str(); + return CommonLoadXML(tmpData); +} + +bool widget::Composer::CommonLoadXML(const char* data) +{ + if (NULL==data) { + return false; + } + TiXmlDocument XmlDocument; + // load the XML from the memory + XmlDocument.Parse(data, 0, TIXML_ENCODING_UTF8); + + TiXmlElement* root = XmlDocument.FirstChildElement("composer"); + if (NULL == root ) { + EWOL_ERROR("(l ?) main node not find: \"composer\" ..."); + return false; + } + // remove previous elements ... + Clean(); + ewol::Widget::LoadXML(root); + + for(TiXmlNode * pNode = root->FirstChild() ; + NULL != pNode ; + pNode = pNode->NextSibling() ) { + if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) { + // nothing to do, just proceed to next step + continue; + } + etk::UString widgetName = pNode->Value(); + if (ewol::widgetManager::Exist(widgetName) == false) { + EWOL_ERROR("(l "<Row()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << ewol::widgetManager::List() << "]" ); + continue; + } + if (NULL != m_subWidget) { + EWOL_ERROR("(l "<Row()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" ); + continue; + } + ewol::Widget* tmpWidget = ewol::widgetManager::Create(widgetName); + if (tmpWidget == NULL) { + EWOL_ERROR ("(l "<Row()<<") Can not create the widget : \"" << widgetName << "\""); + continue; + } + if (false == tmpWidget->LoadXML(pNode)) { + EWOL_ERROR ("(l "<Row()<<") can not load widget properties : \"" << widgetName << "\""); + return false; + } + } + return true; +} + + +ewol::Widget* widget::Composer::GetWidgetNamed(const etk::UString& widgetName) { for (int32_t iii=0; iiiGenDraw(displayProp); + } +} + +void widget::Composer::CalculateSize(const vec2& availlable) +{ + if (NULL!=m_subWidget) { + m_subWidget->CalculateSize(availlable); + // copy all sub parameters: + m_hide = m_subWidget->IsHide(); + } +} +void widget::Composer::CalculateMinSize(void) +{ + if (NULL!=m_subWidget) { + m_subWidget->CalculateMinSize(); + // copy all sub parameters : + m_hide = m_subWidget->IsHide(); + m_userFill = m_subWidget->CanFill(); + + } } diff --git a/sources/ewol/widget/Composer.h b/sources/ewol/widget/Composer.h index c452be9d..176a3f18 100644 --- a/sources/ewol/widget/Composer.h +++ b/sources/ewol/widget/Composer.h @@ -6,8 +6,8 @@ * @license BSD v3 (see license file) */ -#ifndef __EWOL_XML_COMPOSER_H__ -#define __EWOL_XML_COMPOSER_H__ +#ifndef __EWOL_WIDGET_COMPOSER_H__ +#define __EWOL_WIDGET_COMPOSER_H__ #include #include @@ -15,26 +15,54 @@ namespace widget { - class XmlComposer : public ewol::EObject + /** + * @brief the composer widget is a widget that create a link on a string.file to parse the data and generate some widget tree + */ + class Composer : public ewol::Widget { private: class ComposerWidgetListNamed { public: ewol::Widget* widget; etk::UString widgetName; - } - ewol::Widget* m_widget; - etk::UString composerString; + }; + ewol::Widget* m_subWidget; etk::Vector m_list; public: /** * @brief Constructor */ - XmlComposer(const etk::UString& composerXmlString); + Composer(void); /** * @brief Destructor */ - ~XmlComposer(void); + ~Composer(void); + /** + * @brief Remove all sub elements + */ + void Clean(void); + /** + * @brief Load a composition with a file + * @param[in] fileName Name of the file + * @return true ==> all done OK + * @return false ==> some error occured + */ + bool LoadFromFile(const etk::UString& fileName); + /** + * @brief Load a composition with a file + * @param[in] composerXmlString xml to parse directly + * @return true ==> all done OK + * @return false ==> some error occured + */ + bool LoadFromString(const etk::UString& composerXmlString); + private: + /** + * @brief Load a composition with a file. + * @param[in] data pointer on the file data. + * @return true ==> all done OK. + * @return false ==> some error occured. + */ + bool CommonLoadXML(const char* data); public: /** * @brief Get the main node widget @@ -48,9 +76,13 @@ namespace widget */ ewol::Widget* GetWidgetNamed(const etk::UString& widgetName); - public: - // herited function : + protected: // Derived function + virtual void OnDraw(ewol::DrawProperty& displayProp); + public:// Derived function virtual void OnObjectRemove(ewol::EObject* removeObject); + virtual void CalculateSize(const vec2& availlable); + virtual void CalculateMinSize(void); + // TODO : Call all sub element getter an setter ==> this object might be transparent ... }; }; diff --git a/sources/ewol/widget/ContextMenu.cpp b/sources/ewol/widget/ContextMenu.cpp index a8f00f3a..56b9480a 100644 --- a/sources/ewol/widget/ContextMenu.cpp +++ b/sources/ewol/widget/ContextMenu.cpp @@ -37,20 +37,20 @@ widget::ContextMenu::~ContextMenu(void) } -bool widget::ContextMenu::CalculateSize(float availlableX, float availlableY) +void widget::ContextMenu::CalculateSize(const vec2& availlable) { - EWOL_DEBUG("CalculateSize(" << availlableX << "," << availlableY << ")"); + //EWOL_DEBUG("CalculateSize=" << availlable); // pop-up fill all the display : - m_size.setValue(availlableX, availlableY); + m_size = availlable; if (NULL != m_subWidget) { vec2 subWidgetSize; vec2 subWidgetOrigin; subWidgetSize = m_subWidget->GetMinSize(); - if (true == m_subWidget->CanExpentX()) { + if (true == m_subWidget->CanExpand().x()) { subWidgetSize.setX(m_size.x()); } - if (true == m_subWidget->CanExpentY()) { + if (true == m_subWidget->CanExpand().y()) { subWidgetSize.setY(m_size.y()); } int32_t minWidth = 100; @@ -98,15 +98,14 @@ bool widget::ContextMenu::CalculateSize(float availlableX, float availlableY) } break; } - m_subWidget->SetOrigin(subWidgetOrigin.x(), subWidgetOrigin.y()); - m_subWidget->CalculateSize(subWidgetSize.x(), subWidgetSize.y()); + m_subWidget->SetOrigin(subWidgetOrigin); + m_subWidget->CalculateSize(subWidgetSize); } MarkToRedraw(); - return true; } -bool widget::ContextMenu::CalculateMinSize(void) +void widget::ContextMenu::CalculateMinSize(void) { EWOL_DEBUG("CalculateMinSize"); m_userExpend.setValue(false,false); @@ -117,24 +116,18 @@ bool widget::ContextMenu::CalculateMinSize(void) } EWOL_DEBUG("CalculateMinSize=>>" << m_minSize); MarkToRedraw(); - return true; } -void widget::ContextMenu::SetMinSise(float x, float y) +void widget::ContextMenu::SetMinSize(const vec2& size) { EWOL_ERROR("Pop-up can not have a user Minimum size (herited from under elements)"); } -void widget::ContextMenu::SetExpendX(bool newExpend) +void widget::ContextMenu::SetExpand(const bvec2& newExpend) { EWOL_ERROR("Pop-up can not have a user expend settings X (herited from under elements)"); } -void widget::ContextMenu::SetExpendY(bool newExpend) -{ - EWOL_ERROR("Pop-up can not have a user expend settings Y (herited from under elements)"); -} - void widget::ContextMenu::SubWidgetSet(ewol::Widget* newWidget) { diff --git a/sources/ewol/widget/ContextMenu.h b/sources/ewol/widget/ContextMenu.h index e692bb50..c4f1ef97 100644 --- a/sources/ewol/widget/ContextMenu.h +++ b/sources/ewol/widget/ContextMenu.h @@ -31,32 +31,29 @@ namespace widget { // Derived function virtual const char * const GetObjectType(void) { return "EwolContextMenu"; }; public: - virtual bool CalculateSize(float availlableX, float availlableY); // this generate the current size ... - virtual bool CalculateMinSize(void); //update the min Size ... and the expend parameters for the sizer - virtual void SetMinSise(float x=-1, float y=-1); - virtual void SetExpendX(bool newExpend=false); - virtual void SetExpendY(bool newExpend=false); + virtual void CalculateSize(const vec2& availlable); // this generate the current size ... + virtual void CalculateMinSize(void); //update the min Size ... and the expend parameters for the sizer + virtual void SetMinSize(const vec2& size); + virtual void SetExpand(const bvec2& newExpend); private: - draw::Color m_colorBackGroung; - draw::Color m_colorBorder; - vec2 m_padding; - vec2 m_arrowPos; - float m_offset; + draw::Color m_colorBackGroung; + draw::Color m_colorBorder; + vec2 m_padding; + vec2 m_arrowPos; + float m_offset; markPosition_te m_arrawBorder; - ewol::Widget* m_subWidget; + ewol::Widget* m_subWidget; public: - void SubWidgetSet(ewol::Widget* newWidget); - void SubWidgetRemove(void); - void SetPositionMark(markPosition_te position, vec2 arrowPos); + void SubWidgetSet(ewol::Widget* newWidget); + void SubWidgetRemove(void); + void SetPositionMark(markPosition_te position, vec2 arrowPos); protected: // Derived function - virtual void OnDraw(ewol::DrawProperty& displayProp); + virtual void OnDraw(ewol::DrawProperty& displayProp); public: // Derived function - virtual void OnRegenerateDisplay(void); - // Derived function - virtual ewol::Widget * GetWidgetAtPos(vec2 pos); - // Derived function + virtual void OnRegenerateDisplay(void); + virtual ewol::Widget* GetWidgetAtPos(vec2 pos); virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos); }; diff --git a/sources/ewol/widget/Entry.cpp b/sources/ewol/widget/Entry.cpp index d267f688..9bdff35e 100644 --- a/sources/ewol/widget/Entry.cpp +++ b/sources/ewol/widget/Entry.cpp @@ -31,6 +31,21 @@ const char * const ewolEventEntrySelect = "ewol-Entry-Select"; #define STATUS_HOVER (1) #define STATUS_SELECTED (2) +static ewol::Widget* Create(void) +{ + return new widget::Entry(); +} + +void widget::Entry::Init(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,&Create); +} + +void widget::Entry::UnInit(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,NULL); +} + widget::Entry::Entry(etk::UString newData) : m_shaper("THEME:GUI:widgetEntry.conf"), @@ -66,7 +81,7 @@ widget::Entry::~Entry(void) } -bool widget::Entry::CalculateMinSize(void) +void widget::Entry::CalculateMinSize(void) { vec2 padding = m_shaper.GetPadding(); @@ -75,7 +90,6 @@ bool widget::Entry::CalculateMinSize(void) minHeight + 2*padding.y()); UpdateTextPosition(); MarkToRedraw(); - return true; } diff --git a/sources/ewol/widget/Entry.h b/sources/ewol/widget/Entry.h index bf9ce666..3ad8ac40 100644 --- a/sources/ewol/widget/Entry.h +++ b/sources/ewol/widget/Entry.h @@ -33,6 +33,9 @@ namespace widget { */ class Entry : public ewol::Widget { + public: + static void Init(void); + static void UnInit(void); private: ewol::Shaper m_shaper; ewol::Text m_oObjectText; //!< text display @@ -54,29 +57,22 @@ namespace widget { * @brief Destuctor */ virtual ~Entry(void); - // Derived function - virtual const char * const GetObjectType(void) { return "EwolEntry"; }; - // Derived function - virtual bool CalculateMinSize(void); - void SetValue(etk::UString newData); - etk::UString GetValue(void); - void SetWidth(int32_t width) + void SetValue(etk::UString newData); + etk::UString GetValue(void); + void SetWidth(int32_t width) { m_userSize = width; } public: // Derived function virtual void OnRegenerateDisplay(void); - // Derived function virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos); - // Derived function virtual bool OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData); - // Derived function virtual bool OnEventKbMove(ewol::keyEvent::status_te typeEvent, ewol::keyEvent::keyboard_te moveTypeEvent); - // Derived function virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data); - // Derived function virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID); + virtual const char * const GetObjectType(void) { return "EwolEntry"; }; + virtual void CalculateMinSize(void); protected: // Derived function virtual void OnDraw(ewol::DrawProperty& displayProp); diff --git a/sources/ewol/widget/Gird.cpp b/sources/ewol/widget/Gird.cpp index 2e0cfa65..b7464a92 100644 --- a/sources/ewol/widget/Gird.cpp +++ b/sources/ewol/widget/Gird.cpp @@ -15,11 +15,27 @@ #define __class__ "Gird" +static ewol::Widget* Create(void) +{ + return new widget::Gird(); +} + +void widget::Gird::Init(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,&Create); +} + +void widget::Gird::UnInit(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,NULL); +} + + widget::Gird::Gird(int32_t colNumber) : - m_tmpWidget(NULL), m_sizeRow(0), - m_borderSize(0,0), - m_gavityButtom(true) + m_tmpWidget(NULL), + m_gavityButtom(true), + m_borderSize(0,0) { SetColNumber(colNumber); ewol::RequestUpdateSize(); @@ -46,15 +62,11 @@ void widget::Gird::SetBorderSize(const ivec2& newBorderSize) ewol::RequestUpdateSize(); } -bool widget::Gird::CalculateSize(float availlableX, float availlableY) +void widget::Gird::CalculateSize(const vec2& availlable) { //EWOL_DEBUG("Update Size"); - m_size.setValue(availlableX, availlableY); + m_size = availlable; m_size -= m_borderSize*2; - // calculate unExpendable Size : - float unexpendableSize=0.0; - int32_t nbWidgetFixedSize=0; - int32_t nbWidgetNotFixedSize=0; for (int32_t iii=0; iii0) { m_imageSize = size; } @@ -57,12 +66,11 @@ void widget::Image::SetPadding(vec2 newPadding) m_padding = newPadding; } -bool widget::Image::CalculateMinSize(void) +void widget::Image::CalculateMinSize(void) { m_minSize.setValue(m_padding.x()*2 + m_imageSize, m_padding.y()*2 + m_imageSize ); MarkToRedraw(); - return true; } diff --git a/sources/ewol/widget/Image.h b/sources/ewol/widget/Image.h index 5369b2ef..9aee834f 100644 --- a/sources/ewol/widget/Image.h +++ b/sources/ewol/widget/Image.h @@ -20,24 +20,23 @@ namespace widget { class Image :public widget::Drawable { public: - Image(etk::UString dataFile, int32_t size=-1); // automatic considering in the appl Data older - // Derived function - virtual const char * const GetObjectType(void) { return "EwolImage"; }; - void Init(void); + static void Init(void); + static void UnInit(void); + public: + Image(const etk::UString& dataFile="", int32_t size=-1); // automatic considering in the appl Data older virtual ~Image(void); - // Derived function - virtual bool CalculateMinSize(void); - void SetFile(etk::UString newFile); - void SetPadding(vec2 newPadding); + void SetFile(etk::UString newFile); + void SetPadding(vec2 newPadding); private: - etk::UString m_imageSelected; + etk::UString m_imageSelected; vec2 m_padding; - draw::Color m_textColorBg; //!< Background color - int32_t m_imageSize; + draw::Color m_textColorBg; //!< Background color + int32_t m_imageSize; public: // Derived function - virtual void OnRegenerateDisplay(void); - // Derived function + virtual const char * const GetObjectType(void) { return "Ewol::Image"; }; + virtual void CalculateMinSize(void); + virtual void OnRegenerateDisplay(void); virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos); }; }; diff --git a/sources/ewol/widget/Joystick.cpp b/sources/ewol/widget/Joystick.cpp index 82d24e25..5562ac5d 100644 --- a/sources/ewol/widget/Joystick.cpp +++ b/sources/ewol/widget/Joystick.cpp @@ -58,12 +58,11 @@ widget::Joystick::~Joystick(void) } -bool widget::Joystick::CalculateSize(float availlableX, float availlableY) +void widget::Joystick::CalculateSize(const vec2& availlable) { - float minimumSize = etk_min(availlableX, availlableY); + float minimumSize = etk_min(availlable.x(), availlable.y()); m_size.setValue(minimumSize, minimumSize); MarkToRedraw(); - return true; } void widget::Joystick::OnRegenerateDisplay(void) diff --git a/sources/ewol/widget/Joystick.h b/sources/ewol/widget/Joystick.h index ca4dd28c..38c6cd2a 100644 --- a/sources/ewol/widget/Joystick.h +++ b/sources/ewol/widget/Joystick.h @@ -43,13 +43,11 @@ namespace widget { Joystick(void); virtual ~Joystick(void); // Derived function - virtual const char * const GetObjectType(void) { return "Ewol"; }; - // Derived function - virtual bool CalculateSize(float availlableX, float availlableY); - // Derived function + virtual const char * const GetObjectType(void) { return "Ewol::Joystick"; }; + virtual void CalculateSize(const vec2& availlable); virtual void OnRegenerateDisplay(void); - // Derived function virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos); + void SetLockMode(bool lockWhenOut) { m_lock = lockWhenOut; }; void SetDisplayMode(joystickMode_te newMode) { m_displayMode = newMode; }; /** diff --git a/sources/ewol/widget/Label.cpp b/sources/ewol/widget/Label.cpp index 6ff53c18..7a3d6bed 100644 --- a/sources/ewol/widget/Label.cpp +++ b/sources/ewol/widget/Label.cpp @@ -20,6 +20,21 @@ extern const char * const ewolEventLabelPressed = "ewol Label Pressed"; #undef __class__ #define __class__ "Label" +static ewol::Widget* Create(void) +{ + return new widget::Label(); +} + +void widget::Label::Init(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,&Create); +} + +void widget::Label::UnInit(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,NULL); +} + widget::Label::Label(etk::UString newLabel) { @@ -33,7 +48,7 @@ widget::Label::~Label(void) } -bool widget::Label::CalculateMinSize(void) +void widget::Label::CalculateMinSize(void) { if (m_userMaxSize.x() != -1) { m_text.SetTextAlignement(0, m_userMaxSize.x()-4, ewol::Text::alignLeft); @@ -49,7 +64,6 @@ bool widget::Label::CalculateMinSize(void) } else { m_minSize.setY(4 + minSize.y()); } - return true; } @@ -136,4 +150,14 @@ bool widget::Label::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, return false; } - +bool widget::Label::LoadXML(TiXmlNode* node) +{ + if (NULL==node) { + return false; + } + ewol::Widget::LoadXML(node); + // get internal data : + // TODO : Unparse data type XML ... + SetLabel(node->ToElement()->GetText()); + return true; +} diff --git a/sources/ewol/widget/Label.h b/sources/ewol/widget/Label.h index 1fa62813..07e8a945 100644 --- a/sources/ewol/widget/Label.h +++ b/sources/ewol/widget/Label.h @@ -19,6 +19,9 @@ extern const char * const ewolEventLabelPressed; namespace widget { class Label : public ewol::Widget { + public: + static void Init(void); + static void UnInit(void); private: ewol::Text m_text; //!< Compositing text element. etk::UString m_label; //!< decorated text to display. @@ -42,16 +45,14 @@ namespace widget { * @return The displayed decorated text. */ etk::UString GetLabel(void); + public: // Derived function virtual const char * const GetObjectType(void) { return "Ewol::Label"; }; - // Derived function - virtual bool CalculateMinSize(void); - // Derived function + virtual void CalculateMinSize(void); virtual void OnRegenerateDisplay(void); - // Derived function virtual void OnDraw(ewol::DrawProperty& displayProp); - // Derived function virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos); + virtual bool LoadXML(TiXmlNode* node); }; }; diff --git a/sources/ewol/widget/Layer.cpp b/sources/ewol/widget/Layer.cpp index 3d29d113..2f59c8d0 100644 --- a/sources/ewol/widget/Layer.cpp +++ b/sources/ewol/widget/Layer.cpp @@ -13,6 +13,21 @@ #undef __class__ #define __class__ "Layer" +static ewol::Widget* Create(void) +{ + return new widget::Layer(); +} + +void widget::Layer::Init(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,&Create); +} + +void widget::Layer::UnInit(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,NULL); +} + widget::Layer::Layer(void) { @@ -27,32 +42,31 @@ widget::Layer::~Layer(void) } -bool widget::Layer::CalculateSize(float availlableX, float availlableY) +void widget::Layer::CalculateSize(const vec2& availlable) { //EWOL_DEBUG("Update Size"); - m_size.setValue(availlableX, availlableY); + m_size = availlable; for (int32_t iii=0; iiiSetOrigin(m_origin.x(), m_origin.y()); - m_subWidget[iii]->CalculateSize(m_size.x(), m_size.y()); + m_subWidget[iii]->SetOrigin(m_origin); + m_subWidget[iii]->CalculateSize(m_size); } } MarkToRedraw(); - return true; } -bool widget::Layer::CalculateMinSize(void) +void widget::Layer::CalculateMinSize(void) { m_userExpend.setValue(false, false); m_minSize.setValue(0,0); for (int32_t iii=0; iiiCalculateMinSize(); - if (true == m_subWidget[iii]->CanExpentX()) { + if (true == m_subWidget[iii]->CanExpand().x()) { m_userExpend.setX(true); } - if (true == m_subWidget[iii]->CanExpentY()) { + if (true == m_subWidget[iii]->CanExpand().y()) { m_userExpend.setY(true); } vec2 tmpSize = m_subWidget[iii]->GetMinSize(); @@ -60,38 +74,20 @@ bool widget::Layer::CalculateMinSize(void) etk_max(tmpSize.y(), m_minSize.y()) ); } } - return true; } -void widget::Layer::SetMinSise(float x, float y) +void widget::Layer::SetMinSize(const vec2& size) { EWOL_ERROR("Layer can not have a user Minimum size (herited from under elements)"); } -void widget::Layer::SetExpendX(bool newExpend) -{ - EWOL_ERROR("Layer can not have a user expend settings X (herited from under elements)"); -} -bool widget::Layer::CanExpentX(void) +bvec2 widget::Layer::CanExpand(void) { if (true == m_lockExpendContamination) { - return false; + return bvec2(false,false); } - return m_userExpend.x(); -} - -void widget::Layer::SetExpendY(bool newExpend) -{ - EWOL_ERROR("Sizer can not have a user expend settings Y (herited from under elements)"); -} - -bool widget::Layer::CanExpentY(void) -{ - if (true == m_lockExpendContamination) { - return false; - } - return m_userExpend.y(); + return m_userExpend; } void widget::Layer::LockExpendContamination(bool lockExpend) diff --git a/sources/ewol/widget/Layer.h b/sources/ewol/widget/Layer.h index 6403f5ac..9b3d6e53 100644 --- a/sources/ewol/widget/Layer.h +++ b/sources/ewol/widget/Layer.h @@ -16,20 +16,12 @@ namespace widget { class Layer :public ewol::Widget { + public: + static void Init(void); + static void UnInit(void); public: Layer(void); virtual ~Layer(void); - // Derived function - virtual const char * const GetObjectType(void) { return "EwolLayer"; }; - public: - // Derived function - virtual bool CalculateSize(float availlableX, float availlableY); - virtual bool CalculateMinSize(void); - virtual void SetMinSise(float x=-1, float y=-1); - virtual void SetExpendX(bool newExpend=false); - virtual bool CanExpentX(void); - virtual void SetExpendY(bool newExpend=false); - virtual bool CanExpentY(void); void LockExpendContamination(bool lockExpend=false); private: bool m_lockExpendContamination; @@ -46,10 +38,14 @@ namespace widget { public: // Derived function virtual void OnRegenerateDisplay(void); - // Derived function virtual ewol::Widget * GetWidgetAtPos(vec2 pos); - // Derived function virtual void OnObjectRemove(ewol::EObject * removeObject); + virtual void CalculateSize(const vec2& availlable); + virtual void CalculateMinSize(void); + virtual void SetMinSize(const vec2& size); + virtual void SetExpand(const bvec2& newExpend); + virtual bvec2 CanExpand(void); + virtual const char * const GetObjectType(void) { return "EwolLayer"; }; }; }; diff --git a/sources/ewol/widget/List.cpp b/sources/ewol/widget/List.cpp index cb6e6a17..0f3b2590 100644 --- a/sources/ewol/widget/List.cpp +++ b/sources/ewol/widget/List.cpp @@ -43,7 +43,7 @@ widget::List::~List(void) } -bool widget::List::CalculateMinSize(void) +void widget::List::CalculateMinSize(void) { /*int32_t fontId = GetDefaultFontId(); int32_t minWidth = ewol::GetWidth(fontId, m_label); @@ -52,7 +52,6 @@ bool widget::List::CalculateMinSize(void) m_minSize.y = 3+minHeight; */ m_minSize.setValue(200, 150); - return true; } diff --git a/sources/ewol/widget/List.h b/sources/ewol/widget/List.h index ca760cec..c133e3f9 100644 --- a/sources/ewol/widget/List.h +++ b/sources/ewol/widget/List.h @@ -22,17 +22,17 @@ namespace widget { List(void); void Init(void); // Derived function - virtual const char * const GetObjectType(void) { return "EwolList"; }; + virtual const char * const GetObjectType(void) { return "ewol::List"; }; virtual ~List(void); - virtual bool CalculateMinSize(void); - void SetLabel(etk::UString newLabel); + virtual void CalculateMinSize(void); + void SetLabel(etk::UString newLabel); // Drawing capabilities .... private: etk::Vector m_listOObject; //!< generic element to display... etk::Vector m_lineSize; public: - void AddOObject(ewol::Compositing* newObject, int32_t pos=-1); - void ClearOObjectList(void); + void AddOObject(ewol::Compositing* newObject, int32_t pos=-1); + void ClearOObjectList(void); protected: // Derived function virtual void OnDraw(ewol::DrawProperty& displayProp); @@ -44,7 +44,7 @@ namespace widget { int32_t m_displayCurrentNbLine; //!< Number of line in the display public: // Derived function - virtual void OnRegenerateDisplay(void); + virtual void OnRegenerateDisplay(void); // Derived function virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos); protected: diff --git a/sources/ewol/widget/Menu.cpp b/sources/ewol/widget/Menu.cpp index a6094711..ce1a9629 100644 --- a/sources/ewol/widget/Menu.cpp +++ b/sources/ewol/widget/Menu.cpp @@ -164,7 +164,7 @@ void widget::Menu::OnReceiveMessage(ewol::EObject * CallerObject, const char * e widget::Button * myButton = NULL; mySizer = new widget::Sizer(widget::Sizer::modeVert); - mySizer->LockExpendContamination(true); + mySizer->LockExpendContamination(vec2(true,true)); // set it in the pop-up-system : m_widgetContextMenu->SubWidgetSet(mySizer); diff --git a/sources/ewol/widget/Menu.h b/sources/ewol/widget/Menu.h index cc6113bb..15b809d0 100644 --- a/sources/ewol/widget/Menu.h +++ b/sources/ewol/widget/Menu.h @@ -37,22 +37,21 @@ namespace widget { // Derived functionv virtual const char * const GetObjectType(void) { return "EwolMenu"; }; private: - virtual void SubWidgetRemoveAll(void); - virtual void SubWidgetAdd(ewol::Widget* newWidget); - virtual void SubWidgetRemove(ewol::Widget* newWidget); - virtual void SubWidgetUnLink(ewol::Widget* newWidget); + virtual void SubWidgetRemoveAll(void); + virtual void SubWidgetAdd(ewol::Widget* newWidget); + virtual void SubWidgetRemove(ewol::Widget* newWidget); + virtual void SubWidgetUnLink(ewol::Widget* newWidget); private: etk::Vector m_listElement; - int32_t m_staticId; // unique ID for every element of the menu ... - widget::ContextMenu* m_widgetContextMenu; + int32_t m_staticId; // unique ID for every element of the menu ... + widget::ContextMenu* m_widgetContextMenu; public: - void Clear(void); - int32_t AddTitle(etk::UString label, etk::UString image="", const char * generateEvent = NULL, const etk::UString message = ""); - int32_t Add(int32_t parent, etk::UString label, etk::UString image="", const char * generateEvent = NULL, const etk::UString message = ""); - void AddSpacer(void); + void Clear(void); + int32_t AddTitle(etk::UString label, etk::UString image="", const char * generateEvent = NULL, const etk::UString message = ""); + int32_t Add(int32_t parent, etk::UString label, etk::UString image="", const char * generateEvent = NULL, const etk::UString message = ""); + void AddSpacer(void); // Derived function virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data); - // Derived function virtual void OnObjectRemove(ewol::EObject * removeObject); }; diff --git a/sources/ewol/widget/PopUp.cpp b/sources/ewol/widget/PopUp.cpp index d969ae24..5400c64d 100644 --- a/sources/ewol/widget/PopUp.cpp +++ b/sources/ewol/widget/PopUp.cpp @@ -35,20 +35,20 @@ widget::PopUp::~PopUp(void) } -bool widget::PopUp::CalculateSize(float availlableX, float availlableY) +void widget::PopUp::CalculateSize(const vec2& availlable) { - //EWOL_DEBUG("CalculateSize(" << availlableX << "," << availlableY << ")"); + //EWOL_DEBUG("CalculateSize=" << availlable); // pop-up fill all the display : - m_size.setValue(availlableX, availlableY); + m_size = availlable; if (NULL != m_subWidget) { vec2 subWidgetSize; vec2 subWidgetOrigin; subWidgetSize = m_subWidget->GetMinSize(); - if (true == m_subWidget->CanExpentX()) { + if (true == m_subWidget->CanExpand().x()) { subWidgetSize.setX(m_size.x()); } - if (true == m_subWidget->CanExpentY()) { + if (true == m_subWidget->CanExpand().y()) { subWidgetSize.setY(m_size.y()); } if (m_displayRatio>0.1 && m_displayRatio<=1) { @@ -65,11 +65,10 @@ bool widget::PopUp::CalculateSize(float availlableX, float availlableY) m_subWidget->CalculateSize(subWidgetSize.x(), subWidgetSize.y()); } MarkToRedraw(); - return true; } -bool widget::PopUp::CalculateMinSize(void) +void widget::PopUp::CalculateMinSize(void) { //EWOL_DEBUG("CalculateMinSize"); m_userExpend.setValue(false,false); @@ -81,25 +80,18 @@ bool widget::PopUp::CalculateMinSize(void) } //EWOL_DEBUG("CalculateMinSize(" << m_minSize.x << "," << m_minSize.y << ")"); MarkToRedraw(); - return true; } -void widget::PopUp::SetMinSise(float x, float y) +void widget::PopUp::SetMinSize(const vec2& size) { EWOL_ERROR("Pop-up can not have a user Minimum size (herited from under elements)"); } -void widget::PopUp::SetExpendX(bool newExpend) +void widget::PopUp::SetExpand(const bvec2& newExpend) { EWOL_ERROR("Pop-up can not have a user expend settings X (herited from under elements)"); } -void widget::PopUp::SetExpendY(bool newExpend) -{ - EWOL_ERROR("Pop-up can not have a user expend settings Y (herited from under elements)"); -} - - void widget::PopUp::SubWidgetSet(ewol::Widget* newWidget) { if (NULL == newWidget) { diff --git a/sources/ewol/widget/PopUp.h b/sources/ewol/widget/PopUp.h index 1d996c98..5b82a055 100644 --- a/sources/ewol/widget/PopUp.h +++ b/sources/ewol/widget/PopUp.h @@ -25,16 +25,11 @@ namespace widget { virtual const char * const GetObjectType(void) { return "EwolPopUp"; }; public: // Derived function - virtual bool CalculateSize(float availlableX, float availlableY); - // Derived function - virtual bool CalculateMinSize(void); - // Derived function - virtual void SetMinSise(float x=-1, float y=-1); - // Derived function - virtual void SetExpendX(bool newExpend=false); - // Derived function - virtual void SetExpendY(bool newExpend=false); - void SetDisplayRatio(float ratio); + virtual void CalculateSize(const vec2& availlable); + virtual void CalculateMinSize(void); + virtual void SetMinSize(const vec2& size); + virtual void SetExpand(const bvec2& newExpend); + void SetDisplayRatio(float ratio); private: draw::Color m_colorBackGroung; draw::Color m_colorBorder; diff --git a/sources/ewol/widget/ProgressBar.cpp b/sources/ewol/widget/ProgressBar.cpp index 8b5dbedf..c43d32e1 100644 --- a/sources/ewol/widget/ProgressBar.cpp +++ b/sources/ewol/widget/ProgressBar.cpp @@ -12,7 +12,23 @@ #include #undef __class__ -#define __class__ "Slider" +#define __class__ "ProgressBar" + +static ewol::Widget* Create(void) +{ + return new widget::ProgressBar(); +} + +void widget::ProgressBar::Init(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,&Create); +} + +void widget::ProgressBar::UnInit(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,NULL); +} + const int32_t dotRadius = 6; @@ -35,12 +51,11 @@ widget::ProgressBar::~ProgressBar(void) } -bool widget::ProgressBar::CalculateMinSize(void) +void widget::ProgressBar::CalculateMinSize(void) { m_minSize.setValue( etk_max(m_userMinSize.x(), 40), etk_max(m_userMinSize.y(), dotRadius*2) ); MarkToRedraw(); - return true; } diff --git a/sources/ewol/widget/ProgressBar.h b/sources/ewol/widget/ProgressBar.h index e4dfd01f..57ac2ba6 100644 --- a/sources/ewol/widget/ProgressBar.h +++ b/sources/ewol/widget/ProgressBar.h @@ -18,23 +18,26 @@ namespace widget { class ProgressBar :public widget::Drawable { + public: + static void Init(void); + static void UnInit(void); public: ProgressBar(void); virtual ~ProgressBar(void); // Derived function virtual const char * const GetObjectType(void) { return "EwolProgressBar"; }; - virtual bool CalculateMinSize(void); - void ValueSet(float val); - float ValueGet(void); - void SetColor(draw::Color newColor) { m_textColorFg = newColor; }; + virtual void CalculateMinSize(void); + void ValueSet(float val); + float ValueGet(void); + void SetColor(draw::Color newColor) { m_textColorFg = newColor; }; private: - float m_value; //!< % used - draw::Color m_textColorFg; //!< forder bar color - draw::Color m_textColorBgOn; //!< bar color enable - draw::Color m_textColorBgOff; //!< bar color disable + float m_value; //!< % used + draw::Color m_textColorFg; //!< forder bar color + draw::Color m_textColorBgOn; //!< bar color enable + draw::Color m_textColorBgOff; //!< bar color disable public: // Derived function - virtual void OnRegenerateDisplay(void); + virtual void OnRegenerateDisplay(void); }; }; diff --git a/sources/ewol/widget/Sizer.cpp b/sources/ewol/widget/Sizer.cpp index 26dbed57..bc6b06ca 100644 --- a/sources/ewol/widget/Sizer.cpp +++ b/sources/ewol/widget/Sizer.cpp @@ -14,6 +14,21 @@ #undef __class__ #define __class__ "Sizer" +static ewol::Widget* Create(void) +{ + return new widget::Sizer(); +} + +void widget::Sizer::Init(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,&Create); +} + +void widget::Sizer::UnInit(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,NULL); +} + widget::Sizer::Sizer(widget::Sizer::displayMode_te mode): m_mode(mode), @@ -57,10 +72,10 @@ widget::Sizer::displayMode_te widget::Sizer::GetMode(void) return m_mode; } -bool widget::Sizer::CalculateSize(float availlableX, float availlableY) +void widget::Sizer::CalculateSize(const vec2& availlable) { //EWOL_DEBUG("Update Size"); - m_size.setValue(availlableX, availlableY); + m_size = availlable; m_size -= m_borderSize*2; // calculate unExpendable Size : float unexpendableSize=0.0; @@ -128,11 +143,10 @@ bool widget::Sizer::CalculateSize(float availlableX, float availlableY) } m_size += m_borderSize*2; MarkToRedraw(); - return true; } -bool widget::Sizer::CalculateMinSize(void) +void widget::Sizer::CalculateMinSize(void) { //EWOL_DEBUG("Update minimum Size"); m_userExpend.setValue(false, false); @@ -169,52 +183,29 @@ bool widget::Sizer::CalculateMinSize(void) } } } - //EWOL_DEBUG("Vert Result : expend="<< m_userExpend << " minSize="<< m_minSize); - return true; } -void widget::Sizer::SetMinSize(float x, float y) +void widget::Sizer::SetMinSize(const vec2& size) { EWOL_ERROR("[" << GetId() << "] Sizer can not have a user Minimum size (herited from under elements)"); } -void widget::Sizer::SetExpendX(bool newExpend) +void widget::Sizer::SetExpand(const bvec2& newExpend) { - EWOL_ERROR("[" << GetId() << "] Sizer can not have a user expend settings X (herited from under elements)"); + EWOL_ERROR("[" << GetId() << "] Sizer can not have a user expend settings (herited from under elements)"); } -bool widget::Sizer::CanExpentX(void) +bvec2 widget::Sizer::CanExpentY(void) { - if (true == m_lockExpendContamination.x()) { - return false; + if (true == m_lockExpendContamination)) { + return bvec2(false,false); } - return m_userExpend.x(); + return m_userExpend; } -void widget::Sizer::SetExpendY(bool newExpend) +void widget::Sizer::LockExpendContamination(const bvec2& lockExpend) { - EWOL_ERROR("[" << GetId() << "] Sizer can not have a user expend settings Y (herited from under elements)"); -} - -bool widget::Sizer::CanExpentY(void) -{ - if (true == m_lockExpendContamination.y()) { - return false; - } - return m_userExpend.y(); -} - -void widget::Sizer::LockExpendContamination(bool lockExpend) -{ - m_lockExpendContamination.setValue(lockExpend,lockExpend); -} -void widget::Sizer::LockExpendContaminationVert(bool lockExpend) -{ - m_lockExpendContamination.setY(lockExpend); -} -void widget::Sizer::LockExpendContaminationHori(bool lockExpend) -{ - m_lockExpendContamination.setX(lockExpend); + m_lockExpendContamination = lockExpend; } void widget::Sizer::SubWidgetRemoveAll(void) diff --git a/sources/ewol/widget/Sizer.h b/sources/ewol/widget/Sizer.h index 33d47b5f..f841e4cc 100644 --- a/sources/ewol/widget/Sizer.h +++ b/sources/ewol/widget/Sizer.h @@ -16,6 +16,9 @@ namespace widget { class Sizer :public ewol::Widget { + public: + static void Init(void); + static void UnInit(void); public: typedef enum { modeVert, //!< Vertical mode @@ -51,17 +54,7 @@ namespace widget { * @brief Change state of the expend contatmination (if some sub-widget request the expent this permit to not propagate if at this widget) * @param[in] lockExpend New expend state in vertical and horisantal */ - void LockExpendContamination(bool lockExpend); - /** - * @brief Change state of the expend contatmination (if some sub-widget request the expent this permit to not propagate if at this widget) - * @param[in] lockExpend New expend state in vertical - */ - void LockExpendContaminationVert(bool lockExpend); - /** - * @brief Change state of the expend contatmination (if some sub-widget request the expent this permit to not propagate if at this widget) - * @param[in] lockExpend New expend state in horisantal - */ - void LockExpendContaminationHori(bool lockExpend); + void LockExpendContamination(const bvec2& lockExpend); public: /** * @brief Remove all sub element from the widget. @@ -107,13 +100,11 @@ namespace widget { virtual ewol::Widget* GetWidgetAtPos(vec2 pos); virtual void OnObjectRemove(ewol::EObject* removeObject); virtual const char * const GetObjectType(void) { return "Ewol::Sizer"; }; - virtual bool CalculateSize(float availlableX, float availlableY); - virtual bool CalculateMinSize(void); - virtual void SetMinSize(float x=-1, float y=-1); - virtual void SetExpendX(bool newExpend=false); - virtual bool CanExpentX(void); - virtual void SetExpendY(bool newExpend=false); - virtual bool CanExpentY(void); + virtual void CalculateSize(const vec2& availlable); + virtual void CalculateMinSize(void); + virtual void SetMinSize(const vec2& size); + virtual void SetExpand(const bvec2& newExpend); + virtual bvec2 CanExpent(void);; }; }; diff --git a/sources/ewol/widget/Slider.cpp b/sources/ewol/widget/Slider.cpp index 02e326a5..7e271523 100644 --- a/sources/ewol/widget/Slider.cpp +++ b/sources/ewol/widget/Slider.cpp @@ -19,6 +19,24 @@ extern const char * const ewolEventSliderChange = "ewol-event-slider-change"; #undef __class__ #define __class__ "Slider" + +static ewol::Widget* Create(void) +{ + return new widget::Slider(); +} + +void widget::Slider::Init(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,&Create); +} + +void widget::Slider::UnInit(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,NULL); +} + + + const int32_t dotRadius = 6; widget::Slider::Slider(void) @@ -44,12 +62,11 @@ widget::Slider::~Slider(void) } -bool widget::Slider::CalculateMinSize(void) +void widget::Slider::CalculateMinSize(void) { m_minSize.setValue(etk_max(m_userMinSize.x(), 40), etk_max(m_userMinSize.y(), dotRadius*2) ); MarkToRedraw(); - return true; } diff --git a/sources/ewol/widget/Slider.h b/sources/ewol/widget/Slider.h index 00e95201..a20e1079 100644 --- a/sources/ewol/widget/Slider.h +++ b/sources/ewol/widget/Slider.h @@ -19,18 +19,17 @@ extern const char * const ewolEventSliderChange; namespace widget { class Slider :public widget::Drawable { + public: + static void Init(void); + static void UnInit(void); public: Slider(void); virtual ~Slider(void); - // Derived function - virtual const char * const GetObjectType(void) { return "EwolSlider"; } ; - // Derived function - virtual bool CalculateMinSize(void); - void SetValue(int32_t val); - int32_t GetValue(void); - void SetMin(int32_t val); - void SetMax(int32_t val); - void SetColor(draw::Color newColor) { m_textColorFg = newColor; }; + void SetValue(int32_t val); + int32_t GetValue(void); + void SetMin(int32_t val); + void SetMax(int32_t val); + void SetColor(draw::Color newColor) { m_textColorFg = newColor; }; private: int32_t m_value; int32_t m_min; @@ -39,8 +38,9 @@ namespace widget { draw::Color m_textColorBg; //!< Background color public: // Derived function - virtual void OnRegenerateDisplay(void); - // Derived function + virtual const char * const GetObjectType(void) { return "Ewol::Slider"; } ; + virtual void CalculateMinSize(void); + virtual void OnRegenerateDisplay(void); virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos); }; diff --git a/sources/ewol/widget/Spacer.cpp b/sources/ewol/widget/Spacer.cpp index 3e8b4996..51c43f65 100644 --- a/sources/ewol/widget/Spacer.cpp +++ b/sources/ewol/widget/Spacer.cpp @@ -15,6 +15,21 @@ #undef __class__ #define __class__ "Spacer" +static ewol::Widget* Create(void) +{ + return new widget::Spacer(); +} + +void widget::Spacer::Init(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,&Create); +} + +void widget::Spacer::UnInit(void) +{ + ewol::widgetManager::AddWidgetCreator(__class__,NULL); +} + widget::Spacer::Spacer(void) { @@ -30,10 +45,9 @@ widget::Spacer::~Spacer(void) } -bool widget::Spacer::CalculateMinSize(void) +void widget::Spacer::CalculateMinSize(void) { m_minSize.setValue(m_localSize, m_localSize); - return true; } @@ -50,7 +64,7 @@ void widget::Spacer::OnDraw(ewol::DrawProperty& displayProp) } -#define BORDER_SIZE_TMP (4) +#define BORDER_SIZE_TMP (4) void widget::Spacer::OnRegenerateDisplay(void) { if (false == NeedRedraw()) { diff --git a/sources/ewol/widget/Spacer.h b/sources/ewol/widget/Spacer.h index 9927b804..fd209e8f 100644 --- a/sources/ewol/widget/Spacer.h +++ b/sources/ewol/widget/Spacer.h @@ -18,10 +18,13 @@ namespace widget { class Spacer :public ewol::Widget { + public: + static void Init(void); + static void UnInit(void); private: - ewol::Drawing m_draw; //!< Compositing drawing element - float m_localSize; //!< Local request size of the display - draw::Color m_color; //!< Background color + ewol::Drawing m_draw; //!< Compositing drawing element + float m_localSize; //!< Local request size of the display + draw::Color m_color; //!< Background color public: /** * @brief Main constructer @@ -43,14 +46,10 @@ namespace widget { void SetColor(draw::Color newColor) { m_color = newColor; MarkToRedraw(); }; public: // Derived function - virtual const char * const GetObjectType(void) { return "EwolSpacer"; }; - // Derived function - virtual bool CalculateMinSize(void); - // Derived function + virtual const char * const GetObjectType(void) { return "Ewol::Spacer"; }; + virtual void CalculateMinSize(void); virtual ewol::Widget * GetWidgetAtPos(vec2 pos) { return NULL; }; - // Derived function virtual void OnRegenerateDisplay(void); - // Derived function virtual void OnDraw(ewol::DrawProperty& displayProp); }; diff --git a/sources/ewol/widget/Widget.cpp b/sources/ewol/widget/Widget.cpp index 21614845..7280646c 100644 --- a/sources/ewol/widget/Widget.cpp +++ b/sources/ewol/widget/Widget.cpp @@ -20,15 +20,15 @@ #define __class__ "Widget" ewol::Widget::Widget(void) : - m_hide(false), - m_zoom(1.0f), - m_origin(0,0), m_size(10,10), m_minSize(-1,-1), + m_zoom(1.0f), + m_origin(0,0), m_userMinSize(-1,-1), m_userMaxSize(-1,-1), m_userExpend(false,false), m_userFill(false,false), + m_hide(false), m_hasFocus(false), m_canFocus(false), m_limitMouseEvent(3), @@ -66,11 +66,10 @@ void ewol::Widget::Show(void) } -bool ewol::Widget::CalculateSize(float availlableX, float availlableY) +void ewol::Widget::CalculateSize(const vec2& availlable) { - m_size.setValue(availlableX, availlableY); + m_size = availlable; MarkToRedraw(); - return true; } @@ -206,9 +205,9 @@ float ewol::Widget::GetZoom(void) return m_zoom; } -void ewol::Widget::SetOrigin(float x, float y) +void ewol::Widget::SetOrigin(const vec2& pos) { - m_origin.setValue(x, y); + m_origin = pos; } vec2 ewol::Widget::GetOrigin(void) @@ -221,16 +220,15 @@ vec2 ewol::Widget::RelativePosition(vec2 pos) return pos - m_origin; } -bool ewol::Widget::CalculateMinSize(void) +void ewol::Widget::CalculateMinSize(void) { m_minSize = m_userMinSize; MarkToRedraw(); - return true; } -void ewol::Widget::SetMinSize(float x, float y) +void ewol::Widget::SetMinSize(const vec2& size) { - m_userMinSize.setValue(x, y); + m_userMinSize = size; } void ewol::Widget::CheckMinSize(void) @@ -270,37 +268,17 @@ vec2 ewol::Widget::GetSize(void) return vec2(0,0); } -void ewol::Widget::SetExpendX(bool newExpend) +void ewol::Widget::SetExpand(const bvec2& newExpend) { - m_userExpend.setX(newExpend); - ewol::RequestUpdateSize(); - MarkToRedraw(); -} - -bool ewol::Widget::CanExpentX(void) -{ - if (false==IsHide()) { - return m_userExpend.x(); + if( m_userExpend.x() != newExpend.x() + || m_userExpend.y() != newExpend.y()) { + m_userExpend = newExpend; + ewol::RequestUpdateSize(); + MarkToRedraw(); } - return false; } -void ewol::Widget::SetExpendY(bool newExpend) -{ - m_userExpend.setY(newExpend); - ewol::RequestUpdateSize(); - MarkToRedraw(); -} - -bool ewol::Widget::CanExpentY(void) -{ - if (false==IsHide()) { - return m_userExpend.y(); - } - return false; -} - -bvec2 ewol::Widget::CanExpent(void) +bvec2 ewol::Widget::CanExpand(void) { if (false==IsHide()) { return m_userExpend; @@ -309,27 +287,19 @@ bvec2 ewol::Widget::CanExpent(void) } - -void ewol::Widget::SetFillX(bool newFill) +void ewol::Widget::SetFill(const bvec2& newFill) { - m_userFill.setX(newFill); - MarkToRedraw(); + if( m_userFill.x() != newFill.x() + || m_userFill.y() != newFill.y()) { + m_userFill = newFill; + ewol::RequestUpdateSize(); + MarkToRedraw(); + } } -bool ewol::Widget::CanFillX(void) +const bvec2& ewol::Widget::CanFill(void) { - return m_userFill.x(); -} - -void ewol::Widget::SetFillY(bool newFill) -{ - m_userFill.setY(newFill); - MarkToRedraw(); -} - -bool ewol::Widget::CanFillY(void) -{ - return m_userFill.y(); + return m_userFill; } // ---------------------------------------------------------------------------------------------------------------- @@ -514,3 +484,118 @@ ewol::cursorDisplay_te ewol::Widget::GetCursor(void) { return m_cursorDisplay; } + +bool ewol::Widget::LoadXML(TiXmlNode* node) +{ + if (NULL==node) { + return false; + } + bool ret = true; + const char *tmpAttributeValue = node->ToElement()->Attribute("name"); + if (NULL != tmpAttributeValue) { + m_widgetName = tmpAttributeValue; + } + tmpAttributeValue = node->ToElement()->Attribute("fill"); + if (NULL != tmpAttributeValue) { + if (strcmp("false,false", tmpAttributeValue)==0) { + SetFill(bvec2(false,false)); + } else if (strcmp("false,true", tmpAttributeValue)==0) { + SetFill(bvec2(false,true)); + } else if (strcmp("true,false", tmpAttributeValue)==0) { + SetFill(bvec2(true,false)); + } else if (strcmp("false", tmpAttributeValue)==0) { + SetFill(bvec2(false,false)); + } else { + SetFill(bvec2(true,true)); + } + } + tmpAttributeValue = node->ToElement()->Attribute("expand"); + if (NULL != tmpAttributeValue) { + if (strcmp("false,false", tmpAttributeValue)==0) { + SetExpand(bvec2(false,false)); + } else if (strcmp("false,true", tmpAttributeValue)==0) { + SetExpand(bvec2(false,true)); + } else if (strcmp("true,false", tmpAttributeValue)==0) { + SetExpand(bvec2(true,false)); + } else if (strcmp("false", tmpAttributeValue)==0) { + SetExpand(bvec2(false,false)); + } else { + SetExpand(bvec2(true,true)); + } + } + tmpAttributeValue = node->ToElement()->Attribute("hide"); + if (NULL != tmpAttributeValue) { + if (strcmp("true", tmpAttributeValue)==0) { + Hide(); + } else { + Show(); + } + } + tmpAttributeValue = node->ToElement()->Attribute("focus"); + if (NULL != tmpAttributeValue) { + if (strcmp("true", tmpAttributeValue)==0) { + KeepFocus(); + } + } + tmpAttributeValue = node->ToElement()->Attribute("min-size"); + if (NULL != tmpAttributeValue) { + float x,y; + if (2!=sscanf(tmpAttributeValue, "%f,%f", &x, &y)) { + SetMinSize(vec2(x,y)); + } else { + EWOL_ERROR("(l "<Row()<<") An error occured when parsing element min-size : " << tmpAttributeValue); + ret = false; + } + } + tmpAttributeValue = node->ToElement()->Attribute("max-size"); + if (NULL != tmpAttributeValue) { + float x,y; + if (2!=sscanf(tmpAttributeValue, "%f,%f", &x, &y)) { + SetMaxSize(vec2(x,y)); + } else { + EWOL_ERROR("(l "<Row()<<") An error occured when parsing element max-size : " << tmpAttributeValue); + ret = false; + } + } + return ret; +} + +bool ewol::Widget::StoreXML(TiXmlNode* node) +{ + if (NULL==node) { + return false; + } + /* + TiXmlElement * element = new TiXmlElement(__class__); + if (NULL == element) { + EWOL_ERROR("TinyXML node allocation error"); + return false; + } + node->LinkEndChild(element); + */ + if (m_widgetName.Size()!=0) { + node->ToElement()->SetAttribute("name", m_widgetName.c_str() ); + } + if (m_userMinSize != vec2(-1,-1)) { + etk::UString tmpVal = etk::UString(m_userMinSize.x()) + "," + etk::UString(m_userMinSize.y()); + node->ToElement()->SetAttribute("min-size", tmpVal.c_str() ); + } + if (m_userMaxSize != vec2(-1,-1)) { + etk::UString tmpVal = etk::UString(m_userMaxSize.x()) + "," + etk::UString(m_userMaxSize.y()); + node->ToElement()->SetAttribute("max-size", tmpVal.c_str() ); + } + if (m_userExpend != bvec2(false,false)) { + etk::UString tmpVal = etk::UString(m_userExpend.x()) + "," + etk::UString(m_userExpend.y()); + node->ToElement()->SetAttribute("expand", tmpVal.c_str() ); + } + if (m_userFill != bvec2(false,false)) { + etk::UString tmpVal = etk::UString(m_userFill.x()) + "," + etk::UString(m_userFill.y()); + node->ToElement()->SetAttribute("fill", tmpVal.c_str() ); + } + if (IsHide() != false) { + node->ToElement()->SetAttribute("hide", "true" ); + } + return true; +} + + diff --git a/sources/ewol/widget/Widget.h b/sources/ewol/widget/Widget.h index 86c5a806..21ec677a 100644 --- a/sources/ewol/widget/Widget.h +++ b/sources/ewol/widget/Widget.h @@ -10,6 +10,7 @@ #define __EWOL_WIDGET_H__ #include +#include namespace ewol { class Widget; @@ -70,40 +71,10 @@ namespace ewol { // ---------------------------------------------------------------------------------------------------------------- // -- Widget Size: // ---------------------------------------------------------------------------------------------------------------- - private: - bool m_hide; //!< hide a widget on the display protected: - // internal element calculated by the system - float m_zoom; //!< generic widget zoom - vec2 m_origin; //!< internal ... I do not really known how i can use it ... - vec2 m_size; //!< internal : current size of the widget - vec2 m_minSize; //!< user define the minimum size of the widget - // user configuaration - vec2 m_userMinSize; //!< user define the minimum size of the widget - vec2 m_userMaxSize; //!< user define the maximum size of the widget + vec2 m_size; //!< internal : current size of the widget + vec2 m_minSize; //!< user define the minimum size of the widget public: - /** - * @brief Set the zoom property of the widget - * @param[in] newVal newZoom value - */ - void SetZoom(float newVal); - /** - * @brief Get the zoom property of the widget - * @return the current zoom value - */ - float GetZoom(void); - /** - * @brief Set origin at the widget (must be an parrent widget that set this parameter). - * This represent the absolute origin in the program windows - * @param[in] x Position ot hte horizantal origin - * @param[in] y Position ot hte vertical origin - */ - void SetOrigin(float x, float y); - /** - * @brief Get the origin (obsolute position in the windows) - * @return coordonate of the origin requested - */ - vec2 GetOrigin(void); /** * @brief Convert the absolute position in the local Position (Relative) * @param[in] pos Absolute position that you request convertion @@ -113,34 +84,62 @@ namespace ewol { /** * @brief Parrent set the possible diplay size of the current widget whith his own possibilities * By default this save the widget availlable size in the widget size - * @param[in] availlableX Availlable horisantal pixel size - * @param[in] availlableY Availlable vertical pixel size + * @param[in] availlable Availlable x&y pixel size */ - // TODO : Remove bool ==> deprecated ... - // TODO : Rename in SetSize() - virtual bool CalculateSize(float availlableX, float availlableY); - //update the min Size ... and the expend parameters for the sizer + virtual void CalculateSize(const vec2& availlable); /** * @brief Calculate the minimum size of the widget that is needed to display or the user requested) */ - // TODO : Remove bool ==> deprecated ... - virtual bool CalculateMinSize(void); + virtual void CalculateMinSize(void); + protected: + // internal element calculated by the system + float m_zoom; //!< generic widget zoom + public: + /** + * @brief Set the zoom property of the widget + * @param[in] newVal newZoom value + */ + virtual void SetZoom(float newVal); + /** + * @brief Get the zoom property of the widget + * @return the current zoom value + */ + virtual float GetZoom(void); + protected: + vec2 m_origin; //!< internal ... I do not really known how i can use it ... + public: + /** + * @brief Set origin at the widget (must be an parrent widget that set this parameter). + * This represent the absolute origin in the program windows + * @param[in] pos Position of the origin + */ + virtual void SetOrigin(const vec2& pos); + /** + * @brief Get the origin (obsolute position in the windows) + * @return coordonate of the origin requested + */ + virtual vec2 GetOrigin(void); + protected: + vec2 m_userMinSize; //!< user define the minimum size of the widget + public: /** * @brief User set the minimum size he want to set the display - * @param[in] x Set minimum horizontal size (-1 : no requested) - * @param[in] y Set minimum vertical size (-1 : no requested) + * @param[in] size Set minimum size (none : 0) */ - virtual void SetMinSize(float x=-1, float y=-1); + virtual void SetMinSize(const vec2& size); /** * @brief Get the current calculated min size * @return the size requested */ - vec2 GetMinSize(void); + virtual vec2 GetMinSize(void); /** * @brief Check if the current min size is compatible wit hte user minimum size * If it is not the user minimum size will overWrite the minimum size set. */ - void CheckMinSize(void); + virtual void CheckMinSize(void); + protected: + vec2 m_userMaxSize; //!< user define the maximum size of the widget + public: /** * @brief User set the maximum size he want to set the display * @param[in] size The new maximum size requested (vec2(-1,-1) to unset) @@ -150,114 +149,90 @@ namespace ewol { * @brief Get the current maximum size * @return the size requested */ - vec2 GetMaxSize(void); + virtual vec2 GetMaxSize(void); /** * @brief Get the widget size * @return Requested size */ - vec2 GetSize(void); + virtual vec2 GetSize(void); protected: - bvec2 m_userExpend; + bvec2 m_userExpend; // TODO : Rename expand ... :p public: /** - * @brief Set the horizontal expend capacity - * @param[in] newExpend new Expend state + * @brief Set the expend capabilities (x&y) + * @param[in] newExpend 2D boolean repensent the capacity to expend */ - virtual void SetExpendX(bool newExpend=false); - /** - * @brief Get the horizontal expend capabilities - * @return boolean repensent the capacity to expend - */ - virtual bool CanExpentX(void); - /** - * @brief Set the vertical expend capacity - * @param[in] newExpend new Expend state - */ - virtual void SetExpendY(bool newExpend=false); - /** - * @brief Get the vertical expend capabilities - * @return boolean repensent the capacity to expend - */ - virtual bool CanExpentY(void); + virtual void SetExpand(const bvec2& newExpend); /** * @brief Get the expend capabilities (x&y) * @return 2D boolean repensent the capacity to expend */ - virtual bvec2 CanExpent(void); + virtual bvec2 CanExpand(void); protected: bvec2 m_userFill; public: /** - * @brief Set the horizontal filling capacity - * @param[in] newFill new fill state + * @brief Set the x&y filling capacity + * @param[in] newFill new x&y fill state */ - virtual void SetFillX(bool newFill=false); + virtual void SetFill(const bvec2& newFill); /** - * @brief Get the horizontal filling capabilities - * @return boolean repensent the capacity to horizontal filling + * @brief Get the filling capabilities x&y + * @return bvec2 repensent the capacity to x&y filling */ - bool CanFillX(void); - /** - * @brief Set the vertical filling capacity - * @param[in] newFill new fill state - */ - virtual void SetFillY(bool newFill=false); - /** - * @brief Get the vertical filling capabilities - * @return boolean repensent the capacity to vertical filling - */ - bool CanFillY(void); + const bvec2& CanFill(void); + protected: + bool m_hide; //!< hide a widget on the display + public: /** * @brief Set the widget hidden */ - void Hide(void); + virtual void Hide(void); /** * @brief Set the widget visible */ - void Show(void); + virtual void Show(void); /** * @brief Get the visibility of the widget * @return true: if the widget is hiden, false: it is visible */ - bool IsHide(void) { return m_hide; }; - - + virtual bool IsHide(void) { return m_hide; }; // ---------------------------------------------------------------------------------------------------------------- // -- Focus Area // ---------------------------------------------------------------------------------------------------------------- private: - bool m_hasFocus; //!< set the focus on this widget - bool m_canFocus; //!< the focus can be done on this widget + bool m_hasFocus; //!< set the focus on this widget + bool m_canFocus; //!< the focus can be done on this widget public: /** * @brief Get the focus state of the widget * @return Focus state */ - bool GetFocus(void) { return m_hasFocus;}; + virtual bool GetFocus(void) { return m_hasFocus;}; /** * @brief Get the capability to have focus * @return State capability to have focus */ - bool CanHaveFocus(void) { return m_canFocus;}; + virtual bool CanHaveFocus(void) { return m_canFocus;}; /** * @brief Set focus on this widget * @return return true if the widget keep the focus */ - bool SetFocus(void); + virtual bool SetFocus(void); /** * @brief Remove the focus on this widget * @return return true if the widget have release his focus (if he has it) */ - bool RmFocus(void); + virtual bool RmFocus(void); /** * @brief Set the capability to have the focus * @param[in] canFocusState new focus capability */ - void SetCanHaveFocus(bool canFocusState); + virtual void SetCanHaveFocus(bool canFocusState); /** * @brief Keep the focus on this widget ==> this remove the previous focus on all other widget */ - void KeepFocus(void); + virtual void KeepFocus(void); protected: /** * @brief Event of the focus has been grep by the current widget @@ -278,12 +253,12 @@ namespace ewol { * @brief Get the number of mouse event supported * @return return the number of event that the mouse supported [0..3] */ - int32_t GetMouseLimit(void) { return m_limitMouseEvent; }; + virtual int32_t GetMouseLimit(void) { return m_limitMouseEvent; }; /** * @brief Get the number of mouse event supported * @param[in] numberState The number of event that the mouse supported [0..3] */ - void SetMouseLimit(int32_t numberState) { m_limitMouseEvent = numberState; }; + virtual void SetMouseLimit(int32_t numberState) { m_limitMouseEvent = numberState; }; // ---------------------------------------------------------------------------------------------------------------- // -- keyboard event properties Area @@ -296,12 +271,12 @@ namespace ewol { * @return true : the event can be repeated. * @return false : the event must not be repeated. */ - bool GetKeyboardRepeate(void) { return m_allowRepeateKeyboardEvent; }; + virtual bool GetKeyboardRepeate(void) { return m_allowRepeateKeyboardEvent; }; /** * @brief Set the keyboard repeating event supporting. * @param[in] state The repeating status (true: enable, false disable). */ - void SetKeyboardRepeate(bool state) { m_allowRepeateKeyboardEvent = state; }; + virtual void SetKeyboardRepeate(bool state) { m_allowRepeateKeyboardEvent = state; }; // ---------------------------------------------------------------------------------------------------------------- // -- Periodic call Area @@ -311,7 +286,7 @@ namespace ewol { * @brief Request that the current widegt have a periodic call * @param statusToSet true if the periodic call is needed */ - void PeriodicCallSet(bool statusToSet); + virtual void PeriodicCallSet(bool statusToSet); public: /** * @brief Periodic call of this widget @@ -370,11 +345,11 @@ namespace ewol { * @param[in] generateEventId Event generic of the element * @param[in] data Associate data wit the event */ - void ShortCutAdd(const char * descriptiveString, const char * generateEventId, etk::UString data="", bool broadcast=false); + virtual void ShortCutAdd(const char * descriptiveString, const char * generateEventId, etk::UString data="", bool broadcast=false); /** * @brief Remove all curent shortCut */ - void ShortCutClean(void); + virtual void ShortCutClean(void); public: /** * @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref OnEventKb) @@ -394,13 +369,13 @@ namespace ewol { /** * @brief The widget mark itself that it need to regenerate the nest time. */ - void MarkToRedraw(void); + virtual void MarkToRedraw(void); /** * @brief Get the need of the redrawing of the widget and reset it to false * @return true if we need to redraw * @return false if we have no need to redraw */ - bool NeedRedraw(void) { bool tmpData=m_needRegenerateDisplay; m_needRegenerateDisplay=false; return tmpData; }; + virtual bool NeedRedraw(void) { bool tmpData=m_needRegenerateDisplay; m_needRegenerateDisplay=false; return tmpData; }; public: /** * @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...]) @@ -429,16 +404,16 @@ namespace ewol { * @note : the generation of the offset is due to the fact the cursor position is forced at the center of the widget. * @note This done nothing in "Finger" or "Stylet" mode. */ - void GrabCursor(void); + virtual void GrabCursor(void); /** * @brief Un-Grab the cursor (default mode cursor offset) */ - void UnGrabCursor(void); + virtual void UnGrabCursor(void); /** * @brief Get the grabbing status of the cursor. * @return true if the cursor is curently grabbed */ - bool GetGrabStatus(void); + virtual bool GetGrabStatus(void); // DisplayCursorType private: ewol::cursorDisplay_te m_cursorDisplay; @@ -447,13 +422,29 @@ namespace ewol { * @brief Set the cursor display type. * @param[in] newCursor selected new cursor. */ - void SetCursor(ewol::cursorDisplay_te newCursor); + virtual void SetCursor(ewol::cursorDisplay_te newCursor); /** * @brief Get the currrent cursor. * @return the type of the cursor. */ - ewol::cursorDisplay_te GetCursor(void); - + virtual ewol::cursorDisplay_te GetCursor(void); + private: + etk::UString m_widgetName; + public: + /** + * @brief Load properties with an XML node. + * @param[in] node Pointer on the tinyXML node. + * @return true : All has been done corectly. + * @return false : An error occured. + */ + virtual bool LoadXML(TiXmlNode* node); + /** + * @brief Store properties in this XML node. + * @param[in,out] node Pointer on the tinyXML node. + * @return true : All has been done corectly. + * @return false : An error occured. + */ + virtual bool StoreXML(TiXmlNode* node); }; // end of the class Widget declaration diff --git a/sources/ewol/widget/WidgetManager.cpp b/sources/ewol/widget/WidgetManager.cpp index 51ef8d71..dc51fc39 100644 --- a/sources/ewol/widget/WidgetManager.cpp +++ b/sources/ewol/widget/WidgetManager.cpp @@ -10,7 +10,16 @@ #include #include #include -//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #undef __class__ @@ -22,9 +31,21 @@ static bool IsInit = false; static ewol::Widget * m_focusWidgetDefault = NULL; static ewol::Widget * m_focusWidgetCurrent = NULL; static etk::Vector l_listOfPeriodicWidget; -static bool l_havePeriodic = false; +static bool l_havePeriodic = false; + +static bool l_haveRedraw = true; + + +class dataStructCreator +{ + public: + etk::UString name; + ewol::widgetManager::creator_tf pointer; +}; + +static etk::Vector l_creatorList; + -static bool l_haveRedraw = true; void ewol::widgetManager::Init(void) { @@ -32,10 +53,23 @@ void ewol::widgetManager::Init(void) // prevent android error ==> can create memory leak but I prefer m_focusWidgetDefault = NULL; m_focusWidgetCurrent = NULL; + l_creatorList.Clear(); l_listOfPeriodicWidget.Clear(); l_havePeriodic = false; l_haveRedraw = true; //ewol::WIDGET_SceneInit(); + widget::Button::Init(); + widget::ButtonColor::Init(); + widget::Spacer::Init(); + widget::Slider::Init(); + widget::Sizer::Init(); + widget::ProgressBar::Init(); + widget::Layer::Init(); + widget::Label::Init(); + widget::Image::Init(); + widget::Gird::Init(); + widget::Entry::Init(); + widget::CheckBox::Init(); IsInit = true; } @@ -46,9 +80,24 @@ void ewol::widgetManager::UnInit(void) ewol::widgetManager::FocusSetDefault(NULL); ewol::widgetManager::FocusRelease(); + + widget::CheckBox::UnInit(); + widget::Entry::UnInit(); + widget::Gird::UnInit(); + widget::Image::UnInit(); + widget::Label::UnInit(); + widget::Layer::UnInit(); + widget::ProgressBar::UnInit(); + widget::Sizer::UnInit(); + widget::Slider::UnInit(); + widget::Spacer::UnInit(); + widget::ButtonColor::UnInit(); + widget::Button::UnInit(); + IsInit = false; l_listOfPeriodicWidget.Clear(); + l_creatorList.Clear(); } void ewol::widgetManager::Rm(ewol::Widget * newWidget) @@ -203,3 +252,64 @@ bool ewol::widgetManager::IsDrawingNeeded(void) l_haveRedraw = false; return tmp; } + + + +// element that generate the list of elements +void ewol::widgetManager::AddWidgetCreator(const etk::UString& name, ewol::widgetManager::creator_tf pointer) +{ + for (int32_t iii=0; iii #include #include +#include namespace ewol { namespace widgetManager { - void Init( void); - void UnInit(void); + void Init(void); + void UnInit(void); // need to call when remove a widget to clear all dependency of the focus system - void Rm( ewol::Widget * newWidget); + void Rm(ewol::Widget * newWidget); - void FocusKeep( ewol::Widget * newWidget); // set the focus at the specific widget - void FocusSetDefault(ewol::Widget * newWidget); // select the default focus getter - void FocusRelease( void); // Release focus from the current widget to the default - ewol::Widget * FocusGet( void); - void FocusRemoveIfRemove(ewol::Widget * newWidget); + void FocusKeep(ewol::Widget * newWidget); // set the focus at the specific widget + void FocusSetDefault(ewol::Widget * newWidget); // select the default focus getter + void FocusRelease(void); // Release focus from the current widget to the default + ewol::Widget* FocusGet(void); + void FocusRemoveIfRemove(ewol::Widget * newWidget); - void PeriodicCallAdd(ewol::Widget * pWidget); - void PeriodicCallRm( ewol::Widget * pWidget); - void PeriodicCall(int64_t localTime); - bool PeriodicCallHave(void); + void PeriodicCallAdd(ewol::Widget * pWidget); + void PeriodicCallRm( ewol::Widget * pWidget); + void PeriodicCall(int64_t localTime); + bool PeriodicCallHave(void); - void MarkDrawingIsNeeded(void); - bool IsDrawingNeeded(void); + void MarkDrawingIsNeeded(void); + bool IsDrawingNeeded(void); + + typedef ewol::Widget* (*creator_tf)(void); + // element that generate the list of elements + void AddWidgetCreator(const etk::UString& name, creator_tf pointer); + ewol::Widget* Create(const etk::UString& name); + bool Exist(const etk::UString& name); + etk::UString List(void); }; }; diff --git a/sources/ewol/widget/Windows.cpp b/sources/ewol/widget/Windows.cpp index 3ed2546d..d4380751 100644 --- a/sources/ewol/widget/Windows.cpp +++ b/sources/ewol/widget/Windows.cpp @@ -50,23 +50,22 @@ ewol::Windows::~Windows(void) } -bool ewol::Windows::CalculateSize(float availlableX, float availlableY) +void ewol::Windows::CalculateSize(const vec2& availlable) { //EWOL_DEBUG("calculateMinSize on : " << m_currentCreateId); - m_size.setValue(availlableX, availlableY); + m_size = availlable; if (NULL != m_subWidget) { m_subWidget->CalculateMinSize(); // TODO : Check if min Size is possible ... // TODO : Herited from MinSize .. and expand ??? - m_subWidget->CalculateSize(m_size.x(), m_size.y()); + m_subWidget->CalculateSize(m_size); } for(int32_t iii=0; iiiCalculateMinSize(); - m_popUpWidgetList[iii]->CalculateSize(m_size.x(), m_size.y()); + m_popUpWidgetList[iii]->CalculateSize(m_size); } } - return true; } @@ -191,7 +190,7 @@ void ewol::Windows::SetSubWidget(ewol::Widget * widget) } m_subWidget = widget; // Regenerate the size calculation : - CalculateSize(m_size.x(), m_size.y()); + CalculateSize(m_size); } @@ -199,7 +198,7 @@ void ewol::Windows::PopUpWidgetPush(ewol::Widget * widget) { m_popUpWidgetList.PushBack(widget); // Regenerate the size calculation : - CalculateSize(m_size.x(), m_size.y()); + CalculateSize(m_size); // TODO : it is dansgerous to access directly to the system ... eSystem::ResetIOEvent(); } diff --git a/sources/ewol/widget/Windows.h b/sources/ewol/widget/Windows.h index dd437155..d5a85074 100644 --- a/sources/ewol/widget/Windows.h +++ b/sources/ewol/widget/Windows.h @@ -21,7 +21,7 @@ namespace ewol { Windows(void); virtual ~Windows(void); // Derived function - virtual const char * const GetObjectType(void) { return "EwolWindows"; }; + virtual const char * const GetObjectType(void) { return "Ewol::Windows"; }; // internal event at ewol system : public: void SysDraw(void); @@ -36,9 +36,9 @@ namespace ewol { virtual void On(void) { }; public: // Derived function - virtual bool CalculateSize(float availlableX, float availlableY); + virtual void CalculateSize(const vec2& availlable); // Derived function - virtual ewol::Widget * GetWidgetAtPos(vec2 pos); + virtual ewol::Widget * GetWidgetAtPos(vec2 pos); private: bool m_hasDecoration; public: @@ -52,8 +52,8 @@ namespace ewol { m_hasDecoration = true; } private: - ewol::Widget* m_subWidget; - etk::Vector m_popUpWidgetList; + ewol::Widget* m_subWidget; + etk::Vector m_popUpWidgetList; public: void SetSubWidget(ewol::Widget * widget); void PopUpWidgetPush(ewol::Widget * widget); diff --git a/sources/ewol/widget/meta/FileChooser.h b/sources/ewol/widget/meta/FileChooser.h index c52947c3..9e3dbb4e 100644 --- a/sources/ewol/widget/meta/FileChooser.h +++ b/sources/ewol/widget/meta/FileChooser.h @@ -28,10 +28,8 @@ namespace widget { FileChooser(void); virtual ~FileChooser(void); // Derived function - virtual const char * const GetObjectType(void) { return "EwolFileChooser"; }; - // Derived function + virtual const char * const GetObjectType(void) { return "Ewol::FileChooser"; }; virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, const etk::UString& data); - // Derived function virtual void OnObjectRemove(ewol::EObject * removeObject); void SetTitle(etk::UString label); void SetValidateLabel(etk::UString label); diff --git a/sources/file.mk b/sources/file.mk index 4b920127..a3be57d3 100644 --- a/sources/file.mk +++ b/sources/file.mk @@ -64,6 +64,7 @@ FILE_LIST+= ewol/widget/Widget.cpp \ ewol/widget/CheckBox.cpp \ ewol/widget/ColorBar.cpp \ ewol/widget/ContextMenu.cpp \ + ewol/widget/Composer.cpp \ ewol/widget/Drawable.cpp \ ewol/widget/Entry.cpp \ ewol/widget/Joystick.cpp \