From e6e817bfcd9b3ff13b93c51468a4245457f1fa82 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 14 Feb 2016 15:04:44 +0100 Subject: [PATCH] [DEV] continue integration of property (build but seg fault) --- ewol/context/InputManager.cpp | 8 +- ewol/object/Manager.cpp | 4 +- ewol/object/Object.cpp | 6 +- ewol/translate.cpp | 5 +- ewol/widget/Button.cpp | 115 ++++--- ewol/widget/Button.h | 11 +- ewol/widget/ButtonColor.cpp | 49 ++- ewol/widget/ButtonColor.h | 8 +- ewol/widget/CheckBox.cpp | 63 ++-- ewol/widget/CheckBox.h | 2 +- ewol/widget/ColorBar.cpp | 214 ++++++------ ewol/widget/ColorBar.h | 6 +- ewol/widget/Container.cpp | 16 +- ewol/widget/Container2.cpp | 12 +- ewol/widget/ContainerN.cpp | 29 +- ewol/widget/ContainerN.h | 10 +- ewol/widget/ContextMenu.cpp | 99 +++--- ewol/widget/ContextMenu.h | 9 +- ewol/widget/Entry.cpp | 236 +++++++------ ewol/widget/Entry.h | 17 - ewol/widget/Gird.cpp | 61 ++-- ewol/widget/Image.cpp | 186 +++++----- ewol/widget/Image.h | 137 +------- ewol/widget/Joystick.cpp | 2 +- ewol/widget/Joystick.h | 1 + ewol/widget/Label.cpp | 32 +- ewol/widget/Label.h | 29 +- ewol/widget/Layer.cpp | 7 +- ewol/widget/List.cpp | 4 +- ewol/widget/ListFileSystem.cpp | 78 ++--- ewol/widget/ListFileSystem.h | 97 +----- ewol/widget/Manager.cpp | 4 +- ewol/widget/Menu.cpp | 12 +- ewol/widget/PopUp.cpp | 129 ++++--- ewol/widget/PopUp.h | 38 +-- ewol/widget/ProgressBar.cpp | 66 ++-- ewol/widget/ProgressBar.h | 19 +- ewol/widget/Scroll.cpp | 75 ++-- ewol/widget/Scroll.h | 20 +- ewol/widget/Select.cpp | 33 +- ewol/widget/Select.h | 27 +- ewol/widget/Sizer.cpp | 70 ++-- ewol/widget/Sizer.h | 99 +----- ewol/widget/Slider.cpp | 50 +-- ewol/widget/Slider.h | 77 +---- ewol/widget/Spacer.cpp | 12 +- ewol/widget/Spacer.h | 17 +- ewol/widget/Spin.cpp | 37 +- ewol/widget/WSlider.cpp | 54 +-- ewol/widget/WSlider.h | 45 +-- ewol/widget/Widget.cpp | 124 +++---- ewol/widget/Widget.h | 144 ++------ ewol/widget/WidgetScrolled.cpp | 27 +- ewol/widget/WidgetScrolled.h | 5 + ewol/widget/Windows.cpp | 8 +- ewol/widget/Windows.h | 4 +- ewol/widget/meta/ColorChooser.cpp | 141 ++++---- ewol/widget/meta/ColorChooser.h | 7 +- ewol/widget/meta/FileChooser.cpp | 102 +++--- ewol/widget/meta/FileChooser.h | 15 +- ewol/widget/meta/Parameter.cpp | 88 ++--- ewol/widget/meta/Parameter.h | 4 +- ewol/widget/meta/ParameterList.cpp | 2 +- ewol/widget/meta/SpinBase.cpp | 58 ++-- ewol/widget/meta/SpinBase.h | 3 +- ewol/widget/meta/StdPopUp.cpp | 38 +-- ewol/widget/meta/StdPopUp.h | 2 + lutin_ewol-tools-visual-test.py | 6 - tools/visual_test/appl/MainWindows.cpp | 47 ++- tools/visual_test/appl/TestButton.cpp | 210 ------------ tools/visual_test/appl/TestButton.h | 32 -- tools/visual_test/appl/TestButtonColor.cpp | 125 ------- tools/visual_test/appl/TestButtonColor.h | 36 -- tools/visual_test/appl/TestCheckBox.cpp | 180 ---------- tools/visual_test/appl/TestCheckBox.h | 34 -- tools/visual_test/appl/TestDistanceField.cpp | 4 +- tools/visual_test/appl/TestEntry.cpp | 0 tools/visual_test/appl/TestEntry.h | 0 tools/visual_test/appl/TestImage.cpp | 145 -------- tools/visual_test/appl/TestImage.h | 36 -- tools/visual_test/appl/TestLabel.cpp | 180 ---------- tools/visual_test/appl/TestLabel.h | 44 --- tools/visual_test/appl/TestProgressBar.cpp | 0 tools/visual_test/appl/TestProgressBar.h | 0 tools/visual_test/appl/TestScene.cpp | 340 ------------------- tools/visual_test/appl/TestScene.h | 25 -- tools/visual_test/appl/TestSlider.cpp | 0 tools/visual_test/appl/TestSlider.h | 0 tools/visual_test/appl/WidgetTest.cpp | 0 tools/visual_test/appl/WidgetTest.h | 0 tools/visual_test/appl/init.cpp | 3 - tools/visual_test/appl/widget/SizerColor.cpp | 149 -------- tools/visual_test/appl/widget/SizerColor.h | 50 --- 93 files changed, 1342 insertions(+), 3513 deletions(-) delete mode 100644 tools/visual_test/appl/TestButton.cpp delete mode 100644 tools/visual_test/appl/TestButton.h delete mode 100644 tools/visual_test/appl/TestButtonColor.cpp delete mode 100644 tools/visual_test/appl/TestButtonColor.h delete mode 100644 tools/visual_test/appl/TestCheckBox.cpp delete mode 100644 tools/visual_test/appl/TestCheckBox.h delete mode 100644 tools/visual_test/appl/TestEntry.cpp delete mode 100644 tools/visual_test/appl/TestEntry.h delete mode 100644 tools/visual_test/appl/TestImage.cpp delete mode 100644 tools/visual_test/appl/TestImage.h delete mode 100644 tools/visual_test/appl/TestLabel.cpp delete mode 100644 tools/visual_test/appl/TestLabel.h delete mode 100644 tools/visual_test/appl/TestProgressBar.cpp delete mode 100644 tools/visual_test/appl/TestProgressBar.h delete mode 100644 tools/visual_test/appl/TestScene.cpp delete mode 100644 tools/visual_test/appl/TestScene.h delete mode 100644 tools/visual_test/appl/TestSlider.cpp delete mode 100644 tools/visual_test/appl/TestSlider.h delete mode 100644 tools/visual_test/appl/WidgetTest.cpp delete mode 100644 tools/visual_test/appl/WidgetTest.h delete mode 100644 tools/visual_test/appl/widget/SizerColor.cpp delete mode 100644 tools/visual_test/appl/widget/SizerColor.h diff --git a/ewol/context/InputManager.cpp b/ewol/context/InputManager.cpp index 168a1e29..494f54eb 100644 --- a/ewol/context/InputManager.cpp +++ b/ewol/context/InputManager.cpp @@ -359,8 +359,8 @@ void ewol::context::InputManager::state(enum gale::key::type _type, // we have an event previously ... check delay between click and offset position if (currentTime - eventTable[_pointerID].lastTimeEvent > localLimit.sepatateTime) { cleanElement(eventTable, _pointerID); - } else if( abs(eventTable[_pointerID].downStart.x() - _pos.x()) >= localLimit.DpiOffset - || abs(eventTable[_pointerID].downStart.y() - _pos.y()) >= localLimit.DpiOffset ){ + } else if( std::abs(eventTable[_pointerID].downStart.x() - _pos.x()) >= localLimit.DpiOffset + || std::abs(eventTable[_pointerID].downStart.y() - _pos.y()) >= localLimit.DpiOffset ){ cleanElement(eventTable, _pointerID); } } @@ -442,8 +442,8 @@ void ewol::context::InputManager::state(enum gale::key::type _type, gale::key::status_up, _pos); // generate event (single) - if( abs(eventTable[_pointerID].downStart.x() - _pos.x()) < localLimit.DpiOffset - && abs(eventTable[_pointerID].downStart.y() - _pos.y()) < localLimit.DpiOffset ){ + if( std::abs(eventTable[_pointerID].downStart.x() - _pos.x()) < localLimit.DpiOffset + && std::abs(eventTable[_pointerID].downStart.y() - _pos.y()) < localLimit.DpiOffset ){ // Save current position : eventTable[_pointerID].downStart = _pos; // save start time diff --git a/ewol/object/Manager.cpp b/ewol/object/Manager.cpp index 53d3abc7..34e5d9bf 100644 --- a/ewol/object/Manager.cpp +++ b/ewol/object/Manager.cpp @@ -44,7 +44,7 @@ void ewol::object::Manager::displayListObject() { for (auto &it : m_eObjectList) { std::shared_ptr element = it.lock(); if (element != nullptr) { - EWOL_INFO(" [" << element->getId() << "] ref=" << element.use_count()-1 << " name='" << element->getName() << "' type=" << element->getObjectType()); + EWOL_INFO(" [" << element->getId() << "] ref=" << element.use_count()-1 << " name='" << element->propertyName.get() << "' type=" << element->getObjectType()); } } } @@ -102,7 +102,7 @@ std::shared_ptr ewol::object::Manager::get(const std::string& _nam for (auto &it : m_eObjectList) { std::shared_ptr element = it.lock(); if ( element != nullptr - && element->getName() == _name) { + && element->propertyName.get() == _name) { return element; } } diff --git a/ewol/object/Object.cpp b/ewol/object/Object.cpp index 56a0d443..d75c38bd 100644 --- a/ewol/object/Object.cpp +++ b/ewol/object/Object.cpp @@ -46,10 +46,10 @@ void ewol::Object::removeParent() { } ewol::Object::Object() : + propertyName(*this, "name", "", "Object name, might be a unique reference in all the program"), m_objectHasBeenInit(false), m_destroy(false), m_static(false), - m_name(*this, "name", "", "Object name, might be a unique reference in all the program"), m_isResource(false) { // note this is nearly atomic ... (but it is enough) m_uniqueId = m_valUID++; @@ -70,7 +70,7 @@ void ewol::Object::init() { void ewol::Object::init(const std::string& _name) { init(); - m_name = _name; + propertyName.set(_name); } const char * const ewol::Object::getObjectType() { @@ -159,7 +159,7 @@ std::shared_ptr ewol::Object::getObjectNamed(const std::string& _o } std::shared_ptr ewol::Object::getSubObjectNamed(const std::string& _objectName) { - if (_objectName == m_name.get()) { + if (_objectName == propertyName.get()) { return shared_from_this(); } return nullptr; diff --git a/ewol/translate.cpp b/ewol/translate.cpp index c5f0fc88..6b312c3e 100644 --- a/ewol/translate.cpp +++ b/ewol/translate.cpp @@ -105,7 +105,10 @@ class LocalInstanceTranslation { const std::string& get(const std::string& _instance) { loadTranslation(); - auto it = m_translate.find(_instance); + if (etk::start_with(_instance, "TRANSLATE:") == false) { + return _instance; + } + auto it = m_translate.find(std::string(_instance.begin() + 9, _instance.end())); if (it == m_translate.end()) { EWOL_DEBUG("Can not find tranlation : '" << _instance << "'"); return _instance; diff --git a/ewol/widget/Button.cpp b/ewol/widget/Button.cpp index c32c6202..99ca5ffc 100644 --- a/ewol/widget/Button.cpp +++ b/ewol/widget/Button.cpp @@ -14,11 +14,11 @@ #define __class__ "Button" -// DEFINE for the shader display system : -#define STATUS_UP (0) -#define STATUS_HOVER (2) -#define STATUS_PRESSED (1) -#define STATUS_DOWN (3) +// DEFINE for the shader display system: +const static int32_t STATUS_UP(0); +const static int32_t STATUS_HOVER(2); +const static int32_t STATUS_PRESSED(1); +const static int32_t STATUS_DOWN(3); ewol::widget::Button::Button() : signalPressed(*this, "pressed", "Button is pressed"), @@ -27,11 +27,11 @@ ewol::widget::Button::Button() : signalEnter(*this, "enter", "The cursor enter inside the button"), signalLeave(*this, "leave", "the cursor leave the button"), signalValue(*this, "value", "button value change"), - m_shaper(*this, "shaper", "The display name for config file"), - m_value(*this, "value", false, "Value of the Button"), - m_lock(*this, "lock", lockNone, "Lock the button in a special state to permit changing state only by the coder"), - m_toggleMode(*this, "toggle", false, "The Button can toogle"), - m_enableSingle(*this, "enable-single", false, "If one element set in the Button ==> display only set"), + propertyShape(*this, "shaper", "", "The display name for config file"), + propertyValue(*this, "value", false, "Value of the Button"), + propertyLock(*this, "lock", lockNone, "Lock the button in a special state to permit changing state only by the coder"), + propertyToggleMode(*this, "toggle", false, "The Button can toogle"), + propertyEnableSingle(*this, "enable-single", false, "If one element set in the Button ==> display only set"), m_mouseHover(false), m_buttonPressed(false), m_selectableAreaPos(0,0), @@ -39,31 +39,29 @@ ewol::widget::Button::Button() : addObjectType("ewol::widget::Button"); // set property list: - m_lock.add(lockNone, "none"); - m_lock.add(lockWhenPressed, "pressed"); - m_lock.add(lockWhenReleased, "released"); - m_lock.add(lockAccess, "access"); + propertyLock.add(lockNone, "none"); + propertyLock.add(lockWhenPressed, "pressed"); + propertyLock.add(lockWhenReleased, "released"); + propertyLock.add(lockAccess, "access"); // shaper satatus update: CheckStatus(); - // This widget can have the focus ... - setCanHaveFocus(true); // Limit event at 1: setMouseLimit(1); } void ewol::widget::Button::init(const std::string& _shaperName) { ewol::widget::Container2::init(); - m_shaper->setSource(_shaperName); + propertyCanFocus.set(true); + propertyShape.set(_shaperName); } - ewol::widget::Button::~Button() { } void ewol::widget::Button::onChangeSize() { - ewol::Padding padding = m_shaper->getPadding(); + ewol::Padding padding = m_shaper.getPadding(); ewol::Padding ret = onChangeSizePadded(padding); //EWOL_DEBUG(" configuring : origin=" << origin << " size=" << subElementSize << ""); m_selectableAreaPos = vec2(ret.xLeft(), ret.yButtom()); @@ -72,13 +70,13 @@ void ewol::widget::Button::onChangeSize() { void ewol::widget::Button::calculateMinMaxSize() { - ewol::Padding padding = m_shaper->getPadding(); + ewol::Padding padding = m_shaper.getPadding(); calculateMinMaxSizePadded(padding); } void ewol::widget::Button::onDraw() { // draw the shaaper (if needed indeed) - m_shaper->draw(); + m_shaper.draw(); } void ewol::widget::Button::onRegenerateDisplay() { @@ -86,8 +84,8 @@ void ewol::widget::Button::onRegenerateDisplay() { if (needRedraw() == false) { return; } - ewol::Padding padding = m_shaper->getPadding(); - m_shaper->setShape(vec2(0,0), + ewol::Padding padding = m_shaper.getPadding(); + m_shaper.setShape(vec2(0,0), m_size, vec2ClipInt32(m_selectableAreaPos+vec2(padding.xLeft(),padding.yButtom()) ), vec2ClipInt32(m_selectableAreaSize-vec2(padding.x(),padding.y()) ) ); @@ -97,7 +95,7 @@ void ewol::widget::Button::onRegenerateDisplay() { bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { EWOL_VERBOSE("Event on BT : " << _event); // disable event in the lock access mode : - if(ewol::widget::Button::lockAccess == m_lock) { + if(ewol::widget::Button::lockAccess == propertyLock) { return false; } if( gale::key::status_leave == _event.getStatus() @@ -121,36 +119,36 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { if (true == m_mouseHover) { if (1 == _event.getId()) { if(gale::key::status_down == _event.getStatus()) { - EWOL_VERBOSE(getName() << " : Generate event : " << signalDown); + EWOL_VERBOSE(propertyName.get() << " : Generate event : " << signalDown); signalDown.emit(); m_buttonPressed = true; markToRedraw(); } if(gale::key::status_up == _event.getStatus()) { - EWOL_VERBOSE(getName() << " : Generate event : " << signalUp); + EWOL_VERBOSE(propertyName.get() << " : Generate event : " << signalUp); signalUp.emit(); m_buttonPressed = false; markToRedraw(); } if(gale::key::status_single == _event.getStatus()) { - if( ( m_value.get() == true - && ewol::widget::Button::lockWhenPressed == m_lock) - || ( m_value.get() == false - && ewol::widget::Button::lockWhenReleased == m_lock) ) { + if( ( propertyValue.get() == true + && ewol::widget::Button::lockWhenPressed == propertyLock) + || ( propertyValue.get() == false + && ewol::widget::Button::lockWhenReleased == propertyLock) ) { // nothing to do : Lock mode ... // user might set himself the new correct value with @ref setValue(xxx) } else { // inverse value : - setValue((m_value.get())?false:true); - EWOL_VERBOSE(getName() << " : Generate event : " << signalPressed); + propertyValue.set((propertyValue.get())?false:true); + EWOL_VERBOSE(propertyName.get() << " : Generate event : " << signalPressed); signalPressed.emit(); - EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value ); - signalValue.emit(m_value.get()); - if( m_toggleMode.get() == false - && m_value.get() == true) { - setValue(false); - EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value); - signalValue.emit(m_value.get()); + EWOL_VERBOSE(propertyName.get() << " : Generate event : " << signalValue << " val=" << propertyValue ); + signalValue.emit(propertyValue.get()); + if( propertyToggleMode.get() == false + && propertyValue.get() == true) { + propertyValue.set(false); + EWOL_VERBOSE(propertyName.get() << " : Generate event : " << signalValue << " val=" << propertyValue); + signalValue.emit(propertyValue.get()); } } markToRedraw(); @@ -175,7 +173,7 @@ bool ewol::widget::Button::onEventEntry(const ewol::event::Entry& _event) { void ewol::widget::Button::onLostFocus() { m_buttonPressed = false; - EWOL_VERBOSE(getName() << " : Remove Focus ..."); + EWOL_VERBOSE(propertyName.get() << " : Remove Focus ..."); CheckStatus(); } @@ -188,14 +186,14 @@ void ewol::widget::Button::CheckStatus() { changeStatusIn(STATUS_HOVER); return; } - if (m_value == true) { + if (propertyValue == true) { changeStatusIn(STATUS_DOWN); } changeStatusIn(STATUS_UP); } void ewol::widget::Button::changeStatusIn(int32_t _newStatusId) { - if (m_shaper->changeStatusIn(_newStatusId) == true) { + if (m_shaper.changeStatusIn(_newStatusId) == true) { periodicCallEnable(); markToRedraw(); } @@ -203,7 +201,7 @@ void ewol::widget::Button::changeStatusIn(int32_t _newStatusId) { void ewol::widget::Button::periodicCall(const ewol::event::Time& _event) { - if (m_shaper->periodicCall(_event) == false) { + if (m_shaper.periodicCall(_event) == false) { periodicCallDisable(); } markToRedraw(); @@ -211,17 +209,18 @@ void ewol::widget::Button::periodicCall(const ewol::event::Time& _event) { void ewol::widget::Button::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::widget::Container2::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_shaper) { + if (_paramPointer == propertyShape) { + m_shaper.setSource(propertyShape.get()); markToRedraw(); - } else if (_paramPointer == m_value) { - if (m_toggleMode == true) { - if (m_value.get() == false) { + } else if (_paramPointer == propertyValue) { + if (propertyToggleMode == true) { + if (propertyValue.get() == false) { m_idWidgetDisplayed = 0; } else { m_idWidgetDisplayed = 1; } } - if (m_enableSingle == true) { + if (propertyEnableSingle == true) { if ( m_idWidgetDisplayed == 0 && m_subWidget[0] == nullptr && m_subWidget[1] != nullptr) { @@ -234,28 +233,28 @@ void ewol::widget::Button::onPropertyChangeValue(const eproperty::Ref& _paramPoi } CheckStatus(); markToRedraw(); - } else if (_paramPointer == m_lock) { - if(ewol::widget::Button::lockAccess == m_lock.get()) { + } else if (_paramPointer == propertyLock) { + if(ewol::widget::Button::lockAccess == propertyLock.get()) { m_buttonPressed = false; m_mouseHover = false; } CheckStatus(); markToRedraw(); - } else if (_paramPointer == m_toggleMode) { - if (m_value.get() == true) { - m_value.get() = false; + } else if (_paramPointer == propertyToggleMode) { + if (propertyValue.get() == true) { + propertyValue.get() = false; // TODO : change display and send event ... } - if (m_toggleMode.get() == false) { + if (propertyToggleMode.get() == false) { m_idWidgetDisplayed = 0; } else { - if (m_value.get() == false) { + if (propertyValue.get() == false) { m_idWidgetDisplayed = 0; } else { m_idWidgetDisplayed = 1; } } - if (m_enableSingle.get() == true) { + if (propertyEnableSingle.get() == true) { if ( m_idWidgetDisplayed == 0 && m_subWidget[0] == nullptr && m_subWidget[1] != nullptr) { @@ -268,8 +267,8 @@ void ewol::widget::Button::onPropertyChangeValue(const eproperty::Ref& _paramPoi } CheckStatus(); markToRedraw(); - } else if (_paramPointer == m_enableSingle) { - if (m_enableSingle == true) { + } else if (_paramPointer == propertyEnableSingle) { + if (propertyEnableSingle == true) { if ( m_idWidgetDisplayed == 0 && m_subWidget[0] == nullptr && m_subWidget[1] != nullptr) { diff --git a/ewol/widget/Button.h b/ewol/widget/Button.h index 8d39df98..59ca00aa 100644 --- a/ewol/widget/Button.h +++ b/ewol/widget/Button.h @@ -40,7 +40,7 @@ namespace ewol { esignal::Signal signalLeave; esignal::Signal signalValue; public: // propertie list - eproperty::Value propertyShaper; //!< shaper name property + eproperty::Value propertyShape; //!< shaper name property eproperty::Value propertyValue; //!< Current state of the button. eproperty::List propertyLock; //!< Current lock state of the button. eproperty::Value propertyToggleMode; //!< The button is able to toggle. @@ -60,13 +60,6 @@ namespace ewol { * @brief Destructor */ virtual ~Button(); - /** - * @brief set the shaper name (use the contructer one this permit to not noad unused shaper) - * @param[in] _shaperName The new shaper filename - */ - void setShaperName(const std::string& _shaperName) { - m_shaper.setString(_shaperName); - } private: 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. @@ -93,7 +86,7 @@ namespace ewol { virtual bool onEventInput(const ewol::event::Input& _event); virtual bool onEventEntry(const ewol::event::Entry& _event); virtual void onDetectPresenceToggleWidget() { - setToggleMode(true); + propertyToggleMode.set(true); } private: // derived function virtual void periodicCall(const ewol::event::Time& _event); diff --git a/ewol/widget/ButtonColor.cpp b/ewol/widget/ButtonColor.cpp index ade22554..23c26f88 100644 --- a/ewol/widget/ButtonColor.cpp +++ b/ewol/widget/ButtonColor.cpp @@ -29,34 +29,29 @@ static const char* const eventColorHasChange = "ewol-widget-ButtonColor-colorCha ewol::widget::ButtonColor::ButtonColor() : signalChange(*this, "change", "Button color change value"), - m_widgetContextMenu(nullptr), - m_textColorFg(*this, "color", etk::color::black, "Current color") { + propertyValue(*this, "color", etk::color::black, "Current color"), + propertyShape(*this, "shape", "", "shape of the widget"), + m_widgetContextMenu(nullptr) { addObjectType("ewol::widget::ButtonColor"); changeStatusIn(STATUS_UP); - setCanHaveFocus(true); // Limit event at 1: setMouseLimit(1); } void ewol::widget::ButtonColor::init(etk::Color<> _baseColor, std::string _shaperName) { ewol::Widget::init(); - m_shaper.setSource(_shaperName); - m_textColorFg.set(_baseColor); + propertyCanFocus.set(true); + propertyShape.set(_shaperName); + propertyValue.set(_baseColor); } ewol::widget::ButtonColor::~ButtonColor() { } - -void ewol::widget::ButtonColor::setShaperName(std::string _shaperName) { - m_shaper.setSource(_shaperName); -} - - void ewol::widget::ButtonColor::calculateMinMaxSize() { ewol::Padding padding = m_shaper.getPadding(); - std::string label = m_textColorFg.getString(); + std::string label = propertyValue.getString(); vec3 minSize = m_text.calculateSize(label); m_minSize.setX(padding.x()*2 + minSize.x() + 7); m_minSize.setY(padding.y()*2 + minSize.y() ); @@ -81,7 +76,7 @@ void ewol::widget::ButtonColor::onRegenerateDisplay() { ewol::Padding padding = m_shaper.getPadding(); - std::string label = m_textColorFg.getString(); + std::string label = propertyValue.getString(); ivec2 localSize = m_minSize; @@ -93,12 +88,12 @@ void ewol::widget::ButtonColor::onRegenerateDisplay() { (m_size.y() - m_minSize.y()) / 2.0, 0); - if (true == m_userFill->x()) { + if (propertyFill->x() == true) { localSize.setX(m_size.x()); tmpOrigin.setX(0); tmpTextOrigin.setX(0); } - if (true == m_userFill->y()) { + if (propertyFill->y() == true) { localSize.setY(m_size.y()); } tmpOrigin += vec3(padding.xLeft(), padding.yButtom(), 0); @@ -107,20 +102,20 @@ void ewol::widget::ButtonColor::onRegenerateDisplay() { // clean the element m_text.reset(); - if( m_textColorFg.get().r() < 100 - || m_textColorFg.get().g() < 100 - || m_textColorFg.get().b() < 100) { + if( propertyValue.get().r() < 100 + || propertyValue.get().g() < 100 + || propertyValue.get().b() < 100) { m_text.setColor(etk::color::white); } else { m_text.setColor(etk::color::black); } m_text.setPos(tmpTextOrigin); - m_text.setColorBg(m_textColorFg.get()); + m_text.setColorBg(propertyValue.get()); m_text.setTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x(), ewol::compositing::alignCenter); m_text.print(label); - if (true == m_userFill->y()) { + if (propertyFill->y() == true) { tmpOrigin.setY(padding.yButtom()); } @@ -179,7 +174,7 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) { m_widgetContextMenu->setPositionMark(ewol::widget::ContextMenu::markButtom, tmpPos ); std::shared_ptr myColorChooser = widget::ColorChooser::create(); - myColorChooser->setColor(m_textColorFg.get()); + myColorChooser->propertyValue.set(propertyValue.get()); // set it in the pop-up-system : m_widgetContextMenu->setSubWidget(myColorChooser); myColorChooser->signalChange.bind(shared_from_this(), &ewol::widget::ButtonColor::onCallbackColorChange); @@ -210,18 +205,18 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) { } void ewol::widget::ButtonColor::onCallbackColorChange(const etk::Color<>& _color) { - setValue(_color); + propertyValue.set(_color); } void ewol::widget::ButtonColor::changeStatusIn(int32_t _newStatusId) { - if (true == m_shaper.changeStatusIn(_newStatusId) ) { + if (m_shaper.changeStatusIn(_newStatusId) == true) { periodicCallEnable(); markToRedraw(); } } void ewol::widget::ButtonColor::periodicCall(const ewol::event::Time& _event) { - if (false == m_shaper.periodicCall(_event) ) { + if (m_shaper.periodicCall(_event) == false) { periodicCallDisable(); } markToRedraw(); @@ -230,8 +225,10 @@ void ewol::widget::ButtonColor::periodicCall(const ewol::event::Time& _event) { void ewol::widget::ButtonColor::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::Widget::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_textColorFg) { - signalChange.emit(m_textColorFg); + if (_paramPointer == propertyValue) { + signalChange.emit(propertyValue); + } else if (_paramPointer == propertyShape) { + m_shaper.setSource(propertyShape.get()); markToRedraw(); } } \ No newline at end of file diff --git a/ewol/widget/ButtonColor.h b/ewol/widget/ButtonColor.h index 291e00c0..530c8e7b 100644 --- a/ewol/widget/ButtonColor.h +++ b/ewol/widget/ButtonColor.h @@ -23,7 +23,8 @@ namespace ewol { public: // signals esignal::Signal> signalChange; public: // properties - eproperty::Value> m_textColorFg; //!< Current color. + eproperty::Value> propertyValue; //!< Current color. + eproperty::Value propertyShape; //!< Current color. private: ewol::compositing::Shaper m_shaper; //!< Compositing theme. ewol::compositing::Text m_text; //!< Compositing Test display. @@ -47,11 +48,6 @@ namespace ewol { * @brief Main destructor. */ virtual ~ButtonColor(); - /** - * @brief set the shaper name (use the contructer one this permit to not noad unused shaper). - * @param[in] _shaperName The new shaper filename. - */ - void setShaperName(std::string _shaperName); protected: // Derived function virtual void onDraw(); public: // Derived function diff --git a/ewol/widget/CheckBox.cpp b/ewol/widget/CheckBox.cpp index 2b6cbcfb..93399247 100644 --- a/ewol/widget/CheckBox.cpp +++ b/ewol/widget/CheckBox.cpp @@ -25,20 +25,17 @@ ewol::widget::CheckBox::CheckBox() : signalUp(*this, "up", "CheckBox is UP"), signalEnter(*this, "enter", "The cursor enter inside the CheckBox"), signalValue(*this, "value", "CheckBox value change"), - propertyshaper(*this, "shaper", "The display name for config file"), - m_shaper(*this, "shaper", "The display name for config file"), + propertyValue(*this, "value", false, "Basic value of the widget"), + propertyShape(*this, "shape", "", "The display name for config file"), m_mouseHover(false), m_buttonPressed(false), m_selectableAreaPos(0,0), m_selectableAreaSize(0,0), m_shaperIdSize(-1), - m_shaperIdSizeInsize(-1), - m_value(*this, "value", false, "Basic value of the widget") { + m_shaperIdSizeInsize(-1) { addObjectType("ewol::widget::CheckBox"); // shaper satatus update: CheckStatus(); - // This widget can have the focus ... - setCanHaveFocus(true); // Limit event at 1: setMouseLimit(1); } @@ -46,9 +43,10 @@ ewol::widget::CheckBox::CheckBox() : void ewol::widget::CheckBox::init(const std::string& _shaperName) { ewol::widget::Container2::init(); - m_shaper->setSource(_shaperName); - m_shaperIdSize = m_shaper->requestConfig("box-size"); - m_shaperIdSizeInsize = m_shaper->requestConfig("box-inside"); + propertyCanFocus.set(true); + propertyShape.set(_shaperName); + m_shaperIdSize = m_shaper.requestConfig("box-size"); + m_shaperIdSizeInsize = m_shaper.requestConfig("box-inside"); } ewol::widget::CheckBox::~CheckBox() { @@ -56,8 +54,8 @@ ewol::widget::CheckBox::~CheckBox() { } void ewol::widget::CheckBox::onChangeSize() { - ewol::Padding padding = m_shaper->getPadding(); - float boxSize = m_shaper->getConfigNumber(m_shaperIdSize); + ewol::Padding padding = m_shaper.getPadding(); + float boxSize = m_shaper.getConfigNumber(m_shaperIdSize); padding.setXLeft(padding.xLeft()*2.0f + boxSize); ewol::Padding ret = onChangeSizePadded(padding); EWOL_DEBUG(" configuring : padding=" << padding << " boxSize=" << boxSize << ""); @@ -66,8 +64,8 @@ void ewol::widget::CheckBox::onChangeSize() { } void ewol::widget::CheckBox::calculateMinMaxSize() { - ewol::Padding padding = m_shaper->getPadding(); - float boxSize = m_shaper->getConfigNumber(m_shaperIdSize); + ewol::Padding padding = m_shaper.getPadding(); + float boxSize = m_shaper.getConfigNumber(m_shaperIdSize); padding.setXLeft(padding.xLeft()*2.0f + boxSize); calculateMinMaxSizePadded(padding); if (m_minSize.y() < padding.y()+boxSize) { @@ -77,7 +75,7 @@ void ewol::widget::CheckBox::calculateMinMaxSize() { void ewol::widget::CheckBox::onDraw() { // draw the shaaper (if needed indeed) - m_shaper->draw(); + m_shaper.draw(); } void ewol::widget::CheckBox::onRegenerateDisplay() { @@ -85,17 +83,17 @@ void ewol::widget::CheckBox::onRegenerateDisplay() { if (needRedraw() == false) { return; } - ewol::Padding padding = m_shaper->getPadding(); - float boxSize = m_shaper->getConfigNumber(m_shaperIdSize); - float boxInside = m_shaper->getConfigNumber(m_shaperIdSizeInsize); - m_shaper->clear(); + ewol::Padding padding = m_shaper.getPadding(); + float boxSize = m_shaper.getConfigNumber(m_shaperIdSize); + float boxInside = m_shaper.getConfigNumber(m_shaperIdSizeInsize); + m_shaper.clear(); EWOL_DEBUG(" configuring : boxSize=" << boxSize << " boxInside=" << boxInside << ""); vec2 origin(m_selectableAreaPos + vec2(0, (m_selectableAreaSize.y() - (boxSize+padding.y()))*0.5f)); vec2 size = vec2(boxSize+padding.x(), boxSize+padding.y()); vec2 origin2 = m_selectableAreaPos + vec2((boxSize-boxInside)*0.5f, (m_selectableAreaSize.y() - (boxInside+padding.y()))*0.5f); vec2 size2 = vec2(boxInside+padding.x(), boxInside+padding.y()); - m_shaper->setShape(vec2ClipInt32(origin), + m_shaper.setShape(vec2ClipInt32(origin), vec2ClipInt32(size), vec2ClipInt32(origin2+vec2(padding.xLeft(),padding.yButtom()) ), vec2ClipInt32(size2-vec2(padding.x(),padding.y()) )); @@ -127,24 +125,24 @@ bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) { if (true == m_mouseHover) { if (1 == _event.getId()) { if(gale::key::status_down == _event.getStatus()) { - EWOL_VERBOSE(getName() << " : Generate event : " << signalDown); + EWOL_VERBOSE(propertyName.get() << " : Generate event : " << signalDown); signalDown.emit(); m_buttonPressed = true; markToRedraw(); } if(gale::key::status_up == _event.getStatus()) { - EWOL_VERBOSE(getName() << " : Generate event : " << signalUp); + EWOL_VERBOSE(propertyName.get() << " : Generate event : " << signalUp); signalUp.emit(); m_buttonPressed = false; markToRedraw(); } if(gale::key::status_single == _event.getStatus()) { // inverse value : - setValue((m_value)?false:true); - EWOL_VERBOSE(getName() << " : Generate event : " << signalPressed); + propertyValue.set((propertyValue.get())?false:true); + EWOL_VERBOSE(propertyName.get() << " : Generate event : " << signalPressed); signalPressed.emit(); - EWOL_VERBOSE(getName() << " : Generate event : " << signalValue << " val=" << m_value ); - signalValue.emit(m_value.get()); + EWOL_VERBOSE(propertyName.get() << " : Generate event : " << signalValue << " val=" << propertyValue ); + signalValue.emit(propertyValue.get()); markToRedraw(); } } @@ -169,7 +167,7 @@ bool ewol::widget::CheckBox::onEventEntry(const ewol::event::Entry& _event) { } void ewol::widget::CheckBox::CheckStatus() { - if (m_shaper->setState(m_value==true?1:0) == true) { + if (m_shaper.setState(propertyValue==true?1:0) == true) { markToRedraw(); } if (m_buttonPressed == true) { @@ -187,7 +185,7 @@ void ewol::widget::CheckBox::CheckStatus() { } void ewol::widget::CheckBox::changeStatusIn(int32_t _newStatusId) { - if (m_shaper->changeStatusIn(_newStatusId) == true) { + if (m_shaper.changeStatusIn(_newStatusId) == true) { periodicCallEnable(); markToRedraw(); } @@ -195,7 +193,7 @@ void ewol::widget::CheckBox::changeStatusIn(int32_t _newStatusId) { void ewol::widget::CheckBox::periodicCall(const ewol::event::Time& _event) { - if (m_shaper->periodicCall(_event) == false) { + if (m_shaper.periodicCall(_event) == false) { periodicCallDisable(); } markToRedraw(); @@ -203,16 +201,17 @@ void ewol::widget::CheckBox::periodicCall(const ewol::event::Time& _event) { void ewol::widget::CheckBox::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::widget::Container2::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_shaper) { + if (_paramPointer == propertyShape) { + m_shaper.setSource(propertyShape.get()); markToRedraw(); - } else if (_paramPointer == m_value) { - if (m_value.get() == false) { + } else if (_paramPointer == propertyValue) { + if (propertyValue.get() == false) { m_idWidgetDisplayed = convertId(0); } else { m_idWidgetDisplayed = convertId(1); } CheckStatus(); markToRedraw(); - m_shaper->setActivateState(m_value==true?1:0); + m_shaper.setActivateState(propertyValue==true?1:0); } } diff --git a/ewol/widget/CheckBox.h b/ewol/widget/CheckBox.h index 15371039..e0de93d6 100644 --- a/ewol/widget/CheckBox.h +++ b/ewol/widget/CheckBox.h @@ -25,8 +25,8 @@ namespace ewol { esignal::Signal signalEnter; esignal::Signal signalValue; public: // propertie list - eproperty::Value propertyShaper; eproperty::Value propertyValue; //!< Current state of the checkbox. + eproperty::Value propertyShape; //!< shape of the widget private: ewol::compositing::Shaper m_shaper; //!< Compositing theme. bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). diff --git a/ewol/widget/ColorBar.cpp b/ewol/widget/ColorBar.cpp index 69fe3989..653543ae 100644 --- a/ewol/widget/ColorBar.cpp +++ b/ewol/widget/ColorBar.cpp @@ -17,16 +17,16 @@ #define __class__ "ColorBar" ewol::widget::ColorBar::ColorBar() : - signalChange(*this, "change", "Color value change") { + signalChange(*this, "change", "Color value change"), + propertyValue(*this, "color", etk::color::black, "Current color") { addObjectType("ewol::widget::ColorBar"); m_currentUserPos.setValue(0,0); - m_currentColor = etk::color::black; - setCanHaveFocus(true); setMouseLimit(1); } void ewol::widget::ColorBar::init() { ewol::Widget::init(); + propertyCanFocus.set(true); } ewol::widget::ColorBar::~ColorBar() { @@ -51,14 +51,14 @@ static etk::Color<> s_listColor[NB_BAND_COLOR+1] = { etk::Color<>(0xFF, 0x00, 0xFF, 0xFF), etk::Color<>(0xFF, 0x00, 0x00, 0xFF)}; -etk::Color<> ewol::widget::ColorBar::getCurrentColor() { - return m_currentColor; -} -void ewol::widget::ColorBar::setCurrentColor(etk::Color<> newOne) { - m_currentColor = newOne; - m_currentColor.setA(0xFF); - // estimate the cursor position : - // TODO : Later when really needed ... + +void ewol::widget::ColorBar::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { + ewol::Widget::onPropertyChangeValue(_paramPointer); + if (_paramPointer == propertyValue) { + propertyValue.get().setA(0xFF); + // estimate the cursor position: + EWOL_TODO("Later when really needed ..."); + } } void ewol::widget::ColorBar::onDraw() { @@ -67,100 +67,100 @@ void ewol::widget::ColorBar::onDraw() { void ewol::widget::ColorBar::onRegenerateDisplay() { - if (true == needRedraw()) { - // clean the object list ... - m_draw.clear(); - - int32_t tmpSizeX = m_minSize.x(); - int32_t tmpSizeY = m_minSize.y(); - int32_t tmpOriginX = (m_size.x() - m_minSize.x()) / 2; - int32_t tmpOriginY = (m_size.y() - m_minSize.y()) / 2; - - if (true == m_userFill->x()) { - tmpSizeX = m_size.x(); - tmpOriginX = 0; - } - if (true == m_userFill->y()) { - tmpSizeY = m_size.y(); - tmpOriginY = 0; - } - - for(int32_t iii=0; iii 0.5) { - m_draw.setColor(etk::color::white); - } else { - m_draw.setColor(etk::color::black); - } - m_draw.setPos(vec3(m_currentUserPos.x()*m_size.x(), m_currentUserPos.y()*m_size.y(), 0) ); - m_draw.setThickness(1); - m_draw.circle(3.0); - + if (needRedraw() == true) { + return; } + // clean the object list ... + m_draw.clear(); + + int32_t tmpSizeX = m_minSize.x(); + int32_t tmpSizeY = m_minSize.y(); + int32_t tmpOriginX = (m_size.x() - m_minSize.x()) / 2; + int32_t tmpOriginY = (m_size.y() - m_minSize.y()) / 2; + + if (propertyFill->x() == true) { + tmpSizeX = m_size.x(); + tmpOriginX = 0; + } + if (propertyFill->y() == true) { + tmpSizeY = m_size.y(); + tmpOriginY = 0; + } + + for(int32_t iii=0; iii 0.5) { + m_draw.setColor(etk::color::white); + } else { + m_draw.setColor(etk::color::black); + } + m_draw.setPos(vec3(m_currentUserPos.x()*m_size.x(), m_currentUserPos.y()*m_size.y(), 0) ); + m_draw.setThickness(1); + m_draw.circle(3.0); } @@ -218,9 +218,9 @@ bool ewol::widget::ColorBar::onEventInput(const ewol::event::Input& _event) { estimateColor.setG(estimateColor.g() - estimateColor.g()*poroportionnalBlack); estimateColor.setB(estimateColor.b() - estimateColor.b()*poroportionnalBlack); } - if(m_currentColor != estimateColor) { - m_currentColor = estimateColor; - signalChange.emit(m_currentColor); + if(propertyValue.get() != estimateColor) { + propertyValue.set(estimateColor); + signalChange.emit(propertyValue.get()); } return true; } diff --git a/ewol/widget/ColorBar.h b/ewol/widget/ColorBar.h index 182d2b54..d2de74d5 100644 --- a/ewol/widget/ColorBar.h +++ b/ewol/widget/ColorBar.h @@ -20,17 +20,16 @@ namespace ewol { class ColorBar : public ewol::Widget { public: // signals esignal::Signal> signalChange; + public: + eproperty::Value> propertyValue; protected: ColorBar(); void init(); public: DECLARE_WIDGET_FACTORY(ColorBar, "ColorBar"); virtual ~ColorBar(); - etk::Color<> getCurrentColor(); - void setCurrentColor(etk::Color<> _newOne); private: ewol::compositing::Drawing m_draw; //!< Compositing drawing element - etk::Color<> m_currentColor; vec2 m_currentUserPos; protected: // Derived function virtual void onDraw(); @@ -38,6 +37,7 @@ namespace ewol { virtual void calculateMinMaxSize(); virtual void onRegenerateDisplay(); virtual bool onEventInput(const ewol::event::Input& _event); + virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); }; }; }; diff --git a/ewol/widget/Container.cpp b/ewol/widget/Container.cpp index 179b90ba..1b344ae0 100644 --- a/ewol/widget/Container.cpp +++ b/ewol/widget/Container.cpp @@ -92,12 +92,12 @@ std::shared_ptr ewol::widget::Container::getSubObjectNamed(const s } void ewol::widget::Container::systemDraw(const ewol::DrawProperty& _displayProp) { - if (true == m_hide){ + if (propertyHide.get() == true){ // widget is hidden ... return; } ewol::Widget::systemDraw(_displayProp); - if (nullptr!=m_subWidget) { + if (m_subWidget != nullptr) { ewol::DrawProperty prop = _displayProp; prop.limit(m_origin, m_size); m_subWidget->systemDraw(prop); @@ -111,8 +111,8 @@ void ewol::widget::Container::onChangeSize() { } vec2 origin = m_origin+m_offset; vec2 minSize = m_subWidget->getCalculateMinSize(); - bvec2 expand = m_subWidget->getExpand(); - origin += ewol::gravityGenerateDelta(m_gravity, minSize - m_size); + bvec2 expand = m_subWidget->propertyExpand.get(); + origin += ewol::gravityGenerateDelta(propertyGravity.get(), minSize - m_size); m_subWidget->setOrigin(origin); m_subWidget->setSize(m_size); m_subWidget->onChangeSize(); @@ -122,7 +122,7 @@ void ewol::widget::Container::calculateMinMaxSize() { // call main class ewol::Widget::calculateMinMaxSize(); // call sub classes - if (nullptr!=m_subWidget) { + if (m_subWidget != nullptr) { m_subWidget->calculateMinMaxSize(); vec2 min = m_subWidget->getCalculateMinSize(); m_minSize.setMax(min); @@ -131,14 +131,14 @@ void ewol::widget::Container::calculateMinMaxSize() { } void ewol::widget::Container::onRegenerateDisplay() { - if (nullptr!=m_subWidget) { + if (m_subWidget != nullptr) { m_subWidget->onRegenerateDisplay(); } } std::shared_ptr ewol::widget::Container::getWidgetAtPos(const vec2& _pos) { - if (false == isHide()) { - if (nullptr!=m_subWidget) { + if (propertyHide.get() == false) { + if (m_subWidget != nullptr) { return m_subWidget->getWidgetAtPos(_pos); } } diff --git a/ewol/widget/Container2.cpp b/ewol/widget/Container2.cpp index 82241eb1..cfb169ad 100644 --- a/ewol/widget/Container2.cpp +++ b/ewol/widget/Container2.cpp @@ -104,7 +104,7 @@ std::shared_ptr ewol::widget::Container2::getSubObjectNamed(const } void ewol::widget::Container2::systemDraw(const ewol::DrawProperty& _displayProp) { - if (true == m_hide){ + if (propertyHide.get() == true){ // widget is hidden ... return; } @@ -119,21 +119,21 @@ ewol::Padding ewol::widget::Container2::onChangeSizePadded(const ewol::Padding& vec2 localAvaillable = m_size - vec2(_padding.x(), _padding.y()); // Checkin the filling properties == > for the subElements: vec2 subElementSize = m_minSize; - if (m_userFill->x() == true) { + if (propertyFill->x() == true) { subElementSize.setX(m_size.x()); } - if (m_userFill->y() == true) { + if (propertyFill->y() == true) { subElementSize.setY(m_size.y()); } - vec2 delta = ewol::gravityGenerateDelta(m_gravity, m_size - subElementSize); + vec2 delta = ewol::gravityGenerateDelta(propertyGravity, m_size - subElementSize); vec2 origin = delta + vec2(_padding.xLeft(), _padding.yButtom()); subElementSize -= vec2(_padding.x(), _padding.y()); for (size_t iii = 0; iii < 2; ++iii) { if (m_subWidget[iii] != nullptr) { vec2 origin2 = origin+m_offset; vec2 minSize = m_subWidget[iii]->getCalculateMinSize(); - bvec2 expand = m_subWidget[iii]->getExpand(); - origin2 += ewol::gravityGenerateDelta(m_gravity, minSize - localAvaillable); + bvec2 expand = m_subWidget[iii]->propertyExpand.get(); + origin2 += ewol::gravityGenerateDelta(propertyGravity, minSize - localAvaillable); m_subWidget[iii]->setOrigin(m_origin + origin); m_subWidget[iii]->setSize(subElementSize); m_subWidget[iii]->onChangeSize(); diff --git a/ewol/widget/ContainerN.cpp b/ewol/widget/ContainerN.cpp index bfe58a9d..0174f5a8 100644 --- a/ewol/widget/ContainerN.cpp +++ b/ewol/widget/ContainerN.cpp @@ -16,7 +16,7 @@ ewol::widget::ContainerN::ContainerN() : - m_lockExpand(false,false), + propertyLockExpand(*this, "lock", vec2(false,false), "Lock the subwidget expand"), m_subExpend(false,false) { addObjectType("ewol::widget::ContainerN"); // nothing to do ... @@ -32,30 +32,29 @@ ewol::widget::ContainerN::~ContainerN() { bvec2 ewol::widget::ContainerN::canExpand() { - bvec2 res = m_userExpand; - if (false == m_lockExpand.x()) { - if (true == m_subExpend.x()) { + bvec2 res = propertyExpand.get(); + if (propertyLockExpand->x() == false) { + if (m_subExpend.x() == true) { res.setX(true); } } - if (false == m_lockExpand.y()) { - if (true == m_subExpend.y()) { + if (propertyLockExpand->y() == false) { + if (m_subExpend.y() == true) { res.setY(true); } } - //EWOL_DEBUG("Expend check : user=" << m_userExpand << " lock=" << m_lockExpand << " sub=" << m_subExpend << " res=" << res); + //EWOL_DEBUG("Expend check : user=" << m_userExpand << " lock=" << propertyLockExpand << " sub=" << m_subExpend << " res=" << res); return res; } -void ewol::widget::ContainerN::lockExpand(const bvec2& _lockExpand) { - if (_lockExpand != m_lockExpand) { - m_lockExpand = _lockExpand; +void ewol::widget::ContainerN::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { + ewol::Widget::onPropertyChangeValue(_paramPointer); + if (_paramPointer == propertyLockExpand) { markToRedraw(); requestUpdateSize(); } } - void ewol::widget::ContainerN::subWidgetReplace(const std::shared_ptr& _oldWidget, const std::shared_ptr& _newWidget) { bool haveChange = false; @@ -179,7 +178,7 @@ std::shared_ptr ewol::widget::ContainerN::getSubObjectNamed(const } void ewol::widget::ContainerN::systemDraw(const ewol::DrawProperty& _displayProp) { - if (true == m_hide){ + if (propertyHide.get() == true){ // widget is hidden ... return; } @@ -238,7 +237,7 @@ void ewol::widget::ContainerN::onRegenerateDisplay() { } std::shared_ptr ewol::widget::ContainerN::getWidgetAtPos(const vec2& _pos) { - if (true == isHide()) { + if (propertyHide.get() == true) { return nullptr; } // for all element in the sizer ... @@ -250,7 +249,7 @@ std::shared_ptr ewol::widget::ContainerN::getWidgetAtPos(const vec && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { std::shared_ptr tmpWidget = it->getWidgetAtPos(_pos); - if (nullptr != tmpWidget) { + if (tmpWidget != nullptr) { return tmpWidget; } // stop searching @@ -273,7 +272,7 @@ bool ewol::widget::ContainerN::loadXML(const std::shared_ptrgetAttribute("lock"); if (tmpAttributeValue.size()!=0) { - m_lockExpand = tmpAttributeValue; + propertyLockExpand = tmpAttributeValue; } bool invertAdding=false; tmpAttributeValue = _node->getAttribute("addmode"); diff --git a/ewol/widget/ContainerN.h b/ewol/widget/ContainerN.h index 832de4bf..e650d12e 100644 --- a/ewol/widget/ContainerN.h +++ b/ewol/widget/ContainerN.h @@ -19,6 +19,8 @@ namespace ewol { * @brief the Cotainer widget is a widget that have an only one subWidget */ class ContainerN : public ewol::Widget { + public: // properties: + eproperty::Value propertyLockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget protected: std::list> m_subWidget; protected: @@ -33,14 +35,7 @@ namespace ewol { */ virtual ~ContainerN(); protected: - bvec2 m_lockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget bvec2 m_subExpend; //!< reference of the sub element expention requested. - public: - /** - * @brief Limit the expend properties to the current widget (no contamination) - * @param[in] _lockExpend Lock mode of the expend properties - */ - void lockExpand(const bvec2& _lockExpand); // herited function virtual bvec2 canExpand(); public: @@ -103,6 +98,7 @@ namespace ewol { virtual bool loadXML(const std::shared_ptr& _node); virtual void setOffset(const vec2& _newVal); virtual void requestDestroyFromChild(const std::shared_ptr& _child); + void onPropertyChangeValue(const eproperty::Ref& _paramPointer); }; }; }; diff --git a/ewol/widget/ContextMenu.cpp b/ewol/widget/ContextMenu.cpp index 0d1f0b7a..86bca60d 100644 --- a/ewol/widget/ContextMenu.cpp +++ b/ewol/widget/ContextMenu.cpp @@ -19,21 +19,19 @@ ewol::widget::ContextMenu::ContextMenu(): - m_shaper(*this, "shaper", "the display name for config file"), - m_arrowPos(*this, "arrow-position", vec2(0,0), "Position of the arrow in the pop-up"), - m_arrawBorder(*this, "arrow-mode", markTop, "position of the arrow") { + propertyShape(*this, "shape", "", "the display name for config file"), + propertyArrowPos(*this, "arrow-position", vec2(0,0), "Position of the arrow in the pop-up"), + propertyArrawBorder(*this, "arrow-mode", markTop, "position of the arrow") { addObjectType("ewol::widget::ContextMenu"); - m_arrawBorder.add(markTop, "top"); - m_arrawBorder.add(markRight, "right"); - m_arrawBorder.add(markButtom, "buttom"); - m_arrawBorder.add(markLeft, "left"); - m_arrawBorder.add(markNone, "none"); + propertyArrawBorder.add(markTop, "top"); + propertyArrawBorder.add(markRight, "right"); + propertyArrawBorder.add(markButtom, "buttom"); + propertyArrawBorder.add(markLeft, "left"); + propertyArrawBorder.add(markNone, "none"); - m_userExpand.set(bvec2(false,false)); m_offset = 20; - m_colorBackGroung = etk::color::white; m_colorBorder = etk::color::black; m_colorBorder.setA(0x7F); @@ -43,7 +41,8 @@ ewol::widget::ContextMenu::ContextMenu(): void ewol::widget::ContextMenu::init(const std::string& _shaperName) { ewol::widget::Container::init(); - m_shaper.set(_shaperName); + propertyShape.set(_shaperName); + propertyExpand.set(bvec2(false,false)); } ewol::widget::ContextMenu::~ContextMenu() { @@ -53,7 +52,7 @@ ewol::widget::ContextMenu::~ContextMenu() { void ewol::widget::ContextMenu::onChangeSize() { markToRedraw(); // pop-up fill all the display : - ewol::Padding padding = m_shaper->getPadding(); + ewol::Padding padding = m_shaper.getPadding(); EWOL_VERBOSE("our origin=" << m_origin << " size=" << m_size); if (m_subWidget == nullptr) { return; @@ -74,14 +73,14 @@ void ewol::widget::ContextMenu::onChangeSize() { subWidgetSize.setY((int32_t)subWidgetSize.y()); // set config to the Sub-widget - switch (m_arrawBorder) { + switch (propertyArrawBorder.get()) { case markTop: - subWidgetOrigin.setX((int32_t)(m_arrowPos->x() - subWidgetSize.x()/2)); - subWidgetOrigin.setY((int32_t)(m_arrowPos->y() - m_offset - subWidgetSize.y())); + subWidgetOrigin.setX((int32_t)(propertyArrowPos->x() - subWidgetSize.x()/2)); + subWidgetOrigin.setY((int32_t)(propertyArrowPos->y() - m_offset - subWidgetSize.y())); break; case markButtom: - subWidgetOrigin.setX((int32_t)(m_arrowPos->x() - subWidgetSize.x()/2)); - subWidgetOrigin.setY((int32_t)(m_arrowPos->y() + m_offset)); + subWidgetOrigin.setX((int32_t)(propertyArrowPos->x() - subWidgetSize.x()/2)); + subWidgetOrigin.setY((int32_t)(propertyArrowPos->y() + m_offset)); break; case markRight: case markLeft: @@ -95,18 +94,18 @@ void ewol::widget::ContextMenu::onChangeSize() { + padding.x()) ); subWidgetOrigin.setY( (int32_t)( std::max(0, (int32_t)(subWidgetOrigin.y()-padding.y())) + padding.y()) ); - switch (m_arrawBorder) { + switch (propertyArrawBorder.get()) { default: case markTop: case markButtom: - if (m_arrowPos->x() <= m_offset ) { - subWidgetOrigin.setX(m_arrowPos->x()+padding.xLeft()); + if (propertyArrowPos->x() <= m_offset ) { + subWidgetOrigin.setX(propertyArrowPos->x()+padding.xLeft()); } break; case markRight: case markLeft: - if (m_arrowPos->y() <= m_offset ) { - subWidgetOrigin.setY(m_arrowPos->y()+padding.yButtom()); + if (propertyArrowPos->y() <= m_offset ) { + subWidgetOrigin.setY(propertyArrowPos->y()+padding.yButtom()); } break; } @@ -121,7 +120,7 @@ void ewol::widget::ContextMenu::calculateMinMaxSize() { // call main class to calculate the min size... ewol::widget::Container::calculateMinMaxSize(); // add padding of the display - ewol::Padding padding = m_shaper->getPadding(); + ewol::Padding padding = m_shaper.getPadding(); m_minSize += vec2(padding.x(), padding.y()); //EWOL_DEBUG("CalculateMinSize=>>" << m_minSize); markToRedraw(); @@ -130,7 +129,7 @@ void ewol::widget::ContextMenu::calculateMinMaxSize() { void ewol::widget::ContextMenu::onDraw() { m_compositing.draw(); - m_shaper->draw(); + m_shaper.draw(); } @@ -141,8 +140,8 @@ void ewol::widget::ContextMenu::onRegenerateDisplay() { return; } m_compositing.clear(); - m_shaper->clear(); - ewol::Padding padding = m_shaper->getPadding(); + m_shaper.clear(); + ewol::Padding padding = m_shaper.getPadding(); if (m_subWidget == nullptr) { return; @@ -152,38 +151,38 @@ void ewol::widget::ContextMenu::onRegenerateDisplay() { // display border ... m_compositing.setColor(m_colorBorder); - switch (m_arrawBorder) { + switch (propertyArrawBorder) { case markTop: - m_compositing.setPos(vec3(m_arrowPos->x(), m_arrowPos->y(), 0.0f) ); + m_compositing.setPos(vec3(propertyArrowPos->x(), propertyArrowPos->y(), 0.0f) ); m_compositing.addVertex(); - if (m_arrowPos->x() <= tmpOrigin.x() ) { + if (propertyArrowPos->x() <= tmpOrigin.x() ) { float laking = m_offset - padding.yTop(); - m_compositing.setPos(vec3(m_arrowPos->x()+laking, m_arrowPos->y()-laking, 0.0f) ); + m_compositing.setPos(vec3(propertyArrowPos->x()+laking, propertyArrowPos->y()-laking, 0.0f) ); m_compositing.addVertex(); - m_compositing.setPos(vec3(m_arrowPos->x(), m_arrowPos->y()-laking, 0.0f) ); + m_compositing.setPos(vec3(propertyArrowPos->x(), propertyArrowPos->y()-laking, 0.0f) ); m_compositing.addVertex(); } else { float laking = m_offset - padding.yTop(); - m_compositing.setPos(vec3(m_arrowPos->x()+laking, m_arrowPos->y()-laking, 0.0f) ); + m_compositing.setPos(vec3(propertyArrowPos->x()+laking, propertyArrowPos->y()-laking, 0.0f) ); m_compositing.addVertex(); - m_compositing.setPos(vec3(m_arrowPos->x()-laking, m_arrowPos->y()-laking, 0.0f) ); + m_compositing.setPos(vec3(propertyArrowPos->x()-laking, propertyArrowPos->y()-laking, 0.0f) ); m_compositing.addVertex(); } break; case markButtom: - m_compositing.setPos(vec3(m_arrowPos->x(), m_arrowPos->y(), 0) ); + m_compositing.setPos(vec3(propertyArrowPos->x(), propertyArrowPos->y(), 0) ); m_compositing.addVertex(); - if (m_arrowPos->x() <= tmpOrigin.x() ) { + if (propertyArrowPos->x() <= tmpOrigin.x() ) { int32_t laking = m_offset - padding.yTop(); - m_compositing.setPos(vec3(m_arrowPos->x()+laking, m_arrowPos->y()+laking, 0.0f) ); + m_compositing.setPos(vec3(propertyArrowPos->x()+laking, propertyArrowPos->y()+laking, 0.0f) ); m_compositing.addVertex(); - m_compositing.setPos(vec3(m_arrowPos->x(), m_arrowPos->y()+laking, 0.0f) ); + m_compositing.setPos(vec3(propertyArrowPos->x(), propertyArrowPos->y()+laking, 0.0f) ); m_compositing.addVertex(); } else { int32_t laking = m_offset - padding.yTop(); - m_compositing.setPos(vec3(m_arrowPos->x()+laking, m_arrowPos->y()+laking, 0.0f) ); + m_compositing.setPos(vec3(propertyArrowPos->x()+laking, propertyArrowPos->y()+laking, 0.0f) ); m_compositing.addVertex(); - m_compositing.setPos(vec3(m_arrowPos->x()-laking, m_arrowPos->y()+laking, 0.0f) ); + m_compositing.setPos(vec3(propertyArrowPos->x()-laking, propertyArrowPos->y()+laking, 0.0f) ); m_compositing.addVertex(); } break; @@ -196,13 +195,13 @@ void ewol::widget::ContextMenu::onRegenerateDisplay() { vec2 shaperOrigin = tmpOrigin-vec2(padding.xLeft(), padding.yButtom()); vec2 shaperSize = tmpSize+vec2(padding.x(), padding.y()); - m_shaper->setShape(vec2ClipInt32(shaperOrigin), - vec2ClipInt32(shaperSize)); + m_shaper.setShape(vec2ClipInt32(shaperOrigin), + vec2ClipInt32(shaperSize)); } bool ewol::widget::ContextMenu::onEventInput(const ewol::event::Input& _event) { if (_event.getId() > 0) { - if (nullptr != ewol::widget::Container::getWidgetAtPos(_event.getPos())) { + if (ewol::widget::Container::getWidgetAtPos(_event.getPos()) != nullptr) { return false; } if( _event.getStatus() == gale::key::status_down @@ -221,23 +220,21 @@ bool ewol::widget::ContextMenu::onEventInput(const ewol::event::Input& _event) { std::shared_ptr ewol::widget::ContextMenu::getWidgetAtPos(const vec2& _pos) { std::shared_ptr val = ewol::widget::Container::getWidgetAtPos(_pos); - if (nullptr != val) { + if (val != nullptr) { return val; } return std::dynamic_pointer_cast(shared_from_this()); } -void ewol::widget::ContextMenu::setShaperName(const std::string& _shaperName) { - m_shaper.set(_shaperName); -} void ewol::widget::ContextMenu::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::widget::Container::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_shaper) { + if (_paramPointer == propertyArrowPos) { markToRedraw(); - } else if (_paramPointer == m_arrowPos) { + } else if (_paramPointer == propertyArrawBorder) { markToRedraw(); - } else if (_paramPointer == m_arrawBorder) { + } else if (_paramPointer == propertyShape) { + m_shaper.setSource(propertyShape.get()); markToRedraw(); } } @@ -258,7 +255,7 @@ void ewol::widget::ContextMenu::setPositionMarkAuto(const vec2& _origin, const v } } void ewol::widget::ContextMenu::setPositionMark(enum markPosition _position, const vec2& _arrowPos) { - m_arrawBorder.set(_position); - m_arrowPos.set(_arrowPos); + propertyArrawBorder.set(_position); + propertyArrowPos.set(_arrowPos); } diff --git a/ewol/widget/ContextMenu.h b/ewol/widget/ContextMenu.h index 3c031069..1d35f0ec 100644 --- a/ewol/widget/ContextMenu.h +++ b/ewol/widget/ContextMenu.h @@ -30,9 +30,9 @@ namespace ewol { markNone }; public: // properties + eproperty::Value propertyShape; //!< shape of the widget. eproperty::Value propertyArrowPos; eproperty::List propertyArrawBorder; - eproperty::Value propertyShaper; //!< Compositing theme. protected: ContextMenu(); void init(const std::string& _shaperName="{ewol}THEME:GUI:ContextMenu.json"); @@ -41,9 +41,12 @@ namespace ewol { virtual ~ContextMenu(); private: ewol::compositing::Shaper m_shaper; //!< Compositing theme. + + // TODO : Use shaper for the arraw ... ewol::compositing::Drawing m_compositing; - etk::Color<> m_colorBackGroung; - etk::Color<> m_colorBorder; + etk::Color<> m_colorBorder; // use shaper ID + + float m_offset; public: void setPositionMarkAuto(const vec2& _origin, const vec2& _size); diff --git a/ewol/widget/Entry.cpp b/ewol/widget/Entry.cpp index 26be8344..78ee6ff6 100644 --- a/ewol/widget/Entry.cpp +++ b/ewol/widget/Entry.cpp @@ -25,29 +25,29 @@ ewol::widget::Entry::Entry() : signalClick(*this, "click", "the user Click on the Entry box"), signalEnter(*this, "enter", "The cursor enter inside the button"), signalModify(*this, "modify", "Entry box value change"), - m_shaper(*this, "shaper", "Shaper to display the background"), - m_data(*this, "value", "", "Value display in the entry (decorated text)"), - m_maxCharacter(*this, "max", 0x7FFFFFFF, 0, 0x7FFFFFFF, "Maximum cgar that can be set on the Entry"), - m_regexValue(*this, "regex", ".*", "Control what it is write with a regular expression"), + propertyShaper(*this, "shaper", "", "Shaper to display the background"), + propertyValue(*this, "value", "", "Value display in the entry (decorated text)"), + propertyMaxCharacter(*this, "max", 0x7FFFFFFF, 0, 0x7FFFFFFF, "Maximum cgar that can be set on the Entry"), + propertyRegex(*this, "regex", ".*", "Control what it is write with a regular expression"), + propertyTextWhenNothing(*this, "empty-text", "", "Text when nothing is written"), m_needUpdateTextPos(true), m_displayStartPosition(0), m_displayCursor(false), m_displayCursorPos(0), - m_displayCursorPosSelection(0), - m_textWhenNothing(*this, "emptytext", "", "Text that is displayed when the Entry is empty (decorated text)") { + m_displayCursorPosSelection(0) { addObjectType("ewol::widget::Entry"); } void ewol::widget::Entry::init(const std::string& _newData, const std::string& _shaperName) { ewol::Widget::init(); - m_data.set(_newData); - m_shaper.setString(_shaperName); - setCanHaveFocus(true); + propertyValue.set(_newData); + propertyShaper.set(_shaperName); + propertyCanFocus.set(true); try { m_regex.assign(".*", std::regex_constants::optimize | std::regex_constants::ECMAScript); } catch (std::regex_error e) { - EWOL_ERROR("can not parse regex : '" << e.what() << "' for : " << m_regexValue); + EWOL_ERROR("can not parse regex : '" << e.what() << "' for : " << propertyRegex); } markToRedraw(); @@ -87,7 +87,7 @@ void ewol::widget::Entry::calculateMinMaxSize() { // call main class ewol::Widget::calculateMinMaxSize(); // get generic padding - ewol::Padding padding = m_shaper->getPadding(); + ewol::Padding padding = m_shaper.getPadding(); int32_t minHeight = m_text.calculateSize(char32_t('A')).y(); vec2 minimumSizeBase(20, minHeight); // add padding : @@ -97,48 +97,31 @@ void ewol::widget::Entry::calculateMinMaxSize() { checkMinSize(); } -// TODO : ... Set it a a generic parameter... -void ewol::widget::Entry::setValue(const std::string& _newData) { - std::string newData = _newData; - if ((int64_t)newData.size() > m_maxCharacter) { - newData = std::string(_newData, 0, m_maxCharacter); - EWOL_DEBUG("Limit entry set of data... " << std::string(_newData, m_maxCharacter)); - } - // set the value with the check of the RegExp ... - setInternalValue(newData); - if (newData == m_data.get()) { - m_displayCursorPos = m_data->size(); - m_displayCursorPosSelection = m_displayCursorPos; - EWOL_VERBOSE("Set : '" << newData << "'"); - } - markToRedraw(); -} - void ewol::widget::Entry::onDraw() { - m_shaper->draw(); + m_shaper.draw(); m_text.draw(); } void ewol::widget::Entry::onRegenerateDisplay() { - if (true == needRedraw()) { - m_shaper->clear(); + if (needRedraw() == true) { + m_shaper.clear(); m_text.clear(); if (m_colorIdTextFg >= 0) { - m_text.setDefaultColorFg(m_shaper->getColor(m_colorIdTextFg)); - m_text.setDefaultColorBg(m_shaper->getColor(m_colorIdTextBg)); - m_text.setCursorColor(m_shaper->getColor(m_colorIdCursor)); - m_text.setSelectionColor(m_shaper->getColor(m_colorIdSelection)); + m_text.setDefaultColorFg(m_shaper.getColor(m_colorIdTextFg)); + m_text.setDefaultColorBg(m_shaper.getColor(m_colorIdTextBg)); + m_text.setCursorColor(m_shaper.getColor(m_colorIdCursor)); + m_text.setSelectionColor(m_shaper.getColor(m_colorIdSelection)); } updateTextPosition(); - ewol::Padding padding = m_shaper->getPadding(); + ewol::Padding padding = m_shaper.getPadding(); vec2 tmpSizeShaper = m_minSize; - if (true == m_userFill->x()) { + if (propertyFill->x() == true) { tmpSizeShaper.setX(m_size.x()); } - if (true == m_userFill->y()) { + if (propertyFill->y() == true) { tmpSizeShaper.setY(m_size.y()); } @@ -147,7 +130,7 @@ void ewol::widget::Entry::onRegenerateDisplay() { vec2 tmpOriginText = (m_size - tmpSizeText) / 2.0f; // sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ... int32_t minHeight = m_text.calculateSize(char32_t('A')).y(); - if (tmpSizeText.y()>minHeight) { + if (tmpSizeText.y() > minHeight) { tmpOriginText += vec2(0,(tmpSizeText.y()-minHeight)/2.0f); } // fix all the position in the int32_t class: @@ -164,33 +147,33 @@ void ewol::widget::Entry::onRegenerateDisplay() { } else { m_text.setCursorPos(m_displayCursorPos); } - if (0!=m_data->size()) { - m_text.print(m_data); + if (propertyValue->size() != 0) { + m_text.print(propertyValue); } else { - if (0!=m_textWhenNothing->size()) { - m_text.printDecorated(m_textWhenNothing); + if (propertyTextWhenNothing->size() != 0) { + m_text.printDecorated(propertyTextWhenNothing); } } m_text.setClippingMode(false); - m_shaper->setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText); + m_shaper.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText); } } void ewol::widget::Entry::updateCursorPosition(const vec2& _pos, bool _selection) { - ewol::Padding padding = m_shaper->getPadding(); + ewol::Padding padding = m_shaper.getPadding(); vec2 relPos = relativePosition(_pos); relPos.setX(relPos.x()-m_displayStartPosition - padding.xLeft()); // try to find the new cursor position : - std::string tmpDisplay = std::string(m_data, 0, m_displayStartPosition); + std::string tmpDisplay = std::string(propertyValue, 0, m_displayStartPosition); int32_t displayHidenSize = m_text.calculateSize(tmpDisplay).x(); //EWOL_DEBUG("hidenSize : " << displayHidenSize); int32_t newCursorPosition = -1; int32_t tmpTextOriginX = padding.xLeft(); - for (size_t iii=0; iiisize(); iii++) { - tmpDisplay = std::string(m_data, 0, iii); + for (size_t iii=0; iiisize(); iii++) { + tmpDisplay = std::string(propertyValue, 0, iii); int32_t tmpWidth = m_text.calculateSize(tmpDisplay).x() - displayHidenSize; if (tmpWidth >= relPos.x()-tmpTextOriginX) { newCursorPosition = iii; @@ -198,9 +181,9 @@ void ewol::widget::Entry::updateCursorPosition(const vec2& _pos, bool _selection } } if (newCursorPosition == -1) { - newCursorPosition = m_data->size(); + newCursorPosition = propertyValue->size(); } - if (false == _selection) { + if (_selection == false) { m_displayCursorPos = newCursorPosition; m_displayCursorPosSelection = m_displayCursorPos; markToRedraw(); @@ -229,7 +212,7 @@ void ewol::widget::Entry::removeSelected() { // remove data ... m_displayCursorPos = pos1; m_displayCursorPosSelection = pos1; - m_data->erase(pos1, pos2-pos1); + propertyValue->erase(pos1, pos2-pos1); markToRedraw(); } @@ -246,14 +229,14 @@ void ewol::widget::Entry::copySelectionToClipBoard(enum gale::context::clipBoard pos1 = m_displayCursorPos; } // Copy - std::string tmpData = std::string(m_data, pos1, pos2); + std::string tmpData = std::string(propertyValue, pos1, pos2); gale::context::clipBoard::set(_clipboardID, tmpData); } bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { //EWOL_DEBUG("Event on Entry ... type=" << (int32_t)type << " id=" << IdInput); - if (1 == _event.getId()) { + if (_event.getId() == 1) { if (gale::key::status_single == _event.getStatus()) { keepFocus(); signalClick.emit(); @@ -264,19 +247,19 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { // select word m_displayCursorPosSelection = m_displayCursorPos-1; // search forward - for (size_t iii=m_displayCursorPos; iii <= m_data->size(); iii++) { - if(iii == m_data->size()) { + for (size_t iii=m_displayCursorPos; iii <= propertyValue->size(); iii++) { + if(iii == propertyValue->size()) { m_displayCursorPos = iii; break; } - if(!( ( m_data.get()[iii] >= 'a' - && m_data.get()[iii] <= 'z') - || ( m_data.get()[iii] >= 'A' - && m_data.get()[iii] <= 'Z') - || ( m_data.get()[iii] >= '0' - && m_data.get()[iii] <= '9') - || m_data.get()[iii] == '_' - || m_data.get()[iii] == '-' + if(!( ( propertyValue.get()[iii] >= 'a' + && propertyValue.get()[iii] <= 'z') + || ( propertyValue.get()[iii] >= 'A' + && propertyValue.get()[iii] <= 'Z') + || ( propertyValue.get()[iii] >= '0' + && propertyValue.get()[iii] <= '9') + || propertyValue.get()[iii] == '_' + || propertyValue.get()[iii] == '-' ) ) { m_displayCursorPos = iii; break; @@ -288,14 +271,14 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { m_displayCursorPosSelection = 0; break; } - if(!( ( m_data.get()[iii] >= 'a' - && m_data.get()[iii] <= 'z') - || ( m_data.get()[iii] >= 'A' - && m_data.get()[iii] <= 'Z') - || ( m_data.get()[iii] >= '0' - && m_data.get()[iii] <= '9') - || m_data.get()[iii] == '_' - || m_data.get()[iii] == '-' + if(!( ( propertyValue.get()[iii] >= 'a' + && propertyValue.get()[iii] <= 'z') + || ( propertyValue.get()[iii] >= 'A' + && propertyValue.get()[iii] <= 'Z') + || ( propertyValue.get()[iii] >= '0' + && propertyValue.get()[iii] <= '9') + || propertyValue.get()[iii] == '_' + || propertyValue.get()[iii] == '-' ) ) { m_displayCursorPosSelection = iii+1; break; @@ -307,7 +290,7 @@ bool ewol::widget::Entry::onEventInput(const ewol::event::Input& _event) { } else if (gale::key::status_triple == _event.getStatus()) { keepFocus(); m_displayCursorPosSelection = 0; - m_displayCursorPos = m_data->size(); + m_displayCursorPos = propertyValue->size(); } else if (gale::key::status_down == _event.getStatus()) { keepFocus(); updateCursorPosition(_event.getPos()); @@ -351,45 +334,44 @@ bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { removeSelected(); if( _event.getChar() == '\n' || _event.getChar() == '\r') { - signalEnter.emit(m_data); + signalEnter.emit(propertyValue); return true; } else if (_event.getChar() == 0x7F) { // SUPPR : - if (m_data->size() > 0 && m_displayCursorPos < (int64_t)m_data->size()) { - m_data->erase(m_displayCursorPos, 1); + if (propertyValue->size() > 0 && m_displayCursorPos < (int64_t)propertyValue->size()) { + propertyValue->erase(m_displayCursorPos, 1); m_displayCursorPos = std::max(m_displayCursorPos, 0); m_displayCursorPosSelection = m_displayCursorPos; } } else if (_event.getChar() == 0x08) { // DEL : - if (m_data->size() > 0 && m_displayCursorPos != 0) { - m_data->erase(m_displayCursorPos-1, 1); + if (propertyValue->size() > 0 && m_displayCursorPos != 0) { + propertyValue->erase(m_displayCursorPos-1, 1); m_displayCursorPos--; m_displayCursorPos = std::max(m_displayCursorPos, 0); m_displayCursorPosSelection = m_displayCursorPos; } } else if(_event.getChar() >= 20) { - if ((int64_t)m_data->size() > m_maxCharacter) { + if ((int64_t)propertyValue->size() > propertyMaxCharacter) { EWOL_INFO("Reject data for entry : '" << _event.getChar() << "'"); } else { - std::string newData = m_data; + std::string newData = propertyValue; newData.insert(newData.begin()+m_displayCursorPos, _event.getChar()); setInternalValue(newData); - if (m_data.get() == newData) { + if (propertyValue.get() == newData) { m_displayCursorPos++; m_displayCursorPosSelection = m_displayCursorPos; } } } - signalModify.emit(m_data); + signalModify.emit(propertyValue); markToRedraw(); return true; } return false; } else { if(_event.getStatus() == gale::key::status_down) { - switch (_event.getType()) - { + switch (_event.getType()) { case gale::key::keyboard_left: m_displayCursorPos--; break; @@ -400,12 +382,12 @@ bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { m_displayCursorPos = 0; break; case gale::key::keyboard_end: - m_displayCursorPos = m_data->size(); + m_displayCursorPos = propertyValue->size(); break; default: return false; } - m_displayCursorPos = std::avg(0, m_displayCursorPos, (int32_t)m_data->size()); + m_displayCursorPos = std::avg(0, m_displayCursorPos, (int32_t)propertyValue->size()); m_displayCursorPosSelection = m_displayCursorPos; markToRedraw(); return true; @@ -415,25 +397,25 @@ bool ewol::widget::Entry::onEventEntry(const ewol::event::Entry& _event) { } void ewol::widget::Entry::setInternalValue(const std::string& _newData) { - std::string previous = m_data; + std::string previous = propertyValue; // check the RegExp : if (_newData.size()>0) { std::smatch resultMatch; std::regex_search(_newData.begin(), _newData.end(), resultMatch, m_regex, std::regex_constants::match_continuous); if (resultMatch.size() <= 0) { - EWOL_INFO("The input data does not match with the regExp '" << _newData << "' Regex='" << m_regexValue << "'" ); + EWOL_INFO("The input data does not match with the regExp '" << _newData << "' Regex='" << propertyRegex << "'" ); return; } if (_newData.begin() != resultMatch[0].first) { - EWOL_INFO("The input data does not match with the regExp '" << _newData << "' Regex='" << m_regexValue << "' (start position error)" ); + EWOL_INFO("The input data does not match with the regExp '" << _newData << "' Regex='" << propertyRegex << "' (start position error)" ); return; } if (_newData.end() != resultMatch[0].second) { - EWOL_INFO("The input data does not match with the regExp '" << _newData << "' Regex='" << m_regexValue << "' (stop position error)" ); + EWOL_INFO("The input data does not match with the regExp '" << _newData << "' Regex='" << propertyRegex << "' (stop position error)" ); return; } } - m_data = _newData; + propertyValue.get() = _newData; markToRedraw(); } @@ -444,11 +426,11 @@ void ewol::widget::Entry::onEventClipboard(enum gale::context::clipBoard::clipbo std::string tmpData = get(_clipboardID); // add it on the current display : if (tmpData.size() != 0) { - std::string newData = m_data; + std::string newData = propertyValue; newData.insert(m_displayCursorPos, &tmpData[0]); setInternalValue(newData); - if (m_data.get() == newData) { - if (m_data->size() == tmpData.size()) { + if (propertyValue.get() == newData) { + if (propertyValue->size() == tmpData.size()) { m_displayCursorPos = tmpData.size(); } else { m_displayCursorPos += tmpData.size(); @@ -457,11 +439,11 @@ void ewol::widget::Entry::onEventClipboard(enum gale::context::clipBoard::clipbo markToRedraw(); } } - signalModify.emit(m_data); + signalModify.emit(propertyValue); } void ewol::widget::Entry::onCallbackEntryClean() { - m_data = ""; + propertyValue = ""; m_displayStartPosition = 0; m_displayCursorPos = 0; m_displayCursorPosSelection = m_displayCursorPos; @@ -471,7 +453,7 @@ void ewol::widget::Entry::onCallbackEntryClean() { void ewol::widget::Entry::onCallbackCut() { copySelectionToClipBoard(gale::context::clipBoard::clipboardStd); removeSelected(); - signalModify.emit(m_data); + signalModify.emit(propertyValue); } void ewol::widget::Entry::onCallbackCopy() { @@ -485,7 +467,7 @@ void ewol::widget::Entry::onCallbackPaste() { void ewol::widget::Entry::onCallbackSelect(bool _all) { if(_all == true) { m_displayCursorPosSelection = 0; - m_displayCursorPos = m_data->size(); + m_displayCursorPos = propertyValue->size(); } else { m_displayCursorPosSelection = m_displayCursorPos; } @@ -493,28 +475,28 @@ void ewol::widget::Entry::onCallbackSelect(bool _all) { } void ewol::widget::Entry::markToUpdateTextPosition() { - m_needUpdateTextPos=true; + m_needUpdateTextPos = true; } void ewol::widget::Entry::updateTextPosition() { - if (false == m_needUpdateTextPos) { + if (m_needUpdateTextPos == false) { return; } - ewol::Padding padding = m_shaper->getPadding(); + ewol::Padding padding = m_shaper.getPadding(); int32_t tmpSizeX = m_minSize.x(); - if (true == m_userFill->x()) { + if (propertyFill->x() == true) { tmpSizeX = m_size.x(); } int32_t tmpUserSize = tmpSizeX - padding.x(); - int32_t totalWidth = m_text.calculateSize(m_data).x(); + int32_t totalWidth = m_text.calculateSize(propertyValue).x(); // Check if the data inside the display can be contain in the entry box if (totalWidth < tmpUserSize) { // all can be display : m_displayStartPosition = 0; } else { // all can not be set : - std::string tmpDisplay = std::string(m_data, 0, m_displayCursorPos); + std::string tmpDisplay = std::string(propertyValue, 0, m_displayCursorPos); int32_t pixelCursorPos = m_text.calculateSize(tmpDisplay).x(); // check if the Cussor is visible at 10px nearest the border : int32_t tmp1 = pixelCursorPos+m_displayStartPosition; @@ -546,14 +528,14 @@ void ewol::widget::Entry::onLostFocus() { } void ewol::widget::Entry::changeStatusIn(int32_t _newStatusId) { - if (true == m_shaper->changeStatusIn(_newStatusId) ) { + if (m_shaper.changeStatusIn(_newStatusId) == true) { periodicCallEnable(); markToRedraw(); } } void ewol::widget::Entry::periodicCall(const ewol::event::Time& _event) { - if (false == m_shaper->periodicCall(_event) ) { + if (m_shaper.periodicCall(_event) == false) { periodicCallDisable(); } markToRedraw(); @@ -561,24 +543,36 @@ void ewol::widget::Entry::periodicCall(const ewol::event::Time& _event) { void ewol::widget::Entry::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::Widget::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_shaper) { - m_colorIdTextFg = m_shaper->requestColor("text-foreground"); - m_colorIdTextBg = m_shaper->requestColor("text-background"); - m_colorIdCursor = m_shaper->requestColor("text-cursor"); - m_colorIdSelection = m_shaper->requestColor("text-selection"); - } else if (_paramPointer == m_data) { - // to late to update data ... with control. - markToRedraw(); - } else if (_paramPointer == m_maxCharacter) { - // nothing to do ... - } else if (_paramPointer == m_regexValue) { - try { - m_regex.assign(m_regexValue.get(), std::regex_constants::optimize | std::regex_constants::ECMAScript); - } catch (std::regex_error e) { - EWOL_ERROR("can not parse regex : '" << e.what() << "' for : " << m_regexValue); + if (_paramPointer == propertyShaper) { + m_shaper.setSource(propertyShaper.get()); + m_colorIdTextFg = m_shaper.requestColor("text-foreground"); + m_colorIdTextBg = m_shaper.requestColor("text-background"); + m_colorIdCursor = m_shaper.requestColor("text-cursor"); + m_colorIdSelection = m_shaper.requestColor("text-selection"); + } else if (_paramPointer == propertyValue) { + std::string newData = propertyValue.get(); + if ((int64_t)newData.size() > propertyMaxCharacter) { + newData = std::string(newData, 0, propertyMaxCharacter); + EWOL_DEBUG("Limit entry set of data... " << std::string(newData, propertyMaxCharacter)); + } + // set the value with the check of the RegExp ... + setInternalValue(newData); + if (newData == propertyValue.get()) { + m_displayCursorPos = propertyValue->size(); + m_displayCursorPosSelection = m_displayCursorPos; + EWOL_VERBOSE("Set : '" << newData << "'"); } markToRedraw(); - } else if (_paramPointer == m_textWhenNothing) { + } else if (_paramPointer == propertyMaxCharacter) { + // TODO : check nomber of char in the data + } else if (_paramPointer == propertyRegex) { + try { + m_regex.assign(propertyRegex.get(), std::regex_constants::optimize | std::regex_constants::ECMAScript); + } catch (std::regex_error e) { + EWOL_ERROR("can not parse regex : '" << e.what() << "' for : " << propertyRegex); + } + markToRedraw(); + } else if (_paramPointer == propertyTextWhenNothing) { markToRedraw(); } } diff --git a/ewol/widget/Entry.h b/ewol/widget/Entry.h index c075adc6..786294c7 100644 --- a/ewol/widget/Entry.h +++ b/ewol/widget/Entry.h @@ -103,23 +103,6 @@ namespace ewol { * @note This request a regeneration of the display */ virtual void removeSelected(); - private: - eproperty::Value m_textWhenNothing; //!< Text to display when nothing in in the entry (decorated text...) - public: - /** - * @brief set The text displayed when nothing is in the entry. - * @param _text Text to display when the entry box is empty (this text can be decorated). - */ - void setEmptyText(const std::string& _text) { - m_textWhenNothing.set(_text); - } - /** - * @brief get The text displayed when nothing is in the entry. - * @return Text display when nothing - */ - const std::string& getEmptyText() const { - return m_textWhenNothing; - }; public: // Derived function virtual void onRegenerateDisplay(); virtual bool onEventInput(const ewol::event::Input& _event); diff --git a/ewol/widget/Gird.cpp b/ewol/widget/Gird.cpp index 0d05ea1e..aada096e 100644 --- a/ewol/widget/Gird.cpp +++ b/ewol/widget/Gird.cpp @@ -52,7 +52,7 @@ void ewol::widget::Gird::onChangeSize() { m_size -= m_borderSize*2; for (size_t iii=0; iiigetPixel(); - m_maxSize = m_userMaxSize->getPixel(); + m_minSize = propertyMinSize->getPixel(); + m_maxSize = propertyMaxSize->getPixel(); m_uniformSizeRow = 0; m_minSize += m_borderSize*2; int32_t lastLineID = 0; @@ -102,7 +102,7 @@ void ewol::widget::Gird::calculateMinMaxSize() { // change of line : lastLineID = m_subWidget[iii].row; } - if (nullptr != m_subWidget[iii].widget) { + if (m_subWidget[iii].widget != nullptr) { m_subWidget[iii].widget->calculateMinMaxSize(); vec2 tmpSize = m_subWidget[iii].widget->getCalculateMinSize(); EWOL_DEBUG(" [" << iii << "] subWidgetMinSize=" << tmpSize); @@ -136,7 +136,7 @@ void ewol::widget::Gird::setColNumber(int32_t _colNumber) { size_t errorControl = m_subWidget.size(); // remove subWidget : for (int64_t iii=m_subWidget.size(); iii >= 0; iii--) { - if (m_subWidget[iii].col>(_colNumber-1)) { + if (m_subWidget[iii].col > (_colNumber-1)) { // out of bounds : must remove it ... if (m_subWidget[iii].widget != nullptr) { m_subWidget[iii].widget.reset(); @@ -197,7 +197,7 @@ void ewol::widget::Gird::subWidgetRemoveAll() { void ewol::widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, std::shared_ptr _newWidget) { - if (nullptr == _newWidget) { + if (_newWidget == nullptr) { return; } GirdProperties prop; @@ -249,7 +249,8 @@ void ewol::widget::Gird::subWidgetRemove(std::shared_ptr _newWidge } void ewol::widget::Gird::subWidgetRemove(int32_t _colId, int32_t _rowId) { - if (_colId<0 || _rowId<0) { + if ( _colId < 0 + || _rowId < 0) { EWOL_WARNING("[" << getId() << "] try to remove widget with id < 0 col=" << _colId << " row=" << _rowId); return; } @@ -266,7 +267,7 @@ void ewol::widget::Gird::subWidgetRemove(int32_t _colId, int32_t _rowId) { } void ewol::widget::Gird::subWidgetUnLink(std::shared_ptr _newWidget) { - if (nullptr == _newWidget) { + if (_newWidget == nullptr) { return; } for (size_t iii=0; iii _newWidge } void ewol::widget::Gird::subWidgetUnLink(int32_t _colId, int32_t _rowId) { - if (_colId<0 || _rowId<0) { + if ( _colId < 0 + || _rowId < 0) { EWOL_WARNING("[" << getId() << "] try to Unlink widget with id < 0 col=" << _colId << " row=" << _rowId); return; } @@ -295,41 +297,42 @@ void ewol::widget::Gird::subWidgetUnLink(int32_t _colId, int32_t _rowId) { void ewol::widget::Gird::systemDraw(const ewol::DrawProperty& _displayProp) { ewol::Widget::systemDraw(_displayProp); - for (size_t iii=0; iiisystemDraw(_displayProp); + for (auto &it : m_subWidget) { + if (it.widget != nullptr) { + it.widget->systemDraw(_displayProp); } } } void ewol::widget::Gird::onRegenerateDisplay() { - for (size_t iii=0; iiionRegenerateDisplay(); + for (auto &it : m_subWidget) { + if (it.widget != nullptr) { + it.widget->onRegenerateDisplay(); } } } std::shared_ptr ewol::widget::Gird::getWidgetAtPos(const vec2& _pos) { - if (true == isHide()) { + if (propertyHide == true) { return nullptr; } // for all element in the sizer ... - for (size_t iii=0; iiigetSize(); - vec2 tmpOrigin = m_subWidget[iii].widget->getOrigin(); - if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) - && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) - { - std::shared_ptr tmpWidget = m_subWidget[iii].widget->getWidgetAtPos(_pos); - if (nullptr != tmpWidget) { - return tmpWidget; - } - // stop searching - break; + for (auto &it : m_subWidget) { + if (it.widget == nullptr) { + continue; + } + vec2 tmpSize = it.widget->getSize(); + vec2 tmpOrigin = it.widget->getOrigin(); + if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) + && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { + std::shared_ptr tmpWidget = it.widget->getWidgetAtPos(_pos); + if (tmpWidget != nullptr) { + return tmpWidget; } + // stop searching + break; } } return nullptr; } + diff --git a/ewol/widget/Image.cpp b/ewol/widget/Image.cpp index 79d76e55..fed1261f 100644 --- a/ewol/widget/Image.cpp +++ b/ewol/widget/Image.cpp @@ -18,16 +18,16 @@ ewol::widget::Image::Image() : signalPressed(*this, "pressed", "Image is pressed"), + propertySource(*this, "src", "", "Image source path"), + propertyBorder(*this, "border", vec2(0,0), "Border of the image"), + propertyImageSize(*this, "size", vec2(0,0), "Basic display size of the image"), + propertyKeepRatio(*this, "ratio", true, "Keep ratio of the image"), + propertyPosStart(*this, "part-start", vec2(0.0f, 0.0f), vec2(0.0f, 0.0f), vec2(1.0f, 1.0f), "Start display position in the image"), + propertyPosStop(*this, "part-stop", vec2(1.0f, 1.0f), vec2(0.0f, 0.0f), vec2(1.0f, 1.0f), "Start display position in the image"), + propertyDistanceFieldMode(*this, "distance-field", false, "Distance field mode"), + propertySmooth(*this, "smooth", true, "Smooth display of the image"), m_colorProperty(nullptr), - m_colorId(-1), - m_fileName(*this, "src", "", "Image source path"), - m_border(*this, "border", vec2(0,0), "Border of the image"), - m_imageSize(*this, "size", vec2(0,0), "Basic display size of the image"), - m_keepRatio(*this, "ratio", true, "Keep ratio of the image"), - m_posStart(*this, "part-start", vec2(0.0f, 0.0f), vec2(0.0f, 0.0f), vec2(1.0f, 1.0f), "Start display position in the image"), - m_posStop(*this, "part-stop", vec2(1.0f, 1.0f), vec2(0.0f, 0.0f), vec2(1.0f, 1.0f), "Start display position in the image"), - m_distanceFieldMode(*this, "distance-field", false, "Distance field mode"), - m_smooth(*this, "smooth", true, "Smooth display of the image") { + m_colorId(-1) { addObjectType("ewol::widget::Image"); m_imageRenderSize = vec2(0,0); m_colorProperty = ewol::resource::ColorFile::create("{ewol}THEME:COLOR:Image.json"); @@ -48,8 +48,8 @@ ewol::widget::Image::~Image() { void ewol::widget::Image::set(const std::string& _file, const gale::Dimension& _border) { EWOL_VERBOSE("Set Image : " << _file << " border=" << _border); - m_border.set(_border); - m_fileName.set(_file); + propertyBorder.set(_border); + propertySource.set(_file); } void ewol::widget::Image::onDraw() { @@ -57,85 +57,86 @@ void ewol::widget::Image::onDraw() { } void ewol::widget::Image::onRegenerateDisplay() { - if (true == needRedraw()) { - // remove data of the previous composition : - m_compositing.clear(); - if (m_colorProperty != nullptr) { - m_compositing.setColor(m_colorProperty->get(m_colorId)); - } - // calculate the new position and size : - vec2 imageBoder = m_border->getPixel(); - vec2 origin = imageBoder; - imageBoder *= 2.0f; - vec2 imageRealSize = m_imageRenderSize - imageBoder; - vec2 imageRealSizeMax = m_size - imageBoder; - - vec2 ratioSizeDisplayRequested = m_posStop.get() - m_posStart.get(); - //imageRealSizeMax *= ratioSizeDisplayRequested; - - vec2 delta = ewol::gravityGenerateDelta(m_gravity, m_size-m_imageRenderSize); - if (m_userFill->x() == true) { - imageRealSize.setX(imageRealSizeMax.x()); - delta.setX(0.0); - } - if (m_userFill->y() == true) { - imageRealSize.setY(imageRealSizeMax.y()); - delta.setY(0.0); - } - origin += delta; - - if (m_keepRatio == true) { - vec2 tmpSize = m_compositing.getRealSize(); - //float ratio = tmpSize.x() / tmpSize.y(); - float ratio = (tmpSize.x()*ratioSizeDisplayRequested.x()) / (tmpSize.y() * ratioSizeDisplayRequested.y()); - //float ratioCurrent = (imageRealSize.x()*ratioSizeDisplayRequested.x()) / (imageRealSize.y() * ratioSizeDisplayRequested.y()); - float ratioCurrent = imageRealSize.x() / imageRealSize.y(); - if (ratio == ratioCurrent) { - // nothing to do ... - } else if (ratio < ratioCurrent) { - float oldX = imageRealSize.x(); - imageRealSize.setX(imageRealSize.y()*ratio); - origin += vec2((oldX - imageRealSize.x()) * 0.5f, 0); - } else { - float oldY = imageRealSize.y(); - imageRealSize.setY(imageRealSize.x()/ratio); - origin += vec2(0, (oldY - imageRealSize.y()) * 0.5f); - } - } - - // set the somposition properties : - if (m_smooth.get() == true) { - m_compositing.setPos(origin); - } else { - m_compositing.setPos(ivec2(origin)); - } - m_compositing.printPart(imageRealSize, m_posStart, m_posStop); - //EWOL_DEBUG("Paint Image at : " << origin << " size=" << imageRealSize << " origin=" << origin); - EWOL_VERBOSE("Paint Image :" << m_fileName << " realsize=" << m_compositing.getRealSize() << " size=" << imageRealSize); + if (needRedraw() == false) { + return; } + // remove data of the previous composition : + m_compositing.clear(); + if (m_colorProperty != nullptr) { + m_compositing.setColor(m_colorProperty->get(m_colorId)); + } + // calculate the new position and size : + vec2 imageBoder = propertyBorder->getPixel(); + vec2 origin = imageBoder; + imageBoder *= 2.0f; + vec2 imageRealSize = m_imageRenderSize - imageBoder; + vec2 imageRealSizeMax = m_size - imageBoder; + + vec2 ratioSizeDisplayRequested = propertyPosStop.get() - propertyPosStart.get(); + //imageRealSizeMax *= ratioSizeDisplayRequested; + + vec2 delta = ewol::gravityGenerateDelta(propertyGravity, m_size-m_imageRenderSize); + if (propertyFill->x() == true) { + imageRealSize.setX(imageRealSizeMax.x()); + delta.setX(0.0); + } + if (propertyFill->y() == true) { + imageRealSize.setY(imageRealSizeMax.y()); + delta.setY(0.0); + } + origin += delta; + + if (propertyKeepRatio == true) { + vec2 tmpSize = m_compositing.getRealSize(); + //float ratio = tmpSize.x() / tmpSize.y(); + float ratio = (tmpSize.x()*ratioSizeDisplayRequested.x()) / (tmpSize.y() * ratioSizeDisplayRequested.y()); + //float ratioCurrent = (imageRealSize.x()*ratioSizeDisplayRequested.x()) / (imageRealSize.y() * ratioSizeDisplayRequested.y()); + float ratioCurrent = imageRealSize.x() / imageRealSize.y(); + if (ratio == ratioCurrent) { + // nothing to do ... + } else if (ratio < ratioCurrent) { + float oldX = imageRealSize.x(); + imageRealSize.setX(imageRealSize.y()*ratio); + origin += vec2((oldX - imageRealSize.x()) * 0.5f, 0); + } else { + float oldY = imageRealSize.y(); + imageRealSize.setY(imageRealSize.x()/ratio); + origin += vec2(0, (oldY - imageRealSize.y()) * 0.5f); + } + } + + // set the somposition properties : + if (propertySmooth.get() == true) { + m_compositing.setPos(origin); + } else { + m_compositing.setPos(ivec2(origin)); + } + m_compositing.printPart(imageRealSize, propertyPosStart, propertyPosStop); + //EWOL_DEBUG("Paint Image at : " << origin << " size=" << imageRealSize << " origin=" << origin); + EWOL_VERBOSE("Paint Image :" << propertySource << " realsize=" << m_compositing.getRealSize() << " size=" << imageRealSize); } void ewol::widget::Image::calculateMinMaxSize() { - vec2 imageBoder = m_border->getPixel()*2.0f; - vec2 imageSize = m_imageSize->getPixel(); - vec2 size = m_userMinSize->getPixel(); + vec2 imageBoder = propertyBorder->getPixel()*2.0f; + vec2 imageSize = propertyImageSize->getPixel(); + vec2 size = propertyMinSize->getPixel(); if (imageSize != vec2(0,0)) { m_minSize = imageBoder+imageSize; m_maxSize = m_minSize; } else { vec2 imageSizeReal = m_compositing.getRealSize(); - vec2 min1 = imageBoder+m_userMinSize->getPixel(); + vec2 min1 = imageBoder+propertyMinSize->getPixel(); m_minSize = imageBoder+imageSizeReal; //EWOL_DEBUG(" set max : " << m_minSize << " " << min1); m_minSize.setMax(min1); //EWOL_DEBUG(" result : " << m_minSize); - m_maxSize = imageBoder+m_userMaxSize->getPixel(); + m_maxSize = imageBoder+propertyMaxSize->getPixel(); m_minSize.setMin(m_maxSize); } m_imageRenderSize = m_minSize; m_minSize.setMax(size); m_maxSize.setMax(m_minSize); - //EWOL_ERROR("set widget min=" << m_minSize << " max=" << m_maxSize << " with real Image size=" << m_imageRenderSize << " img size=" << imageSize << " " << m_imageSize); + //EWOL_ERROR("set widget min=" << m_minSize << " max=" << m_maxSize << " with real Image size=" << m_imageRenderSize << " img size=" << imageSize << " " << propertyImageSize); markToRedraw(); } @@ -161,34 +162,34 @@ bool ewol::widget::Image::loadXML(const std::shared_ptr& _n std::string tmpAttributeValue = _node->getAttribute("ratio"); if (tmpAttributeValue.size() != 0) { if (etk::compare_no_case(tmpAttributeValue, "true") == true) { - m_keepRatio = true; + propertyKeepRatio = true; } else if (tmpAttributeValue == "1") { - m_keepRatio = true; + propertyKeepRatio = true; } else { - m_keepRatio = false; + propertyKeepRatio = false; } } tmpAttributeValue = _node->getAttribute("size"); if (tmpAttributeValue.size() != 0) { //EWOL_CRITICAL(" Parse SIZE : " << tmpAttributeValue); - m_imageSize = tmpAttributeValue; - //EWOL_CRITICAL(" == > " << m_imageSize); + propertyImageSize = tmpAttributeValue; + //EWOL_CRITICAL(" == > " << propertyImageSize); } tmpAttributeValue = _node->getAttribute("border"); if (tmpAttributeValue.size() != 0) { - m_border = tmpAttributeValue; + propertyBorder = tmpAttributeValue; } tmpAttributeValue = _node->getAttribute("smooth"); if (tmpAttributeValue.size() != 0) { - m_smooth = etk::string_to_bool(tmpAttributeValue); + propertySmooth = etk::string_to_bool(tmpAttributeValue); } //EWOL_DEBUG("Load label:" << node->ToElement()->getText()); if (_node->size() != 0) { - setFile(_node->getText()); + propertySource.set(_node->getText()); } else { tmpAttributeValue = _node->getAttribute("src"); if (tmpAttributeValue.size() != 0) { - setFile(tmpAttributeValue); + propertySource.set(tmpAttributeValue); } } return true; @@ -196,21 +197,24 @@ bool ewol::widget::Image::loadXML(const std::shared_ptr& _n void ewol::widget::Image::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::Widget::onPropertyChangeValue(_paramPointer); - if ( _paramPointer == m_fileName - || _paramPointer == m_imageSize) { + if ( _paramPointer == propertySource + || _paramPointer == propertyImageSize) { markToRedraw(); requestUpdateSize(); - EWOL_VERBOSE("Set sources : " << m_fileName << " size=" << m_imageSize); - m_compositing.setSource(m_fileName, m_imageSize->getPixel()); - } else if ( _paramPointer == m_border - || _paramPointer == m_keepRatio - || _paramPointer == m_posStart - || _paramPointer == m_posStop) { + EWOL_VERBOSE("Set sources : " << propertySource << " size=" << propertyImageSize); + m_compositing.setSource(propertySource, propertyImageSize->getPixel()); + } else if ( _paramPointer == propertyBorder + || _paramPointer == propertyKeepRatio + || _paramPointer == propertyPosStart + || _paramPointer == propertyPosStop) { markToRedraw(); requestUpdateSize(); - } else if (_paramPointer == m_distanceFieldMode) { + } else if (_paramPointer == propertyDistanceFieldMode) { markToRedraw(); - } else if (_paramPointer == m_smooth) { + } else if (_paramPointer == propertySmooth) { + markToRedraw(); + } else if (_paramPointer == propertyDistanceFieldMode) { + m_compositing.setDistanceFieldMode(propertyDistanceFieldMode.get()); markToRedraw(); } } diff --git a/ewol/widget/Image.h b/ewol/widget/Image.h index b35fb930..7ac65e34 100644 --- a/ewol/widget/Image.h +++ b/ewol/widget/Image.h @@ -21,9 +21,17 @@ namespace ewol { * @ingroup ewolWidgetGroup */ class Image :public ewol::Widget { - public: - // Event list of properties + public: // signals esignal::Signal signalPressed; + public: // properties + eproperty::Value propertySource; //!< file name of the image. + eproperty::Value propertyBorder; //!< border to add at the image. + eproperty::Value propertyImageSize; //!< border to add at the image. + eproperty::Value propertyKeepRatio; //!< keep the image ratio between width and hight + eproperty::Range propertyPosStart; //!< position in the image to start the sisplay (when we want not to display all the image) + eproperty::Range propertyPosStop; //!< position in the image to start the sisplay (when we want not to display all the image) + eproperty::Value propertyDistanceFieldMode; //!< to have a parameter + eproperty::Value propertySmooth; //!< display is done in the pixed approximation if false protected: ewol::compositing::Image m_compositing; //!< compositing element of the image. std::shared_ptr m_colorProperty; //!< theme color property @@ -48,132 +56,7 @@ namespace ewol { */ void set(const std::string& _file, const gale::Dimension& _border); protected: - eproperty::Value m_fileName; //!< file name of the image. - public: - /** - * @brief set the new filename - * @param[in] _file Filaneme of the new image - */ - void setFile(const std::string& _file) { - m_fileName.set(_file); - } - /** - * @brief get the file displayed - * @return the filename of the image - */ - const std::string& getFile() const { - return m_fileName; - }; - protected: - eproperty::Value m_border; //!< border to add at the image. - public: - /** - * @brief set tge Border size around the image - * @param[in] _border New border size to set - */ - void setBorder(const gale::Dimension& _border); - /** - * @brief get the current border request at the image - * @return the border size - */ - const gale::Dimension& getBorder() const { - return m_border; - }; - protected: - eproperty::Value m_imageSize; //!< border to add at the image. vec2 m_imageRenderSize; //!< size of the image when we render it - public: - /** - * @brief set tge Border size around the image - * @param[in] _size New border size to set - */ - void setImageSize(const gale::Dimension& _size); - /** - * @brief get the current border request at the image - * @return the border size - */ - const gale::Dimension& getImageSize() const { - return m_imageSize; - }; - protected: - eproperty::Value m_keepRatio; //!< keep the image ratio between width and hight - public: - /** - * @brief set the current status of keeping ratio. - * @param[in] _keep The new status of keeping the ratio of this image. - */ - void setKeepRatio(bool _keep); - /** - * @brief get the current status of keeping ratio. - * @return The status of keeping the ratio of this image. - */ - bool getKeepRatio() const { - return m_keepRatio; - }; - protected: - eproperty::Range m_posStart; //!< position in the image to start the sisplay (when we want not to display all the image) - public: - /** - * @brief set the current 'start' position in the image to display. - * @param[in] _keep The new position in the image vec2([0..1],[0..1]) - */ - void setStartPos(const vec2& _pos); - /** - * @brief get the current 'start' position in the image to display. - * @return The Position of the display in image - */ - vec2 getStartPos() const { - return m_posStart; - }; - protected: - eproperty::Range m_posStop; //!< position in the image to start the sisplay (when we want not to display all the image) - public: - /** - * @brief set the current 'stop' position in the image to display. - * @param[in] _keep The new position in the image vec2([0..1],[0..1]) - */ - void setStopPos(const vec2& _pos); - /** - * @brief get the current 'stop' position in the image to display. - * @return The Position of the display in image - */ - vec2 getStopPos() const { - return m_posStop; - }; - protected: - eproperty::Value m_distanceFieldMode; //!< to have a parameter - public: - /** - * @brief Set distance field rendering mode - * @param[in] _df enable distance field - */ - void setDistanceField(bool _df) { - m_compositing.setDistanceFieldMode(_df); - } - /** - * @brief Get the distance field render mode. - * @return Status of the distance field render mode. - */ - bool getDistanceField() const { - return m_compositing.getDistanceFieldMode(); - } - protected: - eproperty::Value m_smooth; //!< display is done in the pixed approximation if false - public: - /** - * @brief Set smooth rendering mode - * @param[in] _value enable smooting of the display - */ - void setSmooth(bool _value) { - m_smooth.set(_value); - } - /** - * @brief Get smooth rendering mode - * @return Status of the smooting render mode. - */ - bool getSmooth() const { - return m_smooth; - } protected: // Derived function virtual void onDraw(); virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); diff --git a/ewol/widget/Joystick.cpp b/ewol/widget/Joystick.cpp index 584cbacb..1ae4cbea 100644 --- a/ewol/widget/Joystick.cpp +++ b/ewol/widget/Joystick.cpp @@ -43,11 +43,11 @@ ewol::widget::Joystick::Joystick() : m_background = l_background; m_foreground = l_foreground; m_ratio = l_ratio; - setCanHaveFocus(true); } void ewol::widget::Joystick::init() { ewol::Widget::init(); + propertyCanFocus.set(true); } diff --git a/ewol/widget/Joystick.h b/ewol/widget/Joystick.h index fa406513..04520b90 100644 --- a/ewol/widget/Joystick.h +++ b/ewol/widget/Joystick.h @@ -13,6 +13,7 @@ #include #include +// TODO : Rework ==> use property and shaper ... namespace ewol { namespace widget { diff --git a/ewol/widget/Label.cpp b/ewol/widget/Label.cpp index a205a256..b57a3e70 100644 --- a/ewol/widget/Label.cpp +++ b/ewol/widget/Label.cpp @@ -18,7 +18,8 @@ // TODO : Remove the label name in the constructor ... ewol::widget::Label::Label() : signalPressed(*this, "pressed"), - m_label(*this, "value", U"", "displayed value string"), + propertyValue(*this, "value", "", "displayed value string"), + m_value(U""), m_colorProperty(nullptr), m_colorDefaultFgText(-1), m_colorDefaultBgText(-1){ @@ -28,13 +29,13 @@ ewol::widget::Label::Label() : m_colorDefaultFgText = m_colorProperty->request("foreground"); m_colorDefaultBgText = m_colorProperty->request("background"); } - setCanHaveFocus(false); setMouseLimit(1); } void ewol::widget::Label::init(std::string _newLabel) { ewol::Widget::init(); - m_label.setString(_newLabel); + propertyCanFocus.set(false); + propertyValue.set(_newLabel); } ewol::widget::Label::~Label() { @@ -42,14 +43,14 @@ ewol::widget::Label::~Label() { } void ewol::widget::Label::calculateMinMaxSize() { - vec2 tmpMax = m_userMaxSize->getPixel(); - vec2 tmpMin = m_userMinSize->getPixel(); + vec2 tmpMax = propertyMaxSize->getPixel(); + vec2 tmpMin = propertyMinSize->getPixel(); //EWOL_DEBUG("[" << getId() << "] {" << getObjectType() << "} tmpMax : " << tmpMax); if (tmpMax.x() <= 999999) { m_text.setTextAlignement(0, tmpMax.x()-4, ewol::compositing::alignLeft); //EWOL_DEBUG("[" << getId() << "] {" << getObjectType() << "} forcez Alignement "); } - vec3 minSize = m_text.calculateSizeDecorated(m_label.get()); + vec3 minSize = m_text.calculateSizeDecorated(m_value); //EWOL_DEBUG("[" << getId() << "] {" << getObjectType() << "} minSize : " << minSize); m_minSize.setX(std::avg(tmpMin.x(), 4 + minSize.x(), tmpMax.x())); @@ -68,7 +69,7 @@ void ewol::widget::Label::onRegenerateDisplay() { m_text.clear(); int32_t paddingSize = 2; - vec2 tmpMax = m_userMaxSize->getPixel(); + vec2 tmpMax = propertyMaxSize->getPixel(); // to know the size of one line : vec3 minSize = m_text.calculateSize(char32_t('A')); @@ -77,7 +78,7 @@ void ewol::widget::Label::onRegenerateDisplay() { if (tmpMax.x() <= 999999) { m_text.setTextAlignement(0, tmpMax.x()-2*paddingSize, ewol::compositing::alignLeft); } - vec3 curentTextSize = m_text.calculateSizeDecorated(m_label.get()); + vec3 curentTextSize = m_text.calculateSizeDecorated(m_value); ivec2 localSize = m_minSize; @@ -86,11 +87,11 @@ void ewol::widget::Label::onRegenerateDisplay() { (m_size.y() - m_minSize.y()) / 2.0, 0); - if (m_userFill->x() == true) { + if (propertyFill->x() == true) { localSize.setX(m_size.x()); tmpTextOrigin.setX(0); } - if (m_userFill->y() == true) { + if (propertyFill->y() == true) { localSize.setY(m_size.y()); tmpTextOrigin.setY(m_size.y() - 2*paddingSize - curentTextSize.y()); } @@ -113,15 +114,15 @@ void ewol::widget::Label::onRegenerateDisplay() { m_text.setDefaultColorBg(m_colorProperty->get(m_colorDefaultBgText)); } m_text.setPos(tmpTextOrigin); - EWOL_VERBOSE("[" << getId() << "] {" << m_label.get() << "} display at pos : " << tmpTextOrigin); + EWOL_VERBOSE("[" << getId() << "] {" << m_value << "} display at pos : " << tmpTextOrigin); m_text.setTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x(), ewol::compositing::alignLeft); m_text.setClipping(drawClippingPos, drawClippingSize); - m_text.printDecorated(m_label.get()); + m_text.printDecorated(m_value); } bool ewol::widget::Label::onEventInput(const ewol::event::Input& _event) { //EWOL_DEBUG("Event on Label ..."); - if (1 == _event.getId()) { + if (_event.getId() == 1) { if (gale::key::status_single == _event.getStatus()) { // nothing to do ... signalPressed.emit(); @@ -138,13 +139,14 @@ bool ewol::widget::Label::loadXML(const std::shared_ptr& _n ewol::Widget::loadXML(_node); // get internal data : EWOL_DEBUG("Load label:" << _node->getText()); - setLabel(_node->getText()); + propertyValue.set(_node->getText()); return true; } void ewol::widget::Label::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::Widget::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_label) { + if (_paramPointer == propertyValue) { + m_value = etk::to_u32string(propertyValue.get()); markToRedraw(); requestUpdateSize(); } diff --git a/ewol/widget/Label.h b/ewol/widget/Label.h index 1f9da0d4..fc33013e 100644 --- a/ewol/widget/Label.h +++ b/ewol/widget/Label.h @@ -21,12 +21,13 @@ namespace ewol { * @ingroup ewolWidgetGroup */ class Label : public ewol::Widget { - public: - // Event list of properties + public: // signals esignal::Signal signalPressed; + public: // properties + eproperty::Value propertyValue; //!< decorated text to display. private: ewol::compositing::Text m_text; //!< Compositing text element. - eproperty::Value m_label; //!< decorated text to display. + std::u32string m_value; std::shared_ptr m_colorProperty; //!< theme color property int32_t m_colorDefaultFgText; //!< Default color of the text int32_t m_colorDefaultBgText; //!< Default Background color of the text @@ -43,28 +44,6 @@ namespace ewol { * @brief destructor */ virtual ~Label(); - /** - * @brief change the label displayed - * @param[in] _newLabel The displayed decorated text. - */ - void setLabel(const std::string& _newLabel) { - m_label.set(etk::to_u32string(_newLabel)); - } - //! @previous - inline void setValue(const std::string& _newLabel) { - m_label.set(etk::to_u32string(_newLabel)); - }; - /** - * @brief get the current displayed label - * @return The displayed decorated text. - */ - std::string getLabel() const { - return etk::to_string(m_label); - } - //! @previous - inline std::string getValue() const { - return etk::to_string(m_label); - }; protected: // Derived function virtual void onDraw(); virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); diff --git a/ewol/widget/Layer.cpp b/ewol/widget/Layer.cpp index 2a695bc5..d0c0c1d2 100644 --- a/ewol/widget/Layer.cpp +++ b/ewol/widget/Layer.cpp @@ -26,7 +26,7 @@ ewol::widget::Layer::~Layer() { } std::shared_ptr ewol::widget::Layer::getWidgetAtPos(const vec2& _pos) { - if (true == isHide()) { + if (propertyHide == true) { return nullptr; } // for all element in the sizer ... @@ -37,10 +37,9 @@ std::shared_ptr ewol::widget::Layer::getWidgetAtPos(const vec2& _p vec2 tmpSize = it->getSize(); vec2 tmpOrigin = it->getOrigin(); if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x()) - && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) - { + && (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) ) { std::shared_ptr tmpWidget = it->getWidgetAtPos(_pos); - if (nullptr != tmpWidget) { + if (tmpWidget != nullptr) { return tmpWidget; } // parse the next layer ... diff --git a/ewol/widget/List.cpp b/ewol/widget/List.cpp index 553e9864..4f5ce7ca 100644 --- a/ewol/widget/List.cpp +++ b/ewol/widget/List.cpp @@ -24,12 +24,12 @@ ewol::widget::List::List() { #else m_paddingSizeY = 2; #endif - m_nbVisibleRaw=0; - setCanHaveFocus(true); + m_nbVisibleRaw = 0; } void ewol::widget::List::init() { ewol::widget::WidgetScrolled::init(); + propertyCanFocus.set(true); } ewol::widget::List::~List() { diff --git a/ewol/widget/ListFileSystem.cpp b/ewol/widget/ListFileSystem.cpp index ea173916..9c8f29dc 100644 --- a/ewol/widget/ListFileSystem.cpp +++ b/ewol/widget/ListFileSystem.cpp @@ -20,16 +20,16 @@ ewol::widget::ListFileSystem::ListFileSystem() : signalFileValidate(*this, "file-validate"), signalFolderSelect(*this, "folder-select"), signalFolderValidate(*this, "folder-validate"), - m_selectedLine(-1), - m_folder(*this, "path", "/", "Path to display"), - m_selectFile(*this, "select", "", "selection af a specific file"), - m_showFile(*this, "show-file", true, "display files"), - m_showFolder(*this, "show-folder", true, "display folders"), - m_showHidden(*this, "show-hidden", true, "Show the hidden element (file, folder, ...)"), - m_showTemporaryFile(*this, "show-temporary", true, "display temporary files") { + propertyPath(*this, "path", "/", "Path to display"), + propertyFile(*this, "select", "", "selection af a specific file"), + propertyShowFile(*this, "show-file", true, "display files"), + propertyShowFolder(*this, "show-folder", true, "display folders"), + propertyShowHidden(*this, "show-hidden", true, "Show the hidden element (file, folder, ...)"), + propertyFilter(*this, "filter", "", "regex to filter files ..."), + m_selectedLine(-1) { addObjectType("ewol::widget::ListFileSystem"); #if defined(__TARGET_OS__Windows) - m_folder = "c:/"; + propertyPath = "c:/"; #endif m_colorProperty = ewol::resource::ColorFile::create("{ewol}THEME:COLOR:ListFileSystem.json"); if (m_colorProperty != nullptr) { @@ -39,25 +39,25 @@ ewol::widget::ListFileSystem::ListFileSystem() : m_colorIdBackgroundSelected = m_colorProperty->request("selected"); } setMouseLimit(1); -}; +} void ewol::widget::ListFileSystem::init() { ewol::widget::List::init(); -}; +} ewol::widget::ListFileSystem::~ListFileSystem() { clearList(); -}; +} void ewol::widget::ListFileSystem::clearList() { - for (size_t iii=0; iii ewol::widget::ListFileSystem::getBasicBG() { return m_colorProperty->get(m_colorIdBackground1); @@ -69,9 +69,9 @@ void ewol::widget::ListFileSystem::regenerateView() { m_selectedLine = -1; m_list.clear(); m_originScrooled.setValue(0,0); - etk::FSNode tmpFolder(m_folder.get()); + etk::FSNode tmpFolder(propertyPath.get()); // get the new list : - m_list = tmpFolder.folderGetSubList(m_showHidden, m_showFolder, m_showFile, m_showTemporaryFile); + m_list = tmpFolder.folderGetSubList(propertyShowHidden, propertyShowFolder, propertyShowFile, propertyFilter); // request a redraw ... markToRedraw(); } @@ -91,8 +91,8 @@ void ewol::widget::ListFileSystem::setSelect(const std::string& _data) { // remove selected line m_selectedLine = -1; // search the coresponding file : - for (size_t iii=0; iiigetNameFile() == _data) { // we find the line : m_selectedLine = iii; @@ -114,8 +114,8 @@ bool ewol::widget::ListFileSystem::getTitle(int32_t _colomn, std::string &_myTit uint32_t ewol::widget::ListFileSystem::getNuberOfRaw() { int32_t offset = 0; - if (m_showFolder == true) { - if (m_folder.get() == "/") { + if (propertyShowFolder == true) { + if (propertyPath.get() == "/") { offset = 1; } else { offset = 2; @@ -126,8 +126,8 @@ uint32_t ewol::widget::ListFileSystem::getNuberOfRaw() { bool ewol::widget::ListFileSystem::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) { int32_t offset = 0; - if (m_showFolder == true) { - if (m_folder.get() == "/") { + if (propertyShowFolder == true) { + if (propertyPath.get() == "/") { offset = 1; } else { offset = 2; @@ -135,13 +135,13 @@ bool ewol::widget::ListFileSystem::getElement(int32_t _colomn, int32_t _raw, std if (_raw == 0) { _myTextToWrite = "."; } else if ( _raw == 1 - && m_folder.get() != "/") { + && propertyPath.get() != "/") { _myTextToWrite = ".."; } } if( _raw-offset >= 0 && _raw-offset < (int32_t)m_list.size() - && nullptr != m_list[_raw-offset]) { + && m_list[_raw-offset] != nullptr) { _myTextToWrite = m_list[_raw-offset]->getNameFile(); EWOL_VERBOSE("get filename for : '" << *m_list[_raw-offset] << ":'" << _myTextToWrite << "'"); } @@ -165,8 +165,8 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput, float _x, float _y) { int32_t offset = 0; - if (m_showFolder == true) { - if (m_folder.get() == "/") { + if (propertyShowFolder == true) { + if (propertyPath.get() == "/") { offset = 1; } else { offset = 2; @@ -182,11 +182,11 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput, m_selectedLine = _raw; } if (previousRaw != m_selectedLine) { - if( m_showFolder == true + if( propertyShowFolder == true && m_selectedLine == 0) { // "." folder signalFolderSelect.emit("."); - } else if ( m_showFolder == true + } else if ( propertyShowFolder == true && m_selectedLine == 1) { // ".." folder signalFolderSelect.emit(".."); @@ -207,11 +207,11 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput, } } } else { - if( m_showFolder == true + if( propertyShowFolder == true && m_selectedLine == 0) { // "." folder signalFolderValidate.emit("."); - } else if ( m_showFolder == true + } else if ( propertyShowFolder == true && m_selectedLine == 1) { // ".." folder signalFolderValidate.emit(".."); @@ -241,17 +241,17 @@ bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput, void ewol::widget::ListFileSystem::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::widget::List::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_folder) { + if (_paramPointer == propertyPath) { regenerateView(); - } else if (_paramPointer == m_selectFile) { - setSelect(m_selectFile); - } else if (_paramPointer == m_showFile) { + } else if (_paramPointer == propertyFile) { + setSelect(propertyFile); + } else if (_paramPointer == propertyShowFile) { regenerateView(); - } else if (_paramPointer == m_showFolder) { + } else if (_paramPointer == propertyShowFolder) { regenerateView(); - } else if (_paramPointer == m_showHidden) { + } else if (_paramPointer == propertyShowHidden) { regenerateView(); - } else if (_paramPointer == m_showTemporaryFile) { + } else if (_paramPointer == propertyFilter) { regenerateView(); } } diff --git a/ewol/widget/ListFileSystem.h b/ewol/widget/ListFileSystem.h index ae1ef539..945e245e 100644 --- a/ewol/widget/ListFileSystem.h +++ b/ewol/widget/ListFileSystem.h @@ -18,12 +18,18 @@ namespace ewol { * @brief Generic display folder class. This widget display the content of a single folder : */ class ListFileSystem : public ewol::widget::List { - public: - // Event list of properties + public: // signals esignal::Signal signalFileSelect; //!< @event "file-select" Generated when a file is selected. esignal::Signal signalFileValidate; //!< @event "file-validate" Generate when the user validate (return) or double click on the element esignal::Signal signalFolderSelect; esignal::Signal signalFolderValidate; + public: // properties + eproperty::Value propertyPath; //!< Current folder that display point on. + eproperty::Value propertyFile; //!< current selected file + eproperty::Value propertyShowFile; //!< Show files elements + eproperty::Value propertyShowFolder; //!< Display the folders elements + eproperty::Value propertyShowHidden; //!< Display hidden elements + eproperty::Value propertyFilter; //!< Regular expression to filter the view (for temporary file:".*(~|.bck|.pyc)\e") protected: ListFileSystem(); void init(); @@ -44,6 +50,7 @@ namespace ewol { virtual bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg); virtual bool onItemEvent(int32_t _IdInput, enum gale::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y); protected: + // TODO: use shred_ptr std::vector m_list; //!< List of all element in the path. (they are filtered) /** * @brief Clean the list of element. @@ -66,92 +73,6 @@ namespace ewol { * @return the String of the element selected. */ std::string getSelect() const ; - protected: - eproperty::Value m_folder; //!< Current folder that display point on. - eproperty::Value m_selectFile; //!< current selected file - public: - /** - * @brief Set a folder to display (might be a valid folder !!!) - * @param[in] _newFolder Path on the folder to display content. - */ - void setFolder(const std::string& _newFolder) { - m_folder.set(_newFolder); - }; - /** - * @brief Get the element current displaying folder path. - * @return Path on the folder. - */ - const std::string& getFolder() const { - return m_folder; - }; - protected: - eproperty::Value m_showFile; //!< Show files elements - public: - /** - * @brief Set the status of the displaying files or Not. - * @param[in] _state New state to apply on display the 'file'. - */ - void setShowFiles(bool _state) { - m_showFile.set(_state); - }; - /** - * @brief Get the status of the displaying files or Not. - * @return The status on displaying the 'file'. - */ - bool getShowFiles() const { - return m_showFile; - }; - protected: - eproperty::Value m_showFolder; //!< Display the folders elements - public: - /** - * @brief Set the status of the displaying fodlers or Not. - * @param[in] _state New state to apply on display the 'folder'. - */ - void setShowFolder(bool _state) { - m_showFolder.set(_state); - }; - /** - * @brief Get the status of the displaying fodlers or Not. - * @return The status on displaying the 'folder'. - */ - bool getShowFolder() const { - return m_showFile; - }; - protected: - eproperty::Value m_showHidden; //!< Display hidden elements - public: - /** - * @brief Set the status of the displaying hidden files or folder or Not. - * @param[in] _state New state to apply on display the hidden element. - */ - void setShowHidden(bool _state) { - m_showHidden.set(_state); - }; - /** - * @brief Get the status of the displaying hidden files or folder or Not. - * @return The status on displaying the hidden element. - */ - bool getShowHidden() const { - return m_showFile; - }; - protected: - eproperty::Value m_showTemporaryFile; //!< show the temporary files elements (XXX~, XXX.bck, XXX.pyc ...) - public: - /** - * @brief Set the status of the displaying temporary file (xxx~, xxx.bck, xxx.pyc) or Not. - * @param[in] _state New state to apply on display temporary files. - */ - void setShowTemporaryFiles(bool _state) { - m_showTemporaryFile.set(_state); - }; - /** - * @brief Get the status of the displaying temporary file (xxx~, xxx.bck, xxx.pyc) or Not. - * @return The status on displaying temporary files. - */ - bool getShowTemporaryFiles() const { - return m_showFile; - }; public: // glocal derived functions virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); }; diff --git a/ewol/widget/Manager.cpp b/ewol/widget/Manager.cpp index c7a20c31..4c2d6f24 100644 --- a/ewol/widget/Manager.cpp +++ b/ewol/widget/Manager.cpp @@ -91,7 +91,7 @@ void ewol::widget::Manager::focusKeep(const std::shared_ptr& _newW focusWidgetCurrent->rmFocus(); focusWidgetCurrent.reset(); } - if (_newWidget->canHaveFocus() == false) { + if (_newWidget->propertyCanFocus.get() == false) { EWOL_DEBUG("Widget can not have focus, id=" << _newWidget->getId() ); return; } @@ -104,7 +104,7 @@ void ewol::widget::Manager::focusKeep(const std::shared_ptr& _newW void ewol::widget::Manager::focusSetDefault(const std::shared_ptr& _newWidget) { if( _newWidget != nullptr - && _newWidget->canHaveFocus() == false) { + && _newWidget->propertyCanFocus.get() == false) { EWOL_VERBOSE("Widget can not have focus, id=" << _newWidget->getId() ); return; } diff --git a/ewol/widget/Menu.cpp b/ewol/widget/Menu.cpp index 58bf8632..bb572f28 100644 --- a/ewol/widget/Menu.cpp +++ b/ewol/widget/Menu.cpp @@ -180,8 +180,8 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu std::shared_ptr myButton; mySizer = ewol::widget::Sizer::create(widget::Sizer::modeVert); if (mySizer != nullptr) { - mySizer->lockExpand(vec2(true,true)); - mySizer->setFill(vec2(true,true)); + mySizer->propertyLockExpand.set(vec2(true,true)); + mySizer->propertyFill.set(vec2(true,true)); // set it in the pop-up-system: tmpContext->setSubWidget(mySizer); bool menuHaveImage = false; @@ -203,8 +203,8 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu EWOL_ERROR("Allocation Error"); continue; } - myButton->setExpand(bvec2(true,true)); - myButton->setFill(bvec2(true,true)); + myButton->propertyExpand.set(bvec2(true,true)); + myButton->propertyFill.set(bvec2(true,true)); // set callback myButton->signalPressed.bind(shared_from_this(), &ewol::widget::Menu::onButtonPressed, std::weak_ptr(myButton)); // add it in the widget list @@ -232,8 +232,8 @@ void ewol::widget::Menu::onButtonPressed(std::weak_ptr _bu } else { std::shared_ptr tmpLabel = widget::Label::create(std::string("") + it2->m_label + "\n"); if (tmpLabel != nullptr) { - tmpLabel->setExpand(bvec2(true,false)); - tmpLabel->setFill(bvec2(true,true)); + tmpLabel->propertyExpand.set(bvec2(true,false)); + tmpLabel->propertyFill.set(bvec2(true,true)); myButton->setSubWidget(tmpLabel); } } diff --git a/ewol/widget/PopUp.cpp b/ewol/widget/PopUp.cpp index 7537106f..d0dfcb45 100644 --- a/ewol/widget/PopUp.cpp +++ b/ewol/widget/PopUp.cpp @@ -18,9 +18,9 @@ static const char* annimationIncrease = "increase"; ewol::widget::PopUp::PopUp() : - m_shaper(*this, "shaper", "The shaper properties"), - m_lockExpand(*this, "lock", bvec2(true,true), "Lock expand contamination"), - m_closeOutEvent(*this, "out-click-remove", false, "Remove the widget if the use click outside") { + propertyShape(*this, "shaper", "", "The shaper properties"), + propertyLockExpand(*this, "lock", bvec2(true,true), "Lock expand contamination"), + propertyCloseOutEvent(*this, "out-click-remove", false, "Remove the widget if the use click outside") { addObjectType("ewol::widget::PopUp"); // Add annimations : addAnnimationType(ewol::Widget::annimationModeEnableAdd, annimationIncrease); @@ -28,37 +28,31 @@ ewol::widget::PopUp::PopUp() : void ewol::widget::PopUp::init(const std::string& _shaperName) { ewol::widget::Container::init(); - m_userFill.set(bvec2(false,false)); - m_shaper.setString(_shaperName); - setMinSize(gale::Dimension(vec2(80,80),gale::Dimension::Pourcent)); - m_userExpand.set(bvec2(false, false)); + propertyFill.set(bvec2(false,false)); + propertyShape.set(_shaperName); + propertyMinSize.set(gale::Dimension(vec2(80,80),gale::Dimension::Pourcent)); + propertyExpand.set(bvec2(false, false)); } ewol::widget::PopUp::~PopUp() { } - -void ewol::widget::PopUp::setShaperName(const std::string& _shaperName) { - m_shaper.setString(_shaperName); - markToRedraw(); -} - void ewol::widget::PopUp::onChangeSize() { markToRedraw(); - if (nullptr == m_subWidget) { + if (m_subWidget == nullptr) { return; } - ewol::Padding padding = m_shaper->getPadding(); + ewol::Padding padding = m_shaper.getPadding(); vec2 subWidgetSize = m_subWidget->getCalculateMinSize(); if (true == m_subWidget->canExpand().x()) { - if (m_lockExpand->x() == true) { + if (propertyLockExpand->x() == true) { subWidgetSize.setX(m_minSize.x()); } else { subWidgetSize.setX(m_size.x()-padding.xLeft()); } } if (true == m_subWidget->canExpand().y()) { - if (m_lockExpand->y() == true) { + if (propertyLockExpand->y() == true) { subWidgetSize.setY(m_minSize.y()); } else { subWidgetSize.setY(m_size.y()-padding.yButtom()); @@ -79,58 +73,58 @@ void ewol::widget::PopUp::onChangeSize() { } void ewol::widget::PopUp::systemDraw(const ewol::DrawProperty& _displayProp) { - if (true == m_hide){ + if (propertyHide == true){ // widget is hidden ... return; } ewol::Widget::systemDraw(_displayProp); - if (nullptr!=m_subWidget) { - if( m_shaper->getNextDisplayedStatus() == -1 - && m_shaper->getTransitionStatus() >= 1.0) { - ewol::DrawProperty prop = _displayProp; - prop.limit(m_origin, m_size); - m_subWidget->systemDraw(prop); - } + if (m_subWidget == nullptr) { + return; + } + if( m_shaper.getNextDisplayedStatus() == -1 + && m_shaper.getTransitionStatus() >= 1.0) { + ewol::DrawProperty prop = _displayProp; + prop.limit(m_origin, m_size); + m_subWidget->systemDraw(prop); } } void ewol::widget::PopUp::onDraw() { - m_shaper->draw(); + m_shaper.draw(); } void ewol::widget::PopUp::onRegenerateDisplay() { - if (true == needRedraw()) { - m_shaper->clear(); - ewol::Padding padding = m_shaper->getPadding(); + if (needRedraw() == true) { + m_shaper.clear(); + ewol::Padding padding = m_shaper.getPadding(); vec2 tmpSize(0,0); bvec2 expand = canExpand(); bvec2 fill = canFill(); - if (fill.x()) { + if (fill.x() == true) { tmpSize.setX(m_size.x()-padding.x()); } - if (fill.y()) { + if (fill.y() == true) { tmpSize.setY(m_size.y()-padding.y()); } - if (nullptr != m_subWidget) { + if (m_subWidget != nullptr) { vec2 tmpSize = m_subWidget->getSize(); } tmpSize.setMax(m_minSize); vec2 tmpOrigin = (m_size-tmpSize)/2.0f; - - m_shaper->setShape(vec2(0,0), - vec2ClipInt32(m_size), - vec2ClipInt32(tmpOrigin-vec2(padding.xLeft(), padding.yButtom())), - vec2ClipInt32(tmpSize + vec2(padding.x(), padding.y()))); + m_shaper.setShape(vec2(0,0), + vec2ClipInt32(m_size), + vec2ClipInt32(tmpOrigin-vec2(padding.xLeft(), padding.yButtom())), + vec2ClipInt32(tmpSize + vec2(padding.x(), padding.y()))); } // SUBwIDGET GENERATION ... - if (nullptr != m_subWidget) { + if (m_subWidget != nullptr) { m_subWidget->onRegenerateDisplay(); } } std::shared_ptr ewol::widget::PopUp::getWidgetAtPos(const vec2& _pos) { std::shared_ptr val = ewol::widget::Container::getWidgetAtPos(_pos); - if (nullptr != val) { + if (val != nullptr) { return val; } return std::dynamic_pointer_cast(shared_from_this()); @@ -138,46 +132,49 @@ std::shared_ptr ewol::widget::PopUp::getWidgetAtPos(const vec2& _p void ewol::widget::PopUp::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::widget::Container::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_shaper) { + if (_paramPointer == propertyShape) { + m_shaper.setSource(propertyShape); markToRedraw(); requestUpdateSize(); - } else if (_paramPointer == m_lockExpand) { + } else if (_paramPointer == propertyLockExpand) { markToRedraw(); requestUpdateSize(); - } else if (_paramPointer == m_closeOutEvent) { + } else if (_paramPointer == propertyCloseOutEvent) { // nothing to do ... } } bool ewol::widget::PopUp::onEventInput(const ewol::event::Input& _event) { - if (0 != _event.getId()) { - if (true == m_closeOutEvent) { - ewol::Padding padding = m_shaper->getPadding(); - vec2 tmpSize(0,0); - if (nullptr != m_subWidget) { - vec2 tmpSize = m_subWidget->getSize(); - } - tmpSize.setMax(m_minSize); - vec2 tmpOrigin = (m_size-tmpSize)/2.0f; - - tmpOrigin -= vec2(padding.xLeft(), padding.yButtom()); - tmpSize += vec2(padding.x(), padding.y()); - vec2 pos = relativePosition(_event.getPos()); - if( pos.x() < tmpOrigin.x() - || pos.y() < tmpOrigin.y() - || pos.x() > tmpOrigin.x()+tmpSize.x() - || pos.y() > tmpOrigin.y()+tmpSize.y() ) { - autoDestroy(); - return true; - } - } + if (_event.getId() == 0) { + return false; + } + if (propertyCloseOutEvent == true) { + return false; + } + ewol::Padding padding = m_shaper.getPadding(); + vec2 tmpSize(0,0); + if (m_subWidget != nullptr) { + vec2 tmpSize = m_subWidget->getSize(); + } + tmpSize.setMax(m_minSize); + vec2 tmpOrigin = (m_size-tmpSize)/2.0f; + + tmpOrigin -= vec2(padding.xLeft(), padding.yButtom()); + tmpSize += vec2(padding.x(), padding.y()); + vec2 pos = relativePosition(_event.getPos()); + if( pos.x() < tmpOrigin.x() + || pos.y() < tmpOrigin.y() + || pos.x() > tmpOrigin.x()+tmpSize.x() + || pos.y() > tmpOrigin.y()+tmpSize.y() ) { + autoDestroy(); + return true; } return false; } bool ewol::widget::PopUp::onStartAnnimation(enum ewol::Widget::annimationMode _mode) { - if (_mode==0) { + if (_mode == 0) { /* if (m_annimationTypeStart.get() != annimationIncrease) { return false; @@ -191,7 +188,7 @@ bool ewol::widget::PopUp::onStartAnnimation(enum ewol::Widget::annimationMode _m */ } return false; - if (true == m_shaper->changeStatusIn(1) ) { + if (m_shaper.changeStatusIn(1) == true) { periodicCallEnable(); return true; } @@ -203,7 +200,7 @@ void ewol::widget::PopUp::onStopAnnimation() { } void ewol::widget::PopUp::periodicCall(const ewol::event::Time& _event) { - if (false == m_shaper->periodicCall(_event) ) { + if (m_shaper.periodicCall(_event) == false) { stopAnnimation(); } markToRedraw(); diff --git a/ewol/widget/PopUp.h b/ewol/widget/PopUp.h index 6c959d84..2ee3b6e8 100644 --- a/ewol/widget/PopUp.h +++ b/ewol/widget/PopUp.h @@ -21,8 +21,10 @@ namespace ewol { * @ingroup ewolWidgetGroup */ class PopUp : public ewol::widget::Container { - protected: - eproperty::Value m_shaper; //!< Compositing theme. + public: // properties + eproperty::Value propertyShape; //!< Compositing theme. + eproperty::Value propertyLockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget + eproperty::Value propertyCloseOutEvent; //!< ratio progression of a sliding protected: /** * @brief Constructor @@ -36,38 +38,8 @@ namespace ewol { * @brief Destructor */ virtual ~PopUp(); - /** - * @brief set the shaper name (use the contructer one this permit to not noad unused shaper) - * @param[in] _shaperName The new shaper filename - */ - void setShaperName(const std::string& _shaperName); protected: - eproperty::Value m_lockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget - public: - /** - * @brief Limit the expend properties to the current widget (no contamination) - * @param[in] _lockExpend Lock mode of the expend properties - */ - void lockExpand(const bvec2& _lockExpand) { - m_lockExpand.set(_lockExpand); - } - private: - eproperty::Value m_closeOutEvent; //!< ratio progression of a sliding - public: - /** - * @brief Request the Auto-remove when the event input is set outside the widget - * @param[in] _state New status - */ - void setRemoveOnExternClick(bool _state) { - m_closeOutEvent.set(_state); - }; - /** - * @brief get the status of the request the Auto-remove when the event input is set outside the widget. - * @return the status of the removing - */ - bool getRemoveOnExternClick() const { - return m_closeOutEvent; - }; + ewol::compositing::Shaper m_shaper; //!< Compositing theme. protected: // Derived function virtual void onDraw(); virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); diff --git a/ewol/widget/ProgressBar.cpp b/ewol/widget/ProgressBar.cpp index 86a4d320..d3502b5b 100644 --- a/ewol/widget/ProgressBar.cpp +++ b/ewol/widget/ProgressBar.cpp @@ -17,16 +17,16 @@ const int32_t dotRadius = 6; ewol::widget::ProgressBar::ProgressBar() : - m_value(*this, "value", 0.0f, "Value of the progress bar"), - m_textColorFg(*this, "color-bg", etk::color::black, "Background color"), - m_textColorBgOn(*this, "color-on", etk::Color<>(0x00, 0xFF, 0x00, 0xFF), "Color of the true value"), - m_textColorBgOff(*this, "color-off", etk::color::none, "Color of the false value") { + propertyValue(*this, "value", 0.0f, 0.0f, 1.0f, "Value of the progress bar"), + propertyTextColorFg(*this, "color-bg", etk::color::black, "Background color"), + propertyTextColorBgOn(*this, "color-on", etk::Color<>(0x00, 0xFF, 0x00, 0xFF), "Color of the true value"), + PropertyTextColorBgOff(*this, "color-off", etk::color::none, "Color of the false value") { addObjectType("ewol::widget::ProgressBar"); - setCanHaveFocus(true); } void ewol::widget::ProgressBar::init() { ewol::Widget::init(); + propertyCanFocus.set(true); } ewol::widget::ProgressBar::~ProgressBar() { @@ -34,54 +34,50 @@ ewol::widget::ProgressBar::~ProgressBar() { } void ewol::widget::ProgressBar::calculateMinMaxSize() { - vec2 tmpMin = m_userMinSize->getPixel(); + vec2 tmpMin = propertyMinSize->getPixel(); m_minSize.setValue( std::max(tmpMin.x(), 40.0f), std::max(tmpMin.y(), dotRadius*2.0f) ); markToRedraw(); } -void ewol::widget::ProgressBar::setValue(float _val) { - m_value = std::avg(0.0f, _val, 1.0f); - markToRedraw(); -} - void ewol::widget::ProgressBar::onDraw() { m_draw.draw(); } void ewol::widget::ProgressBar::onRegenerateDisplay() { - if (true == needRedraw()) { - // clean the object list ... - m_draw.clear(); - - m_draw.setColor(m_textColorFg); - - int32_t tmpSizeX = m_size.x() - 10; - int32_t tmpSizeY = m_size.y() - 10; - int32_t tmpOriginX = 5; - int32_t tmpOriginY = 5; - m_draw.setColor(m_textColorBgOn); - m_draw.setPos(vec3(tmpOriginX, tmpOriginY, 0) ); - m_draw.rectangleWidth(vec3(tmpSizeX*m_value, tmpSizeY, 0) ); - m_draw.setColor(m_textColorBgOff); - m_draw.setPos(vec3(tmpOriginX+tmpSizeX*m_value, tmpOriginY, 0) ); - m_draw.rectangleWidth(vec3(tmpSizeX*(1.0-m_value), tmpSizeY, 0) ); - - // TODO : Create a better progress Bar ... - //m_draw.setColor(m_textColorFg); - //m_draw.rectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, 1); + if (needRedraw() == false) { + return; } + // clean the object list ... + m_draw.clear(); + + m_draw.setColor(propertyTextColorFg); + + int32_t tmpSizeX = m_size.x() - 10; + int32_t tmpSizeY = m_size.y() - 10; + int32_t tmpOriginX = 5; + int32_t tmpOriginY = 5; + m_draw.setColor(propertyTextColorBgOn); + m_draw.setPos(vec3(tmpOriginX, tmpOriginY, 0) ); + m_draw.rectangleWidth(vec3(tmpSizeX*propertyValue, tmpSizeY, 0) ); + m_draw.setColor(PropertyTextColorBgOff); + m_draw.setPos(vec3(tmpOriginX+tmpSizeX*propertyValue, tmpOriginY, 0) ); + m_draw.rectangleWidth(vec3(tmpSizeX*(1.0-propertyValue), tmpSizeY, 0) ); + + // TODO : Create a better progress Bar ... + //m_draw.setColor(propertyTextColorFg); + //m_draw.rectangleBorder( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY, 1); } void ewol::widget::ProgressBar::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::Widget::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_value) { + if (_paramPointer == propertyValue) { markToRedraw(); - } else if (_paramPointer == m_textColorFg) { + } else if (_paramPointer == propertyTextColorFg) { markToRedraw(); - } else if (_paramPointer == m_textColorBgOn) { + } else if (_paramPointer == propertyTextColorBgOn) { markToRedraw(); - } else if (_paramPointer == m_textColorBgOff) { + } else if (_paramPointer == PropertyTextColorBgOff) { markToRedraw(); } } diff --git a/ewol/widget/ProgressBar.h b/ewol/widget/ProgressBar.h index 91c5f7f5..d1adec20 100644 --- a/ewol/widget/ProgressBar.h +++ b/ewol/widget/ProgressBar.h @@ -20,26 +20,19 @@ namespace ewol { * @ingroup ewolWidgetGroup */ class ProgressBar : public ewol::Widget { - private: - ewol::compositing::Drawing m_draw; // basic drawing element + public: // properties + eproperty::Range propertyValue; //!< % used + eproperty::Value> propertyTextColorFg; //!< forder bar color + eproperty::Value> propertyTextColorBgOn; //!< bar color enable + eproperty::Value> PropertyTextColorBgOff; //!< bar color disable protected: ProgressBar(); void init(); public: DECLARE_WIDGET_FACTORY(ProgressBar, "ProgressBar"); virtual ~ProgressBar(); - void setValue(float _val); - float getValue() const { - return m_value; - }; - void setColor(etk::Color<> _newColor) { - m_textColorFg = _newColor; - }; private: - eproperty::Value m_value; //!< % used - eproperty::Value> m_textColorFg; //!< forder bar color - eproperty::Value> m_textColorBgOn; //!< bar color enable - eproperty::Value> m_textColorBgOff; //!< bar color disable + ewol::compositing::Drawing m_draw; // basic drawing element protected: // Derived function virtual void onDraw(); virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); diff --git a/ewol/widget/Scroll.cpp b/ewol/widget/Scroll.cpp index 8e7f8313..abf55ed6 100644 --- a/ewol/widget/Scroll.cpp +++ b/ewol/widget/Scroll.cpp @@ -15,7 +15,9 @@ #define __class__ "Scroll" ewol::widget::Scroll::Scroll() : - m_limit(*this, "limit", vec2(0.15,0.5), vec2(0.0,0.0), vec2(1.0,1.0), "Limit the scroll maximum position [0..1]% represent the free space in the scoll when arrive at the end"), + propertyLimit(*this, "limit", vec2(0.15,0.5), vec2(0.0,0.0), vec2(1.0,1.0), "Limit the scroll maximum position [0..1]% represent the free space in the scoll when arrive at the end"), + propertyShapeVert(*this, "shape-vert", "", "shape for the vertical display"), + propertyShapeHori(*this, "shape-hori", "", "shape for the horizonal display"), m_pixelScrolling(20), m_highSpeedStartPos(0,0), m_highSpeedMode(speedModeDisable), @@ -26,8 +28,8 @@ ewol::widget::Scroll::Scroll() : void ewol::widget::Scroll::init(const std::string& _shaperName) { ewol::widget::Container::init(); - m_shaperH.setSource(_shaperName); - m_shaperV.setSource(_shaperName); + propertyShapeVert.set(_shaperName); + propertyShapeHori.set(_shaperName); } @@ -35,27 +37,22 @@ ewol::widget::Scroll::~Scroll() { } -void ewol::widget::Scroll::setLimit(const vec2& _limit) { - m_limit.set(_limit); - markToRedraw(); -} - #define SCROLL_BAR_SPACE (15) void ewol::widget::Scroll::calculateMinMaxSize() { // call main class !! and not containter class ... ewol::Widget::calculateMinMaxSize(); // call sub classes - if (nullptr!=m_subWidget) { + if (m_subWidget != nullptr) { m_subWidget->calculateMinMaxSize(); } } void ewol::widget::Scroll::systemDraw(const ewol::DrawProperty& _displayProp) { - if (m_hide == true) { + if (propertyHide == true) { return; } - if (nullptr!=m_subWidget) { + if (m_subWidget != nullptr) { ewol::DrawProperty prop = _displayProp; prop.limit(m_origin, m_size); m_subWidget->systemDraw(prop); @@ -89,7 +86,7 @@ void ewol::widget::Scroll::onRegenerateDisplay() { || scrollOffset.y()!=0) { float lenScrollBar = m_size.y()*m_size.y() / scrollSize.y(); lenScrollBar = std::avg(10.0f, lenScrollBar, m_size.y()); - float originScrollBar = scrollOffset.y() / (scrollSize.y()-m_size.y()*m_limit->y()); + float originScrollBar = scrollOffset.y() / (scrollSize.y()-m_size.y()*propertyLimit->y()); originScrollBar = std::avg(0.0f, originScrollBar, 1.0f); originScrollBar *= (m_size.y()-lenScrollBar); m_shaperV.setShape(vec2(m_size.x() - paddingVert.x(), 0), @@ -101,7 +98,7 @@ void ewol::widget::Scroll::onRegenerateDisplay() { || scrollOffset.x()!=0) { float lenScrollBar = (m_size.x()-paddingHori.xLeft())*(m_size.x()-paddingVert.x()) / scrollSize.x(); lenScrollBar = std::avg(10.0f, lenScrollBar, (m_size.x()-paddingVert.x())); - float originScrollBar = scrollOffset.x() / (scrollSize.x()-m_size.x()*m_limit->x()); + float originScrollBar = scrollOffset.x() / (scrollSize.x()-m_size.x()*propertyLimit->x()); originScrollBar = std::avg(0.0f, originScrollBar, 1.0f); originScrollBar *= (m_size.x()-paddingHori.xRight()-lenScrollBar); m_shaperH.setShape(vec2(0, 0), @@ -139,7 +136,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { m_highSpeedButton = 1; // force direct scrolling in this case scrollOffset.setY((int32_t)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (m_size.y()-SCROLL_BAR_SPACE*2))); - scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit->y()))); + scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*propertyLimit->y()))); markToRedraw(); if (nullptr!=m_subWidget) { m_subWidget->setOffset(scrollOffset); @@ -156,7 +153,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { m_highSpeedButton = 1; // force direct scrolling in this case scrollOffset.setX((int32_t)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (m_size.x()-SCROLL_BAR_SPACE*2))); - scrollOffset.setY(std::avg(0.0f, scrollOffset.x(), (scrollSize.x() - m_size.x()*m_limit->x()))); + scrollOffset.setY(std::avg(0.0f, scrollOffset.x(), (scrollSize.x() - m_size.x()*propertyLimit->x()))); markToRedraw(); if (nullptr!=m_subWidget) { m_subWidget->setOffset(scrollOffset); @@ -169,7 +166,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { && _event.getStatus() == gale::key::status_up) { if(m_size.y() < scrollSize.y()) { scrollOffset.setY(scrollOffset.y()-m_pixelScrolling); - scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit->y()))); + scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*propertyLimit->y()))); markToRedraw(); if (nullptr!=m_subWidget) { m_subWidget->setOffset(scrollOffset); @@ -180,7 +177,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { && _event.getStatus() == gale::key::status_up) { if(m_size.y() < scrollSize.y()) { scrollOffset.setY(scrollOffset.y()+m_pixelScrolling); - scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit->y()))); + scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*propertyLimit->y()))); markToRedraw(); if (nullptr!=m_subWidget) { m_subWidget->setOffset(scrollOffset); @@ -227,8 +224,8 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { } else if( m_highSpeedMode == speedModeInit && _event.getStatus() == gale::key::status_move) { // wait that the cursor move more than 10 px to enable it : - if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 - || abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { + if( std::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 + || std::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { // the scrooling can start : // select the direction : if (relativePos.x() == m_highSpeedStartPos.x()) { @@ -237,7 +234,7 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { m_highSpeedMode = speedModeEnableHorizontal; } else { float coef = (relativePos.y() - m_highSpeedStartPos.y()) / (relativePos.x() - m_highSpeedStartPos.x()); - if (abs(coef) <= 1 ) { + if (std::abs(coef) <= 1 ) { m_highSpeedMode = speedModeEnableHorizontal; } else { m_highSpeedMode = speedModeEnableVertical; @@ -250,8 +247,8 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { } markToRedraw(); } - scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit->y()))); - if (nullptr!=m_subWidget) { + scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*propertyLimit->y()))); + if (m_subWidget != nullptr) { m_subWidget->setOffset(scrollOffset); } return true; @@ -259,9 +256,9 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { if( m_highSpeedMode == speedModeEnableHorizontal && _event.getStatus() == gale::key::status_move) { scrollOffset.setX((int32_t)(scrollSize.x() * (relativePos.x()-SCROLL_BAR_SPACE) / (m_size.x()-SCROLL_BAR_SPACE*2))); - scrollOffset.setX(std::avg(0.0f, scrollOffset.x(), (scrollSize.x() - m_size.x()*m_limit->x() ))); + scrollOffset.setX(std::avg(0.0f, scrollOffset.x(), (scrollSize.x() - m_size.x()*propertyLimit->x() ))); markToRedraw(); - if (nullptr!=m_subWidget) { + if (m_subWidget != nullptr) { m_subWidget->setOffset(scrollOffset); } return true; @@ -269,9 +266,9 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { if( m_highSpeedMode == speedModeEnableVertical && _event.getStatus() == gale::key::status_move) { scrollOffset.setY((int32_t)(scrollSize.y() * (relativePos.y()-SCROLL_BAR_SPACE) / (m_size.y()-SCROLL_BAR_SPACE*2))); - scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit->x()))); + scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*propertyLimit->x()))); markToRedraw(); - if (nullptr!=m_subWidget) { + if (m_subWidget != nullptr) { m_subWidget->setOffset(scrollOffset); } return true; @@ -297,8 +294,8 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { } else if ( m_highSpeedMode == speedModeInit && gale::key::status_move == _event.getStatus()) { // wait that the cursor move more than 10 px to enable it : - if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 - || abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { + if( std::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 + || std::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { // the scrooling can start : // select the direction : m_highSpeedMode = speedModeEnableFinger; @@ -311,19 +308,19 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { && gale::key::status_move == _event.getStatus()) { EWOL_VERBOSE("SCROOL == > INIT scrollOffset=" << scrollOffset.y() << " relativePos=" << relativePos.y() << " m_highSpeedStartPos=" << m_highSpeedStartPos.y()); //scrollOffset.x = (int32_t)(scrollSize.x * x / m_size.x); - if (m_limit->x() != 0.0f) { + if (propertyLimit->x() != 0.0f) { scrollOffset.setX(scrollOffset.x() + (relativePos.x() - m_highSpeedStartPos.x())); - scrollOffset.setX(std::avg(0.0f, scrollOffset.x(), (scrollSize.x() - m_size.x()*m_limit->x()))); + scrollOffset.setX(std::avg(0.0f, scrollOffset.x(), (scrollSize.x() - m_size.x()*propertyLimit->x()))); } - if (m_limit->y() != 0.0f) { + if (propertyLimit->y() != 0.0f) { scrollOffset.setY(scrollOffset.y() - (relativePos.y() - m_highSpeedStartPos.y())); - scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*m_limit->y()))); + scrollOffset.setY(std::avg(0.0f, scrollOffset.y(), (scrollSize.y() - m_size.y()*propertyLimit->y()))); } // update current position: m_highSpeedStartPos = relativePos; EWOL_VERBOSE("SCROOL == > MOVE " << scrollOffset); markToRedraw(); - if (nullptr!=m_subWidget) { + if (m_subWidget != nullptr) { m_subWidget->setOffset(scrollOffset); } return true; @@ -345,15 +342,21 @@ bool ewol::widget::Scroll::onEventInput(const ewol::event::Input& _event) { std::shared_ptr ewol::widget::Scroll::getWidgetAtPos(const vec2& _pos) { std::shared_ptr tmpWidget = ewol::widget::Container::getWidgetAtPos(_pos); - if (nullptr != tmpWidget) { + if (tmpWidget != nullptr) { return tmpWidget; } return std::dynamic_pointer_cast(shared_from_this());; } void ewol::widget::Scroll::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::widget::Container::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_limit) { - + if (_paramPointer == propertyLimit) { + markToRedraw(); + } else if (_paramPointer == propertyShapeVert) { + m_shaperV.setSource(propertyShapeVert); + markToRedraw(); + } else if (_paramPointer == propertyShapeHori) { + m_shaperH.setSource(propertyShapeHori); + markToRedraw(); } } diff --git a/ewol/widget/Scroll.h b/ewol/widget/Scroll.h index d95e32f4..90695cea 100644 --- a/ewol/widget/Scroll.h +++ b/ewol/widget/Scroll.h @@ -17,6 +17,10 @@ namespace ewol { namespace widget { class Scroll : public ewol::widget::Container { + public: // properties + eproperty::Range propertyLimit; //!< Set the limitation of the ratio in the sreen + eproperty::Value propertyShapeVert; //!< Vertical shaper name + eproperty::Value propertyShapeHori; //!< Horizontal shaper name public: enum highSpeedMode { speedModeDisable, @@ -29,8 +33,6 @@ namespace ewol { private: ewol::compositing::Shaper m_shaperH; //!< Compositing theme Horizontal. ewol::compositing::Shaper m_shaperV; //!< Compositing theme Vertical. - protected: - eproperty::Range m_limit; private: float m_pixelScrolling; vec2 m_highSpeedStartPos; @@ -43,20 +45,6 @@ namespace ewol { public: DECLARE_WIDGET_FACTORY(Scroll, "Scroll"); virtual ~Scroll(); - /** - * @brief set the limit of scrolling - * @note This permit to scoll element upper the end of the display - * @param[in] _limit scrolling limit [0..1] (represent a pourcent) - */ - void setLimit(const vec2& _limit); - /** - * @brief get the limit of scrolling - * @return scrolling limit - */ - const vec2& getLimit() const { - return m_limit; - }; - public: // Derived function void calculateMinMaxSize(); virtual void onRegenerateDisplay(); diff --git a/ewol/widget/Select.cpp b/ewol/widget/Select.cpp index fed43f91..21c7fb8e 100644 --- a/ewol/widget/Select.cpp +++ b/ewol/widget/Select.cpp @@ -29,7 +29,7 @@ ewol::widget::Select::Element::Element(int32_t _value, std::string _name, bool _ ewol::widget::Select::Select() : signalValue(*this, "value", "Select value change"), - m_value(*this, "value", -1, "Value of the Select") { + propertyValue(*this, "value", -1, "Value of the Select") { addObjectType("ewol::widget::Select"); } @@ -46,18 +46,18 @@ ewol::widget::Select::~Select() { void ewol::widget::Select::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::widget::SpinBase::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_value) { + if (_paramPointer == propertyValue) { markToRedraw(); if (m_widgetEntry == nullptr) { EWOL_ERROR("Can not acces at entry ..."); return; } for (auto &it : m_listElement) { - if (it.m_value == m_value.get()) { + if (it.m_value == propertyValue.get()) { if (it.m_selected == false) { it.m_selected = true; - m_widgetEntry->setValue(it.m_name); - signalValue.emit(m_value.get()); + m_widgetEntry->propertyValue.set(it.m_name); + signalValue.emit(propertyValue.get()); } } else { it.m_selected = false; @@ -77,9 +77,9 @@ void ewol::widget::Select::optionSelectDefault() { } } if (m_listElement.size() == 0) { - m_widgetEntry->setValue(""); + m_widgetEntry->propertyValue.set(""); } - m_widgetEntry->setValue(m_listElement[0].m_name); + m_widgetEntry->propertyValue.set(m_listElement[0].m_name); } void ewol::widget::Select::optionRemove(int32_t _value) { @@ -134,7 +134,7 @@ bool ewol::widget::Select::loadXML(const std::shared_ptr& _ int32_t select = etk::string_to_bool(valIsSelected); optionAdd(id, valText); if (select == true) { - setValue(id); + propertyValue.set(id); } EWOL_WARNING("Add option : id='" << valId << "' select='" << valIsSelected << "' text='" << valText << "'"); @@ -158,7 +158,7 @@ void ewol::widget::Select::updateGui() { void ewol::widget::Select::onCallbackLabelPressed(int32_t _value) { EWOL_VERBOSE("User select:" << _value); - setValue(_value); + propertyValue.set(_value); } void ewol::widget::Select::onCallbackOpenMenu() { @@ -176,8 +176,8 @@ void ewol::widget::Select::onCallbackOpenMenu() { EWOL_ERROR("Allocation Error or sizer"); return; } - mySizer->lockExpand(vec2(true,true)); - mySizer->setFill(vec2(true,true)); + mySizer->propertyLockExpand.set(vec2(true,true)); + mySizer->propertyFill.set(vec2(true,true)); // set it in the pop-up-system: tmpContext->setSubWidget(mySizer); for (auto &it : m_listElement) { @@ -191,8 +191,8 @@ void ewol::widget::Select::onCallbackOpenMenu() { EWOL_ERROR("Allocation Error"); continue; } - myLabel->setExpand(bvec2(true,true)); - myLabel->setFill(bvec2(true,true)); + myLabel->propertyExpand.set(bvec2(true,true)); + myLabel->propertyFill.set(bvec2(true,true)); // set callback myLabel->signalPressed.bind(shared_from_this(), &ewol::widget::Select::onCallbackLabelPressed, it.m_value); myLabel->signalPressed.bind(tmpContext, &ewol::widget::ContextMenu::destroy); @@ -207,10 +207,3 @@ void ewol::widget::Select::onCallbackOpenMenu() { } } - -void ewol::widget::Select::setValue(int32_t _val) { - m_value.set(_val); -} -int32_t ewol::widget::Select::getValue() const { - return m_value.get(); -}; \ No newline at end of file diff --git a/ewol/widget/Select.h b/ewol/widget/Select.h index 20f3f761..d501c935 100644 --- a/ewol/widget/Select.h +++ b/ewol/widget/Select.h @@ -18,9 +18,10 @@ namespace ewol { * ==> this permit to generate standard element simple */ class Select : public ewol::widget::SpinBase { - public: - // Event list of properties + public: // signals esignal::Signal signalValue; + public: // properties + eproperty::Value propertyValue; //!< Current state of the Select. protected: /** * @brief Constructor @@ -34,13 +35,6 @@ namespace ewol { * @brief Destructor */ virtual ~Select(); - /** - * @brief set the shaper name (use the contructer one this permit to not noad unused shaper) - * @param[in] _shaperName The new shaper filename - */ - void setShaperName(const std::string& _shaperName) { - //m_shaper.setString(_shaperName); - } protected: class Element { public: @@ -56,21 +50,6 @@ namespace ewol { void optionRemove(int32_t _value); void optionClear(); void optionAdd(int32_t _value, std::string _name); - protected: - eproperty::Value m_value; //!< Current state of the Select. - public: - /** - * @brief set the currentValue of the Select (pressed or not) - * @note Work only in toggle mode - * @param[in] _val New value of the Select - */ - void setValue(int32_t _val); - /** - * @brief get the current Select value. - * @return True : The Select is pressed. - * @return false : The Select is released. - */ - int32_t getValue() const; protected: virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); virtual bool loadXML(const std::shared_ptr& _node); diff --git a/ewol/widget/Sizer.cpp b/ewol/widget/Sizer.cpp index dfd03cc4..3755ad28 100644 --- a/ewol/widget/Sizer.cpp +++ b/ewol/widget/Sizer.cpp @@ -14,32 +14,34 @@ #define __class__ "Sizer" ewol::widget::Sizer::Sizer() : - m_mode(*this, "mode", modeHori, "The display mode"), - m_borderSize(*this, "border", vec2(0,0), "The sizer border size"), - m_animation(animationNone), - m_animationTime(0) { + propertyMode(*this, "mode", modeHori, "The display mode"), + propertyBorderSize(*this, "border", vec2(0,0), "The sizer border size"), + propertyAnimation(*this, "annimation", animationNone, "sizer annimation"), + propertyAnimationTime(*this, "annimation-time", 0, "time of the anniation") { addObjectType("ewol::widget::Sizer"); - m_mode.add(modeHori, "hori"); - m_mode.add(modeVert, "vert"); + propertyMode.add(modeHori, "hori"); + propertyMode.add(modeVert, "vert"); + propertyAnimation.add(animationNone, "none"); + propertyAnimation.add(animationTop, "top"); + propertyAnimation.add(animationbuttom, "buttom"); + propertyAnimation.add(animationLeft, "left"); + propertyAnimation.add(animationRight, "right"); } void ewol::widget::Sizer::init(enum displayMode _mode) { ewol::widget::ContainerN::init(); - m_mode.set(_mode); + propertyMode.set(_mode); } ewol::widget::Sizer::~Sizer() { - // disable annimation to remore "remove" error - m_animation = animationNone; - m_animationTime = 0; - //EWOL_DEBUG("[" << getId() << "]={" << getObjectType() << "} sizer : destroy (mode=" << (m_mode == ewol::widget::Sizer::modeVert?"Vert":"Hori") << ")"); + //EWOL_DEBUG("[" << getId() << "]={" << getObjectType() << "} sizer : destroy (mode=" << (propertyMode == ewol::widget::Sizer::modeVert?"Vert":"Hori") << ")"); } void ewol::widget::Sizer::onChangeSize() { ewol::Widget::onChangeSize(); - vec2 tmpBorderSize = m_borderSize->getPixel(); - EWOL_VERBOSE("[" << getId() << "] update size : " << m_size << " nbElement : " << m_subWidget.size() << " borderSize=" << tmpBorderSize << " from border=" << m_borderSize); + vec2 tmpBorderSize = propertyBorderSize->getPixel(); + EWOL_VERBOSE("[" << getId() << "] update size : " << m_size << " nbElement : " << m_subWidget.size() << " borderSize=" << tmpBorderSize << " from border=" << propertyBorderSize); vec2 localWidgetSize = m_size - tmpBorderSize*2.0f; // -1- calculate min-size and expand requested: vec2 minSize(0.0f, 0.0f); @@ -49,7 +51,7 @@ void ewol::widget::Sizer::onChangeSize() { continue; } vec2 tmpSize = it->getCalculateMinSize(); - if (m_mode == ewol::widget::Sizer::modeVert) { + if (propertyMode == ewol::widget::Sizer::modeVert) { minSize = vec2(std::max(minSize.x(), tmpSize.x()), minSize.y() + tmpSize.y()); } else { @@ -63,7 +65,7 @@ void ewol::widget::Sizer::onChangeSize() { // -2- Calculate the size to add at every elements... float deltaExpandSize = 0.0f; if (nbWidgetExpand != ivec2(0,0)) { - if (m_mode == ewol::widget::Sizer::modeVert) { + if (propertyMode == ewol::widget::Sizer::modeVert) { deltaExpandSize = (localWidgetSize.y() - minSize.y()) / float(nbWidgetExpand.y()); } else { deltaExpandSize = (localWidgetSize.x() - minSize.x()) / float(nbWidgetExpand.x()); @@ -84,7 +86,7 @@ void ewol::widget::Sizer::onChangeSize() { float residualNext = 0.0f; // get the number of element that need to devide... int32_t countCalculation = nbWidgetExpand.x(); - if (m_mode == ewol::widget::Sizer::modeVert) { + if (propertyMode == ewol::widget::Sizer::modeVert) { countCalculation = nbWidgetExpand.y(); } // -4.1- Update every subWidget size @@ -95,7 +97,7 @@ void ewol::widget::Sizer::onChangeSize() { vec2 tmpSizeMin = it->getSize(); vec2 tmpSizeMax = it->getCalculateMaxSize(); // Now update his size his size in X and the curent sizer size in Y: - if (m_mode == ewol::widget::Sizer::modeVert) { + if (propertyMode == ewol::widget::Sizer::modeVert) { if (it->canExpand().y() == true) { float sizeExpand = tmpSizeMin.y() + deltaExpandSize; if (sizeExpand > tmpSizeMax.y()) { @@ -127,7 +129,7 @@ void ewol::widget::Sizer::onChangeSize() { if (countCalculation <= 0) { break; } - if (m_mode == ewol::widget::Sizer::modeVert) { + if (propertyMode == ewol::widget::Sizer::modeVert) { deltaExpandSize = residualNext / float(countCalculation); } else { deltaExpandSize = residualNext / float(countCalculation); @@ -143,7 +145,7 @@ void ewol::widget::Sizer::onChangeSize() { continue; } // Now update his size his size in X and the curent sizer size in Y: - if (m_mode == ewol::widget::Sizer::modeVert) { + if (propertyMode == ewol::widget::Sizer::modeVert) { if (it->canExpand().x() == false) { continue; } @@ -173,7 +175,7 @@ void ewol::widget::Sizer::onChangeSize() { continue; } vec2 size = it->getSize(); - if (m_mode == ewol::widget::Sizer::modeVert) { + if (propertyMode == ewol::widget::Sizer::modeVert) { underSize += vec2(0.0f, size.y()); underSize.setX(std::max(underSize.x(), size.x())); } else { @@ -184,7 +186,7 @@ void ewol::widget::Sizer::onChangeSize() { vec2 deltas = localWidgetSize - underSize; // -8- Calculate the local origin, depending of the gravity: - vec2 tmpOrigin = m_origin + tmpBorderSize + ewol::gravityGenerateDelta(m_gravity, deltas); + vec2 tmpOrigin = m_origin + tmpBorderSize + ewol::gravityGenerateDelta(propertyGravity, deltas); // -9- Set sub widget origin: for (auto &it : m_subWidget) { if (it == nullptr) { @@ -192,13 +194,13 @@ void ewol::widget::Sizer::onChangeSize() { } vec2 origin; vec2 size = it->getSize(); - if (m_mode == ewol::widget::Sizer::modeVert) { - origin = vec2ClipInt32(tmpOrigin+m_offset + ewol::gravityGenerateDelta(m_gravity, vec2(underSize.x()-size.x(),0.0f))); + if (propertyMode == ewol::widget::Sizer::modeVert) { + origin = vec2ClipInt32(tmpOrigin+m_offset + ewol::gravityGenerateDelta(propertyGravity, vec2(underSize.x()-size.x(),0.0f))); } else { - origin = vec2ClipInt32(tmpOrigin+m_offset + ewol::gravityGenerateDelta(m_gravity, vec2(0.0f, underSize.y()-size.y()))); + origin = vec2ClipInt32(tmpOrigin+m_offset + ewol::gravityGenerateDelta(propertyGravity, vec2(0.0f, underSize.y()-size.y()))); } it->setOrigin(origin); - if (m_mode == ewol::widget::Sizer::modeVert) { + if (propertyMode == ewol::widget::Sizer::modeVert) { tmpOrigin.setY(tmpOrigin.y() + size.y()); } else { tmpOrigin.setX(tmpOrigin.x() + size.x()); @@ -217,8 +219,8 @@ void ewol::widget::Sizer::onChangeSize() { void ewol::widget::Sizer::calculateMinMaxSize() { EWOL_VERBOSE("[" << getId() << "] update minimum size"); m_subExpend.setValue(false, false); - m_minSize = m_userMinSize->getPixel(); - vec2 tmpBorderSize = m_borderSize->getPixel(); + m_minSize = propertyMinSize->getPixel(); + vec2 tmpBorderSize = propertyBorderSize->getPixel(); EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} set min size : " << m_minSize); for (auto &it : m_subWidget) { if (it == nullptr) { @@ -234,7 +236,7 @@ void ewol::widget::Sizer::calculateMinMaxSize() { vec2 tmpSize = it->getCalculateMinSize(); EWOL_VERBOSE("[" << getId() << "] NewMinSize=" << tmpSize); EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} Get minSize="<< tmpSize); - if (m_mode == ewol::widget::Sizer::modeVert) { + if (propertyMode == ewol::widget::Sizer::modeVert) { m_minSize.setY(m_minSize.y() + tmpSize.y()); if (tmpSize.x()>m_minSize.x()) { m_minSize.setX(tmpSize.x()); @@ -251,7 +253,7 @@ void ewol::widget::Sizer::calculateMinMaxSize() { } int32_t ewol::widget::Sizer::subWidgetAdd(std::shared_ptr _newWidget) { - if (m_animation == animationNone) { + if (propertyAnimation == animationNone) { return ewol::widget::ContainerN::subWidgetAdd(_newWidget); } // TODO : ... @@ -259,7 +261,7 @@ int32_t ewol::widget::Sizer::subWidgetAdd(std::shared_ptr _newWidg } int32_t ewol::widget::Sizer::subWidgetAddStart(std::shared_ptr _newWidget) { - if (m_animation == animationNone) { + if (propertyAnimation == animationNone) { return ewol::widget::ContainerN::subWidgetAddStart(_newWidget); } // TODO : ... @@ -267,7 +269,7 @@ int32_t ewol::widget::Sizer::subWidgetAddStart(std::shared_ptr _ne } void ewol::widget::Sizer::subWidgetRemove(std::shared_ptr _newWidget) { - if (m_animation == animationNone) { + if (propertyAnimation == animationNone) { ewol::widget::ContainerN::subWidgetRemove(_newWidget); return; } @@ -276,7 +278,7 @@ void ewol::widget::Sizer::subWidgetRemove(std::shared_ptr _newWidg } void ewol::widget::Sizer::subWidgetUnLink(std::shared_ptr _newWidget) { - if (m_animation == animationNone) { + if (propertyAnimation == animationNone) { ewol::widget::ContainerN::subWidgetUnLink(_newWidget); return; } @@ -286,10 +288,10 @@ void ewol::widget::Sizer::subWidgetUnLink(std::shared_ptr _newWidg void ewol::widget::Sizer::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::widget::ContainerN::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_mode) { + if (_paramPointer == propertyMode) { markToRedraw(); requestUpdateSize(); - } else if (_paramPointer == m_borderSize) { + } else if (_paramPointer == propertyBorderSize) { markToRedraw(); requestUpdateSize(); } diff --git a/ewol/widget/Sizer.h b/ewol/widget/Sizer.h index 942af187..d5007046 100644 --- a/ewol/widget/Sizer.h +++ b/ewol/widget/Sizer.h @@ -20,18 +20,29 @@ namespace ewol { * @ingroup ewolWidgetGroup */ class Sizer : public ewol::widget::ContainerN { - public: - /** - * @brief Main call of recording the widget on the List of "widget named creator" - */ - static void init(ewol::widget::Manager& _widgetManager); public: enum displayMode { modeVert, //!< Vertical mode modeHori, //!< Horizontal mode }; - protected: - eproperty::List m_mode; //!< Methode to display the widget list (vert/hory ...) + enum animation { + animationNone, //!< No annimation + animationTop, //!< element came from the top + animationbuttom, //!< element came from the buttom + animationLeft, //!< element came from the Left + animationRight //!< element came from the right + //animationZoom //!< element came from zooming + }; + public: // properties: + eproperty::List propertyMode; //!< Methode to display the widget list (vert/hory ...) + eproperty::Value propertyBorderSize; //!< Border size needed for all the display + eproperty::List propertyAnimation; //!< Methode add and remove element (animation) + eproperty::Value propertyAnimationTime; //!< Time in second to generate animation + public: + /** + * @brief Main call of recording the widget on the List of "widget named creator" + */ + static void init(ewol::widget::Manager& _widgetManager); protected: /** * @brief Constructor @@ -45,80 +56,6 @@ namespace ewol { * @brief Destructor */ virtual ~Sizer(); - /** - * @brief set the mode to display elements. - * @param[in] _mode The mode to display the elements. - */ - void setMode(enum displayMode _mode) { - m_mode.set(_mode); - } - /** - * @brief get the mode to display elements. - * @return The current mode to display the elements. - */ - enum displayMode getMode() const { - return m_mode; - } - protected: - eproperty::Value m_borderSize; //!< Border size needed for all the display - public: - /** - * @brief set the current border size of the current element: - * @param[in] _newBorderSize The border size to set (0 if not used) - */ - void setBorderSize(const gale::Dimension& _newBorderSize) { - m_borderSize.set(_newBorderSize); - } - /** - * @brief get the current border size of the current element: - * @return the border size (0 if not used) - */ - const gale::Dimension& getBorderSize() const { - return m_borderSize; - }; - public: - enum animation { - animationNone, //!< No annimation - animationTop, //!< element came from the top - animationbuttom, //!< element came from the buttom - animationLeft, //!< element came from the Left - animationRight //!< element came from the right - //animationZoom //!< element came from zooming - }; - protected: - enum animation m_animation; //!< Methode add and remove element (animation) - public: - /** - * @brief set an animation mode for the new element set in the Widget container. - * @param[in] _animation The new animation mode. - */ - void setAnimationMode(enum animation _animation) { - m_animation = _animation; - }; - /** - * @brief get the current animation mode. - * @return The animation mode. - */ - enum animation getAnimationMode() { - return m_animation; - }; - protected: - float m_animationTime; //!< Time in second to generate animation - public: - /** - * @brief set the time to produce animation. - * @param[in] _time The new animation time. - */ - void setAnimationTime(float _time) { - m_animationTime = _time; - }; - /** - * @brief get the current animation time. - * @return The time to produce the animation. - */ - float getAnimationTime() { - return m_animationTime; - }; public: // Derived function virtual void onChangeSize(); virtual void calculateMinMaxSize(); diff --git a/ewol/widget/Slider.cpp b/ewol/widget/Slider.cpp index 0ec630b7..676b37df 100644 --- a/ewol/widget/Slider.cpp +++ b/ewol/widget/Slider.cpp @@ -17,23 +17,23 @@ const int32_t dotRadius = 6; ewol::widget::Slider::Slider() : signalChange(*this, "change"), - m_value(*this, "value", 0.0f, "Value of the Slider"), - m_min(*this, "min", 0.0f, "Minium value"), - m_max(*this, "max", 10.0f, "Maximum value"), - m_step(*this, "step", 1.0f, "Step size") { + propertyValue(*this, "value", 0.0f, "Value of the Slider"), + propertyMinimum(*this, "min", 0.0f, "Minium value"), + propertyMaximum(*this, "max", 10.0f, "Maximum value"), + propertyStep(*this, "step", 1.0f, "Step size") { addObjectType("ewol::widget::Slider"); m_textColorFg = etk::color::black; m_textColorBg = etk::color::black; m_textColorBg.setA(0x3F); - setCanHaveFocus(true); // Limit event at 1: setMouseLimit(1); } void ewol::widget::Slider::init() { ewol::Widget::init(); + propertyCanFocus.set(true); } ewol::widget::Slider::~Slider() { @@ -41,7 +41,7 @@ ewol::widget::Slider::~Slider() { } void ewol::widget::Slider::calculateMinMaxSize() { - vec2 minTmp = m_userMinSize->getPixel(); + vec2 minTmp = propertyMinSize->getPixel(); m_minSize.setValue(std::max(minTmp.x(), 40.0f), std::max(minTmp.y(), dotRadius*2.0f) ); markToRedraw(); @@ -66,7 +66,7 @@ void ewol::widget::Slider::onRegenerateDisplay() { etk::Color<> borderDot = m_textColorFg; borderDot.setA(borderDot.a()/2); - m_draw.setPos(vec3(4+((m_value-m_min)/(m_max-m_min))*(m_size.x()-2*dotRadius), m_size.y()/2, 0) ); + m_draw.setPos(vec3(4+((propertyValue-propertyMinimum)/(propertyMaximum-propertyMinimum))*(m_size.x()-2*dotRadius), m_size.y()/2, 0) ); m_draw.setColorBg(borderDot); m_draw.circle(dotRadius); m_draw.setColorBg(m_textColorFg); @@ -81,11 +81,11 @@ bool ewol::widget::Slider::onEventInput(const ewol::event::Input& _event) { || gale::key::status_move == _event.getStatus()) { // get the new position : EWOL_VERBOSE("Event on Slider (" << relativePos.x() << "," << relativePos.y() << ")"); - float oldValue = m_value.get(); - updateValue(m_min + (float)(relativePos.x() - dotRadius) / (m_size.x()-2*dotRadius) * (m_max-m_min)); - if (oldValue != m_value) { - EWOL_VERBOSE(" new value : " << m_value << " in [" << m_min << ".." << m_max << "]"); - signalChange.emit(m_value); + float oldValue = propertyValue.get(); + updateValue(propertyMinimum + (float)(relativePos.x() - dotRadius) / (m_size.x()-2*dotRadius) * (propertyMaximum-propertyMinimum)); + if (oldValue != propertyValue) { + EWOL_VERBOSE(" new value : " << propertyValue << " in [" << propertyMinimum << ".." << propertyMaximum << "]"); + signalChange.emit(propertyValue); } return true; } @@ -94,12 +94,12 @@ bool ewol::widget::Slider::onEventInput(const ewol::event::Input& _event) { } void ewol::widget::Slider::updateValue(float _newValue) { - _newValue = std::max(std::min(_newValue, m_max.get()), m_min.get()); - if (m_step.get() == 0.0f) { - m_value = _newValue; + _newValue = std::max(std::min(_newValue, propertyMaximum.get()), propertyMinimum.get()); + if (propertyStep.get() == 0.0f) { + propertyValue = _newValue; } else { - float basicVal = (int64_t)(_newValue / m_step.get()); - m_value = basicVal * m_step.get(); + float basicVal = (int64_t)(_newValue / propertyStep.get()); + propertyValue = basicVal * propertyStep.get(); } markToRedraw(); } @@ -107,20 +107,20 @@ void ewol::widget::Slider::updateValue(float _newValue) { // TODO : Review this really bad things ... void ewol::widget::Slider::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::Widget::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_value) { - updateValue(m_value.get()); + if (_paramPointer == propertyValue) { + updateValue(propertyValue.get()); return; } - if (_paramPointer == m_min) { - updateValue(m_value.get()); + if (_paramPointer == propertyMinimum) { + updateValue(propertyValue.get()); return; } - if (_paramPointer == m_max) { - updateValue(m_value.get()); + if (_paramPointer == propertyMaximum) { + updateValue(propertyValue.get()); return; } - if (_paramPointer == m_step) { - updateValue(m_value.get()); + if (_paramPointer == propertyStep) { + updateValue(propertyValue.get()); return; } } diff --git a/ewol/widget/Slider.h b/ewol/widget/Slider.h index 98b985a6..9c46e75d 100644 --- a/ewol/widget/Slider.h +++ b/ewol/widget/Slider.h @@ -20,83 +20,20 @@ namespace ewol { * @ingroup ewolWidgetGroup */ class Slider : public ewol::Widget { - public: - // Event list of properties + public: // signals esignal::Signal signalChange; + public: + //eproperty::Value propertyShape; //!< name of the shape used + eproperty::Value propertyValue; //!< current value of the Slider + eproperty::Value propertyMinimum; //!< minimum value of the slider + eproperty::Value propertyMaximum; //!< maximum value of the slider + eproperty::Value propertyStep; //!< step of every iteration of the slider (increment/precision) protected: Slider(); void init(); public: DECLARE_WIDGET_FACTORY(Slider, "Slider"); virtual ~Slider(); - protected: - eproperty::Value m_value; //!< current value of the Slider - public: - /** - * @brief Set the value of the slider. - * @param[in] _val New value to apply. - */ - void setValue(float _val) { - m_value.set(_val); - } - /** - * @brief Get the value of the slider. - * @return The current value of the slider. - */ - float getValue() { - return m_value; - } - protected: - eproperty::Value m_min; //!< minimum value of the slider - public: - /** - * @brief Set the minumum value of the slider. - * @param[in] _val New minimum value to apply. - */ - void setMin(float _val) { - m_min.set(_val); - } - /** - * @brief Get the minimum value of the slider. - * @return The minimum value of the slider. - */ - float getMin() { - return m_min; - } - protected: - eproperty::Value m_max; //!< maximum value of the slider - public: - /** - * @brief Set the maximum value of the slider. - * @param[in] _val New maximum value to apply. - */ - void setMax(float _val) { - m_max.set(_val); - } - /** - * @brief Get the maximum value of the slider. - * @return The maximum value of the slider. - */ - float getMax() { - return m_max; - } - protected: - eproperty::Value m_step; - public: - /** - * @brief Set the step value of the slider. - * @param[in] _val New step value to apply. - */ - void setStep(float _val) { - m_step.set(_val); - } - /** - * @brief Get the step value of the slider. - * @return The wtep value of the slider. - */ - float getStep() { - return m_step; - } public: // TODO : Rewoek the color in the theme ... void setColor(etk::Color<> _newColor) { diff --git a/ewol/widget/Spacer.cpp b/ewol/widget/Spacer.cpp index 23e85393..bd373bcf 100644 --- a/ewol/widget/Spacer.cpp +++ b/ewol/widget/Spacer.cpp @@ -15,14 +15,14 @@ #define __class__ "Spacer" ewol::widget::Spacer::Spacer() : - m_color(*this, "color", etk::color::none, "background of the spacer") { + propertyColor(*this, "color", etk::color::none, "background of the spacer") { addObjectType("ewol::widget::Spacer"); - m_userMinSize = gale::Dimension(vec2(10,10)); - setCanHaveFocus(false); } void ewol::widget::Spacer::init() { ewol::Widget::init(); + propertyMinSize.set(gale::Dimension(vec2(10,10))); + propertyCanFocus.set(true); } ewol::widget::Spacer::~Spacer() { @@ -40,17 +40,17 @@ void ewol::widget::Spacer::onRegenerateDisplay() { } m_draw.clear(); - if (m_color->a() == 0) { + if (propertyColor->a() == 0) { return; } - m_draw.setColor(m_color); + m_draw.setColor(propertyColor); m_draw.setPos(vec3(0, 0, 0) ); m_draw.rectangleWidth(vec3(m_size.x(), m_size.y(),0) ); } void ewol::widget::Spacer::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::Widget::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_color) { + if (_paramPointer == propertyColor) { markToRedraw(); } } diff --git a/ewol/widget/Spacer.h b/ewol/widget/Spacer.h index 814c58df..1e05c002 100644 --- a/ewol/widget/Spacer.h +++ b/ewol/widget/Spacer.h @@ -20,8 +20,8 @@ namespace ewol { * @ingroup ewolWidgetGroup */ class Spacer : public ewol::Widget { - private: - ewol::compositing::Drawing m_draw; //!< Compositing drawing element + public: // properties: + eproperty::Value> propertyColor; //!< Background color protected: /** * @brief Main constructer @@ -34,17 +34,8 @@ namespace ewol { * @brief Main destructer */ virtual ~Spacer(); - protected: - eproperty::Value> m_color; //!< Background color - public: - /** - * @brief Spziby the background color (basicly transparent) - * @param[in] newColor the display background color - */ - void setColor(etk::Color<> _newColor) { - m_color = _newColor; - markToRedraw(); - }; + private: + ewol::compositing::Drawing m_draw; //!< Compositing drawing element public: // Derived function virtual std::shared_ptr getWidgetAtPos(const vec2& _pos) { return nullptr; }; virtual void onRegenerateDisplay(); diff --git a/ewol/widget/Spin.cpp b/ewol/widget/Spin.cpp index 606da839..5f4d2aee 100644 --- a/ewol/widget/Spin.cpp +++ b/ewol/widget/Spin.cpp @@ -15,15 +15,14 @@ #undef __class__ #define __class__ "widget::Spin" - ewol::widget::Spin::Spin() : signalValue(*this, "value", "Spin value change"), signalValueDouble(*this, "valueDouble", "Spin value change value in 'double'"), - m_value(*this, "value", 0, "Value of the Spin"), - m_min(*this, "min", -9999999999, "Minimum value of the spin"), - m_max(*this, "max", 9999999999, "Maximum value of the spin"), - m_increment(*this, "increment", 1, "Increment value at each button event or keybord event"), - m_mantis(*this, "mantis", 0, "fix-point mantis") { + propertyValue(*this, "value", 0, "Value of the Spin"), + propertyMin(*this, "min", -9999999999, "Minimum value of the spin"), + propertyMax(*this, "max", 9999999999, "Maximum value of the spin"), + propertyIncrement(*this, "increment", 1, "Increment value at each button event or keybord event"), + propertyMantis(*this, "mantis", 0, "fix-point mantis") { addObjectType("ewol::widget::Spin"); } @@ -41,20 +40,20 @@ ewol::widget::Spin::~Spin() { void ewol::widget::Spin::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::widget::SpinBase::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_value) { + if (_paramPointer == propertyValue) { markToRedraw(); if (m_widgetEntry == nullptr) { EWOL_ERROR("Can not acces at entry ..."); return; } - checkValue(m_value.get()); - } else if (_paramPointer == m_min) { - checkValue(m_value.get()); - } else if (_paramPointer == m_max) { - checkValue(m_value.get()); - } else if (_paramPointer == m_increment) { + checkValue(propertyValue.get()); + } else if (_paramPointer == propertyMin) { + checkValue(propertyValue.get()); + } else if (_paramPointer == propertyMax) { + checkValue(propertyValue.get()); + } else if (_paramPointer == propertyIncrement) { - } else if (_paramPointer == m_mantis) { + } else if (_paramPointer == propertyMantis) { } } @@ -79,17 +78,17 @@ void ewol::widget::Spin::updateGui() { } void ewol::widget::Spin::checkValue(int64_t _value) { - _value = std::avg(m_min.get(), _value, m_max.get()); - m_value.get() = _value; - m_widgetEntry->setValue(etk::to_string(_value)); + _value = std::avg(propertyMin.get(), _value, propertyMax.get()); + propertyValue.get() = _value; + m_widgetEntry->propertyValue.set(etk::to_string(_value)); } void ewol::widget::Spin::onCallbackUp() { - int64_t value = m_value.get() + m_increment.get(); + int64_t value = propertyValue.get() + propertyIncrement.get(); checkValue(value); } void ewol::widget::Spin::onCallbackDown() { - int64_t value = m_value.get() - m_increment.get(); + int64_t value = propertyValue.get() - propertyIncrement.get(); checkValue(value); } diff --git a/ewol/widget/WSlider.cpp b/ewol/widget/WSlider.cpp index 631cfb5c..a3d76be7 100644 --- a/ewol/widget/WSlider.cpp +++ b/ewol/widget/WSlider.cpp @@ -26,16 +26,16 @@ std::ostream& operator <<(std::ostream& _os, const enum ewol::widget::WSlider::s ewol::widget::WSlider::WSlider() : signalStartSlide(*this, "start"), signalStopSlide(*this, "stop"), + propertyTransitionSpeed(*this, "speed", 1.0f, 0.0f, 200.0f, "Transition speed of the slider"), + propertyTransitionMode(*this, "mode", sladingTransitionHori, "Transition mode of the slider"), + propertySelectWidget(*this, "select", "", "Select the requested widget to display"), m_windowsSources(0), m_windowsDestination(0), m_windowsRequested(-1), - m_slidingProgress(1.0f), - m_selectNewWidget(*this, "select", "", "Select the requested widget to display"), - m_transitionSpeed(*this, "speed", 1.0f, 0.0f, 200.0f, "Transition speed of the slider"), - m_transitionSlide(*this, "mode", sladingTransitionHori, "Transition mode of the slider") { + m_slidingProgress(1.0f) { addObjectType("ewol::widget::WSlider"); - m_transitionSlide.add(sladingTransitionVert, "vert"); - m_transitionSlide.add(sladingTransitionHori, "hori"); + propertyTransitionMode.add(sladingTransitionVert, "vert"); + propertyTransitionMode.add(sladingTransitionHori, "hori"); } ewol::widget::WSlider::~WSlider() { @@ -63,7 +63,7 @@ void ewol::widget::WSlider::onChangeSize() { std::advance(it, m_windowsSources); if ( it != m_subWidget.end() && *it != nullptr) { - if (m_transitionSlide == sladingTransitionHori) { + if (propertyTransitionMode == sladingTransitionHori) { (*it)->setOrigin( vec2(m_origin.x() + factor*(m_size.x()*m_slidingProgress), m_origin.y()) + m_offset); @@ -79,7 +79,7 @@ void ewol::widget::WSlider::onChangeSize() { std::advance(it, m_windowsDestination); if ( it != m_subWidget.end() && *it != nullptr) { - if (m_transitionSlide == sladingTransitionHori) { + if (propertyTransitionMode == sladingTransitionHori) { (*it)->setOrigin( vec2(m_origin.x() + factor*(m_size.x()*m_slidingProgress - m_size.x()), m_origin.y()) + m_offset); @@ -115,11 +115,11 @@ void ewol::widget::WSlider::subWidgetSelectSet(int32_t _id) { elementID ++; if (it != nullptr) { if (it->getId() == _id) { - if (it->getName() != "") { + if (it->propertyName.get() != "") { // change the internal event parameter (in case...) ==> no event generation - m_selectNewWidget.get() = it->getName(); + propertySelectWidget.get() = it->propertyName.get(); } else { - m_selectNewWidget.get() = ""; + propertySelectWidget.get() = ""; } break; } @@ -130,7 +130,7 @@ void ewol::widget::WSlider::subWidgetSelectSet(int32_t _id) { } else { subWidgetSelectSetVectorId(-1); // change the internal event parameter (in case...) ==> no event generation - m_selectNewWidget.get() = ""; + propertySelectWidget.get() = ""; } } @@ -144,11 +144,11 @@ void ewol::widget::WSlider::subWidgetSelectSet(const std::shared_ptrgetName() != "") { + if (_widgetPointer->propertyName.get() != "") { // change the internal event parameter (in case...) ==> no event generation - m_selectNewWidget.get() = _widgetPointer->getName(); + propertySelectWidget.get() = _widgetPointer->propertyName.get(); } else { - m_selectNewWidget.get() = ""; + propertySelectWidget.get() = ""; } return; } @@ -165,10 +165,10 @@ void ewol::widget::WSlider::subWidgetSelectSet(const std::string& _widgetName) { int32_t iii = 0; for (auto &it : m_subWidget) { if ( it != nullptr - && it->getName() == _widgetName) { + && it->propertyName.get() == _widgetName) { subWidgetSelectSetVectorId(iii); // change the internal event parameter (in case...) ==> no event generation - m_selectNewWidget.get() = _widgetName; + propertySelectWidget.get() = _widgetName; return; } iii++; @@ -192,7 +192,8 @@ void ewol::widget::WSlider::periodicCall(const ewol::event::Time& _event) { } if (m_slidingProgress < 1.0) { - if (m_windowsRequested != -1 && m_slidingProgress<0.5 ) { + if ( m_windowsRequested != -1 + && m_slidingProgress<0.5 ) { // invert sources with destination int32_t tmppp = m_windowsDestination; m_windowsDestination = m_windowsSources; @@ -202,14 +203,14 @@ void ewol::widget::WSlider::periodicCall(const ewol::event::Time& _event) { m_windowsRequested = -1; } } - m_slidingProgress += _event.getDeltaCall()/m_transitionSpeed; + m_slidingProgress += _event.getDeltaCall()/propertyTransitionSpeed; m_slidingProgress = std::avg(0.0f, m_slidingProgress, 1.0f); } onChangeSize(); } void ewol::widget::WSlider::systemDraw(const ewol::DrawProperty& _displayProp) { - if (true == m_hide){ + if (propertyHide == true){ // widget is hidden ... return; } @@ -270,21 +271,22 @@ void ewol::widget::WSlider::onRegenerateDisplay() { } } } + void ewol::widget::WSlider::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::widget::ContainerN::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_selectNewWidget) { - if (m_selectNewWidget.get() != "") { - subWidgetSelectSet(m_selectNewWidget); + if (_paramPointer == propertySelectWidget) { + if (propertySelectWidget.get() != "") { + subWidgetSelectSet(propertySelectWidget); } - } else if (_paramPointer == m_transitionSpeed) { + } else if (_paramPointer == propertyTransitionSpeed) { // nothing to do ... - } else if (_paramPointer == m_transitionSlide) { + } else if (_paramPointer == propertyTransitionMode) { markToRedraw(); } } std::shared_ptr ewol::widget::WSlider::getWidgetAtPos(const vec2& _pos) { - if (true == isHide()) { + if (propertyHide == true) { return nullptr; } if (m_windowsDestination == m_windowsSources) { diff --git a/ewol/widget/WSlider.h b/ewol/widget/WSlider.h index 9613c9e3..d07718c4 100644 --- a/ewol/widget/WSlider.h +++ b/ewol/widget/WSlider.h @@ -20,14 +20,18 @@ namespace ewol { */ class WSlider :public ewol::widget::ContainerN { public: - // Event list of properties - esignal::Signal signalStartSlide; - esignal::Signal signalStopSlide; enum sladingMode { sladingTransitionVert, sladingTransitionHori, sladingTransition_count, }; + public: // signals: + esignal::Signal signalStartSlide; + esignal::Signal signalStopSlide; + public: // properties: + eproperty::Range propertyTransitionSpeed; //!< speed of the transition (default 1 == > 1s) + eproperty::List propertyTransitionMode; //!< mode to slide the widgets + eproperty::Value propertySelectWidget; //!< current select configuration protected: WSlider(); void init() { @@ -41,7 +45,6 @@ namespace ewol { int32_t m_windowsDestination; //!< widget destinated viewed int32_t m_windowsRequested; //!< widget destination requested when change in modification in progress float m_slidingProgress; //!< ratio progression of a sliding - eproperty::Value m_selectNewWidget; // input config requesting protected: /** * @brief Generate the move on the specific vector ID (This is not a public acces, because the vector can have some null pointer inside ...) @@ -64,40 +67,6 @@ namespace ewol { * @param[in] _widgetName Name of the subwidget name */ void subWidgetSelectSet(const std::string& _widgetName); - private: - eproperty::Range m_transitionSpeed; //!< speed of the transition (default 1 == > 1s) - public: - /** - * @brief set transition speed element. - * @param[in] _timeSecond number of second needed to do the transition. - */ - void setTransitionSpeed(float _timeSecond) { - m_transitionSpeed.set(_timeSecond); - }; - /** - * @brief get transition speed element. - * @return number of second needed to do the transition. - */ - float getTransitionSpeed() const { - return m_transitionSpeed; - }; - private: - eproperty::List m_transitionSlide; //!< mode to slide the widgets - public: - /** - * @brief set a new mode of sliding element - * @param[in] _mode new display mode - */ - void setTransitionMode(enum sladingMode _mode) { - m_transitionSlide.set(_mode); - } - /** - * @brief get a new mode of sliding element - * @return The current sliding mode - */ - enum sladingMode getTransitionMode() { - return m_transitionSlide; - }; public: // Derived function virtual void onChangeSize(); virtual void systemDraw(const ewol::DrawProperty& _displayProp); diff --git a/ewol/widget/Widget.cpp b/ewol/widget/Widget.cpp index 5d0f5f58..6d50b0c1 100644 --- a/ewol/widget/Widget.cpp +++ b/ewol/widget/Widget.cpp @@ -18,20 +18,20 @@ #define __class__ "Widget" ewol::Widget::Widget() : + propertyMinSize(*this, "min-size", gale::Dimension(vec2(0,0),gale::Dimension::Pixel), "User minimum size"), + propertyMaxSize(*this, "max-size", gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel), "User maximum size"), + propertyExpand(*this, "expand", bvec2(false,false), "Request the widget Expand size wile space is available"), + propertyFill(*this, "fill", bvec2(true,true), "Fill the widget available size"), + propertyHide(*this, "hide", false, "The widget start hided"), + propertyGravity(*this, "gravity", ewol::gravity_buttomLeft, "Gravity orientation"), + propertyCanFocus(*this, "focus", false, "enable the widget to have the focus capacity"), // TODO : je pense que c'est une erreur, c'st surement un event to get the cocus ... m_size(10,10), m_minSize(0,0), m_maxSize(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE)), m_offset(0,0), m_zoom(1.0f), m_origin(0,0), - m_userMinSize(*this, "min-size", gale::Dimension(vec2(0,0),gale::Dimension::Pixel), "User minimum size"), - m_userMaxSize(*this, "max-size", gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel), "User maximum size"), - m_userExpand(*this, "expand", bvec2(false,false), "Request the widget Expand size wile space is available"), - m_userFill(*this, "fill", bvec2(true,true), "Fill the widget available size"), - m_hide(*this, "hide", false, "The widget start hided"), - m_gravity(*this, "gravity", ewol::gravity_buttomLeft, "Gravity orientation"), m_hasFocus(false), - m_canFocus(*this, "focus", false, "enable the widget to have the focus capacity"), // TODO : je pense que c'est une erreur, c'st surement un event to get the cocus ... m_limitMouseEvent(3), m_allowRepeateKeyboardEvent(true), signalShortcut(*this, "shortcut"), @@ -43,24 +43,24 @@ ewol::Widget::Widget() : signalAnnimationStop(*this, "annimation-stop"), m_annimationMode(annimationModeDisable), m_annimationratio(0.0f), - m_annimationTypeStart(*this, "annimation-start-type", 0, "Annimation type, when adding/show a widget"), - m_annimationTimeStart(*this, "annimation-start-time", 0.1f, 0.0f, 200.0f, "Annimation time in second, when adding/show a widget"), - m_annimationTypeStop(*this, "annimation-stop-type", 0, "Annimation type, when removing/hide a widget"), - m_annimationTimeStop(*this, "annimation-stop-time", 0.1f, 0.0f, 200.0f, "Annimation time in second, when removing/hide a widget"){ + propertyAnnimationTypeStart(*this, "annimation-start-type", 0, "Annimation type, when adding/show a widget"), + propertyAnnimationTimeStart(*this, "annimation-start-time", 0.1f, 0.0f, 200.0f, "Annimation time in second, when adding/show a widget"), + propertyAnnimationTypeStop(*this, "annimation-stop-type", 0, "Annimation type, when removing/hide a widget"), + propertyAnnimationTimeStop(*this, "annimation-stop-time", 0.1f, 0.0f, 200.0f, "Annimation time in second, when removing/hide a widget"){ addObjectType("ewol::Widget"); // TODO : Set a static interface for list ==> this methode create a multiple allocation - m_gravity.add(ewol::gravity_center, "center"); - m_gravity.add(ewol::gravity_topLeft, "top-left"); - m_gravity.add(ewol::gravity_top, "top"); - m_gravity.add(ewol::gravity_topRight, "top-right"); - m_gravity.add(ewol::gravity_right, "right"); - m_gravity.add(ewol::gravity_buttomRight, "buttom-right"); - m_gravity.add(ewol::gravity_buttom, "buttom"); - m_gravity.add(ewol::gravity_buttomLeft, "buttom-left"); - m_gravity.add(ewol::gravity_left, "left"); - m_annimationTypeStart.add(0, "none"); - m_annimationTypeStop.add(0, "none"); + propertyGravity.add(ewol::gravity_center, "center"); + propertyGravity.add(ewol::gravity_topLeft, "top-left"); + propertyGravity.add(ewol::gravity_top, "top"); + propertyGravity.add(ewol::gravity_topRight, "top-right"); + propertyGravity.add(ewol::gravity_right, "right"); + propertyGravity.add(ewol::gravity_buttomRight, "buttom-right"); + propertyGravity.add(ewol::gravity_buttom, "buttom"); + propertyGravity.add(ewol::gravity_buttomLeft, "buttom-left"); + propertyGravity.add(ewol::gravity_left, "left"); + propertyAnnimationTypeStart.add(0, "none"); + propertyAnnimationTypeStop.add(0, "none"); } void ewol::Widget::init() { @@ -82,7 +82,7 @@ void ewol::Widget::onChangeSize() { } bool ewol::Widget::setFocus() { - if (m_canFocus == true) { + if (propertyCanFocus == true) { if (m_hasFocus == false) { m_hasFocus = true; onGetFocus(); @@ -93,7 +93,7 @@ bool ewol::Widget::setFocus() { } bool ewol::Widget::rmFocus() { - if (m_canFocus == true) { + if (propertyCanFocus == true) { if (m_hasFocus == true) { m_hasFocus = false; onLostFocus(); @@ -142,7 +142,7 @@ void ewol::Widget::setOffset(const vec2& _newVal) { (0,0) */ void ewol::Widget::systemDraw(const ewol::DrawProperty& _displayProp) { - if (true == m_hide){ + if (propertyHide == true){ // widget is hidden ... return; } @@ -238,16 +238,16 @@ void ewol::Widget::systemDraw(const ewol::DrawProperty& _displayProp) { } void ewol::Widget::periodicCallDisable() { - EWOL_VERBOSE("Perodic call disable " << getName()); + EWOL_VERBOSE("Perodic call disable " << propertyName); getObjectManager().periodicCall.release(shared_from_this()); } void ewol::Widget::periodicCallEnable() { if (getObjectManager().periodicCall.isRegistered(shared_from_this()) == true) { - EWOL_VERBOSE("Perodic call enable " << getName() << " ==> rejected"); + EWOL_VERBOSE("Perodic call enable " << propertyName << " ==> rejected"); return; } else { - EWOL_VERBOSE("Perodic call enable " << getName()); + EWOL_VERBOSE("Perodic call enable " << propertyName); } getObjectManager().periodicCall.bind(shared_from_this(), &ewol::Widget::periodicCall); } @@ -291,62 +291,62 @@ vec2 ewol::Widget::relativePosition(const vec2& _pos) { } void ewol::Widget::calculateMinMaxSize() { - m_minSize = m_userMinSize->getPixel(); - //EWOL_ERROR("[" << getId() << "] convert in min size : " << m_userMinSize << " out=" << m_minSize); - m_maxSize = m_userMaxSize->getPixel(); + m_minSize = propertyMinSize->getPixel(); + //EWOL_ERROR("[" << getId() << "] convert in min size : " << propertyMinSize << " out=" << m_minSize); + m_maxSize = propertyMaxSize->getPixel(); markToRedraw(); } vec2 ewol::Widget::getCalculateMinSize() { - if (false == isHide()) { + if (propertyHide == false) { return m_minSize; } return vec2(0,0); } vec2 ewol::Widget::getCalculateMaxSize() { - if (false == isHide()) { + if (propertyHide == false) { return m_maxSize; } return vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE); } void ewol::Widget::setNoMinSize() { - m_userMinSize.set(gale::Dimension(vec2(0,0),gale::Dimension::Pixel)); + propertyMinSize.set(gale::Dimension(vec2(0,0),gale::Dimension::Pixel)); } void ewol::Widget::checkMinSize() { - vec2 pixelSize = m_userMinSize->getPixel(); + vec2 pixelSize = propertyMinSize->getPixel(); m_minSize.setX(std::max(m_minSize.x(), pixelSize.x())); m_minSize.setY(std::max(m_minSize.y(), pixelSize.y())); } void ewol::Widget::setNoMaxSize() { - m_userMaxSize.set(gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel)); + propertyMaxSize.set(gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel)); } void ewol::Widget::checkMaxSize() { - vec2 pixelSize = m_userMaxSize->getPixel(); + vec2 pixelSize = propertyMaxSize->getPixel(); m_maxSize.setX(std::min(m_maxSize.x(), pixelSize.x())); m_maxSize.setY(std::min(m_maxSize.y(), pixelSize.y())); } vec2 ewol::Widget::getSize() { - if (false == isHide()) { + if (propertyHide == false) { return m_size; } return vec2(0,0); } bvec2 ewol::Widget::canExpand() { - if (false == isHide()) { - return m_userExpand; + if (propertyHide == false) { + return propertyExpand; } return bvec2(false,false); } const bvec2& ewol::Widget::canFill() { - return m_userFill; + return propertyFill; } // ---------------------------------------------------------------------------------------------------------------- @@ -554,25 +554,25 @@ bool ewol::Widget::systemEventInput(ewol::event::InputSystem& _event) { void ewol::Widget::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::Object::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_canFocus) { + if (_paramPointer == propertyCanFocus) { if (m_hasFocus == true) { rmFocus(); } - } else if (_paramPointer == m_gravity) { + } else if (_paramPointer == propertyGravity) { markToRedraw(); requestUpdateSize(); - } else if (_paramPointer == m_hide) { + } else if (_paramPointer == propertyHide) { markToRedraw(); requestUpdateSize(); - } else if (_paramPointer == m_userFill) { + } else if (_paramPointer == propertyFill) { markToRedraw(); requestUpdateSize(); - } else if (_paramPointer == m_userExpand) { + } else if (_paramPointer == propertyExpand) { requestUpdateSize(); markToRedraw(); - } else if (_paramPointer == m_userMaxSize) { - vec2 pixelMin = m_userMinSize->getPixel(); - vec2 pixelMax = m_userMaxSize->getPixel(); + } else if (_paramPointer == propertyMaxSize) { + vec2 pixelMin = propertyMinSize->getPixel(); + vec2 pixelMax = propertyMaxSize->getPixel(); // check minimum & maximum compatibility : bool error=false; if (pixelMin.x()>pixelMax.x()) { @@ -583,12 +583,12 @@ void ewol::Widget::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { } if (error == true) { EWOL_ERROR("Can not set a 'min size' > 'max size' reset to maximum ..."); - m_userMaxSize = gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel); + propertyMaxSize.get() = gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel); } requestUpdateSize(); - } else if (_paramPointer == m_userMinSize) { - vec2 pixelMin = m_userMinSize->getPixel(); - vec2 pixelMax = m_userMaxSize->getPixel(); + } else if (_paramPointer == propertyMinSize) { + vec2 pixelMin = propertyMinSize->getPixel(); + vec2 pixelMax = propertyMaxSize->getPixel(); // check minimum & maximum compatibility : bool error=false; if (pixelMin.x()>pixelMax.x()) { @@ -599,16 +599,16 @@ void ewol::Widget::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { } if (error == true) { EWOL_ERROR("Can not set a 'min size' > 'max size' set nothing ..."); - m_userMinSize = gale::Dimension(vec2(0,0),gale::Dimension::Pixel); + propertyMinSize = gale::Dimension(vec2(0,0),gale::Dimension::Pixel); } requestUpdateSize(); - } else if (_paramPointer == m_annimationTypeStart) { + } else if (_paramPointer == propertyAnnimationTypeStart) { - } else if (_paramPointer == m_annimationTimeStart) { + } else if (_paramPointer == propertyAnnimationTimeStart) { - } else if (_paramPointer == m_annimationTypeStop) { + } else if (_paramPointer == propertyAnnimationTypeStop) { - } else if (_paramPointer == m_annimationTimeStop) { + } else if (_paramPointer == propertyAnnimationTimeStop) { } } @@ -650,17 +650,17 @@ void ewol::Widget::addAnnimationType(enum ewol::Widget::annimationMode _mode, co void ewol::Widget::setAnnimationType(enum ewol::Widget::annimationMode _mode, const std::string& _type) { if (_mode == 0) { - m_annimationTypeStart.setString(_type); + propertyAnnimationTypeStart.setString(_type); } else { - m_annimationTypeStop.setString(_type); + propertyAnnimationTypeStop.setString(_type); } } void ewol::Widget::setAnnimationTime(enum ewol::Widget::annimationMode _mode, float _time) { if (_mode == 0) { - m_annimationTimeStart.set(_time); + propertyAnnimationTimeStart.set(_time); } else { - m_annimationTimeStop.set(_time); + propertyAnnimationTimeStop.set(_time); } } diff --git a/ewol/widget/Widget.h b/ewol/widget/Widget.h index 71b0bc52..99599630 100644 --- a/ewol/widget/Widget.h +++ b/ewol/widget/Widget.h @@ -69,6 +69,16 @@ namespace ewol { * */ class Widget : public ewol::Object { + public: // signals: + + public: // properties: + eproperty::Value propertyMinSize; //!< user define the minimum size of the widget + eproperty::Value propertyMaxSize; //!< user define the maximum size of the widget + eproperty::Value propertyExpand; //!< the widget will expand if possible + eproperty::Value propertyFill; //!< the widget will fill all the space provided by the parrent. + eproperty::Value propertyHide; //!< hide a widget on the display + eproperty::List propertyGravity; //!< Gravity of the widget + eproperty::Value propertyCanFocus; //!< the focus can be done on this widget protected: /** * @brief Constructor of the widget classes @@ -183,27 +193,11 @@ namespace ewol { * @return coordonate of the origin requested */ virtual vec2 getOrigin(); - protected: - eproperty::Value 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] _size set minimum size (none : 0) - */ - void setMinSize(const gale::Dimension& _size) { - m_userMinSize.set(_size); - } /** * @brief User set No minimum size. */ - void setNoMinSize(); - /** - * @brief get the current calculated min size - * @return the size requested - */ - const gale::Dimension& getMinSize() { - return m_userMinSize.get(); - }; + void setNoMinSize(); // TODO : Remove ==> default ... of the property /** * @brief Check if the current min size is compatible with the user minimum size * If it is not the user minimum size will overWrite the minimum size set. @@ -211,124 +205,38 @@ namespace ewol { */ virtual void checkMinSize(); protected: - eproperty::Value 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(0,0) to unset) - */ - void setMaxSize(const gale::Dimension& _size) { - m_userMaxSize.set(_size); - } /** * @brief User set No maximum size. */ - void setNoMaxSize(); - /** - * @brief get the current maximum size - * @return the size requested - */ - const gale::Dimension& getMaxSize() { - return m_userMaxSize.get(); - }; + void setNoMaxSize(); // TODO : Remove ==> default ... of the property /** * @brief Check if the current max size is compatible with the user maximum size * If it is not the user maximum size will overWrite the maximum size set. * @note : INTERNAL EWOL SYSTEM */ virtual void checkMaxSize(); - protected: - eproperty::Value m_userExpand; public: - /** - * @brief set the expend capabilities (x&y) - * @param[in] _newExpend 2D boolean repensent the capacity to expend - */ - virtual void setExpand(const bvec2& _newExpand) { - m_userExpand.set(_newExpand); - } - /** - * @brief get the expend capabilities (x&y) (set by the user) - * @return 2D boolean repensent the capacity to expend - */ - virtual bvec2 getExpand() { - return m_userExpand; - }; /** * @brief get the expend capabilities (x&y) * @return 2D boolean repensent the capacity to expend * @note : INTERNAL EWOL SYSTEM */ virtual bvec2 canExpand(); - protected: - eproperty::Value m_userFill; public: - /** - * @brief set the x&y filling capacity - * @param[in] _newFill new x&y fill state - */ - virtual void setFill(const bvec2& _newFill) { - m_userFill.set(_newFill); - } - /** - * @brief set the x&y filling capacity set by the user - * @return bvec2 repensent the capacity to x&y filling (set by the user) - */ - virtual const bvec2& getFill() { - return m_userFill; - }; /** * @brief get the filling capabilities x&y * @return bvec2 repensent the capacity to x&y filling * @note : INTERNAL EWOL SYSTEM */ const bvec2& canFill(); - protected: - eproperty::Value m_hide; //!< hide a widget on the display - public: - /** - * @brief set the widget hidden - */ - virtual void hide() { - m_hide.set(true); - } - /** - * @brief set the widget visible - */ - virtual void show() { - m_hide.set(false); - } - /** - * @brief get the visibility of the widget - * @return true: if the widget is hiden, false: it is visible - */ - virtual bool isHide() { - return m_hide; - }; - - protected: - eproperty::List m_gravity; //!< Gravity of the widget - public: - /** - * @brief set the widget gravity - * @param[in] _gravity New gravity of the widget - */ - virtual void setGravity(enum ewol::gravity _gravity) { - m_gravity.set(_gravity); - } - /** - * @brief get the widget gravity - * @return the gravity type - */ - virtual enum ewol::gravity getGravity() { - return m_gravity; - }; // ---------------------------------------------------------------------------------------------------------------- // -- focus Area // ---------------------------------------------------------------------------------------------------------------- private: bool m_hasFocus; //!< set the focus on this widget - eproperty::Value m_canFocus; //!< the focus can be done on this widget + public: /** * @brief get the focus state of the widget @@ -337,13 +245,6 @@ namespace ewol { virtual bool getFocus() { return m_hasFocus; }; - /** - * @brief get the capability to have focus - * @return State capability to have focus - */ - virtual bool canHaveFocus() { - return m_canFocus; - }; /** * @brief set focus on this widget * @return return true if the widget keep the focus @@ -354,13 +255,6 @@ namespace ewol { * @return return true if the widget have release his focus (if he has it) */ virtual bool rmFocus(); - /** - * @brief set the capability to have the focus - * @param[in] _canFocusState new focus capability - */ - virtual void setCanHaveFocus(bool _canFocusState) { - m_canFocus.set(_canFocusState); - } /** * @brief keep the focus on this widget == > this remove the previous focus on all other widget */ @@ -455,7 +349,7 @@ namespace ewol { * @note : INTERNAL EWOL SYSTEM */ virtual std::shared_ptr getWidgetAtPos(const vec2& _pos) { - if (false == isHide()) { + if (propertyHide.get() == false) { return std::dynamic_pointer_cast(shared_from_this()); } return nullptr; @@ -652,10 +546,10 @@ namespace ewol { enum annimationMode m_annimationMode; //!< true when the annimation is started float m_annimationratio; //!< Ratio of the annimation [0..1] protected: - eproperty::List m_annimationTypeStart; //!< type of start annimation - eproperty::Range m_annimationTimeStart; //!< time to produce start annimation - eproperty::List m_annimationTypeStop; //!< type of start annimation - eproperty::Range m_annimationTimeStop; //!< time to produce start annimation + eproperty::List propertyAnnimationTypeStart; //!< type of start annimation + eproperty::Range propertyAnnimationTimeStart; //!< time to produce start annimation + eproperty::List propertyAnnimationTypeStop; //!< type of start annimation + eproperty::Range propertyAnnimationTimeStop; //!< time to produce start annimation protected: /** * @brief Add a annimation type capabilities of this widget. diff --git a/ewol/widget/WidgetScrolled.cpp b/ewol/widget/WidgetScrolled.cpp index 8865e150..122bc7e0 100644 --- a/ewol/widget/WidgetScrolled.cpp +++ b/ewol/widget/WidgetScrolled.cpp @@ -16,6 +16,8 @@ ewol::widget::WidgetScrolled::WidgetScrolled() : + propertyShapeVert(*this, "shape-vert", "", "shape for the vertical display"), + propertyShapeHori(*this, "shape-hori", "", "shape for the horizonal display"), m_shaperH(), m_shaperV(), m_singleFingerMode(true) { @@ -36,8 +38,8 @@ ewol::widget::WidgetScrolled::WidgetScrolled() : void ewol::widget::WidgetScrolled::init(const std::string& _shaperName) { ewol::Widget::init(); - m_shaperH.setSource(_shaperName); - m_shaperV.setSource(_shaperName); + propertyShapeVert.set(_shaperName); + propertyShapeHori.set(_shaperName); } ewol::widget::WidgetScrolled::~WidgetScrolled() { @@ -225,8 +227,8 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event } else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeInit && _event.getStatus() == gale::key::status_move) { // wait that the cursor move more than 10 px to enable it : - if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 - || abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { + if( std::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 + || std::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { // the scrooling can start : // select the direction : if (relativePos.x() == m_highSpeedStartPos.x()) { @@ -235,7 +237,7 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event m_highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal; } else { float coef = (relativePos.y() - m_highSpeedStartPos.y()) / (relativePos.x() - m_highSpeedStartPos.x()); - if (abs(coef) <= 1 ) { + if (std::abs(coef) <= 1 ) { m_highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal; } else { m_highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical; @@ -334,8 +336,8 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event } else if ( m_highSpeedMode == ewol::widget::Scroll::speedModeInit && _event.getStatus() == gale::key::status_move) { // wait that the cursor move more than 10 px to enable it : - if( abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 - || abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { + if( std::abs(relativePos.x() - m_highSpeedStartPos.x()) > 10 + || std::abs(relativePos.y() - m_highSpeedStartPos.y()) > 10 ) { // the scrooling can start : // select the direction : m_highSpeedMode = ewol::widget::Scroll::speedModeEnableFinger; @@ -475,3 +477,14 @@ void ewol::widget::WidgetScrolled::setSingleFinger(bool _status) { } m_singleFingerMode = _status; } + +void ewol::widget::WidgetScrolled::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { + ewol::Widget::onPropertyChangeValue(_paramPointer); + if (_paramPointer == propertyShapeVert) { + m_shaperV.setSource(propertyShapeVert); + markToRedraw(); + } else if (_paramPointer == propertyShapeHori) { + m_shaperH.setSource(propertyShapeHori); + markToRedraw(); + } +} \ No newline at end of file diff --git a/ewol/widget/WidgetScrolled.h b/ewol/widget/WidgetScrolled.h index c549b1cd..a13dcec3 100644 --- a/ewol/widget/WidgetScrolled.h +++ b/ewol/widget/WidgetScrolled.h @@ -21,6 +21,10 @@ namespace ewol { * @brief Widget to integrate a scrool bar in a widget. This is not a stadalone widget. */ class WidgetScrolled : public ewol::Widget { + public: // properties: + eproperty::Value propertyShapeVert; //!< Vertical shaper name + eproperty::Value propertyShapeHori; //!< Horizontal shaper name + // TODO : All property public: enum scrollingMode { scroolModeNormal, //!< No Zoom , can UP and down, left and right @@ -114,6 +118,7 @@ namespace ewol { void setLimitScrolling(float _poucentageLimit) { m_limitScrolling = std::avg(0.1f, _poucentageLimit,0.9f); }; + void onPropertyChangeValue(const eproperty::Ref& _paramPointer); }; } } diff --git a/ewol/widget/Windows.cpp b/ewol/widget/Windows.cpp index f4b73fd3..0c4fe495 100644 --- a/ewol/widget/Windows.cpp +++ b/ewol/widget/Windows.cpp @@ -28,7 +28,6 @@ ewol::widget::Windows::Windows() : m_colorProperty(nullptr), m_colorBg(-1) { addObjectType("ewol::widget::Windows"); - setCanHaveFocus(true); m_colorProperty = ewol::resource::ColorFile::create("{ewol}THEME:COLOR:Windows.json"); if (m_colorProperty != nullptr) { m_colorBg = m_colorProperty->request("background"); @@ -36,6 +35,11 @@ ewol::widget::Windows::Windows() : //KeyboardShow(KEYBOARD_MODE_CODE); } +void ewol::widget::Windows::init() { + ewol::Widget::init(); + propertyCanFocus.set(true); +} + ewol::widget::Windows::~Windows() { m_subWidget.reset(); m_popUpWidgetList.clear(); @@ -234,7 +238,7 @@ void ewol::widget::Windows::createPopUpMessage(enum popUpMessageType _type, cons } tmpPopUp->setComment(_message); tmpPopUp->addButton("close", true); - tmpPopUp->setRemoveOnExternClick(true); + tmpPopUp->propertyCloseOutEvent.set(true); popUpWidgetPush(tmpPopUp); } diff --git a/ewol/widget/Windows.h b/ewol/widget/Windows.h index bfc1b691..e2c3594e 100644 --- a/ewol/widget/Windows.h +++ b/ewol/widget/Windows.h @@ -25,9 +25,7 @@ namespace ewol { int32_t m_colorBg; //!< Default background color of the windows protected: Windows(); - void init() { - ewol::Widget::init(); - }; + void init(); public: virtual ~Windows(); // internal event at ewol system : diff --git a/ewol/widget/meta/ColorChooser.cpp b/ewol/widget/meta/ColorChooser.cpp index b7ec2ea1..3ed4d71d 100644 --- a/ewol/widget/meta/ColorChooser.cpp +++ b/ewol/widget/meta/ColorChooser.cpp @@ -26,16 +26,17 @@ static const char * const eventColorBarHasChange = "event-color-bar-has ewol::widget::ColorChooser::ColorChooser() : - signalChange(*this, "change") { + signalChange(*this, "change"), + propertyValue(*this, "value", etk::color::white, "color to select") { addObjectType("ewol::widget::ColorChooser"); } void ewol::widget::ColorChooser::init() { ewol::widget::Sizer::init(ewol::widget::Sizer::modeVert); - lockExpand(bvec2(true,true)); + propertyLockExpand.set(bvec2(true,true)); m_widgetColorBar = ewol::widget::ColorBar::create(); m_widgetColorBar->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChange); - m_widgetColorBar->setFill(bvec2(true,true)); + m_widgetColorBar->propertyFill.set(bvec2(true,true)); subWidgetAdd(m_widgetColorBar); etk::Color<> sliderColor; @@ -43,40 +44,38 @@ void ewol::widget::ColorChooser::init() { m_widgetRed = ewol::widget::Slider::create(); m_widgetRed->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChangeRed); - m_widgetRed->setExpand(bvec2(true,false)); - m_widgetRed->setFill(bvec2(true,false)); - m_widgetRed->setMin(0); - m_widgetRed->setMax(255); + m_widgetRed->propertyExpand.set(bvec2(true,false)); + m_widgetRed->propertyFill.set(bvec2(true,false)); + m_widgetRed->propertyMinimum.set(0); + m_widgetRed->propertyMaximum.set(255); sliderColor = etk::Color<>(0xFF, 0x00, 0x00, 0xFF); m_widgetRed->setColor(sliderColor); subWidgetAdd(m_widgetRed); m_widgetGreen = ewol::widget::Slider::create(); m_widgetGreen->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChangeGreen); - m_widgetGreen->setExpand(bvec2(true,false)); - m_widgetGreen->setFill(bvec2(true,false)); - m_widgetGreen->setMin(0); + m_widgetGreen->propertyExpand.set(bvec2(true,false)); + m_widgetGreen->propertyFill.set(bvec2(true,false)); + m_widgetGreen->propertyMinimum.set(0); + m_widgetGreen->propertyMaximum.set(255); sliderColor = etk::Color<>(0x00, 0xFF, 0x00, 0xFF); m_widgetGreen->setColor(sliderColor); - m_widgetGreen->setMax(255); subWidgetAdd(m_widgetGreen); m_widgetBlue = ewol::widget::Slider::create(); m_widgetBlue->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChangeBlue); - m_widgetBlue->setExpand(bvec2(true,false)); - m_widgetBlue->setFill(bvec2(true,false)); - m_widgetBlue->setMin(0); + m_widgetBlue->propertyExpand.set(bvec2(true,false)); + m_widgetBlue->propertyFill.set(bvec2(true,false)); + m_widgetBlue->propertyMinimum.set(0); + m_widgetBlue->propertyMaximum.set(255); sliderColor = etk::Color<>(0x00, 0x00, 0xFF, 0xFF); m_widgetBlue->setColor(sliderColor); - m_widgetBlue->setMax(255); subWidgetAdd(m_widgetBlue); m_widgetAlpha = ewol::widget::Slider::create(); m_widgetAlpha->signalChange.bind(shared_from_this(), &ewol::widget::ColorChooser::onCallbackColorChangeAlpha); - m_widgetAlpha->setExpand(bvec2(true,false)); - m_widgetAlpha->setFill(bvec2(true,false)); - m_widgetAlpha->setMin(0); - m_widgetAlpha->setMax(255); + m_widgetAlpha->propertyExpand.set(bvec2(true,false)); + m_widgetAlpha->propertyFill.set(bvec2(true,false)); + m_widgetAlpha->propertyMinimum.set(0); + m_widgetAlpha->propertyMaximum.set(255); subWidgetAdd(m_widgetAlpha); - - m_currentColor = etk::color::white; } @@ -85,75 +84,75 @@ ewol::widget::ColorChooser::~ColorChooser() { } -void ewol::widget::ColorChooser::setColor(etk::Color<> _newColor) { - m_currentColor = _newColor; - if (nullptr != m_widgetRed) { - m_widgetRed->setValue(m_currentColor.r()); +void ewol::widget::ColorChooser::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { + ewol::widget::Sizer::onPropertyChangeValue(_paramPointer); + if (_paramPointer == propertyValue) { + if (m_widgetRed != nullptr) { + m_widgetRed->propertyValue.set(propertyValue->r()); + } + if (m_widgetGreen != nullptr) { + m_widgetGreen->propertyValue.set(propertyValue->g()); + } + if (m_widgetBlue != nullptr) { + m_widgetBlue->propertyValue.set(propertyValue->b()); + } + if (m_widgetAlpha != nullptr) { + m_widgetAlpha->propertyValue.set(propertyValue->a()); + } + if (m_widgetColorBar != nullptr) { + m_widgetColorBar->propertyValue.set(propertyValue); + } } - if (nullptr != m_widgetGreen) { - m_widgetGreen->setValue(m_currentColor.g()); - } - if (nullptr != m_widgetBlue) { - m_widgetBlue->setValue(m_currentColor.b()); - } - if (nullptr != m_widgetAlpha) { - m_widgetAlpha->setValue(m_currentColor.a()); - } - if (nullptr != m_widgetColorBar) { - m_widgetColorBar->setCurrentColor(m_currentColor); - } -} - - -etk::Color<> ewol::widget::ColorChooser::getColor() { - return m_currentColor; } void ewol::widget::ColorChooser::onCallbackColorChangeRed(const float& _newColor) { - m_currentColor.setR(_newColor); - if (nullptr != m_widgetColorBar) { - m_widgetColorBar->setCurrentColor(m_currentColor); + propertyValue.get().setR(_newColor); + if (m_widgetColorBar != nullptr) { + m_widgetColorBar->propertyValue.set(propertyValue); } - signalChange.emit(m_currentColor); + signalChange.emit(propertyValue); } + void ewol::widget::ColorChooser::onCallbackColorChangeGreen(const float& _newColor) { - m_currentColor.setG(_newColor); - if (nullptr != m_widgetColorBar) { - m_widgetColorBar->setCurrentColor(m_currentColor); + propertyValue.get().setG(_newColor); + if (m_widgetColorBar != nullptr) { + m_widgetColorBar->propertyValue.set(propertyValue); } - signalChange.emit(m_currentColor); + signalChange.emit(propertyValue); } + void ewol::widget::ColorChooser::onCallbackColorChangeBlue(const float& _newColor) { - m_currentColor.setB(_newColor); - if (nullptr != m_widgetColorBar) { - m_widgetColorBar->setCurrentColor(m_currentColor); + propertyValue.get().setB(_newColor); + if (m_widgetColorBar != nullptr) { + m_widgetColorBar->propertyValue.set(propertyValue); } - signalChange.emit(m_currentColor); + signalChange.emit(propertyValue); } + void ewol::widget::ColorChooser::onCallbackColorChangeAlpha(const float& _newColor) { - m_currentColor.setA(_newColor); - if (nullptr != m_widgetColorBar) { - m_widgetColorBar->setCurrentColor(m_currentColor); + propertyValue.get().setA(_newColor); + if (m_widgetColorBar != nullptr) { + m_widgetColorBar->propertyValue.set(propertyValue); } - signalChange.emit(m_currentColor); + signalChange.emit(propertyValue); } + void ewol::widget::ColorChooser::onCallbackColorChange(const etk::Color<>& _newColor) { - m_currentColor = _newColor; // == > colorBar has change ... - uint8_t tmpAlpha = m_currentColor.a(); - m_currentColor = _newColor; - m_currentColor.setA(tmpAlpha); - if (nullptr != m_widgetRed) { - m_widgetRed->setValue(m_currentColor.r()); + uint8_t tmpAlpha = propertyValue->a(); + propertyValue.get() = _newColor; + propertyValue.get().setA(tmpAlpha); + if (m_widgetRed != nullptr) { + m_widgetRed->propertyValue.set(propertyValue->r()); } - if (nullptr != m_widgetGreen) { - m_widgetGreen->setValue(m_currentColor.g()); + if (m_widgetGreen != nullptr) { + m_widgetGreen->propertyValue.set(propertyValue->g()); } - if (nullptr != m_widgetBlue) { - m_widgetBlue->setValue(m_currentColor.b()); + if (m_widgetBlue != nullptr) { + m_widgetBlue->propertyValue.set(propertyValue->b()); } - if (nullptr != m_widgetAlpha) { - m_widgetAlpha->setValue(m_currentColor.a()); + if (m_widgetAlpha != nullptr) { + m_widgetAlpha->propertyValue.set(propertyValue->a()); } - signalChange.emit(m_currentColor); + signalChange.emit(propertyValue); } \ No newline at end of file diff --git a/ewol/widget/meta/ColorChooser.h b/ewol/widget/meta/ColorChooser.h index 98b1b831..04b72391 100644 --- a/ewol/widget/meta/ColorChooser.h +++ b/ewol/widget/meta/ColorChooser.h @@ -26,27 +26,26 @@ namespace ewol { class ColorChooser : public ewol::widget::Sizer { public: // signals esignal::Signal> signalChange; + public: + eproperty::Value> propertyValue; protected: ColorChooser(); void init(); public: DECLARE_WIDGET_FACTORY(ColorChooser, "ColorChooser"); virtual ~ColorChooser(); - public: - void setColor(etk::Color<> _newColor); - etk::Color<> getColor(); private: std::shared_ptr m_widgetColorBar; std::shared_ptr m_widgetRed; std::shared_ptr m_widgetGreen; std::shared_ptr m_widgetBlue; std::shared_ptr m_widgetAlpha; - etk::Color<> m_currentColor; void onCallbackColorChangeRed(const float& _newColor); void onCallbackColorChangeGreen(const float& _newColor); void onCallbackColorChangeBlue(const float& _newColor); void onCallbackColorChangeAlpha(const float& _newColor); void onCallbackColorChange(const etk::Color<>& _newColor); + virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); }; }; }; diff --git a/ewol/widget/meta/FileChooser.cpp b/ewol/widget/meta/FileChooser.cpp index ca5e535a..45d00b10 100644 --- a/ewol/widget/meta/FileChooser.cpp +++ b/ewol/widget/meta/FileChooser.cpp @@ -33,34 +33,38 @@ extern "C" { #undef __class__ #define __class__ "FileChooser" + ewol::widget::FileChooser::FileChooser() : signalCancel(*this, "cancel"), - signalValidate(*this, "validate") { + signalValidate(*this, "validate"), + propertyPath(*this, "path", etk::getUserHomeFolder(), ""), + propertyFile(*this, "file", "", ""), + propertyLabelTitle(*this, "title", "TRANSLATE:FileChooser", ""), + propertyLabelValidate(*this, "label-validate", "TRANSLATE:Validate", ""), + propertyLabelCancel(*this, "label-cancel", "TRANSLATE:Cancel", "") { addObjectType("ewol::widget::FileChooser"); } void ewol::widget::FileChooser::init() { ewol::widget::Composer::init(); - m_folder = etk::getUserHomeFolder(); - m_file = ""; std::string myDescription = std::string("") + "\n" + " \n" + " \n" + " \n" - + " \n" + + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" @@ -91,7 +95,7 @@ void ewol::widget::FileChooser::init() { + " \n" + " \n" + " \n" - + " \n" + + " \n" + " \n" + ""; loadFromString(myDescription); @@ -108,7 +112,7 @@ void ewol::widget::FileChooser::init() { subBind(ewol::widget::Image, "[" + etk::to_string(getId()) + "]file-shooser:img-home", signalPressed, shared_from_this(), &ewol::widget::FileChooser::onCallbackHomePressed); // set the default Folder properties: updateCurrentFolder(); - setCanHaveFocus(true); + propertyCanFocus.set(true); } void ewol::widget::FileChooser::onGetFocus() { @@ -120,29 +124,23 @@ ewol::widget::FileChooser::~FileChooser() { } -void ewol::widget::FileChooser::setTitle(const std::string& _label) { - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:title-label", "value", _label); +void ewol::widget::FileChooser::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { + ewol::widget::Composer::onPropertyChangeValue(_paramPointer); + if (_paramPointer == propertyPath) { + propertyPath.get() += "/"; + updateCurrentFolder(); + } else if (_paramPointer == propertyFile) { + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:entry-file", "value", propertyFile); + updateCurrentFolder(); + } else if (_paramPointer == propertyLabelTitle) { + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:title-label", "value", TRANSLATE(propertyLabelTitle)); + } else if (_paramPointer == propertyLabelValidate) { + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:validate-label", "value", TRANSLATE(propertyLabelValidate)); + } else if (_paramPointer == propertyLabelCancel) { + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:cancel-label", "value", TRANSLATE(propertyLabelCancel)); + } } -void ewol::widget::FileChooser::setValidateLabel(const std::string& _label) { - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:validate-label", "value", _label); -} - -void ewol::widget::FileChooser::setCancelLabel(const std::string& _label) { - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:cancel-label", "value", _label); -} - -void ewol::widget::FileChooser::setFolder(const std::string& _folder) { - m_folder = _folder + "/"; - updateCurrentFolder(); -} - -void ewol::widget::FileChooser::setFileName(const std::string& _filename) { - m_file = _filename; - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:entry-file", "value", _filename); -} - - void ewol::widget::FileChooser::onCallbackEntryFolderChangeValue(const std::string& _value) { // == > change the folder name // TODO : change the folder, if it exit ... @@ -150,9 +148,9 @@ void ewol::widget::FileChooser::onCallbackEntryFolderChangeValue(const std::stri void ewol::widget::FileChooser::onCallbackEntryFileChangeValue(const std::string& _value) { // == > change the file name - m_file = _value; + propertyFile.get() = _value; // update the selected file in the list : - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "select", m_file); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "select", propertyFile); } void ewol::widget::FileChooser::onCallbackButtonCancelPressed() { @@ -173,16 +171,16 @@ void ewol::widget::FileChooser::onCallbackHidenFileChangeChangeValue(const bool& void ewol::widget::FileChooser::onCallbackListFolderSelectChange(const std::string& _value) { // == > this is an internal event ... - EWOL_DEBUG(" old PATH : \"" << m_folder << "\" + \"" << _value << "\""); - m_folder = m_folder + _value; - EWOL_DEBUG("new PATH : \"" << m_folder << "\""); - m_folder = etk::simplifyPath(m_folder); - setFileName(""); + EWOL_DEBUG(" old PATH: '" << propertyPath << "' + '" << _value << "'"); + propertyPath.get() += _value; + EWOL_DEBUG("new PATH: '" << propertyPath << "'"); + propertyPath.get() = etk::simplifyPath(propertyPath); + propertyFile.set(""); updateCurrentFolder(); } void ewol::widget::FileChooser::onCallbackListFileSelectChange(const std::string& _value) { - setFileName(_value); + propertyFile.set(_value); /* std::string tmpFileCompleatName = m_folder; tmpFileCompleatName += m_file; @@ -192,18 +190,18 @@ void ewol::widget::FileChooser::onCallbackListFileSelectChange(const std::string void ewol::widget::FileChooser::onCallbackListFileValidate(const std::string& _value) { // select the file == > generate a validate - setFileName(_value); - EWOL_VERBOSE(" generate a fiel opening : '" << m_folder << "' / '" << m_file << "'"); + propertyFile.set(_value); + EWOL_VERBOSE(" generate a fiel opening : '" << propertyPath << "' / '" << propertyFile << "'"); signalValidate.emit(getCompleateFileName()); autoDestroy(); } void ewol::widget::FileChooser::onCallbackListValidate() { - if (m_file == "" ) { - EWOL_WARNING(" Validate : '" << m_folder << "' / '" << m_file << "' ==> error No name ..."); + if (propertyFile.get() == "") { + EWOL_WARNING(" Validate : '" << propertyPath << "' / '" << propertyFile << "' ==> error No name ..."); return; } - EWOL_DEBUG(" generate a file opening : '" << m_folder << "' / '" << m_file << "'"); + EWOL_DEBUG(" generate a file opening : '" << propertyPath << "' / '" << propertyFile << "'"); signalValidate.emit(getCompleateFileName()); autoDestroy(); } @@ -212,28 +210,28 @@ void ewol::widget::FileChooser::onCallbackHomePressed() { std::string tmpUserFolder = etk::getUserHomeFolder(); EWOL_DEBUG("new PATH : \"" << tmpUserFolder << "\""); - m_folder = etk::simplifyPath(tmpUserFolder); + propertyPath.get() = etk::simplifyPath(tmpUserFolder); - setFileName(""); + propertyFile.set(""); updateCurrentFolder(); } void ewol::widget::FileChooser::updateCurrentFolder() { - if (m_folder != "" ) { - if (m_folder[m_folder.size()-1] != '/') { - m_folder += "/"; + if (propertyPath.get() != "") { + if (propertyPath.get()[propertyPath->size()-1] != '/') { + propertyPath.get() += "/"; } } - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "path", m_folder); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "path", m_folder); - propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:entry-folder", "value", m_folder); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-files", "path", propertyPath); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:list-folder", "path", propertyPath); + propertySetOnWidgetNamed("[" + etk::to_string(getId()) + "]file-shooser:entry-folder", "value", propertyPath); markToRedraw(); } std::string ewol::widget::FileChooser::getCompleateFileName() { - std::string tmpString = m_folder; + std::string tmpString = propertyPath; tmpString += "/"; - tmpString += m_file; + tmpString += propertyFile; etk::FSNode node(tmpString); return node.getName(); } diff --git a/ewol/widget/meta/FileChooser.h b/ewol/widget/meta/FileChooser.h index 01a429cf..3ed0ae08 100644 --- a/ewol/widget/meta/FileChooser.h +++ b/ewol/widget/meta/FileChooser.h @@ -66,6 +66,12 @@ namespace ewol { public: // signals esignal::Signal signalCancel; esignal::Signal signalValidate; + public: // properties + eproperty::Value propertyPath; + eproperty::Value propertyFile; + eproperty::Value propertyLabelTitle; + eproperty::Value propertyLabelValidate; + eproperty::Value propertyLabelCancel; protected: FileChooser(); void init(); @@ -73,14 +79,6 @@ namespace ewol { DECLARE_WIDGET_FACTORY(FileChooser, "FileChooser"); virtual ~FileChooser(); private: - std::string m_folder; - std::string m_file; - public: - void setTitle(const std::string& _label); - void setValidateLabel(const std::string& _label); - void setCancelLabel(const std::string& _label); - void setFolder(const std::string& _folder); - void setFileName(const std::string& _filename); std::string getCompleateFileName(); void updateCurrentFolder(); public: // Derived function @@ -96,6 +94,7 @@ namespace ewol { void onCallbackListFileValidate(const std::string& _value); void onCallbackListValidate(); void onCallbackHomePressed(); + virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); }; }; }; diff --git a/ewol/widget/meta/Parameter.cpp b/ewol/widget/meta/Parameter.cpp index 9c7b5dba..92ec4e8e 100644 --- a/ewol/widget/meta/Parameter.cpp +++ b/ewol/widget/meta/Parameter.cpp @@ -23,6 +23,7 @@ ewol::widget::Parameter::Parameter() : signalClose(*this, "close"), + propertyLabelTitle(*this, "title", "TRANSLATE:Parameter", ""), m_currentIdList(0), m_widgetTitle(), m_paramList() { @@ -36,37 +37,37 @@ void ewol::widget::Parameter::init() { std::shared_ptr mySizerHori = nullptr; std::shared_ptr mySpacer = nullptr; #ifdef __TARGET_OS__Android - setMinSize(gale::Dimension(vec2(90, 90), gale::Dimension::Pourcent)); + propertyMinSize.set(gale::Dimension(vec2(90, 90), gale::Dimension::Pourcent)); #else - setMinSize(gale::Dimension(vec2(80, 80), gale::Dimension::Pourcent)); + propertyMinSize.set(gale::Dimension(vec2(80, 80), gale::Dimension::Pourcent)); #endif mySizerVert = ewol::widget::Sizer::create(widget::Sizer::modeVert); - if (nullptr == mySizerVert) { + if (mySizerVert == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { EWOL_INFO("add widget"); - mySizerVert->lockExpand(bvec2(true,true)); - mySizerVert->setExpand(bvec2(true,true)); + mySizerVert->propertyLockExpand.set(bvec2(true,true)); + mySizerVert->propertyExpand.set(bvec2(true,true)); // set it in the pop-up-system : setSubWidget(mySizerVert); mySizerHori = ewol::widget::Sizer::create(widget::Sizer::modeHori); - if (nullptr == mySizerHori) { + if (mySizerHori == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { mySizerVert->subWidgetAdd(mySizerHori); mySpacer = ewol::widget::Spacer::create(); - if (nullptr == mySpacer) { + if (mySpacer == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { - mySpacer->setExpand(bvec2(true,false)); + mySpacer->propertyExpand.set(bvec2(true,false)); mySizerHori->subWidgetAdd(mySpacer); } std::shared_ptr tmpButton = widget::Button::create(); - if (nullptr == tmpButton) { + if (tmpButton == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { tmpButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, @@ -81,16 +82,16 @@ void ewol::widget::Parameter::init() { } mySpacer = ewol::widget::Spacer::create(); - if (nullptr == mySpacer) { + if (mySpacer == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { - mySpacer->setExpand(bvec2(false,false)); - mySpacer->setMinSize(gale::Dimension(vec2(10,0))); + mySpacer->propertyExpand.set(bvec2(false,false)); + mySpacer->propertyMinSize.set(gale::Dimension(vec2(10,0))); mySizerHori->subWidgetAdd(mySpacer); } tmpButton = ewol::widget::Button::create(); - if (nullptr == tmpButton) { + if (tmpButton == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { tmpButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, @@ -106,74 +107,74 @@ void ewol::widget::Parameter::init() { } mySizerHori = ewol::widget::Sizer::create(widget::Sizer::modeHori); - if (nullptr == mySizerHori) { + if (mySizerHori == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { mySizerVert->subWidgetAdd(mySizerHori); m_paramList = ewol::widget::ParameterList::create(); - if (nullptr == m_paramList) { + if (m_paramList == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { m_paramList->signalSelect.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackMenuSelected); - m_paramList->setFill(bvec2(false,true)); - m_paramList->setExpand(bvec2(false,true)); + m_paramList->propertyFill.set(bvec2(false,true)); + m_paramList->propertyExpand.set(bvec2(false,true)); mySizerHori->subWidgetAdd(m_paramList); } mySpacer = ewol::widget::Spacer::create(); - if (nullptr == mySpacer) { + if (mySpacer == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { - mySpacer->setFill(bvec2(false,true)); - mySpacer->setMinSize(vec2(5,5)); - mySpacer->setColor(0x000000BF); + mySpacer->propertyFill.set(bvec2(false,true)); + mySpacer->propertyMinSize.set(vec2(5,5)); + mySpacer->propertyColor.set(0x000000BF); mySizerHori->subWidgetAdd(mySpacer); } std::shared_ptr mySizerVert2 = widget::Sizer::create(widget::Sizer::modeVert); - if (nullptr == mySizerVert2) { + if (mySizerVert2 == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { mySizerHori->subWidgetAdd(mySizerVert2); mySpacer = ewol::widget::Spacer::create(); - if (nullptr == mySpacer) { + if (mySpacer == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { - mySpacer->setExpand(bvec2(true,false)); - mySpacer->setMinSize(vec2(5,5)); - mySpacer->setColor(0x000000BF); + mySpacer->propertyExpand.set(bvec2(true,false)); + mySpacer->propertyMinSize.set(vec2(5,5)); + mySpacer->propertyColor.set(0x000000BF); mySizerVert2->subWidgetAdd(mySpacer); } m_wSlider = ewol::widget::WSlider::create(); - if (nullptr == m_wSlider) { + if (m_wSlider == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { - m_wSlider->setTransitionSpeed(0.5); - m_wSlider->setTransitionMode(ewol::widget::WSlider::sladingTransitionVert); - m_wSlider->setExpand(bvec2(true,true)); + m_wSlider->propertyTransitionSpeed.set(0.5); + m_wSlider->propertyTransitionMode.set(ewol::widget::WSlider::sladingTransitionVert); + m_wSlider->propertyExpand.set(bvec2(true,true)); mySizerVert2->subWidgetAdd(m_wSlider); } } } mySpacer = ewol::widget::Spacer::create(); - if (nullptr == mySpacer) { + if (mySpacer == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { - mySpacer->setExpand(bvec2(true,false)); - mySpacer->setMinSize(vec2(5,5)); - mySpacer->setColor(0x000000BF); + mySpacer->propertyExpand.set(bvec2(true,false)); + mySpacer->propertyMinSize.set(vec2(5,5)); + mySpacer->propertyColor.set(0x000000BF); mySizerVert->subWidgetAdd(mySpacer); } - m_widgetTitle = ewol::widget::Label::create("File chooser ..."); - if (nullptr == m_widgetTitle) { + m_widgetTitle = ewol::widget::Label::create(TRANSLATE(propertyLabelTitle)); + if (m_widgetTitle == nullptr) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { - m_widgetTitle->setExpand(bvec2(true,false)); + m_widgetTitle->propertyExpand.set(bvec2(true,false)); mySizerVert->subWidgetAdd(m_widgetTitle); } } @@ -183,12 +184,13 @@ void ewol::widget::Parameter::init() { ewol::widget::Parameter::~Parameter() { } - -void ewol::widget::Parameter::setTitle(std::string _label) { - if (nullptr == m_widgetTitle) { - return; +void ewol::widget::Parameter::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { + ewol::widget::PopUp::onPropertyChangeValue(_paramPointer); + if (_paramPointer == propertyLabelTitle) { + if (m_widgetTitle != nullptr) { + m_widgetTitle->propertyValue.set(TRANSLATE(propertyLabelTitle)); + } } - m_widgetTitle->setLabel(_label); } void ewol::widget::Parameter::onCallbackMenuclosed() { @@ -220,7 +222,7 @@ void ewol::widget::Parameter::menuAdd(std::string _label, std::string _image, st if (nullptr == myLabel) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { - myLabel->setExpand(bvec2(true,true)); + myLabel->propertyExpand.set(bvec2(true,true)); m_wSlider->subWidgetAdd(myLabel); } } diff --git a/ewol/widget/meta/Parameter.h b/ewol/widget/meta/Parameter.h index 61eaa42e..9e4bd018 100644 --- a/ewol/widget/meta/Parameter.h +++ b/ewol/widget/meta/Parameter.h @@ -27,6 +27,8 @@ namespace ewol { class Parameter : public ewol::widget::PopUp { public: // signals esignal::Signal signalClose; + public: // properties + eproperty::Value propertyLabelTitle; protected: Parameter(); void init(); @@ -34,7 +36,6 @@ namespace ewol { DECLARE_WIDGET_FACTORY(Parameter, "Parameter"); virtual ~Parameter(); public: - void setTitle(std::string _label); void menuAdd(std::string _label, std::string _image, std::shared_ptr _associateWidget); void menuAddGroup(std::string _label); void menuClear(); @@ -48,6 +49,7 @@ namespace ewol { void onCallbackMenuclosed(); void onCallbackParameterSave(); void onCallbackMenuSelected(const int32_t& _value); + virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); }; }; }; diff --git a/ewol/widget/meta/ParameterList.cpp b/ewol/widget/meta/ParameterList.cpp index 901ba662..d8e4742c 100644 --- a/ewol/widget/meta/ParameterList.cpp +++ b/ewol/widget/meta/ParameterList.cpp @@ -30,11 +30,11 @@ ewol::widget::ParameterList::ParameterList() : #else m_paddingSizeY = 2; #endif - setCanHaveFocus(true); } void ewol::widget::ParameterList::init() { ewol::widget::WidgetScrolled::init(); + propertyCanFocus.set(true); } ewol::widget::ParameterList::~ParameterList() { //clean all the object diff --git a/ewol/widget/meta/SpinBase.cpp b/ewol/widget/meta/SpinBase.cpp index fda06094..c5942212 100644 --- a/ewol/widget/meta/SpinBase.cpp +++ b/ewol/widget/meta/SpinBase.cpp @@ -19,35 +19,29 @@ void ewol::widget::SpinBase::init(ewol::widget::Manager& _widgetManager) { } ewol::widget::SpinBase::SpinBase() : + propertyShape(*this, "shape", "", "shape for the display"), + propertySpinMode(*this, "mode", ewol::widget::spinPosition_RightRight, "The display spin mode"), m_confIdEntryShaper(-1), m_confIdUpShaper(-1), m_confIdDownShaper(-1), m_confIdUpData(-1), - m_confIdDownData(-1), - m_spinMode(*this, "mode", ewol::widget::spinPosition_RightRight, "The display spin mode") { + m_confIdDownData(-1) { addObjectType("ewol::widget::SpinBase"); - m_spinMode.add(ewol::widget::spinPosition_noneNone, "none-none"); - m_spinMode.add(ewol::widget::spinPosition_noneRight, "none-right"); - m_spinMode.add(ewol::widget::spinPosition_leftNone, "left-none"); - m_spinMode.add(ewol::widget::spinPosition_leftRight, "left-right"); - m_spinMode.add(ewol::widget::spinPosition_leftLeft, "left-left"); - m_spinMode.add(ewol::widget::spinPosition_RightRight, "right-right"); + propertySpinMode.add(ewol::widget::spinPosition_noneNone, "none-none"); + propertySpinMode.add(ewol::widget::spinPosition_noneRight, "none-right"); + propertySpinMode.add(ewol::widget::spinPosition_leftNone, "left-none"); + propertySpinMode.add(ewol::widget::spinPosition_leftRight, "left-right"); + propertySpinMode.add(ewol::widget::spinPosition_leftLeft, "left-left"); + propertySpinMode.add(ewol::widget::spinPosition_RightRight, "right-right"); } void ewol::widget::SpinBase::init(enum ewol::widget::spinPosition _mode, const std::string& _shaperName) { ewol::widget::Sizer::init(ewol::widget::Sizer::modeHori); - lockExpand(bvec2(true,true)); - m_config = ewol::resource::ConfigFile::create(_shaperName); - if (m_config != nullptr) { - m_confIdEntryShaper = m_config->request("entry-shaper"); - m_confIdUpShaper = m_config->request("up-shaper"); - m_confIdDownShaper = m_config->request("down-shaper"); - m_confIdUpData = m_config->request("up-data"); - m_confIdDownData = m_config->request("down-data"); - } - m_spinMode = _mode; - setGravity(gravity_center); + propertyLockExpand.set(bvec2(true,true)); + propertyShape.set(_shaperName); + propertySpinMode = _mode; + propertyGravity.set(gravity_center); updateGui(); } @@ -57,8 +51,18 @@ ewol::widget::SpinBase::~SpinBase() { void ewol::widget::SpinBase::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { ewol::widget::Sizer::onPropertyChangeValue(_paramPointer); - if (_paramPointer == m_spinMode) { + if (_paramPointer == propertySpinMode) { updateGui(); + } else if (_paramPointer == propertyShape) { + m_config = ewol::resource::ConfigFile::create(propertyShape); + if (m_config != nullptr) { + m_confIdEntryShaper = m_config->request("entry-shaper"); + m_confIdUpShaper = m_config->request("up-shaper"); + m_confIdDownShaper = m_config->request("down-shaper"); + m_confIdUpData = m_config->request("up-data"); + m_confIdDownData = m_config->request("down-data"); + } + markToRedraw(); } } @@ -77,8 +81,8 @@ void ewol::widget::SpinBase::updateGui() { } m_widgetEntry = ewol::widget::Entry::create("", shaper); if (m_widgetEntry != nullptr) { - m_widgetEntry->setExpand(bvec2(true,false)); - m_widgetEntry->setFill(bvec2(true,true)); + m_widgetEntry->propertyExpand.set(bvec2(true,false)); + m_widgetEntry->propertyFill.set(bvec2(true,true)); } } if (m_widgetButtonDown == nullptr) { @@ -89,8 +93,8 @@ void ewol::widget::SpinBase::updateGui() { } m_widgetButtonDown = ewol::widget::Button::create(shaper); if (m_widgetButtonDown != nullptr) { - m_widgetButtonDown->setExpand(bvec2(false,false)); - m_widgetButtonDown->setFill(bvec2(true,true)); + m_widgetButtonDown->propertyExpand.set(bvec2(false,false)); + m_widgetButtonDown->propertyFill.set(bvec2(true,true)); std::string data = m_config->getString(m_confIdDownData); std::shared_ptr widget = ewol::widget::composerGenerate(ewol::widget::Composer::String, data); m_widgetButtonDown->setSubWidget(widget); @@ -104,15 +108,15 @@ void ewol::widget::SpinBase::updateGui() { } m_widgetButtonUp = ewol::widget::Button::create(shaper); if (m_widgetButtonUp != nullptr) { - m_widgetButtonUp->setExpand(bvec2(false,false)); - m_widgetButtonUp->setFill(bvec2(true,true)); + m_widgetButtonUp->propertyExpand.set(bvec2(false,false)); + m_widgetButtonUp->propertyFill.set(bvec2(true,true)); std::string data = m_config->getString(m_confIdUpData); std::shared_ptr widget = ewol::widget::composerGenerate(ewol::widget::Composer::String, data); m_widgetButtonUp->setSubWidget(widget); } } EWOL_INFO("add ...."); - switch (m_spinMode) { + switch (propertySpinMode) { case ewol::widget::spinPosition_noneNone: EWOL_INFO("add Entry"); subWidgetAdd(m_widgetEntry); diff --git a/ewol/widget/meta/SpinBase.h b/ewol/widget/meta/SpinBase.h index 3493b981..dfc93008 100644 --- a/ewol/widget/meta/SpinBase.h +++ b/ewol/widget/meta/SpinBase.h @@ -62,7 +62,8 @@ namespace ewol { */ class SpinBase : public ewol::widget::Sizer { public: // properties list: - eproperty::List m_spinMode; //!< How to display the spin base + eproperty::Value propertyShape; //!< Shape of the widget + eproperty::List propertySpinMode; //!< How to display the spin base public: /** * @brief Main call of recording the widget on the List of "widget named creator" diff --git a/ewol/widget/meta/StdPopUp.cpp b/ewol/widget/meta/StdPopUp.cpp index 43929ed8..4f16bbe7 100644 --- a/ewol/widget/meta/StdPopUp.cpp +++ b/ewol/widget/meta/StdPopUp.cpp @@ -21,11 +21,11 @@ ewol::widget::StdPopUp::StdPopUp() : m_comment(nullptr), m_subBar(nullptr) { addObjectType("ewol::widget::StdPopUp"); - setMinSize(gale::Dimension(vec2(20,10),gale::Dimension::Pourcent)); } void ewol::widget::StdPopUp::init() { ewol::widget::PopUp::init(); + propertyMinSize.set(gale::Dimension(vec2(20,10),gale::Dimension::Pourcent)); std::shared_ptr mySizerVert; std::shared_ptr mySpacer; @@ -34,42 +34,42 @@ void ewol::widget::StdPopUp::init() { setSubWidget(mySizerVert); m_subBar = ewol::widget::Sizer::create(widget::Sizer::modeHori); - m_subBar->lockExpand(bvec2(true,true)); - m_subBar->setExpand(bvec2(true,false)); + m_subBar->propertyLockExpand.set(bvec2(true,true)); + m_subBar->propertyExpand.set(bvec2(true,false)); mySizerVert->subWidgetAdd(m_subBar); mySpacer = ewol::widget::Spacer::create(); - mySpacer->setExpand(bvec2(true,false)); + mySpacer->propertyExpand.set(bvec2(true,false)); m_subBar->subWidgetAdd(mySpacer); mySpacer = ewol::widget::Spacer::create(); - mySpacer->setExpand(bvec2(true,false)); - mySpacer->setColor(etk::Color<>(0x88, 0x88, 0x88, 0xFF)); - mySpacer->setMinSize(gale::Dimension(vec2(0,3),gale::Dimension::Pixel)); + mySpacer->propertyExpand.set(bvec2(true,false)); + mySpacer->propertyColor.set(etk::Color<>(0x88, 0x88, 0x88, 0xFF)); + mySpacer->propertyMinSize.set(gale::Dimension(vec2(0,3),gale::Dimension::Pixel)); mySizerVert->subWidgetAdd(mySpacer); mySpacer = ewol::widget::Spacer::create(); - mySpacer->setExpand(bvec2(true,false)); - mySpacer->setMinSize(gale::Dimension(vec2(0,5),gale::Dimension::Pixel)); + mySpacer->propertyExpand.set(bvec2(true,false)); + mySpacer->propertyMinSize.set(gale::Dimension(vec2(0,5),gale::Dimension::Pixel)); mySizerVert->subWidgetAdd(mySpacer); m_comment = ewol::widget::Label::create("No Label"); - m_comment->setExpand(bvec2(true,true)); + m_comment->propertyExpand.set(bvec2(true,true)); mySizerVert->subWidgetAdd(m_comment); mySpacer = ewol::widget::Spacer::create(); - mySpacer->setExpand(bvec2(true,false)); - mySpacer->setMinSize(gale::Dimension(vec2(0,5),gale::Dimension::Pixel)); + mySpacer->propertyExpand.set(bvec2(true,false)); + mySpacer->propertyMinSize.set(gale::Dimension(vec2(0,5),gale::Dimension::Pixel)); mySizerVert->subWidgetAdd(mySpacer); mySpacer = ewol::widget::Spacer::create(); - mySpacer->setExpand(bvec2(true,false)); - mySpacer->setColor(etk::Color<>(0x88, 0x88, 0x88, 0xFF)); - mySpacer->setMinSize(gale::Dimension(vec2(0,3),gale::Dimension::Pixel)); + mySpacer->propertyExpand.set(bvec2(true,false)); + mySpacer->propertyColor.set(etk::Color<>(0x88, 0x88, 0x88, 0xFF)); + mySpacer->propertyMinSize.set(gale::Dimension(vec2(0,3),gale::Dimension::Pixel)); mySizerVert->subWidgetAdd(mySpacer); m_title = ewol::widget::Label::create("Message"); - m_title->setExpand(bvec2(true,false)); - m_title->setFill(bvec2(true,true)); + m_title->propertyExpand.set(bvec2(true,false)); + m_title->propertyFill.set(bvec2(true,true)); mySizerVert->subWidgetAdd(m_title); } @@ -81,7 +81,7 @@ void ewol::widget::StdPopUp::setTitle(const std::string& _text) { if (m_title == nullptr) { return; } - m_title->setLabel(_text); + m_title->propertyValue.set(_text); markToRedraw(); } @@ -89,7 +89,7 @@ void ewol::widget::StdPopUp::setComment(const std::string& _text) { if (m_comment == nullptr) { return; } - m_comment->setLabel(_text); + m_comment->propertyValue.set(_text); markToRedraw(); } diff --git a/ewol/widget/meta/StdPopUp.h b/ewol/widget/meta/StdPopUp.h index 12964686..c75fe496 100644 --- a/ewol/widget/meta/StdPopUp.h +++ b/ewol/widget/meta/StdPopUp.h @@ -38,6 +38,8 @@ namespace ewol { * [/pre] */ class StdPopUp : public ewol::widget::PopUp { + public: // properties: + // TODO: ... protected: /** * @brief std-pop-up constructor. diff --git a/lutin_ewol-tools-visual-test.py b/lutin_ewol-tools-visual-test.py index b0e8dc28..abec301e 100755 --- a/lutin_ewol-tools-visual-test.py +++ b/lutin_ewol-tools-visual-test.py @@ -31,12 +31,6 @@ def create(target, module_name): 'tools/visual_test/appl/debug.cpp', 'tools/visual_test/appl/init.cpp', 'tools/visual_test/appl/MainWindows.cpp', - 'tools/visual_test/appl/widget/SizerColor.cpp', - 'tools/visual_test/appl/TestButton.cpp', - 'tools/visual_test/appl/TestCheckBox.cpp', - 'tools/visual_test/appl/TestImage.cpp', - 'tools/visual_test/appl/TestButtonColor.cpp', - 'tools/visual_test/appl/TestLabel.cpp', 'tools/visual_test/appl/TestDistanceField.cpp' ]) diff --git a/tools/visual_test/appl/MainWindows.cpp b/tools/visual_test/appl/MainWindows.cpp index 29bc8657..d43ccae9 100644 --- a/tools/visual_test/appl/MainWindows.cpp +++ b/tools/visual_test/appl/MainWindows.cpp @@ -25,11 +25,6 @@ #include #include #include -#include -#include -#include -#include -#include #include #include #include @@ -190,11 +185,11 @@ void appl::MainWindows::onCallbackWidgetChange(int32_t _increment) { static void addSpacer(const std::shared_ptr& _sizer, etk::Color<> _color=etk::color::none) { std::shared_ptr mySpacer = ewol::widget::Spacer::create(); if (mySpacer != nullptr) { - mySpacer->setExpand(bvec2(true,false)); - mySpacer->setFill(bvec2(true,false)); + mySpacer->propertyExpand.set(bvec2(true,false)); + mySpacer->propertyFill.set(bvec2(true,false)); if (_color == etk::color::none) { - mySpacer->setMinSize(vec2(3,3)); - mySpacer->setColor(_color); + mySpacer->propertyMinSize.set(vec2(3,3)); + mySpacer->propertyColor.set(_color); } _sizer->subWidgetAdd(mySpacer); } @@ -217,8 +212,8 @@ void appl::MainWindows::updateProperty() { } std::shared_ptr widgetSizer = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori); if (widgetSizer != nullptr) { - widgetSizer->setExpand(bvec2(true,false)); - widgetSizer->setFill(bvec2(true,true)); + widgetSizer->propertyExpand.set(bvec2(true,false)); + widgetSizer->propertyFill.set(bvec2(true,true)); m_sizerDynamic->subWidgetAddStart(widgetSizer); std::shared_ptr widget = ewol::widget::Label::create(param->getName() + ":"); @@ -236,9 +231,9 @@ void appl::MainWindows::updateProperty() { return; } std::string value = paramValue->get(); - widgetTmp->setValue(value); - widgetTmp->setExpand(bvec2(true,false)); - widgetTmp->setFill(bvec2(true,false)); + widgetTmp->propertyValue.set(value); + widgetTmp->propertyExpand.set(bvec2(true,false)); + widgetTmp->propertyFill.set(bvec2(true,false)); widgetTmp->signalModify.connect([=](const std::string& _value) { APPL_INFO("set parameter : NAME name=" << param->getName() << " value=" << _value); paramValue->set(_value); @@ -257,7 +252,7 @@ void appl::MainWindows::updateProperty() { return; } bvec2 value = paramValue->get(); - widgetTmp->setValue(value.x()); + widgetTmp->propertyValue.set(value.x()); widgetTmp->signalValue.connect([=](const bool& _value) { APPL_INFO("set parameter : X name=" << param->getName() << " value=" << _value); bvec2 lastValueInterpreted = paramValue->get(); @@ -270,7 +265,7 @@ void appl::MainWindows::updateProperty() { widgetTmp = ewol::widget::CheckBox::create(); widgetSizer->subWidgetAdd(widgetTmp); - widgetTmp->setValue(value.y()); + widgetTmp->propertyValue.set(value.y()); widgetTmp->signalValue.connect([=](const bool& _value) { APPL_INFO("set parameter : Y name=" << param->getName() << " value=" << _value); bvec2 lastValueInterpreted = paramValue->get(); @@ -311,9 +306,9 @@ void appl::MainWindows::updateProperty() { widgetSizer->subWidgetAdd(widgetTmp); eproperty::Property* param = m_subWidget->getPropertyRaw(iii); std::string value = param->getString(); - widgetTmp->setValue(value); - widgetTmp->setExpand(bvec2(true,false)); - widgetTmp->setFill(bvec2(true,false)); + widgetTmp->propertyValue.set(value); + widgetTmp->propertyExpand.set(bvec2(true,false)); + widgetTmp->propertyFill.set(bvec2(true,false)); widgetTmp->signalModify.connect([=](const std::string& _value) { APPL_INFO("set parameter : NAME name=" << param->getName() << " value=" << _value); param->setString(_value); @@ -344,8 +339,8 @@ void appl::MainWindows::updateProperty() { type = "enum ewol::gravity"; std::shared_ptr widgetTmp = ewol::widget::Select::create(); widgetSizer->subWidgetAdd(widgetTmp); - widgetTmp->setExpand(bvec2(true,false)); - widgetTmp->setFill(bvec2(true,false)); + widgetTmp->propertyExpand.set(bvec2(true,false)); + widgetTmp->propertyFill.set(bvec2(true,false)); widgetTmp->optionAdd(int32_t(ewol::gravity_center), "Center"); widgetTmp->optionAdd(int32_t(ewol::gravity_top), "Top"); widgetTmp->optionAdd(int32_t(ewol::gravity_buttom), "Buttom"); @@ -362,7 +357,7 @@ void appl::MainWindows::updateProperty() { return; } ewol::gravity value = paramValue->get(); - widgetTmp->setValue(value); + widgetTmp->propertyValue.set(value); widgetTmp->signalValue.connect([=](const int32_t& _value) { enum ewol::gravity val = ewol::gravity(_value); APPL_INFO("set parameter: gravity name=" << param->getName() << " value=" << val); @@ -373,10 +368,10 @@ void appl::MainWindows::updateProperty() { } std::shared_ptr mySpacer = ewol::widget::Spacer::create(); if (mySpacer != nullptr) { - mySpacer->setExpand(bvec2(true,false)); - mySpacer->setFill(bvec2(true,false)); - mySpacer->setMinSize(vec2(3,3)); - mySpacer->setColor(etk::color::blue); + mySpacer->propertyExpand.set(bvec2(true,false)); + mySpacer->propertyFill.set(bvec2(true,false)); + mySpacer->propertyMinSize.set(vec2(3,3)); + mySpacer->propertyColor.set(etk::color::blue); m_sizerDynamic->subWidgetAddStart(mySpacer); } } diff --git a/tools/visual_test/appl/TestButton.cpp b/tools/visual_test/appl/TestButton.cpp deleted file mode 100644 index a30af681..00000000 --- a/tools/visual_test/appl/TestButton.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef __class__ -#define __class__ "TestButton" - -appl::TestButton::TestButton() { - addObjectType("appl::TestButton"); -} - -void appl::TestButton::init() { - ewol::widget::Composer::init(); - APPL_INFO("Create " __class__ " (start)"); - - std::string myDescription = std::string("") - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + ""; - loadFromString(myDescription); - setExpand(bvec2(true,true)); - setFill(bvec2(true,true)); - subBind(ewol::widget::Button, "[TEST]Button:Expand-x", signalValue, shared_from_this(), &appl::TestButton::onCallbackExpendX); - subBind(ewol::widget::Button, "[TEST]Button:Expand-y", signalValue, shared_from_this(), &appl::TestButton::onCallbackExpendY); - subBind(ewol::widget::Button, "[TEST]Button:Toggle", signalValue, shared_from_this(), &appl::TestButton::onCallbackToggle); - subBind(ewol::widget::Button, "[TEST]Button:TextToggle", signalValue, shared_from_this(), &appl::TestButton::onCallbackTextToggle); - subBind(ewol::widget::Button, "[TEST]Button:Fill-x", signalValue, shared_from_this(), &appl::TestButton::onCallbackFillX); - subBind(ewol::widget::Button, "[TEST]Button:Fill-y", signalValue, shared_from_this(), &appl::TestButton::onCallbackFillY); - subBind(ewol::widget::Button, "[TEST]Button:ChangeText", signalPressed, shared_from_this(), &appl::TestButton::onCallbackChangeText); - m_testWidget = std::dynamic_pointer_cast(getSubObjectNamed("[TEST]Button:TO-TEST")); - if (m_testWidget == nullptr) { - APPL_CRITICAL("Can not get the pointer of the widget button pointer"); - } - APPL_INFO("Create " __class__ " (end)"); -} - - - -void appl::TestButton::onCallbackExpendX(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setExpand(bvec2(_value, m_testWidget->getExpand().y())); -} - -void appl::TestButton::onCallbackExpendY(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setExpand(bvec2(m_testWidget->getExpand().x(), _value)); -} - -void appl::TestButton::onCallbackFillX(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setFill(bvec2(_value, m_testWidget->getFill().y())); -} - -void appl::TestButton::onCallbackFillY(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setFill(bvec2(m_testWidget->getFill().x(), _value)); -} - -void appl::TestButton::onCallbackToggle(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setToggleMode(_value); -} - -void appl::TestButton::onCallbackTextToggle(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - if (_value == true) { - m_testWidget->setSubWidgetToggle(ewol::widget::Label::create("A stupid very long text on toggle

and on multiple lines")); - } else { - m_testWidget->setSubWidgetToggle(nullptr); - } -} - -void appl::TestButton::onCallbackChangeText() { - if (m_testWidget == nullptr) { - return; - } - static int32_t countTextID = 1; - switch (countTextID) { - case 0: - m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text")); - break; - case 1: - m_testWidget->setSubWidget(ewol::widget::Label::create("Align Left")); - break; - case 2: - m_testWidget->setSubWidget(ewol::widget::Label::create("Align right")); - break; - case 3: - m_testWidget->setSubWidget(ewol::widget::Label::create("
Align center
")); - break; - case 4: - m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text
With Some Other Lines
and more if you want ...
plop")); - break; - case 5: - m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with bold")); - break; - case 6: - m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with italic")); - break; - case 7: - m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with italic bold")); - break; - case 8: - m_testWidget->setSubWidget(nullptr); - break; - case 9: - m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with colored text")); - break; - case 10: - m_testWidget->setSubWidget(ewol::widget::Composer::create(ewol::widget::Composer::String, "\n")); - break; - case 11: - m_testWidget->setSubWidget(ewol::widget::Composer::create(ewol::widget::Composer::String, - " \n" - " \n" - " \n" - " \n")); - break; - case 12: - m_testWidget->setSubWidget(ewol::widget::Composer::create(ewol::widget::Composer::String, "\n")); - break; - default: - m_testWidget->setSubWidget(ewol::widget::Label::create("My Button
And Some under line
plop
and an other super long line ...")); - countTextID=-1; - break; - } - // set at the subWidget all the space they can ... - if (m_testWidget->getSubWidget() != nullptr){ - m_testWidget->getSubWidget()->setFill(bvec2(true,true)); - m_testWidget->getSubWidget()->setExpand(bvec2(true,true)); - } - countTextID++; -} - diff --git a/tools/visual_test/appl/TestButton.h b/tools/visual_test/appl/TestButton.h deleted file mode 100644 index 8b18e961..00000000 --- a/tools/visual_test/appl/TestButton.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ -#pragma once - -#include -#include -#include -namespace appl { - class TestButton : public ewol::widget::Composer { - private: - std::shared_ptr m_testWidget; - public: - // Constructeur - TestButton(); - void init(); - public: - DECLARE_FACTORY(TestButton); - protected: - void onCallbackExpendX(const bool& _value); - void onCallbackExpendY(const bool& _value); - void onCallbackFillX(const bool& _value); - void onCallbackFillY(const bool& _value); - void onCallbackToggle(const bool& _value); - void onCallbackTextToggle(const bool& _value); - void onCallbackChangeText(); - }; -} diff --git a/tools/visual_test/appl/TestButtonColor.cpp b/tools/visual_test/appl/TestButtonColor.cpp deleted file mode 100644 index 21f67189..00000000 --- a/tools/visual_test/appl/TestButtonColor.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -static const char * l_eventChangeExpendX = "event-change-expend-X"; -static const char * l_eventChangeExpendY = "event-change-expend-Y"; -static const char * l_eventChangeFillX = "event-change-fill-X"; -static const char * l_eventChangeFillY = "event-change-fill-Y"; - -#undef __class__ -#define __class__ "TestButton" - -appl::TestButtonColor::TestButtonColor() { - addObjectType("appl::TestButtonColor"); -} - -void appl::TestButtonColor::init() { - ewol::widget::Composer::init(); - - APPL_INFO("Create " __class__ " (start)"); - - std::string myDescription = std::string("") - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + ""; - loadFromString(myDescription); - setExpand(bvec2(true,true)); - setFill(bvec2(true,true)); - subBind(ewol::widget::Button, "[TEST]Button:Expand-x", signalValue, shared_from_this(), &appl::TestButtonColor::onCallbackExpendX); - subBind(ewol::widget::Button, "[TEST]Button:Expand-y", signalValue, shared_from_this(), &appl::TestButtonColor::onCallbackExpendY); - subBind(ewol::widget::Button, "[TEST]Button:Fill-x", signalValue, shared_from_this(), &appl::TestButtonColor::onCallbackFillX); - subBind(ewol::widget::Button, "[TEST]Button:Fill-y", signalValue, shared_from_this(), &appl::TestButtonColor::onCallbackFillY); - m_testWidget = std::dynamic_pointer_cast(getSubObjectNamed("[TEST]TO-TEST")); - if (m_testWidget == nullptr) { - APPL_CRITICAL("Can not get the pointer of the widget button pointer"); - } - m_testWidget->signalChange.bind(shared_from_this(), &appl::TestButtonColor::onCallbackChangeColor); - APPL_INFO("Create " __class__ " (end)"); -} - -void appl::TestButtonColor::onCallbackExpendX(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setExpand(bvec2(_value, m_testWidget->getExpand().y())); -} - -void appl::TestButtonColor::onCallbackExpendY(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setExpand(bvec2(m_testWidget->getExpand().x(), _value)); -} - -void appl::TestButtonColor::onCallbackFillX(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setFill(bvec2(_value, m_testWidget->getFill().y())); -} - -void appl::TestButtonColor::onCallbackFillY(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setFill(bvec2(m_testWidget->getFill().x(), _value)); -} - -void appl::TestButtonColor::onCallbackChangeColor(const etk::Color<>& _value) { - if (m_testWidget == nullptr) { - return; - } - APPL_WARNING("Color change: " << _value); -} diff --git a/tools/visual_test/appl/TestButtonColor.h b/tools/visual_test/appl/TestButtonColor.h deleted file mode 100644 index d336e1fe..00000000 --- a/tools/visual_test/appl/TestButtonColor.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace appl { - class TestButtonColor : public ewol::widget::Composer { - private: - std::shared_ptr m_testWidget; - public: - // Constructeur - TestButtonColor(); - void init(); - public: - DECLARE_FACTORY(TestButtonColor); - virtual ~TestButtonColor() {}; - protected: - void onCallbackExpendX(const bool& _value); - void onCallbackExpendY(const bool& _value); - void onCallbackFillX(const bool& _value); - void onCallbackFillY(const bool& _value); - void onCallbackChangeColor(const etk::Color<>& _value); - }; -} - diff --git a/tools/visual_test/appl/TestCheckBox.cpp b/tools/visual_test/appl/TestCheckBox.cpp deleted file mode 100644 index 4e9c7b87..00000000 --- a/tools/visual_test/appl/TestCheckBox.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef __class__ -#define __class__ "TestCheckBox" - -appl::TestCheckBox::TestCheckBox() { - addObjectType("appl::TestCheckBox"); -} - -void appl::TestCheckBox::init() { - ewol::widget::Composer::init(); - - APPL_INFO("Create " __class__ " (start)"); - - std::string myDescription = std::string("") - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + ""; - loadFromString(myDescription); - setExpand(bvec2(true,true)); - setFill(bvec2(true,true)); - subBind(ewol::widget::Button, "[TEST]Button:Expand-x", signalValue, shared_from_this(), &appl::TestCheckBox::onCallbackExpendX); - subBind(ewol::widget::Button, "[TEST]Button:Expand-y", signalValue, shared_from_this(), &appl::TestCheckBox::onCallbackExpendY); - subBind(ewol::widget::Button, "[TEST]Button:Fill-x", signalValue, shared_from_this(), &appl::TestCheckBox::onCallbackFillX); - subBind(ewol::widget::Button, "[TEST]Button:Fill-y", signalValue, shared_from_this(), &appl::TestCheckBox::onCallbackFillY); - subBind(ewol::widget::Button, "[TEST]Button:TextToggle", signalValue, shared_from_this(), &appl::TestCheckBox::onCallbackTextToggle); - subBind(ewol::widget::Button, "[TEST]Button:ChangeText", signalPressed, shared_from_this(), &appl::TestCheckBox::onCallbackChangeText); - m_testWidget = std::dynamic_pointer_cast(getSubObjectNamed("[TEST]TO-TEST")); - if (m_testWidget == nullptr) { - APPL_CRITICAL("Can not get the pointer of the widget button pointer"); - } - APPL_INFO("Create " __class__ " (end)"); -} - -void appl::TestCheckBox::onCallbackExpendX(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setExpand(bvec2(_value, m_testWidget->getExpand().y())); -} - -void appl::TestCheckBox::onCallbackExpendY(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setExpand(bvec2(m_testWidget->getExpand().x(), _value)); -} - -void appl::TestCheckBox::onCallbackFillX(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setFill(bvec2(_value, m_testWidget->getFill().y())); -} - -void appl::TestCheckBox::onCallbackFillY(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setFill(bvec2(m_testWidget->getFill().x(), _value)); -} - -void appl::TestCheckBox::onCallbackTextToggle(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - if (_value == true) { - m_testWidget->setSubWidgetToggle(ewol::widget::Label::create("A stupid very long text on toggle

and on multiple lines")); - } else { - m_testWidget->setSubWidgetToggle(nullptr); - } -} - -void appl::TestCheckBox::onCallbackChangeText() { - if (m_testWidget == nullptr) { - return; - } - static int32_t countTextID = 1; - switch (countTextID) { - case 0: - m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text")); - break; - case 1: - m_testWidget->setSubWidget(ewol::widget::Label::create("Align Left")); - break; - case 2: - m_testWidget->setSubWidget(ewol::widget::Label::create("Align right")); - break; - case 3: - m_testWidget->setSubWidget(ewol::widget::Label::create("
Align center
")); - break; - case 4: - m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text
With Some Other Lines
and more if you want ...
plop")); - break; - case 5: - m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with bold")); - break; - case 6: - m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with italic")); - break; - case 7: - m_testWidget->setSubWidget(ewol::widget::Label::create("simple Text with italic bold")); - break; - case 8: - m_testWidget->setSubWidget(nullptr); - countTextID=-1; - break; - } - // set at the subWidget all the space they can ... - if (m_testWidget->getSubWidget() != nullptr){ - m_testWidget->getSubWidget()->setFill(bvec2(true,true)); - m_testWidget->getSubWidget()->setExpand(bvec2(true,true)); - } - countTextID++; -} - - - diff --git a/tools/visual_test/appl/TestCheckBox.h b/tools/visual_test/appl/TestCheckBox.h deleted file mode 100644 index 99464c94..00000000 --- a/tools/visual_test/appl/TestCheckBox.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ -#pragma once - -#include -#include -#include - -namespace appl { - class TestCheckBox : public ewol::widget::Composer { - private: - std::shared_ptr m_testWidget; - public: - // Constructeur - TestCheckBox(); - void init(); - public: - DECLARE_FACTORY(TestCheckBox); - protected: - void onCallbackExpendX(const bool& _value); - void onCallbackExpendY(const bool& _value); - void onCallbackFillX(const bool& _value); - void onCallbackFillY(const bool& _value); - void onCallbackTextToggle(const bool& _value); - void onCallbackChangeText(); - }; -} - - diff --git a/tools/visual_test/appl/TestDistanceField.cpp b/tools/visual_test/appl/TestDistanceField.cpp index 66e605dd..fa2cc1ea 100644 --- a/tools/visual_test/appl/TestDistanceField.cpp +++ b/tools/visual_test/appl/TestDistanceField.cpp @@ -35,8 +35,8 @@ appl::TestDistanceField::TestDistanceField(){ void appl::TestDistanceField::init() { ewol::Widget::init(); APPL_INFO("Create " __class__ " (start)"); - setExpand(bvec2(true, true)); - setFill(bvec2(true, true)); + propertyExpand.set(bvec2(true, true)); + propertyFill.set(bvec2(true, true)); APPL_INFO("Create " __class__ " (end)"); } diff --git a/tools/visual_test/appl/TestEntry.cpp b/tools/visual_test/appl/TestEntry.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/tools/visual_test/appl/TestEntry.h b/tools/visual_test/appl/TestEntry.h deleted file mode 100644 index e69de29b..00000000 diff --git a/tools/visual_test/appl/TestImage.cpp b/tools/visual_test/appl/TestImage.cpp deleted file mode 100644 index 6730ba65..00000000 --- a/tools/visual_test/appl/TestImage.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef __class__ -#define __class__ "TestImage" - -appl::TestImage::TestImage() { - addObjectType("appl::TestImage"); -} -void appl::TestImage::init() { - ewol::widget::Composer::init(); - - APPL_INFO("Create " __class__ " (start)"); - - std::string myDescription = std::string("") - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + ""; - loadFromString(myDescription); - setExpand(bvec2(true,true)); - setFill(bvec2(true,true)); - subBind(ewol::widget::Button, "[TEST]Button:Expand-x", signalValue, shared_from_this(), &appl::TestImage::onCallbackExpendX); - subBind(ewol::widget::Button, "[TEST]Button:Expand-y", signalValue, shared_from_this(), &appl::TestImage::onCallbackExpendY); - subBind(ewol::widget::Button, "[TEST]Button:Fill-x", signalValue, shared_from_this(), &appl::TestImage::onCallbackFillX); - subBind(ewol::widget::Button, "[TEST]Button:Fill-y", signalValue, shared_from_this(), &appl::TestImage::onCallbackFillY); - subBind(ewol::widget::Button, "[TEST]Button:ChangeImage", signalPressed, shared_from_this(), &appl::TestImage::onCallbackChangeImage); - m_testWidget = std::dynamic_pointer_cast(getSubObjectNamed("[TEST]TO-TEST")); - if (m_testWidget == nullptr) { - APPL_CRITICAL("Can not get the pointer of the widget button pointer"); - } - APPL_INFO("Create " __class__ " (end)"); -} - -void appl::TestImage::onCallbackExpendX(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setExpand(bvec2(_value, m_testWidget->getExpand().y())); -} - -void appl::TestImage::onCallbackExpendY(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setExpand(bvec2(m_testWidget->getExpand().x(), _value)); -} - -void appl::TestImage::onCallbackFillX(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setFill(bvec2(_value, m_testWidget->getFill().y())); -} - -void appl::TestImage::onCallbackFillY(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setFill(bvec2(m_testWidget->getFill().x(), _value)); -} - - -void appl::TestImage::onCallbackChangeImage() { - if (m_testWidget == nullptr) { - return; - } - static int32_t countID = 1; - switch (countID) { - case 0: - m_testWidget->setFile("DATA:stone.png"); - break; - case 1: - m_testWidget->setFile("DATA:grass.png"); - break; - default: - m_testWidget->setFile("DATA:sphere.png"); - countID=-1; - break; - } - countID++; -} - diff --git a/tools/visual_test/appl/TestImage.h b/tools/visual_test/appl/TestImage.h deleted file mode 100644 index 0beaa001..00000000 --- a/tools/visual_test/appl/TestImage.h +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace appl { - class TestImage : public ewol::widget::Composer { - private: - std::shared_ptr m_testWidget; - public: - // Constructeur - TestImage(); - void init(); - public: - DECLARE_FACTORY(TestImage); - virtual ~TestImage() {}; - protected: - void onCallbackExpendX(const bool& _value); - void onCallbackExpendY(const bool& _value); - void onCallbackFillX(const bool& _value); - void onCallbackFillY(const bool& _value); - void onCallbackChangeImage(); - }; -} - diff --git a/tools/visual_test/appl/TestLabel.cpp b/tools/visual_test/appl/TestLabel.cpp deleted file mode 100644 index e8531387..00000000 --- a/tools/visual_test/appl/TestLabel.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#undef __class__ -#define __class__ "TestButton" - -appl::TestLabel::TestLabel() { - addObjectType("appl::TestLabel"); -} - -void appl::TestLabel::init() { - ewol::widget::Composer::init(); - - APPL_INFO("Create " __class__ " (start)"); - - std::string myDescription = std::string("") - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + ""; - loadFromString(myDescription); - setExpand(bvec2(true,true)); - setFill(bvec2(true,true)); - subBind(ewol::widget::Button, "[TEST]Button:Expand-x", signalValue, shared_from_this(), &appl::TestLabel::onCallbackExpendX); - subBind(ewol::widget::Button, "[TEST]Button:Expand-y", signalValue, shared_from_this(), &appl::TestLabel::onCallbackExpendY); - subBind(ewol::widget::Button, "[TEST]Button:Fill-x", signalValue, shared_from_this(), &appl::TestLabel::onCallbackFillX); - subBind(ewol::widget::Button, "[TEST]Button:Fill-y", signalValue, shared_from_this(), &appl::TestLabel::onCallbackFillY); - subBind(ewol::widget::Button, "[TEST]Button:SetMaxSize", signalValue, shared_from_this(), &appl::TestLabel::onCallbackMaxSize); - subBind(ewol::widget::Button, "[TEST]Button:ChangeText", signalPressed, shared_from_this(), &appl::TestLabel::onCallbackChangeLabel); - m_testWidget = std::dynamic_pointer_cast(getSubObjectNamed("[TEST]TO-TEST")); - if (m_testWidget == nullptr) { - APPL_CRITICAL("Can not get the pointer of the widget button pointer"); - } - APPL_INFO("Create " __class__ " (end)"); -} - -void appl::TestLabel::onCallbackExpendX(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setExpand(bvec2(_value, m_testWidget->getExpand().y())); -} - -void appl::TestLabel::onCallbackExpendY(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setExpand(bvec2(m_testWidget->getExpand().x(), _value)); -} - -void appl::TestLabel::onCallbackFillX(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setFill(bvec2(_value, m_testWidget->getFill().y())); -} - -void appl::TestLabel::onCallbackFillY(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - m_testWidget->setFill(bvec2(m_testWidget->getFill().x(), _value)); -} - - -void appl::TestLabel::onCallbackMaxSize(const bool& _value) { - if (m_testWidget == nullptr) { - return; - } - if (_value == true) { - m_testWidget->setMaxSize(vec2(400,9999999999)); - } else { - m_testWidget->setNoMaxSize(); - } -} - -void appl::TestLabel::onCallbackChangeLabel() { - if (m_testWidget == nullptr) { - return; - } - m_labelId++; - switch(m_labelId) { - default: - m_labelId=0; - case 0: - m_testWidget->setLabel("Basic label"); - break; - case 1: - m_testWidget->setLabel("Basic label"); - break; - case 2: - m_testWidget->setLabel("
\n" - " Un jour Cosette se regarda par hasard dans son miroir et se dit: Tiens! Il lui semblait presque qu'elle à jolie. Ceci la jeta dans un trouble singulier. Jusqu'au moment elle n'avait point song figure. Elle se voyait dans son miroir, mais elle ne s'y regardait pas. Et puis, on lui avait souvent dit qu'elle à laide;
Jean Valjean seul disait doucement :
Mais non!
mais non!
Quoi qu'il en fut, Cosette toujours crue laide, et avait grandi dans cette id ec la réation facile de l'enfance. Voici que tout d'un coup son miroir lui disait comme Jean Valjean : Mais non! Elle ne dormit pas de la nuit. Si jolie ? pensait-elle, comme cela serait drole que je fusse jolie! Et elle se rappelait celles de ses compagnes dont la beauté sait effet dans le couvent, et elle se disait : Comment! je serais comme mademoiselle une telle!\n" - "
\n"); - break; - case 3: - m_testWidget->setLabel("\n" - " Un jour Cosette se regarda par hasard dans son miroir et se dit: Tiens! Il lui semblait presque qu'elle à jolie. Ceci la jeta dans un trouble singulier. Jusqu'au moment elle n'avait point song figure. Elle se voyait dans son miroir, mais elle ne s'y regardait pas. Et puis, on lui avait souvent dit qu'elle à laide;
Jean Valjean seul disait doucement :
Mais non!
mais non!
Quoi qu'il en fut, Cosette toujours crue laide, et avait grandi dans cette id ec la réation facile de l'enfance. Voici que tout d'un coup son miroir lui disait comme Jean Valjean : Mais non! Elle ne dormit pas de la nuit. Si jolie ? pensait-elle, comme cela serait drole que je fusse jolie! Et elle se rappelait celles de ses compagnes dont la beauté sait effet dans le couvent, et elle se disait : Comment! je serais comme mademoiselle une telle!\n" - "
\n"); - break; - case 4: - m_testWidget->setLabel("\n" - " Un jour Cosette se regarda par hasard dans son miroir et se dit: Tiens! Il lui semblait presque qu'elle à jolie. Ceci la jeta dans un trouble singulier. Jusqu'au moment elle n'avait point song figure. Elle se voyait dans son miroir, mais elle ne s'y regardait pas. Et puis, on lui avait souvent dit qu'elle à laide;
Jean Valjean seul disait doucement :
Mais non!
mais non!
Quoi qu'il en fut, Cosette toujours crue laide, et avait grandi dans cette id ec la réation facile de l'enfance. Voici que tout d'un coup son miroir lui disait comme Jean Valjean : Mais non! Elle ne dormit pas de la nuit. Si jolie ? pensait-elle, comme cela serait drole que je fusse jolie! Et elle se rappelait celles de ses compagnes dont la beauté sait effet dans le couvent, et elle se disait : Comment! je serais comme mademoiselle une telle!\n" - "
\n"); - break; - case 5: - m_testWidget->setLabel("\n" - " Un jour Cosette se regarda par hasard dans son miroir et se dit: Tiens! Il lui semblait presque qu'elle à jolie. Ceci la jeta dans un trouble singulier. Jusqu'au moment elle n'avait point song figure. Elle se voyait dans son miroir, mais elle ne s'y regardait pas. Et puis, on lui avait souvent dit qu'elle à laide;
Jean Valjean seul disait doucement :
Mais non!
mais non!
Quoi qu'il en fut, Cosette toujours crue laide, et avait grandi dans cette id ec la réation facile de l'enfance. Voici que tout d'un coup son miroir lui disait comme Jean Valjean : Mais non! Elle ne dormit pas de la nuit. Si jolie ? pensait-elle, comme cela serait drole que je fusse jolie! Et elle se rappelait celles de ses compagnes dont la beauté sait effet dans le couvent, et elle se disait : Comment! je serais comme mademoiselle une telle!\n" - "
\n"); - break; - } -} - diff --git a/tools/visual_test/appl/TestLabel.h b/tools/visual_test/appl/TestLabel.h deleted file mode 100644 index f4fc6738..00000000 --- a/tools/visual_test/appl/TestLabel.h +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace appl { - class TestLabel : public ewol::widget::Composer { - private: - std::shared_ptr m_testWidget; - int32_t m_labelId; - public: - /** - * @brief Constructeur - */ - TestLabel(); - void init(); - public: - DECLARE_FACTORY(TestLabel); - /** - * @brief Destructor - */ - virtual ~TestLabel() {}; - protected: - void onCallbackExpendX(const bool& _value); - void onCallbackExpendY(const bool& _value); - void onCallbackFillX(const bool& _value); - void onCallbackFillY(const bool& _value); - void onCallbackMaxSize(const bool& _value); - void onCallbackChangeLabel(); - }; -} - - diff --git a/tools/visual_test/appl/TestProgressBar.cpp b/tools/visual_test/appl/TestProgressBar.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/tools/visual_test/appl/TestProgressBar.h b/tools/visual_test/appl/TestProgressBar.h deleted file mode 100644 index e69de29b..00000000 diff --git a/tools/visual_test/appl/TestScene.cpp b/tools/visual_test/appl/TestScene.cpp deleted file mode 100644 index 11bf4d1b..00000000 --- a/tools/visual_test/appl/TestScene.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const char * l_eventAddBox = "event-add-box"; -static const char * l_eventAddSphere = "event-add-sphere"; -static const char * l_eventRotationX = "event-rotation-X"; -static const char * l_eventRotationY = "event-rotation-Y"; -static const char * l_eventRotationZ = "event-rotation-Z"; -static const char * l_eventRotation0 = "event-rotation-0"; -static const char * l_eventLunch = "event-lunch"; -static const char * l_eventChangeTimeSpeed4 = "event-speed4"; -static const char * l_eventChangeTimeSpeed2 = "event-speed2"; -static const char * l_eventChangeTimeSpeed0 = "event-speed0.5"; -static const char * l_eventChangeTimeSpeed1 = "event-speed1"; -static const char * l_eventUp = "event-up"; -static const char * l_eventDown = "event-down"; - - -#undef __class__ -#define __class__ "TestScene" - -TestScene::TestScene() : - ewol::widget::Sizer(ewol::widget::Sizer::modeVert) -{ - addObjectType("appl::TestScene"); - /* - m_ground = new game::Element("DATA:grass.obj"); - if (nullptr != m_ground) { - m_ground->SetStaticMode(true); - m_gameEngine.AddElement(m_ground); - } - */ - - APPL_CRITICAL("Create "__class__" (start)"); - std::shared_ptr mySizerVert2 = nullptr; - std::shared_ptr mySizerHori = nullptr; - std::shared_ptr myButton = nullptr; - /* - mySizerHori = new ewol::widget::SizerHori(); - if (nullptr == mySizerHori) { - APPL_DEBUG("Allocation error mySizerHori"); - return; - } - SubWidgetAdd(mySizerHori); - myButton = new ewol::widget::Button("Add Box"); - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventAddBox); - mySizerHori->SubWidgetAdd(myButton); - } - myButton = new ewol::widget::Button("Add Sphere"); - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventAddSphere); - mySizerHori->SubWidgetAdd(myButton); - } - myButton = new ewol::widget::Button("Rotation X"); - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventRotationX); - mySizerHori->SubWidgetAdd(myButton); - } - myButton = new ewol::widget::Button("Rotation Y"); = nullptr - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventRotationY); - mySizerHori->SubWidgetAdd(myButton); - } - myButton = new ewol::widget::Button("Rotation Z"); - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventRotationZ); - mySizerHori->SubWidgetAdd(myButton); - } - myButton = new ewol::widget::Button("Rotation -"); - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventRotation0); - mySizerHori->SubWidgetAdd(myButton); - } - myButton = new ewol::widget::Button("UP"); - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventUp); - mySizerHori->SubWidgetAdd(myButton); - } - myButton = new ewol::widget::Button("DOWN"); - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventDown); - mySizerHori->SubWidgetAdd(myButton); - } - mySizerHori = new ewol::widget::SizerHori(); - if (nullptr == mySizerHori) { - APPL_DEBUG("Allocation error mySizerHori"); - return; - } - SubWidgetAdd(mySizerHori); - myButton = new ewol::widget::Button("lunch object"); - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventLunch); - mySizerHori->SubWidgetAdd(myButton); - } - myButton = new ewol::widget::Button("1x speed"); - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventChangeTimeSpeed1); - mySizerHori->SubWidgetAdd(myButton); - } - myButton = new ewol::widget::Button("0.5x speed"); - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventChangeTimeSpeed0); - mySizerHori->SubWidgetAdd(myButton); - } - myButton = new ewol::widget::Button("2x speed"); - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventChangeTimeSpeed2); - mySizerHori->SubWidgetAdd(myButton); - } - myButton = new ewol::widget::Button("4x speed"); - if (nullptr != myButton) { - myButton->RegisterOnEvent(this, ewolEventButtonPressed, l_eventChangeTimeSpeed4); - mySizerHori->SubWidgetAdd(myButton); - } - */ - std::shared_ptr mySpacer = new widget::Spacer(); - if (nullptr != mySpacer) { - mySpacer->setExpand(bvec2(false,false)); - mySpacer->setFill(bvec2(true,false)); - mySpacer->setMinSize(vec2(10,10)); - mySpacer->setColor(0xFF000080); - subWidgetAdd(mySpacer); - } - - mySizerHori = new ewol::widget::Sizer(ewol::widget::Sizer::modeHori); - if (nullptr == mySizerHori) { - APPL_DEBUG("Allocation error mySizerHori"); - return; - } - subWidgetAdd(mySizerHori); - mySpacer = new ewol::widget::Spacer(); - if (nullptr != mySpacer) { - mySpacer->setExpand(bvec2(false,false)); - mySpacer->setFill(bvec2(false,true)); - mySpacer->setMinSize(vec2(10,10)); - mySpacer->setColor(0x00FF0080); - mySizerHori->subWidgetAdd(mySpacer); - } - - m_testWidget = new ewol::widget::Scene(/*&m_gameEngine*/ nullptr); - if (nullptr != m_testWidget) { - m_testWidget->setExpand(bvec2(true,true)); - m_testWidget->setFill(bvec2(true,true)); - mySizerHori->subWidgetAdd(m_testWidget); - } - - mySpacer = new ewol::widget::Spacer(); - if (nullptr != mySpacer) { - mySpacer->setExpand(bvec2(false,false)); - mySpacer->setFill(bvec2(false,true)); - mySpacer->setMinSize(vec2(10,10)); - mySpacer->setColor(0x0000FF80); - mySizerHori->subWidgetAdd(mySpacer); - } - - mySpacer = new ewol::widget::Spacer(); - if (nullptr != mySpacer) { - mySpacer->setExpand(bvec2(false,false)); - mySpacer->setFill(bvec2(true,false)); - mySpacer->setMinSize(vec2(10,10)); - mySpacer->setColor(0x00FFFF80); - subWidgetAdd(mySpacer); - } - APPL_INFO("Create "__class__" (end)"); -} - - -TestScene::~TestScene() { - APPL_INFO("Remove "__class__" ..."); -} - -/* -#include - -vec3 baseRotationVect; -vec3 baseMove; -class stupidCube : public game::Element -{ - public: - stupidCube(float poidKg=0.0f) : game::Element("DATA:cube.obj") - { - m_mass = poidKg; - }; - - // herited methode - virtual bool ArtificialIntelligence(float delta) - { - if (m_mass == 0.0f) { - if (baseRotationVect != vec3(0,0,0) ) { - Rotate(baseRotationVect, 0.5 * delta ); - } - if (baseMove != vec3(0,0,0) ) { - Translate(baseMove); - baseMove = vec3(0,0,0); - } - } - return false; - } - -}; - -class stupidSphere : public game::Element -{ - public: - stupidSphere(float poidKg=0.0f) : game::Element("DATA:sphere.obj") - { - m_mass = poidKg; - }; - - // herited methode - virtual bool ArtificialIntelligence(float delta) - { - if (m_mass == 0.0f) { - if (baseRotationVect != vec3(0,0,0) ) { - Rotate(baseRotationVect, 0.5 * delta ); - } - if (baseMove != vec3(0,0,0) ) { - Translate(baseMove); - baseMove = vec3(0,0,0); - } - } - return false; - } - -}; -*/ - - - - - - -void TestScene::onReceiveMessage(const ewol::object::Message& _msg) { - ewol::widget::Sizer::onReceiveMessage(_msg); - /* - //APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" ==> data=\"" << data << "\"" ); - if (m_testWidget == CallerObject) { - APPL_WARNING("Receive Event from tested Scene ... : \"" << eventId << "\" ==> data=\"" << data << "\"" ); - } - if (eventId == l_eventAddBox) { - static bool firstTime = true; - if (firstTime==false) { - stupidCube * tmpp = new stupidCube(); - vec3 newPos = vec3(etk::tool::frand(-40,40),etk::tool::frand(-40,40),etk::tool::frand(1,8)); - APPL_DEBUG("add a box at the pos : " << newPos); - tmpp->Translate(newPos); - tmpp->Scale(etk::tool::frand(0.5,2) ); - float angle = etk::tool::frand(-M_PI,M_PI); - tmpp->Rotate(vec3(1,0,0), angle); - angle = etk::tool::frand(-M_PI,M_PI); - tmpp->Rotate(vec3(0,1,0), angle); - angle = etk::tool::frand(-M_PI,M_PI); - tmpp->Rotate(vec3(0,0,1), angle); - m_gameEngine.AddElement(tmpp); - } else { - firstTime = false; - stupidCube * tmpp = new stupidCube(); - m_gameEngine.AddElement(tmpp); - } - } else if (eventId == l_eventAddSphere) { - if (nullptr!=m_testWidget) { - stupidSphere * tmpp = new stupidSphere(); - vec3 newPos = vec3(etk::tool::frand(-40,40),etk::tool::frand(-40,40),etk::tool::frand(1,8)); - APPL_DEBUG("add a box at the pos : " << newPos); - tmpp->Translate(newPos); - tmpp->Scale(etk::tool::frand(0.5,2) ); - float angle = etk::tool::frand(-M_PI,M_PI); - tmpp->Rotate(vec3(1,0,0), angle); - angle = etk::tool::frand(-M_PI,M_PI); - tmpp->Rotate(vec3(0,1,0), angle); - angle = etk::tool::frand(-M_PI,M_PI); - tmpp->Rotate(vec3(0,0,1), angle); - m_gameEngine.AddElement(tmpp); - } - } else if (eventId == l_eventUp) { - baseMove = vec3(0.1,0,0); - } else if (eventId == l_eventDown) { - baseMove = vec3(-0.1,0,0); - } else if (eventId == l_eventRotationX) { - baseRotationVect = vec3(1,0,0); - } else if (eventId == l_eventRotationY) { - baseRotationVect = vec3(0,1,0); - } else if (eventId == l_eventRotationZ) { - baseRotationVect = vec3(0,0,1); - } else if (eventId == l_eventRotation0) { - baseRotationVect = vec3(0,0,0); - } else if (eventId == l_eventLunch) { - stupidCube * tmpp = new stupidCube(250); - vec3 newPos = vec3(5,5,100); - tmpp->Translate(newPos); - tmpp->SetSpeed(vec3(10,10,50)); - m_gameEngine.AddElement(tmpp); - } else if (eventId == l_eventChangeTimeSpeed1) { - if (nullptr!=m_testWidget) { - m_testWidget->SetRatioTime(1); - } - } else if (eventId == l_eventChangeTimeSpeed0) { - if (nullptr!=m_testWidget) { - m_testWidget->SetRatioTime(0.5); - } - } else if (eventId == l_eventChangeTimeSpeed2) { - if (nullptr!=m_testWidget) { - m_testWidget->SetRatioTime(2); - } - } else if (eventId == l_eventChangeTimeSpeed4) { - if (nullptr!=m_testWidget) { - m_testWidget->SetRatioTime(4); - } - } - */ - - return; -} - diff --git a/tools/visual_test/appl/TestScene.h b/tools/visual_test/appl/TestScene.h deleted file mode 100644 index 4cdd1b9e..00000000 --- a/tools/visual_test/appl/TestScene.h +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license BSD v3 (see license file) - */ -#pragma once - -#include -#include -#include -#include - -class TestScene : public ewol::widget::Sizer { - private: - std::shared_ptr m_testWidget; - public: - // Constructeur - TestScene(); - virtual ~TestScene(); - public: // Derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); -}; - diff --git a/tools/visual_test/appl/TestSlider.cpp b/tools/visual_test/appl/TestSlider.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/tools/visual_test/appl/TestSlider.h b/tools/visual_test/appl/TestSlider.h deleted file mode 100644 index e69de29b..00000000 diff --git a/tools/visual_test/appl/WidgetTest.cpp b/tools/visual_test/appl/WidgetTest.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/tools/visual_test/appl/WidgetTest.h b/tools/visual_test/appl/WidgetTest.h deleted file mode 100644 index e69de29b..00000000 diff --git a/tools/visual_test/appl/init.cpp b/tools/visual_test/appl/init.cpp index 76ce0c59..611ce5e9 100644 --- a/tools/visual_test/appl/init.cpp +++ b/tools/visual_test/appl/init.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -49,8 +48,6 @@ class MainApplication : public ewol::context::Application { // set the application icon ... _context.setIcon("DATA:icon.png"); - appl::widget::SizerColor::createManagerWidget(_context.getWidgetManager()); - APPL_INFO("==> CREATE ... (END)"); } diff --git a/tools/visual_test/appl/widget/SizerColor.cpp b/tools/visual_test/appl/widget/SizerColor.cpp deleted file mode 100644 index 11be6ec6..00000000 --- a/tools/visual_test/appl/widget/SizerColor.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ - -#include -#include - -#undef __class__ -#define __class__ "SizerColor" - -appl::widget::SizerColor::SizerColor() : - m_borderColor(*this, "border-color", etk::color::none, "Color of the border"), - m_leftColor(*this, "color-left", etk::color::purple), - m_rightColor(*this, "color-right", etk::color::orange), - m_topColor(*this, "color-top", etk::color::cyan), - m_buttomColor(*this, "color-buttom", etk::color::brown) { - addObjectType("appl::widget::SizerColor"); -} - -void appl::widget::SizerColor::init(enum displayMode _mode) { - ewol::widget::Sizer::init(); -} - -appl::widget::SizerColor::~SizerColor() { - -} - -void appl::widget::SizerColor::onRegenerateDisplay() { - ewol::widget::Sizer::onRegenerateDisplay(); - m_draw.clear(); - vec2 tmpBorderSize = m_borderSize->getPixel(); - if (tmpBorderSize == vec2(0.0f, 0.0f)) { - return; - } - if (m_borderColor->a() == 0) { - return; - } - m_draw.setColor(m_borderColor); - m_draw.setPos(vec3(0, 0, 0) ); - m_draw.rectangleWidth(vec3(tmpBorderSize.x(), m_size.y(),0) ); - m_draw.setPos(vec3(m_size.x() - tmpBorderSize.x(), 0, 0) ); - m_draw.rectangleWidth(vec3(tmpBorderSize.x(), m_size.y(),0) ); - m_draw.setPos(vec3(tmpBorderSize.x(), 0, 0) ); - m_draw.rectangleWidth(vec3(m_size.x()-tmpBorderSize.x()*2.0f, tmpBorderSize.y(),0) ); - m_draw.setPos(vec3(tmpBorderSize.x(), m_size.y()-tmpBorderSize.y(), 0) ); - m_draw.rectangleWidth(vec3(m_size.x()-tmpBorderSize.x()*2.0f, tmpBorderSize.y(),0) ); - vec2 underSize(0,0); - vec2 underOrigin(999999999999.0,999999999999.0); - for (auto &it : m_subWidget) { - if (it == nullptr) { - continue; - } - vec2 size = it->getSize(); - if (m_mode == ewol::widget::Sizer::modeVert) { - underSize += vec2(0.0f, size.y()); - underSize.setX(std::max(underSize.x(), size.x())); - } else { - underSize += vec2(size.x(), 0.0f); - underSize.setY(std::max(underSize.y(), size.y())); - } - underOrigin.setX(std::min(it->getOrigin().x(), underOrigin.x())); - underOrigin.setY(std::min(it->getOrigin().y(), underOrigin.y())); - } - vec2 localWidgetSize = m_size - tmpBorderSize*2.0f; - vec2 localWidgetOrigin = m_origin + tmpBorderSize; - for (auto &it : m_subWidget) { - if (it == nullptr) { - continue; - } - vec2 origin = it->getOrigin(); - vec2 size = it->getSize(); - // now we display around the widget every element needed - if (m_mode == ewol::widget::Sizer::modeHori) { - if (size.y() < localWidgetSize.y()) { - // under - if ((uint32_t(m_gravity) & uint32_t(ewol::gravity_buttom)) == 0) { - m_draw.setColor(m_buttomColor); - m_draw.setPos(vec2(origin.x(), localWidgetOrigin.y()) - m_origin); - m_draw.rectangleWidth(vec2(it->getSize().x(), origin.y()-localWidgetOrigin.y()) ); - } - // upper - if ((uint32_t(m_gravity) & uint32_t(ewol::gravity_top)) == 0) { - m_draw.setColor(m_topColor); - float startDraw = origin.y()+it->getSize().y() - m_origin.y(); - m_draw.setPos(vec2(origin.x()-m_origin.x(), startDraw)); - m_draw.rectangleWidth(vec2(it->getSize().x(), localWidgetSize.y()-startDraw+tmpBorderSize.y()) ); - } - } - } else { - if (size.x() < localWidgetSize.x()) { - // left - if ((uint32_t(m_gravity) & uint32_t(ewol::gravity_left)) == 0) { - m_draw.setColor(m_leftColor); - m_draw.setPos(vec2(localWidgetOrigin.x(), origin.y()) - m_origin); - m_draw.rectangleWidth(vec2(origin.x()-localWidgetOrigin.x(), it->getSize().y()) ); - } - // right - if ((uint32_t(m_gravity) & uint32_t(ewol::gravity_right)) == 0) { - m_draw.setColor(m_rightColor); - float startDraw = origin.x()+it->getSize().x() - m_origin.x(); - m_draw.setPos(vec2(startDraw, origin.y()-m_origin.y())); - m_draw.rectangleWidth(vec2(localWidgetSize.x()-startDraw+tmpBorderSize.x(), it->getSize().y()) ); - } - } - } - } - // now we do the rest of the sizer: - if (m_mode == ewol::widget::Sizer::modeHori) { - if (underSize.x() < localWidgetSize.x()) { - // left - if ((uint32_t(m_gravity) & uint32_t(ewol::gravity_left)) == 0) { - m_draw.setColor(m_leftColor); - m_draw.setPos(localWidgetOrigin - m_origin); - m_draw.rectangleWidth(vec2(underOrigin.x()-localWidgetOrigin.x(), localWidgetSize.y()) ); - } - // right - if ((uint32_t(m_gravity) & uint32_t(ewol::gravity_right)) == 0) { - m_draw.setColor(m_rightColor); - float startDraw = underOrigin.x() + underSize.x() - m_origin.x(); - m_draw.setPos(vec2(startDraw, localWidgetOrigin.y()-m_origin.y())); - m_draw.rectangleWidth(vec2(localWidgetSize.x()-startDraw+tmpBorderSize.x(), localWidgetSize.y()) ); - } - } - } else { - if (underSize.y() < localWidgetSize.y()) { - // under - if ((uint32_t(m_gravity) & uint32_t(ewol::gravity_buttom)) == 0) { - m_draw.setColor(m_buttomColor); - m_draw.setPos(localWidgetOrigin - m_origin); - m_draw.rectangleWidth(vec2(localWidgetSize.x(), underOrigin.y()-localWidgetOrigin.y()) ); - } - // upper - if ((uint32_t(m_gravity) & uint32_t(ewol::gravity_top)) == 0) { - m_draw.setColor(m_topColor); - float startDraw = underOrigin.y() + underSize.y() - m_origin.y(); - m_draw.setPos(vec2(localWidgetOrigin.x()-m_origin.x(), startDraw)); - m_draw.rectangleWidth(vec2(localWidgetSize.x(), localWidgetSize.y()-startDraw+tmpBorderSize.y()) ); - } - } - } -} -void appl::widget::SizerColor::onDraw() { - m_draw.draw(); - ewol::widget::Sizer::onDraw(); -} diff --git a/tools/visual_test/appl/widget/SizerColor.h b/tools/visual_test/appl/widget/SizerColor.h deleted file mode 100644 index bebb439f..00000000 --- a/tools/visual_test/appl/widget/SizerColor.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2011, Edouard DUPIN, all right reserved - * - * @license APACHE v2.0 (see license file) - */ -#pragma once - -#include -#include -#include -#include - -namespace appl { - namespace widget { - class SizerColor : public ewol::widget::Sizer { - public: - /** - * @brief Main call of recording the widget on the List of "widget named creator" - */ - static void init(ewol::widget::Manager& _widgetManager); - protected: - /** - * @brief Constructor - * @param[in] _mode The mode to display the elements - */ - SizerColor(); - void init(enum displayMode _mode=ewol::widget::Sizer::modeHori); - public: - DECLARE_WIDGET_FACTORY(SizerColor, "SizerColor"); - /** - * @brief Desstructor - */ - virtual ~SizerColor(); - private: - eproperty::Value> m_borderColor; //!< Border color. - eproperty::Value> m_leftColor; //!< Left color. - eproperty::Value> m_rightColor; //!< Right color. - eproperty::Value> m_topColor; //!< Top color. - eproperty::Value> m_buttomColor; //!< Buttom color. - private: - ewol::compositing::Drawing m_draw; //!< Compositing drawing element for display the border. - public: - virtual void onRegenerateDisplay(); - virtual void onDraw(); - }; - } -} -