diff --git a/bin/assets/layouts/test_widgets.xml b/bin/assets/layouts/test_widgets.xml
index 2abc25c02..9690a5ff4 100644
--- a/bin/assets/layouts/test_widgets.xml
+++ b/bin/assets/layouts/test_widgets.xml
@@ -30,8 +30,8 @@
- Test 3
- Test 4
- Test 5
- Test 6
- Test 7
- Test 8
-
-
+
+
diff --git a/include/eepp/ui/css/stylesheetselectorrule.hpp b/include/eepp/ui/css/stylesheetselectorrule.hpp
index 81b20a669..73d3ffa3c 100644
--- a/include/eepp/ui/css/stylesheetselectorrule.hpp
+++ b/include/eepp/ui/css/stylesheetselectorrule.hpp
@@ -74,6 +74,10 @@ class EE_API StyleSheetSelectorRule {
bool hasStructuralPseudoClass( const std::string& cls ) const;
+ const std::string& getTagName() const;
+
+ const std::string& getId() const;
+
protected:
int mSpecificity;
PatternMatch mPatternMatch;
diff --git a/include/eepp/ui/css/stylesheetvariable.hpp b/include/eepp/ui/css/stylesheetvariable.hpp
index 4febae9b7..e5a85d720 100644
--- a/include/eepp/ui/css/stylesheetvariable.hpp
+++ b/include/eepp/ui/css/stylesheetvariable.hpp
@@ -43,7 +43,7 @@ class EE_API StyleSheetVariable {
Uint32 mSpecificity;
};
-typedef std::map StyleSheetVariables;
+typedef std::map StyleSheetVariables;
}}} // namespace EE::UI::CSS
diff --git a/include/eepp/ui/uiitemcontainer.hpp b/include/eepp/ui/uiitemcontainer.hpp
index 742d06cb4..4f8cc696a 100644
--- a/include/eepp/ui/uiitemcontainer.hpp
+++ b/include/eepp/ui/uiitemcontainer.hpp
@@ -20,17 +20,17 @@ template class UIItemContainer : public UIWidget {
void drawChilds();
+ virtual void onChildCountChange( Node* child, const bool& removed );
+
protected:
Node* overFind( const Vector2f& Point );
};
-template
-Uint32 UIItemContainer::getType() const {
+template Uint32 UIItemContainer::getType() const {
return UI_TYPE_ITEMCONTAINER;
}
-template
-bool UIItemContainer::isType( const Uint32& type ) const {
+template bool UIItemContainer::isType( const Uint32& type ) const {
return UIItemContainer::getType() == type ? true : UIWidget::isType( type );
}
@@ -38,6 +38,11 @@ template UIItemContainer::UIItemContainer() : UIW
template UIItemContainer::~UIItemContainer() {}
+template
+void UIItemContainer::onChildCountChange( Node* child, const bool& removed ) {
+ UINode::onChildCountChange( child, removed );
+}
+
template void UIItemContainer::update( const Time& time ) {
TContainer* tParent = reinterpret_cast( getParent() );
diff --git a/include/eepp/ui/uilinearlayout.hpp b/include/eepp/ui/uilinearlayout.hpp
index 32e4dd20d..eee130bb9 100644
--- a/include/eepp/ui/uilinearlayout.hpp
+++ b/include/eepp/ui/uilinearlayout.hpp
@@ -39,6 +39,8 @@ class EE_API UILinearLayout : public UILayout {
virtual void onSizeChange();
+ virtual void onPaddingChange();
+
virtual void onParentSizeChange( const Vector2f& SizeChange );
virtual void onChildCountChange( Node* child, const bool& removed );
diff --git a/include/eepp/ui/uirelativelayout.hpp b/include/eepp/ui/uirelativelayout.hpp
index f7c7de8c2..84bf213e2 100644
--- a/include/eepp/ui/uirelativelayout.hpp
+++ b/include/eepp/ui/uirelativelayout.hpp
@@ -22,6 +22,8 @@ class EE_API UIRelativeLayout : public UILayout {
virtual void onSizeChange();
+ virtual void onPaddingChange();
+
virtual void onChildCountChange( Node * child, const bool& removed );
virtual void onParentSizeChange( const Vector2f& SizeChange );
diff --git a/include/eepp/ui/uiscenenode.hpp b/include/eepp/ui/uiscenenode.hpp
index 5be996e8c..a335241e8 100644
--- a/include/eepp/ui/uiscenenode.hpp
+++ b/include/eepp/ui/uiscenenode.hpp
@@ -82,6 +82,10 @@ class EE_API UISceneNode : public SceneNode {
const bool& invalidStyleSheetState();
+ bool getVerbose() const;
+
+ void setVerbose( bool verbose );
+
protected:
friend class EE::UI::UIWindow;
UIWidget* mRoot;
@@ -92,6 +96,7 @@ class EE_API UISceneNode : public SceneNode {
CSS::StyleSheet mStyleSheet;
bool mIsLoading;
bool mCSSInvalid;
+ bool mVerbose;
UIThemeManager* mUIThemeManager;
std::vector mFontFaces;
KeyboardShortcuts mKbShortcuts;
diff --git a/include/eepp/ui/uitab.hpp b/include/eepp/ui/uitab.hpp
index 46ad3223c..891653bfb 100644
--- a/include/eepp/ui/uitab.hpp
+++ b/include/eepp/ui/uitab.hpp
@@ -13,9 +13,9 @@ class EE_API UITab : public UISelectButton {
UITab();
- Node* getControlOwned() const;
+ Node* getOwnedWidget() const;
- void setControlOwned( Node* controlOwned );
+ void setOwnedWidget( Node* ownedWidget );
virtual ~UITab();
@@ -37,7 +37,7 @@ class EE_API UITab : public UISelectButton {
protected:
friend class UITabWidget;
- Node* mControlOwned;
+ Node* mOwnedWidget;
String mText;
std::string mOwnedName;
diff --git a/include/eepp/ui/uitabwidget.hpp b/include/eepp/ui/uitabwidget.hpp
index 7d438a38b..375d50159 100644
--- a/include/eepp/ui/uitabwidget.hpp
+++ b/include/eepp/ui/uitabwidget.hpp
@@ -145,7 +145,7 @@ class EE_API UITabWidget : public UIWidget {
void applyThemeToTabs();
- void refreshControlOwned( UITab* tab );
+ void refreshOwnedWidget( UITab* tab );
};
}} // namespace EE::UI
diff --git a/include/eepp/ui/uiwidget.hpp b/include/eepp/ui/uiwidget.hpp
index 408236337..e1d8daf38 100644
--- a/include/eepp/ui/uiwidget.hpp
+++ b/include/eepp/ui/uiwidget.hpp
@@ -160,7 +160,8 @@ class EE_API UIWidget : public UINode {
UIStyle* getUIStyle() const;
- void reloadStyle( const bool& reloadChilds = true, const bool& disableAnimations = false );
+ void reloadStyle( const bool& reloadChilds = true, const bool& disableAnimations = false,
+ const bool& reportStateChange = true );
void beginAttributesTransaction();
@@ -225,6 +226,8 @@ class EE_API UIWidget : public UINode {
void setMaxHeightEq( const std::string& maxHeightEq );
+ void reportStyleStateChangeRecursive();
+
protected:
friend class UIManager;
friend class UISceneNode;
@@ -308,8 +311,6 @@ class EE_API UIWidget : public UINode {
bool checkPropertyDefinition( const StyleSheetProperty& property );
- void reloadChildsStyleState();
-
Vector2f getTooltipPosition();
void createStyle();
diff --git a/include/eepp/ui/uiwindow.hpp b/include/eepp/ui/uiwindow.hpp
index 63a5583b2..5381ad294 100644
--- a/include/eepp/ui/uiwindow.hpp
+++ b/include/eepp/ui/uiwindow.hpp
@@ -262,6 +262,8 @@ class EE_API UIWindow : public UIWidget {
virtual void onWindowReady();
+ Sizef getMinWindowSizeWithDecoration();
+
void onContainerPositionChange( const Event* Event );
void setupModal();
diff --git a/src/eepp/graphics/texture.cpp b/src/eepp/graphics/texture.cpp
index 0ca9e51ab..e599cc1a5 100644
--- a/src/eepp/graphics/texture.cpp
+++ b/src/eepp/graphics/texture.cpp
@@ -309,6 +309,12 @@ void Texture::iTextureFilter( const TextureFilter& filter ) {
if ( mTexture ) {
mFilter = filter;
+ bool threaded = Engine::instance()->isSharedGLContextEnabled() &&
+ Thread::getCurrentThreadId() != Engine::instance()->getMainThreadId();
+
+ if ( threaded )
+ Engine::instance()->getCurrentWindow()->setGLContextThread();
+
ScopedTexture saver( mTexture );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
@@ -320,6 +326,9 @@ void Texture::iTextureFilter( const TextureFilter& filter ) {
else
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
( mFilter == Linear ) ? GL_LINEAR : GL_NEAREST );
+
+ if ( threaded )
+ Engine::instance()->getCurrentWindow()->unsetGLContextThread();
}
}
diff --git a/src/eepp/ui/css/propertydefinition.cpp b/src/eepp/ui/css/propertydefinition.cpp
index 827b8f25a..30f0ecbf2 100644
--- a/src/eepp/ui/css/propertydefinition.cpp
+++ b/src/eepp/ui/css/propertydefinition.cpp
@@ -79,7 +79,11 @@ bool PropertyDefinition::isAlias( const std::string& alias ) const {
}
bool PropertyDefinition::isAlias( const Uint32& id ) const {
- return std::find( mAliasesHash.begin(), mAliasesHash.end(), id ) != mAliasesHash.end();
+ for ( auto& tid : mAliasesHash ) {
+ if ( tid == id )
+ return true;
+ }
+ return false;
}
bool PropertyDefinition::isDefinition( const std::string& name ) const {
diff --git a/src/eepp/ui/css/stylesheetpropertiesparser.cpp b/src/eepp/ui/css/stylesheetpropertiesparser.cpp
index 93a7b4883..e818a1b2b 100644
--- a/src/eepp/ui/css/stylesheetpropertiesparser.cpp
+++ b/src/eepp/ui/css/stylesheetpropertiesparser.cpp
@@ -149,7 +149,7 @@ void StyleSheetPropertiesParser::addProperty( std::string name, std::string valu
mProperties[property.getId()] = property;
} else {
if ( String::startsWith( name, "--" ) ) {
- mVariables[name] = StyleSheetVariable( name, value );
+ mVariables[String::hash(name)] = StyleSheetVariable( name, value );
} else {
StyleSheetProperty property( StyleSheetProperty( name, value ) );
mProperties[property.getId()] = property;
diff --git a/src/eepp/ui/css/stylesheetselectorrule.cpp b/src/eepp/ui/css/stylesheetselectorrule.cpp
index 35c321b64..3ebadc027 100644
--- a/src/eepp/ui/css/stylesheetselectorrule.cpp
+++ b/src/eepp/ui/css/stylesheetselectorrule.cpp
@@ -218,25 +218,39 @@ bool StyleSheetSelectorRule::hasStructuralPseudoClass( const std::string& cls )
mStructuralPseudoClasses.end();
}
+const std::string& StyleSheetSelectorRule::getTagName() const {
+ return mTagName;
+}
+
+const std::string& StyleSheetSelectorRule::getId() const {
+ return mId;
+}
+
bool StyleSheetSelectorRule::matches( UIWidget* element, const bool& applyPseudo ) const {
Uint32 flags = 0;
- if ( mTagName == "*" ) {
- if ( !applyPseudo ) {
- return true;
+ if ( !mTagName.empty() ) {
+ if ( mTagName != "*" ) {
+ if ( mTagName != element->getElementTag() ) {
+ return false;
+ } else {
+ flags |= TagName;
+ }
} else {
- flags |= TagName;
+ if ( !applyPseudo ) {
+ return true;
+ } else {
+ flags |= TagName;
+ }
}
}
- if ( !mTagName.empty() && !element->getStyleSheetTag().empty() &&
- mTagName == element->getStyleSheetTag() ) {
- flags |= TagName;
- }
-
- if ( !mId.empty() && !element->getStyleSheetId().empty() &&
- mId == element->getStyleSheetId() ) {
- flags |= Id;
+ if ( !mId.empty() ) {
+ if ( mId != element->getId() ) {
+ return false;
+ } else {
+ flags |= Id;
+ }
}
if ( !mClasses.empty() && !element->getStyleSheetClasses().empty() ) {
diff --git a/src/eepp/ui/css/stylesheetstyle.cpp b/src/eepp/ui/css/stylesheetstyle.cpp
index eec021592..dcc04bbd0 100644
--- a/src/eepp/ui/css/stylesheetstyle.cpp
+++ b/src/eepp/ui/css/stylesheetstyle.cpp
@@ -125,7 +125,7 @@ void StyleSheetStyle::clearProperties() {
}
StyleSheetVariable StyleSheetStyle::getVariableByName( const std::string& name ) const {
- auto it = mVariables.find( name );
+ auto it = mVariables.find( String::hash( name ) );
if ( it != mVariables.end() )
return it->second;
@@ -134,7 +134,7 @@ StyleSheetVariable StyleSheetStyle::getVariableByName( const std::string& name )
}
void StyleSheetStyle::setVariable( const StyleSheetVariable& variable ) {
- mVariables[variable.getName()] = variable;
+ mVariables[variable.getNameHash()] = variable;
}
bool StyleSheetStyle::isMediaValid() const {
diff --git a/src/eepp/ui/tools/textureatlasnew.cpp b/src/eepp/ui/tools/textureatlasnew.cpp
index 94fc27c70..3de48f652 100644
--- a/src/eepp/ui/tools/textureatlasnew.cpp
+++ b/src/eepp/ui/tools/textureatlasnew.cpp
@@ -11,17 +11,16 @@ namespace EE { namespace UI { namespace Tools {
TextureAtlasNew::TextureAtlasNew( TGCreateCb NewTGCb ) : mUIWindow( NULL ), mNewTGCb( NewTGCb ) {
mUIWindow = UIWindow::New();
- mUIWindow->setSizeWithDecoration( 378, 374 )
- ->setMinWindowSize( 378, 374 )
- ->setWinFlags( UI_WIN_CLOSE_BUTTON | UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS |
- UI_WIN_SHARE_ALPHA_WITH_CHILDS | UI_WIN_MODAL );
+ mUIWindow->setSizeWithDecoration( 378, 0 )->setMinWindowSize( 378, 0 )->setWinFlags(
+ UI_WIN_CLOSE_BUTTON | UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS | UI_WIN_SHARE_ALPHA_WITH_CHILDS |
+ UI_WIN_MODAL );
mUIWindow->addEventListener( Event::OnWindowClose,
cb::Make1( this, &TextureAtlasNew::windowClose ) );
mUIWindow->setTitle( "New Texture Atlas" );
std::string layout = R"xml(
-
+
@@ -79,9 +78,11 @@ TextureAtlasNew::TextureAtlasNew( TGCreateCb NewTGCb ) : mUIWindow( NULL ), mNew
)xml";
- if ( mUIWindow->getSceneNode()->isUISceneNode() )
- static_cast( mUIWindow->getSceneNode() )
- ->loadLayoutFromString( layout, mUIWindow->getContainer() );
+ UIWidget* container = NULL;
+ if ( mUIWindow->getSceneNode()->isUISceneNode() ) {
+ container =
+ mUIWindow->getUISceneNode()->loadLayoutFromString( layout, mUIWindow->getContainer() );
+ }
mUIWindow->bind( "saveType", mSaveFileType );
mUIWindow->bind( "maxTAWidth", mComboWidth );
@@ -114,7 +115,8 @@ TextureAtlasNew::TextureAtlasNew( TGCreateCb NewTGCb ) : mUIWindow( NULL ), mNew
mUIWindow->find( "cancelButton" )
->addEventListener( Event::MouseClick, cb::Make1( this, &TextureAtlasNew::cancelClick ) );
- mUIWindow->setSizeWithDecoration( mUIWindow->getContainer()->find( "container" )->getSize() );
+ mUIWindow->setMinWindowSize(
+ Sizef( container->getSize().getWidth(), container->getSize().getHeight() ) );
mUIWindow->center();
mUIWindow->show();
}
diff --git a/src/eepp/ui/uilinearlayout.cpp b/src/eepp/ui/uilinearlayout.cpp
index 526177b07..e92890ca9 100644
--- a/src/eepp/ui/uilinearlayout.cpp
+++ b/src/eepp/ui/uilinearlayout.cpp
@@ -51,6 +51,11 @@ void UILinearLayout::onSizeChange() {
pack();
}
+void UILinearLayout::onPaddingChange() {
+ UILayout::onPaddingChange();
+ pack();
+}
+
void UILinearLayout::onParentSizeChange( const Vector2f& ) {
UILayout::onParentChange();
pack();
diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp
index 754f88e0a..d97947685 100644
--- a/src/eepp/ui/uinode.cpp
+++ b/src/eepp/ui/uinode.cpp
@@ -329,7 +329,7 @@ void UINode::updateDebugData() {
text += "Classes: " + String::join( widget->getStyleSheetClasses(), ' ' ) + "\n";
}
- text += String::format( "X: %2.4f Y: %2.4f\nW: %2.4f H: %2.4f", mDpPos.x, mDpPos.y,
+ text += String::format( "X: %.2f Y: %.2f\nW: %.2f H: %.2f", mDpPos.x, mDpPos.y,
mDpSize.x, mDpSize.y );
if ( widget->getPadding() != Rectf( 0, 0, 0, 0 ) ) {
diff --git a/src/eepp/ui/uirelativelayout.cpp b/src/eepp/ui/uirelativelayout.cpp
index 11cb8bf97..9ce8c01bb 100644
--- a/src/eepp/ui/uirelativelayout.cpp
+++ b/src/eepp/ui/uirelativelayout.cpp
@@ -28,6 +28,11 @@ void UIRelativeLayout::onSizeChange() {
fixChilds();
}
+void UIRelativeLayout::onPaddingChange() {
+ UILayout::onPaddingChange();
+ fixChilds();
+}
+
void UIRelativeLayout::onChildCountChange( Node* child, const bool& removed ) {
UILayout::onChildCountChange( child, removed );
fixChilds();
diff --git a/src/eepp/ui/uiscenenode.cpp b/src/eepp/ui/uiscenenode.cpp
index 7fad1fbe5..35026d2f1 100644
--- a/src/eepp/ui/uiscenenode.cpp
+++ b/src/eepp/ui/uiscenenode.cpp
@@ -32,6 +32,11 @@ UISceneNode::UISceneNode( EE::Window::Window* window ) :
mRoot( NULL ),
mIsLoading( false ),
mCSSInvalid( false ),
+#ifdef EE_DEBUG
+ mVerbose( true ),
+#else
+ mVerbose( false ),
+#endif
mUIThemeManager( UIThemeManager::New() ) {
// Update only UI elements that requires it.
setUpdateAllChilds( false );
@@ -114,13 +119,18 @@ bool UISceneNode::windowExists( UIWindow* win ) {
return mWindowsList.end() != std::find( mWindowsList.begin(), mWindowsList.end(), win );
}
+static std::vector> times;
+
std::vector UISceneNode::loadNode( pugi::xml_node node, Node* parent ) {
std::vector rootWidgets;
if ( NULL == parent )
parent = this;
+ Clock clock;
for ( pugi::xml_node widget = node; widget; widget = widget.next_sibling() ) {
+ clock.restart();
+
UIWidget* uiwidget = UIWidgetCreator::createFromName( widget.name() );
if ( NULL != uiwidget ) {
@@ -129,6 +139,11 @@ std::vector UISceneNode::loadNode( pugi::xml_node node, Node* parent
uiwidget->setParent( parent );
uiwidget->loadFromXmlNode( widget );
+ if ( mVerbose ) {
+ times.push_back( std::make_pair(
+ clock.getElapsedTime().asMilliseconds(), widget.name() ) );
+ }
+
if ( widget.first_child() ) {
loadNode( widget.first_child(), uiwidget );
}
@@ -146,14 +161,52 @@ UIWidget* UISceneNode::loadLayoutNodes( pugi::xml_node node, Node* parent ) {
Clock clock;
UISceneNode* prevUISceneNode = SceneManager::instance()->getUISceneNode();
SceneManager::instance()->setCurrentUISceneNode( this );
+ std::string id( node.attribute( "id" ).as_string() );
mIsLoading = true;
+ Clock innerClock;
std::vector widgets = loadNode( node, parent );
+
+ if ( mVerbose ) {
+ std::sort(
+ times.begin(), times.end(),
+ []( const std::pair& left,
+ const std::pair& right ) { return left.first < right.first; } );
+
+ for ( auto& time : times ) {
+ eePRINTL( "Widget %s created in %.2f ms", time.second.c_str(), time.first );
+ }
+
+ times.clear();
+
+ eePRINTL( "UISceneNode::loadLayoutNodes loaded nodes%s in: %.2f ms",
+ id.empty() ? "" : std::string( " (id=" + id + ")" ).c_str(),
+ innerClock.getElapsed().asMilliseconds() );
+ }
+
for ( auto& widget : widgets )
- widget->reloadStyle( true, true );
+ widget->reloadStyle( true, true, false );
+
+ if ( mVerbose ) {
+ eePRINTL( "UISceneNode::loadLayoutNodes reloaded styles in: %.2f ms",
+ innerClock.getElapsed().asMilliseconds() );
+ }
+
+ for ( auto& widget : widgets )
+ widget->reportStyleStateChangeRecursive();
+
+ if ( mVerbose ) {
+ eePRINTL( "UISceneNode::loadLayoutNodes reloaded style state in: %.2f ms",
+ innerClock.getElapsed().asMilliseconds() );
+ }
+
mIsLoading = false;
SceneManager::instance()->setCurrentUISceneNode( prevUISceneNode );
- eePRINTL( "UISceneNode::loadLayoutNodes loaded in: %.2fms",
- clock.getElapsedTime().asMilliseconds() );
+
+ if ( mVerbose ) {
+ eePRINTL( "UISceneNode::loadLayoutNodes loaded in: %.2f ms",
+ clock.getElapsedTime().asMilliseconds() );
+ }
+
return widgets.empty() ? NULL : widgets[0];
}
@@ -336,7 +389,10 @@ void UISceneNode::update( const Time& elapsed ) {
if ( mCSSInvalid ) {
mCSSInvalid = false;
- mRoot->reloadChildsStyleState();
+ Clock clock;
+ mRoot->reportStyleStateChangeRecursive();
+ eePRINTL( "CSS Invalidated, reapplied state in %.2f ms",
+ clock.getElapsedTime().asMilliseconds() );
}
SceneManager::instance()->setCurrentUISceneNode( uiSceneNode );
@@ -362,6 +418,14 @@ const bool& UISceneNode::invalidStyleSheetState() {
return mCSSInvalid;
}
+bool UISceneNode::getVerbose() const {
+ return mVerbose;
+}
+
+void UISceneNode::setVerbose( bool verbose ) {
+ mVerbose = verbose;
+}
+
bool UISceneNode::onMediaChanged() {
if ( !mStyleSheet.isMediaQueryListEmpty() ) {
MediaFeatures media;
@@ -376,7 +440,7 @@ bool UISceneNode::onMediaChanged() {
media.resolution = static_cast( getDPI() );
if ( mStyleSheet.updateMediaLists( media ) ) {
- mRoot->reloadChildsStyleState();
+ mRoot->reportStyleStateChangeRecursive();
return true;
}
}
diff --git a/src/eepp/ui/uiscrollbar.cpp b/src/eepp/ui/uiscrollbar.cpp
index 1ce933b62..1127699d0 100644
--- a/src/eepp/ui/uiscrollbar.cpp
+++ b/src/eepp/ui/uiscrollbar.cpp
@@ -57,20 +57,6 @@ 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();
}
@@ -131,7 +117,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() );
@@ -139,11 +125,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 ) );
@@ -155,7 +141,7 @@ void UIScrollBar::onAutoSize() {
setSize( getSize().getWidth(), size.getHeight() );
}
}
- }*/
+ }
}
if ( mLayoutWidthRule == LayoutSizeRule::WrapContent ||
diff --git a/src/eepp/ui/uislider.cpp b/src/eepp/ui/uislider.cpp
index c2f0cd220..f9bf30e44 100644
--- a/src/eepp/ui/uislider.cpp
+++ b/src/eepp/ui/uislider.cpp
@@ -401,17 +401,17 @@ Uint32 UISlider::onKeyDown( const KeyEvent& Event ) {
void UISlider::manageClick( const Uint32& Flags ) {
if ( Flags && NULL != getEventDispatcher() ) {
- Vector2f ControlPos = getEventDispatcher()->getMousePosf();
- mSlider->worldToNode( ControlPos );
+ Vector2f controlPos = getEventDispatcher()->getMousePosf();
+ mSlider->worldToNode( controlPos );
if ( Flags & EE_BUTTON_LMASK && !mSlider->isMouseOver() ) {
if ( UIOrientation::Horizontal == mOrientation ) {
- if ( ControlPos.x < 0 )
+ if ( controlPos.x < 0 )
setValue( mValue - mClickStep );
else
setValue( mValue + mClickStep );
} else {
- if ( ControlPos.y < 0 )
+ if ( controlPos.y < 0 )
setValue( mValue - mClickStep );
else
setValue( mValue + mClickStep );
diff --git a/src/eepp/ui/uispinbox.cpp b/src/eepp/ui/uispinbox.cpp
index 232605210..2336ba735 100644
--- a/src/eepp/ui/uispinbox.cpp
+++ b/src/eepp/ui/uispinbox.cpp
@@ -45,8 +45,6 @@ UISpinBox::UISpinBox() :
internalValue( mValue, true );
- adjustChilds();
-
applyDefaultTheme();
}
diff --git a/src/eepp/ui/uistyle.cpp b/src/eepp/ui/uistyle.cpp
index e7a2a8c15..f7a8cc21c 100644
--- a/src/eepp/ui/uistyle.cpp
+++ b/src/eepp/ui/uistyle.cpp
@@ -131,7 +131,7 @@ const bool& UIStyle::isChangingState() const {
}
StyleSheetVariable UIStyle::getVariable( const std::string& variable ) {
- auto it = mVariables.find( variable );
+ auto it = mVariables.find( String::hash( variable ) );
if ( it != mVariables.end() ) {
return it->second;
@@ -198,10 +198,10 @@ void UIStyle::tryApplyStyle( const StyleSheetStyle* style ) {
void UIStyle::findVariables( const StyleSheetStyle* style ) {
for ( const auto& vars : style->getVariables() ) {
const StyleSheetVariable& variable = vars.second;
- const auto& it = mVariables.find( variable.getName() );
+ const auto& it = mVariables.find( variable.getNameHash() );
if ( it == mVariables.end() || variable.getSpecificity() >= it->second.getSpecificity() ) {
- mVariables[variable.getName()] = variable;
+ mVariables[variable.getNameHash()] = variable;
}
}
}
diff --git a/src/eepp/ui/uitab.cpp b/src/eepp/ui/uitab.cpp
index 53d4346ed..8b34b7dfa 100644
--- a/src/eepp/ui/uitab.cpp
+++ b/src/eepp/ui/uitab.cpp
@@ -9,13 +9,11 @@ UITab* UITab::New() {
return eeNew( UITab, () );
}
-UITab::UITab() : UISelectButton( "tab" ), mControlOwned( NULL ) {
+UITab::UITab() : UISelectButton( "tab" ), mOwnedWidget( NULL ) {
mTextBox->setElementTag( mTag + "::text" );
mIcon->setElementTag( mTag + "::icon" );
applyDefaultTheme();
- auto cb = [&]( const Event* event ) {
- onSizeChange();
- };
+ auto cb = [&]( const Event* event ) { onSizeChange(); };
mTextBox->addEventListener( Event::OnSizeChange, cb );
mIcon->addEventListener( Event::OnSizeChange, cb );
}
@@ -187,7 +185,7 @@ bool UITab::applyProperty( const StyleSheetProperty& attribute ) {
Uint32 UITab::onMouseUp( const Vector2i& Pos, const Uint32& Flags ) {
if ( mEnabled && mVisible ) {
- if ( NULL == mControlOwned && !mOwnedName.empty() ) {
+ if ( NULL == mOwnedWidget && !mOwnedName.empty() ) {
setOwnedControl();
}
@@ -213,7 +211,7 @@ void UITab::setOwnedControl() {
Node* ctrl = getParent()->getParent()->find( mOwnedName );
if ( NULL != ctrl ) {
- setControlOwned( ctrl );
+ setOwnedWidget( ctrl );
}
}
@@ -231,17 +229,17 @@ void UITab::updateTab() {
}
}
-Node* UITab::getControlOwned() const {
- return mControlOwned;
+Node* UITab::getOwnedWidget() const {
+ return mOwnedWidget;
}
-void UITab::setControlOwned( Node* controlOwned ) {
- mControlOwned = controlOwned;
+void UITab::setOwnedWidget( Node* ownedWidget ) {
+ mOwnedWidget = ownedWidget;
UITabWidget* tTabW = getTabWidget();
if ( NULL != tTabW ) {
- tTabW->refreshControlOwned( this );
+ tTabW->refreshOwnedWidget( this );
if ( NULL == tTabW->mTabSelected )
tTabW->setTabSelected( this );
diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp
index 851ec0eda..084bb4103 100644
--- a/src/eepp/ui/uitabwidget.cpp
+++ b/src/eepp/ui/uitabwidget.cpp
@@ -85,10 +85,16 @@ void UITabWidget::setContainerSize() {
PixelDensity::dpToPx( mStyleConfig.TabHeight ) );
mTabContainer->setPosition( mPadding.Left, mPadding.Top );
mCtrlContainer->setPosition( mPadding.Left, mPadding.Top + mStyleConfig.TabHeight );
- mCtrlContainer->setPixelsSize( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right,
- mSize.getHeight() -
- PixelDensity::dpToPx( mStyleConfig.TabHeight ) -
- mRealPadding.Top - mRealPadding.Bottom );
+ Sizef s( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right,
+ mSize.getHeight() - PixelDensity::dpToPx( mStyleConfig.TabHeight ) - mRealPadding.Top -
+ mRealPadding.Bottom );
+ if ( s != mCtrlContainer->getSize() ) {
+ mCtrlContainer->setPixelsSize( s );
+
+ for ( auto& tab : mTabs ) {
+ refreshOwnedWidget( tab );
+ }
+ }
}
const UITabWidget::StyleConfig& UITabWidget::getStyleConfig() const {
@@ -346,26 +352,26 @@ void UITabWidget::updateTabs() {
}
}
-UITab* UITabWidget::createTab( const String& Text, UINode* CtrlOwned, Drawable* Icon ) {
- UITab* tCtrl = UITab::New();
- tCtrl->setParent( mTabContainer );
- tCtrl->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER | UI_AUTO_SIZE );
- tCtrl->setIcon( Icon );
- tCtrl->setText( Text );
- tCtrl->setVisible( true );
- tCtrl->setEnabled( true );
- tCtrl->setControlOwned( CtrlOwned );
- CtrlOwned->setParent( mCtrlContainer );
- CtrlOwned->setVisible( false );
- CtrlOwned->setEnabled( true );
+UITab* UITabWidget::createTab( const String& Text, UINode* ownedWidget, Drawable* Icon ) {
+ UITab* tab = UITab::New();
+ tab->setParent( mTabContainer );
+ tab->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER | UI_AUTO_SIZE );
+ tab->setIcon( Icon );
+ tab->setText( Text );
+ tab->setVisible( true );
+ tab->setEnabled( true );
+ tab->setOwnedWidget( ownedWidget );
+ ownedWidget->setParent( mCtrlContainer );
+ ownedWidget->setVisible( false );
+ ownedWidget->setEnabled( true );
- if ( CtrlOwned->isWidget() ) {
- UIWidget* widgetOwned = static_cast( CtrlOwned );
+ if ( ownedWidget->isWidget() ) {
+ UIWidget* widgetOwned = static_cast( ownedWidget );
widgetOwned->setLayoutSizeRules( LayoutSizeRule::Fixed, LayoutSizeRule::Fixed );
}
- return tCtrl;
+ return tab;
}
UITabWidget* UITabWidget::add( const String& Text, UINode* CtrlOwned, Drawable* Icon ) {
@@ -421,8 +427,8 @@ void UITabWidget::removeTab( const Uint32& Index ) {
eeASSERT( Index < mTabs.size() );
if ( mTabs[Index] == mTabSelected ) {
- mTabSelected->getControlOwned()->setVisible( false );
- mTabSelected->getControlOwned()->setEnabled( false );
+ mTabSelected->getOwnedWidget()->setVisible( false );
+ mTabSelected->getOwnedWidget()->setEnabled( false );
}
mTabs[Index]->close();
@@ -498,16 +504,16 @@ void UITabWidget::setTabSelected( UITab* Tab ) {
invalidateDraw();
if ( Tab == mTabSelected ) {
- refreshControlOwned( Tab );
+ refreshOwnedWidget( Tab );
return;
}
if ( NULL != mTabSelected ) {
mTabSelected->unselect();
- if ( NULL != mTabSelected->getControlOwned() ) {
- mTabSelected->getControlOwned()->setVisible( false );
- mTabSelected->getControlOwned()->setEnabled( false );
+ if ( NULL != mTabSelected->getOwnedWidget() ) {
+ mTabSelected->getOwnedWidget()->setVisible( false );
+ mTabSelected->getOwnedWidget()->setEnabled( false );
}
}
@@ -519,7 +525,7 @@ void UITabWidget::setTabSelected( UITab* Tab ) {
mTabSelected = Tab;
mTabSelectedIndex = TabIndex;
- refreshControlOwned( mTabSelected );
+ refreshOwnedWidget( mTabSelected );
orderTabs();
@@ -533,19 +539,19 @@ void UITabWidget::setTabSelected( const Uint32& tabIndex ) {
}
}
-void UITabWidget::refreshControlOwned( UITab* tab ) {
- if ( NULL != tab && NULL != tab->getControlOwned() ) {
- tab->getControlOwned()->setParent( mCtrlContainer );
- tab->getControlOwned()->setVisible( tab == mTabSelected );
- tab->getControlOwned()->setEnabled( tab == mTabSelected );
- tab->getControlOwned()->setSize( mCtrlContainer->getSize() );
+void UITabWidget::refreshOwnedWidget( UITab* tab ) {
+ if ( NULL != tab && NULL != tab->getOwnedWidget() ) {
+ tab->getOwnedWidget()->setParent( mCtrlContainer );
+ tab->getOwnedWidget()->setVisible( tab == mTabSelected );
+ tab->getOwnedWidget()->setEnabled( tab == mTabSelected );
+ tab->getOwnedWidget()->setSize( mCtrlContainer->getSize() );
- if ( tab->getControlOwned()->isWidget() ) {
- UIWidget* widget = static_cast( tab->getControlOwned() );
+ if ( tab->getOwnedWidget()->isWidget() ) {
+ UIWidget* widget = static_cast( tab->getOwnedWidget() );
widget->setPosition( widget->getLayoutMargin().Left, widget->getLayoutMargin().Top );
} else {
- tab->getControlOwned()->setPosition( 0, 0 );
+ tab->getOwnedWidget()->setPosition( 0, 0 );
}
}
}
@@ -574,8 +580,8 @@ void UITabWidget::onSizeChange() {
setContainerSize();
posTabs();
- if ( NULL != mTabSelected && NULL != mTabSelected->getControlOwned() ) {
- mTabSelected->getControlOwned()->setSize( mCtrlContainer->getSize() );
+ if ( NULL != mTabSelected && NULL != mTabSelected->getOwnedWidget() ) {
+ mTabSelected->getOwnedWidget()->setSize( mCtrlContainer->getSize() );
}
UIWidget::onSizeChange();
diff --git a/src/eepp/ui/uitextview.cpp b/src/eepp/ui/uitextview.cpp
index 3b8f79279..17fa67b3b 100644
--- a/src/eepp/ui/uitextview.cpp
+++ b/src/eepp/ui/uitextview.cpp
@@ -53,8 +53,6 @@ UITextView::UITextView( const std::string& tag ) :
}
}
- alignFix();
-
applyDefaultTheme();
}
@@ -392,8 +390,10 @@ Uint32 UITextView::onMouseDoubleClick( const Vector2i& Pos, const Uint32& Flags
if ( isTextSelectionEnabled() && ( Flags & EE_BUTTON_LMASK ) ) {
Vector2f controlPos( Vector2f( Pos.x, Pos.y ) );
worldToNode( controlPos );
- controlPos = PixelDensity::dpToPx( controlPos ) - mRealAlignOffset;
- controlPos -= Vector2f( mRealPadding.Left, mRealPadding.Top );
+ controlPos = PixelDensity::dpToPx( controlPos ) - mRealAlignOffset -
+ Vector2f( mRealPadding.Left, mRealPadding.Top );
+ controlPos.x = eemax( 0.f, controlPos.x );
+ controlPos.y = eemax( 0.f, controlPos.y );
Int32 curPos = mTextCache->findCharacterFromPos( controlPos.asInt() );
@@ -432,8 +432,10 @@ Uint32 UITextView::onMouseDown( const Vector2i& Pos, const Uint32& Flags ) {
getEventDispatcher()->getDownControl() == this ) {
Vector2f controlPos( Vector2f( Pos.x, Pos.y ) );
worldToNode( controlPos );
- controlPos = PixelDensity::dpToPx( controlPos ) - mRealAlignOffset +
+ controlPos = PixelDensity::dpToPx( controlPos ) - mRealAlignOffset -
Vector2f( mRealPadding.Left, mRealPadding.Top );
+ controlPos.x = eemax( 0.f, controlPos.x );
+ controlPos.y = eemax( 0.f, controlPos.y );
Int32 curPos = mTextCache->findCharacterFromPos( controlPos.asInt() );
diff --git a/src/eepp/ui/uitooltip.cpp b/src/eepp/ui/uitooltip.cpp
index af520315e..506902979 100644
--- a/src/eepp/ui/uitooltip.cpp
+++ b/src/eepp/ui/uitooltip.cpp
@@ -36,6 +36,8 @@ UITooltip::UITooltip() :
autoPadding();
applyDefaultTheme();
+
+ reloadStyle( true, true );
}
UITooltip::~UITooltip() {
diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp
index fc2a0d03f..48c5e1955 100644
--- a/src/eepp/ui/uiwidget.cpp
+++ b/src/eepp/ui/uiwidget.cpp
@@ -905,26 +905,31 @@ UIStyle* UIWidget::getUIStyle() const {
return mStyle;
}
-void UIWidget::reloadStyle( const bool& reloadChilds, const bool& disableAnimations ) {
+void UIWidget::reloadStyle( const bool& reloadChilds, const bool& disableAnimations,
+ const bool& reportStateChange ) {
createStyle();
if ( NULL != mStyle ) {
if ( disableAnimations )
mStyle->setDisableAnimations( true );
+
mStyle->load();
- reportStyleStateChange();
if ( NULL != getFirstChild() && reloadChilds ) {
- Node* ChildLoop = mChild;
+ Node* child = getFirstChild();
- while ( NULL != ChildLoop ) {
- if ( ChildLoop->isWidget() )
- ChildLoop->asType()->reloadStyle( reloadChilds, disableAnimations );
+ while ( NULL != child ) {
+ if ( child->isWidget() )
+ child->asType()->reloadStyle( reloadChilds, disableAnimations,
+ reportStateChange );
- ChildLoop = ChildLoop->getNextNode();
+ child = child->getNextNode();
}
}
+ if ( reportStateChange )
+ reportStyleStateChange();
+
if ( disableAnimations )
mStyle->setDisableAnimations( false );
}
@@ -1121,14 +1126,14 @@ bool UIWidget::checkPropertyDefinition( const StyleSheetProperty& property ) {
return true;
}
-void UIWidget::reloadChildsStyleState() {
- reportStyleStateChange();
+void UIWidget::reportStyleStateChangeRecursive() {
Node* childLoop = getFirstChild();
while ( childLoop != NULL ) {
if ( childLoop->isWidget() )
- childLoop->asType()->reloadChildsStyleState();
+ childLoop->asType()->reportStyleStateChangeRecursive();
childLoop = childLoop->getNextNode();
}
+ reportStyleStateChange();
}
UIWidget* UIWidget::querySelector( const std::string& selector ) {
@@ -1313,12 +1318,12 @@ bool UIWidget::applyProperty( const StyleSheetProperty& attribute ) {
break;
case PropertyId::Width:
setLayoutWidthRule( LayoutSizeRule::Fixed );
- setInternalWidth( eefloor( lengthFromValueAsDp( attribute ) ) );
+ setSize( eefloor( lengthFromValueAsDp( attribute ) ), getSize().getHeight() );
notifyLayoutAttrChange();
break;
case PropertyId::Height:
setLayoutHeightRule( LayoutSizeRule::Fixed );
- setInternalHeight( eefloor( lengthFromValueAsDp( attribute ) ) );
+ setSize( getSize().getWidth(), eefloor( lengthFromValueAsDp( attribute ) ) );
notifyLayoutAttrChange();
break;
case PropertyId::BackgroundColor:
diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp
index 80bbadaa8..79413bb3a 100644
--- a/src/eepp/ui/uiwindow.cpp
+++ b/src/eepp/ui/uiwindow.cpp
@@ -82,9 +82,7 @@ UIWindow::UIWindow( UIWindow::WindowBaseContainerType type, const StyleConfig& w
applyDefaultTheme();
- runOnMainThread( [&]() {
- onWindowReady();
- } );
+ runOnMainThread( [&]() { onWindowReady(); } );
}
UIWindow::~UIWindow() {
@@ -557,25 +555,27 @@ void UIWindow::calcMinWinSize() {
}
void UIWindow::applyMinWinSize() {
- if ( getSize().getWidth() < mStyleConfig.MinWindowSize.getWidth() &&
- getSize().getHeight() < mStyleConfig.MinWindowSize.getHeight() ) {
+ Sizef size( getMinWindowSizeWithDecoration() );
+
+ if ( getSize().getWidth() < size.getWidth() && getSize().getHeight() < size.getHeight() ) {
setSize( mStyleConfig.MinWindowSize );
- } else if ( getSize().getWidth() < mStyleConfig.MinWindowSize.getWidth() ) {
+ } else if ( getSize().getWidth() < size.getWidth() ) {
setSize( Sizef( mStyleConfig.MinWindowSize.getWidth(), getSize().getHeight() ) );
- } else if ( getSize().getHeight() < mStyleConfig.MinWindowSize.getHeight() ) {
+ } else if ( getSize().getHeight() < size.getHeight() ) {
setSize( Sizef( getSize().getWidth(), mStyleConfig.MinWindowSize.getHeight() ) );
}
}
void UIWindow::onSizeChange() {
- if ( getSize().getWidth() < mStyleConfig.MinWindowSize.getWidth() ||
- getSize().getHeight() < mStyleConfig.MinWindowSize.getHeight() ) {
- if ( getSize().getWidth() < mStyleConfig.MinWindowSize.getWidth() &&
+ Sizef size( getMinWindowSizeWithDecoration() );
+
+ if ( getSize().getWidth() < size.getWidth() || getSize().getHeight() < size.getHeight() ) {
+ if ( getSize().getWidth() < size.getWidth() &&
getSize().getHeight() < mStyleConfig.MinWindowSize.getHeight() ) {
setSize( mStyleConfig.MinWindowSize );
- } else if ( getSize().getWidth() < mStyleConfig.MinWindowSize.getHeight() ) {
+ } else if ( getSize().getWidth() < size.getWidth() ) {
setSize( Sizef( mStyleConfig.MinWindowSize.getWidth(), getSize().getHeight() ) );
- } else {
+ } else if ( getSize().getHeight() < size.getHeight() ) {
setSize( Sizef( getSize().getWidth(), mStyleConfig.MinWindowSize.getHeight() ) );
}
} else {
@@ -631,12 +631,11 @@ const Sizef& UIWindow::getSize() const {
}
void UIWindow::fixChildsSize() {
- if ( mSize.getWidth() < PixelDensity::dpToPx( mStyleConfig.MinWindowSize.getWidth() ) ||
- mSize.getHeight() < PixelDensity::dpToPx( mStyleConfig.MinWindowSize.getHeight() ) ) {
- internalSize( eemin( mSize.getWidth(),
- PixelDensity::dpToPx( mStyleConfig.MinWindowSize.getWidth() ) ),
- eemin( mSize.getHeight(),
- PixelDensity::dpToPx( mStyleConfig.MinWindowSize.getHeight() ) ) );
+ Sizef size( PixelDensity::dpToPx( getMinWindowSizeWithDecoration() ) );
+
+ if ( mSize.getWidth() < size.getWidth() || mSize.getHeight() < size.getHeight() ) {
+ internalSize( eemin( mSize.getWidth(), size.getWidth() ),
+ eemin( mSize.getHeight(), size.getHeight() ) );
}
if ( NULL == mWindowDecoration && NULL != mContainer ) {
@@ -1004,7 +1003,7 @@ void UIWindow::internalSize( const Float& w, const Float& h ) {
}
void UIWindow::internalSize( Sizef Size ) {
- Sizef realMin = PixelDensity::dpToPx( mStyleConfig.MinWindowSize );
+ Sizef realMin = PixelDensity::dpToPx( getMinWindowSizeWithDecoration() );
Size.x = eemax( realMin.x, Size.x );
Size.y = eemax( realMin.y, Size.y );
@@ -1409,6 +1408,15 @@ UIWindow* UIWindow::setMinWindowSize( Sizef size ) {
return this;
}
+Sizef UIWindow::getMinWindowSizeWithDecoration() {
+ Sizef size( getMinWindowSize() );
+ if ( NULL != mWindowDecoration ) {
+ size.x += mBorderLeft->getSize().getWidth() + mBorderRight->getSize().getWidth();
+ size.y += mWindowDecoration->getSize().getHeight() + mBorderBottom->getSize().getHeight();
+ }
+ return size;
+}
+
const Sizef& UIWindow::getMinWindowSize() {
return mStyleConfig.MinWindowSize;
}
diff --git a/src/eepp/window/inputtextbuffer.cpp b/src/eepp/window/inputtextbuffer.cpp
index 23d949113..13e078ab3 100644
--- a/src/eepp/window/inputtextbuffer.cpp
+++ b/src/eepp/window/inputtextbuffer.cpp
@@ -668,7 +668,7 @@ void InputTextBuffer::setCursorPosition( const Uint32& pos ) {
}
void InputTextBuffer::setCursorPos( const Uint32& pos ) {
- if ( isFreeEditingEnabled() ) {
+ if ( isFreeEditingEnabled() && mPromptPos != (Int32)pos ) {
setCursorPosition( pos );
onCursorPositionChange();
diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp
index 04a6bf90c..bd4e9751b 100644
--- a/src/test/eetest.cpp
+++ b/src/test/eetest.cpp
@@ -602,6 +602,7 @@ void EETest::createUI() {
sceneNode->enableDrawInvalidation();
sceneNode->enableFrameBuffer();
+ sceneNode->setVerbose( true );
if ( mDebugUI ) {
sceneNode->setDrawBoxes( true );
@@ -732,7 +733,8 @@ void EETest::createNewUI() {
pushButton->setText( "PushButton" );
pushButton->setIcon( mTheme->getIconByName( "ok" ) );
pushButton->addEventListener( Event::MouseClick, [&, pushButton]( const Event* event ) {
- createColorPicker( pushButton );
+ if ( static_cast( event )->getFlags() & EE_BUTTON_LMASK )
+ createColorPicker( pushButton );
} );
UISprite* sprite = UISprite::New();
@@ -899,7 +901,7 @@ void EETest::createNewUI() {
->setLayoutSizeRules( LayoutSizeRule::MatchParent, LayoutSizeRule::Fixed )
->setSize( 0, 105 )
->setParent( lay2 );
- lbox->addListBoxItems( { "This", "is", "a", "ListBox" } );
+ lbox->addListBoxItems( {"This", "is", "a", "ListBox"} );
lay2->setParent( layPar );
lay->setParent( layPar );
@@ -907,7 +909,7 @@ void EETest::createNewUI() {
drop->setLayoutMargin( Rect( 10, 10, 10, 10 ) )
->setLayoutSizeRules( LayoutSizeRule::MatchParent, LayoutSizeRule::WrapContent )
->setParent( layWin );
- drop->getListBox()->addListBoxItems( { "Car", "Bus", "Plane", "Submarine" } );
+ drop->getListBox()->addListBoxItems( {"Car", "Bus", "Plane", "Submarine"} );
drop->getListBox()->setSelected( 0 );
win->show();
diff --git a/src/tools/mapeditor/mapeditor.cpp b/src/tools/mapeditor/mapeditor.cpp
index 96e190448..9d4ca2407 100644
--- a/src/tools/mapeditor/mapeditor.cpp
+++ b/src/tools/mapeditor/mapeditor.cpp
@@ -104,6 +104,8 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
UITheme* theme =
UITheme::load( "uitheme" + pd, "uitheme" + pd, "assets/ui/uitheme" + pd + ".eta",
font, "assets/ui/uitheme.css" );
+ /*UITheme* theme =
+ UITheme::load( "uitheme", "uitheme", "", font, "assets/ui/breeze.css" );*/
uiSceneNode->combineStyleSheet( theme->getStyleSheet() );
diff --git a/src/tools/uieditor/uieditor.cpp b/src/tools/uieditor/uieditor.cpp
index 08a86ddba..2f7c383d4 100644
--- a/src/tools/uieditor/uieditor.cpp
+++ b/src/tools/uieditor/uieditor.cpp
@@ -767,6 +767,13 @@ void mainLoop() {
uiSceneNode->setDrawDebugData( !uiSceneNode->getDrawDebugData() );
}
+ if ( window->getInput()->isKeyUp( KEY_F9 ) ) {
+ Clock clock;
+ uiSceneNode->getRoot()->reportStyleStateChangeRecursive();
+ eePRINTL( "Applied style state changes in: %.2fms",
+ clock.getElapsedTime().asMilliseconds() );
+ }
+
if ( mousePos != window->getInput()->getMousePos() ) {
mousePos = window->getInput()->getMousePos();
mouseClock.restart();
@@ -967,6 +974,9 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
preserveContainerSize = true;
}
+ Log::instance()->setLiveWrite( true );
+ Log::instance()->setConsoleOutput( true );
+
window = Engine::instance()->createWindow(
WindowSettings( 1280, 720, "eepp - UI Editor", WindowStyle::Default, WindowBackend::Default,
32, "assets/icon/ee.png", pixelDensity ),
@@ -995,6 +1005,7 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
uiSceneNode = UISceneNode::New();
uiSceneNode->setId( "uiSceneNode" );
+ uiSceneNode->setVerbose( true );
SceneManager::instance()->add( uiSceneNode );
appUiSceneNode = UISceneNode::New();