diff --git a/include/eepp/ui/uitheme.hpp b/include/eepp/ui/uitheme.hpp index 51a6079b6..cdcd1be74 100644 --- a/include/eepp/ui/uitheme.hpp +++ b/include/eepp/ui/uitheme.hpp @@ -52,6 +52,8 @@ class EE_API UITheme : protected ResourceManager { SubTexture * getIconByName( const std::string& name ); + UISkin * getSkin( const std::string& controlName ); + UITooltipStyleConfig getFontStyleConfig() const; void setFontStyleConfig(const UITooltipStyleConfig & fontConfig); diff --git a/src/eepp/gaming/mapeditor/mapeditor.cpp b/src/eepp/gaming/mapeditor/mapeditor.cpp index 9142a3e0a..8f1e7867b 100644 --- a/src/eepp/gaming/mapeditor/mapeditor.cpp +++ b/src/eepp/gaming/mapeditor/mapeditor.cpp @@ -473,8 +473,8 @@ void MapEditor::onObjectModeSel( const UIEvent * Event ) { } void MapEditor::createUIMap() { - UISkin * HScrollSkin = mTheme->getByName( mTheme->getAbbr() + "_" + "hscrollbar_bg" ); - UISkin * VScrollSkin = mTheme->getByName( mTheme->getAbbr() + "_" + "vscrollbar_bg" ); + UISkin * HScrollSkin = mTheme->getSkin( "hscrollbar_bg" ); + UISkin * VScrollSkin = mTheme->getSkin( "vscrollbar_bg" ); Float ScrollH = 16; Float ScrollV = 16; diff --git a/src/eepp/ui/uicontrol.cpp b/src/eepp/ui/uicontrol.cpp index dad6501be..4f34335e6 100644 --- a/src/eepp/ui/uicontrol.cpp +++ b/src/eepp/ui/uicontrol.cpp @@ -1220,7 +1220,7 @@ UIControl * UIControl::setThemeControl( const std::string& ControlName ) { UIControl * UIControl::setThemeControl( UITheme * Theme, const std::string& ControlName ) { if ( NULL != Theme ) { - UISkin * tSkin = Theme->getByName( Theme->getAbbr() + "_" + ControlName ); + UISkin * tSkin = Theme->getSkin( ControlName ); if ( NULL != tSkin ) { Uint32 InitialState = UISkinState::StateNormal; diff --git a/src/eepp/ui/uilistbox.cpp b/src/eepp/ui/uilistbox.cpp index 3b25b14b3..9456b845e 100644 --- a/src/eepp/ui/uilistbox.cpp +++ b/src/eepp/ui/uilistbox.cpp @@ -65,9 +65,9 @@ UIListBox::UIListBox() : setSmoothScroll( true ); - setRowHeight(); - applyDefaultTheme(); + + setRowHeight(); } UIListBox::~UIListBox() { @@ -298,16 +298,15 @@ void UIListBox::setRowHeight() { if ( 0 == mRowHeight ) { Uint32 FontSize = PixelDensity::dpToPxI( 12 ); - if ( NULL != UIThemeManager::instance()->getDefaultFont() ) - FontSize = UIThemeManager::instance()->getDefaultFont()->getFontHeight( PixelDensity::dpToPxI( UIThemeManager::instance()->getDefaultFontStyleConfig().CharacterSize ) ); + UITheme * theme = NULL != mTheme ? mTheme : UIThemeManager::instance()->getDefaultTheme(); - if ( NULL != mSkinState && NULL != mSkinState->getSkin() && NULL != mSkinState->getSkin()->getTheme() && NULL != mSkinState->getSkin()->getTheme()->getFontStyleConfig().getFont() ) - FontSize = mSkinState->getSkin()->getTheme()->getFontStyleConfig().getFont()->getFontHeight( PixelDensity::dpToPxI( mSkinState->getSkin()->getTheme()->getFontStyleConfig().CharacterSize ) ); + if ( NULL != theme ) + FontSize = theme->getFontStyleConfig().getFont()->getFontHeight( PixelDensity::dpToPxI( UIThemeManager::instance()->getDefaultFontStyleConfig().CharacterSize ) ); if ( NULL != mFontStyleConfig.getFont() ) FontSize = mFontStyleConfig.getFont()->getFontHeight( PixelDensity::dpToPxI( mFontStyleConfig.CharacterSize ) ); - mRowHeight = (Uint32)PixelDensity::pxToDpI( FontSize ); + mRowHeight = (Uint32)PixelDensity::pxToDpI( FontSize ) + 4; } if ( tOldRowHeight != mRowHeight ) { diff --git a/src/eepp/ui/uimenucheckbox.cpp b/src/eepp/ui/uimenucheckbox.cpp index 098ab6edd..62c71f697 100644 --- a/src/eepp/ui/uimenucheckbox.cpp +++ b/src/eepp/ui/uimenucheckbox.cpp @@ -32,8 +32,8 @@ void UIMenuCheckBox::setTheme( UITheme * Theme ) { setThemeControl( Theme, "menuitem" ); - mSkinActive = Theme->getByName( Theme->getAbbr() + "_" + "menucheckbox_active" ); - mSkinInactive = Theme->getByName( Theme->getAbbr() + "_" + "menucheckbox_inactive" ); + mSkinActive = Theme->getSkin( "menucheckbox_active" ); + mSkinInactive = Theme->getSkin( "menucheckbox_inactive" ); setActive( mActive ); diff --git a/src/eepp/ui/uimenusubmenu.cpp b/src/eepp/ui/uimenusubmenu.cpp index 8563cb98b..aab15e20d 100644 --- a/src/eepp/ui/uimenusubmenu.cpp +++ b/src/eepp/ui/uimenusubmenu.cpp @@ -41,7 +41,7 @@ bool UIMenuSubMenu::isType( const Uint32& type ) const { void UIMenuSubMenu::setTheme( UITheme * Theme ) { UIMenuItem::setTheme( Theme ); - mSkinArrow = Theme->getByName( Theme->getAbbr() + "_" + "menuarrow" ); + mSkinArrow = Theme->getSkin( "menuarrow" ); onStateChange(); } diff --git a/src/eepp/ui/uiprogressbar.cpp b/src/eepp/ui/uiprogressbar.cpp index bc34f499c..902562637 100644 --- a/src/eepp/ui/uiprogressbar.cpp +++ b/src/eepp/ui/uiprogressbar.cpp @@ -64,7 +64,7 @@ void UIProgressBar::setTheme( UITheme * Theme ) { UIWidget::setTheme( Theme ); setThemeControl( Theme, "progressbar" ); - UISkin * tSkin = Theme->getByName( Theme->getAbbr() + "_progressbar_filler" ); + UISkin * tSkin = Theme->getSkin( "progressbar_filler" ); if ( tSkin ) { SubTexture * tSubTexture = tSkin->getSubTexture( UISkinState::StateNormal ); diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp index 3dd7b3a50..2ab132a04 100644 --- a/src/eepp/ui/uitabwidget.cpp +++ b/src/eepp/ui/uitabwidget.cpp @@ -57,7 +57,7 @@ void UITabWidget::setTheme( UITheme * Theme ) { mCtrlContainer->setThemeControl( Theme, "tabcontainer" ); if ( 0 == mStyleConfig.TabWidgetHeight ) { - UISkin * tSkin = Theme->getByName( Theme->getAbbr() + "_" + "tab" ); + UISkin * tSkin = Theme->getSkin( "tab" ); if ( NULL != tSkin ) { Sizei tSize1 = getSkinSize( tSkin ); diff --git a/src/eepp/ui/uitheme.cpp b/src/eepp/ui/uitheme.cpp index d2a595712..ef649f2a4 100644 --- a/src/eepp/ui/uitheme.cpp +++ b/src/eepp/ui/uitheme.cpp @@ -146,7 +146,7 @@ UITheme * UITheme::loadFromTextureAtlas( UITheme * tTheme, Graphics::TextureAtla for ( std::list::iterator it = tTheme->mUIElements.begin() ; it != tTheme->mUIElements.end(); it++ ) { Uint32 IsComplex = 0; - Element = std::string( tTheme->getAbbr() + "_" + *it ); + Element = tTheme->getAbbr() + "_" + *it; Found = searchFilesInAtlas( TextureAtlas, Element, IsComplex ); @@ -379,6 +379,10 @@ SubTexture * UITheme::getIconByName( const std::string& name ) { return NULL; } +UISkin * UITheme::getSkin(const std::string & controlName) { + return getByName( mAbbr + "_" + controlName ); +} + void UITheme::setFontStyleConfig(const UITooltipStyleConfig & fontConfig) { mFontStyleConfig = fontConfig; }