diff --git a/bin/assets/layouts/test.css b/bin/assets/layouts/test.css index 3165f7959..7d1ca3177 100644 --- a/bin/assets/layouts/test.css +++ b/bin/assets/layouts/test.css @@ -3,9 +3,13 @@ src: url("file://assets/fonts/OpenSans-Regular.ttf"); } +:root { + --font-color: #E6E6E6FF; +} + /* Global rules */ * { - color: #E6E6E6FF; + color: var(--font-color); shadow-color: #32323296; selected-color: #000; selection-back-color: #969696FF; @@ -31,7 +35,7 @@ WinMenu { Menu, PopUpMenu { - color: #E6E6E6FF; + color: var(--font-color); min-width: 100dp; min-icon-space: 24dp; min-margin-right: 8dp; @@ -63,7 +67,7 @@ Window { } Window::title { - color: #E6E6E6FF; + color: var(--font-color); font-style: shadow; } diff --git a/include/eepp/ui/uiscenenode.hpp b/include/eepp/ui/uiscenenode.hpp index 119c232b6..cfa9262c6 100644 --- a/include/eepp/ui/uiscenenode.hpp +++ b/include/eepp/ui/uiscenenode.hpp @@ -10,6 +10,7 @@ namespace EE { namespace UI { class UIThemeManager; class UIWidget; class UIWindow; +class UIWidget; class EE_API UISceneNode : public SceneNode { public: @@ -62,8 +63,11 @@ class EE_API UISceneNode : public SceneNode { UIThemeManager* getUIThemeManager() const; + UIWidget* getRoot() const; + protected: friend class EE::UI::UIWindow; + UIWidget* mRoot; Sizef mDpSize; Uint32 mFlags; Translator mTranslator; @@ -89,6 +93,10 @@ class EE_API UISceneNode : public SceneNode { void reloadStyle(); bool onMediaChanged(); + + virtual void onChildCountChange(); + + virtual void onSizeChange(); }; }} // namespace EE::UI diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index 34c12d484..641662eed 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -43,7 +43,7 @@ UINode::UINode() : mNodeFlags |= NODE_FLAG_UINODE | NODE_FLAG_OVER_FIND_ALLOWED; if ( NULL != SceneManager::instance()->getUISceneNode() ) - setParent( (Node*)SceneManager::instance()->getUISceneNode() ); + setParent( (Node*)SceneManager::instance()->getUISceneNode()->getRoot() ); } UINode::~UINode() { @@ -889,7 +889,11 @@ Node * UINode::getWindowContainer() const { if ( Ctrl->isType( UI_TYPE_WINDOW ) ) { return static_cast( Ctrl )->getContainer(); } else if ( mSceneNode == Ctrl ) { - return mSceneNode; + if ( mSceneNode->isUISceneNode() ) { + return static_cast( mSceneNode )->getRoot(); + } else { + return mSceneNode; + } } Ctrl = Ctrl->getParent(); diff --git a/src/eepp/ui/uiscenenode.cpp b/src/eepp/ui/uiscenenode.cpp index bfd15dda2..3c2f068e3 100644 --- a/src/eepp/ui/uiscenenode.cpp +++ b/src/eepp/ui/uiscenenode.cpp @@ -18,7 +18,10 @@ UISceneNode* UISceneNode::New( EE::Window::Window* window ) { } UISceneNode::UISceneNode( EE::Window::Window* window ) : - SceneNode( window ), mIsLoading( false ), mUIThemeManager( UIThemeManager::New() ) { + SceneNode( window ), + mRoot( NULL ), + mIsLoading( false ), + mUIThemeManager( UIThemeManager::New() ) { // Update only UI elements that requires it. setUpdateAllChilds( false ); @@ -26,6 +29,13 @@ UISceneNode::UISceneNode( EE::Window::Window* window ) : setEventDispatcher( UIEventDispatcher::New( this ) ); + mRoot = UIWidget::NewWithTag( ":root" ); + mRoot->setLayoutSizeRules( FIXED, FIXED ); + mRoot->writeNodeFlag( NODE_FLAG_OWNED_BY_NODE, 1 ); + mRoot->setParent( this ); + mRoot->clipEnable(); + mRoot->enableReportSizeChangeToChilds(); + resizeControl( mWindow ); } @@ -166,7 +176,7 @@ void UISceneNode::reloadStyle() { while ( NULL != ChildLoop ) { if ( ChildLoop->isWidget() ) - static_cast( ChildLoop )->reloadStyle(); + ChildLoop->asType()->reloadStyle(); ChildLoop = ChildLoop->getNextNode(); } @@ -300,6 +310,10 @@ UIThemeManager* UISceneNode::getUIThemeManager() const { return mUIThemeManager; } +UIWidget* UISceneNode::getRoot() const { + return mRoot; +} + bool UISceneNode::onMediaChanged() { if ( !mStyleSheet.isMediaQueryListEmpty() ) { MediaFeatures media; @@ -322,4 +336,31 @@ bool UISceneNode::onMediaChanged() { return false; } +void UISceneNode::onChildCountChange() { + if ( NULL == mRoot ) + return; + + Node* child = mChild; + bool found = false; + + while ( NULL != child ) { + if ( !( child->getNodeFlags() & NODE_FLAG_OWNED_BY_NODE ) ) { + found = true; + break; + } + + child = child->getNextNode(); + } + + if ( found ) { + child->setParent( mRoot ); + } +} + +void UISceneNode::onSizeChange() { + SceneNode::onSizeChange(); + + mRoot->setPixelsSize( getPixelsSize() ); +} + }} // namespace EE::UI diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index abe97e980..968177273 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -713,7 +713,7 @@ UIStyle * UIWidget::getUIStyle() const { } void UIWidget::reloadStyle( const bool& reloadChilds ) { - if ( NULL == mStyle && getSceneNode()->isUISceneNode() && static_cast( getSceneNode() )->hasStyleSheet() ) { + if ( NULL == mStyle && NULL != getSceneNode() && getSceneNode()->isUISceneNode() && getUISceneNode()->hasStyleSheet() ) { mStyle = UIStyle::New( this ); mStyle->setState( mState ); }