diff --git a/bin/assets/layouts/test_widgets.xml b/bin/assets/layouts/test_widgets.xml index 4cc6b0755..2abc25c02 100644 --- a/bin/assets/layouts/test_widgets.xml +++ b/bin/assets/layouts/test_widgets.xml @@ -52,7 +52,7 @@ - + diff --git a/bin/assets/ui/breeze.css b/bin/assets/ui/breeze.css index 946cae444..31568a563 100644 --- a/bin/assets/ui/breeze.css +++ b/bin/assets/ui/breeze.css @@ -287,8 +287,6 @@ ScrollBar { ScrollBar::hback { min-height: 4dp; border-radius: 3dp; - margin-left: 4dp; - margin-right: 4dp; background-color: transparent; } @@ -296,8 +294,6 @@ ScrollBar::vback { min-width: 4dp; border-radius: 3dp; background-color: transparent; - margin-top: 4dp; - margin-bottom: 4dp; } ScrollBar::vslider { diff --git a/include/eepp/scene/event.hpp b/include/eepp/scene/event.hpp index 67369fa18..1d8e91223 100644 --- a/include/eepp/scene/event.hpp +++ b/include/eepp/scene/event.hpp @@ -58,6 +58,9 @@ class EE_API Event { OnUpdateScreenPosition, OnPageChanged, OnMarginChange, + OnTagChange, + OnIdChange, + OnClassChange, UserEvent, NoEvent = eeINDEX_NOT_FOUND }; diff --git a/include/eepp/scene/node.hpp b/include/eepp/scene/node.hpp index 8fce196e6..7f3236381 100644 --- a/include/eepp/scene/node.hpp +++ b/include/eepp/scene/node.hpp @@ -60,7 +60,8 @@ enum NodeFlags { NODE_FLAG_WIDGET = ( 1 << 24 ), NODE_FLAG_WINDOW = ( 1 << 25 ), - NODE_FLAG_FREE_USE = ( 1 << 26 ) + NODE_FLAG_LOADING = ( 1 << 26 ), + NODE_FLAG_FREE_USE = ( 1 << 27 ) }; class EE_API Node : public Transformable { @@ -358,6 +359,11 @@ class EE_API Node : public Transformable { bool inParentTreeOf( Node* Child ) const; + void setLoadingState( bool loading ); + + bool isLoadingState() const; + + virtual void onIdChange(); protected: typedef std::map> EventsMap; friend class EventDispatcher; diff --git a/include/eepp/ui/css/propertydefinition.hpp b/include/eepp/ui/css/propertydefinition.hpp index 254b3b1fe..eab30e0cf 100644 --- a/include/eepp/ui/css/propertydefinition.hpp +++ b/include/eepp/ui/css/propertydefinition.hpp @@ -199,6 +199,7 @@ enum class PropertyType : Uint32 { NumberFloat, NumberFloatFixed, NumberLength, + NumberLengthFixed, RadiusLength, Color, Vector2, diff --git a/include/eepp/ui/css/stylesheet.hpp b/include/eepp/ui/css/stylesheet.hpp index 1d96a2d9b..8532a3c78 100644 --- a/include/eepp/ui/css/stylesheet.hpp +++ b/include/eepp/ui/css/stylesheet.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace EE { namespace UI { namespace CSS { @@ -11,7 +12,7 @@ class EE_API StyleSheet { public: StyleSheet(); - void addStyle( const StyleSheetStyle& node ); + void addStyle( std::shared_ptr node ); bool isEmpty() const; diff --git a/include/eepp/ui/css/stylesheetparser.hpp b/include/eepp/ui/css/stylesheetparser.hpp index 900ed5fd9..bd5c66429 100644 --- a/include/eepp/ui/css/stylesheetparser.hpp +++ b/include/eepp/ui/css/stylesheetparser.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -39,11 +40,8 @@ class EE_API StyleSheetParser { enum ReadState { ReadingSelector, ReadingProperty, ReadingComment }; std::string mCSS; - StyleSheet mStyleSheet; - std::vector mComments; - MediaQueryList::ptr mMediaQueryList; bool parse( std::string& css, std::vector& importedList ); diff --git a/include/eepp/ui/css/stylesheetpropertiesparser.hpp b/include/eepp/ui/css/stylesheetpropertiesparser.hpp index 650328516..37c39f3f8 100644 --- a/include/eepp/ui/css/stylesheetpropertiesparser.hpp +++ b/include/eepp/ui/css/stylesheetpropertiesparser.hpp @@ -15,6 +15,8 @@ class EE_API StyleSheetPropertiesParser { explicit StyleSheetPropertiesParser( const std::string& propsstr ); + void parse( const std::string& propsstr ); + void print(); const StyleSheetProperties& getProperties() const; @@ -29,8 +31,6 @@ class EE_API StyleSheetPropertiesParser { StyleSheetProperties mProperties; StyleSheetVariables mVariables; - void parse( std::string propsstr ); - int readPropertyName( ReadState& rs, std::size_t pos, std::string& buffer, const std::string& str ); diff --git a/include/eepp/ui/css/stylesheetstyle.hpp b/include/eepp/ui/css/stylesheetstyle.hpp index 995308dbf..9ff84c078 100644 --- a/include/eepp/ui/css/stylesheetstyle.hpp +++ b/include/eepp/ui/css/stylesheetstyle.hpp @@ -62,7 +62,7 @@ class EE_API StyleSheetStyle { }; typedef std::map StyleSheetStyleList; -typedef std::vector StyleSheetStyleVector; +typedef std::vector> StyleSheetStyleVector; }}} // namespace EE::UI::CSS diff --git a/include/eepp/ui/uidropdownlist.hpp b/include/eepp/ui/uidropdownlist.hpp index 14ebc34a0..e15811c9c 100644 --- a/include/eepp/ui/uidropdownlist.hpp +++ b/include/eepp/ui/uidropdownlist.hpp @@ -11,7 +11,7 @@ class EE_API UIDropDownList : public UITextInput { class StyleConfig { public: Uint32 MaxNumVisibleItems = 10; - bool PopUpToMainControl = false; + bool PopUpToRoot = false; }; static UIDropDownList* NewWithTag( const std::string& tag ); @@ -32,9 +32,9 @@ class EE_API UIDropDownList : public UITextInput { void showList(); - bool getPopUpToMainControl() const; + bool getPopUpToRoot() const; - void setPopUpToMainControl( bool popUpToMainControl ); + void setPopUpToRoot( bool popUpToRoot ); Uint32 getMaxNumVisibleItems() const; diff --git a/include/eepp/ui/uihelper.hpp b/include/eepp/ui/uihelper.hpp index d61ada991..5c07168b3 100644 --- a/include/eepp/ui/uihelper.hpp +++ b/include/eepp/ui/uihelper.hpp @@ -82,6 +82,7 @@ enum UINodeType { UI_TYPE_GRID_LAYOUT, UI_TYPE_LAYOUT, UI_TYPE_VIEWPAGER, + UI_TYPE_ITEMCONTAINER, UI_TYPE_USER = 10000 }; diff --git a/include/eepp/ui/uiitemcontainer.hpp b/include/eepp/ui/uiitemcontainer.hpp index 1d850fc3c..742d06cb4 100644 --- a/include/eepp/ui/uiitemcontainer.hpp +++ b/include/eepp/ui/uiitemcontainer.hpp @@ -2,16 +2,20 @@ #define EE_UITUIITEMCONTAINER_HPP #include -#include +#include namespace EE { namespace UI { -template class UIItemContainer : public UINode { +template class UIItemContainer : public UIWidget { public: UIItemContainer(); ~UIItemContainer(); + virtual Uint32 getType() const; + + virtual bool isType( const Uint32& type ) const; + void update( const Time& time ); void drawChilds(); @@ -20,7 +24,17 @@ template class UIItemContainer : public UINode { Node* overFind( const Vector2f& Point ); }; -template UIItemContainer::UIItemContainer() : UINode() {} +template +Uint32 UIItemContainer::getType() const { + return UI_TYPE_ITEMCONTAINER; +} + +template +bool UIItemContainer::isType( const Uint32& type ) const { + return UIItemContainer::getType() == type ? true : UIWidget::isType( type ); +} + +template UIItemContainer::UIItemContainer() : UIWidget() {} template UIItemContainer::~UIItemContainer() {} diff --git a/include/eepp/ui/uilistbox.hpp b/include/eepp/ui/uilistbox.hpp index 6dffb6f9e..89784f3c8 100644 --- a/include/eepp/ui/uilistbox.hpp +++ b/include/eepp/ui/uilistbox.hpp @@ -177,6 +177,10 @@ class EE_API UIListBox : public UITouchDraggableWidget { void setHScrollStep(); + void updateScrollBar(); + + void updatePageStep(); + virtual void onTouchDragValueChange( Vector2f diff ); virtual bool isTouchOverAllowedChilds(); diff --git a/include/eepp/ui/uiscenenode.hpp b/include/eepp/ui/uiscenenode.hpp index 42c694ab3..5be996e8c 100644 --- a/include/eepp/ui/uiscenenode.hpp +++ b/include/eepp/ui/uiscenenode.hpp @@ -58,9 +58,11 @@ class EE_API UISceneNode : public SceneNode { void setStyleSheet( const std::string& inlineStyleSheet ); - void combineStyleSheet( const CSS::StyleSheet& styleSheet ); + void combineStyleSheet( const CSS::StyleSheet& styleSheet, + const bool& forceReloadStyle = true ); - void combineStyleSheet( const std::string& inlineStyleSheet ); + void combineStyleSheet( const std::string& inlineStyleSheet, + const bool& forceReloadStyle = true ); CSS::StyleSheet& getStyleSheet(); @@ -120,7 +122,7 @@ class EE_API UISceneNode : public SceneNode { void loadFontFaces( const CSS::StyleSheetStyleVector& styles ); - UIWidget* loadNode( pugi::xml_node node, Node* parent ); + std::vector loadNode( pugi::xml_node node, Node* parent ); virtual Uint32 onKeyDown( const KeyEvent& Event ); diff --git a/include/eepp/ui/uistyle.hpp b/include/eepp/ui/uistyle.hpp index 0586f7908..db0e64123 100644 --- a/include/eepp/ui/uistyle.hpp +++ b/include/eepp/ui/uistyle.hpp @@ -80,11 +80,11 @@ class EE_API UIStyle : public UIState { bool mForceReapplyProperties; bool mDisableAnimations; - void tryApplyStyle( const CSS::StyleSheetStyle& style ); + void tryApplyStyle( const CSS::StyleSheetStyle* style ); - void findVariables( const CSS::StyleSheetStyle& style ); + void findVariables( const CSS::StyleSheetStyle* style ); - void applyVarValues( CSS::StyleSheetStyle& style ); + void applyVarValues( CSS::StyleSheetProperty& style ); void setVariableFromValue( CSS::StyleSheetProperty& property, const std::string& value ); diff --git a/include/eepp/ui/uitab.hpp b/include/eepp/ui/uitab.hpp index 827d807d4..46ad3223c 100644 --- a/include/eepp/ui/uitab.hpp +++ b/include/eepp/ui/uitab.hpp @@ -53,6 +53,8 @@ class EE_API UITab : public UISelectButton { virtual void onParentChange(); + virtual void onSizeChange(); + void setOwnedControl(); void updateTab(); diff --git a/include/eepp/ui/uitable.hpp b/include/eepp/ui/uitable.hpp index a339ac391..72addcf88 100644 --- a/include/eepp/ui/uitable.hpp +++ b/include/eepp/ui/uitable.hpp @@ -138,9 +138,13 @@ class EE_API UITable : public UITouchDraggableWidget { void setHScrollStep(); + void updateScrollBar(); + virtual void onTouchDragValueChange( Vector2f diff ); virtual bool isTouchOverAllowedChilds(); + + void updatePageStep(); }; }} // namespace EE::UI diff --git a/include/eepp/ui/uiwidget.hpp b/include/eepp/ui/uiwidget.hpp index c37f0e027..408236337 100644 --- a/include/eepp/ui/uiwidget.hpp +++ b/include/eepp/ui/uiwidget.hpp @@ -286,6 +286,10 @@ class EE_API UIWidget : public UINode { virtual void onParentChange(); + virtual void onClassChange(); + + virtual void onTagChange(); + void updateAnchors( const Vector2f& SizeChange ); void alignAgainstLayout(); @@ -307,6 +311,8 @@ class EE_API UIWidget : public UINode { void reloadChildsStyleState(); Vector2f getTooltipPosition(); + + void createStyle(); }; }} // namespace EE::UI diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 5c654d724..c182b7e4a 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -85,8 +85,8 @@ true - gmake2 - premake5 + gmake + premake4 %{buildDir}../../../ ProjectExplorer.ProcessStep @@ -167,7 +167,7 @@ true gmake - premake5 + premake4 %{buildDir}../../../ ProjectExplorer.ProcessStep diff --git a/src/eepp/scene/node.cpp b/src/eepp/scene/node.cpp index 66cda21d4..6060f66f5 100644 --- a/src/eepp/scene/node.cpp +++ b/src/eepp/scene/node.cpp @@ -682,9 +682,14 @@ std::string Node::getId() const { Node* Node::setId( const std::string& id ) { mId = id; mIdHash = String::hash( id ); + onIdChange(); return this; } +void Node::onIdChange() { + sendCommonEvent( Event::OnIdChange ); +} + Uint32 Node::getIdHash() const { return mIdHash; } @@ -738,6 +743,14 @@ bool Node::inParentTreeOf( Node* Child ) const { return false; } +void Node::setLoadingState( bool loading ) { + writeNodeFlag( NODE_FLAG_LOADING, loading ? 1 : 0 ); +} + +bool Node::isLoadingState() const { + return 0 != ( mNodeFlags & NODE_FLAG_LOADING ); +} + Uint32 Node::getChildCount() const { Node* ChildLoop = mChild; Uint32 Count = 0; diff --git a/src/eepp/scene/scenenode.cpp b/src/eepp/scene/scenenode.cpp index 34ba2ad4c..f90636a6d 100644 --- a/src/eepp/scene/scenenode.cpp +++ b/src/eepp/scene/scenenode.cpp @@ -145,15 +145,15 @@ void SceneNode::update( const Time& time ) { } if ( !mScheduledUpdate.empty() ) { - for ( auto it = mScheduledUpdate.begin(); it != mScheduledUpdate.end(); ++it ) - ( *it )->scheduledUpdate( time ); + for ( auto& node : mScheduledUpdate ) + node->scheduledUpdate( time ); } if ( mUpdateAllChilds ) { Node::update( time ); } else { - for ( auto it = mMouseOverNodes.begin(); it != mMouseOverNodes.end(); ++it ) - ( *it )->writeNodeFlag( NODE_FLAG_MOUSEOVER_ME_OR_CHILD, 0 ); + for ( auto& nodeOver : mMouseOverNodes ) + nodeOver->writeNodeFlag( NODE_FLAG_MOUSEOVER_ME_OR_CHILD, 0 ); } mMouseOverNodes.clear(); diff --git a/src/eepp/ui/css/keyframesdefinition.cpp b/src/eepp/ui/css/keyframesdefinition.cpp index 61cda2c47..ee87dbe07 100644 --- a/src/eepp/ui/css/keyframesdefinition.cpp +++ b/src/eepp/ui/css/keyframesdefinition.cpp @@ -9,7 +9,7 @@ KeyframesDefinition::parseKeyframes( const std::string& name, def.name = name; for ( const auto& block : keyframeBlocks ) { - std::string blockName( String::toLower( String::trim( block.getSelector().getName() ) ) ); + std::string blockName( String::toLower( String::trim( block->getSelector().getName() ) ) ); Float blockTime = 0.f; if ( blockName == "from" ) { @@ -26,7 +26,7 @@ KeyframesDefinition::parseKeyframes( const std::string& name, continue; } - def.keyframeBlocks[blockTime] = {blockTime, block.getProperties()}; + def.keyframeBlocks[blockTime] = {blockTime, block->getProperties()}; } return def; diff --git a/src/eepp/ui/css/propertydefinition.cpp b/src/eepp/ui/css/propertydefinition.cpp index 7fd20d168..827b8f25a 100644 --- a/src/eepp/ui/css/propertydefinition.cpp +++ b/src/eepp/ui/css/propertydefinition.cpp @@ -17,6 +17,7 @@ PropertyDefinition::PropertyDefinition( const std::string& name, const std::stri mDefaultValue( defaultValue ), mInherited( inherited ), mIndexed( false ), + mRelativeTarget( PropertyRelativeTarget::None ), mPropertyType( PropertyType::Undefined ) { for ( auto& sep : {"-", "_"} ) { diff --git a/src/eepp/ui/css/stylesheet.cpp b/src/eepp/ui/css/stylesheet.cpp index e458567b5..1c9e40b97 100644 --- a/src/eepp/ui/css/stylesheet.cpp +++ b/src/eepp/ui/css/stylesheet.cpp @@ -8,10 +8,10 @@ namespace EE { namespace UI { namespace CSS { StyleSheet::StyleSheet() {} -void StyleSheet::addStyle( const StyleSheetStyle& node ) { +void StyleSheet::addStyle( std::shared_ptr node ) { mNodes.push_back( node ); - addMediaQueryList( node.getMediaQueryList() ); + addMediaQueryList( node->getMediaQueryList() ); } bool StyleSheet::isEmpty() const { @@ -20,7 +20,7 @@ bool StyleSheet::isEmpty() const { void StyleSheet::print() { for ( auto& style : mNodes ) { - std::cout << style.build(); + std::cout << style->build(); } } @@ -37,7 +37,7 @@ StyleSheetStyleVector StyleSheet::getElementStyles( UIWidget* element, StyleSheetStyleVector styles; for ( const auto& node : mNodes ) { - const StyleSheetSelector& selector = node.getSelector(); + const StyleSheetSelector& selector = node->getSelector(); if ( selector.select( element, applyPseudo ) ) { styles.push_back( node ); @@ -84,7 +84,7 @@ StyleSheetStyleVector StyleSheet::getStyleSheetStyleByAtRule( const AtRuleType& StyleSheetStyleVector vector; for ( auto& node : mNodes ) { - if ( node.getAtRuleType() == atRuleType ) { + if ( node->getAtRuleType() == atRuleType ) { vector.push_back( node ); } } diff --git a/src/eepp/ui/css/stylesheetparser.cpp b/src/eepp/ui/css/stylesheetparser.cpp index 7fbf2f852..eea2df361 100644 --- a/src/eepp/ui/css/stylesheetparser.cpp +++ b/src/eepp/ui/css/stylesheetparser.cpp @@ -24,7 +24,7 @@ StyleSheetParser::StyleSheetParser() {} bool StyleSheetParser::loadFromStream( IOStream& stream ) { Clock elapsed; std::vector importedList; - mCSS.resize( stream.getSize(), '\0' ); + mCSS.resize( stream.getSize() ); stream.read( &mCSS[0], stream.getSize() ); bool ok = parse( mCSS, importedList ); eePRINTL( "StyleSheet loaded in: %4.3f ms.", elapsed.getElapsedTime().asMilliseconds() ); @@ -192,13 +192,14 @@ int StyleSheetParser::readProperty( const std::string& css, ReadState& rs, std:: selectorName = String::trim( selectorName ); StyleSheetSelectorParser selectorParse( selectorName ); - StyleSheetPropertiesParser propertiesParse( buffer ); + StyleSheetPropertiesParser propertiesParser( buffer ); if ( !selectorParse.selectors.empty() ) { for ( auto it = selectorParse.selectors.begin(); it != selectorParse.selectors.end(); ++it ) { - StyleSheetStyle node( it->getName(), propertiesParse.getProperties(), - propertiesParse.getVariables(), mMediaQueryList ); + std::shared_ptr node = std::make_shared( + it->getName(), propertiesParser.getProperties(), + propertiesParser.getVariables(), mMediaQueryList ); mStyleSheet.addStyle( node ); } diff --git a/src/eepp/ui/css/stylesheetpropertiesparser.cpp b/src/eepp/ui/css/stylesheetpropertiesparser.cpp index 7c658ddae..93a7b4883 100644 --- a/src/eepp/ui/css/stylesheetpropertiesparser.cpp +++ b/src/eepp/ui/css/stylesheetpropertiesparser.cpp @@ -6,9 +6,10 @@ using namespace EE::UI; namespace EE { namespace UI { namespace CSS { -StyleSheetPropertiesParser::StyleSheetPropertiesParser() {} +StyleSheetPropertiesParser::StyleSheetPropertiesParser() : mPrevRs( ReadingPropertyName ) {} -StyleSheetPropertiesParser::StyleSheetPropertiesParser( const std::string& propsstr ) { +StyleSheetPropertiesParser::StyleSheetPropertiesParser( const std::string& propsstr ) : + mPrevRs( ReadingPropertyName ) { std::vector props = String::split( propsstr, ';' ); if ( !props.empty() ) { @@ -24,7 +25,9 @@ const StyleSheetVariables& StyleSheetPropertiesParser::getVariables() const { return mVariables; } -void StyleSheetPropertiesParser::parse( std::string propsstr ) { +void StyleSheetPropertiesParser::parse( const std::string& propsstr ) { + mProperties.clear(); + mVariables.clear(); ReadState rs = ReadingPropertyName; mPrevRs = rs; std::size_t pos = 0; diff --git a/src/eepp/ui/css/stylesheetspecification.cpp b/src/eepp/ui/css/stylesheetspecification.cpp index 7461eb2c0..cc520aa1e 100644 --- a/src/eepp/ui/css/stylesheetspecification.cpp +++ b/src/eepp/ui/css/stylesheetspecification.cpp @@ -244,16 +244,16 @@ void StyleSheetSpecification::registerDefaultProperties() { registerProperty( "arc-start-angle", "" ).setType( PropertyType::NumberFloat ); registerProperty( "min-width", "" ) - .setType( PropertyType::NumberLength ) + .setType( PropertyType::NumberLengthFixed ) .setRelativeTarget( PropertyRelativeTarget::ContainingBlockWidth ); registerProperty( "min-height", "" ) - .setType( PropertyType::NumberLength ) + .setType( PropertyType::NumberLengthFixed ) .setRelativeTarget( PropertyRelativeTarget::ContainingBlockHeight ); registerProperty( "max-width", "" ) - .setType( PropertyType::NumberLength ) + .setType( PropertyType::NumberLengthFixed ) .setRelativeTarget( PropertyRelativeTarget::ContainingBlockWidth ); registerProperty( "max-height", "" ) - .setType( PropertyType::NumberLength ) + .setType( PropertyType::NumberLengthFixed ) .setRelativeTarget( PropertyRelativeTarget::ContainingBlockHeight ); registerProperty( "total-steps", "" ).setType( PropertyType::NumberInt ); diff --git a/src/eepp/ui/tools/uicolorpicker.cpp b/src/eepp/ui/tools/uicolorpicker.cpp index b62798727..72bc7610c 100644 --- a/src/eepp/ui/tools/uicolorpicker.cpp +++ b/src/eepp/ui/tools/uicolorpicker.cpp @@ -56,6 +56,7 @@ UIColorPicker* UIColorPicker::NewModal( Node* nodeCreator, UIColorPicker* UIColorPicker::NewWindow( const ColorPickedCb& colorPickedCb, const Uint32& winFlags, const Sizef& winSize, const Uint8& modalAlpha ) { + Clock clock; UIWindow* tWin = UIWindow::New(); tWin->setSizeWithDecoration( winSize )->setPosition( 0, 0 ); UIWindow::StyleConfig windowStyleConfig = tWin->getStyleConfig(); @@ -64,6 +65,7 @@ UIColorPicker* UIColorPicker::NewWindow( const ColorPickedCb& colorPickedCb, con tWin->setStyleConfig( windowStyleConfig ); UIColorPicker* colorPicker = Tools::UIColorPicker::New( tWin, colorPickedCb, modalAlpha ); tWin->show(); + eePRINTL( "UIColorPicker created in: %.2fms", clock.getElapsedTime().asMilliseconds() ); return colorPicker; } @@ -214,9 +216,13 @@ UIColorPicker::UIColorPicker( UIWindow* attachTo, const UIColorPicker::ColorPick )xml"; - if ( NULL != mUIContainer->getSceneNode() && mUIContainer->getSceneNode()->isUISceneNode() ) + if ( NULL != mUIContainer->getSceneNode() && mUIContainer->getSceneNode()->isUISceneNode() ) { + Clock clock; mRoot = mUIContainer->getSceneNode()->asType()->loadLayoutFromString( layout, mUIContainer ); + eePRINTL( "UIColorPicker loadLayoutFromString time: %.2f", + clock.getElapsedTime().asMilliseconds() ); + } if ( NULL != mUIWindow ) { mUIWindow->setTitle( "Color Picker" ); @@ -347,9 +353,8 @@ Texture* UIColorPicker::createGridTexture() { } TextureFactory* TF = TextureFactory::instance(); - Uint32 texId = - TF->loadFromPixels( image.getPixelsPtr(), image.getWidth(), image.getHeight(), - image.getChannels() ); + Uint32 texId = TF->loadFromPixels( image.getPixelsPtr(), image.getWidth(), image.getHeight(), + image.getChannels() ); return TF->getTexture( texId ); } diff --git a/src/eepp/ui/uicheckbox.cpp b/src/eepp/ui/uicheckbox.cpp index c2d4e4241..7ebda9001 100644 --- a/src/eepp/ui/uicheckbox.cpp +++ b/src/eepp/ui/uicheckbox.cpp @@ -10,19 +10,23 @@ UICheckBox* UICheckBox::New() { } UICheckBox::UICheckBox() : UITextView( "checkbox" ), mChecked( false ), mTextSeparation( 4 ) { + auto cb = [&]( const Event* event ) { onAutoSize(); }; + mActiveButton = UIWidget::NewWithTag( "checkbox::active" ); mActiveButton->setVisible( false ); mActiveButton->setEnabled( true ); mActiveButton->setParent( this ); mActiveButton->setPosition( 0, 0 ); - mActiveButton->setSize( 16, 16 ); + mActiveButton->setSize( 8, 8 ); + mActiveButton->addEventListener( Event::OnSizeChange, cb ); mInactiveButton = UIWidget::NewWithTag( "checkbox::inactive" ); mInactiveButton->setVisible( true ); mInactiveButton->setEnabled( true ); mInactiveButton->setParent( this ); mInactiveButton->setPosition( 0, 0 ); - mInactiveButton->setSize( 16, 16 ); + mInactiveButton->setSize( 8, 8 ); + mInactiveButton->addEventListener( Event::OnSizeChange, cb ); onPaddingChange(); @@ -53,17 +57,13 @@ void UICheckBox::setTheme( UITheme* Theme ) { void UICheckBox::onThemeLoaded() { UISkin* tSkin = mActiveButton->getSkin(); - if ( tSkin ) { + if ( tSkin ) mActiveButton->setSize( tSkin->getSize() ); - mActiveButton->centerVertical(); - } tSkin = mInactiveButton->getSkin(); - if ( NULL != tSkin ) { + if ( NULL != tSkin ) mInactiveButton->setSize( tSkin->getSize() ); - mInactiveButton->centerVertical(); - } setMinSize( mActiveButton->getSkinSize() ); @@ -81,34 +81,28 @@ void UICheckBox::onAutoSize() { } if ( getSize().getHeight() == 0 ) { - setInternalHeight( mActiveButton->getSize().getHeight() + mRealPadding.Top + - mRealPadding.Bottom ); + setInternalHeight( mActiveButton->getSize().getHeight() + mPadding.Top + + mPadding.Bottom ); } - - mActiveButton->centerVertical(); - mInactiveButton->centerVertical(); } if ( mLayoutWidthRule == LayoutSizeRule::WrapContent ) { setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mRealPadding.Left + mRealPadding.Right + mActiveButton->getPixelsSize().getWidth() + - mTextSeparation ); + PixelDensity::dpToPx( mTextSeparation ) ); } if ( mLayoutHeightRule == LayoutSizeRule::WrapContent ) { setInternalPixelsHeight( (int)mTextCache->getTextHeight() + mRealPadding.Top + mRealPadding.Bottom ); - - mActiveButton->centerVertical(); - mInactiveButton->centerVertical(); } + + alignFix(); } void UICheckBox::onSizeChange() { + alignFix(); UITextView::onSizeChange(); - - mActiveButton->centerVertical(); - mInactiveButton->centerVertical(); } Uint32 UICheckBox::onMessage( const NodeMessage* Msg ) { @@ -152,6 +146,8 @@ void UICheckBox::setChecked( const bool& checked ) { pushState( UIState::StateChecked ); } + alignFix(); + onValueChange(); } @@ -162,13 +158,16 @@ const bool& UICheckBox::isChecked() const { void UICheckBox::onPaddingChange() { mActiveButton->setPosition( mPadding.Left, mActiveButton->getPosition().y ); mInactiveButton->setPosition( mPadding.Left, mInactiveButton->getPosition().y ); - + alignFix(); UITextView::onPaddingChange(); } void UICheckBox::alignFix() { UITextView::alignFix(); + mActiveButton->centerVertical(); + mInactiveButton->centerVertical(); + switch ( Font::getHorizontalAlign( getFlags() ) ) { case UI_HALIGN_CENTER: mRealAlignOffset.x = diff --git a/src/eepp/ui/uicommondialog.cpp b/src/eepp/ui/uicommondialog.cpp index 25b083523..d2185adf0 100644 --- a/src/eepp/ui/uicommondialog.cpp +++ b/src/eepp/ui/uicommondialog.cpp @@ -121,7 +121,7 @@ UICommonDialog::UICommonDialog( Uint32 CDLFlags, std::string DefaultFilePattern, mFiletype->setLayoutSizeRules( LayoutSizeRule::WrapContent, LayoutSizeRule::WrapContent ) ->setLayoutWeight( 1 ) ->setParent( hLayout ); - mFiletype->setPopUpToMainControl( true ); + mFiletype->setPopUpToRoot( true ); mFiletype->getListBox()->addListBoxItem( DefaultFilePattern ); mFiletype->getListBox()->setSelected( 0 ); mFiletype->setLayoutMargin( Rect( 0, 0, 4, 0 ) ); diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index df080f67d..566108ee1 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -32,6 +32,8 @@ UIDropDownList::UIDropDownList( const std::string& tag ) : mStyleConfig.MaxNumVisibleItems * getSize().getHeight() ); mListBox->setEnabled( false ); mListBox->setVisible( false ); + // This will force to change the parent when shown, and force the CSS style reload. + mListBox->setParent( this ); mListBox->addEventListener( Event::OnWidgetFocusLoss, cb::Make1( this, &UIDropDownList::onListBoxFocusLoss ) ); @@ -127,7 +129,7 @@ Uint32 UIDropDownList::onMouseClick( const Vector2i& Pos, const Uint32& Flags ) void UIDropDownList::showList() { if ( !mListBox->isVisible() ) { - if ( !mStyleConfig.PopUpToMainControl ) + if ( !mStyleConfig.PopUpToRoot ) mListBox->setParent( getWindowContainer() ); else mListBox->setParent( mSceneNode ); @@ -136,7 +138,7 @@ void UIDropDownList::showList() { Vector2f Pos( mDpPos.x, mDpPos.y + getSize().getHeight() ); - if ( mStyleConfig.PopUpToMainControl ) { + if ( mStyleConfig.PopUpToRoot ) { getParent()->nodeToWorld( Pos ); Pos = PixelDensity::pxToDp( Pos ); } else { @@ -178,12 +180,12 @@ void UIDropDownList::showList() { } } -bool UIDropDownList::getPopUpToMainControl() const { - return mStyleConfig.PopUpToMainControl; +bool UIDropDownList::getPopUpToRoot() const { + return mStyleConfig.PopUpToRoot; } -void UIDropDownList::setPopUpToMainControl( bool popUpToMainControl ) { - mStyleConfig.PopUpToMainControl = popUpToMainControl; +void UIDropDownList::setPopUpToRoot( bool popUpToRoot ) { + mStyleConfig.PopUpToRoot = popUpToRoot; } Uint32 UIDropDownList::getMaxNumVisibleItems() const { @@ -207,7 +209,7 @@ void UIDropDownList::setStyleConfig( const StyleConfig& styleConfig ) { mStyleConfig = styleConfig; setMaxNumVisibleItems( mStyleConfig.MaxNumVisibleItems ); - setPopUpToMainControl( mStyleConfig.PopUpToMainControl ); + setPopUpToRoot( mStyleConfig.PopUpToRoot ); } void UIDropDownList::onControlClear( const Event* ) { @@ -308,7 +310,7 @@ bool UIDropDownList::applyProperty( const StyleSheetProperty& attribute ) { switch ( attribute.getPropertyDefinition()->getPropertyId() ) { case PropertyId::PopUpToRoot: - setPopUpToMainControl( attribute.asBool() ); + setPopUpToRoot( attribute.asBool() ); break; case PropertyId::MaxVisibleItems: setMaxNumVisibleItems( attribute.asUint() ); @@ -334,7 +336,7 @@ std::string UIDropDownList::getPropertyString( const PropertyDefinition* propert switch ( propertyDef->getPropertyId() ) { case PropertyId::PopUpToRoot: - return mStyleConfig.PopUpToMainControl ? "true" : "false"; + return mStyleConfig.PopUpToRoot ? "true" : "false"; case PropertyId::MaxVisibleItems: return String::toStr( mStyleConfig.MaxNumVisibleItems ); case PropertyId::SelectedIndex: diff --git a/src/eepp/ui/uilistbox.cpp b/src/eepp/ui/uilistbox.cpp index 1afa55948..7ed6983b9 100644 --- a/src/eepp/ui/uilistbox.cpp +++ b/src/eepp/ui/uilistbox.cpp @@ -40,6 +40,8 @@ UIListBox::UIListBox( const std::string& tag ) : mSmoothScroll( true ) { setFlags( UI_AUTO_PADDING ); + auto cb = [&]( const Event* event ) { containerResize(); }; + mContainer = eeNew( UIItemContainer, () ); mContainer->setParent( this ); mContainer->setSize( getSize() ); @@ -52,16 +54,18 @@ UIListBox::UIListBox( const std::string& tag ) : mVScrollBar = UIScrollBar::New(); mVScrollBar->setOrientation( UIOrientation::Vertical ); mVScrollBar->setParent( this ); - mVScrollBar->setPosition( getSize().getWidth() - 16, 0 ); - mVScrollBar->setSize( 16, getSize().getHeight() ); + mVScrollBar->setPosition( getSize().getWidth() - 8, 0 ); + mVScrollBar->setSize( 8, getSize().getHeight() ); mVScrollBar->setEnabled( false )->setVisible( false ); + mVScrollBar->addEventListener( Event::OnSizeChange, cb ); mHScrollBar = UIScrollBar::New(); mHScrollBar->setOrientation( UIOrientation::Horizontal ); mHScrollBar->setParent( this ); - mHScrollBar->setSize( getSize().getWidth() - mVScrollBar->getSize().getWidth(), 16 ); - mHScrollBar->setPosition( 0, getSize().getHeight() - 16 ); + mHScrollBar->setSize( getSize().getWidth() - mVScrollBar->getSize().getWidth(), 8 ); + mHScrollBar->setPosition( 0, getSize().getHeight() - 8 ); mHScrollBar->setEnabled( false )->setVisible( false ); + mHScrollBar->addEventListener( Event::OnSizeChange, cb ); mVScrollBar->addEventListener( Event::OnValueChange, cb::Make1( this, &UIListBox::onScrollValueChange ) ); @@ -151,8 +155,7 @@ Uint32 UIListBox::addListBoxItem( UIListBoxItem* Item ) { updateScroll(); } - mVScrollBar->setPageStep( ( (Float)mContainer->getSize().getHeight() / (Float)mRowHeight ) / - (Float)mItems.size() ); + updatePageStep(); return ( Uint32 )( mItems.size() - 1 ); } @@ -177,9 +180,7 @@ Uint32 UIListBox::addListBoxItem( const String& text ) { } } - mVScrollBar->setPageStep( ( (Float)mContainer->getSize().getHeight() / (Float)mRowHeight ) / - (Float)mItems.size() ); - + updatePageStep(); updateScroll(); return ( Uint32 )( mItems.size() - 1 ); @@ -299,32 +300,10 @@ void UIListBox::onHScrollValueChange( const Event* ) { } void UIListBox::onSizeChange() { - mVScrollBar->setPosition( getSize().getWidth() - mVScrollBar->getSize().getWidth() + - mVScrollBar->getPadding().Left, - mVScrollBar->getPadding().Top ); - mVScrollBar->setSize( mVScrollBar->getSize().getWidth() + mVScrollBar->getPadding().Right, - getSize().getHeight() + mVScrollBar->getPadding().Bottom ); - - mHScrollBar->setPosition( mHScrollBar->getPadding().Left, - getSize().getHeight() - mHScrollBar->getSize().getHeight() + - mHScrollBar->getPadding().Top ); - mHScrollBar->setSize( getSize().getWidth() - mVScrollBar->getSize().getWidth() + - mHScrollBar->getPadding().Right, - mHScrollBar->getSize().getHeight() + mHScrollBar->getPadding().Bottom ); - - if ( mContainer->isClipped() && ScrollBarMode::Auto == mHScrollMode ) { - if ( (Int32)mMaxTextWidth <= mContainer->getPixelsSize().getWidth() ) { - mHScrollBar->setVisible( false ); - mHScrollBar->setEnabled( false ); - mHScrollInit = 0; - } - } - containerResize(); updateScrollBarState(); - updateListBoxItemsSize(); updateScroll(); - + updatePageStep(); UIWidget::onSizeChange(); } @@ -368,6 +347,34 @@ void UIListBox::setHScrollStep() { mHScrollBar->setClickStep( stepVal ); } +void UIListBox::updateScrollBar() { + mVScrollBar->setPosition( getSize().getWidth() - mVScrollBar->getSize().getWidth() + + mVScrollBar->getPadding().Left, + mVScrollBar->getPadding().Top ); + mVScrollBar->setSize( mVScrollBar->getSize().getWidth() + mVScrollBar->getPadding().Right, + getSize().getHeight() + mVScrollBar->getPadding().Bottom ); + + mHScrollBar->setPosition( mHScrollBar->getPadding().Left, + getSize().getHeight() - mHScrollBar->getSize().getHeight() + + mHScrollBar->getPadding().Top ); + mHScrollBar->setSize( getSize().getWidth() - mVScrollBar->getSize().getWidth() + + mHScrollBar->getPadding().Right, + mHScrollBar->getSize().getHeight() + mHScrollBar->getPadding().Bottom ); + + if ( mContainer->isClipped() && ScrollBarMode::Auto == mHScrollMode ) { + if ( (Int32)mMaxTextWidth <= mContainer->getPixelsSize().getWidth() ) { + mHScrollBar->setVisible( false ); + mHScrollBar->setEnabled( false ); + mHScrollInit = 0; + } + } +} + +void UIListBox::updatePageStep() { + mVScrollBar->setPageStep( ( (Float)mContainer->getSize().getHeight() / (Float)mRowHeight ) / + (Float)mTexts.size() ); +} + void UIListBox::onTouchDragValueChange( Vector2f diff ) { if ( mVScrollBar->isEnabled() ) mVScrollBar->setValue( mVScrollBar->getValue() + @@ -445,13 +452,17 @@ void UIListBox::containerResize() { mContainer->setPixelsPosition( padding.Left, padding.Top ); - if ( mHScrollBar->isVisible() ) + if ( mHScrollBar->isVisible() ) { mContainer->setPixelsSize( mSize.getWidth() - padding.Right - padding.Left, mSize.getHeight() - padding.Top - mHScrollBar->getPixelsSize().getHeight() ); - else + } else { mContainer->setPixelsSize( mSize.getWidth() - padding.Right - padding.Left, mSize.getHeight() - padding.Bottom - padding.Top ); + } + + updateListBoxItemsSize(); + updateScrollBar(); } void UIListBox::createItemIndex( const Uint32& i ) { diff --git a/src/eepp/ui/uilistboxitem.cpp b/src/eepp/ui/uilistboxitem.cpp index fae75895d..55d60bae8 100644 --- a/src/eepp/ui/uilistboxitem.cpp +++ b/src/eepp/ui/uilistboxitem.cpp @@ -12,10 +12,7 @@ UIListBoxItem* UIListBoxItem::NewWithTag( const std::string& tag ) { return eeNew( UIListBoxItem, ( tag ) ); } -UIListBoxItem::UIListBoxItem() : UITextView( "listbox::item" ) { - setLayoutSizeRules( LayoutSizeRule::Fixed, LayoutSizeRule::Fixed ); - applyDefaultTheme(); -} +UIListBoxItem::UIListBoxItem() : UIListBoxItem( "listbox::item" ) {} UIListBoxItem::UIListBoxItem( const std::string& tag ) : UITextView( tag ) { setLayoutSizeRules( LayoutSizeRule::Fixed, LayoutSizeRule::Fixed ); diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index ca60edeb2..754f88e0a 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -332,6 +332,18 @@ void UINode::updateDebugData() { text += String::format( "X: %2.4f Y: %2.4f\nW: %2.4f H: %2.4f", mDpPos.x, mDpPos.y, mDpSize.x, mDpSize.y ); + if ( widget->getPadding() != Rectf( 0, 0, 0, 0 ) ) { + Rectf p( widget->getPadding() ); + text += + String::format( "\npadding: %.2f %.2f %.2f %.2f", p.Top, p.Right, p.Bottom, p.Left ); + } + + if ( widget->getLayoutMargin() != Rect( 0, 0, 0, 0 ) ) { + Rect m( widget->getLayoutMargin() ); + text += + String::format( "\nmargin: %d %d %d %d", m.Top, m.Right, m.Bottom, m.Left ); + } + widget->setTooltipText( text ); } } diff --git a/src/eepp/ui/uiradiobutton.cpp b/src/eepp/ui/uiradiobutton.cpp index b7b9141ee..20e3c3dbc 100644 --- a/src/eepp/ui/uiradiobutton.cpp +++ b/src/eepp/ui/uiradiobutton.cpp @@ -15,19 +15,23 @@ UIRadioButton::UIRadioButton() : mInactiveButton( NULL ), mActive( false ), mTextSeparation( 4 ) { + auto cb = [&]( const Event* event ) { onAutoSize(); }; + mActiveButton = UIWidget::NewWithTag( "radiobutton::active" ); mActiveButton->setVisible( false ); mActiveButton->setEnabled( true ); mActiveButton->setParent( this ); mActiveButton->setPosition( 0, 0 ); - mActiveButton->setSize( 16, 16 ); + mActiveButton->setSize( 8, 8 ); + mActiveButton->addEventListener( Event::OnSizeChange, cb ); mInactiveButton = UIWidget::NewWithTag( "radiobutton::inactive" ); mInactiveButton->setVisible( true ); mInactiveButton->setEnabled( true ); mInactiveButton->setParent( this ); mInactiveButton->setPosition( 0, 0 ); - mInactiveButton->setSize( 16, 16 ); + mInactiveButton->setSize( 9, 8 ); + mInactiveButton->addEventListener( Event::OnSizeChange, cb ); onPaddingChange(); @@ -57,17 +61,13 @@ void UIRadioButton::setTheme( UITheme* Theme ) { void UIRadioButton::onThemeLoaded() { UISkin* tSkin = mActiveButton->getSkin(); - if ( tSkin ) { + if ( tSkin ) mActiveButton->setSize( tSkin->getSize() ); - mActiveButton->centerVertical(); - } tSkin = mInactiveButton->getSkin(); - if ( NULL != tSkin ) { + if ( NULL != tSkin ) mInactiveButton->setSize( tSkin->getSize() ); - mInactiveButton->centerVertical(); - } setMinSize( mActiveButton->getSkinSize() ); @@ -79,40 +79,35 @@ void UIRadioButton::onThemeLoaded() { void UIRadioButton::onAutoSize() { if ( mFlags & UI_AUTO_SIZE ) { if ( getSize().getWidth() == 0 ) { - setInternalPixelsWidth( (int)mTextCache->getTextWidth() + - mActiveButton->getPixelsSize().getWidth() + mTextSeparation + - mRealPadding.Left + mRealPadding.Right ); + setInternalPixelsWidth( + (int)mTextCache->getTextWidth() + mActiveButton->getPixelsSize().getWidth() + + PixelDensity::dpToPx( mTextSeparation ) + mRealPadding.Left + mRealPadding.Right ); } if ( getSize().getHeight() == 0 ) { setInternalHeight( mActiveButton->getSize().getHeight() + mRealPadding.Top + mRealPadding.Bottom ); } - - mActiveButton->centerVertical(); - mInactiveButton->centerVertical(); } if ( mLayoutWidthRule == LayoutSizeRule::WrapContent ) { setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mRealPadding.Left + mRealPadding.Right + mActiveButton->getPixelsSize().getWidth() + - mTextSeparation ); + PixelDensity::dpToPx( mTextSeparation ) ); } if ( mLayoutHeightRule == LayoutSizeRule::WrapContent ) { setInternalPixelsHeight( (int)mTextCache->getTextHeight() + mRealPadding.Top + mRealPadding.Bottom ); - - mActiveButton->centerVertical(); - mInactiveButton->centerVertical(); } + + alignFix(); } void UIRadioButton::onSizeChange() { UITextView::onSizeChange(); - mActiveButton->centerVertical(); - mInactiveButton->centerVertical(); + alignFix(); } Uint32 UIRadioButton::onMessage( const NodeMessage* Msg ) { @@ -229,13 +224,16 @@ const bool& UIRadioButton::isActive() const { void UIRadioButton::onPaddingChange() { mActiveButton->setPosition( mPadding.Left, mActiveButton->getPosition().y ); mInactiveButton->setPosition( mPadding.Left, mInactiveButton->getPosition().y ); - + alignFix(); UITextView::onPaddingChange(); } void UIRadioButton::alignFix() { UITextView::alignFix(); + mActiveButton->centerVertical(); + mInactiveButton->centerVertical(); + switch ( Font::getHorizontalAlign( getFlags() ) ) { case UI_HALIGN_CENTER: mRealAlignOffset.x = diff --git a/src/eepp/ui/uiscenenode.cpp b/src/eepp/ui/uiscenenode.cpp index feca828d5..7fad1fbe5 100644 --- a/src/eepp/ui/uiscenenode.cpp +++ b/src/eepp/ui/uiscenenode.cpp @@ -114,8 +114,8 @@ bool UISceneNode::windowExists( UIWindow* win ) { return mWindowsList.end() != std::find( mWindowsList.begin(), mWindowsList.end(), win ); } -UIWidget* UISceneNode::loadNode( pugi::xml_node node, Node* parent ) { - UIWidget* firstWidget = NULL; +std::vector UISceneNode::loadNode( pugi::xml_node node, Node* parent ) { + std::vector rootWidgets; if ( NULL == parent ) parent = this; @@ -124,9 +124,7 @@ UIWidget* UISceneNode::loadNode( pugi::xml_node node, Node* parent ) { UIWidget* uiwidget = UIWidgetCreator::createFromName( widget.name() ); if ( NULL != uiwidget ) { - if ( NULL == firstWidget ) { - firstWidget = uiwidget; - } + rootWidgets.push_back( uiwidget ); uiwidget->setParent( parent ); uiwidget->loadFromXmlNode( widget ); @@ -137,22 +135,26 @@ UIWidget* UISceneNode::loadNode( pugi::xml_node node, Node* parent ) { uiwidget->onWidgetCreated(); } else if ( String::toLower( widget.name() ) == "style" ) { - combineStyleSheet( widget.text().as_string() ); + combineStyleSheet( widget.text().as_string(), false ); } } - return firstWidget; + return rootWidgets; } UIWidget* UISceneNode::loadLayoutNodes( pugi::xml_node node, Node* parent ) { - UIWidget* firstWidget = NULL; - + Clock clock; + UISceneNode* prevUISceneNode = SceneManager::instance()->getUISceneNode(); + SceneManager::instance()->setCurrentUISceneNode( this ); mIsLoading = true; - firstWidget = loadNode( node, parent ); - reloadStyle( true ); + std::vector widgets = loadNode( node, parent ); + for ( auto& widget : widgets ) + widget->reloadStyle( true, true ); mIsLoading = false; - - return firstWidget; + SceneManager::instance()->setCurrentUISceneNode( prevUISceneNode ); + eePRINTL( "UISceneNode::loadLayoutNodes loaded in: %.2fms", + clock.getElapsedTime().asMilliseconds() ); + return widgets.empty() ? NULL : widgets[0]; } void UISceneNode::setStyleSheet( const CSS::StyleSheet& styleSheet ) { @@ -169,18 +171,21 @@ void UISceneNode::setStyleSheet( const std::string& inlineStyleSheet ) { setStyleSheet( parser.getStyleSheet() ); } -void UISceneNode::combineStyleSheet( const CSS::StyleSheet& styleSheet ) { +void UISceneNode::combineStyleSheet( const CSS::StyleSheet& styleSheet, + const bool& forceReloadStyle ) { mStyleSheet.combineStyleSheet( styleSheet ); processStyleSheetAtRules( styleSheet ); onMediaChanged(); - reloadStyle(); + if ( forceReloadStyle ) + reloadStyle(); } -void UISceneNode::combineStyleSheet( const std::string& inlineStyleSheet ) { +void UISceneNode::combineStyleSheet( const std::string& inlineStyleSheet, + const bool& forceReloadStyle ) { CSS::StyleSheetParser parser; if ( parser.loadFromString( inlineStyleSheet ) ) - combineStyleSheet( parser.getStyleSheet() ); + combineStyleSheet( parser.getStyleSheet(), forceReloadStyle ); } CSS::StyleSheet& UISceneNode::getStyleSheet() { @@ -371,7 +376,7 @@ bool UISceneNode::onMediaChanged() { media.resolution = static_cast( getDPI() ); if ( mStyleSheet.updateMediaLists( media ) ) { - reloadStyle(); + mRoot->reloadChildsStyleState(); return true; } } @@ -397,8 +402,8 @@ void UISceneNode::processStyleSheetAtRules( const StyleSheet& styleSheet ) { void UISceneNode::loadFontFaces( const StyleSheetStyleVector& styles ) { for ( auto& style : styles ) { - CSS::StyleSheetProperty familyProp( style.getPropertyById( PropertyId::FontFamily ) ); - CSS::StyleSheetProperty srcProp( style.getPropertyById( PropertyId::Src ) ); + CSS::StyleSheetProperty familyProp( style->getPropertyById( PropertyId::FontFamily ) ); + CSS::StyleSheetProperty srcProp( style->getPropertyById( PropertyId::Src ) ); if ( !familyProp.isEmpty() && !srcProp.isEmpty() ) { Font* fontSearch = FontManager::instance()->getByName( familyProp.getValue() ); diff --git a/src/eepp/ui/uiscrollbar.cpp b/src/eepp/ui/uiscrollbar.cpp index 30dea3222..1ce933b62 100644 --- a/src/eepp/ui/uiscrollbar.cpp +++ b/src/eepp/ui/uiscrollbar.cpp @@ -57,6 +57,18 @@ UIScrollBar::UIScrollBar( const UIOrientation& orientation ) : mSlider->getBackSlider()->setElementTag( "scrollbar::hback" ); } + auto cb = [&]( const Event* event ) { + onAutoSize(); + adjustChilds(); + }; + + mBtnUp->addEventListener( Event::OnSizeChange, cb ); + mBtnDown->addEventListener( Event::OnSizeChange, cb ); + mSlider->addEventListener( Event::OnSizeChange, [&]( const Event* event ) { + onAutoSize(); + } ); + mSlider->addEventListener( Event::OnPaddingChange, cb ); + adjustChilds(); applyDefaultTheme(); @@ -119,7 +131,7 @@ void UIScrollBar::onAutoSize() { setMinSize( PixelDensity::pxToDp( size ) ); - if ( mFlags & UI_AUTO_SIZE ) { + /*if ( mFlags & UI_AUTO_SIZE ) { if ( mSlider->isVertical() ) { mSlider->setSize( size.getWidth(), getSize().getHeight() ); setSize( size.getWidth(), getSize().getHeight() ); @@ -127,11 +139,11 @@ void UIScrollBar::onAutoSize() { mSlider->setSize( getSize().getWidth(), size.getHeight() ); setSize( getSize().getWidth(), size.getHeight() ); } - } + }*/ } else if ( NULL != mSlider->getSliderButton() ) { tSkin = mSlider->getSliderButton()->getSkin(); - if ( NULL != tSkin ) { + /*if ( NULL != tSkin ) { size = tSkin->getSize(); setMinSize( PixelDensity::pxToDp( size ) ); @@ -143,7 +155,7 @@ void UIScrollBar::onAutoSize() { setSize( getSize().getWidth(), size.getHeight() ); } } - } + }*/ } if ( mLayoutWidthRule == LayoutSizeRule::WrapContent || @@ -180,7 +192,10 @@ void UIScrollBar::onSizeChange() { } void UIScrollBar::adjustChilds() { - mSlider->adjustChilds(); + if ( mNodeFlags & NODE_FLAG_FREE_USE ) + return; + + mNodeFlags |= NODE_FLAG_FREE_USE; mBtnUp->setPosition( 0, 0 ); @@ -238,6 +253,10 @@ void UIScrollBar::adjustChilds() { break; } } + + mSlider->adjustChilds(); + + mNodeFlags &= ~NODE_FLAG_FREE_USE; } Uint32 UIScrollBar::onMessage( const NodeMessage* Msg ) { diff --git a/src/eepp/ui/uislider.cpp b/src/eepp/ui/uislider.cpp index 0061ffe26..c2f0cd220 100644 --- a/src/eepp/ui/uislider.cpp +++ b/src/eepp/ui/uislider.cpp @@ -70,6 +70,8 @@ UISlider::UISlider( const std::string& tag, const UIOrientation& orientation ) : mBackSlider->addEventListener( Event::OnSizeChange, cb ); mSlider->addEventListener( Event::OnSizeChange, cb ); + mBackSlider->addEventListener( Event::OnPaddingChange, cb ); + mSlider->addEventListener( Event::OnPaddingChange, cb ); applyDefaultTheme(); } @@ -130,13 +132,15 @@ void UISlider::adjustChilds() { Float percent = ( mPageStep / ( mMaxValue - mMinValue ) ); if ( UIOrientation::Horizontal == mOrientation ) { - Float size = eemax( ( (Float)getSize().getWidth() * percent ), - mSlider->getMinSize().getWidth() ); + Float size = eemax( + ( ( Float )( getSize().getWidth() - mPadding.Left - mPadding.Right ) * percent ), + mSlider->getMinSize().getWidth() ); mSlider->setSize( size, mSlider->getSize().getHeight() ); } else { - Float size = eemax( ( (Float)getSize().getHeight() * percent ), - mSlider->getMinSize().getHeight() ); + Float size = eemax( + ( ( Float )( getSize().getHeight() - mPadding.Top - mPadding.Bottom ) * percent ), + mSlider->getMinSize().getHeight() ); mSlider->setSize( mSlider->getSize().getWidth(), size ); } @@ -433,7 +437,9 @@ UISlider* UISlider::setOrientation( const UIOrientation& orientation, std::strin mOrientation = orientation; mBackSlider->setMinSize( Sizef::Zero ); + mBackSlider->setMinSizeEq( "", "" ); mSlider->setMinSize( Sizef::Zero ); + mSlider->setMinSizeEq( "", "" ); mBackSlider->setSize( Sizef::Zero ); mSlider->setSize( Sizef::Zero ); @@ -601,19 +607,23 @@ Sizef UISlider::getMinimumSize() { void UISlider::onAutoSize() { if ( mLayoutWidthRule == LayoutSizeRule::WrapContent || mLayoutHeightRule == LayoutSizeRule::WrapContent ) { + bool modified = false; Sizef total( getMinimumSize() ); total = PixelDensity::dpToPx( total ); if ( mLayoutWidthRule == LayoutSizeRule::WrapContent ) { setInternalPixelsWidth( total.getWidth() ); + modified = true; } if ( mLayoutHeightRule == LayoutSizeRule::WrapContent ) { setInternalPixelsHeight( total.getHeight() ); + modified = true; } - adjustChilds(); + if ( modified ) + adjustChilds(); } } diff --git a/src/eepp/ui/uistyle.cpp b/src/eepp/ui/uistyle.cpp index e392d2bcd..e7a2a8c15 100644 --- a/src/eepp/ui/uistyle.cpp +++ b/src/eepp/ui/uistyle.cpp @@ -67,7 +67,7 @@ void UIStyle::load() { StyleSheetStyleVector styles = styleSheet.getElementStyles( mWidget ); for ( auto& style : styles ) { - const StyleSheetSelector& selector = style.getSelector(); + const StyleSheetSelector& selector = style->getSelector(); if ( selector.isCacheable() ) { mCacheableStyles.push_back( style ); @@ -75,15 +75,7 @@ void UIStyle::load() { mNoncacheableStyles.push_back( style ); } - findVariables( style ); - } - - for ( auto& style : mCacheableStyles ) { - applyVarValues( style ); - } - - for ( auto& style : mNoncacheableStyles ) { - applyVarValues( style ); + findVariables( style.get() ); } subscribeNonCacheableStyles(); @@ -182,9 +174,9 @@ void UIStyle::unsubscribeRelated( UIWidget* widget ) { mRelatedWidgets.erase( widget ); } -void UIStyle::tryApplyStyle( const StyleSheetStyle& style ) { - if ( style.isMediaValid() && style.getSelector().select( mWidget ) ) { - for ( const auto& prop : style.getProperties() ) { +void UIStyle::tryApplyStyle( const StyleSheetStyle* style ) { + if ( style->isMediaValid() && style->getSelector().select( mWidget ) ) { + for ( const auto& prop : style->getProperties() ) { const StyleSheetProperty& property = prop.second; const auto& it = mProperties.find( property.getId() ); @@ -192,6 +184,8 @@ void UIStyle::tryApplyStyle( const StyleSheetStyle& style ) { property.getSpecificity() >= it->second.getSpecificity() ) { mProperties[property.getId()] = property; + applyVarValues( mProperties[property.getId()] ); + if ( String::startsWith( property.getName(), "transition" ) ) mTransitionProperties.push_back( property ); else if ( String::startsWith( property.getName(), "animation" ) ) @@ -201,16 +195,13 @@ void UIStyle::tryApplyStyle( const StyleSheetStyle& style ) { } } -void UIStyle::findVariables( const StyleSheetStyle& style ) { - if ( style.getSelector().select( mWidget, false ) ) { - for ( const auto& vars : style.getVariables() ) { - const StyleSheetVariable& variable = vars.second; - const auto& it = mVariables.find( variable.getName() ); +void UIStyle::findVariables( const StyleSheetStyle* style ) { + for ( const auto& vars : style->getVariables() ) { + const StyleSheetVariable& variable = vars.second; + const auto& it = mVariables.find( variable.getName() ); - if ( it == mVariables.end() || - variable.getSpecificity() >= it->second.getSpecificity() ) { - mVariables[variable.getName()] = variable; - } + if ( it == mVariables.end() || variable.getSpecificity() >= it->second.getSpecificity() ) { + mVariables[variable.getName()] = variable; } } } @@ -267,20 +258,16 @@ void UIStyle::setVariableFromValue( StyleSheetProperty& property, const std::str } } -void UIStyle::applyVarValues( StyleSheetStyle& style ) { - for ( auto& prop : style.getPropertiesRef() ) { - StyleSheetProperty& property = prop.second; - - if ( property.isVarValue() ) { - if ( NULL != property.getPropertyDefinition() && - property.getPropertyDefinition()->isIndexed() ) { - for ( size_t i = 0; i < property.getPropertyIndexCount(); i++ ) { - StyleSheetProperty& realProperty = property.getPropertyIndexRef( i ); - setVariableFromValue( realProperty, realProperty.getValue() ); - } - } else { - setVariableFromValue( property, property.getValue() ); +void UIStyle::applyVarValues( StyleSheetProperty& property ) { + if ( property.isVarValue() ) { + if ( NULL != property.getPropertyDefinition() && + property.getPropertyDefinition()->isIndexed() ) { + for ( size_t i = 0; i < property.getPropertyIndexCount(); i++ ) { + StyleSheetProperty& realProperty = property.getPropertyIndexRef( i ); + setVariableFromValue( realProperty, realProperty.getValue() ); } + } else { + setVariableFromValue( property, property.getValue() ); } } } @@ -299,14 +286,14 @@ void UIStyle::onStateChange() { mTransitionProperties.clear(); mAnimationProperties.clear(); - tryApplyStyle( mElementStyle ); + tryApplyStyle( &mElementStyle ); for ( auto& style : mCacheableStyles ) { - tryApplyStyle( style ); + tryApplyStyle( style.get() ); } for ( auto& style : mNoncacheableStyles ) { - tryApplyStyle( style ); + tryApplyStyle( style.get() ); } if ( !mapEquals( mProperties, prevProperties ) || mForceReapplyProperties ) { @@ -358,9 +345,9 @@ StyleSheetProperty UIStyle::getStatelessStyleSheetProperty( const Uint32& proper return property; } - for ( const StyleSheetStyle& style : mCacheableStyles ) { - if ( !style.getSelector().hasPseudoClasses() ) { - StyleSheetProperty property = style.getPropertyById( propertyId ); + for ( auto style : mCacheableStyles ) { + if ( !style->getSelector().hasPseudoClasses() ) { + StyleSheetProperty property = style->getPropertyById( propertyId ); if ( !property.isEmpty() ) return property; @@ -389,7 +376,7 @@ void UIStyle::updateState() { void UIStyle::subscribeNonCacheableStyles() { for ( auto& style : mNoncacheableStyles ) { - std::vector elements = style.getSelector().getRelatedElements( mWidget, false ); + std::vector elements = style->getSelector().getRelatedElements( mWidget, false ); if ( !elements.empty() ) { for ( auto& element : elements ) { @@ -512,8 +499,7 @@ void UIStyle::applyStyleSheetProperty( const StyleSheetProperty& property, } } else if ( startValue == prevTransition->getEndValue() ) { startValue = currentValue; - } /*else if ( startValue == prevTransition->getStartValue() ) { - }*/ + } for ( auto& rem : removeTransitions ) { mWidget->removeAction( rem ); diff --git a/src/eepp/ui/uitab.cpp b/src/eepp/ui/uitab.cpp index 92abd58f7..53d4346ed 100644 --- a/src/eepp/ui/uitab.cpp +++ b/src/eepp/ui/uitab.cpp @@ -13,6 +13,11 @@ UITab::UITab() : UISelectButton( "tab" ), mControlOwned( NULL ) { mTextBox->setElementTag( mTag + "::text" ); mIcon->setElementTag( mTag + "::icon" ); applyDefaultTheme(); + auto cb = [&]( const Event* event ) { + onSizeChange(); + }; + mTextBox->addEventListener( Event::OnSizeChange, cb ); + mIcon->addEventListener( Event::OnSizeChange, cb ); } UITab::~UITab() {} @@ -39,6 +44,13 @@ void UITab::onParentChange() { UISelectButton::onParentChange(); } +void UITab::onSizeChange() { + onAutoSize(); + if ( NULL != getTabWidget() ) + getTabWidget()->orderTabs(); + UISelectButton::onSizeChange(); +} + void UITab::setTheme( UITheme* Theme ) { UIWidget::setTheme( Theme ); @@ -129,6 +141,11 @@ void UITab::onAutoSize() { } setInternalWidth( w ); + + if ( getSize().getWidth() != w ) { + if ( NULL != getTabWidget() ) + getTabWidget()->orderTabs(); + } } } diff --git a/src/eepp/ui/uitable.cpp b/src/eepp/ui/uitable.cpp index a3f4bac82..281ad662f 100644 --- a/src/eepp/ui/uitable.cpp +++ b/src/eepp/ui/uitable.cpp @@ -29,6 +29,8 @@ UITable::UITable() : mCollWidthAssigned( false ) { setFlags( UI_AUTO_PADDING ); + auto cb = [&]( const Event* event ) { containerResize(); }; + mContainer = eeNew( UIItemContainer, () ); mContainer->setVisible( true ); mContainer->setEnabled( true ); @@ -59,6 +61,9 @@ UITable::UITable() : mHScrollBar->addEventListener( Event::OnValueChange, cb::Make1( this, &UITable::onScrollValueChange ) ); + mVScrollBar->addEventListener( Event::OnSizeChange, cb ); + mHScrollBar->addEventListener( Event::OnSizeChange, cb ); + applyDefaultTheme(); } @@ -123,24 +128,10 @@ void UITable::autoPadding() { } void UITable::onSizeChange() { - mVScrollBar->setPosition( getSize().getWidth() - mVScrollBar->getSize().getWidth(), 0 ); - mVScrollBar->setSize( mVScrollBar->getSize().getWidth(), getSize().getHeight() ); - - mHScrollBar->setPosition( 0, getSize().getHeight() - mHScrollBar->getSize().getHeight() ); - mHScrollBar->setSize( getSize().getWidth() - mVScrollBar->getSize().getWidth(), - mHScrollBar->getSize().getHeight() ); - - if ( mContainer->isClipped() && ScrollBarMode::Auto == mHScrollMode ) { - if ( (Int32)mTotalWidth <= mContainer->getSize().getWidth() ) { - mHScrollBar->setVisible( false ); - mHScrollBar->setEnabled( false ); - mHScrollInit = 0; - } - } - containerResize(); setDefaultCollumnsWidth(); updateScroll(); + updatePageStep(); } void UITable::containerResize() { @@ -148,20 +139,23 @@ void UITable::containerResize() { mContainer->setPosition( padding.Left, padding.Top ); - if ( mHScrollBar->isVisible() ) + if ( mHScrollBar->isVisible() ) { mContainer->setPixelsSize( mSize.getWidth() - padding.Right - padding.Left, mSize.getHeight() - padding.Top - mHScrollBar->getPixelsSize().getHeight() ); - else + } else { mContainer->setPixelsSize( mSize.getWidth() - padding.Right - padding.Left, mSize.getHeight() - padding.Bottom - padding.Top ); + } - if ( mVScrollBar->isVisible() ) + if ( mVScrollBar->isVisible() ) { mContainer->setPixelsSize( mContainer->getPixelsSize().getWidth() - mVScrollBar->getPixelsSize().getWidth(), mContainer->getPixelsSize().getHeight() ); + } setDefaultCollumnsWidth(); + updateScrollBar(); } void UITable::updateVScroll() { @@ -235,6 +229,23 @@ void UITable::setHScrollStep() { mHScrollBar->setClickStep( stepVal ); } +void UITable::updateScrollBar() { + mVScrollBar->setPosition( getSize().getWidth() - mVScrollBar->getSize().getWidth(), 0 ); + mVScrollBar->setSize( mVScrollBar->getSize().getWidth(), getSize().getHeight() ); + + mHScrollBar->setPosition( 0, getSize().getHeight() - mHScrollBar->getSize().getHeight() ); + mHScrollBar->setSize( getSize().getWidth() - mVScrollBar->getSize().getWidth(), + mHScrollBar->getSize().getHeight() ); + + if ( mContainer->isClipped() && ScrollBarMode::Auto == mHScrollMode ) { + if ( (Int32)mTotalWidth <= mContainer->getSize().getWidth() ) { + mHScrollBar->setVisible( false ); + mHScrollBar->setEnabled( false ); + mHScrollInit = 0; + } + } +} + void UITable::updateScroll( bool FromScrollChange ) { if ( !mItems.size() ) return; @@ -367,8 +378,7 @@ void UITable::add( UITableCell* Cell ) { updateScroll(); - mVScrollBar->setPageStep( ( (Float)mContainer->getSize().getHeight() / (Float)mRowHeight ) / - (Float)mItems.size() ); + updatePageStep(); } void UITable::remove( UITableCell* Cell ) { @@ -638,6 +648,11 @@ bool UITable::isTouchOverAllowedChilds() { !mHScrollBar->isMouseOverMeOrChilds(); } +void UITable::updatePageStep() { + mVScrollBar->setPageStep( ( (Float)mContainer->getSize().getHeight() / (Float)mRowHeight ) / + (Float)mItems.size() ); +} + std::string UITable::getPropertyString( const PropertyDefinition* propertyDef, const Uint32& propertyIndex ) { if ( NULL == propertyDef ) diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 346ea2531..fc2a0d03f 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -43,14 +43,15 @@ UIWidget::UIWidget( const std::string& tag ) : mAttributesTransactionCount( 0 ) { mNodeFlags |= NODE_FLAG_WIDGET; - reloadStyle( false, true ); + if ( !isSceneNodeLoading() && !isLoadingState() ) + reloadStyle( false, true ); + + createStyle(); updateAnchorsDistances(); } -UIWidget::UIWidget() : UIWidget( "widget" ) { - reloadStyle( false, true ); -} +UIWidget::UIWidget() : UIWidget( "widget" ) {} UIWidget::~UIWidget() { eeSAFE_DELETE( mStyle ); @@ -248,6 +249,14 @@ Vector2f UIWidget::getTooltipPosition() { return Pos; } +void UIWidget::createStyle() { + if ( NULL == mStyle && NULL != getSceneNode() && getSceneNode()->isUISceneNode() && + getUISceneNode()->hasStyleSheet() ) { + mStyle = UIStyle::New( this ); + mStyle->setState( mState ); + } +} + Uint32 UIWidget::onMouseMove( const Vector2i& position, const Uint32& flags ) { EventDispatcher* eventDispatcher = getEventDispatcher(); @@ -425,7 +434,8 @@ Node* UIWidget::setSize( const Float& Width, const Float& Height ) { Node* UIWidget::setId( const std::string& id ) { Node::setId( id ); - reloadStyle( true ); + if ( !isSceneNodeLoading() && !isLoadingState() ) + reloadStyle( true ); return this; } @@ -563,7 +573,7 @@ void UIWidget::reportStyleStateChange() { } bool UIWidget::isSceneNodeLoading() const { - return getSceneNode()->isUISceneNode() + return NULL != getSceneNode() && getSceneNode()->isUISceneNode() ? static_cast( getSceneNode() )->isLoading() : false; } @@ -768,7 +778,10 @@ void UIWidget::addClass( const std::string& cls ) { if ( !cls.empty() && !hasClass( cls ) ) { mClasses.push_back( cls ); - reloadStyle( true ); + if ( !isSceneNodeLoading() && !isLoadingState() ) + reloadStyle( true ); + + onClassChange(); } } @@ -782,7 +795,10 @@ void UIWidget::addClasses( const std::vector& classes ) { } } - reloadStyle( true ); + if ( !isSceneNodeLoading() && !isLoadingState() ) + reloadStyle( true ); + + onClassChange(); } } @@ -790,7 +806,10 @@ void UIWidget::removeClass( const std::string& cls ) { if ( hasClass( cls ) ) { mClasses.erase( std::find( mClasses.begin(), mClasses.end(), cls ) ); - reloadStyle( true ); + if ( !isSceneNodeLoading() && !isLoadingState() ) + reloadStyle( true ); + + onClassChange(); } } @@ -808,7 +827,10 @@ void UIWidget::removeClasses( const std::vector& classes ) { } } - reloadStyle( true ); + if ( !isSceneNodeLoading() && !isLoadingState() ) + reloadStyle( true ); + + onClassChange(); } } @@ -824,7 +846,10 @@ void UIWidget::setElementTag( const std::string& tag ) { mMinHeightEq = ""; mMinSize = Sizef::Zero; - reloadStyle( true ); + if ( !isSceneNodeLoading() && !isLoadingState() ) + reloadStyle( true ); + + onTagChange(); } } @@ -881,11 +906,7 @@ UIStyle* UIWidget::getUIStyle() const { } void UIWidget::reloadStyle( const bool& reloadChilds, const bool& disableAnimations ) { - if ( NULL == mStyle && NULL != getSceneNode() && getSceneNode()->isUISceneNode() && - getUISceneNode()->hasStyleSheet() ) { - mStyle = UIStyle::New( this ); - mStyle->setState( mState ); - } + createStyle(); if ( NULL != mStyle ) { if ( disableAnimations ) @@ -893,7 +914,7 @@ void UIWidget::reloadStyle( const bool& reloadChilds, const bool& disableAnimati mStyle->load(); reportStyleStateChange(); - if ( NULL != mChild && reloadChilds ) { + if ( NULL != getFirstChild() && reloadChilds ) { Node* ChildLoop = mChild; while ( NULL != ChildLoop ) { @@ -922,7 +943,16 @@ void UIWidget::onMarginChange() { void UIWidget::onThemeLoaded() {} void UIWidget::onParentChange() { - reloadStyle( true, true ); + if ( !isSceneNodeLoading() && !isLoadingState() ) + reloadStyle( true, true ); +} + +void UIWidget::onClassChange() { + sendCommonEvent( Event::OnClassChange ); +} + +void UIWidget::onTagChange() { + sendCommonEvent( Event::OnTagChange ); } void UIWidget::beginAttributesTransaction() { @@ -1092,10 +1122,11 @@ bool UIWidget::checkPropertyDefinition( const StyleSheetProperty& property ) { } void UIWidget::reloadChildsStyleState() { + reportStyleStateChange(); Node* childLoop = getFirstChild(); while ( childLoop != NULL ) { if ( childLoop->isWidget() ) - childLoop->asType()->reportStyleStateChange(); + childLoop->asType()->reloadChildsStyleState(); childLoop = childLoop->getNextNode(); } } diff --git a/src/eepp/ui/uiwinmenu.cpp b/src/eepp/ui/uiwinmenu.cpp index c423920dc..949e582ac 100644 --- a/src/eepp/ui/uiwinmenu.cpp +++ b/src/eepp/ui/uiwinmenu.cpp @@ -46,7 +46,8 @@ void UIWinMenu::addMenuButton( const String& ButtonText, UIPopUpMenu* Menu ) { Menu->setVisible( false ); Menu->setEnabled( false ); - Menu->setParent( getWindowContainer() ); + // This will force to change the parent when shown, and force the CSS style reload. + Menu->setParent( this ); Menu->addEventListener( Event::OnWidgetFocusLoss, cb::Make1( this, &UIWinMenu::onMenuFocusLoss ) ); Menu->addEventListener( Event::OnHideByClick, cb::Make1( this, &UIWinMenu::onHideByClick ) ); @@ -184,6 +185,7 @@ Uint32 UIWinMenu::onMessage( const NodeMessage* Msg ) { mCurrentMenu = tpop; tbut->select(); + tpop->setParent( getWindowContainer() ); tpop->show(); } } else { @@ -192,6 +194,7 @@ Uint32 UIWinMenu::onMessage( const NodeMessage* Msg ) { mCurrentMenu = tpop; tbut->select(); + tpop->setParent( getWindowContainer() ); tpop->show(); } else { mCurrentMenu = NULL; diff --git a/src/tools/uieditor/uieditor.cpp b/src/tools/uieditor/uieditor.cpp index 2972daa03..08a86ddba 100644 --- a/src/tools/uieditor/uieditor.cpp +++ b/src/tools/uieditor/uieditor.cpp @@ -994,9 +994,11 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) { font, "assets/ui/uitheme.css" ); uiSceneNode = UISceneNode::New(); + uiSceneNode->setId( "uiSceneNode" ); SceneManager::instance()->add( uiSceneNode ); appUiSceneNode = UISceneNode::New(); + appUiSceneNode->setId( "appUiSceneNode" ); SceneManager::instance()->add( appUiSceneNode ); appUiSceneNode->enableDrawInvalidation();