diff --git a/bin/assets/layouts/color_picker.xml b/bin/assets/layouts/color_picker.xml new file mode 100644 index 000000000..e237caf2b --- /dev/null +++ b/bin/assets/layouts/color_picker.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/assets/ui/uitheme.eta b/bin/assets/ui/uitheme.eta index 9912f6c93..652bc1687 100644 Binary files a/bin/assets/ui/uitheme.eta and b/bin/assets/ui/uitheme.eta differ diff --git a/bin/assets/ui/uitheme.png b/bin/assets/ui/uitheme.png index 194670583..cd7bb8f38 100644 Binary files a/bin/assets/ui/uitheme.png and b/bin/assets/ui/uitheme.png differ diff --git a/bin/assets/ui/uitheme/uitheme_icon_color-picker-white.png b/bin/assets/ui/uitheme/uitheme_icon_color-picker-white.png new file mode 100644 index 000000000..e181408f4 Binary files /dev/null and b/bin/assets/ui/uitheme/uitheme_icon_color-picker-white.png differ diff --git a/bin/assets/ui/uitheme1.5x.eta b/bin/assets/ui/uitheme1.5x.eta index c076576fd..a96512e62 100644 Binary files a/bin/assets/ui/uitheme1.5x.eta and b/bin/assets/ui/uitheme1.5x.eta differ diff --git a/bin/assets/ui/uitheme1.5x.png b/bin/assets/ui/uitheme1.5x.png index 8d21aa074..96706fcfd 100644 Binary files a/bin/assets/ui/uitheme1.5x.png and b/bin/assets/ui/uitheme1.5x.png differ diff --git a/bin/assets/ui/uitheme1.5x/uitheme1.5x_icon_color-picker-white.png b/bin/assets/ui/uitheme1.5x/uitheme1.5x_icon_color-picker-white.png new file mode 100644 index 000000000..10eff6c20 Binary files /dev/null and b/bin/assets/ui/uitheme1.5x/uitheme1.5x_icon_color-picker-white.png differ diff --git a/bin/assets/ui/uitheme2x.eta b/bin/assets/ui/uitheme2x.eta index 0c5ed4d18..52aba4dd4 100644 Binary files a/bin/assets/ui/uitheme2x.eta and b/bin/assets/ui/uitheme2x.eta differ diff --git a/bin/assets/ui/uitheme2x.png b/bin/assets/ui/uitheme2x.png index 3703c27c3..affba9d97 100644 Binary files a/bin/assets/ui/uitheme2x.png and b/bin/assets/ui/uitheme2x.png differ diff --git a/bin/assets/ui/uitheme2x/uitheme2x_icon_color-picker-white.png b/bin/assets/ui/uitheme2x/uitheme2x_icon_color-picker-white.png new file mode 100644 index 000000000..e87fedac3 Binary files /dev/null and b/bin/assets/ui/uitheme2x/uitheme2x_icon_color-picker-white.png differ diff --git a/include/eepp/graphics/texturefactory.hpp b/include/eepp/graphics/texturefactory.hpp index d0fadbd8b..d4ee3ae3d 100755 --- a/include/eepp/graphics/texturefactory.hpp +++ b/include/eepp/graphics/texturefactory.hpp @@ -197,7 +197,7 @@ class EE_API TextureFactory : protected Mutex { TextureFactory(); - int mCurrentTexture[ EE_MAX_TEXTURE_UNITS ]; + std::vector mCurrentTexture; std::vector mTextures; diff --git a/src/eepp/graphics/texturefactory.cpp b/src/eepp/graphics/texturefactory.cpp index 65ebffb5d..a4481d511 100755 --- a/src/eepp/graphics/texturefactory.cpp +++ b/src/eepp/graphics/texturefactory.cpp @@ -13,14 +13,13 @@ namespace EE { namespace Graphics { SINGLETON_DECLARE_IMPLEMENTATION(TextureFactory) TextureFactory::TextureFactory() : + mCurrentTexture(EE_MAX_TEXTURE_UNITS), mMemSize(0), mLastCoordinateType( Texture::CoordinateType::Normalized ), mErasing(false) { mTextures.clear(); mTextures.push_back( NULL ); - - memset( &mCurrentTexture[0], 0, EE_MAX_TEXTURE_UNITS ); } const Texture::CoordinateType & TextureFactory::getLastCoordinateType() const { diff --git a/src/eepp/scene/node.cpp b/src/eepp/scene/node.cpp index 668cfb0bf..bae715291 100644 --- a/src/eepp/scene/node.cpp +++ b/src/eepp/scene/node.cpp @@ -34,12 +34,15 @@ Node::Node() : } Node::~Node() { - if ( !SceneManager::instance()->isShootingDown() ) { - if ( NULL != mSceneNode && mSceneNode != this && NULL != mSceneNode->getActionManager() ) + if ( !SceneManager::instance()->isShootingDown() && NULL != mSceneNode ) { + if ( mSceneNode != this && NULL != mSceneNode->getActionManager() ) mSceneNode->getActionManager()->removeAllActionsFromTarget(this); - if ( NULL != mSceneNode && (mNodeFlags & NODE_FLAG_SCHEDULED_UPDATE) ) + if ( mNodeFlags & NODE_FLAG_SCHEDULED_UPDATE ) mSceneNode->unsubscribeScheduledUpdate(this); + + if ( isMouseOverMeOrChilds() ) + mSceneNode->removeMouseOverNode( this ); } childDeleteAll(); diff --git a/src/eepp/ui/css/stylesheet.cpp b/src/eepp/ui/css/stylesheet.cpp index 82818f2a1..3d362c58c 100644 --- a/src/eepp/ui/css/stylesheet.cpp +++ b/src/eepp/ui/css/stylesheet.cpp @@ -29,7 +29,7 @@ void StyleSheet::combineStyle( const StyleSheetStyle& node ) { } else { auto& currentNode = nodeIt->second; - if ( node.getSelector().getSpecificity() > currentNode.getSelector().getSpecificity() ) { + if ( node.getSelector().getSpecificity() >= currentNode.getSelector().getSpecificity() ) { for ( auto& pit : node.getProperties() ) currentNode.setProperty( pit.second ); } diff --git a/src/eepp/ui/uiimage.cpp b/src/eepp/ui/uiimage.cpp index b694eeb28..68441f8b6 100644 --- a/src/eepp/ui/uiimage.cpp +++ b/src/eepp/ui/uiimage.cpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace EE { namespace UI { @@ -25,6 +26,8 @@ UIImage::UIImage( const std::string& tag ) : mFlags |= UI_AUTO_SIZE; onAutoSize(); + + applyDefaultTheme(); } UIImage::UIImage() : @@ -74,11 +77,11 @@ void UIImage::onAutoSize() { } if ( mLayoutWidthRules == WRAP_CONTENT ) { - setInternalPixelsWidth( (int)mDrawable->getSize().getWidth() + mRealPadding.Left + mRealPadding.Right ); + setInternalPixelsWidth( (int)PixelDensity::dpToPx( mDrawable->getSize().getWidth() ) + mRealPadding.Left + mRealPadding.Right ); } if ( mLayoutHeightRules == WRAP_CONTENT ) { - setInternalPixelsHeight( (int)mDrawable->getSize().getHeight() + mRealPadding.Top + mRealPadding.Bottom ); + setInternalPixelsHeight( (int)PixelDensity::dpToPx( mDrawable->getSize().getHeight() ) + mRealPadding.Top + mRealPadding.Bottom ); } } } @@ -106,7 +109,7 @@ void UIImage::calcDestSize() { if ( NULL == mDrawable) return; - mDestSize = mDrawable->getSize(); + mDestSize = PixelDensity::dpToPx( mDrawable->getSize() ); } mDestSize = mDestSize.floor(); @@ -220,6 +223,15 @@ bool UIImage::setAttribute( const NodeAttribute& attribute, const Uint32& state setDrawable( res ); } + } else if ( "icon" == name ) { + std::string val = attribute.asString(); + Drawable * icon = NULL; + + if ( NULL != mTheme && NULL != ( icon = mTheme->getIconByName( val ) ) ) { + setDrawable( icon ); + } else if ( NULL != ( icon = DrawableSearcher::searchByName( val ) ) ) { + setDrawable( icon ); + } } else if ( "scale-type" == name || "scaletype" == name ) { std::string val = attribute.asString(); String::toLowerInPlace( val ); diff --git a/src/eepp/ui/uimenu.cpp b/src/eepp/ui/uimenu.cpp index 696762dbb..56e050259 100644 --- a/src/eepp/ui/uimenu.cpp +++ b/src/eepp/ui/uimenu.cpp @@ -216,7 +216,7 @@ Uint32 UIMenu::getCount() const { void UIMenu::remove( const Uint32& Index ) { eeASSERT( Index < mItems.size() ); - eeSAFE_DELETE( mItems[ Index ] ); + mItems[ Index ]->close(); mItems.erase( mItems.begin() + Index ); @@ -235,7 +235,7 @@ void UIMenu::remove( UINode * Ctrl ) { void UIMenu::removeAll() { for ( Uint32 i = 0; i < mItems.size(); i++ ) { - eeSAFE_DELETE( mItems[ i ] ); + mItems[ i ]->close(); } mItems.clear(); diff --git a/src/eepp/ui/uiscenenode.cpp b/src/eepp/ui/uiscenenode.cpp index b258db4db..e51de5acb 100644 --- a/src/eepp/ui/uiscenenode.cpp +++ b/src/eepp/ui/uiscenenode.cpp @@ -4,9 +4,9 @@ #include #include #include -#include #include #include +#include #include namespace EE { namespace UI { @@ -110,6 +110,8 @@ UIWidget * UISceneNode::loadLayoutNodes( pugi::xml_node node, Node * parent ) { uiwidget->reloadStyle( false ); uiwidget->onWidgetCreated(); + } else if ( String::toLower( widget.name() ) == "style" ) { + combineStyleSheet( widget.text().as_string() ); } } diff --git a/src/tools/uieditor/uieditor.cpp b/src/tools/uieditor/uieditor.cpp index 36198cd64..4566690c5 100644 --- a/src/tools/uieditor/uieditor.cpp +++ b/src/tools/uieditor/uieditor.cpp @@ -80,16 +80,12 @@ void loadConfig() { ini.loadFromFile( path ); ini.readFile(); - std::string recent = ini.getValue( "UIEDITOR", "recentfiles", "" ); - std::vector files = String::split( recent, ';' ); - - recentProjects = files; + std::string recent = ini.getValue( "UIEDITOR", "recentprojects", "" ); + recentProjects = String::split( recent, ';' ); } void saveConfig() { - std::string files = String::join( recentProjects, ';' ); - - ini.setValue( "UIEDITOR", "recentfiles", files ); + ini.setValue( "UIEDITOR", "recentprojects", String::join( recentProjects, ';' ) ); ini.writeFile(); } @@ -227,6 +223,10 @@ static void loadLayout( std::string file ) { static void refreshLayout() { if ( !currentLayout.empty() && FileSystem::fileExists( currentLayout ) && uiContainer != NULL ) { + if ( !currentStyleSheet.empty() && FileSystem::fileExists( currentStyleSheet ) && uiContainer != NULL ) { + loadStyleSheet( currentStyleSheet ); + } + loadLayout( currentLayout ); } @@ -236,6 +236,10 @@ static void refreshLayout() { static void refreshStyleSheet() { if ( !currentStyleSheet.empty() && FileSystem::fileExists( currentStyleSheet ) && uiContainer != NULL ) { loadStyleSheet( currentStyleSheet ); + + if ( !currentLayout.empty() && FileSystem::fileExists( currentLayout ) && uiContainer != NULL ) { + loadLayout( currentLayout ); + } } updateStyleSheet = false; @@ -383,7 +387,7 @@ void refreshLayoutList() { chk->setActive( currentLayout == it->second ); } - } else if ( uiWinMenu->getButton( "Layouts" ) == NULL ) { + } else if ( uiWinMenu->getButton( "Layouts" ) != NULL ) { uiWinMenu->removeMenuButton( "Layouts" ); } @@ -534,8 +538,12 @@ void loadProject( std::string projectPath ) { if ( result ) { loadProjectNodes( doc.first_child() ); - if ( recentProjects.size() > 0 && recentProjects[0] == projectPath ) - return; + for ( auto pathIt = recentProjects.begin(); pathIt != recentProjects.end(); pathIt++ ) { + if ( *pathIt == projectPath ) { + recentProjects.erase(pathIt); + break; + } + } recentProjects.insert( recentProjects.begin(), projectPath );