diff --git a/bin/assets/layouts/test.css b/bin/assets/layouts/test.css index 64d0a37b2..ff3e733e6 100644 --- a/bin/assets/layouts/test.css +++ b/bin/assets/layouts/test.css @@ -1,35 +1,35 @@ /* Global rules */ * { - textColor: #E6E6E6FF; - textShadowColor: #32323296; - textSelectedColor: #000; - textSelectionBackColor: #969696FF; + color: #E6E6E6FF; + shadow-color: #32323296; + selected-color: #000; + selection-back-color: #969696FF; } TabWidget { - tabSeparation: -1dp; - drawLineBelowTabs: true; - lineBelowTabsColor: #2f3030; - lineBelowTabsYOffset: 0dp; + tab-separation: -1dp; + line-below-tabs: true; + line-below-tabs-color: #2f3030; + line-below-tabs-y-offset: 0dp; } ProgressBar { - displayPercent: true; - verticalExpand: true; - fillerPadding: 2dp; - movementSpeed: 32, 0; + display-percent: true; + vertical-expand: true; + filler-padding: 2dp; + movement-speed: 32, 0; } WinMenu { - buttonMargin: 12dp; + button-margin: 12dp; } Menu, PopUpMenu { - textColor: #E6E6E6FF; - minWidth: 100dp; - minSpaceForIcons: 24dp; - minRightMargin: 8dp; + color: #E6E6E6FF; + min-width: 100dp; + min-icon-space: 24dp; + min-margin-right: 8dp; } Menu:hover, @@ -41,109 +41,109 @@ ListBox::item:hover, Tab:selected, Tab:hover, Tab:pressed { - textColor: #FFF; + color: #FFF; } Slider { - halfSlider: true; - backgroundColor: #555; + half-slider: true; + background-color: #555; } ScrollBar { - expandBackground: true; + background-expand: true; } Window { - winFlags: shadow; - buttonsPositionFixer: -2, 0; + window-flags: shadow; + buttons-position-offset: -2, 0; } Window::title { - textColor: #E6E6E6FF; - textStyle: shadow; + color: #E6E6E6FF; + font-style: shadow; } Tooltip { padding: 8dp; - textColor: black; + color: black; } #lvbox > * { - layout_marginTop: 8dp; + margin-top: 8dp; } #lvbox > #tpad { - layout_marginTop: 0dp; - borderWidth: 2dp; - borderColor: #66666666; - backgroundColor: #33FF3333; - backgroundImage: linear-gradient( #8c8886, #585857 ); - borderRadius: 12; - textSize: 24dp; + margin-top: 0dp; + border-width: 2dp; + border-color: #66666666; + background-color: #33FF3333; + background-image: linear-gradient( #8c8886, #585857 ); + border-radius: 12; + font-size: 24dp; padding: 12dp; - transition: scale 0.25s, rotation 0.25s 0.25s, borderColor 0.25s, backgroundColor 0.25s, borderRadius 0.25s; + transition: scale 0.25s, rotation 0.25s 0.25s, border-color 0.25s, background-color 0.25s, border-radius 0.25s; } #lvbox > #tpad:hover { scale: 1.1; rotation: -3; - backgroundColor: #FF333333; - borderColor: #99999999; - borderRadius: 4; + background-color: #FF333333; + border-color: #99999999; + border-radius: 4; } #tpad2 { - layout_marginLeft: 0; + margin-left: 0; padding: 24dp; opacity: 0.8; - textSize: 24dp; - backgroundColor: #333; + font-size: 24dp; + background-color: #333; transition: all 0.25s; } #tpad2:hover { - layout_marginLeft: 8dp; + margin-left: 8dp; padding: 28dp; opacity: 1; - borderRadius: 24; - backgroundColor: #656; + border-radius: 24; + background-color: #656; } #tpad3 { - borderWidth: 2dp; - borderColor: #1e2021d7; - backgroundImage: linear-gradient( #797a79, #585857 ); - borderRadius: 3; + border-width: 2dp; + border-color: #1e2021d7; + background-image: linear-gradient( #797a79, #585857 ); + border-radius: 3; padding: 12dp; transition: all 0.25; - textStyle: shadow; - textColor: white; + font-style: shadow; + color: white; } #tpad3:hover { - backgroundImage: linear-gradient( #9c9d9b, #5b5b5a ); - borderColor: #1d1f1fd7; - borderRadius: 3; + background-image: linear-gradient( #9c9d9b, #5b5b5a ); + border-color: #1d1f1fd7; + border-radius: 3; cursor: hand; - textShadowColor: black; + shadow-color: black; padding: 18dp 12dp 100dp 12dp; } #tpad3:pressed { - backgroundImage: linear-gradient( #4e4f4d, #414141 ); - borderColor: #222320d7; + background-image: linear-gradient( #4e4f4d, #414141 ); + border-color: #222320d7; padding: 22dp 12dp 120dp 12dp; } #chbox, #rdbut { - textSize:24dp; + font-size:24dp; padding: 12dp; - backgroundColor: #333; + background-color: #333; } #tres { - backgroundColor: #444; + background-color: #444; padding: 8dp; transition: all 0.25s; } @@ -158,7 +158,7 @@ Tooltip { } #pbut:hover { - skinColor: #66ff44; + skin-color: #66ff44; } #test_2 > #rtest { @@ -168,8 +168,8 @@ Tooltip { #test_2 > #rtest #rttv { background: #333; - textSize: 24dp; - borderRadius: 8; + font-size: 24dp; + border-radius: 8; padding: 8dp; transition: all 0.125s; } @@ -188,7 +188,7 @@ Tooltip { #test_2 > #rtest:hover #rttv:pressed { background: lime; - textColor: #333; + color: #333; } #test_3 { @@ -219,7 +219,7 @@ Tooltip { #test_3 > .rooter:hover .outer:hover .inner { background: #DABA22; - layout_marginLeft: 16dp; + margin-left: 16dp; } #test_3 > .rooter:hover .outer:hover .inner:hover { @@ -227,22 +227,22 @@ Tooltip { } #test_4 { - backgroundColor: #221122; + background-color: #221122; } #test_4 > RelativeLayout { - backgroundColor: #331133; + background-color: #331133; padding: 8dp; transition: all 0.125s; } #test_4 > RelativeLayout:hover { - backgroundColor: #442244; + background-color: #442244; cursor: hand; } #test_4 > RelativeLayout:pressed { - backgroundColor: #662266; + background-color: #662266; } #test_4 > RelativeLayout > TextView { @@ -250,83 +250,83 @@ Tooltip { } #test_4 > RelativeLayout:hover > TextView { - layout_marginLeft: 8dp; + margin-left: 8dp; } TabWidget { - paddingLeft: 8dp; - paddingRight: 8dp; - paddingBottom: 8dp; - paddingTop: 20dp; - backgroundColor: #656565; + padding-left: 8dp; + padding-right: 8dp; + padding-bottom: 8dp; + padding-top: 20dp; + background-color: #656565; } #lvbox { - backgroundColor: #222; + background-color: #222; padding: 12dp; } .list { - textSize: 16dp; + font-size: 16dp; padding: 8dp; } #tviewl { - textSize: 24dp; - backgroundColor: #333; + font-size: 24dp; + background-color: #333; } #tinput { - textSize: 24dp; + font-size: 24dp; padding: 24dp; } #rvbox { - backgroundColor: #323232; + background-color: #323232; padding: 12dp; } #rrl { - backgroundColor: #999; + background-color: #999; padding: 24dp; } #rrl > #tmap { - textSize: 24dp; + font-size: 24dp; padding: 12dp; - backgroundColor: #333; + background-color: #333; } .eltv { - textSize: 24dp; + font-size: 24dp; padding: 12dp; - backgroundColor: #242424; + background-color: #242424; } #rrl > #el2, #rrl > #tm, #rrl > #tmp { - layout_margin: 12dp; + margin: 12dp; } #rrl > #slider { padding: 32dp; - backgroundColor: #555; + background-color: #555; } #rrl > #scrollbar { padding: 8dp; - backgroundColor: #12345666; + background-color: #12345666; } #rrl > #spinbox { padding: 8dp; - backgroundColor: #54345666; + background-color: #54345666; } #rrl > TextEdit { padding: 16dp; - layout_marginBottom: 140dp; + margin-bottom: 140dp; } #test_5 { @@ -339,14 +339,14 @@ TabWidget { } #test_5 TextView { - layout_margin: 4dp; + margin: 4dp; padding: 8dp; layout_width: match_parent; skin: button; } #test_6 { - layout_margin: 8dp; + margin: 8dp; background: #323232; } @@ -354,7 +354,7 @@ TabWidget { gravity: center; background: #323232; transition: all 0.2; - scaleType: expand; + scale-type: expand; padding: 4dp; } diff --git a/bin/assets/layouts/test.xml b/bin/assets/layouts/test.xml index 2df15a541..4fa50194d 100644 --- a/bin/assets/layouts/test.xml +++ b/bin/assets/layouts/test.xml @@ -8,12 +8,12 @@ - + - - - - + + + + Test @@ -34,12 +34,12 @@ - + - + - + @@ -51,7 +51,7 @@ - + @@ -76,7 +76,7 @@ - + diff --git a/bin/assets/layouts/test_widgets.xml b/bin/assets/layouts/test_widgets.xml index fee28a16a..b7858ba72 100644 --- a/bin/assets/layouts/test_widgets.xml +++ b/bin/assets/layouts/test_widgets.xml @@ -1,63 +1,63 @@ - + - - - + + + Test Test 2 Test 3 - - + + Test Test 2 Test 3 - - - - - + + + + + Test Test 2 Test 3 - - - - + + + + - - - - - - + + + + + + - - + + - + - + - + - + diff --git a/bin/assets/ui/uitheme.css b/bin/assets/ui/uitheme.css index 664b8525f..0b54264dc 100644 --- a/bin/assets/ui/uitheme.css +++ b/bin/assets/ui/uitheme.css @@ -1,38 +1,38 @@ /* Global rules */ * { - textColor: #E6E6E6FF; - textShadowColor: #32323296; - textSelectedColor: #000; - textSelectionBackColor: #969696FF; + color: #E6E6E6FF; + shadow-color: #32323296; + selected-color: #000; + selection-back-color: #969696FF; } TabWidget { - tabSeparation: -1dp; - drawLineBelowTabs: true; - lineBelowTabsColor: #2f3030; - lineBelowTabsYOffset: 0dp; + tab-separation: -1dp; + line-below-tabs: true; + line-below-tabs-color: #2f3030; + line-below-tabs-y-offset: 0dp; } ProgressBar { - displayPercent: true; - verticalExpand: true; - fillerPadding: 2dp; - movementSpeed: 32, 0; + display-percent: true; + vertical-expand: true; + filler-padding: 2dp; + movement-speed: 32, 0; } WinMenu { - buttonMargin: 12dp; + button-margin: 12dp; } Menu, PopUpMenu { - textColor: #E6E6E6FF; - minWidth: 100dp; - minSpaceForIcons: 24dp; - minRightMargin: 8dp; + color: #E6E6E6FF; + min-width: 100dp; + min-icon-space: 24dp; + min-margin-right: 8dp; } -Menu:hover, +Menu:hover, PopUpMenu:hover, Menu::Item:hover, Menu::CheckBox:hover, @@ -41,28 +41,29 @@ ListBox::item:hover, Tab:selected, Tab:hover, Tab:pressed { - textColor: #FFF; + color: #FFF; } -Slider { - halfSlider: true; +Slider { + half-slider: true; } ScrollBar { - expandBackground: true; + background-expand: true; } Window { - winFlags: shadow; - buttonsPositionFixer: -2, 0; + window-flags: shadow; + buttons-position-offset: -2, 0; } Window::title { - textColor: #E6E6E6FF; - textStyle: shadow; + color: #E6E6E6FF; + font-style: shadow; } Tooltip { padding: 8dp; - textColor: black; + color: black; } + diff --git a/include/eepp/system.hpp b/include/eepp/system.hpp index 8e4c10f60..3939bf625 100644 --- a/include/eepp/system.hpp +++ b/include/eepp/system.hpp @@ -37,5 +37,6 @@ #include #include #include +#include #endif diff --git a/include/eepp/ui/uilistbox.hpp b/include/eepp/ui/uilistbox.hpp index db0f31908..72b33194f 100644 --- a/include/eepp/ui/uilistbox.hpp +++ b/include/eepp/ui/uilistbox.hpp @@ -127,7 +127,9 @@ class EE_API UIListBox : public UITouchDragableWidget { std::vector mItems; std::vector mTexts; - void updateScroll( bool FromScrollChange = false ); + void updateScroll( bool fromScrollChange = false ); + + void updateScrollBarState(); void onScrollValueChange( const Event * Event ); diff --git a/src/eepp/ui/css/stylesheetpropertiesparser.cpp b/src/eepp/ui/css/stylesheetpropertiesparser.cpp index 362861d88..9ec1a5665 100644 --- a/src/eepp/ui/css/stylesheetpropertiesparser.cpp +++ b/src/eepp/ui/css/stylesheetpropertiesparser.cpp @@ -168,17 +168,17 @@ void StyleSheetPropertiesParser::addProperty( const std::string& name, std::stri if ( name == "padding" ) { value = String::toLower( String::trim( value ) ); Rectf rect( NodeAttribute( name, value ).asRectf() ); - mProperties[ "paddingleft" ] = StyleSheetProperty( "paddingleft", String::toStr( rect.Left ) ); - mProperties[ "paddingright" ] = StyleSheetProperty( "paddingright", String::toStr( rect.Right ) ); - mProperties[ "paddingtop" ] = StyleSheetProperty( "paddingtop", String::toStr( rect.Top ) ); - mProperties[ "paddingbottom" ] = StyleSheetProperty( "paddingbottom", String::toStr( rect.Bottom ) ); - } else if ( name == "layout_margin" ) { + mProperties[ "padding-left" ] = StyleSheetProperty( "padding-left", String::toStr( rect.Left ) ); + mProperties[ "padding-right" ] = StyleSheetProperty( "padding-right", String::toStr( rect.Right ) ); + mProperties[ "padding-top" ] = StyleSheetProperty( "padding-top", String::toStr( rect.Top ) ); + mProperties[ "padding-bottom" ] = StyleSheetProperty( "padding-bottom", String::toStr( rect.Bottom ) ); + } else if ( name == "margin" ) { value = String::toLower( String::trim( value ) ); Rect rect( NodeAttribute( name, value ).asRect() ); - mProperties[ "layout_marginleft" ] = StyleSheetProperty( "layout_marginleft", String::toStr( rect.Left ) ); - mProperties[ "layout_marginright" ] = StyleSheetProperty( "layout_marginright", String::toStr( rect.Right ) ); - mProperties[ "layout_margintop" ] = StyleSheetProperty( "layout_margintop", String::toStr( rect.Top ) ); - mProperties[ "layout_marginbottom" ] = StyleSheetProperty( "layout_marginbottom", String::toStr( rect.Bottom ) ); + mProperties[ "margin-left" ] = StyleSheetProperty( "margin-left", String::toStr( rect.Left ) ); + mProperties[ "margin-right" ] = StyleSheetProperty( "margin-right", String::toStr( rect.Right ) ); + mProperties[ "margin-top" ] = StyleSheetProperty( "margin-top", String::toStr( rect.Top ) ); + mProperties[ "margin-bottom" ] = StyleSheetProperty( "margin-bottom", String::toStr( rect.Bottom ) ); } else { mProperties[ name ] = StyleSheetProperty( name, value ); } diff --git a/src/eepp/ui/css/stylesheetproperty.cpp b/src/eepp/ui/css/stylesheetproperty.cpp index 95f7e2e4e..b5aa61c54 100644 --- a/src/eepp/ui/css/stylesheetproperty.cpp +++ b/src/eepp/ui/css/stylesheetproperty.cpp @@ -1,9 +1,5 @@ #include #include -#include -#include -#include -#include namespace EE { namespace UI { namespace CSS { diff --git a/src/eepp/ui/css/stylesheetselectorrule.cpp b/src/eepp/ui/css/stylesheetselectorrule.cpp index 5c42cc082..b4585a8e2 100644 --- a/src/eepp/ui/css/stylesheetselectorrule.cpp +++ b/src/eepp/ui/css/stylesheetselectorrule.cpp @@ -97,6 +97,7 @@ void StyleSheetSelectorRule::pushSelectorTypeIdentifier( TypeIdentifier selector case GLOBAL: mTagName = name; mSpecificity += SpecificityGlobal; + break; case TAG: mTagName = name; mSpecificity += SpecificityTag; diff --git a/src/eepp/ui/tools/textureatlaseditor.cpp b/src/eepp/ui/tools/textureatlaseditor.cpp index c1c8cfae3..61e6c3cc4 100644 --- a/src/eepp/ui/tools/textureatlaseditor.cpp +++ b/src/eepp/ui/tools/textureatlaseditor.cpp @@ -60,47 +60,47 @@ TextureAtlasEditor::TextureAtlasEditor( UIWindow * AttatchTo, const TGEditorClos - - - + flags="clip" background-color="#00000032" border-width="1" border-color="#000000FF" /> + + + Linear Nearest - + - + - + - - + + - - + + - - + + - - + + - - - - + + + + diff --git a/src/eepp/ui/tools/textureatlasnew.cpp b/src/eepp/ui/tools/textureatlasnew.cpp index 8c095c371..46c231610 100644 --- a/src/eepp/ui/tools/textureatlasnew.cpp +++ b/src/eepp/ui/tools/textureatlasnew.cpp @@ -28,10 +28,10 @@ TextureAtlasNew::TextureAtlasNew( TGCreateCb NewTGCb ) : mUIWindow->setTitle( "New Texture Atlas" ); std::string layout = R"xml( - - + + - + TGA BMP PNG @@ -39,21 +39,21 @@ TextureAtlasNew::TextureAtlasNew( TGCreateCb NewTGCb ) : JPG - + - + - + - + - + MDPI HDPI XHDPI @@ -61,20 +61,20 @@ TextureAtlasNew::TextureAtlasNew( TGCreateCb NewTGCb ) : XXXHDPI - + - + Linear Nearest - + - - + + diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index 8fa488d26..01ee8240b 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -263,10 +263,17 @@ void UIDropDownList::destroyListBox() { bool UIDropDownList::setAttribute( const NodeAttribute& attribute, const Uint32& state ) { const std::string& name = attribute.getName(); - if ( "popuptomaincontrol" == name ) { + if ( "popup-to-main-control" == name || "popuptomaincontrol" == name ) { setPopUpToMainControl( attribute.asBool() ); - } else if ( "maxnumvisibleitems" == name ) { + } else if ( "max-visible-items" == name || "maxvisibleitems" == name ) { setMaxNumVisibleItems( attribute.asUint() ); + } else if ( "selected-index" == name || "selected-text" == name || + "scrollbar-type" == name || "row-height" == name || + "vscroll-mode" == name || "hscroll-mode" == name || + "selectedindex" == name || "selectedtext" == name || + "scrollbartype" == name || "rowheight" == name || + "vscrollmode" == name || "hscrollmode" == name) { + mListBox->setAttribute( attribute, state ); } else { return UITextInput::setAttribute( attribute, state ); } @@ -277,16 +284,10 @@ bool UIDropDownList::setAttribute( const NodeAttribute& attribute, const Uint32& void UIDropDownList::loadFromXmlNode(const pugi::xml_node & node) { beginAttributesTransaction(); - UITextInput::loadFromXmlNode( node ); - - for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) { - if ( String::startsWith( std::string( ait->name() ), "listbox_" ) ) { - mListBox->setAttribute( NodeAttribute( std::string( ait->name() + 8 ), ait->value() ) ); - } - } - mListBox->loadItemsFromXmlNode( node ); + UITextInput::loadFromXmlNode( node ); + endAttributesTransaction(); } diff --git a/src/eepp/ui/uigridlayout.cpp b/src/eepp/ui/uigridlayout.cpp index e33114971..bb6c1bf49 100644 --- a/src/eepp/ui/uigridlayout.cpp +++ b/src/eepp/ui/uigridlayout.cpp @@ -207,29 +207,29 @@ Sizef UIGridLayout::getTargetElementSize() const { bool UIGridLayout::setAttribute( const NodeAttribute& attribute, const Uint32& state ) { const std::string& name = attribute.getName(); - if ( "columnspan" == name ) { + if ( "column-span" == name || "columnspan" == name ) { setSpan( Sizei( attribute.asInt(), mSpan.y ) ); - } else if ( "rowspan" == name ) { + } else if ( "row-span" == name || "rowspan" == name ) { setSpan( Sizei( mSpan.x, attribute.asInt() ) ); } else if ( "span" == name ) { setSpan( Sizei( attribute.asInt(), attribute.asInt() ) ); - } else if ( "columnmode" == name ) { + } else if ( "column-mode" == name || "columnmode" == name ) { std::string val( attribute.asString() ); String::toLowerInPlace( val ); setColumnMode( "size" == val ? Size : Weight ); - } else if ( "rowmode" == name ) { + } else if ( "row-mode" == name || "rowmode" == name ) { std::string val( attribute.asString() ); String::toLowerInPlace( val ); setRowMode( "size" == val ? Size : Weight ); - } else if ( "columnweight" == name ) { + } else if ( "column-weight" == name || "columnweight" == name ) { setColumnWeight( attribute.asFloat() ); - } else if ( "columnwidth" == name ) { + } else if ( "column-width" == name || "columnwidth" == name ) { setColumnWidth( attribute.asInt() ); - } else if ( "rowweight" == name ) { + } else if ( "row-weight" == name || "rowweight" == name ) { setRowWeight( attribute.asFloat() ); - } else if ( "rowheight" == name ) { + } else if ( "row-height" == name || "rowheight" == name ) { setRowHeight( attribute.asInt() ); - } else if ( "reversedraw" == name ) { + } else if ( "reverse-draw" == name || "reversedraw" == name ) { setReverseDraw( attribute.asBool() ); } else { return UILayout::setAttribute( attribute, state ); diff --git a/src/eepp/ui/uiimage.cpp b/src/eepp/ui/uiimage.cpp index 16459f539..1eff6bcc1 100644 --- a/src/eepp/ui/uiimage.cpp +++ b/src/eepp/ui/uiimage.cpp @@ -221,7 +221,7 @@ bool UIImage::setAttribute( const NodeAttribute& attribute, const Uint32& state setDrawable( res ); } - } else if ( "scaletype" == name ) { + } else if ( "scale-type" == name || "scaletype" == name ) { std::string val = attribute.asString(); String::toLowerInPlace( val ); diff --git a/src/eepp/ui/uilistbox.cpp b/src/eepp/ui/uilistbox.cpp index 17e397ee1..3395b6435 100644 --- a/src/eepp/ui/uilistbox.cpp +++ b/src/eepp/ui/uilistbox.cpp @@ -311,6 +311,7 @@ void UIListBox::onSizeChange() { } containerResize(); + updateScrollBarState(); updateListBoxItemsSize(); updateScroll(); @@ -451,22 +452,11 @@ void UIListBox::createItemIndex( const Uint32& i ) { } } -void UIListBox::updateScroll( bool FromScrollChange ) { - if ( !mItems.size() ) - return; +void UIListBox::updateScrollBarState() { + bool clipped = 0 != mContainer->isClipped(); - UIListBoxItem * Item; - Uint32 i, RelPos = 0, RelPosMax; - Int32 ItemPos, ItemPosMax; - Int32 tHLastScroll = mHScrollInit; - - Uint32 VisibleItems = mContainer->getSize().getHeight() / mRowHeight; - mItemsNotVisible = (Int32)mItems.size() - VisibleItems; - - bool wasScrollVisible = mVScrollBar->isVisible(); - bool wasHScrollVisible = mHScrollBar->isVisible(); - - bool Clipped = 0 != mContainer->isClipped(); + Uint32 visibleItems = mContainer->getSize().getHeight() / mRowHeight; + mItemsNotVisible = (Int32)mItems.size() - visibleItems; if ( mItemsNotVisible <= 0 ) { if ( UI_SCROLLBAR_ALWAYS_ON == mVScrollMode ) { @@ -486,7 +476,7 @@ void UIListBox::updateScroll( bool FromScrollChange ) { } } - if ( Clipped && ( UI_SCROLLBAR_AUTO == mHScrollMode || UI_SCROLLBAR_ALWAYS_ON == mHScrollMode ) ) { + if ( clipped && ( UI_SCROLLBAR_AUTO == mHScrollMode || UI_SCROLLBAR_ALWAYS_ON == mHScrollMode ) ) { if ( ( mVScrollBar->isVisible() && mContainer->getPixelsSize().getWidth() - mVScrollBar->getPixelsSize().getWidth() < (Int32)mMaxTextWidth ) || ( !mVScrollBar->isVisible() && mContainer->getPixelsSize().getWidth() < (Int32)mMaxTextWidth ) ) { mHScrollBar->setVisible( true ); @@ -515,41 +505,57 @@ void UIListBox::updateScroll( bool FromScrollChange ) { } } } +} - VisibleItems = mContainer->getSize().getHeight() / mRowHeight; - mItemsNotVisible = (Uint32)mItems.size() - VisibleItems; - Int32 Scrolleable = (Int32)mItems.size() * mRowHeight - mContainer->getSize().getHeight(); +void UIListBox::updateScroll( bool fromScrollChange ) { + if ( !mItems.size() ) + return; + + bool clipped = 0 != mContainer->isClipped(); + UIListBoxItem * item; + Uint32 i, relPos = 0, relPosMax; + Int32 itemPos, itemPosMax; + Int32 tHLastScroll = mHScrollInit; + + bool wasScrollVisible = mVScrollBar->isVisible(); + bool wasHScrollVisible = mHScrollBar->isVisible(); + + updateScrollBarState(); + + bool visibleItems = mContainer->getSize().getHeight() / mRowHeight; + mItemsNotVisible = (Uint32)mItems.size() - visibleItems; + Int32 scrolleable = (Int32)mItems.size() * mRowHeight - mContainer->getSize().getHeight(); bool isScrollVisible = mVScrollBar->isVisible(); bool isHScrollVisible = mHScrollBar->isVisible(); bool FirstVisible = false; - if ( Clipped && mSmoothScroll ) { - if ( Scrolleable >= 0 ) - RelPos = (Uint32)( mVScrollBar->getValue() * Scrolleable ); + if ( clipped && mSmoothScroll ) { + if ( scrolleable >= 0 ) + relPos = (Uint32)( mVScrollBar->getValue() * scrolleable ); else - RelPos = 0; + relPos = 0; - RelPosMax = RelPos + mContainer->getSize().getHeight() + mRowHeight; + relPosMax = relPos + mContainer->getSize().getHeight() + mRowHeight; - if ( ( FromScrollChange && eeINDEX_NOT_FOUND != mLastPos && mLastPos == RelPos ) && ( tHLastScroll == mHScrollInit ) ) + if ( ( fromScrollChange && eeINDEX_NOT_FOUND != mLastPos && mLastPos == relPos ) && ( tHLastScroll == mHScrollInit ) ) return; - mLastPos = RelPos; + mLastPos = relPos; for ( i = 0; i < mItems.size(); i++ ) { - Item = mItems[i]; - ItemPos = mRowHeight * i; - ItemPosMax = ItemPos + mRowHeight; + item = mItems[i]; + itemPos = mRowHeight * i; + itemPosMax = itemPos + mRowHeight; - if ( ( ItemPos >= (Int32)RelPos || ItemPosMax >= (Int32)RelPos ) && ( ItemPos <= (Int32)RelPosMax ) ) { - if ( NULL == Item ) { + if ( ( itemPos >= (Int32)relPos || itemPosMax >= (Int32)relPos ) && ( itemPos <= (Int32)relPosMax ) ) { + if ( NULL == item ) { createItemIndex( i ); - Item = mItems[i]; + item = mItems[i]; } - Item->setPosition( mHScrollInit, ItemPos - (Int32)RelPos ); - Item->setEnabled( true ); - Item->setVisible( true ); + item->setPosition( mHScrollInit, itemPos - (Int32)relPos ); + item->setEnabled( true ); + item->setVisible( true ); if ( !FirstVisible ) { mVisibleFirst = i; @@ -559,44 +565,44 @@ void UIListBox::updateScroll( bool FromScrollChange ) { mVisibleLast = i; } else { eeSAFE_DELETE( mItems[i] ); - Item = NULL; + item = NULL; } - if ( NULL != Item ) { + if ( NULL != item ) { if ( ( !wasScrollVisible && isScrollVisible ) || ( wasScrollVisible && !isScrollVisible ) ||( !wasHScrollVisible && isHScrollVisible ) || ( wasHScrollVisible && !isHScrollVisible ) ) - itemUpdateSize( Item ); + itemUpdateSize( item ); } } } else { - RelPosMax = (Uint32)mItems.size(); + relPosMax = (Uint32)mItems.size(); if ( mItemsNotVisible > 0 ) { - RelPos = (Uint32)( mVScrollBar->getValue() * mItemsNotVisible ); - RelPosMax = RelPos + VisibleItems; + relPos = (Uint32)( mVScrollBar->getValue() * mItemsNotVisible ); + relPosMax = relPos + visibleItems; } - if ( ( FromScrollChange && eeINDEX_NOT_FOUND != mLastPos && mLastPos == RelPos ) && ( !Clipped || tHLastScroll == mHScrollInit ) ) + if ( ( fromScrollChange && eeINDEX_NOT_FOUND != mLastPos && mLastPos == relPos ) && ( !clipped || tHLastScroll == mHScrollInit ) ) return; - mLastPos = RelPos; + mLastPos = relPos; for ( i = 0; i < mItems.size(); i++ ) { - Item = mItems[i]; - ItemPos = mRowHeight * ( (Int32)i - (Int32)RelPos ); + item = mItems[i]; + itemPos = mRowHeight * ( (Int32)i - (Int32)relPos ); - if ( i >= RelPos && i < RelPosMax ) { - if ( NULL == Item ) { + if ( i >= relPos && i < relPosMax ) { + if ( NULL == item ) { createItemIndex( i ); - Item = mItems[i]; + item = mItems[i]; } - if ( Clipped ) - Item->setPosition( mHScrollInit, ItemPos ); + if ( clipped ) + item->setPosition( mHScrollInit, itemPos ); else - Item->setPosition( 0, ItemPos ); + item->setPosition( 0, itemPos ); - Item->setEnabled( true ); - Item->setVisible( true ); + item->setEnabled( true ); + item->setVisible( true ); if ( !FirstVisible ) { mVisibleFirst = i; @@ -606,12 +612,12 @@ void UIListBox::updateScroll( bool FromScrollChange ) { mVisibleLast = i; } else { eeSAFE_DELETE( mItems[i] ); - Item = NULL; + item = NULL; } - if ( NULL != Item ) { + if ( NULL != item ) { if ( ( !wasScrollVisible && isScrollVisible ) || ( wasScrollVisible && !isScrollVisible ) ||( !wasHScrollVisible && isHScrollVisible ) || ( wasHScrollVisible && !isHScrollVisible ) ) - itemUpdateSize( Item ); + itemUpdateSize( item ); } } } @@ -953,30 +959,30 @@ const UI_SCROLLBAR_MODE& UIListBox::getHorizontalScrollMode() { bool UIListBox::setAttribute( const NodeAttribute& attribute, const Uint32& state ) { const std::string& name = attribute.getName(); - if ( "rowheight" == name ) { + if ( "row-height" == name || "rowheight" == name ) { setRowHeight( attribute.asInt() ); - } else if ( "verticalscrollmode" == name || "vscrollmode" == name ) { + } else if ( "vscroll-mode" == name || "vscrollmode" == name ) { std::string val = attribute.asString(); if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO ); else if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON ); else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_OFF ); - } else if ( "horizontalscrollmode" == name || "hscrollmode" == name ) { + } else if ( "hscroll-mode" == name || "hscrollmode" == name ) { std::string val = attribute.asString(); if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO ); else if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON ); else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_OFF ); - } else if ( "selectedindex" == name ) { + } else if ( "selected-index" == name || "selectedindex" == name ) { setSelected( attribute.asUint() ); - } else if ( "selectedtext" == name ) { + } else if ( "selected-text" == name || "selectedtext" == name ) { setSelected( attribute.asString() ); - } else if ( "scrollbartype" == name ) { + } else if ( "scrollbar-type" == name || "scrollbartype" == name ) { std::string val( attribute.asString() ); String::toLowerInPlace( val ); - if ( "nobuttons" == val ) { + if ( "no-buttons" == val || "nobuttons" == val ) { mVScrollBar->setScrollBarType( UIScrollBar::NoButtons ); mHScrollBar->setScrollBarType( UIScrollBar::NoButtons ); - } else if ( "twobuttons" == val ) { + } else if ( "two-buttons" == val || "twobuttons" == val ) { mVScrollBar->setScrollBarType( UIScrollBar::TwoButtons ); mHScrollBar->setScrollBarType( UIScrollBar::NoButtons ); } diff --git a/src/eepp/ui/uiloader.cpp b/src/eepp/ui/uiloader.cpp index 0a0b86c03..1ce9d0b40 100644 --- a/src/eepp/ui/uiloader.cpp +++ b/src/eepp/ui/uiloader.cpp @@ -200,19 +200,19 @@ bool UILoader::setAttribute( const NodeAttribute& attribute, const Uint32& state if ( "indeterminate" == name ) { setIndeterminate( attribute.asBool() ); - } else if ( "maxprogress" == name ) { + } else if ( "max-progress" == name || "maxprogress" == name ) { setMaxProgress( attribute.asFloat() ); } else if ( "progress" == name ) { setProgress( attribute.asFloat() ); - } else if ( "fillcolor" == name ) { + } else if ( "fill-color" == name || "fillcolor" == name ) { setFillColor( attribute.asColor() ); } else if ( "radius" == name ) { setRadius( attribute.asFloat() ); - } else if ( "outlinethickness" == name ) { + } else if ( "outline-thickness" == name || "outlinethickness" == name ) { setOutlineThickness( attribute.asFloat() ); - } else if ( "animationspeed" == name ) { + } else if ( "animation-speed" == name || "animationspeed" == name ) { setAnimationSpeed( attribute.asFloat() ); - } else if ( "arcstartangle" == name ) { + } else if ( "arc-start-angle" == name || "arcstartangle" == name ) { setArcStartAngle( attribute.asFloat() ); } else { return UIWidget::setAttribute( attribute, state ); diff --git a/src/eepp/ui/uimenu.cpp b/src/eepp/ui/uimenu.cpp index 84d55cc69..925e5e640 100644 --- a/src/eepp/ui/uimenu.cpp +++ b/src/eepp/ui/uimenu.cpp @@ -191,12 +191,12 @@ UINode * UIMenu::getItem( const String& Text ) { for ( Uint32 i = 0; i < mItems.size(); i++ ) { if ( mItems[i]->isType( UI_TYPE_MENUITEM ) ) { UIMenuItem * tMenuItem = reinterpret_cast( mItems[i] ); - + if ( tMenuItem->getText() == Text ) return tMenuItem; } } - + return NULL; } @@ -573,12 +573,12 @@ void UIMenu::loadFromXmlNode( const pugi::xml_node& node ) { bool UIMenu::setAttribute(const NodeAttribute & attribute, const Uint32 & state) { const std::string& name = attribute.getName(); - if ( "minwidth" == name ) { + if ( "min-width" == name || "minwidth" == name ) { mStyleConfig.MinWidth = attribute.asInt(); onSizeChange(); - } else if ( "minrightmargin" == name ) { + } else if ( "min-margin-right" == name || "minmarginright" == name ) { setMinRightMargin( attribute.asDpDimensionUint() ); - } else if ( "minspaceforicons" == name ) { + } else if ( "min-icon-space" == name || "miniconspace" == name ) { setMinSpaceForIcons( attribute.asDpDimensionUint() ); } else { return UIWidget::setAttribute( attribute, state ); diff --git a/src/eepp/ui/uiprogressbar.cpp b/src/eepp/ui/uiprogressbar.cpp index 2e7dda385..5bf7f323f 100644 --- a/src/eepp/ui/uiprogressbar.cpp +++ b/src/eepp/ui/uiprogressbar.cpp @@ -210,26 +210,26 @@ UITextView * UIProgressBar::getTextBox() const { bool UIProgressBar::setAttribute( const NodeAttribute& attribute, const Uint32& state ) { const std::string& name = attribute.getName(); - if ( "totalsteps" == name ) { + if ( "total-steps" == name || "totalsteps" == name ) { setTotalSteps( attribute.asFloat() ); } else if ( "progress" == name ) { setProgress( attribute.asFloat() ); - } else if ( "verticalexpand" == name ) { + } else if ( "vertical-expand" == name || "verticalexpand" == name ) { setVerticalExpand( attribute.asBool() ); - } else if ( "displaypercent" == name ) { + } else if ( "display-percent" == name || "displaypercent" == name ) { setDisplayPercent( attribute.asBool() ); - } else if ( "fillerpadding" == name ) { + } else if ( "filler-padding" == name || "fillerpadding" == name ) { Float val = attribute.asDpDimension(); setFillerPadding( Rectf( val, val, val, val ) ); - } else if ( "fillerpaddingleft" == name ) { + } else if ( "filler-padding-left" == name || "fillerpaddingleft" == name ) { setFillerPadding( Rectf( attribute.asDpDimension(), mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) ); - } else if ( "fillerpaddingright" == name ) { + } else if ( "filler-padding-right" == name || "fillerpaddingright" == name ) { setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, attribute.asDpDimension(), mStyleConfig.FillerPadding.Bottom ) ); - } else if ( "fillerpaddingtop" == name ) { + } else if ( "filler-padding-top" == name || "fillerpaddingtop" == name ) { setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, attribute.asDpDimension(), mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) ); - } else if ( "fillerpaddingbottom" == name ) { + } else if ( "filler-padding-bottom" == name || "fillerpaddingbottom" == name ) { setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, attribute.asDpDimension() ) ); - } else if ( "movementspeed" == name ) { + } else if ( "movement-speed" == name || "movementspeed" == name ) { setMovementSpeed( attribute.asVector2f() ); } else { return UIWidget::setAttribute( attribute, state ); @@ -244,7 +244,7 @@ const UIProgressBar::StyleConfig & UIProgressBar::getStyleConfig() const { void UIProgressBar::onAlphaChange() { UINode::onAlphaChange(); - + mTextBox->setAlpha( mAlpha ); } diff --git a/src/eepp/ui/uipushbutton.cpp b/src/eepp/ui/uipushbutton.cpp index 8a7f907bf..66a102e29 100644 --- a/src/eepp/ui/uipushbutton.cpp +++ b/src/eepp/ui/uipushbutton.cpp @@ -301,11 +301,11 @@ bool UIPushButton::setAttribute( const NodeAttribute& attribute, const Uint32& s } else if ( NULL != ( icon = DrawableSearcher::searchByName( val ) ) ) { setIcon( icon ); } - } else if ( "iconminsize" == name ) { + } else if ( "min-icon-size" == name || "miniconsize" == name ) { setIconMinimumSize( attribute.asSizei() ); - } else if ( "iconhorizontalmargin" == name ) { + } else if ( "icon-horizontal-margin" == name || "iconhorizontalmargin" == name ) { setIconHorizontalMargin( attribute.asInt() ); - } else if ( "iconautomargin" == name ) { + } else if ( "icon-auto-margin" == name || "iconautomargin" == name ) { mStyleConfig.IconAutoMargin = attribute.asBool(); if ( mStyleConfig.IconAutoMargin ) diff --git a/src/eepp/ui/uiscrollbar.cpp b/src/eepp/ui/uiscrollbar.cpp index 0dbeaa57f..f303247dd 100644 --- a/src/eepp/ui/uiscrollbar.cpp +++ b/src/eepp/ui/uiscrollbar.cpp @@ -315,29 +315,27 @@ bool UIScrollBar::setAttribute( const NodeAttribute& attribute, const Uint32& st setOrientation( UI_HORIZONTAL ); else if ( "vertical" == val ) setOrientation( UI_VERTICAL ); - } else if ( "minvalue" == name ) { + } else if ( "min-value" == name || "minvalue" == name ) { setMinValue( attribute.asFloat() ); - } else if ( "maxvalue" == name ) { + } else if ( "max-value" == name || "maxvalue" == name ) { setMaxValue( attribute.asFloat() ); } else if ( "value" == name ) { setValue( attribute.asFloat() ); - } else if ( "clickstep" == name ) { + } else if ( "click-step" == name || "clickstep" == name ) { setClickStep( attribute.asFloat() ); - } else if ( "pagestep" == name ) { + } else if ( "page-step" == name || "pagestep" == name ) { setPageStep( attribute.asFloat() ); - } else if ( "scrollbartype" == name ) { + } else if ( "scrollbar-type" == name || "scrollbartype" == name ) { std::string val = attribute.asString(); String::toLowerInPlace( val ); - if ( "nobuttons" == val ) { + if ( "no-buttons" == val || "nobuttons" == val ) { setScrollBarType( NoButtons ); - } else if ( "twobuttons" == val ) { + } else if ( "two-buttons" == val || "twobuttons" == val ) { setScrollBarType( TwoButtons ); } - } else if ( "expandbackground" == name ) { + } else if ( "background-expand" == name || "backgroundexpand" == name ) { setExpandBackground( attribute.asBool() ); - } else if ( "padding" == name ) { - return UIWidget::setAttribute( attribute, state ); } else { return UIWidget::setAttribute( attribute, state ); } @@ -375,7 +373,7 @@ UINode * UIScrollBar::setOrientation( const UI_ORIENTATION & orientation ) { void UIScrollBar::onAlphaChange() { UINode::onAlphaChange(); - + mSlider->setAlpha( mAlpha ); mBtnUp->setAlpha( mAlpha ); mBtnDown->setAlpha( mAlpha ); diff --git a/src/eepp/ui/uiscrollview.cpp b/src/eepp/ui/uiscrollview.cpp index 307cb1c9e..2e86130fa 100644 --- a/src/eepp/ui/uiscrollview.cpp +++ b/src/eepp/ui/uiscrollview.cpp @@ -250,28 +250,28 @@ bool UIScrollView::setAttribute( const NodeAttribute& attribute, const Uint32& s if ( "inclusive" == val ) setViewType( Inclusive ); else if ( "exclusive" == val ) setViewType( Exclusive ); - } else if ( "vscroll_mode" == name ) { + } else if ( "vscroll-mode" == name || "vscrollmode" == name ) { std::string val( attribute.asString() ); String::toLowerInPlace( val ); if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON ); else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON ); else if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO ); - } else if ( "hscroll_mode" == name ) { + } else if ( "hscroll-mode" == name || "hscrollmode" == name ) { std::string val( attribute.asString() ); String::toLowerInPlace( val ); if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON ); else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON ); else if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO ); - } else if ( "scrollbartype" == name ) { + } else if ( "scrollbar-type" == name || "scrollbartype" == name ) { std::string val( attribute.asString() ); String::toLowerInPlace( val ); - if ( "nobuttons" == val ) { + if ( "no-buttons" == val || "nobuttons" == val ) { mVScroll->setScrollBarType( UIScrollBar::NoButtons ); mHScroll->setScrollBarType( UIScrollBar::NoButtons ); - } else if ( "twobuttons" == val ) { + } else if ( "two-buttons" == val || "twobuttons" == val ) { mVScroll->setScrollBarType( UIScrollBar::TwoButtons ); mHScroll->setScrollBarType( UIScrollBar::NoButtons ); } diff --git a/src/eepp/ui/uislider.cpp b/src/eepp/ui/uislider.cpp index b999fe4ec..cd094d3b3 100644 --- a/src/eepp/ui/uislider.cpp +++ b/src/eepp/ui/uislider.cpp @@ -105,9 +105,7 @@ void UISlider::onPaddingChange() { } void UISlider::adjustChilds() { - UISkin * tSkin = NULL; - - tSkin = mSlider->getSkin(); + UISkin * tSkin = mSlider->getSkin(); if ( NULL != tSkin ) { if ( mPageStep == 0 ) { @@ -183,7 +181,7 @@ void UISlider::fixSliderPos() { mSlider->setPosition( mBackSlider->getSize().getWidth() + mPadding.Left, 0 ); } else { if ( mSlider->getPosition().x > mBackSlider->getSize().getWidth() - mSlider->getSize().getWidth() + mPadding.Left ) - mSlider->setPosition( mBackSlider->getSize().getWidth() - mSlider->getSize().getWidth() + mPadding.Left, 0 ); + mSlider->setPosition( eemax(0.f, mBackSlider->getSize().getWidth() - mSlider->getSize().getWidth()) + mPadding.Left, 0 ); } mSlider->centerVertical(); @@ -203,7 +201,7 @@ void UISlider::fixSliderPos() { mSlider->setPosition( 0, mBackSlider->getSize().getHeight() + mPadding.Top ); } else { if ( mSlider->getPosition().y > mBackSlider->getSize().getHeight() - mSlider->getSize().getHeight() + mPadding.Top ) { - mSlider->setPosition( 0, mBackSlider->getSize().getHeight() - mSlider->getSize().getHeight() + mPadding.Top ); + mSlider->setPosition( 0, eemax(0.f, mBackSlider->getSize().getHeight() - mSlider->getSize().getHeight()) + mPadding.Top ); } } @@ -411,7 +409,7 @@ UINode * UISlider::getSliderButton() const { void UISlider::onAlphaChange() { UINode::onAlphaChange(); - + mBackSlider->setAlpha( mAlpha ); mSlider->setAlpha( mAlpha ); } @@ -439,19 +437,19 @@ bool UISlider::setAttribute( const NodeAttribute& attribute, const Uint32& state setOrientation( UI_HORIZONTAL ); else if ( "vertical" == val ) setOrientation( UI_VERTICAL ); - } else if ( "minvalue" == name ) { + } else if ( "min-value" == name || "minvalue" == name ) { setMinValue( attribute.asFloat() ); - } else if ( "maxvalue" == name ) { + } else if ( "max-value" == name || "maxvalue" == name ) { setMaxValue( attribute.asFloat() ); } else if ( "value" == name ) { setValue( attribute.asFloat() ); - } else if ( "clickstep" == name ) { + } else if ( "click-step" == name || "clickstep" == name ) { setClickStep( attribute.asFloat() ); - } else if ( "pagestep" == name ) { + } else if ( "page-step" == name || "pagestep" == name ) { setPageStep( attribute.asFloat() ); - } else if ( "halfslider" == name ) { + } else if ( "half-slider" == name || "halfslider" == name ) { setAllowHalfSliderOut( attribute.asBool() ); - } else if ( "expandbackground" == name ) { + } else if ( "background-expand" == name || "backgroundexpand" == name ) { setExpandBackground( attribute.asBool() ); } else { return UIWidget::setAttribute( attribute, state ); diff --git a/src/eepp/ui/uispinbox.cpp b/src/eepp/ui/uispinbox.cpp index 1c4a091a5..96abe1a16 100644 --- a/src/eepp/ui/uispinbox.cpp +++ b/src/eepp/ui/uispinbox.cpp @@ -262,7 +262,7 @@ bool UISpinBox::dotsInNumbersAllowed() { void UISpinBox::onAlphaChange() { UINode::onAlphaChange(); - + mInput->setAlpha( mAlpha ); mPushUp->setAlpha( mAlpha ); mPushDown->setAlpha( mAlpha ); @@ -278,13 +278,13 @@ bool UISpinBox::setAttribute( const NodeAttribute& attribute, const Uint32& stat bool attributeSet = true; - if ( "minvalue" == name ) { + if ( "min-value" == name || "minvalue" == name ) { setMinValue(attribute.asFloat() ); - } else if ( "maxvalue" == name ) { + } else if ( "max-value" == name || "maxvalue" == name ) { setMaxValue(attribute.asFloat() ); } else if ( "value" == name ) { setValue(attribute.asFloat() ); - } else if ( "clickstep" == name ) { + } else if ( "click-step" == name || "clickstep" == name ) { setClickStep(attribute.asFloat() ); } else { attributeSet = UIWidget::setAttribute( attribute, state ); diff --git a/src/eepp/ui/uistyle.cpp b/src/eepp/ui/uistyle.cpp index 856d69359..aa5f00c64 100644 --- a/src/eepp/ui/uistyle.cpp +++ b/src/eepp/ui/uistyle.cpp @@ -32,16 +32,16 @@ bool UIStyle::stateExists( const EE::Uint32& ) const { void UIStyle::setStyleSheetProperty( const StyleSheetProperty& attribute ) { if ( attribute.getName() == "padding" ) { Rectf rect( NodeAttribute( attribute.getName(), attribute.getValue() ).asRectf() ); - mElementStyle.setProperty( StyleSheetProperty( "paddingleft", String::toStr( rect.Left ), attribute.getSpecificity(), attribute.isVolatile() ) ); - mElementStyle.setProperty( StyleSheetProperty( "paddingright", String::toStr( rect.Right ), attribute.getSpecificity(), attribute.isVolatile() ) ); - mElementStyle.setProperty( StyleSheetProperty( "paddingtop", String::toStr( rect.Top ), attribute.getSpecificity(), attribute.isVolatile() ) ); - mElementStyle.setProperty( StyleSheetProperty( "paddingbottom", String::toStr( rect.Bottom ), attribute.getSpecificity(), attribute.isVolatile() ) ); - } else if ( attribute.getName() == "layout_margin" ) { + mElementStyle.setProperty( StyleSheetProperty( "padding-left", String::toStr( rect.Left ), attribute.getSpecificity(), attribute.isVolatile() ) ); + mElementStyle.setProperty( StyleSheetProperty( "padding-right", String::toStr( rect.Right ), attribute.getSpecificity(), attribute.isVolatile() ) ); + mElementStyle.setProperty( StyleSheetProperty( "padding-top", String::toStr( rect.Top ), attribute.getSpecificity(), attribute.isVolatile() ) ); + mElementStyle.setProperty( StyleSheetProperty( "padding-bottom", String::toStr( rect.Bottom ), attribute.getSpecificity(), attribute.isVolatile() ) ); + } else if ( attribute.getName() == "margin" ) { Rect rect( NodeAttribute( attribute.getName(), attribute.getValue() ).asRect() ); - mElementStyle.setProperty( StyleSheetProperty( "layout_marginleft", String::toStr( rect.Left ), attribute.getSpecificity(), attribute.isVolatile() ) ); - mElementStyle.setProperty( StyleSheetProperty( "layout_marginright", String::toStr( rect.Right ), attribute.getSpecificity(), attribute.isVolatile() ) ); - mElementStyle.setProperty( StyleSheetProperty( "layout_margintop", String::toStr( rect.Top ), attribute.getSpecificity(), attribute.isVolatile() ) ); - mElementStyle.setProperty( StyleSheetProperty( "layout_marginbottom", String::toStr( rect.Bottom ), attribute.getSpecificity(), attribute.isVolatile() ) ); + mElementStyle.setProperty( StyleSheetProperty( "margin-left", String::toStr( rect.Left ), attribute.getSpecificity(), attribute.isVolatile() ) ); + mElementStyle.setProperty( StyleSheetProperty( "margin-right", String::toStr( rect.Right ), attribute.getSpecificity(), attribute.isVolatile() ) ); + mElementStyle.setProperty( StyleSheetProperty( "margin-top", String::toStr( rect.Top ), attribute.getSpecificity(), attribute.isVolatile() ) ); + mElementStyle.setProperty( StyleSheetProperty( "margin-bottom", String::toStr( rect.Bottom ), attribute.getSpecificity(), attribute.isVolatile() ) ); } else { mElementStyle.setProperty( attribute ); } diff --git a/src/eepp/ui/uitab.cpp b/src/eepp/ui/uitab.cpp index cf0aa29c3..ceede2500 100644 --- a/src/eepp/ui/uitab.cpp +++ b/src/eepp/ui/uitab.cpp @@ -150,7 +150,7 @@ bool UITab::setAttribute( const NodeAttribute& attribute, const Uint32& state ) if ( "name" == name || "text" == name ) { if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) setText( static_cast( mSceneNode )->getTranslatorString( attribute.asString() ) ); - } else if ( "controlowned" == name || "owns" == name ) { + } else if ( "owns" == name ) { mOwnedName = attribute.asString(); setOwnedControl(); } else { diff --git a/src/eepp/ui/uitable.cpp b/src/eepp/ui/uitable.cpp index 75ee698b3..4d8b1c7e9 100644 --- a/src/eepp/ui/uitable.cpp +++ b/src/eepp/ui/uitable.cpp @@ -622,26 +622,26 @@ bool UITable::isTouchOverAllowedChilds() { bool UITable::setAttribute( const NodeAttribute& attribute, const Uint32& state ) { const std::string& name = attribute.getName(); - if ( "rowheight" == name ) { + if ( "row-height" == name || "rowheight" == name ) { setRowHeight( attribute.asInt() ); - } else if ( "verticalscrollmode" == name || "vscrollmode" == name ) { + } else if ( "vscroll-mode" == name || "vscrollmode" == name ) { std::string val = attribute.asString(); if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO ); else if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON ); else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_OFF ); - } else if ( "horizontalscrollmode" == name || "hscrollmode" == name ) { + } else if ( "hscroll-mode" == name || "hscrollmode" == name ) { std::string val = attribute.asString(); if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO ); else if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON ); else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_OFF ); - } else if ( "scrollbartype" == name ) { + } else if ( "scrollbar-type" == name || "scrollbartype" == name ) { std::string val( attribute.asString() ); String::toLowerInPlace( val ); - if ( "nobuttons" == val ) { + if ( "no-buttons" == val || "nobuttons" == val ) { mVScrollBar->setScrollBarType( UIScrollBar::NoButtons ); mHScrollBar->setScrollBarType( UIScrollBar::NoButtons ); - } else if ( "twobuttons" == val ) { + } else if ( "two-buttons" == val || "twobuttons" == val ) { mVScrollBar->setScrollBarType( UIScrollBar::TwoButtons ); mHScrollBar->setScrollBarType( UIScrollBar::NoButtons ); } diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp index 517cb3b6e..ae5885b72 100644 --- a/src/eepp/ui/uitabwidget.cpp +++ b/src/eepp/ui/uitabwidget.cpp @@ -122,23 +122,23 @@ void UITabWidget::setStyleConfig(const StyleConfig & styleConfig) { bool UITabWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state ) { const std::string& name = attribute.getName(); - if ( "maxtextlength" == name ) { + if ( "max-text-length" == name || "maxtextlength" == name ) { setMaxTextLength( attribute.asUint(1) ); - } else if ( "mintabwidth" == name ) { + } else if ( "min-tab-width" == name || "mintabwidth" == name ) { setMinTabWidth( attribute.asUint(1) ); - } else if ( "maxtabwidth" == name ) { + } else if ( "max-tab-width" == name || "maxtabwidth" == name ) { setMaxTabWidth( attribute.asUint() ); - } else if ( "tabclosable" == name ) { + } else if ( "tab-closable" == name || "tabclosable" == name ) { setTabsClosable( attribute.asBool() ); - } else if ( "specialbordertabs" == name ) { + } else if ( "special-border-tabs" == name || "specialbordertabs" == name ) { setSpecialBorderTabs( attribute.asBool() ); - } else if ( "drawlinebelowtabs" == name ) { + } else if ( "line-below-tabs" == name || "linebelowtabs" == name ) { setDrawLineBelowTabs( attribute.asBool() ); - } else if ( "linebelowtabscolor" == name ) { + } else if ( "line-below-tabs-color" == name || "linebelowtabscolor" == name ) { setLineBelowTabsColor( attribute.asColor() ); - } else if ( "linebelowtabsyoffset" == name ) { + } else if ( "line-below-tabs-y-offset" == name || "linebelowtabsyoffset" == name ) { setLineBelowTabsYOffset( attribute.asDpDimensionI() ); - } else if ( "tabseparation" == name ) { + } else if ( "tab-separation" == name || "tabseparation" == name ) { setTabSeparation( attribute.asDpDimensionI() ); } else { return UIWidget::setAttribute( attribute, state ); diff --git a/src/eepp/ui/uitextedit.cpp b/src/eepp/ui/uitextedit.cpp index 0eb917fcd..0d3389702 100644 --- a/src/eepp/ui/uitextedit.cpp +++ b/src/eepp/ui/uitextedit.cpp @@ -485,14 +485,14 @@ bool UITextEdit::setAttribute( const NodeAttribute& attribute, const Uint32& sta if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) { setText( static_cast( mSceneNode )->getTranslatorString( attribute.asString() ) ); } - } else if ( "allowediting" == name ) { + } else if ( "allow-editing" == name || "allowediting" == name ) { setAllowEditing( attribute.asBool() ); - } else if ( "verticalscrollmode" == name || "vscrollmode" == name ) { + } else if ( "vscroll-mode" == name || "vscrollmode" == name ) { std::string val = attribute.asString(); if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO ); else if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON ); else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_OFF ); - } else if ( "horizontalscrollmode" == name || "hscrollmode" == name ) { + } else if ( "hscroll-mode" == name || "hscrollmode" == name ) { std::string val = attribute.asString(); if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO ); else if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON ); diff --git a/src/eepp/ui/uitextinput.cpp b/src/eepp/ui/uitextinput.cpp index 1a0cdc257..f3c907c1e 100644 --- a/src/eepp/ui/uitextinput.cpp +++ b/src/eepp/ui/uitextinput.cpp @@ -359,15 +359,15 @@ bool UITextInput::setAttribute( const NodeAttribute& attribute, const Uint32& st if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) { setText( static_cast( mSceneNode )->getTranslatorString( attribute.asString() ) ); } - } else if ( "allowediting" == name ) { + } else if ( "allow-editing" == name || "allowediting" == name ) { setAllowEditing( attribute.asBool() ); - } else if ( "maxlength" == name ) { + } else if ( "max-length" == name || "maxlength" == name ) { setMaxLength( attribute.asUint() ); - } else if ( "freeediting" == name ) { + } else if ( "free-editing" == name || "freeediting" == name ) { setFreeEditing( attribute.asBool() ); - } else if ( "onlynumbers" == name ) { + } else if ( "only-numbers" == name || "onlynumbers" == name ) { getInputTextBuffer()->setAllowOnlyNumbers( attribute.asBool(), getInputTextBuffer()->dotsInNumbersAllowed() ); - } else if ( "allowdot" == name ) { + } else if ( "allow-dot" == name || "allowdot" == name ) { getInputTextBuffer()->setAllowOnlyNumbers( getInputTextBuffer()->onlyNumbersAllowed(), attribute.asBool() ); } else { return UITextView::setAttribute( attribute, state ); diff --git a/src/eepp/ui/uitextureregion.cpp b/src/eepp/ui/uitextureregion.cpp index 80950103c..dcecad71e 100644 --- a/src/eepp/ui/uitextureregion.cpp +++ b/src/eepp/ui/uitextureregion.cpp @@ -105,7 +105,7 @@ void UITextureRegion::draw() { autoAlign(); drawTextureRegion(); - } else { + } else { mTextureRegion->setDestSize( Vector2f( (Float)pxSize.x, (Float)pxSize.y ) ); autoAlign(); @@ -200,13 +200,13 @@ const Vector2f& UITextureRegion::getAlignOffset() const { bool UITextureRegion::setAttribute( const NodeAttribute& attribute, const Uint32& state ) { const std::string& name = attribute.getName(); - if ( "src" == name || "textureregion" == name ) { + if ( "src" == name ) { Drawable * res = NULL; if ( NULL != ( res = TextureAtlasManager::instance()->getTextureRegionByName( attribute.asString() ) ) && res->getDrawableType() == Drawable::TEXTUREREGION ) { setTextureRegion( static_cast( res ) ); } - } else if ( "scaletype" == name ) { + } else if ( "scale-type" == name || "scaletype" == name ) { std::string val = attribute.asString(); String::toLowerInPlace( val ); diff --git a/src/eepp/ui/uitextview.cpp b/src/eepp/ui/uitextview.cpp index a35f9bb69..dd72b3fcf 100644 --- a/src/eepp/ui/uitextview.cpp +++ b/src/eepp/ui/uitextview.cpp @@ -570,7 +570,7 @@ bool UITextView::setAttribute( const NodeAttribute& attribute, const Uint32& sta if ( "text" == name ) { if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) setText( static_cast( mSceneNode )->getTranslatorString( attribute.asString() ) ); - } else if ( "textcolor" == name ) { + } else if ( "color" == name || "textcolor" == name ) { SAVE_NORMAL_STATE_ATTR( getFontColor().toHexString() ); Color color = attribute.asColor(); @@ -587,7 +587,7 @@ bool UITextView::setAttribute( const NodeAttribute& attribute, const Uint32& sta } else { setFontColor( color ); } - } else if ( "textshadowcolor" == name ) { + } else if ( "shadow-color" == name || "textshadowcolor" == name ) { SAVE_NORMAL_STATE_ATTR( getFontShadowColor().toHexString() ); Color color = attribute.asColor(); @@ -604,19 +604,19 @@ bool UITextView::setAttribute( const NodeAttribute& attribute, const Uint32& sta } else { setFontShadowColor( color ); } - } else if ( "textselectedcolor" == name ) { + } else if ( "selected-color" == name || "textselectedcolor" == name ) { mFontStyleConfig.FontSelectedColor = attribute.asColor(); - } else if ( "textselectionbackcolor" == name ) { + } else if ( "selection-back-color" == name || "textselectionbackcolor" == name ) { setSelectionBackColor( attribute.asColor() ); - } else if ( "fontfamily" == name || "fontname" == name ) { + } else if ( "font-family" == name || "font-name" == name || "fontfamily" == name || "fontname" == name ) { SAVE_NORMAL_STATE_ATTR( getFont()->getName() ); setFont( FontManager::instance()->getByName( attribute.asString() ) ); - } else if ( "textsize" == name || "fontsize" == name || "charactersize" == name ) { + } else if ( "font-size" == name || "textsize" == name || "fontsize" == name ) { SAVE_NORMAL_STATE_ATTR( String::format( "%dpx", getCharacterSize() ) ); setCharacterSize( attribute.asDpDimensionI() ); - } else if ( "textstyle" == name || "fontstyle" == name ) { + } else if ( "font-style" == name || "textstyle" == name || "fontstyle" == name ) { Uint32 flags = attribute.asFontStyle(); SAVE_NORMAL_STATE_ATTR( Text::styleFlagToString( getFontStyle() ) ); @@ -628,18 +628,18 @@ bool UITextView::setAttribute( const NodeAttribute& attribute, const Uint32& sta } setFontStyle( flags ); - } else if ( "wordwrap" == name || "word_wrap" == name ) { + } else if ( "wordwrap" == name || "word-wrap" == name ) { if ( attribute.asBool() ) mFlags |= UI_WORD_WRAP; else mFlags &= ~UI_WORD_WRAP; autoShrink(); - } else if ( "fontoutlinethickness" == name ) { + } else if ( "text-stroke-width" == name || "fontoutlinethickness" == name ) { SAVE_NORMAL_STATE_ATTR( String::toStr( PixelDensity::dpToPx( getOutlineThickness() ) ) ) setOutlineThickness( PixelDensity::dpToPx( attribute.asDpDimension() ) ); - } else if ( "fontoutlinecolor" == name ) { + } else if ( "text-stroke-color" == name || "fontoutlinecolor" == name ) { SAVE_NORMAL_STATE_ATTR( getOutlineColor().toHexString() ); Color color = attribute.asColor(); @@ -656,7 +656,7 @@ bool UITextView::setAttribute( const NodeAttribute& attribute, const Uint32& sta } else { setOutlineColor( color ); } - } else if ( "textselection" == name ) { + } else if ( "text-selection" == name || "textselection" == name ) { mFlags|= UI_TEXT_SELECTION_ENABLED; } else { return UIWidget::setAttribute( attribute, state ); diff --git a/src/eepp/ui/uitooltip.cpp b/src/eepp/ui/uitooltip.cpp index 8ea2dc733..24520c9a9 100644 --- a/src/eepp/ui/uitooltip.cpp +++ b/src/eepp/ui/uitooltip.cpp @@ -158,6 +158,8 @@ void UITooltip::onAutoSize() { (int)mTextCache->getTextWidth() + mRealPadding.Left + mRealPadding.Right, (int)mTextCache->getTextHeight() + mRealPadding.Top + mRealPadding.Bottom ) ); + + autoAlign(); } } @@ -328,21 +330,19 @@ void UITooltip::setFontStyleConfig(const UIFontStyleConfig & styleConfig) { bool UITooltip::setAttribute( const NodeAttribute& attribute, const Uint32& state ) { const std::string& name = attribute.getName(); - if ( "textcolor" == name ) { + if ( "color" == name ) { setFontColor( attribute.asColor() ); - } else if ( "padding" == name ) { - setPadding( attribute.asRectf() ); - } else if ( "textshadowcolor" == name ) { + } else if ( "shadow-color" == name || "textshadowcolor" == name ) { setFontShadowColor( attribute.asColor() ); - } else if ( "fontfamily" == name || "fontname" == name ) { + } else if ( "font-family" == name || "font-name" == name || "fontfamily" == name || "fontname" == name ) { setFont( FontManager::instance()->getByName( attribute.asString() ) ); - } else if ( "textsize" == name || "fontsize" == name || "charactersize" == name ) { + } else if ( "font-size" == name || "textsize" == name || "fontsize" == name ) { setCharacterSize( attribute.asDpDimensionI() ); - } else if ( "textstyle" == name || "fontstyle" == name ) { + } else if ( "font-style" == name || "textstyle" == name || "fontstyle" == name ) { setFontStyle( attribute.asFontStyle() ); - } else if ( "fontoutlinethickness" == name ) { + } else if ( "text-stroke-width" == name || "fontoutlinethickness" == name ) { setOutlineThickness( attribute.asDpDimension() ); - } else if ( "fontoutlinecolor" == name ) { + } else if ( "text-stroke-color" == name || "fontoutlinecolor" == name ) { setOutlineColor( attribute.asColor() ); } else { return UIWidget::setAttribute( attribute, state ); diff --git a/src/eepp/ui/uitouchdragablewidget.cpp b/src/eepp/ui/uitouchdragablewidget.cpp index 507b3cf57..e1fb22257 100644 --- a/src/eepp/ui/uitouchdragablewidget.cpp +++ b/src/eepp/ui/uitouchdragablewidget.cpp @@ -149,9 +149,9 @@ void UITouchDragableWidget::scheduledUpdate( const Time& time ) { bool UITouchDragableWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state ) { const std::string& name = attribute.getName(); - if ( "touchdrag" == name ) { + if ( "touch-drag" == name || "touchdrag" == name ) { setTouchDragEnabled( attribute.asBool() ); - } else if ( "touchdragdeceleration" == name ) { + } else if ( "touchdrag-deceleration" == name || "touchdragdeceleration" == name ) { setTouchDragDeceleration( Vector2f( attribute.asFloat(), attribute.asFloat() ) ); } else { return UIWidget::setAttribute( attribute, state ); diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 9de7e3a9c..3779a1f83 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -140,7 +140,6 @@ UIWidget * UIWidget::setLayoutSizeRules(const LayoutSizeRules & layoutWidthRules } UIWidget * UIWidget::setLayoutPositionRule(const LayoutPositionRules & layoutPositionRule, UIWidget * of) { - if ( mLayoutPositionRule != layoutPositionRule || mLayoutPositionRuleWidget != of ) { mLayoutPositionRule = layoutPositionRule; mLayoutPositionRuleWidget = of; @@ -758,11 +757,11 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state Drawable * res = NULL; if ( Color::isColorString( attribute.getValue() ) ) { - setAttribute( NodeAttribute( "backgroundcolor", attribute.getValue() ) ); + setAttribute( NodeAttribute( "background-color", attribute.getValue() ) ); } else if ( NULL != ( res = DrawableSearcher::searchByName( attribute.getValue() ) ) ) { setBackgroundDrawable( res, res->getDrawableType() == Drawable::SPRITE ); } - } else if ( "backgroundcolor" == name ) { + } else if ( "background-color" == name || "backgroundcolor" == name ) { SAVE_NORMAL_STATE_ATTR( getBackgroundColor().toHexString() ); Color color = attribute.asColor(); @@ -780,7 +779,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state } else { setBackgroundColor( color ); } - } else if ( "backgroundimage" == name ) { + } else if ( "background-image" == name || "backgroundimage" == name ) { NodeAttribute::FunctionType functionType = NodeAttribute::FunctionType::parse( attribute.getValue() ); Drawable * res = NULL; @@ -815,7 +814,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state rectColors.BottomLeft = rectColors.BottomRight = Color::fromString( params.at(2) ); } } else { - return setAttribute( NodeAttribute( "backgroundcolor", params.at(0) ) ); + return setAttribute( NodeAttribute( "background-color", params.at(0) ) ); } drawable->setRectColors( rectColors ); @@ -829,11 +828,11 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state Drawable * res = NULL; if ( Color::isColorString( attribute.getValue() ) ) { - setAttribute( NodeAttribute( "foregroundcolor", attribute.getValue() ) ); + setAttribute( NodeAttribute( "foreground-color", attribute.getValue() ) ); } else if ( NULL != ( res = DrawableSearcher::searchByName( attribute.getValue() ) ) ) { setForegroundDrawable( res, res->getDrawableType() == Drawable::SPRITE ); } - } else if ( "foregroundcolor" == name ) { + } else if ( "foreground-color" == name || "foregroundcolor" == name ) { SAVE_NORMAL_STATE_ATTR( getForegroundColor().toHexString() ); Color color = attribute.asColor(); @@ -851,11 +850,11 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state } else { setForegroundColor( color ); } - } else if ( "foregroundradius" == name ) { + } else if ( "foreground-radius" == name || "foregroundradius" == name ) { SAVE_NORMAL_STATE_ATTR( String::toStr( getForegroundRadius() ) ); setForegroundRadius( attribute.asUint() ); - } else if ( "bordercolor" == name ) { + } else if ( "border-color" == name || "bordercolor" == name ) { SAVE_NORMAL_STATE_ATTR( getBorderColor().toHexString() ) Color color = attribute.asColor(); @@ -873,11 +872,11 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state } else { setBorderColor( color ); } - } else if ( "borderwidth" == name ) { + } else if ( "border-width" == name || "borderwidth" == name ) { SAVE_NORMAL_STATE_ATTR( String::toStr( getBorderWidth() ) ); setBorderWidth( attribute.asDpDimensionI("1") ); - } else if ( "borderradius" == name ) { + } else if ( "border-radius" == name || "borderradius" == name ) { SAVE_NORMAL_STATE_ATTR( String::format( "%d", getBorderRadius() ) ); Uint32 borderRadius = attribute.asUint(); @@ -916,7 +915,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state SAVE_NORMAL_STATE_ATTR( mSkinName ); mSkinName = attribute.asString(); setThemeSkin( mSkinName ); - } else if ( "skincolor" == name ) { + } else if ( "skin-color" == name || "skincolor" == name ) { SAVE_NORMAL_STATE_ATTR( getSkinColor().toHexString() ); Color color = attribute.asColor(); @@ -991,25 +990,25 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state } } } - } else if ( String::startsWith( name, "layout_margin" ) ) { + } else if ( String::startsWith( name, "margin" ) || String::startsWith( name, "layout_margin" ) ) { SAVE_NORMAL_STATE_ATTR( String::format( "%d %d %d %d", mLayoutMargin.Left, mLayoutMargin.Top, mLayoutMargin.Right, mLayoutMargin.Bottom ) ); Rect margin; Uint32 marginFlag = 0; - if ( "layout_margin" == name ) { + if ( "margin" == name || "layout_margin" == name ) { margin = attribute.asRect(); marginFlag = Actions::MarginMove::All; - } else if ( "layout_marginleft" == name ) { + } else if ( "margin-left" == name || "layout_marginleft" == name ) { margin = Rect( attribute.asDpDimensionI(), mLayoutMargin.Top, mLayoutMargin.Right, mLayoutMargin.Bottom ); marginFlag = Actions::MarginMove::Left; - } else if ( "layout_marginright" == name ) { + } else if ( "margin-right" == name || "layout_marginright" == name ) { margin = Rect( mLayoutMargin.Left, mLayoutMargin.Top, attribute.asDpDimensionI(), mLayoutMargin.Bottom ); marginFlag = Actions::MarginMove::Right; - } else if ( "layout_margintop" == name ) { + } else if ( "margin-top" == name || "layout_margintop" == name ) { margin = Rect( mLayoutMargin.Left, attribute.asDpDimensionI(), mLayoutMargin.Right, mLayoutMargin.Bottom ); marginFlag = Actions::MarginMove::Top; - } else if ( "layout_marginbottom" == name ) { + } else if ( "margin-bottom" == name || "layout_marginbottom" == name ) { margin = Rect( mLayoutMargin.Left, mLayoutMargin.Top, mLayoutMargin.Right, attribute.asDpDimensionI() ); marginFlag = Actions::MarginMove::Bottom; } @@ -1027,11 +1026,11 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state } } else if ( "tooltip" == name ) { setTooltipText( attribute.asString() ); - } else if ( "layout_weight" == name ) { + } else if ( "layout_weight" == name || "layout-weight" == name ) { SAVE_NORMAL_STATE_ATTR( String::toStr( getLayoutWeight() ) ); setLayoutWeight( attribute.asFloat() ); - } else if ( "layout_gravity" == name ) { + } else if ( "layout_gravity" == name || "layout-gravity" == name ) { SAVE_NORMAL_STATE_ATTR( getLayoutGravityString() ); std::string gravityStr = attribute.asString(); @@ -1063,7 +1062,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state setLayoutGravity( gravity ); } - } else if ( "layout_width" == name ) { + } else if ( "layout_width" == name || "layout-width" == name ) { SAVE_NORMAL_STATE_ATTR( getLayoutWidthRulesString() ); std::string val = attribute.asString(); @@ -1082,7 +1081,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state setInternalWidth( PixelDensity::toDpFromStringI( val ) ); onSizeChange(); } - } else if ( "layout_height" == name ) { + } else if ( "layout_height" == name || "layout-height" == name ) { SAVE_NORMAL_STATE_ATTR( getLayoutHeightRulesString() ); std::string val = attribute.asString(); @@ -1156,15 +1155,15 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state } else { setScale( attribute.asVector2f() ); } - } else if ( "rotationoriginpoint" == name ) { + } else if ( "rotation-origin-point" == name || "rotationoriginpoint" == name ) { SAVE_NORMAL_STATE_ATTR( getRotationOriginPoint().toString() ); setRotationOriginPoint( attribute.asOriginPoint() ); - } else if ( "scaleoriginpoint" == name ) { + } else if ( "scale-origin-point" == name || "scaleoriginpoint" == name ) { SAVE_NORMAL_STATE_ATTR( getScaleOriginPoint().toString() ); setScaleOriginPoint( attribute.asOriginPoint() ); - } else if ( "blendmode" == name ) { + } else if ( "blend-mode" == name || "blendmode" == name ) { // TODO: SAVE_NORMAL_STATE_ATTR setBlendMode( attribute.asBlendMode() ); } else if ( String::startsWith( name, "padding" ) ) { @@ -1176,16 +1175,16 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state if ( "padding" == name ) { padding = ( attribute.asRectf() ); paddingFlag = Actions::PaddingTransition::All; - } else if ( "paddingleft" == name ) { + } else if ( "padding-left" == name || "paddingleft" == name ) { padding = Rectf( attribute.asDpDimension(), mPadding.Top, mPadding.Right, mPadding.Bottom ); paddingFlag = Actions::PaddingTransition::Left; - } else if ( "paddingright" == name ) { + } else if ( "padding-right" == name || "paddingright" == name ) { padding = Rectf( mPadding.Left, mPadding.Top, attribute.asDpDimension(), mPadding.Bottom ); paddingFlag = Actions::PaddingTransition::Right; - } else if ( "paddingtop" == name ) { + } else if ( "padding-top" == name || "paddingtop" == name ) { padding = Rectf( mPadding.Left, attribute.asDpDimension(), mPadding.Right, mPadding.Bottom ); paddingFlag = Actions::PaddingTransition::Top; - } else if ( "paddingbottom" == name ) { + } else if ( "padding-bottom" == name || "paddingbottom" == name ) { padding = Rectf( mPadding.Left, mPadding.Top, mPadding.Right, attribute.asDpDimension() ); paddingFlag = Actions::PaddingTransition::Bottom; } diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index 569ecda0b..ce60c91e9 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -802,7 +802,7 @@ void UIWindow::tryResize( const UI_RESIZE_TYPE& Type ) { Vector2f Pos = getEventDispatcher()->getMousePosf(); worldToNode( Pos ); - + mResizeType = Type; Pos = PixelDensity::dpToPx( Pos ); @@ -1414,14 +1414,14 @@ bool UIWindow::setAttribute( const NodeAttribute& attribute, const Uint32& state setSize( mDpSize.getWidth(), attribute.asInt() ); } else if ( "title" == name ) { setTitle( attribute.asString() ); - } else if ( "basealpha" == name ) { + } else if ( "base-alpha" == name || "basealpha" == name ) { unsigned int val = attribute.asUint(); if ( val <= 255 ) setBaseAlpha( (Uint8)val ); - } else if ( "buttonspositionfixer" == name ) { + } else if ( "buttons-position-offset" == name || "buttonspositionoffset" == name ) { mStyleConfig.ButtonsPositionFixer = attribute.asVector2i(); fixChildsSize(); - } else if ( "winflags" == name ) { + } else if ( "window-flags" == name || "winflags" == name ) { std::string flagsStr = attribute.asString(); String::toLowerInPlace( flagsStr ); std::vector strings = String::split( flagsStr, '|' ); @@ -1450,24 +1450,24 @@ bool UIWindow::setAttribute( const NodeAttribute& attribute, const Uint32& state mStyleConfig.WinFlags |= winflags; updateWinFlags(); } - } else if ( "decorationsize" == name ) { + } else if ( "decoration-size" == name || "decorationsize" == name ) { mStyleConfig.DecorationSize = attribute.asSizei(); fixChildsSize(); - } else if ( "bordersize" == name ) { + } else if ( "border-size" == name || "bordersize" == name ) { mStyleConfig.BorderSize = attribute.asSizei(); fixChildsSize(); - } else if ( "minwindowsize" == name ) { + } else if ( "min-window-size" == name || "minwindowsize" == name ) { mStyleConfig.MinWindowSize = attribute.asSizef(); fixChildsSize(); - } else if ( "buttonsseparation" == name ) { + } else if ( "buttons-separation" == name || "buttonsseparation" == name ) { mStyleConfig.ButtonsSeparation = attribute.asUint(); fixChildsSize(); - } else if ( "mincornerdistance" == name ) { + } else if ( "min-corner-distance" == name || "mincornerdistance" == name ) { mStyleConfig.MinCornerDistance = attribute.asInt(); - } else if ( "decorationautosize" == name ) { + } else if ( "decoration-auto-size" == name || "decorationautosize" == name ) { mStyleConfig.DecorationAutoSize = attribute.asBool(); fixChildsSize(); - } else if ( "borderautosize" == name ) { + } else if ( "border-auto-size" == name || "borderautosize" == name ) { mStyleConfig.BorderAutoSize = attribute.asBool(); fixChildsSize(); } else { diff --git a/src/eepp/ui/uiwinmenu.cpp b/src/eepp/ui/uiwinmenu.cpp index 016440c2b..c26985483 100644 --- a/src/eepp/ui/uiwinmenu.cpp +++ b/src/eepp/ui/uiwinmenu.cpp @@ -161,13 +161,13 @@ void UIWinMenu::setFirstButtonMargin( const Uint32& buttonMargin ) { bool UIWinMenu::setAttribute( const NodeAttribute& attribute, const Uint32 & state ) { const std::string& name = attribute.getName(); - if ( "marginbetweenbuttons" == name ) { + if ( "margin-between-buttons" == name || "marginbetweenbuttons" == name ) { setMarginBetweenButtons( attribute.asDpDimensionUint() ); - } else if ( "buttonmargin" == name ) { + } else if ( "button-margin" == name || "buttonmargin" == name ) { setButtonMargin( attribute.asDpDimensionUint() ); - } else if ( "menuheight" == name ) { + } else if ( "menu-height" == name || "menuheight" == name ) { setMenuHeight( attribute.asDpDimensionUint() ); - } else if ( "firstbuttonmargin" == name ) { + } else if ( "first-button-margin-left" == name || "firstbuttonmarginleft" == name ) { setFirstButtonMargin( attribute.asDpDimensionUint() ); } else { return UIWidget::setAttribute( attribute, state ); diff --git a/src/thirdparty/args/args.hxx b/src/thirdparty/args/args.hxx index 09c1919fe..f784538ab 100644 --- a/src/thirdparty/args/args.hxx +++ b/src/thirdparty/args/args.hxx @@ -1,4 +1,8 @@ -/* Copyright (c) 2016-2017 Taylor C. Richberger and Pavel +/* A simple header-only C++ argument parser library. + * + * https://github.com/Taywee/args + * + * Copyright (c) 2016-2019 Taylor C. Richberger and Pavel * Belikov * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -1633,11 +1637,11 @@ namespace args public: Subparser(std::vector args_, ArgumentParser &parser_, const Command &command_, const HelpParams &helpParams_) - : args(std::move(args_)), parser(&parser_), helpParams(helpParams_), command(command_) + : Group({}, Validators::AllChildGroups), args(std::move(args_)), parser(&parser_), helpParams(helpParams_), command(command_) { } - Subparser(const Command &command_, const HelpParams &helpParams_) : helpParams(helpParams_), command(command_) + Subparser(const Command &command_, const HelpParams &helpParams_) : Group({}, Validators::AllChildGroups), helpParams(helpParams_), command(command_) { } @@ -2128,18 +2132,23 @@ namespace args return; } + auto onValidationError = [&] + { + std::ostringstream problem; + problem << "Group validation failed somewhere!"; +#ifdef ARGS_NOEXCEPT + error = Error::Validation; + errorMsg = problem.str(); +#else + throw ValidationError(problem.str()); +#endif + }; + for (Base *child: Children()) { if (child->IsGroup() && !child->Matched()) { - std::ostringstream problem; - problem << "Group validation failed somewhere!"; -#ifdef ARGS_NOEXCEPT - error = Error::Validation; - errorMsg = problem.str(); -#else - throw ValidationError(problem.str()); -#endif + onValidationError(); } child->Validate(shortprefix, longprefix); @@ -2148,6 +2157,10 @@ namespace args if (subparser != nullptr) { subparser->Validate(shortprefix, longprefix); + if (!subparser->Matched()) + { + onValidationError(); + } } if (selectedCommand == nullptr && commandIsRequired && (Group::HasCommand() || subparserHasCommand)) @@ -3256,9 +3269,14 @@ namespace args operator ()(const std::string &name, const std::string &value, T &destination) { std::istringstream ss(value); - ss >> destination >> std::ws; + bool failed = !(ss >> destination); - if (ss.rdbuf()->in_avail() > 0) + if (!failed) + { + ss >> std::ws; + } + + if (ss.rdbuf()->in_avail() > 0 || failed) { #ifdef ARGS_NOEXCEPT (void)name;