diff --git a/include/eepp/ui/css/stylesheetproperty.hpp b/include/eepp/ui/css/stylesheetproperty.hpp index 92fb5bbff..4ff8ecfb7 100644 --- a/include/eepp/ui/css/stylesheetproperty.hpp +++ b/include/eepp/ui/css/stylesheetproperty.hpp @@ -89,6 +89,14 @@ class EE_API StyleSheetProperty { BlendMode asBlendMode() const; + Vector2f asDpDimensionVector2f( const Vector2f& defaultValue = Vector2f::Zero ) const; + + Vector2i asDpDimensionVector2i( const Vector2i& defaultValue = Vector2i::Zero ) const; + + Vector2f asDpDimensionSizef( const Sizef& defaultValue = Sizef::Zero ) const; + + Vector2i asDpDimensionSizei( const Sizei& defaultValue = Sizei::Zero ) const; + Vector2f asVector2f( const Vector2f& defaultValue = Vector2f::Zero ) const; Vector2i asVector2i( const Vector2i& defaultValue = Vector2i::Zero ) const; diff --git a/include/eepp/ui/uipushbutton.hpp b/include/eepp/ui/uipushbutton.hpp index bc17c7c2b..f2d70d9dd 100644 --- a/include/eepp/ui/uipushbutton.hpp +++ b/include/eepp/ui/uipushbutton.hpp @@ -49,6 +49,8 @@ class EE_API UIPushButton : public UIWidget { void setStyleConfig(const StyleConfig & styleConfig); virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: StyleConfig mStyleConfig; UIImage * mIcon; diff --git a/include/eepp/ui/uiradiobutton.hpp b/include/eepp/ui/uiradiobutton.hpp index ea13921aa..1c9e83832 100644 --- a/include/eepp/ui/uiradiobutton.hpp +++ b/include/eepp/ui/uiradiobutton.hpp @@ -33,6 +33,8 @@ class EE_API UIRadioButton : public UITextView { void setTextSeparation(const Int32 & textSeparation); virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: UINode * mActiveButton; UINode * mInactiveButton; diff --git a/include/eepp/ui/uiscrollbar.hpp b/include/eepp/ui/uiscrollbar.hpp index e9628e1be..42d46a3c9 100644 --- a/include/eepp/ui/uiscrollbar.hpp +++ b/include/eepp/ui/uiscrollbar.hpp @@ -70,6 +70,8 @@ class EE_API UIScrollBar : public UIWidget { void setExpandBackground( bool expandBackground ); virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: ScrollBarType mScrollBarType; UISlider * mSlider; diff --git a/include/eepp/ui/uiscrollview.hpp b/include/eepp/ui/uiscrollview.hpp index 6d9f75396..8949c992b 100644 --- a/include/eepp/ui/uiscrollview.hpp +++ b/include/eepp/ui/uiscrollview.hpp @@ -41,6 +41,8 @@ class EE_API UIScrollView : public UITouchDragableWidget { UIWidget * getContainer() const; virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: ScrollViewType mViewType; UI_SCROLLBAR_MODE mVScrollMode; diff --git a/include/eepp/ui/uislider.hpp b/include/eepp/ui/uislider.hpp index 0dec2a3ce..852faaa87 100644 --- a/include/eepp/ui/uislider.hpp +++ b/include/eepp/ui/uislider.hpp @@ -67,6 +67,8 @@ class EE_API UISlider : public UIWidget { virtual bool applyProperty( const StyleSheetProperty& attribute ); + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); + Sizef getMinimumSize(); protected: UI_ORIENTATION mOrientation; diff --git a/include/eepp/ui/uispinbox.hpp b/include/eepp/ui/uispinbox.hpp index 0ef9b89b7..951c1f840 100644 --- a/include/eepp/ui/uispinbox.hpp +++ b/include/eepp/ui/uispinbox.hpp @@ -55,6 +55,8 @@ class EE_API UISpinBox : public UIWidget { bool dotsInNumbersAllowed(); virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: UITextInput * mInput; UINode * mPushUp; diff --git a/include/eepp/ui/uisprite.hpp b/include/eepp/ui/uisprite.hpp index 1209bcae9..2ed93aa8e 100644 --- a/include/eepp/ui/uisprite.hpp +++ b/include/eepp/ui/uisprite.hpp @@ -47,6 +47,8 @@ class EE_API UISprite : public UIWidget { bool getDeallocSprite(); virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: Graphics::Sprite * mSprite; RenderMode mRender; diff --git a/include/eepp/ui/uitab.hpp b/include/eepp/ui/uitab.hpp index 389fcc145..2199b9671 100644 --- a/include/eepp/ui/uitab.hpp +++ b/include/eepp/ui/uitab.hpp @@ -30,6 +30,8 @@ class EE_API UITab : public UISelectButton { virtual UIPushButton * setText( const String& text ); virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString( const PropertyDefinition* propertyDef ); protected: Node * mControlOwned; std::string mOwnedName; diff --git a/include/eepp/ui/uitable.hpp b/include/eepp/ui/uitable.hpp index 1fab04cff..8490b3e66 100644 --- a/include/eepp/ui/uitable.hpp +++ b/include/eepp/ui/uitable.hpp @@ -78,6 +78,8 @@ class EE_API UITable : public UITouchDragableWidget { Rectf getContainerPadding() const; virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: friend class UIItemContainer; friend class UITableCell; diff --git a/include/eepp/ui/uitabwidget.hpp b/include/eepp/ui/uitabwidget.hpp index 6c249a295..8b40af004 100644 --- a/include/eepp/ui/uitabwidget.hpp +++ b/include/eepp/ui/uitabwidget.hpp @@ -111,6 +111,8 @@ class EE_API UITabWidget : public UIWidget { void setStyleConfig(const StyleConfig & styleConfig); virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: friend class UITab; diff --git a/include/eepp/ui/uitextedit.hpp b/include/eepp/ui/uitextedit.hpp index b307b8216..5c2af4410 100644 --- a/include/eepp/ui/uitextedit.hpp +++ b/include/eepp/ui/uitextedit.hpp @@ -46,6 +46,8 @@ class EE_API UITextEdit : public UIWidget { UIFontStyleConfig getFontStyleConfig() const; virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: UITextInput * mTextInput; UIScrollBar * mHScrollBar; diff --git a/include/eepp/ui/uitextinput.hpp b/include/eepp/ui/uitextinput.hpp index c4153a0aa..fe04e21e2 100644 --- a/include/eepp/ui/uitextinput.hpp +++ b/include/eepp/ui/uitextinput.hpp @@ -35,7 +35,7 @@ class EE_API UITextInput : public UITextView { UITextInput * setAllowEditing( const bool& allow ); - const bool& getAllowEditing() const; + const bool& isEditingAllowed() const; virtual const String& getText(); @@ -53,6 +53,8 @@ class EE_API UITextInput : public UITextView { virtual bool applyProperty( const StyleSheetProperty& attribute ); + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); + virtual UIWidget * setPadding(const Rectf& padding); protected: InputTextBuffer mTextBuffer; diff --git a/include/eepp/ui/uitextureregion.hpp b/include/eepp/ui/uitextureregion.hpp index 024dccc30..f8fa3d42b 100644 --- a/include/eepp/ui/uitextureregion.hpp +++ b/include/eepp/ui/uitextureregion.hpp @@ -44,6 +44,8 @@ class EE_API UITextureRegion : public UIWidget { UITextureRegion * setScaleType(const Uint32 & scaleType); virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: Uint32 mScaleType; Graphics::TextureRegion * mTextureRegion; diff --git a/include/eepp/ui/uitooltip.hpp b/include/eepp/ui/uitooltip.hpp index 106393d18..bfa8a1eb9 100644 --- a/include/eepp/ui/uitooltip.hpp +++ b/include/eepp/ui/uitooltip.hpp @@ -92,6 +92,8 @@ class EE_API UITooltip : public UIWidget { UITooltip * setOutlineColor( const Color& outlineColor ); virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: Text * mTextCache; UIFontStyleConfig mStyleConfig; diff --git a/include/eepp/ui/uitouchdragablewidget.hpp b/include/eepp/ui/uitouchdragablewidget.hpp index da9d4bf26..4c0c5e04e 100644 --- a/include/eepp/ui/uitouchdragablewidget.hpp +++ b/include/eepp/ui/uitouchdragablewidget.hpp @@ -8,7 +8,7 @@ namespace EE { namespace UI { class EE_API UITouchDragableWidget : public UIWidget { public: static UITouchDragableWidget * New(); - + UITouchDragableWidget(); ~UITouchDragableWidget(); @@ -30,6 +30,8 @@ class EE_API UITouchDragableWidget : public UIWidget { UITouchDragableWidget * setTouchDragDeceleration( const Vector2f& touchDragDeceleration ); virtual bool applyProperty( const StyleSheetProperty& attribute ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: Vector2f mTouchDragPoint; Vector2f mTouchDragAcceleration; diff --git a/include/eepp/ui/uiwindow.hpp b/include/eepp/ui/uiwindow.hpp index 5794abed6..adc90acec 100644 --- a/include/eepp/ui/uiwindow.hpp +++ b/include/eepp/ui/uiwindow.hpp @@ -140,6 +140,10 @@ class EE_API UIWindow : public UIWidget { FrameBuffer * getFrameBuffer() const; virtual bool isDrawInvalidator() const; + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); + + std::string getWindowFlagsString(); protected: class KeyboardShortcut { public: diff --git a/include/eepp/ui/uiwinmenu.hpp b/include/eepp/ui/uiwinmenu.hpp index aebeba103..daa4071e7 100644 --- a/include/eepp/ui/uiwinmenu.hpp +++ b/include/eepp/ui/uiwinmenu.hpp @@ -61,6 +61,8 @@ class EE_API UIWinMenu : public UIWidget { virtual bool applyProperty( const StyleSheetProperty& attribute ); virtual void loadFromXmlNode( const pugi::xml_node& node ); + + virtual std::string getPropertyString(const PropertyDefinition* propertyDef); protected: typedef std::list< std::pair< UISelectButton *, UIPopUpMenu * > > WinMenuList; diff --git a/src/eepp/ui/css/stylesheetproperty.cpp b/src/eepp/ui/css/stylesheetproperty.cpp index 33052f6d8..ce488e77c 100644 --- a/src/eepp/ui/css/stylesheetproperty.cpp +++ b/src/eepp/ui/css/stylesheetproperty.cpp @@ -237,6 +237,39 @@ BlendMode StyleSheetProperty::asBlendMode() const { return toBlendMode( mValue ); } +Vector2f StyleSheetProperty::asDpDimensionVector2f( const Vector2f& defaultValue ) const { + if ( !mValue.empty() ) { + Vector2f vector; + auto xySplit = String::split( mValue, ',', true ); + + if ( xySplit.size() == 2 ) { + vector.x = PixelDensity::toDpFromString("0"); + vector.y = PixelDensity::toDpFromString("0"); + return vector; + } else if ( xySplit.size() == 1 ) { + vector.x = vector.y = PixelDensity::toDpFromString("0"); + return vector; + } + } + + return defaultValue; +} + +Vector2i StyleSheetProperty::asDpDimensionVector2i( const Vector2i& defaultValue ) const { + Vector2f v( asDpDimensionVector2f( Vector2f( defaultValue.x, defaultValue.y ) ) ); + return Vector2i( v.x, v.y ); +} + +Vector2f StyleSheetProperty::asDpDimensionSizef( const Sizef& defaultValue ) const { + Vector2f v( asDpDimensionVector2f( defaultValue ) ); + return Sizef( v.x, v.y ); +} + +Vector2i StyleSheetProperty::asDpDimensionSizei( const Sizei& defaultValue ) const { + Vector2i v( asDpDimensionVector2i( defaultValue ) ); + return Sizei( v.x, v.y ); +} + Vector2f StyleSheetProperty::asVector2f( const Vector2f& defaultValue ) const { if ( !mValue.empty() ) { Vector2f vector; diff --git a/src/eepp/ui/uiimage.cpp b/src/eepp/ui/uiimage.cpp index bccde53e6..c2318511d 100644 --- a/src/eepp/ui/uiimage.cpp +++ b/src/eepp/ui/uiimage.cpp @@ -218,8 +218,13 @@ std::string UIImage::getPropertyString( const PropertyDefinition* propertyDef ) if ( NULL == propertyDef ) return ""; - // TODO: Implement src and icon. switch ( propertyDef->getPropertyId() ) { + case PropertyId::Src: + // TODO: Implement src. + return ""; + case PropertyId::Icon: + // TODO: Implement icon. + return ""; case PropertyId::ScaleType: return getScaleType() == UIScaleType::FitInside ? "fit-inside" diff --git a/src/eepp/ui/uipushbutton.cpp b/src/eepp/ui/uipushbutton.cpp index ea89a076f..1ff94dcb2 100644 --- a/src/eepp/ui/uipushbutton.cpp +++ b/src/eepp/ui/uipushbutton.cpp @@ -284,6 +284,27 @@ void UIPushButton::setStyleConfig(const StyleConfig & styleConfig) { onStateChange(); } +std::string UIPushButton::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::Text: + return getText().toUtf8(); + case PropertyId::Icon: + // TODO: Implement icon + return ""; + case PropertyId::MinIconSize: + return String::format( "%ddp", mStyleConfig.IconMinSize.getWidth() ) + ", " + + String::format( "%ddp", mStyleConfig.IconMinSize.getHeight() ); + case PropertyId::IconHorizontalMargin: + return String::format( "%ddp", mStyleConfig.IconHorizontalMargin ); + case PropertyId::IconAutoMargin: + return mStyleConfig.IconAutoMargin ? "true" : "false"; + default: + return UIWidget::getPropertyString( propertyDef ); + } +} + bool UIPushButton::applyProperty( const StyleSheetProperty& attribute ) { bool attributeSet = true; diff --git a/src/eepp/ui/uiradiobutton.cpp b/src/eepp/ui/uiradiobutton.cpp index 955d9d7d8..a2cb07fd2 100644 --- a/src/eepp/ui/uiradiobutton.cpp +++ b/src/eepp/ui/uiradiobutton.cpp @@ -264,6 +264,18 @@ void UIRadioButton::setTextSeparation(const Int32 & textSeparation) { setPadding( getPadding() ); } +std::string UIRadioButton::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::Selected: + return isActive() ? "true" : "false"; + break; + default: + return UITextView::getPropertyString( propertyDef ); + } +} + bool UIRadioButton::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uiscrollbar.cpp b/src/eepp/ui/uiscrollbar.cpp index 7b6a14440..02c18cb5d 100644 --- a/src/eepp/ui/uiscrollbar.cpp +++ b/src/eepp/ui/uiscrollbar.cpp @@ -305,6 +305,31 @@ void UIScrollBar::setExpandBackground( bool expandBackground ) { } } +std::string UIScrollBar::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::Orientation: + return getOrientation() == UI_HORIZONTAL ? "horizontal" : "vertical"; + case PropertyId::MinValue: + return String::fromFloat( getMinValue() ); + case PropertyId::MaxValue: + return String::fromFloat( getMaxValue() ); + case PropertyId::Value: + return String::fromFloat( getValue() ); + case PropertyId::ClickStep: + return String::fromFloat( getClickStep() ); + case PropertyId::PageStep: + return String::fromFloat( getPageStep() ); + case PropertyId::ScrollBarType: + return getScrollBarType() == NoButtons ? "no-buttons" : "two-buttons"; + case PropertyId::BackgroundExpand: + return getExpandBackground() ? "true" : "false"; + default: + return UIWidget::getPropertyString( propertyDef ); + } +} + bool UIScrollBar::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uiscrollview.cpp b/src/eepp/ui/uiscrollview.cpp index af274245a..0bfa8fdd1 100644 --- a/src/eepp/ui/uiscrollview.cpp +++ b/src/eepp/ui/uiscrollview.cpp @@ -241,6 +241,28 @@ bool UIScrollView::isTouchOverAllowedChilds() { return isMouseOverMeOrChilds() && mScrollView->isMouseOverMeOrChilds() && ret; } +std::string UIScrollView::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::VScrollMode: + return getVerticalScrollMode() == UI_SCROLLBAR_AUTO ? "auto" : ( + getVerticalScrollMode() == UI_SCROLLBAR_ALWAYS_ON ? "on" : "off" + ); + case PropertyId::HScrollMode: + return getHorizontalScrollMode() == UI_SCROLLBAR_AUTO ? "auto" : ( + getHorizontalScrollMode() == UI_SCROLLBAR_ALWAYS_ON ? "on" : "off" + ); + case PropertyId::ScrollBarType: + return mVScroll->getScrollBarType() == UIScrollBar::NoButtons ? "no-buttons" : + "two-buttons"; + case PropertyId::ScrollBarMode: + return getViewType() == Inclusive ? "inclusive" : "exclusive"; + default: + return UITouchDragableWidget::getPropertyString( propertyDef ); + } +} + bool UIScrollView::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uislider.cpp b/src/eepp/ui/uislider.cpp index 5739190d7..562aa3eca 100644 --- a/src/eepp/ui/uislider.cpp +++ b/src/eepp/ui/uislider.cpp @@ -436,6 +436,31 @@ Uint32 UISlider::onMessage(const NodeMessage * Msg) { return 0; } +std::string UISlider::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::Orientation: + return getOrientation() == UI_HORIZONTAL ? "horizontal" : "vertical"; + case PropertyId::MinValue: + return String::fromFloat( getMinValue() ); + case PropertyId::MaxValue: + return String::fromFloat( getMaxValue() ); + case PropertyId::Value: + return String::fromFloat( getValue() ); + case PropertyId::ClickStep: + return String::fromFloat( getClickStep() ); + case PropertyId::PageStep: + return String::fromFloat( getPageStep() ); + case PropertyId::HalfSlider: + return getAllowHalfSliderOut() ? "true" : "false"; + case PropertyId::BackgroundExpand: + return getExpandBackground() ? "true" : "false"; + default: + return UIWidget::getPropertyString( propertyDef ); + } +} + bool UISlider::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uispinbox.cpp b/src/eepp/ui/uispinbox.cpp index ca41fb149..ca5aa85bd 100644 --- a/src/eepp/ui/uispinbox.cpp +++ b/src/eepp/ui/uispinbox.cpp @@ -270,6 +270,23 @@ void UISpinBox::onPaddingChange() { UIWidget::onPaddingChange(); } +std::string UISpinBox::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::MinValue: + return String::fromFloat( getMinValue() ); + case PropertyId::MaxValue: + return String::fromFloat( getMaxValue() ); + case PropertyId::Value: + return String::fromFloat( getValue() ); + case PropertyId::ClickStep: + return String::fromFloat( getClickStep() ); + default: + return UIWidget::getPropertyString( propertyDef ); + } +} + bool UISpinBox::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uisprite.cpp b/src/eepp/ui/uisprite.cpp index 31423ec9c..caa821c89 100644 --- a/src/eepp/ui/uisprite.cpp +++ b/src/eepp/ui/uisprite.cpp @@ -185,6 +185,18 @@ void UISprite::onSizeChange() { UIWidget::onSizeChange(); } +std::string UISprite::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::Src: + // TODO: Implement src + return ""; + default: + return UIWidget::getPropertyString( propertyDef ); + } +} + bool UISprite::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uitab.cpp b/src/eepp/ui/uitab.cpp index 4ba28c6a4..bb3402422 100644 --- a/src/eepp/ui/uitab.cpp +++ b/src/eepp/ui/uitab.cpp @@ -144,6 +144,20 @@ void UITab::onAutoSize() { } } +std::string UITab::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::Text: + case PropertyId::Name: + return getText().toUtf8(); + case PropertyId::Owns: + return mOwnedName; + default: + return UISelectButton::getPropertyString( propertyDef ); + } +} + bool UITab::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uitable.cpp b/src/eepp/ui/uitable.cpp index fc8f78e94..d54ee0f25 100644 --- a/src/eepp/ui/uitable.cpp +++ b/src/eepp/ui/uitable.cpp @@ -623,6 +623,28 @@ bool UITable::isTouchOverAllowedChilds() { return isMouseOverMeOrChilds() && !mVScrollBar->isMouseOverMeOrChilds() && !mHScrollBar->isMouseOverMeOrChilds(); } +std::string UITable::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::RowHeight: + return String::format( "%ddp", getRowHeight() ); + case PropertyId::VScrollMode: + return getVerticalScrollMode() == UI_SCROLLBAR_AUTO ? "auto" : ( + getVerticalScrollMode() == UI_SCROLLBAR_ALWAYS_ON ? "on" : "off" + ); + case PropertyId::HScrollMode: + return getHorizontalScrollMode() == UI_SCROLLBAR_AUTO ? "auto" : ( + getHorizontalScrollMode() == UI_SCROLLBAR_ALWAYS_ON ? "on" : "off" + ); + case PropertyId::ScrollBarType: + return mVScrollBar->getScrollBarType() == UIScrollBar::NoButtons ? "no-buttons" : + "two-buttons"; + default: + return UITouchDragableWidget::getPropertyString( propertyDef ); + } +} + bool UITable::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp index 3b22706b4..398c1335c 100644 --- a/src/eepp/ui/uitabwidget.cpp +++ b/src/eepp/ui/uitabwidget.cpp @@ -119,21 +119,45 @@ void UITabWidget::setStyleConfig(const StyleConfig & styleConfig) { orderTabs(); } -bool UITabWidget::applyProperty( const StyleSheetProperty& attribute ) { - if ( attribute.getPropertyDefinition() == NULL ) { - eePRINTL( "applyProperty: Property %s not defined!", attribute.getName().c_str() ); - return false; +std::string UITabWidget::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::MaxTextLength: + return String::toStr( getMaxTextLength() ); + case PropertyId::MinTabWidth: + return String::format( "%ddp", getMinTabWidth() ); + case PropertyId::MaxTabWidth: + return String::format( "%ddp", getMaxTabWidth() ); + case PropertyId::TabClosable: + return getTabsClosable() ? "true" : "false"; + case PropertyId::SpecialBorderTabs: + return getSpecialBorderTabs() ? "true" : "false"; + case PropertyId::LineBelowTabs: + return getDrawLineBelowTabs() ? "true" : "false"; + case PropertyId::LineBelowTabsColor: + return getLineBelowTabsColor().toHexString(); + case PropertyId::LineBelowTabsYOffset: + return String::format( "%ddp", getLineBelowTabsYOffset() ); + case PropertyId::TabSeparation: + return String::format( "%ddp", getTabSeparation() ); + default: + return UIWidget::getPropertyString( propertyDef ); } +} + +bool UITabWidget::applyProperty( const StyleSheetProperty& attribute ) { + if ( !checkPropertyDefinition( attribute ) ) return false; switch ( attribute.getPropertyDefinition()->getPropertyId() ) { case PropertyId::MaxTextLength: setMaxTextLength( attribute.asUint(1) ); break; case PropertyId::MinTabWidth: - setMinTabWidth( attribute.asUint(1) ); + setMinTabWidth( attribute.asDpDimensionUint("1") ); break; case PropertyId::MaxTabWidth: - setMaxTabWidth( attribute.asUint() ); + setMaxTabWidth( attribute.asDpDimensionUint() ); break; case PropertyId::TabClosable: setTabsClosable( attribute.asBool() ); diff --git a/src/eepp/ui/uitextedit.cpp b/src/eepp/ui/uitextedit.cpp index 2689e9253..aa76f2fce 100644 --- a/src/eepp/ui/uitextedit.cpp +++ b/src/eepp/ui/uitextedit.cpp @@ -443,7 +443,7 @@ void UITextEdit::setAllowEditing( const bool& allow ) { } const bool& UITextEdit::isEditingAllowed() const { - return mTextInput->getAllowEditing(); + return mTextInput->isEditingAllowed(); } void UITextEdit::setVerticalScrollMode( const UI_SCROLLBAR_MODE& Mode ) { @@ -474,6 +474,27 @@ UIFontStyleConfig UITextEdit::getFontStyleConfig() const { return mTextInput->getFontStyleConfig(); } +std::string UITextEdit::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::Text: + return getText().toUtf8(); + case PropertyId::AllowEditing: + return isEditingAllowed() ? "true" : "false"; + case PropertyId::VScrollMode: + return getVerticalScrollMode() == UI_SCROLLBAR_AUTO ? "auto" : ( + getVerticalScrollMode() == UI_SCROLLBAR_ALWAYS_ON ? "on" : "off" + ); + case PropertyId::HScrollMode: + return getHorizontalScrollMode() == UI_SCROLLBAR_AUTO ? "auto" : ( + getHorizontalScrollMode() == UI_SCROLLBAR_ALWAYS_ON ? "on" : "off" + ); + default: + return UIWidget::getPropertyString( propertyDef ); + } +} + bool UITextEdit::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uitextinput.cpp b/src/eepp/ui/uitextinput.cpp index bd951ce2d..1fe1ab509 100644 --- a/src/eepp/ui/uitextinput.cpp +++ b/src/eepp/ui/uitextinput.cpp @@ -220,7 +220,7 @@ UITextInput * UITextInput::setAllowEditing( const bool& allow ) { return this; } -const bool& UITextInput::getAllowEditing() const { +const bool& UITextInput::isEditingAllowed() const { return mAllowEditing; } @@ -393,6 +393,27 @@ bool UITextInput::isFreeEditingEnabled() { return mTextBuffer.isFreeEditingEnabled(); } +std::string UITextInput::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::Text: + return getText().toUtf8(); + case PropertyId::AllowEditing: + return isEditingAllowed() ? "true" : "false"; + case PropertyId::MaxLength: + return String::toStr( getMaxLength() ); + case PropertyId::FreeEditing: + return isFreeEditingEnabled() ? "true" : "false"; + case PropertyId::OnlyNumbers: + return getInputTextBuffer()->onlyNumbersAllowed() ? "true" : "false"; + case PropertyId::AllowDot: + return getInputTextBuffer()->dotsInNumbersAllowed() ? "true" : "false"; + default: + return UITextView::getPropertyString( propertyDef ); + } +} + bool UITextInput::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uitextureregion.cpp b/src/eepp/ui/uitextureregion.cpp index d753400f6..85d7c1498 100644 --- a/src/eepp/ui/uitextureregion.cpp +++ b/src/eepp/ui/uitextureregion.cpp @@ -197,6 +197,25 @@ const Vector2f& UITextureRegion::getAlignOffset() const { return mAlignOffset; } +std::string UITextureRegion::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) + return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::Src: + // TODO: Implement src. + return ""; + case PropertyId::ScaleType: + return getScaleType() == UIScaleType::FitInside + ? "fit-inside" + : ( getScaleType() == UIScaleType::Expand ? "expand" : "none" ); + case PropertyId::Tint: + return getColor().toHexString(); + default: + return UIWidget::getPropertyString( propertyDef ); + } +} + bool UITextureRegion::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uitextview.cpp b/src/eepp/ui/uitextview.cpp index af8595496..b028e2655 100644 --- a/src/eepp/ui/uitextview.cpp +++ b/src/eepp/ui/uitextview.cpp @@ -633,6 +633,8 @@ std::string UITextView::getPropertyString( const PropertyDefinition* propertyDef if ( NULL == propertyDef ) return ""; switch ( propertyDef->getPropertyId() ) { + case PropertyId::Text: + return getText().toUtf8(); case PropertyId::Color: return getFontColor().toHexString(); case PropertyId::ShadowColor: @@ -651,6 +653,14 @@ std::string UITextView::getPropertyString( const PropertyDefinition* propertyDef return String::toStr( PixelDensity::dpToPx( getOutlineThickness() ) ); case PropertyId::TextStrokeColor: return getOutlineColor().toHexString(); + case PropertyId::Wordwrap: + return mFlags & UI_WORD_WRAP ? "true" : "false"; + case PropertyId::TextSelection: + return isTextSelectionEnabled() ? "true" : "false"; + case PropertyId::TextAlign: + return fontHAlignGet( getFlags() ) == UI_HALIGN_CENTER ? "center" : ( + fontHAlignGet( getFlags() ) == UI_HALIGN_RIGHT ? "right" : "left" + ); default: return UIWidget::getPropertyString( propertyDef ); } diff --git a/src/eepp/ui/uitooltip.cpp b/src/eepp/ui/uitooltip.cpp index 465df153a..8d24a703e 100644 --- a/src/eepp/ui/uitooltip.cpp +++ b/src/eepp/ui/uitooltip.cpp @@ -328,6 +328,33 @@ void UITooltip::setFontStyleConfig(const UIFontStyleConfig & styleConfig) { mTextCache->setOutlineColor( mStyleConfig.OutlineColor ); } +std::string UITooltip::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::Color: + return getFontColor().toHexString(); + case PropertyId::ShadowColor: + return getFontShadowColor().toHexString(); + case PropertyId::FontFamily: + return NULL != getFont() ? getFont()->getName() : ""; + case PropertyId::FontSize: + return String::format( "%ddp", getCharacterSize() ); + case PropertyId::FontStyle: + return Text::styleFlagToString( getFontStyle() ); + case PropertyId::TextStrokeWidth: + return String::toStr( PixelDensity::dpToPx( getOutlineThickness() ) ); + case PropertyId::TextStrokeColor: + return getOutlineColor().toHexString(); + case PropertyId::TextAlign: + return fontHAlignGet( getFlags() ) == UI_HALIGN_CENTER ? "center" : ( + fontHAlignGet( getFlags() ) == UI_HALIGN_RIGHT ? "right" : "left" + ); + default: + return UIWidget::getPropertyString( propertyDef ); + } +} + bool UITooltip::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uitouchdragablewidget.cpp b/src/eepp/ui/uitouchdragablewidget.cpp index c2dfe8537..c17b85c70 100644 --- a/src/eepp/ui/uitouchdragablewidget.cpp +++ b/src/eepp/ui/uitouchdragablewidget.cpp @@ -146,6 +146,20 @@ void UITouchDragableWidget::scheduledUpdate( const Time& time ) { } } +std::string UITouchDragableWidget::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::TouchDrag: + return isTouchDragEnabled() ? "true" : "false"; + case PropertyId::TouchDragDeceleration: + return String::fromFloat( getTouchDragDeceleration().x ) + ", " + + String::fromFloat( getTouchDragDeceleration().y ); + default: + return UIWidget::getPropertyString( propertyDef ); + } +} + bool UITouchDragableWidget::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index 89550e405..d36539d32 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -1379,6 +1379,62 @@ void UIWindow::resizeCursor() { } } +std::string UIWindow::getWindowFlagsString() { + std::vector flags; + if ( getWinFlags() & UI_WIN_DEFAULT_FLAGS) flags.push_back( "default" ); + if ( getWinFlags() & UI_WIN_CLOSE_BUTTON ) flags.push_back( "close" ); + if ( getWinFlags() & UI_WIN_MAXIMIZE_BUTTON ) flags.push_back( "maximize" ); + if ( getWinFlags() & UI_WIN_DRAGABLE_CONTAINER ) flags.push_back( "dragable" ); + if ( getWinFlags() & UI_WIN_SHADOW ) flags.push_back( "shadow" ); + if ( getWinFlags() & UI_WIN_MODAL ) flags.push_back( "modal" ); + if ( getWinFlags() & UI_WIN_NO_DECORATION ) flags.push_back( "borderless" ); + if ( getWinFlags() & UI_WIN_RESIZEABLE ) flags.push_back( "resizeable" ); + if ( getWinFlags() & UI_WIN_SHARE_ALPHA_WITH_CHILDS ) flags.push_back( "sharealpha" ); + if ( getWinFlags() & UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS ) flags.push_back( "buttonactions" ); + if ( getWinFlags() & UI_WIN_FRAME_BUFFER ) flags.push_back( "framebuffer" ); + if ( getWinFlags() & UI_WIN_COLOR_BUFFER ) flags.push_back( "colorbuffer" ); + return String::join( flags, '|' ); +} + +std::string UIWindow::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::Width: + return String::fromFloat( getSize().getWidth(), "dp" ); + case PropertyId::Height: + return String::fromFloat( getSize().getHeight(), "dp" ); + case PropertyId::Title: + return getTitle().toUtf8(); + case PropertyId::BaseAlpha: + return String::toStr( getBaseAlpha() ); + case PropertyId::ButtonsPositionOffset: + return String::format( "%ddp", mStyleConfig.ButtonsPositionFixer.x ) + ", " + + String::format( "%ddp", mStyleConfig.ButtonsPositionFixer.y ); + case PropertyId::WindowFlags: + return getWindowFlagsString(); + case PropertyId::DecorationSize: + return String::format( "%ddp", mStyleConfig.DecorationSize.x ) + ", " + + String::format( "%ddp", mStyleConfig.DecorationSize.y ); + case PropertyId::BorderSize: + return String::format( "%ddp", mStyleConfig.BorderSize.x ) + ", " + + String::format( "%ddp", mStyleConfig.BorderSize.y ); + case PropertyId::MinWindowSize: + return String::fromFloat( mStyleConfig.MinWindowSize.x, "dp" ) + ", " + + String::fromFloat( mStyleConfig.MinWindowSize.y, "dp" ); + case PropertyId::ButtonsSeparation: + return String::format( "%ddp", mStyleConfig.ButtonsSeparation ); + case PropertyId::MinCornerDistance: + return String::format( "%ddp", mStyleConfig.MinCornerDistance ); + case PropertyId::DecorationAutoSize: + return mStyleConfig.DecorationAutoSize ? "true" : "false"; + case PropertyId::BorderAutoSize: + return mStyleConfig.BorderAutoSize ? "true" : "false"; + default: + return UIWidget::getPropertyString( propertyDef ); + } +} + bool UIWindow::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false; @@ -1396,7 +1452,7 @@ bool UIWindow::applyProperty( const StyleSheetProperty& attribute ) { setBaseAlpha( (Uint8)eemin( attribute.asUint(), 255u ) ); break; case PropertyId::ButtonsPositionOffset: - mStyleConfig.ButtonsPositionFixer = attribute.asVector2i(); + mStyleConfig.ButtonsPositionFixer = attribute.asDpDimensionVector2i(); fixChildsSize(); break; case PropertyId::WindowFlags: @@ -1432,15 +1488,15 @@ bool UIWindow::applyProperty( const StyleSheetProperty& attribute ) { break; } case PropertyId::DecorationSize: - mStyleConfig.DecorationSize = attribute.asSizei(); + mStyleConfig.DecorationSize = attribute.asDpDimensionSizei(); fixChildsSize(); break; case PropertyId::BorderSize: - mStyleConfig.BorderSize = attribute.asSizei(); + mStyleConfig.BorderSize = attribute.asDpDimensionSizei(); fixChildsSize(); break; case PropertyId::MinWindowSize: - mStyleConfig.MinWindowSize = attribute.asSizef(); + mStyleConfig.MinWindowSize = attribute.asDpDimensionSizef(); fixChildsSize(); break; case PropertyId::ButtonsSeparation: diff --git a/src/eepp/ui/uiwinmenu.cpp b/src/eepp/ui/uiwinmenu.cpp index a078b1b82..f0c467c40 100644 --- a/src/eepp/ui/uiwinmenu.cpp +++ b/src/eepp/ui/uiwinmenu.cpp @@ -159,6 +159,23 @@ void UIWinMenu::setFirstButtonMargin( const Uint32& buttonMargin ) { refreshButtons(); } +std::string UIWinMenu::getPropertyString( const PropertyDefinition* propertyDef ) { + if ( NULL == propertyDef ) return ""; + + switch ( propertyDef->getPropertyId() ) { + case PropertyId::MarginBetweenButtons: + return String::format( "%ddp", getMarginBetweenButtons() ); + case PropertyId::ButtonMargin: + return String::format( "%ddp", getButtonMargin() ); + case PropertyId::MenuHeight: + return String::format( "%ddp", getMenuHeight() ); + case PropertyId::FirstButtonMarginLeft: + return String::format( "%ddp", getFirstButtonMargin() ); + default: + return UIWidget::getPropertyString( propertyDef ); + } +} + bool UIWinMenu::applyProperty( const StyleSheetProperty& attribute ) { if ( !checkPropertyDefinition( attribute ) ) return false;