From 5ddbc69a9f9739533bb1b411e5721baef03bc7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=C2=ADn=20Lucas=20Golini?= Date: Tue, 28 Feb 2017 05:35:51 -0300 Subject: [PATCH] Working on a new way to style the widgets from the themes. --HG-- branch : dev --- include/eepp/ui/uicombobox.hpp | 4 +- include/eepp/ui/uicomplexcontrol.hpp | 4 + include/eepp/ui/uicontrol.hpp | 6 +- include/eepp/ui/uidefaulttheme.hpp | 12 +- include/eepp/ui/uilistbox.hpp | 26 +-- include/eepp/ui/uimenu.hpp | 55 +------ include/eepp/ui/uiprogressbar.hpp | 29 +--- include/eepp/ui/uipushbutton.hpp | 28 +--- include/eepp/ui/uiselectbutton.hpp | 6 +- include/eepp/ui/uitab.hpp | 1 - include/eepp/ui/uitabwidget.hpp | 87 ++-------- include/eepp/ui/uitextbox.hpp | 30 +--- include/eepp/ui/uitextedit.hpp | 3 + include/eepp/ui/uitextinputpassword.hpp | 2 + include/eepp/ui/uitheme.hpp | 63 +++---- include/eepp/ui/uithemeconfig.hpp | 127 ++++++++++++++ include/eepp/ui/uithememanager.hpp | 8 +- include/eepp/ui/uitooltip.hpp | 49 ++---- include/eepp/ui/uiwinmenu.hpp | 69 ++------ projects/linux/ee.files | 1 + projects/linux/ee.includes | 1 + src/eepp/gaming/mapeditor/mapeditor.cpp | 9 +- src/eepp/ui/uicombobox.cpp | 14 +- src/eepp/ui/uicommondialog.cpp | 8 +- src/eepp/ui/uicomplexcontrol.cpp | 31 ++-- src/eepp/ui/uicontrol.cpp | 5 + src/eepp/ui/uidefaulttheme.cpp | 134 ++++----------- src/eepp/ui/uidropdownlist.cpp | 2 +- src/eepp/ui/uilistbox.cpp | 64 +++----- src/eepp/ui/uimenu.cpp | 88 ++-------- src/eepp/ui/uimenuitem.cpp | 6 +- src/eepp/ui/uiprogressbar.cpp | 71 +++----- src/eepp/ui/uipushbutton.cpp | 37 +++-- src/eepp/ui/uiselectbutton.cpp | 20 +-- src/eepp/ui/uitab.cpp | 18 +- src/eepp/ui/uitabwidget.cpp | 210 +++++++++--------------- src/eepp/ui/uitextbox.cpp | 80 ++++----- src/eepp/ui/uitextedit.cpp | 14 +- src/eepp/ui/uitextinput.cpp | 2 +- src/eepp/ui/uitextinputpassword.cpp | 16 +- src/eepp/ui/uitheme.cpp | 191 ++++++++------------- src/eepp/ui/uithememanager.cpp | 42 ++++- src/eepp/ui/uitooltip.cpp | 91 ++++++---- src/eepp/ui/uiwindow.cpp | 2 +- src/eepp/ui/uiwinmenu.cpp | 83 ++-------- src/test/eetest.cpp | 20 +-- 46 files changed, 743 insertions(+), 1126 deletions(-) create mode 100644 include/eepp/ui/uithemeconfig.hpp diff --git a/include/eepp/ui/uicombobox.hpp b/include/eepp/ui/uicombobox.hpp index 10b93b68c..edd73add8 100644 --- a/include/eepp/ui/uicombobox.hpp +++ b/include/eepp/ui/uicombobox.hpp @@ -7,7 +7,7 @@ namespace EE { namespace UI { class EE_API UIComboBox : public UIComplexControl { public: - UIComboBox( UIComboBox::CreateParams& Params ); + static UIComboBox * New(); UIComboBox(); @@ -43,8 +43,6 @@ class EE_API UIComboBox : public UIComplexControl { virtual void onSizeChange(); virtual void onPositionChange(); - - virtual void onParentChange(); }; }} diff --git a/include/eepp/ui/uicomplexcontrol.hpp b/include/eepp/ui/uicomplexcontrol.hpp index c207e6514..645a57259 100644 --- a/include/eepp/ui/uicomplexcontrol.hpp +++ b/include/eepp/ui/uicomplexcontrol.hpp @@ -51,6 +51,10 @@ class EE_API UIComplexControl : public UIControlAnim { virtual UIControl * setSize( const Sizei& size ); + virtual UIControl * setFlags( const Uint32& flags ); + + virtual UIControl * unsetFlags( const Uint32& flags ); + UIControl * setSize( const Int32& Width, const Int32& Height ); const Sizei& getSize(); diff --git a/include/eepp/ui/uicontrol.hpp b/include/eepp/ui/uicontrol.hpp index b5258ddb0..fb3a8f779 100644 --- a/include/eepp/ui/uicontrol.hpp +++ b/include/eepp/ui/uicontrol.hpp @@ -174,9 +174,11 @@ class EE_API UIControl { const Uint32& getFlags() const; - UIControl * setFlags( const Uint32& flags ); + virtual UIControl * setFlags( const Uint32& flags ); - UIControl * unsetFlags( const Uint32& flags ); + virtual UIControl * unsetFlags( const Uint32& flags ); + + UIControl * resetFlags(); void setBlendMode( const EE_BLEND_MODE& blend ); diff --git a/include/eepp/ui/uidefaulttheme.hpp b/include/eepp/ui/uidefaulttheme.hpp index 1b9cd1242..3a22ec302 100644 --- a/include/eepp/ui/uidefaulttheme.hpp +++ b/include/eepp/ui/uidefaulttheme.hpp @@ -9,9 +9,11 @@ class EE_API UIDefaultTheme : public UITheme { public: UIDefaultTheme( const std::string& name, const std::string& abbr, Graphics::Font * defaultFont = NULL ); - virtual UIPopUpMenu * createPopUpMenu(UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE | UI_AUTO_PADDING, Recti PaddingContainer = Recti(), Uint32 MinWidth = 100, Uint32 MinSpaceForIcons = 16, Uint32 MinRightMargin = 8 ); + TabWidgetStyleConfig getTabWidgetStyleConfig(); - virtual UIProgressBar * createProgressBar( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS, bool DisplayPercent = true, bool VerticalExpand = false, Vector2f MovementSpeed = Vector2f( -64, 0 ), Rectf FillerMargin = Rectf() ); + ProgressBarStyleConfig getProgressBarStyleConfig(); + + virtual UIPopUpMenu * createPopUpMenu(UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE | UI_AUTO_PADDING, Recti PaddingContainer = Recti(), Uint32 MinWidth = 100, Uint32 MinSpaceForIcons = 16, Uint32 MinRightMargin = 8 ); virtual UIWinMenu * createWinMenu( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS, Uint32 MarginBetweenButtons = 0, Uint32 ButtonMargin = 12, Uint32 MenuHeight = 0, Uint32 FirstButtonMargin = 1 ); @@ -19,15 +21,9 @@ class EE_API UIDefaultTheme : public UITheme { virtual UICommonDialog * createCommonDialog( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS_CENTERED, Uint32 WinFlags = UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON, Sizei MinWindowSize = Sizei(0,0), Uint8 BaseAlpha = 255, Uint32 CDLFlags = UI_CDL_DEFAULT_FLAGS, std::string DefaultFilePattern = "*", std::string DefaultDirectory = Sys::getProcessPath() ); - virtual UIComboBox * createComboBox( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_AUTO_SIZE, Uint32 MinNumVisibleItems = 6, bool PopUpToMainControl = false, UIListBox * ListBox = NULL ); - virtual UIDropDownList * createDropDownList( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_AUTO_SIZE, Uint32 MinNumVisibleItems = 6, bool PopUpToMainControl = false, UIListBox * ListBox = NULL ); virtual UIMessageBox * createMessageBox( UI_MSGBOX_TYPE Type = MSGBOX_OKCANCEL, const String& Message = String(), Uint32 WinFlags = UI_WIN_DEFAULT_FLAGS | UI_WIN_MODAL, UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS_CENTERED, Sizei MinWindowSize = Sizei(0,0), Uint8 BaseAlpha = 255 ); - - virtual UITabWidget * createTabWidget( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_HALIGN_CENTER | UI_VALIGN_BOTTOM | UI_CONTROL_DEFAULT_ANCHOR, const bool& TabsClosable = false, const bool& SpecialBorderTabs = false , const Int32& TabSeparation = 0, const Uint32& MaxTextLength = 30, const Uint32& TabWidgetHeight = 0, const Uint32& TabTextAlign = UI_HALIGN_CENTER | UI_VALIGN_CENTER, const Uint32& MinTabWidth = 32, const Uint32& MaxTabWidth = 210 ); - - virtual UITooltip * createTooltip( UIControl * TooltipOf, UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS_CENTERED | UI_AUTO_PADDING | UI_AUTO_SIZE ); }; }} diff --git a/include/eepp/ui/uilistbox.hpp b/include/eepp/ui/uilistbox.hpp index d303f8821..f70bc110b 100644 --- a/include/eepp/ui/uilistbox.hpp +++ b/include/eepp/ui/uilistbox.hpp @@ -19,27 +19,14 @@ class EE_API UIListBox : public UIComplexControl { VScrollMode( UI_SCROLLBAR_AUTO ), HScrollMode( UI_SCROLLBAR_AUTO ), PaddingContainer(), - Font( NULL ), - FontColor( 0, 0, 0, 255 ), - FontOverColor( 0, 0, 0, 255 ), - FontSelectedColor( 0, 0, 0, 255 ), TouchDragDeceleration( 0.01f ) { - UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); - - if ( NULL != Theme ) { - Font = Theme->getFont(); - FontColor = Theme->getFontColor(); - FontOverColor = Theme->getFontOverColor(); - FontSelectedColor = Theme->getFontSelectedColor(); - } - - if ( NULL == Font ) - Font = UIThemeManager::instance()->getDefaultFont(); + fontStyleConfig = UIThemeManager::instance()->getDefaultFontStyleConfig(); } inline ~CreateParams() {} + FontStyleConfig fontStyleConfig; Uint32 RowHeight; bool SmoothScroll; UI_SCROLLBAR_MODE VScrollMode; @@ -47,10 +34,6 @@ class EE_API UIListBox : public UIComplexControl { Recti PaddingContainer; Recti HScrollPadding; Recti VScrollPadding; - Graphics::Font * Font; - ColorA FontColor; - ColorA FontOverColor; - ColorA FontSelectedColor; Float TouchDragDeceleration; }; @@ -168,6 +151,7 @@ class EE_API UIListBox : public UIComplexControl { friend class UIItemContainer; friend class UIDropDownList; + FontStyleConfig mFontStyleConfig; Uint32 mRowHeight; UI_SCROLLBAR_MODE mVScrollMode; UI_SCROLLBAR_MODE mHScrollMode; @@ -178,10 +162,6 @@ class EE_API UIListBox : public UIComplexControl { UIItemContainer * mContainer; UIScrollBar * mVScrollBar; UIScrollBar * mHScrollBar; - Graphics::Font * mFont; - ColorA mFontColor; - ColorA mFontOverColor; - ColorA mFontSelectedColor; Uint32 mLastPos; Uint32 mMaxTextWidth; Int32 mHScrollInit; diff --git a/include/eepp/ui/uimenu.hpp b/include/eepp/ui/uimenu.hpp index 0b722870f..22cd14eec 100644 --- a/include/eepp/ui/uimenu.hpp +++ b/include/eepp/ui/uimenu.hpp @@ -19,24 +19,9 @@ class EE_API UIMenu : public UIComplexControl { PaddingContainer(), MinWidth( 0 ), MinSpaceForIcons( 0 ), - MinRightMargin( 0 ), - Font( NULL ), - FontColor( 0, 0, 0, 255 ), - FontOverColor( 0, 0, 0, 255 ), - FontSelectedColor( 0, 0, 0, 255 ) + MinRightMargin( 0 ) { - UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); - - if ( NULL != Theme ) { - Font = Theme->getFont(); - FontColor = Theme->getFontColor(); - FontShadowColor = Theme->getFontShadowColor(); - FontOverColor = Theme->getFontOverColor(); - FontSelectedColor = Theme->getFontSelectedColor(); - } - - if ( NULL == Font ) - Font = UIThemeManager::instance()->getDefaultFont(); + fontStyleConfig = UIThemeManager::instance()->getDefaultFontStyleConfig(); } inline ~CreateParams() {} @@ -45,11 +30,7 @@ class EE_API UIMenu : public UIComplexControl { Uint32 MinWidth; Uint32 MinSpaceForIcons; Uint32 MinRightMargin; - Graphics::Font * Font; - ColorA FontColor; - ColorA FontShadowColor; - ColorA FontOverColor; - ColorA FontSelectedColor; + FontStyleConfig fontStyleConfig; }; @@ -101,30 +82,14 @@ class EE_API UIMenu : public UIComplexControl { const Recti& getPadding() const; - Font * getFont() const; - - void setFont(Font * font); - - ColorA getFontColor() const; - - void setFontColor(const ColorA & fontColor); - - ColorA getFontShadowColor() const; - - void setFontShadowColor(const ColorA & fontShadowColor); - - ColorA getFontOverColor() const; - - void setFontOverColor(const ColorA & fontOverColor); - - ColorA getFontSelectedColor() const; - - void setFontSelectedColor(const ColorA & fontSelectedColor); - Uint32 getMinRightMargin() const; void setMinRightMargin(const Uint32 & minRightMargin); + FontStyleConfig getFontStyleConfig() const; + + void setFontStyleConfig(const FontStyleConfig & fontStyleConfig); + protected: friend class UIMenuItem; friend class UIMenuCheckBox; @@ -132,11 +97,7 @@ class EE_API UIMenu : public UIComplexControl { std::deque mItems; Recti mPadding; - Font * mFont; - ColorA mFontColor; - ColorA mFontShadowColor; - ColorA mFontOverColor; - ColorA mFontSelectedColor; + FontStyleConfig mFontStyleConfig; Uint32 mMinWidth; Uint32 mMinSpaceForIcons; Uint32 mMinRightMargin; diff --git a/include/eepp/ui/uiprogressbar.hpp b/include/eepp/ui/uiprogressbar.hpp index 7af7263af..6910fc610 100644 --- a/include/eepp/ui/uiprogressbar.hpp +++ b/include/eepp/ui/uiprogressbar.hpp @@ -9,25 +9,7 @@ namespace EE { namespace UI { class EE_API UIProgressBar : public UIComplexControl { public: - class CreateParams : public UITextBox::CreateParams { - public: - inline CreateParams() : - UITextBox::CreateParams(), - DisplayPercent( false ), - VerticalExpand( false ), - MovementSpeed( 64.f, 0.f ) - { - } - - inline ~CreateParams() {} - - bool DisplayPercent; - bool VerticalExpand; - Vector2f MovementSpeed; - Rectf FillerMargin; - }; - - UIProgressBar( const UIProgressBar::CreateParams& Params ); + static UIProgressBar * New(); UIProgressBar(); @@ -66,18 +48,11 @@ class EE_API UIProgressBar : public UIComplexControl { const bool& getDisplayPercent() const; UITextBox * getTextBox() const; - protected: - bool mVerticalExpand; - Vector2f mSpeed; - Rectf mFillerPadding; - bool mDisplayPercent; - + ProgressBarStyleConfig mStyleConfig; Float mProgress; Float mTotalSteps; - ScrollParallax * mParallax; - UITextBox * mTextBox; virtual Uint32 onValueChange(); diff --git a/include/eepp/ui/uipushbutton.hpp b/include/eepp/ui/uipushbutton.hpp index 590ca545d..3a08322d7 100644 --- a/include/eepp/ui/uipushbutton.hpp +++ b/include/eepp/ui/uipushbutton.hpp @@ -13,26 +13,12 @@ class EE_API UIPushButton : public UIComplexControl { public: inline CreateParams() : UITextBox::CreateParams(), - Font( NULL ), - FontColor( 0, 0, 0, 255 ), - FontShadowColor( 0, 0, 0, 255 ), - FontOverColor( 0, 0, 0, 255 ), Icon( NULL ), IconHorizontalMargin( 0 ), IconAutoMargin( true ), IconMinSize( 0, 0 ) { - UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); - - if ( NULL != Theme ) { - Font = Theme->getFont(); - FontColor = Theme->getFontColor(); - FontShadowColor = Theme->getFontShadowColor(); - FontOverColor = Theme->getFontOverColor(); - } - - if ( NULL == Font ) - Font = UIThemeManager::instance()->getDefaultFont(); + fontStyleConfig = UIThemeManager::instance()->getDefaultFontStyleConfig(); } inline ~CreateParams() {} @@ -44,10 +30,7 @@ class EE_API UIPushButton : public UIComplexControl { IconHorizontalMargin = 4; } - Graphics::Font * Font; - ColorA FontColor; - ColorA FontShadowColor; - ColorA FontOverColor; + FontStyleConfig fontStyleConfig; SubTexture * Icon; Int32 IconHorizontalMargin; bool IconAutoMargin; @@ -99,9 +82,12 @@ class EE_API UIPushButton : public UIComplexControl { const ColorA& getFontShadowColor() const; void setFontShadowColor( const ColorA& color ); + + FontStyleConfig getFontStyleConfig() const; + + void setFontStyleConfig(const FontStyleConfig & fontStyleConfig); protected: - ColorA mFontColor; - ColorA mFontOverColor; + FontStyleConfig mFontStyleConfig; UIGfx * mIcon; UITextBox * mTextBox; Int32 mIconSpace; diff --git a/include/eepp/ui/uiselectbutton.hpp b/include/eepp/ui/uiselectbutton.hpp index 6c75fa2f5..bfabd9275 100644 --- a/include/eepp/ui/uiselectbutton.hpp +++ b/include/eepp/ui/uiselectbutton.hpp @@ -23,13 +23,11 @@ class EE_API UISelectButton : public UIPushButton { virtual void select(); - ColorA getFontSelectedColor() const; + void setFontSelectedColor( const ColorA& color ); - void setFontSelectedColor(const ColorA & fontSelectedColor); + const ColorA& getFontSelectedColor() const; protected: virtual void onStateChange(); - - ColorA mFontSelectedColor; }; }} diff --git a/include/eepp/ui/uitab.hpp b/include/eepp/ui/uitab.hpp index 92e68bbf8..3288dcdfa 100644 --- a/include/eepp/ui/uitab.hpp +++ b/include/eepp/ui/uitab.hpp @@ -30,7 +30,6 @@ class EE_API UITab : public UISelectButton { virtual void setText( const String& text ); virtual void update(); - protected: UIControl * mControlOwned; diff --git a/include/eepp/ui/uitabwidget.hpp b/include/eepp/ui/uitabwidget.hpp index 40a6a09f0..fb862b35f 100644 --- a/include/eepp/ui/uitabwidget.hpp +++ b/include/eepp/ui/uitabwidget.hpp @@ -9,63 +9,7 @@ namespace EE { namespace UI { class EE_API UITabWidget : public UIComplexControl { public: - class CreateParams : public UIComplexControl::CreateParams { - public: - inline CreateParams() : - UIComplexControl::CreateParams(), - Font( NULL ), - FontColor( 0, 0, 0, 255 ), - FontOverColor( 0, 0, 0, 255 ), - FontSelectedColor( 0, 0, 0, 255 ), - TabSeparation( 0 ), - MaxTextLength( 30 ), - TabWidgetHeight( 0 ), - TabTextAlign( UI_HALIGN_CENTER | UI_VALIGN_CENTER ), - MinTabWidth( 32 ), - MaxTabWidth( 210 ), - TabsClosable( false ), - SpecialBorderTabs( false ), - DrawLineBelowTabs( false ), - LineBewowTabsYOffset( 0 ) - { - Flags = ( UI_VALIGN_BOTTOM | UI_HALIGN_LEFT | UI_ANCHOR_LEFT | UI_ANCHOR_TOP ); - - UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); - - if ( NULL != Theme ) { - Font = Theme->getFont(); - FontColor = Theme->getFontColor(); - FontShadowColor = Theme->getFontShadowColor(); - FontOverColor = Theme->getFontOverColor(); - FontSelectedColor = Theme->getFontSelectedColor(); - } - - if ( NULL == Font ) - Font = UIThemeManager::instance()->getDefaultFont(); - } - - inline ~CreateParams() {} - - Graphics::Font * Font; - ColorA FontColor; - ColorA FontShadowColor; - ColorA FontOverColor; - ColorA FontSelectedColor; - Int32 TabSeparation; - Uint32 MaxTextLength; - Uint32 TabWidgetHeight; - Uint32 TabTextAlign; - Uint32 MinTabWidth; - Uint32 MaxTabWidth; - bool TabsClosable; - bool SpecialBorderTabs; //! Indicates if the periferical tabs ( the left and right border tab ) are different from the central tabs. - bool DrawLineBelowTabs; - ColorA LineBelowTabsColor; - Int32 LineBewowTabsYOffset; - - }; - - UITabWidget( UITabWidget::CreateParams& Params ); + static UITabWidget * New(); UITabWidget(); @@ -163,30 +107,23 @@ class EE_API UITabWidget : public UIComplexControl { void setLineBelowTabsColor(const ColorA & lineBelowTabsColor); - Int32 getLineBewowTabsYOffset() const; + Int32 getLineBelowTabsYOffset() const; - void setLineBewowTabsYOffset(const Int32 & lineBewowTabsYOffset); + void setLineBelowTabsYOffset(const Int32 & lineBelowTabsYOffset); + + FontStyleConfig getFontStyleConfig() const; + + void setFontStyleConfig(const FontStyleConfig & fontStyleConfig); + + TabWidgetStyleConfig getStyleConfig() const; + + void setStyleConfig(const TabWidgetStyleConfig & styleConfig); protected: friend class UITab; UIComplexControl * mCtrlContainer; UIComplexControl * mTabContainer; - Font * mFont; - ColorA mFontColor; - ColorA mFontShadowColor; - ColorA mFontOverColor; - ColorA mFontSelectedColor; - Int32 mTabSeparation; - Uint32 mMaxTextLength; - Uint32 mTabWidgetHeight; - Uint32 mMinTabWidth; - Uint32 mMaxTabWidth; - bool mTabsClosable; - bool mSpecialBorderTabs; - bool mDrawLineBelowTabs; - ColorA mLineBelowTabsColor; - Int32 mLineBewowTabsYOffset; - + TabWidgetStyleConfig mStyleConfig; std::deque mTabs; UITab * mTabSelected; Uint32 mTabSelectedIndex; diff --git a/include/eepp/ui/uitextbox.hpp b/include/eepp/ui/uitextbox.hpp index 502ed6473..a60d6e540 100644 --- a/include/eepp/ui/uitextbox.hpp +++ b/include/eepp/ui/uitextbox.hpp @@ -10,30 +10,14 @@ class EE_API UITextBox : public UIComplexControl { class CreateParams : public UIComplexControl::CreateParams { public: inline CreateParams() : - UIComplexControl::CreateParams(), - Font( NULL ), - FontColor( 0, 0, 0, 255 ), - FontShadowColor( 255, 255, 255, 150 ), - FontSelectionBackColor( 150, 150, 150, 150 ) + UIComplexControl::CreateParams() { - UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); - - if ( NULL != Theme ) { - Font = Theme->getFont(); - FontColor = Theme->getFontColor(); - FontShadowColor = Theme->getFontShadowColor(); - } - - if ( NULL == Font ) - Font = UIThemeManager::instance()->getDefaultFont(); + fontStyleConfig = UIThemeManager::instance()->getDefaultFontStyleConfig(); } inline ~CreateParams() {} - Graphics::Font * Font; - ColorA FontColor; - ColorA FontShadowColor; - ColorA FontSelectionBackColor; + FontStyleConfig fontStyleConfig; }; UITextBox( const UITextBox::CreateParams& Params ); @@ -89,12 +73,14 @@ class EE_API UITextBox : public UIComplexControl { virtual void shrinkText( const Uint32& MaxWidth ); bool isTextSelectionEnabled() const; + + virtual void setFontStyleConfig( const FontStyleConfig& fontStyleConfig ); + + FontStyleConfig getFontStyleConfig() const; protected: TextCache * mTextCache; String mString; - ColorA mFontColor; - ColorA mFontShadowColor; - ColorA mFontSelectionBackColor; + FontStyleConfig mFontStyleConfig; Vector2i mAlignOffset; Vector2f mRealAlignOffset; Recti mPadding; diff --git a/include/eepp/ui/uitextedit.hpp b/include/eepp/ui/uitextedit.hpp index 2709064b1..eda6d853a 100644 --- a/include/eepp/ui/uitextedit.hpp +++ b/include/eepp/ui/uitextedit.hpp @@ -61,6 +61,9 @@ class EE_API UITextEdit : public UIComplexControl { const UI_SCROLLBAR_MODE& getHorizontalScrollMode(); + FontStyleConfig getFontStyleConfig() const; + + void setFontStyleConfig(const FontStyleConfig & fontStyleConfig); protected: UITextInput * mTextInput; UIScrollBar * mHScrollBar; diff --git a/include/eepp/ui/uitextinputpassword.hpp b/include/eepp/ui/uitextinputpassword.hpp index 80a348634..2db4be722 100644 --- a/include/eepp/ui/uitextinputpassword.hpp +++ b/include/eepp/ui/uitextinputpassword.hpp @@ -19,6 +19,8 @@ class UITextInputPassword : public UITextInput virtual void setText( const String& text ); TextCache * getPassCache() const; + + void setFontStyleConfig( const FontStyleConfig& fontStyleConfig ); protected: TextCache * mPassCache; diff --git a/include/eepp/ui/uitheme.hpp b/include/eepp/ui/uitheme.hpp index f1a35608c..d4d433bc7 100644 --- a/include/eepp/ui/uitheme.hpp +++ b/include/eepp/ui/uitheme.hpp @@ -2,6 +2,7 @@ #define EE_UICUITHEME_HPP #include +#include #include #include #include @@ -74,30 +75,6 @@ class EE_API UITheme : protected ResourceManager { virtual UISkin * add( UISkin * Resource ); - void setFont( Graphics::Font * setFont ); - - Graphics::Font * getFont() const; - - const ColorA& getFontColor() const; - - const ColorA& getFontShadowColor() const; - - const ColorA& getFontOverColor() const; - - const ColorA& getFontSelectedColor() const; - - ColorA getFontSelectionBackColor() const; - - void setFontSelectionBackColor(const ColorA & fontSelectionBackColor); - - void setFontColor( const ColorA& Color ); - - void setFontShadowColor( const ColorA& Color ); - - void setFontOverColor( const ColorA& Color ); - - void setFontSelectedColor( const ColorA& Color ); - void setUseDefaultThemeValues( const bool& Use ); const bool& getUseDefaultThemeValues() const; @@ -122,16 +99,12 @@ class EE_API UITheme : protected ResourceManager { virtual UITextInputPassword * createTextInputPassword( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_TEXT_SELECTION_ENABLED, bool SupportFreeEditing = true, Uint32 MaxLength = 1024*8 ); - virtual UITooltip * createTooltip( UIControl * TooltipOf, UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS_CENTERED | UI_AUTO_PADDING | UI_AUTO_SIZE ); - virtual UIScrollBar * createScrollBar( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE, bool VerticalScrollBar = false ); virtual UISlider * createSlider( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS, bool VerticalSlider = false, bool AllowHalfSliderOut = true, bool ExpandBackground = false ); virtual UISpinBox * createSpinBox( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_SIZE | UI_TEXT_SELECTION_ENABLED, Float DefaultValue = 0.f, bool AllowDotsInNumbers = true ); - virtual UIComboBox * createComboBox( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_TEXT_SELECTION_ENABLED, Uint32 MinNumVisibleItems = 6, bool PopUpToMainControl = false, UIListBox * ListBox = NULL ); - virtual UIDropDownList * createDropDownList( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_PADDING, Uint32 MinNumVisibleItems = 6, bool PopUpToMainControl = false, UIListBox * ListBox = NULL ); virtual UIListBox * createListBox( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_PADDING, bool SmoothScroll = true, Uint32 RowHeight = 0, UI_SCROLLBAR_MODE VScrollMode = UI_SCROLLBAR_AUTO, UI_SCROLLBAR_MODE HScrollMode = UI_SCROLLBAR_AUTO, Recti PaddingContainer = Recti() ); @@ -140,8 +113,6 @@ class EE_API UITheme : protected ResourceManager { virtual UIPopUpMenu * createPopUpMenu(UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE | UI_AUTO_PADDING, Recti PaddingContainer = Recti(), Uint32 MinWidth = 0, Uint32 MinSpaceForIcons = 0, Uint32 MinRightMargin = 0 ); - virtual UIProgressBar * createProgressBar( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS, bool DisplayPercent = false, bool VerticalExpand = false, Vector2f MovementSpeed = Vector2f( 64, 0 ), Rectf FillerMargin = Rectf() ); - virtual UIPushButton * createPushButton( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS_CENTERED | UI_AUTO_SIZE, SubTexture * Icon = NULL, Int32 IconHorizontalMargin = 0, bool IconAutoMargin = true ); virtual UISelectButton * createSelectButton( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS_CENTERED | UI_AUTO_SIZE, SubTexture * Icon = NULL, Int32 IconHorizontalMargin = 0, bool IconAutoMargin = true ); @@ -154,8 +125,6 @@ class EE_API UITheme : protected ResourceManager { virtual UIMessageBox * createMessageBox( UI_MSGBOX_TYPE Type = MSGBOX_OKCANCEL, const String& Message = String(), Uint32 WinFlags = UI_WIN_DEFAULT_FLAGS | UI_WIN_MODAL, UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS_CENTERED, Sizei MinWindowSize = Sizei(0,0), Uint8 BaseAlpha = 255 ); - virtual UITabWidget * createTabWidget( UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_HALIGN_CENTER | UI_VALIGN_BOTTOM | UI_CONTROL_DEFAULT_ANCHOR, const bool& TabsClosable = false, const bool& SpecialBorderTabs = false , const Int32& TabSeparation = 0, const Uint32& MaxTextLength = 30, const Uint32& TabWidgetHeight = 0, const Uint32& TabTextAlign = UI_HALIGN_CENTER | UI_VALIGN_CENTER, const Uint32& MinTabWidth = 32, const Uint32& MaxTabWidth = 210 ); - ColorA getMenuFontColor() const; void setMenuFontColor(const ColorA & menuFontColor); @@ -163,19 +132,37 @@ class EE_API UITheme : protected ResourceManager { ColorA getMenuFontColorOver() const; void setMenuFontColorOver(const ColorA & menuFontColorOver); + + ColorA getTooltipFontColor() const; + + void setTooltipFontColor(const ColorA & tooltipFontColor); + + Recti getTooltipPadding() const; + + void setTooltipPadding(const Recti & tooltipPadding); + + Int32 getTabSeparation() const; + + void setTabSeparation(const Int32 & tabSeparation); + + FontStyleConfig getFontStyleConfig() const; + + void setFontStyleConfig(const FontStyleConfig & fontConfig); + + virtual TabWidgetStyleConfig getTabWidgetStyleConfig(); + + virtual ProgressBarStyleConfig getProgressBarStyleConfig(); protected: std::string mName; Uint32 mNameHash; std::string mAbbr; Graphics::TextureAtlas *mTextureAtlas; - Graphics::Font * mFont; - ColorA mFontColor; - ColorA mFontShadowColor; - ColorA mFontOverColor; - ColorA mFontSelectedColor; - ColorA mFontSelectionBackColor; + FontStyleConfig mFontStyleConfig; ColorA mMenuFontColor; ColorA mMenuFontColorOver; + ColorA mTooltipFontColor; + Recti mTooltipPadding; + Int32 mTabSeparation; bool mUseDefaultThemeValues; std::list mUIElements; std::list mUIIcons; diff --git a/include/eepp/ui/uithemeconfig.hpp b/include/eepp/ui/uithemeconfig.hpp new file mode 100644 index 000000000..5b45eb8b9 --- /dev/null +++ b/include/eepp/ui/uithemeconfig.hpp @@ -0,0 +1,127 @@ +#ifndef EE_UICUITHEMECONFIG_HPP +#define EE_UICUITHEMECONFIG_HPP + +#include + +namespace EE { namespace Graphics { +class Font; +}} + +namespace EE { namespace UI { + +class FontStyleConfig { + public: + Graphics::Font * getFont() const { + return font; + } + + const ColorA& getFontColor() const { + return fontColor; + } + + const ColorA& getFontShadowColor() const { + return fontShadowColor; + } + + const ColorA& getFontOverColor() const { + return fontOverColor; + } + + const ColorA& getFontSelectedColor() const { + return fontSelectedColor; + } + + ColorA getFontSelectionBackColor() const { + return fontSelectionBackColor; + } + + void setFont( Font * font ) { + this->font = font; + } + + void setFontColor( const ColorA& color ) { + fontColor = color; + } + + void setFontShadowColor( const ColorA& color ) { + fontShadowColor = color; + } + + void setFontOverColor( const ColorA& color ) { + fontOverColor = color; + } + + void setFontSelectedColor( const ColorA& color ) { + fontSelectedColor = color; + } + + void setFontSelectionBackColor(const ColorA& color) { + fontSelectionBackColor = color; + } + + FontStyleConfig() {} + + FontStyleConfig( const FontStyleConfig& fontStyleConfig ) : + font( fontStyleConfig.font ), + fontColor( fontStyleConfig.fontColor ), + fontShadowColor( fontStyleConfig.fontShadowColor ), + fontOverColor( fontStyleConfig.fontOverColor ), + fontSelectedColor( fontStyleConfig.fontSelectedColor ), + fontSelectionBackColor( fontStyleConfig.fontSelectionBackColor ) + {} + + void updateFontStyleConfig( const FontStyleConfig& fontStyleConfig ) { + font = ( fontStyleConfig.font ); + fontColor = ( fontStyleConfig.fontColor ); + fontShadowColor = ( fontStyleConfig.fontShadowColor ); + fontOverColor = ( fontStyleConfig.fontOverColor ); + fontSelectedColor = ( fontStyleConfig.fontSelectedColor ); + fontSelectionBackColor = ( fontStyleConfig.fontSelectionBackColor ); + } + + Font * font; + ColorA fontColor; + ColorA fontShadowColor; + ColorA fontOverColor; + ColorA fontSelectedColor; + ColorA fontSelectionBackColor; +}; + +class TabWidgetStyleConfig : public FontStyleConfig { + public: + TabWidgetStyleConfig() {} + + TabWidgetStyleConfig( FontStyleConfig fontStyleConfig ) : + FontStyleConfig( fontStyleConfig ) + {} + + Int32 tabSeparation; + Uint32 maxTextLength; + Uint32 tabWidgetHeight; + Uint32 tabTextAlign; + Uint32 minTabWidth; + Uint32 maxTabWidth; + bool tabsClosable; + bool specialBorderTabs; //! Indicates if the periferical tabs ( the left and right border tab ) are different from the central tabs. + bool drawLineBelowTabs; + ColorA lineBelowTabsColor; + Int32 lineBelowTabsYOffset; +}; + +class ProgressBarStyleConfig : public FontStyleConfig { + public: + ProgressBarStyleConfig() {} + + ProgressBarStyleConfig( FontStyleConfig fontStyleConfig ) : + FontStyleConfig( fontStyleConfig ) + {} + + bool displayPercent = false; + bool verticalExpand = true; + Vector2f movementSpeed = Vector2f( 64.f, 0 ); + Rectf fillerPadding; +}; + +}} + +#endif diff --git a/include/eepp/ui/uithememanager.hpp b/include/eepp/ui/uithememanager.hpp index 0fe0789ff..673c029e2 100644 --- a/include/eepp/ui/uithememanager.hpp +++ b/include/eepp/ui/uithememanager.hpp @@ -57,6 +57,8 @@ class EE_API UIThemeManager : public ResourceManager { void setCursorSize( const Sizei& Size ); const Sizei& getCursorSize() const; + + FontStyleConfig getDefaultFontStyleConfig(); protected: Font * mFont; UITheme * mThemeDefault; @@ -66,10 +68,10 @@ class EE_API UIThemeManager : public ResourceManager { Time mFadeInTime; Time mFadeOutTime; - Time mtooltipTimeToShow; - bool mtooltipFollowMouse; + Time mTooltipTimeToShow; + bool mTooltipFollowMouse; - Sizei mcursorSize; + Sizei mCursorSize; UIThemeManager(); }; diff --git a/include/eepp/ui/uitooltip.hpp b/include/eepp/ui/uitooltip.hpp index 738058f51..ce631f24f 100644 --- a/include/eepp/ui/uitooltip.hpp +++ b/include/eepp/ui/uitooltip.hpp @@ -11,35 +11,7 @@ namespace EE { namespace UI { class EE_API UITooltip : public UIControlAnim { public: - class CreateParams : public UIControlAnim::CreateParams { - public: - inline CreateParams() : - UIControlAnim::CreateParams(), - Font( NULL ), - FontColor( 0, 0, 0, 255 ), - FontShadowColor( 255, 255, 255, 150 ) - { - UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); - - if ( NULL != Theme ) { - Font = Theme->getFont(); - FontColor = Theme->getFontColor(); - FontShadowColor = Theme->getFontShadowColor(); - } - - if ( NULL == Font ) - Font = UIThemeManager::instance()->getDefaultFont(); - } - - inline ~CreateParams() {} - - Graphics::Font * Font; - ColorA FontColor; - ColorA FontShadowColor; - Recti Padding; - }; - - UITooltip( UITooltip::CreateParams& Params, UIControl * TooltipOf ); + UITooltip(); virtual ~UITooltip(); @@ -65,13 +37,13 @@ class EE_API UITooltip : public UIControlAnim { virtual void setText( const String& text ); - const ColorA& getColor() const; + const ColorA& getFontColor() const; - void setColor( const ColorA& color ); + void setFontColor( const ColorA& color ); - const ColorA& getShadowColor() const; + const ColorA& getFontShadowColor() const; - void setShadowColor( const ColorA& color ); + void setFontShadowColor( const ColorA& color ); virtual void onTextChanged(); @@ -96,10 +68,17 @@ class EE_API UITooltip : public UIControlAnim { void addTooltipTime( const Time & Time ); const Time & getTooltipTime() const; + + UIControl * getTooltipOf() const; + + void setTooltipOf(UIControl * tooltipOf); + + FontStyleConfig getFontStyleConfig() const; + + void setFontStyleConfig(const FontStyleConfig & fontStyleConfig); protected: TextCache * mTextCache; - ColorA mFontColor; - ColorA mFontShadowColor; + FontStyleConfig mFontStyleConfig; Vector2f mAlignOffset; Recti mPadding; Recti mRealPadding; diff --git a/include/eepp/ui/uiwinmenu.hpp b/include/eepp/ui/uiwinmenu.hpp index 64392178d..175ba6dda 100644 --- a/include/eepp/ui/uiwinmenu.hpp +++ b/include/eepp/ui/uiwinmenu.hpp @@ -14,39 +14,19 @@ class EE_API UIWinMenu : public UIComplexControl { public: inline CreateParams() : UIComplexControl::CreateParams(), - Font( NULL ), - FontColor( 0, 0, 0, 255 ), - FontShadowColor( 0, 0, 0, 255 ), - FontOverColor( 0, 0, 0, 255 ), - FontSelectedColor( 0, 0, 0, 255 ), - MarginBetweenButtons(0), - ButtonMargin(4), - MenuHeight(0), - FirstButtonMargin(1) + marginBetweenButtons(0), + buttonMargin(4), + menuHeight(0), + firstButtonMargin(1) { - UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); - - if ( NULL != Theme ) { - Font = Theme->getFont(); - FontColor = Theme->getFontColor(); - FontShadowColor = Theme->getFontShadowColor(); - FontOverColor = Theme->getFontOverColor(); - FontSelectedColor = Theme->getFontSelectedColor(); - } - - if ( NULL == Font ) - Font = UIThemeManager::instance()->getDefaultFont(); + fontStyleConfig = UIThemeManager::instance()->getDefaultFontStyleConfig(); } - Graphics::Font * Font; - ColorA FontColor; - ColorA FontShadowColor; - ColorA FontOverColor; - ColorA FontSelectedColor; - Uint32 MarginBetweenButtons; - Uint32 ButtonMargin; - Uint32 MenuHeight; - Uint32 FirstButtonMargin; + FontStyleConfig fontStyleConfig; + Uint32 marginBetweenButtons; + Uint32 buttonMargin; + Uint32 menuHeight; + Uint32 firstButtonMargin; }; UIWinMenu( const UIWinMenu::CreateParams& Params ); @@ -65,42 +45,21 @@ class EE_API UIWinMenu : public UIComplexControl { virtual void setTheme( UITheme * Theme ); - void setFontColor( const ColorA& Color ); - - const ColorA& getFontColor() const; - - void setFontOverColor( const ColorA& Color ); - - const ColorA& getFontOverColor() const; - - void setFontSelectedColor( const ColorA& Color ); - - const ColorA& getFontSelectedColor() const; - - void setFont(Graphics::Font * font); - - Graphics::Font * getFont() const; - UISelectButton * getButton( const String& ButtonText ); UIPopUpMenu * getPopUpMenu( const String& ButtonText ); - ColorA getFontShadowColor() const; - - void setFontShadowColor(const ColorA & fontShadowColor); - Uint32 getMarginBetweenButtons() const; void setMarginBetweenButtons(const Uint32 & marginBetweenButtons); + FontStyleConfig getFontStyleConfig() const; + + void setFontStyleConfig(const FontStyleConfig & fontStyleConfig); protected: typedef std::list< std::pair< UISelectButton *, UIPopUpMenu * > > WinMenuList; - Graphics::Font *mFont; - ColorA mFontColor; - ColorA mFontShadowColor; - ColorA mFontOverColor; - ColorA mFontSelectedColor; + FontStyleConfig mFontStyleConfig; UIPopUpMenu * mCurrentMenu; Uint32 mMarginBetweenButtons; Uint32 mButtonMargin; diff --git a/projects/linux/ee.files b/projects/linux/ee.files index 93d2745ea..ce8aac9e9 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -1,4 +1,5 @@ ../../include/eepp/graphics/font.hpp +../../include/eepp/ui/uithemeconfig.hpp ../../src/eepp/gaming/mapobjectlayer.cpp ../../src/eepp/graphics/globalbatchrenderer.cpp ../../src/eepp/graphics/pixeldensity.cpp diff --git a/projects/linux/ee.includes b/projects/linux/ee.includes index a9e2103fa..b77e93fb5 100644 --- a/projects/linux/ee.includes +++ b/projects/linux/ee.includes @@ -5,3 +5,4 @@ . ../../include/eepp/graphics ../../src/eepp/graphics +../../include/eepp/ui diff --git a/src/eepp/gaming/mapeditor/mapeditor.cpp b/src/eepp/gaming/mapeditor/mapeditor.cpp index 98b8c560a..68aaccff4 100644 --- a/src/eepp/gaming/mapeditor/mapeditor.cpp +++ b/src/eepp/gaming/mapeditor/mapeditor.cpp @@ -187,8 +187,15 @@ void MapEditor::CreateETGMenu() { mObjectCont = eeNew( UIComplexControl, ( CParams ) ); - mTabWidget = mTheme->createTabWidget( mWinContainer, Sizei( Width + DistToBorder, mWinContainer->getSize().getHeight() - DistFromTopMenu ), Vector2i( ContPosX, DistFromTopMenu ), UI_HALIGN_CENTER | UI_VALIGN_BOTTOM | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP | UI_ANCHOR_BOTTOM ); + mTabWidget = UITabWidget::New(); + + mTabWidget->setParent( mWinContainer )-> + setSize( Width + DistToBorder, mWinContainer->getSize().getHeight() - DistFromTopMenu )-> + setPosition( ContPosX, DistFromTopMenu )->resetFlags()-> + setFlags( UI_HALIGN_CENTER | UI_VALIGN_BOTTOM | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP | UI_ANCHOR_BOTTOM ); + mTabWidget->addEventListener( UIEvent::EventOnTabSelected, cb::Make1( this, &MapEditor::OnTabSelected ) ); + CreateTabs(); CreateLighContainer(); diff --git a/src/eepp/ui/uicombobox.cpp b/src/eepp/ui/uicombobox.cpp index 9d8d652c7..54909de7c 100644 --- a/src/eepp/ui/uicombobox.cpp +++ b/src/eepp/ui/uicombobox.cpp @@ -3,12 +3,8 @@ namespace EE { namespace UI { -UIComboBox::UIComboBox( UIComboBox::CreateParams& Params ) : - UIComplexControl( Params ), - mDropDownList( NULL ), - mButton( NULL ) -{ - applyDefaultTheme(); +UIComboBox *UIComboBox::New() { + return eeNew( UIComboBox, () ); } UIComboBox::UIComboBox() : @@ -78,7 +74,7 @@ const String& UIComboBox::getText() { } void UIComboBox::updateControls() { - if ( ( mFlags & UI_AUTO_SIZE ) || 0 == mSize.getHeight() ) { + if ( ( mFlags & UI_AUTO_SIZE ) || mSize.getHeight() < mDropDownList->getSkin()->getSize().getHeight() ) { setInternalHeight( mDropDownList->getSkin()->getSize().getHeight() ); } @@ -110,8 +106,4 @@ void UIComboBox::onPositionChange() { updateControls(); } -void UIComboBox::onParentChange() { - //mButton->centerVertical(); -} - }} diff --git a/src/eepp/ui/uicommondialog.cpp b/src/eepp/ui/uicommondialog.cpp index 1ca363277..fb8e652ad 100644 --- a/src/eepp/ui/uicommondialog.cpp +++ b/src/eepp/ui/uicommondialog.cpp @@ -100,13 +100,7 @@ UICommonDialog::UICommonDialog( const UICommonDialog::CreateParams& Params ) : ); LBParams.Flags = UI_AUTO_PADDING | UI_ANCHOR_RIGHT | UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_BOTTOM | UI_CLIP_ENABLE; - LBParams.FontSelectedColor = ColorA( 255, 255, 255, 255 ); - - if ( NULL != UIThemeManager::instance()->getDefaultTheme() ) { - UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); - - LBParams.FontSelectedColor = Theme->getFontSelectedColor(); - } + LBParams.fontStyleConfig.fontSelectedColor = ColorA( 255, 255, 255, 255 ); mList = eeNew( UIListBox, ( LBParams ) ); mList->setVisible( true ); diff --git a/src/eepp/ui/uicomplexcontrol.cpp b/src/eepp/ui/uicomplexcontrol.cpp index 60c05c29a..4aac0faed 100644 --- a/src/eepp/ui/uicomplexcontrol.cpp +++ b/src/eepp/ui/uicomplexcontrol.cpp @@ -97,18 +97,9 @@ void UIComplexControl::createTooltip() { if ( NULL != mTooltip ) return; - UITheme * tTheme = UIThemeManager::instance()->getDefaultTheme(); - - if ( NULL != tTheme ) { - mTooltip = tTheme->createTooltip( this, UIManager::instance()->getMainControl() ); - mTooltip->setVisible( false ); - mTooltip->setEnabled( false ); - } else { - UITooltip::CreateParams Params; - Params.setParent( UIManager::instance()->getMainControl() ); - Params.Flags = UI_VALIGN_CENTER | UI_HALIGN_CENTER | UI_AUTO_PADDING | UI_AUTO_SIZE; - mTooltip = eeNew( UITooltip, ( Params, this ) ); - } + mTooltip = eeNew( UITooltip, () ); + mTooltip->setVisible( false )->setEnabled( false ); + mTooltip->setTooltipOf( this ); } void UIComplexControl::setTooltipText( const String& Text ) { @@ -146,6 +137,22 @@ UIControl * UIComplexControl::setSize( const Sizei& size ) { return UIControlAnim::setSize( s ); } +UIControl * UIComplexControl::setFlags(const Uint32 & flags) { + if ( flags & ( UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ) ) { + updateAnchorsDistances(); + } + + return UIControlAnim::setFlags( flags ); +} + +UIControl * UIComplexControl::unsetFlags(const Uint32 & flags) { + if ( flags & ( UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ) ) { + updateAnchorsDistances(); + } + + return UIControlAnim::unsetFlags( flags ); +} + UIControl * UIComplexControl::setSize( const Int32& Width, const Int32& Height ) { return UIControlAnim::setSize( Width, Height ); } diff --git a/src/eepp/ui/uicontrol.cpp b/src/eepp/ui/uicontrol.cpp index 8fd7a8634..733c953f6 100644 --- a/src/eepp/ui/uicontrol.cpp +++ b/src/eepp/ui/uicontrol.cpp @@ -636,6 +636,11 @@ UIControl * UIControl::unsetFlags(const Uint32 & flags) { return this; } +UIControl *UIControl::resetFlags() { + mFlags = 0; + return this; +} + void UIControl::setBlendMode( const EE_BLEND_MODE& blend ) { mBlend = static_cast ( blend ); } diff --git a/src/eepp/ui/uidefaulttheme.cpp b/src/eepp/ui/uidefaulttheme.cpp index f71266cc8..ca3f13bf2 100644 --- a/src/eepp/ui/uidefaulttheme.cpp +++ b/src/eepp/ui/uidefaulttheme.cpp @@ -12,13 +12,35 @@ namespace EE { namespace UI { UIDefaultTheme::UIDefaultTheme( const std::string& name, const std::string& Abbr, Graphics::Font * defaultFont ) : UITheme( name, Abbr, defaultFont ) { - setFontColor( ColorA( 230, 230, 230, 255 ) ); - setFontOverColor( ColorA( 255, 255, 255, 255 ) ); - setFontSelectedColor( ColorA( 255, 255, 255, 255 ) ); - setFontShadowColor( ColorA( 50, 50, 50, 150 ) ); - setFontSelectionBackColor( ColorA( 150, 150, 150, 255 ) ); + mFontStyleConfig.fontColor = ColorA( 230, 230, 230, 255 ); + mFontStyleConfig.fontOverColor = mFontStyleConfig.fontSelectedColor = ColorA( 255, 255, 255, 255 ); + mFontStyleConfig.fontShadowColor = ColorA( 50, 50, 50, 150 ); + mFontStyleConfig.fontSelectionBackColor = ColorA( 150, 150, 150, 255 ); + setMenuFontColor( ColorA( 230, 230, 230, 255 ) ); setMenuFontColorOver( ColorA( 255, 255, 255, 255 ) ); + setTooltipFontColor( ColorA( 0, 0, 0, 255 ) ); + setTooltipPadding( Recti( 4, 6, 4, 6) ); + setTabSeparation( -1 ); +} + +TabWidgetStyleConfig UIDefaultTheme::getTabWidgetStyleConfig() { + TabWidgetStyleConfig tabWidgetStyleConfig = UITheme::getTabWidgetStyleConfig(); + tabWidgetStyleConfig.tabSeparation = -1; + tabWidgetStyleConfig.fontSelectedColor = ColorA( 255, 255, 255, 255 ); + tabWidgetStyleConfig.drawLineBelowTabs = true; + tabWidgetStyleConfig.lineBelowTabsColor = ColorA( 0, 0, 0, 255 ); + tabWidgetStyleConfig.lineBelowTabsYOffset = -1; + return tabWidgetStyleConfig; +} + +ProgressBarStyleConfig UIDefaultTheme::getProgressBarStyleConfig() { + ProgressBarStyleConfig progressBarStyleConfig = UITheme::getProgressBarStyleConfig(); + progressBarStyleConfig.displayPercent = true; + progressBarStyleConfig.verticalExpand = true; + progressBarStyleConfig.fillerPadding = Rectf( 2, 2, 2, 2 ); + progressBarStyleConfig.movementSpeed = Vector2f( 32, 0 ); + return progressBarStyleConfig; } UIPopUpMenu * UIDefaultTheme::createPopUpMenu( UIControl * Parent, const Sizei& Size, const Vector2i& Pos, const Uint32& Flags, Recti PaddingContainer, Uint32 MinWidth, Uint32 MinSpaceForIcons, Uint32 MinRightMargin ) { @@ -36,50 +58,25 @@ UIPopUpMenu * UIDefaultTheme::createPopUpMenu( UIControl * Parent, const Sizei& MenuParams.MinWidth = 100; MenuParams.MinSpaceForIcons = 24; MenuParams.MinRightMargin = 8; - MenuParams.FontColor = ColorA( 230, 230, 230, 255 ); + MenuParams.fontStyleConfig.fontColor = ColorA( 230, 230, 230, 255 ); } return eeNew( UIPopUpMenu, ( MenuParams ) ); } -UIProgressBar * UIDefaultTheme::createProgressBar( UIControl * Parent, const Sizei& Size, const Vector2i& Pos, const Uint32& Flags, bool DisplayPercent, bool VerticalExpand, Vector2f MovementSpeed, Rectf FillerMargin ) { - UIProgressBar::CreateParams PBParams; - PBParams.setParent( Parent ); - PBParams.setPosition( Pos ); - PBParams.setSize( Size ); - PBParams.Flags = Flags; - PBParams.DisplayPercent = DisplayPercent; - PBParams.VerticalExpand = VerticalExpand; - PBParams.MovementSpeed = MovementSpeed; - PBParams.FillerMargin = FillerMargin; - - if ( getUseDefaultThemeValues() ) { - PBParams.Flags |= UI_AUTO_SIZE; - PBParams.DisplayPercent = true; - PBParams.VerticalExpand = true; - PBParams.FillerMargin = Rectf( 2, 2, 2, 2 ); - PBParams.MovementSpeed = Vector2f( 32, 0 ); - } - - UIProgressBar * Ctrl = eeNew( UIProgressBar, ( PBParams ) ); - Ctrl->setVisible( true ); - Ctrl->setEnabled( true ); - return Ctrl; -} - UIWinMenu * UIDefaultTheme::createWinMenu( UIControl * Parent, const Sizei& Size, const Vector2i& Pos, const Uint32& Flags, Uint32 MarginBetweenButtons, Uint32 ButtonMargin, Uint32 MenuHeight, Uint32 FirstButtonMargin ) { UIWinMenu::CreateParams WinMenuParams; WinMenuParams.setParent( Parent ); WinMenuParams.setPosition( Pos ); WinMenuParams.setSize( Size ); WinMenuParams.Flags = Flags; - WinMenuParams.MarginBetweenButtons = MarginBetweenButtons; - WinMenuParams.ButtonMargin = ButtonMargin; - WinMenuParams.MenuHeight = MenuHeight; - WinMenuParams.FirstButtonMargin = FirstButtonMargin; + WinMenuParams.marginBetweenButtons = MarginBetweenButtons; + WinMenuParams.buttonMargin = ButtonMargin; + WinMenuParams.menuHeight = MenuHeight; + WinMenuParams.firstButtonMargin = FirstButtonMargin; if ( getUseDefaultThemeValues() ) { - WinMenuParams.ButtonMargin = 12; + WinMenuParams.buttonMargin = 12; } UIWinMenu * Ctrl = eeNew( UIWinMenu, ( WinMenuParams ) ); @@ -153,23 +150,6 @@ UIMessageBox * UIDefaultTheme::createMessageBox( UI_MSGBOX_TYPE Type, const Stri return eeNew( UIMessageBox, ( MsgBoxParams ) ); } -UIComboBox * UIDefaultTheme::createComboBox( UIControl * Parent, const Sizei& Size, const Vector2i& Pos, const Uint32& Flags, Uint32 MinNumVisibleItems, bool PopUpToMainControl, UIListBox * ListBox ) { - UIComboBox::CreateParams ComboParams; - ComboParams.setParent( Parent ); - ComboParams.setPosition( Pos ); - ComboParams.setSize( Size ); - ComboParams.Flags = Flags; - - if ( getUseDefaultThemeValues() ) { - ComboParams.Flags |= UI_AUTO_SIZE | UI_TEXT_SELECTION_ENABLED; - } - - UIComboBox * Ctrl = eeNew( UIComboBox, ( ComboParams ) ); - Ctrl->setVisible( true ); - Ctrl->setEnabled( true ); - return Ctrl; -} - UIDropDownList * UIDefaultTheme::createDropDownList( UIControl * Parent, const Sizei& Size, const Vector2i& Pos, const Uint32& Flags, Uint32 MinNumVisibleItems, bool PopUpToMainControl, UIListBox * ListBox ) { UIDropDownList::CreateParams DDLParams; DDLParams.setParent( Parent ); @@ -190,52 +170,4 @@ UIDropDownList * UIDefaultTheme::createDropDownList( UIControl * Parent, const S return Ctrl; } -UITabWidget * UIDefaultTheme::createTabWidget( UIControl *Parent, const Sizei &Size, const Vector2i &Pos, const Uint32 &Flags, const bool &TabsClosable, const bool &SpecialBorderTabs, const Int32 &TabSeparation, const Uint32 &MaxTextLength, const Uint32 &TabWidgetHeight, const Uint32 &TabTextAlign, const Uint32 &MinTabWidth, const Uint32 &MaxTabWidth ) { - UITabWidget::CreateParams TabWidgetParams; - TabWidgetParams.setParent( Parent ); - TabWidgetParams.setPosition( Pos ); - TabWidgetParams.setSize( Size ); - TabWidgetParams.Flags = Flags; - TabWidgetParams.TabsClosable = TabsClosable; - TabWidgetParams.SpecialBorderTabs = SpecialBorderTabs; - TabWidgetParams.TabSeparation = TabSeparation; - TabWidgetParams.MaxTextLength = MaxTextLength; - TabWidgetParams.TabWidgetHeight = TabWidgetHeight; - TabWidgetParams.TabTextAlign = TabTextAlign; - TabWidgetParams.MinTabWidth = MinTabWidth; - TabWidgetParams.MaxTabWidth = MaxTabWidth; - - if ( getUseDefaultThemeValues() ) { - TabWidgetParams.TabSeparation = -1; - TabWidgetParams.FontSelectedColor = ColorA( 255, 255, 255, 255 ); - TabWidgetParams.DrawLineBelowTabs = true; - TabWidgetParams.LineBelowTabsColor = ColorA( 0, 0, 0, 255 ); - TabWidgetParams.LineBewowTabsYOffset = -1; - } - - UITabWidget * Ctrl = eeNew( UITabWidget, ( TabWidgetParams ) ); - Ctrl->setVisible( true ); - Ctrl->setEnabled( true ); - return Ctrl; -} - -UITooltip * UIDefaultTheme::createTooltip( UIControl * TooltipOf, UIControl * Parent, const Sizei& Size, const Vector2i& Pos, const Uint32& Flags ) { - UITooltip::CreateParams TooltipParams; - TooltipParams.setParent( Parent ); - TooltipParams.setPosition( Pos ); - TooltipParams.setSize( Size ); - TooltipParams.Flags = Flags; - - if ( getUseDefaultThemeValues() ) { - TooltipParams.Flags &= ~UI_AUTO_PADDING; - TooltipParams.FontColor = ColorA( 0, 0, 0, 255 ); - TooltipParams.Padding = Recti( 4, 6, 4, 6 ); - } - - UITooltip * Ctrl = eeNew( UITooltip, ( TooltipParams, TooltipOf ) ); - Ctrl->setVisible( true ); - Ctrl->setEnabled( true ); - return Ctrl; -} - }} diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index e8abe76ce..666ed6641 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -31,7 +31,7 @@ UIDropDownList::UIDropDownList( UIDropDownList::CreateParams& Params ) : UIListBox::CreateParams LBParams; LBParams.Size = Sizei( mSize.getWidth(), mMinNumVisibleItems * mSize.getHeight() ); LBParams.Flags = flags; - LBParams.FontSelectedColor = ColorA( 255, 255, 255, 255 ); + LBParams.fontStyleConfig.fontSelectedColor = ColorA( 255, 255, 255, 255 ); mListBox = eeNew( UIListBox, ( LBParams ) ); } } diff --git a/src/eepp/ui/uilistbox.cpp b/src/eepp/ui/uilistbox.cpp index a2c434227..af00d9a3f 100644 --- a/src/eepp/ui/uilistbox.cpp +++ b/src/eepp/ui/uilistbox.cpp @@ -8,6 +8,7 @@ namespace EE { namespace UI { UIListBox::UIListBox( UIListBox::CreateParams& Params ) : UIComplexControl( Params ), + mFontStyleConfig( Params.fontStyleConfig ), mRowHeight( Params.RowHeight ), mVScrollMode( Params.VScrollMode ), mHScrollMode( Params.HScrollMode ), @@ -18,10 +19,6 @@ UIListBox::UIListBox( UIListBox::CreateParams& Params ) : mContainer( NULL ), mVScrollBar( NULL ), mHScrollBar( NULL ), - mFont( Params.Font ), - mFontColor( Params.FontColor ), - mFontOverColor( Params.FontOverColor ), - mFontSelectedColor( Params.FontSelectedColor ), mLastPos( eeINDEX_NOT_FOUND ), mMaxTextWidth(0), mHScrollInit(0), @@ -32,9 +29,6 @@ UIListBox::UIListBox( UIListBox::CreateParams& Params ) : mTouchDragAcceleration(0), mTouchDragDeceleration( Params.TouchDragDeceleration ) { - if ( NULL == Params.Font && NULL != UIThemeManager::instance()->getDefaultFont() ) - mFont = UIThemeManager::instance()->getDefaultFont(); - UIControl::CreateParams CParams; CParams.setParent( this ); CParams.setPosition( mPaddingContainer.Left, mPaddingContainer.Top ); @@ -96,17 +90,7 @@ UIListBox::UIListBox() : { setFlags( UI_CLIP_ENABLE | UI_AUTO_PADDING ); - UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); - - if ( NULL != Theme ) { - mFont = Theme->getFont(); - mFontColor = Theme->getFontColor(); - mFontOverColor = Theme->getFontOverColor(); - mFontSelectedColor = Theme->getFontSelectedColor(); - } - - if ( NULL == mFont && NULL != UIThemeManager::instance()->getDefaultFont() ) - mFont = UIThemeManager::instance()->getDefaultFont(); + mFontStyleConfig = UIThemeManager::instance()->getDefaultFontStyleConfig(); mContainer = eeNew( UIItemContainer, () ); mContainer->setParent( this ); @@ -152,9 +136,6 @@ bool UIListBox::isType( const Uint32& type ) const { void UIListBox::setTheme( UITheme * Theme ) { UIControl::setThemeControl( Theme, "listbox" ); - if ( NULL == mFont && NULL != mSkinState && NULL != mSkinState->getSkin() && NULL != mSkinState->getSkin()->getTheme() && NULL != mSkinState->getSkin()->getTheme()->getFont() ) - mFont = mSkinState->getSkin()->getTheme()->getFont(); - autoPadding(); onSizeChange(); @@ -212,8 +193,8 @@ Uint32 UIListBox::addListBoxItem( const String& Text ) { mTexts.push_back( Text ); mItems.push_back( NULL ); - if ( NULL != mFont ) { - Uint32 twidth = mFont->getTextWidth( Text ); + if ( NULL != mFontStyleConfig.font ) { + Uint32 twidth = mFontStyleConfig.font->getTextWidth( Text ); if ( twidth > mMaxTextWidth ) { mMaxTextWidth = twidth; @@ -232,10 +213,9 @@ Uint32 UIListBox::addListBoxItem( const String& Text ) { UIListBoxItem * UIListBox::createListBoxItem( const String& Name ) { UITextBox::CreateParams TextParams; TextParams.setParent( mContainer ); - TextParams.Flags = UI_VALIGN_CENTER | UI_HALIGN_LEFT; - TextParams.Font = mFont; - TextParams.FontColor = mFontColor; - UIListBoxItem * tItem = eeNew( UIListBoxItem, ( TextParams ) ); + TextParams.Flags = UI_VALIGN_CENTER | UI_HALIGN_LEFT; + TextParams.fontStyleConfig = mFontStyleConfig; + UIListBoxItem * tItem = eeNew( UIListBoxItem, ( TextParams ) ); tItem->setText( Name ); return tItem; @@ -370,11 +350,11 @@ void UIListBox::setRowHeight() { if ( NULL != UIThemeManager::instance()->getDefaultFont() ) FontSize = UIThemeManager::instance()->getDefaultFont()->getFontHeight(); - if ( NULL != mSkinState && NULL != mSkinState->getSkin() && NULL != mSkinState->getSkin()->getTheme() && NULL != mSkinState->getSkin()->getTheme()->getFont() ) - FontSize = mSkinState->getSkin()->getTheme()->getFont()->getFontHeight(); + if ( NULL != mSkinState && NULL != mSkinState->getSkin() && NULL != mSkinState->getSkin()->getTheme() && NULL != mSkinState->getSkin()->getTheme()->getFontStyleConfig().getFont() ) + FontSize = mSkinState->getSkin()->getTheme()->getFontStyleConfig().getFont()->getFontHeight(); - if ( NULL != mFont ) - FontSize = mFont->getFontHeight(); + if ( NULL != mFontStyleConfig.getFont() ) + FontSize = mFontStyleConfig.getFont()->getFontHeight(); mRowHeight = (Uint32)PixelDensity::pxToDpI( FontSize + 4 ); } @@ -408,7 +388,7 @@ void UIListBox::findMaxWidth() { if ( NULL != mItems[i] ) width = (Int32)mItems[i]->getTextWidth(); else - width = mFont->getTextWidth( mTexts[i] ); + width = mFontStyleConfig.font->getTextWidth( mTexts[i] ); if ( width > (Int32)mMaxTextWidth ) mMaxTextWidth = width; @@ -749,37 +729,37 @@ Uint32 UIListBox::getItemIndex( const String& Text ) { } void UIListBox::setFontColor( const ColorA& Color ) { - mFontColor = Color; + mFontStyleConfig.fontColor = Color; for ( Uint32 i = 0; i < mItems.size(); i++ ) - mItems[i]->setFontColor( mFontColor ); + mItems[i]->setFontColor( mFontStyleConfig.fontColor ); } const ColorA& UIListBox::getFontColor() const { - return mFontColor; + return mFontStyleConfig.fontColor; } void UIListBox::setFontOverColor( const ColorA& Color ) { - mFontOverColor = Color; + mFontStyleConfig.fontOverColor = Color; } const ColorA& UIListBox::getFontOverColor() const { - return mFontOverColor; + return mFontStyleConfig.fontOverColor; } void UIListBox::setFontSelectedColor( const ColorA& Color ) { - mFontSelectedColor = Color; + mFontStyleConfig.fontSelectedColor = Color; } const ColorA& UIListBox::getFontSelectedColor() const { - return mFontSelectedColor; + return mFontStyleConfig.fontSelectedColor; } void UIListBox::setFont( Graphics::Font * Font ) { - mFont = Font; + mFontStyleConfig.font = Font; for ( Uint32 i = 0; i < mItems.size(); i++ ) - mItems[i]->setFont( mFont ); + mItems[i]->setFont( mFontStyleConfig.font ); findMaxWidth(); updateListBoxItemsSize(); @@ -787,7 +767,7 @@ void UIListBox::setFont( Graphics::Font * Font ) { } Graphics::Font * UIListBox::getFont() const { - return mFont; + return mFontStyleConfig.font; } void UIListBox::setContainerPadding( const Recti& Padding ) { diff --git a/src/eepp/ui/uimenu.cpp b/src/eepp/ui/uimenu.cpp index a222f4aec..e1a17211f 100644 --- a/src/eepp/ui/uimenu.cpp +++ b/src/eepp/ui/uimenu.cpp @@ -7,11 +7,7 @@ namespace EE { namespace UI { UIMenu::UIMenu( UIMenu::CreateParams& Params ) : UIComplexControl( Params ), mPadding( Params.PaddingContainer ), - mFont( Params.Font ), - mFontColor( Params.FontColor ), - mFontShadowColor( Params.FontShadowColor ), - mFontOverColor( Params.FontOverColor ), - mFontSelectedColor( Params.FontSelectedColor ), + mFontStyleConfig( Params.fontStyleConfig ), mMinWidth( Params.MinWidth ), mMinSpaceForIcons( Params.MinSpaceForIcons ), mMinRightMargin( Params.MinRightMargin ), @@ -31,11 +27,6 @@ UIMenu::UIMenu( UIMenu::CreateParams& Params ) : UIMenu::UIMenu() : UIComplexControl(), mPadding(), - mFont( NULL ), - mFontColor(), - mFontShadowColor(), - mFontOverColor(), - mFontSelectedColor(), mMinWidth( 100 ), mMinSpaceForIcons( 24 ), mMinRightMargin( 8 ), @@ -49,19 +40,15 @@ UIMenu::UIMenu() : { setFlags( UI_AUTO_SIZE ); + mFontStyleConfig = UIThemeManager::instance()->getDefaultFontStyleConfig(); + UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); if ( NULL != Theme ) { - mFont = Theme->getFont(); - mFontColor = Theme->getMenuFontColor(); - mFontShadowColor = Theme->getFontShadowColor(); - mFontOverColor = Theme->getMenuFontColorOver(); - mFontSelectedColor = Theme->getFontSelectedColor(); + mFontStyleConfig.fontColor = Theme->getMenuFontColor(); + mFontStyleConfig.fontOverColor = Theme->getMenuFontColorOver(); } - if ( NULL == mFont ) - mFont = UIThemeManager::instance()->getDefaultFont(); - onSizeChange(); applyDefaultTheme(); @@ -92,10 +79,7 @@ void UIMenu::doAfterSetTheme() { UIMenuItem * UIMenu::createMenuItem( const String& Text, SubTexture * Icon ) { UIMenuItem::CreateParams Params; Params.setParent( this ); - Params.Font = mFont; - Params.FontColor = mFontColor; - Params.FontShadowColor = mFontShadowColor; - Params.FontOverColor = mFontOverColor; + Params.fontStyleConfig = mFontStyleConfig; Params.Icon = Icon; Params.IconMinSize = Sizei( mMinSpaceForIcons, mMinSpaceForIcons ); @@ -121,10 +105,7 @@ Uint32 UIMenu::add( const String& Text, SubTexture * Icon ) { UIMenuCheckBox * UIMenu::createMenuCheckBox( const String& Text, const bool &Active ) { UIMenuCheckBox::CreateParams Params; Params.setParent( this ); - Params.Font = mFont; - Params.FontColor = mFontColor; - Params.FontShadowColor = mFontShadowColor; - Params.FontOverColor = mFontOverColor; + Params.fontStyleConfig = mFontStyleConfig; Params.IconMinSize = Sizei( mMinSpaceForIcons, mMinSpaceForIcons ); if ( mFlags & UI_AUTO_SIZE ) { @@ -152,10 +133,7 @@ Uint32 UIMenu::addCheckBox( const String& Text, const bool& Active ) { UIMenuSubMenu * UIMenu::createSubMenu( const String& Text, SubTexture * Icon, UIMenu * SubMenu ) { UIMenuSubMenu::CreateParams Params; Params.setParent( this ); - Params.Font = mFont; - Params.FontColor = mFontColor; - Params.FontShadowColor = mFontShadowColor; - Params.FontOverColor = mFontOverColor; + Params.fontStyleConfig = mFontStyleConfig; Params.SubMenu = SubMenu; Params.Icon = Icon; Params.IconMinSize = Sizei( mMinSpaceForIcons, mMinSpaceForIcons ); @@ -577,46 +555,6 @@ const Recti& UIMenu::getPadding() const { return mPadding; } -Font * UIMenu::getFont() const { - return mFont; -} - -void UIMenu::setFont(Font * font) { - mFont = font; -} - -ColorA UIMenu::getFontColor() const { - return mFontColor; -} - -void UIMenu::setFontColor(const ColorA & fontColor) { - mFontColor = fontColor; -} - -ColorA UIMenu::getFontShadowColor() const { - return mFontShadowColor; -} - -void UIMenu::setFontShadowColor(const ColorA & fontShadowColor) { - mFontShadowColor = fontShadowColor; -} - -ColorA UIMenu::getFontOverColor() const { - return mFontOverColor; -} - -void UIMenu::setFontOverColor(const ColorA & fontOverColor) { - mFontOverColor = fontOverColor; -} - -ColorA UIMenu::getFontSelectedColor() const { - return mFontSelectedColor; -} - -void UIMenu::setFontSelectedColor(const ColorA & fontSelectedColor) { - mFontSelectedColor = fontSelectedColor; -} - Uint32 UIMenu::getMinRightMargin() const { return mMinRightMargin; } @@ -626,6 +564,16 @@ void UIMenu::setMinRightMargin(const Uint32 & minRightMargin) { rePosControls(); } +FontStyleConfig UIMenu::getFontStyleConfig() const +{ + return mFontStyleConfig; +} + +void UIMenu::setFontStyleConfig(const FontStyleConfig & fontStyleConfig) +{ + mFontStyleConfig = fontStyleConfig; +} + void UIMenu::fixMenuPos( Vector2i& Pos, UIMenu * Menu, UIMenu * Parent, UIMenuSubMenu * SubMenu ) { eeAABB qScreen( 0.f, 0.f, UIManager::instance()->getMainControl()->getRealSize().getWidth(), UIManager::instance()->getMainControl()->getRealSize().getHeight() ); eeAABB qPos( Pos.x, Pos.y, Pos.x + Menu->getRealSize().getWidth(), Pos.y + Menu->getRealSize().getHeight() ); diff --git a/src/eepp/ui/uimenuitem.cpp b/src/eepp/ui/uimenuitem.cpp index 8cb33012e..f40caab7c 100644 --- a/src/eepp/ui/uimenuitem.cpp +++ b/src/eepp/ui/uimenuitem.cpp @@ -43,11 +43,11 @@ void UIMenuItem::onStateChange() { UIMenu * tMenu = reinterpret_cast ( getParent() ); if ( mSkinState->getState() == UISkinState::StateSelected ) { - mTextBox->setFontColor( tMenu->mFontSelectedColor ); + mTextBox->setFontColor( tMenu->getFontStyleConfig().getFontSelectedColor() ); } else if ( mSkinState->getState() == UISkinState::StateMouseEnter ) { - mTextBox->setFontColor( tMenu->mFontOverColor ); + mTextBox->setFontColor( tMenu->getFontStyleConfig().getFontOverColor() ); } else { - mTextBox->setFontColor( tMenu->mFontColor ); + mTextBox->setFontColor( tMenu->getFontStyleConfig().getFontColor() ); } } diff --git a/src/eepp/ui/uiprogressbar.cpp b/src/eepp/ui/uiprogressbar.cpp index 29921e836..592c0a3bc 100644 --- a/src/eepp/ui/uiprogressbar.cpp +++ b/src/eepp/ui/uiprogressbar.cpp @@ -2,47 +2,30 @@ namespace EE { namespace UI { -UIProgressBar::UIProgressBar( const UIProgressBar::CreateParams& Params ) : - UIComplexControl( Params ), - mVerticalExpand( Params.VerticalExpand ), - mSpeed( Params.MovementSpeed ), - mFillerPadding( Params.FillerMargin ), - mDisplayPercent( Params.DisplayPercent ), - mProgress( 0.f ), - mTotalSteps( 100.f ), - mParallax( NULL ) -{ - UITextBox::CreateParams TxtBoxParams = Params; - - TxtBoxParams.setParent( this ); - TxtBoxParams.Flags = UI_VALIGN_CENTER | UI_HALIGN_CENTER; - TxtBoxParams.setPosition( 0, 0 ); - - mTextBox = eeNew( UITextBox, ( TxtBoxParams ) ); - mTextBox->setEnabled( false ); - - updateTextBox(); - - applyDefaultTheme(); +UIProgressBar *UIProgressBar::New() { + return eeNew( UIProgressBar, () ); } UIProgressBar::UIProgressBar() : UIComplexControl(), - mVerticalExpand( true ), - mSpeed( 64.f, 0.f ), - mFillerPadding(), - mDisplayPercent( false ), mProgress( 0.f ), mTotalSteps( 100.f ), mParallax( NULL ) { setFlags( UI_AUTO_PADDING | UI_AUTO_SIZE ); + UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); + mTextBox = eeNew( UITextBox, () ); mTextBox->setHorizontalAlign( UI_HALIGN_CENTER ); mTextBox->setParent( this ); mTextBox->setEnabled( false ); + if ( NULL != Theme ) { + mStyleConfig = Theme->getProgressBarStyleConfig(); + mTextBox->setFontStyleConfig( mStyleConfig ); + } + updateTextBox(); applyDefaultTheme(); @@ -67,7 +50,7 @@ void UIProgressBar::draw() { ColorA C( mParallax->getColor() ); C.Alpha = (Uint8)mAlpha; - Rectf fillerMargin = PixelDensity::dpToPx( mFillerPadding ); + Rectf fillerMargin = PixelDensity::dpToPx( mStyleConfig.fillerPadding ); mParallax->setColor( C ); mParallax->setPosition( Vector2f( mScreenPos.x + fillerMargin.Left, mScreenPos.y + fillerMargin.Top ) ); @@ -92,7 +75,7 @@ void UIProgressBar::setTheme( UITheme * Theme ) { Float Height = (Float)PixelDensity::dpToPx( getSkinSize().getHeight() ); - if ( !mVerticalExpand ) + if ( !mStyleConfig.verticalExpand ) Height = (Float)tSubTexture->getSize().getHeight(); if ( Height > mRealSize.getHeight() ) @@ -102,12 +85,12 @@ void UIProgressBar::setTheme( UITheme * Theme ) { Float meH = (Float)getSkinSize().getHeight(); Float otH = (Float)tSkin->getSize().getHeight(); Float res = Math::roundUp( ( meH - otH ) * 0.5f ); - mFillerPadding = Rectf( res, res, res, res ); + mStyleConfig.fillerPadding = Rectf( res, res, res, res ); } - Rectf fillerPadding = PixelDensity::dpToPx( mFillerPadding ); + Rectf fillerPadding = PixelDensity::dpToPx( mStyleConfig.fillerPadding ); - mParallax = eeNew( ScrollParallax, ( tSubTexture, Vector2f( mScreenPos.x + fillerPadding.Left, mScreenPos.y + fillerPadding.Top ), Sizef( ( ( mRealSize.getWidth() - fillerPadding.Left - fillerPadding.Right ) * mProgress ) / mTotalSteps, Height - fillerPadding.Top - fillerPadding.Bottom ), mSpeed ) ); + mParallax = eeNew( ScrollParallax, ( tSubTexture, Vector2f( mScreenPos.x + fillerPadding.Left, mScreenPos.y + fillerPadding.Top ), Sizef( ( ( mRealSize.getWidth() - fillerPadding.Left - fillerPadding.Right ) * mProgress ) / mTotalSteps, Height - fillerPadding.Top - fillerPadding.Bottom ), mStyleConfig.movementSpeed ) ); } } } @@ -124,13 +107,13 @@ void UIProgressBar::onSizeChange() { if ( NULL != mParallax ) { Float Height = (Float)mRealSize.getHeight(); - if ( !mVerticalExpand && mParallax->getSubTexture() ) + if ( !mStyleConfig.verticalExpand && mParallax->getSubTexture() ) Height = (Float)mParallax->getSubTexture()->getSize().getHeight(); if ( Height > mRealSize.getHeight() ) Height = mRealSize.getHeight(); - Rectf fillerPadding = PixelDensity::dpToPx( mFillerPadding ); + Rectf fillerPadding = PixelDensity::dpToPx( mStyleConfig.fillerPadding ); mParallax->setSize( Sizef( ( ( mRealSize.getWidth() - fillerPadding.Left - fillerPadding.Right ) * mProgress ) / mTotalSteps, Height - fillerPadding.Top - fillerPadding.Bottom ) ); } @@ -161,51 +144,51 @@ const Float& UIProgressBar::getTotalSteps() const { } void UIProgressBar::setMovementSpeed( const Vector2f& Speed ) { - mSpeed = Speed; + mStyleConfig.movementSpeed = Speed; if ( NULL != mParallax ) - mParallax->setSpeed( PixelDensity::dpToPx( mSpeed ) ); + mParallax->setSpeed( PixelDensity::dpToPx( Speed ) ); } const Vector2f& UIProgressBar::getMovementSpeed() const { - return mSpeed; + return mStyleConfig.movementSpeed; } void UIProgressBar::setVerticalExpand( const bool& VerticalExpand ) { - if ( VerticalExpand != mVerticalExpand ) { - mVerticalExpand = VerticalExpand; + if ( VerticalExpand != mStyleConfig.verticalExpand ) { + mStyleConfig.verticalExpand = VerticalExpand; onSizeChange(); } } const bool& UIProgressBar::getVerticalExpand() const { - return mVerticalExpand; + return mStyleConfig.verticalExpand; } void UIProgressBar::setFillerPadding( const Rectf& margin ) { - mFillerPadding = margin; + mStyleConfig.fillerPadding = margin; onPositionChange(); onSizeChange(); } const Rectf& UIProgressBar::getFillerPadding() const { - return mFillerPadding; + return mStyleConfig.fillerPadding; } void UIProgressBar::setDisplayPercent( const bool& DisplayPercent ) { - mDisplayPercent = DisplayPercent; + mStyleConfig.displayPercent = DisplayPercent; updateTextBox(); } const bool& UIProgressBar::getDisplayPercent() const { - return mDisplayPercent; + return mStyleConfig.displayPercent; } void UIProgressBar::updateTextBox() { - mTextBox->setVisible( mDisplayPercent ); + mTextBox->setVisible( mStyleConfig.displayPercent ); mTextBox->setSize( mSize ); mTextBox->setText( String::toStr( (Int32)( ( mProgress / mTotalSteps ) * 100.f ) ) + "%" ); } diff --git a/src/eepp/ui/uipushbutton.cpp b/src/eepp/ui/uipushbutton.cpp index bd5c7a3d9..a6c3df428 100644 --- a/src/eepp/ui/uipushbutton.cpp +++ b/src/eepp/ui/uipushbutton.cpp @@ -5,8 +5,7 @@ namespace EE { namespace UI { UIPushButton::UIPushButton( const UIPushButton::CreateParams& Params ) : UIComplexControl( Params ), - mFontColor( Params.FontColor ), - mFontOverColor( Params.FontOverColor ), + mFontStyleConfig( Params.fontStyleConfig ), mIcon( NULL ), mTextBox( NULL ), mIconSpace( Params.IconHorizontalMargin ) @@ -35,9 +34,7 @@ UIPushButton::UIPushButton( const UIPushButton::CreateParams& Params ) : UITextBox::CreateParams TxtParams = Params; TxtParams.setParent( this ); TxtParams.Flags = HAlignGet( Params.Flags ) | VAlignGet( Params.Flags ); - TxtParams.Font = Params.Font; - TxtParams.FontColor = Params.FontColor; - TxtParams.FontShadowColor = Params.FontShadowColor; + TxtParams.fontStyleConfig = Params.fontStyleConfig; if ( TxtParams.Flags & UI_CLIP_ENABLE ) TxtParams.Flags &= ~UI_CLIP_ENABLE; @@ -56,12 +53,12 @@ UIPushButton::UIPushButton( const UIPushButton::CreateParams& Params ) : UIPushButton::UIPushButton() : UIComplexControl(), - mFontColor(), - mFontOverColor(), mIcon( NULL ), mTextBox( NULL ), mIconSpace( 0 ) { + mFontStyleConfig = UIThemeManager::instance()->getDefaultFontStyleConfig(); + setFlags( UI_AUTO_SIZE | UI_VALIGN_CENTER | UI_HALIGN_CENTER ); mIcon = eeNew( UIGfx, () ); @@ -152,8 +149,8 @@ void UIPushButton::setTheme( UITheme * Theme ) { } void UIPushButton::doAfterSetTheme() { - if ( NULL != mTextBox && NULL == mTextBox->getFont() && NULL != mSkinState && NULL != mSkinState->getSkin() && NULL != mSkinState->getSkin()->getTheme() && NULL != mSkinState->getSkin()->getTheme()->getFont() ) - mTextBox->setFont( mSkinState->getSkin()->getTheme()->getFont() ); + if ( NULL != mTextBox && NULL == mTextBox->getFont() && NULL != mSkinState && NULL != mSkinState->getSkin() && NULL != mSkinState->getSkin()->getTheme() && NULL != mSkinState->getSkin()->getTheme()->getFontStyleConfig().getFont() ) + mTextBox->setFont( mSkinState->getSkin()->getTheme()->getFontStyleConfig().getFont() ); if ( mControlFlags & UI_CTRL_FLAG_FREE_USE ) { Recti RMargin = makePadding( true, false, false, false, true ); @@ -231,9 +228,9 @@ void UIPushButton::onAlphaChange() { void UIPushButton::onStateChange() { if ( mSkinState->getState() == UISkinState::StateMouseEnter ) { - mTextBox->setFontColor( mFontOverColor ); + mTextBox->setFontColor( mFontStyleConfig.fontOverColor ); } else { - mTextBox->setFontColor( mFontColor ); + mTextBox->setFontColor( mFontStyleConfig.fontColor ); } mTextBox->setAlpha( mAlpha ); @@ -259,20 +256,20 @@ Uint32 UIPushButton::onKeyUp( const UIEventKey& Event ) { return UIComplexControl::onKeyUp( Event ); } const ColorA& UIPushButton::getFontColor() const { - return mFontColor; + return mFontStyleConfig.fontColor; } void UIPushButton::setFontColor( const ColorA& color ) { - mFontColor = color; + mFontStyleConfig.fontColor = color; onStateChange(); } const ColorA& UIPushButton::getFontOverColor() const { - return mFontOverColor; + return mFontStyleConfig.fontOverColor; } void UIPushButton::setFontOverColor( const ColorA& color ) { - mFontOverColor = color; + mFontStyleConfig.fontOverColor = color; onStateChange(); } @@ -284,4 +281,14 @@ void UIPushButton::setFontShadowColor( const ColorA& color ) { mTextBox->setFontShadowColor( color ); } +FontStyleConfig UIPushButton::getFontStyleConfig() const { + return mFontStyleConfig; +} + +void UIPushButton::setFontStyleConfig(const FontStyleConfig & fontStyleConfig) { + mFontStyleConfig = fontStyleConfig; + mTextBox->setFontStyleConfig( fontStyleConfig ); + onStateChange(); +} + }} diff --git a/src/eepp/ui/uiselectbutton.cpp b/src/eepp/ui/uiselectbutton.cpp index b65b5927d..24128b39f 100644 --- a/src/eepp/ui/uiselectbutton.cpp +++ b/src/eepp/ui/uiselectbutton.cpp @@ -59,29 +59,29 @@ void UISelectButton::onStateChange() { UIWinMenu * Menu = reinterpret_cast ( getParent() ); if ( mSkinState->getState() == UISkinState::StateSelected ) { - getTextBox()->setFontColor( Menu->getFontSelectedColor() ); + getTextBox()->setFontColor( Menu->getFontStyleConfig().getFontSelectedColor() ); } else if ( mSkinState->getState() == UISkinState::StateMouseEnter ) { - getTextBox()->setFontColor( Menu->getFontOverColor() ); + getTextBox()->setFontColor( Menu->getFontStyleConfig().getFontOverColor() ); } else { - getTextBox()->setFontColor( Menu->getFontColor() ); + getTextBox()->setFontColor( Menu->getFontStyleConfig().getFontColor() ); } } else { if ( mSkinState->getState() == UISkinState::StateSelected ) { - getTextBox()->setFontColor( mFontSelectedColor ); + getTextBox()->setFontColor( mFontStyleConfig.fontSelectedColor ); } else if ( mSkinState->getState() == UISkinState::StateMouseEnter ) { - getTextBox()->setFontColor( mFontOverColor ); + getTextBox()->setFontColor( mFontStyleConfig.fontOverColor ); } else { - getTextBox()->setFontColor( mFontColor ); + getTextBox()->setFontColor( mFontStyleConfig.fontColor ); } } } -ColorA UISelectButton::getFontSelectedColor() const { - return mFontSelectedColor; +void UISelectButton::setFontSelectedColor(const ColorA & color) { + mFontStyleConfig.fontSelectedColor = color; } -void UISelectButton::setFontSelectedColor(const ColorA & fontSelectedColor) { - mFontSelectedColor = fontSelectedColor; +const ColorA &UISelectButton::getFontSelectedColor() const { + return mFontStyleConfig.fontSelectedColor; } }} diff --git a/src/eepp/ui/uitab.cpp b/src/eepp/ui/uitab.cpp index 64f0dd039..f9b7d7ca0 100644 --- a/src/eepp/ui/uitab.cpp +++ b/src/eepp/ui/uitab.cpp @@ -47,7 +47,7 @@ void UITab::setTheme( UITheme * Theme ) { UITabWidget * tTabW = getTabWidget(); if ( NULL != tTabW ) { - if ( tTabW->mSpecialBorderTabs ) { + if ( tTabW->getSpecialBorderTabs() ) { if ( 0 == tTabW->getTabIndex( this ) ) { tabPos = "tab_left"; } else if ( tTabW->getCount() > 0 && ( tTabW->getCount() - 1 ) == tTabW->getTabIndex( this ) ) { @@ -90,11 +90,11 @@ void UITab::onStateChange() { setSize( mSize.getWidth(), skinSize ); if ( mSkinState->getState() == UISkinState::StateSelected ) { - mTextBox->setFontColor( tTabW->mFontSelectedColor ); + mTextBox->setFontColor( tTabW->getFontSelectedColor() ); } else if ( mSkinState->getState() == UISkinState::StateMouseEnter ) { - mTextBox->setFontColor( tTabW->mFontOverColor ); + mTextBox->setFontColor( tTabW->getFontOverColor() ); } else { - mTextBox->setFontColor( tTabW->mFontColor ); + mTextBox->setFontColor( tTabW->getFontColor() ); } } } @@ -107,8 +107,8 @@ void UITab::setText( const String &text ) { UITabWidget * tTabW = getTabWidget(); if ( NULL != tTabW ) { - if ( text.size() > tTabW->mMaxTextLength ) { - UIPushButton::setText( text.substr( 0, tTabW->mMaxTextLength ) ); + if ( text.size() > tTabW->getMaxTextLength() ) { + UIPushButton::setText( text.substr( 0, tTabW->getMaxTextLength() ) ); autoSize(); @@ -128,8 +128,8 @@ void UITab::autoSize() { UITabWidget * tTabW = getTabWidget(); if ( NULL != tTabW ) { - w = eemax( w, tTabW->mMinTabWidth ); - w = eemin( w, tTabW->mMaxTabWidth ); + w = eemax( w, tTabW->getMinTabWidth() ); + w = eemin( w, tTabW->getMaxTabWidth() ); } setSize( w, mSize.getHeight() ); @@ -152,7 +152,7 @@ void UITab::update() { } else if ( Flags & EE_BUTTON_WDMASK ) { tTabW->selectNext(); } - } else if ( tTabW->mTabsClosable && ( Flags & EE_BUTTON_MMASK ) ) { + } else if ( tTabW->getTabsClosable() && ( Flags & EE_BUTTON_MMASK ) ) { tTabW->remove( this ); } } diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp index 2950faab1..5fca5b521 100644 --- a/src/eepp/ui/uitabwidget.cpp +++ b/src/eepp/ui/uitabwidget.cpp @@ -5,68 +5,12 @@ namespace EE { namespace UI { -UITabWidget::UITabWidget( UITabWidget::CreateParams& Params ) : - UIComplexControl( Params ), - mFont( Params.Font ), - mFontColor( Params.FontColor ), - mFontShadowColor( Params.FontShadowColor ), - mFontOverColor( Params.FontOverColor ), - mFontSelectedColor( Params.FontSelectedColor ), - mTabSeparation( Params.TabSeparation ), - mMaxTextLength( Params.MaxTextLength ), - mTabWidgetHeight( Params.TabWidgetHeight ), - mMinTabWidth( Params.MinTabWidth ), - mMaxTabWidth( Params.MaxTabWidth ), - mTabsClosable( Params.TabsClosable ), - mSpecialBorderTabs( Params.SpecialBorderTabs ), - mDrawLineBelowTabs( Params.DrawLineBelowTabs ), - mLineBelowTabsColor( Params.LineBelowTabsColor ), - mLineBewowTabsYOffset( Params.LineBewowTabsYOffset ), - mTabSelected( NULL ), - mTabSelectedIndex( eeINDEX_NOT_FOUND ) -{ - UIComplexControl::CreateParams TabParams; - TabParams.setParent( this ); - TabParams.setPosition( 0, 0 ); - TabParams.Flags |= UI_CLIP_ENABLE | UI_ANCHOR_RIGHT; - TabParams.setSize( mSize.getWidth(), mTabWidgetHeight ); - - mTabContainer = eeNew( UIComplexControl, ( TabParams ) ); - mTabContainer->setVisible( true ); - mTabContainer->setEnabled( true ); - - UIComplexControl::CreateParams CtrlParams; - CtrlParams.setParent( this ); - CtrlParams.setPosition( 0, mTabWidgetHeight ); - CtrlParams.setSize( mSize.getWidth(), mSize.getHeight() - mTabWidgetHeight ); - CtrlParams.Flags |= UI_CLIP_ENABLE | UI_ANCHOR_BOTTOM | UI_ANCHOR_RIGHT; - - mCtrlContainer = eeNew( UIComplexControl, ( CtrlParams ) ); - mCtrlContainer->setVisible( true ); - mCtrlContainer->setEnabled( true ); - - onSizeChange(); - - applyDefaultTheme(); +UITabWidget * UITabWidget::New() { + return eeNew( UITabWidget, () ); } UITabWidget::UITabWidget() : UIComplexControl(), - mFont( NULL ), - mFontColor(), - mFontShadowColor(), - mFontOverColor(), - mFontSelectedColor(), - mTabSeparation( 0 ), - mMaxTextLength( 32 ), - mTabWidgetHeight( 0 ), - mMinTabWidth( 32 ), - mMaxTabWidth( 0xFFFFFF ), - mTabsClosable( false ), - mSpecialBorderTabs( true ), - mDrawLineBelowTabs( true ), - mLineBelowTabsColor( ColorA(0,0,0,255) ), - mLineBewowTabsYOffset( -1 ), mTabSelected( NULL ), mTabSelectedIndex( eeINDEX_NOT_FOUND ) { @@ -75,23 +19,16 @@ UITabWidget::UITabWidget() : UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); if ( NULL != Theme ) { - mFont = Theme->getFont(); - mFontColor = Theme->getFontColor(); - mFontShadowColor = Theme->getFontShadowColor(); - mFontOverColor = Theme->getFontOverColor(); - mFontSelectedColor = Theme->getFontSelectedColor(); + mStyleConfig = Theme->getTabWidgetStyleConfig(); } - if ( NULL == mFont ) - mFont = UIThemeManager::instance()->getDefaultFont(); - mTabContainer = eeNew( UIComplexControl, ( ) ); - mTabContainer->setParent( this )->setPosition( 0, 0 )->setSize( mSize.getWidth(), mTabWidgetHeight )->setVisible( true )->setEnabled( true ); + mTabContainer->setParent( this )->setPosition( 0, 0 )->setSize( mSize.getWidth(), mStyleConfig.tabWidgetHeight )->setVisible( true )->setEnabled( true ); mTabContainer->setFlags( UI_CLIP_ENABLE | UI_ANCHOR_RIGHT ); mCtrlContainer = eeNew( UIComplexControl, ( ) ); - mCtrlContainer->setParent( this )->setPosition( 0, mTabWidgetHeight ) - ->setSize( mSize.getWidth(), mSize.getHeight() - mTabWidgetHeight )->setVisible( true )->setEnabled( true ) + mCtrlContainer->setParent( this )->setPosition( 0, mStyleConfig.tabWidgetHeight ) + ->setSize( mSize.getWidth(), mSize.getHeight() - mStyleConfig.tabWidgetHeight )->setVisible( true )->setEnabled( true ) ->setFlags( UI_CLIP_ENABLE | UI_ANCHOR_BOTTOM | UI_ANCHOR_RIGHT ); onSizeChange(); @@ -115,14 +52,14 @@ void UITabWidget::setTheme( UITheme * Theme ) { mCtrlContainer->setThemeControl( Theme, "tabcontainer" ); - if ( 0 == mTabWidgetHeight ) { + if ( 0 == mStyleConfig.tabWidgetHeight ) { UISkin * tSkin = Theme->getByName( Theme->getAbbr() + "_" + "tab" ); if ( NULL != tSkin ) { Sizei tSize1 = getSkinSize( tSkin ); Sizei tSize2 = getSkinSize( tSkin, UISkinState::StateSelected ); - mTabWidgetHeight = eemax( tSize1.getHeight(), tSize2.getHeight() ); + mStyleConfig.tabWidgetHeight = eemax( tSize1.getHeight(), tSize2.getHeight() ); seContainerSize(); orderTabs(); @@ -137,27 +74,27 @@ void UITabWidget::doAfterSetTheme() { } void UITabWidget::seContainerSize() { - mTabContainer->setSize( mSize.getWidth(), mTabWidgetHeight ); - mCtrlContainer->setPosition( 0, mTabWidgetHeight ); - mCtrlContainer->setSize( mSize.getWidth(), mSize.getHeight() - mTabWidgetHeight ); + mTabContainer->setSize( mSize.getWidth(), mStyleConfig.tabWidgetHeight ); + mCtrlContainer->setPosition( 0, mStyleConfig.tabWidgetHeight ); + mCtrlContainer->setSize( mSize.getWidth(), mSize.getHeight() - mStyleConfig.tabWidgetHeight ); } void UITabWidget::draw() { UIComplexControl::draw(); - if ( mDrawLineBelowTabs ) { + if ( mStyleConfig.drawLineBelowTabs ) { bool smooth = GLi->isLineSmooth(); if ( smooth ) GLi->lineSmooth( false ); Primitives P; - Vector2i p1( mScreenPos.x, mScreenPos.y + mTabContainer->getRealSize().getHeight() + mLineBewowTabsYOffset ); + Vector2i p1( mScreenPos.x, mScreenPos.y + mTabContainer->getRealSize().getHeight() + mStyleConfig.lineBelowTabsYOffset ); Vector2i p2( mScreenPos.x + mTabContainer->getRealPosition().x, p1.y ); P.setLineWidth( PixelDensity::dpToPx( 1 ) ); - P.setColor( mLineBelowTabsColor ); + P.setColor(mStyleConfig.lineBelowTabsColor ); P.drawLine( Line2f( Vector2f( p1.x, p1.y ), Vector2f( p2.x, p2.y ) ) ); - Vector2i p3( mScreenPos.x + mTabContainer->getRealPosition().x + mTabContainer->getRealSize().getWidth(), mScreenPos.y + mTabContainer->getRealSize().getHeight() + mLineBewowTabsYOffset ); + Vector2i p3( mScreenPos.x + mTabContainer->getRealPosition().x + mTabContainer->getRealSize().getWidth(), mScreenPos.y + mTabContainer->getRealSize().getHeight() + mStyleConfig.lineBelowTabsYOffset ); Vector2i p4( mScreenPos.x + mRealSize.getWidth(), p3.y ); P.drawLine( Line2f( Vector2f( p3.x, p3.y ), Vector2f( p4.x, p4.y ) ) ); @@ -166,154 +103,174 @@ void UITabWidget::draw() { } } +FontStyleConfig UITabWidget::getFontStyleConfig() const { + return FontStyleConfig( mStyleConfig ); +} + +void UITabWidget::setFontStyleConfig(const FontStyleConfig & fontStyleConfig) { + mStyleConfig.updateFontStyleConfig( fontStyleConfig ); +} + +TabWidgetStyleConfig UITabWidget::getStyleConfig() const { + return mStyleConfig; +} + +void UITabWidget::setStyleConfig(const TabWidgetStyleConfig & styleConfig) { + Uint32 tabWidgetHeight = mStyleConfig.tabWidgetHeight; + mStyleConfig = styleConfig; + mStyleConfig.tabWidgetHeight = tabWidgetHeight; + seContainerSize(); + setTabContainerSize(); + orderTabs(); +} + Font * UITabWidget::getFont() const { - return mFont; + return mStyleConfig.font; } void UITabWidget::setFont(Font * font) { - mFont = font; + mStyleConfig.font = font; if ( mTabs.size() > 0 ) { for ( Uint32 i = 0; i < mTabs.size(); i++ ) { - ((UITab*)mTabs[ i ])->setFont( mFont ); + ((UITab*)mTabs[ i ])->setFont( mStyleConfig.font ); } } } ColorA UITabWidget::getFontColor() const { - return mFontColor; + return mStyleConfig.fontColor; } void UITabWidget::setFontColor(const ColorA & fontColor) { - mFontColor = fontColor; + mStyleConfig.fontColor = fontColor; if ( mTabs.size() > 0 ) { for ( Uint32 i = 0; i < mTabs.size(); i++ ) { - ((UITab*)mTabs[ i ])->setFontColor( mFontColor ); + ((UITab*)mTabs[ i ])->setFontColor( mStyleConfig.fontColor ); } } } ColorA UITabWidget::getFontShadowColor() const { - return mFontShadowColor; + return mStyleConfig.fontShadowColor; } void UITabWidget::setFontShadowColor(const ColorA & fontShadowColor) { - mFontShadowColor = fontShadowColor; + mStyleConfig.fontShadowColor = fontShadowColor; if ( mTabs.size() > 0 ) { for ( Uint32 i = 0; i < mTabs.size(); i++ ) { - ((UITab*)mTabs[ i ])->setFontShadowColor( mFontShadowColor ); + ((UITab*)mTabs[ i ])->setFontShadowColor( mStyleConfig.fontShadowColor ); } } } ColorA UITabWidget::getFontOverColor() const { - return mFontOverColor; + return mStyleConfig.fontOverColor; } void UITabWidget::setFontOverColor(const ColorA & fontOverColor) { - mFontOverColor = fontOverColor; + mStyleConfig.fontOverColor = fontOverColor; if ( mTabs.size() > 0 ) { for ( Uint32 i = 0; i < mTabs.size(); i++ ) { - ((UITab*)mTabs[ i ])->setFontOverColor( mFontOverColor ); + ((UITab*)mTabs[ i ])->setFontOverColor( mStyleConfig.fontOverColor ); } } } ColorA UITabWidget::getFontSelectedColor() const { - return mFontSelectedColor; + return mStyleConfig.fontSelectedColor; } void UITabWidget::setFontSelectedColor(const ColorA & fontSelectedColor) { - mFontSelectedColor = fontSelectedColor; + mStyleConfig.fontSelectedColor = fontSelectedColor; if ( mTabs.size() > 0 ) { for ( Uint32 i = 0; i < mTabs.size(); i++ ) { - ((UITab*)mTabs[ i ])->setFontSelectedColor( mFontSelectedColor ); + ((UITab*)mTabs[ i ])->setFontSelectedColor( mStyleConfig.fontSelectedColor ); } } } Int32 UITabWidget::getTabSeparation() const { - return mTabSeparation; + return mStyleConfig.tabSeparation; } void UITabWidget::setTabSeparation(const Int32 & tabSeparation) { - mTabSeparation = tabSeparation; + mStyleConfig.tabSeparation = tabSeparation; setTabContainerSize(); posTabs(); } Uint32 UITabWidget::getMaxTextLength() const { - return mMaxTextLength; + return mStyleConfig.maxTextLength; } void UITabWidget::setMaxTextLength(const Uint32 & maxTextLength) { - mMaxTextLength = maxTextLength; + mStyleConfig.maxTextLength = maxTextLength; } Uint32 UITabWidget::getTabWidgetHeight() const { - return mTabWidgetHeight; + return mStyleConfig.tabWidgetHeight; } -Uint32 UITabWidget::getMinTabWidth() const -{ - return mMinTabWidth; +Uint32 UITabWidget::getMinTabWidth() const { + return mStyleConfig.minTabWidth; } void UITabWidget::setMinTabWidth(const Uint32 & minTabWidth) { - mMinTabWidth = minTabWidth; + mStyleConfig.minTabWidth = minTabWidth; } Uint32 UITabWidget::getMaxTabWidth() const { - return mMaxTabWidth; + return mStyleConfig.maxTabWidth; } void UITabWidget::setMaxTabWidth(const Uint32 & maxTabWidth) { - mMaxTabWidth = maxTabWidth; + mStyleConfig.maxTabWidth = maxTabWidth; } bool UITabWidget::getTabsClosable() const { - return mTabsClosable; + return mStyleConfig.tabsClosable; } void UITabWidget::setTabsClosable(bool tabsClosable) { - mTabsClosable = tabsClosable; + mStyleConfig.tabsClosable = tabsClosable; } bool UITabWidget::getSpecialBorderTabs() const { - return mSpecialBorderTabs; + return mStyleConfig.specialBorderTabs; } void UITabWidget::setSpecialBorderTabs(bool specialBorderTabs) { - mSpecialBorderTabs = specialBorderTabs; + mStyleConfig.specialBorderTabs = specialBorderTabs; applyThemeToTabs(); } bool UITabWidget::getDrawLineBelowTabs() const { - return mDrawLineBelowTabs; + return mStyleConfig.drawLineBelowTabs; } void UITabWidget::setDrawLineBelowTabs(bool drawLineBelowTabs) { - mDrawLineBelowTabs = drawLineBelowTabs; + mStyleConfig.drawLineBelowTabs = drawLineBelowTabs; } ColorA UITabWidget::getLineBelowTabsColor() const { - return mLineBelowTabsColor; + return mStyleConfig.lineBelowTabsColor; } void UITabWidget::setLineBelowTabsColor(const ColorA & lineBelowTabsColor) { - mLineBelowTabsColor = lineBelowTabsColor; + mStyleConfig.lineBelowTabsColor = lineBelowTabsColor; } -Int32 UITabWidget::getLineBewowTabsYOffset() const { - return mLineBewowTabsYOffset; +Int32 UITabWidget::getLineBelowTabsYOffset() const { + return mStyleConfig.lineBelowTabsYOffset; } -void UITabWidget::setLineBewowTabsYOffset(const Int32 & lineBewowTabsYOffset) { - mLineBewowTabsYOffset = lineBewowTabsYOffset; +void UITabWidget::setLineBelowTabsYOffset(const Int32 & lineBelowTabsYOffset) { + mStyleConfig.lineBelowTabsYOffset = lineBelowTabsYOffset; } void UITabWidget::setTabContainerSize() { @@ -321,13 +278,13 @@ void UITabWidget::setTabContainerSize() { if ( mTabs.size() > 0 ) { for ( Uint32 i = 0; i < mTabs.size(); i++ ) { - s += mTabs[i]->getSize().getWidth() + mTabSeparation; + s += mTabs[i]->getSize().getWidth() + mStyleConfig.tabSeparation; } - s -= mTabSeparation; + s -= mStyleConfig.tabSeparation; } - mTabContainer->setSize( s, mTabWidgetHeight ); + mTabContainer->setSize( s, mStyleConfig.tabWidgetHeight ); switch ( HAlignGet( mFlags ) ) { @@ -352,19 +309,19 @@ void UITabWidget::posTabs() { switch ( VA ) { case UI_VALIGN_BOTTOM: - h = mTabWidgetHeight - mTabs[i]->getSize().getHeight(); + h = mStyleConfig.tabWidgetHeight - mTabs[i]->getSize().getHeight(); break; case UI_VALIGN_TOP: h = 0; break; case UI_VALIGN_CENTER: - h = mTabWidgetHeight / 2 - mTabs[i]->getSize().getHeight() / 2; + h = mStyleConfig.tabWidgetHeight / 2 - mTabs[i]->getSize().getHeight() / 2; break; } mTabs[i]->setPosition( w, h ); - w += mTabs[i]->getSize().getWidth() + mTabSeparation; + w += mTabs[i]->getSize().getWidth() + mStyleConfig.tabSeparation; } } @@ -392,11 +349,7 @@ UITab * UITabWidget::createTab( const String& Text, UIControl * CtrlOwned, SubTe UITab * tCtrl = eeNew( UITab, ( ) ); tCtrl->setParent( mTabContainer ); tCtrl->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER | UI_AUTO_SIZE ); - tCtrl->setFont( mFont ); - tCtrl->setFontColor( mFontColor ); - tCtrl->setFontShadowColor( mFontShadowColor ); - tCtrl->setFontOverColor( mFontOverColor ); - tCtrl->setFontSelectedColor( mFontSelectedColor ); + tCtrl->setFontStyleConfig( mStyleConfig ); tCtrl->setIcon( Icon ); tCtrl->setText( Text ); tCtrl->setVisible( true ); @@ -586,7 +539,7 @@ void UITabWidget::onSizeChange() { } void UITabWidget::applyThemeToTabs() { - if ( mSpecialBorderTabs ) { + if ( mStyleConfig.specialBorderTabs ) { for ( Uint32 i = 0; i < mTabs.size(); i++ ) { mTabs[ i ]->applyDefaultTheme(); } @@ -601,5 +554,4 @@ UIComplexControl * UITabWidget::getControlContainer() const { return mCtrlContainer; } - }} diff --git a/src/eepp/ui/uitextbox.cpp b/src/eepp/ui/uitextbox.cpp index a0db4371b..74f2b6a44 100644 --- a/src/eepp/ui/uitextbox.cpp +++ b/src/eepp/ui/uitextbox.cpp @@ -10,54 +10,31 @@ namespace EE { namespace UI { UITextBox::UITextBox( const UITextBox::CreateParams& Params ) : UIComplexControl( Params ), - mFontColor( Params.FontColor ), - mFontShadowColor( Params.FontShadowColor ), - mFontSelectionBackColor( Params.FontSelectionBackColor ), + mFontStyleConfig( Params.fontStyleConfig ), mRealAlignOffset( 0.f, 0.f ), mSelCurInit( -1 ), mSelCurEnd( -1 ) { mTextCache = eeNew( TextCache, () ); - mTextCache->setFont( Params.Font ); - mTextCache->setColor( mFontColor ); - mTextCache->setShadowColor( mFontShadowColor ); - - if ( NULL == Params.Font ) { - if ( NULL != UIThemeManager::instance()->getDefaultFont() ) { - mTextCache->setFont( UIThemeManager::instance()->getDefaultFont() ); - } else { - eePRINTL( "UITextBox::UITextBox : Created a UI TextBox without a defined font." ); - } - } + mTextCache->setFont( mFontStyleConfig.font ); + mTextCache->setColor( mFontStyleConfig.fontColor ); + mTextCache->setShadowColor( mFontStyleConfig.fontShadowColor ); autoAlign(); } UITextBox::UITextBox() : UIComplexControl(), - mFontColor(), - mFontShadowColor(), - mFontSelectionBackColor(), mRealAlignOffset( 0.f, 0.f ), mSelCurInit( -1 ), mSelCurEnd( -1 ) { + mFontStyleConfig = UIThemeManager::instance()->getDefaultFontStyleConfig(); + mTextCache = eeNew( TextCache, () ); - - UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); - - if ( NULL != UIThemeManager::instance()->getDefaultTheme() ) { - setFont( Theme->getFont() ); - setFontColor( Theme->getFontColor() ); - setFontShadowColor( Theme->getFontShadowColor() ); - setSelectionBackColor( Theme->getFontSelectionBackColor() ); - } - - if ( NULL == getFont() && NULL != UIThemeManager::instance()->getDefaultFont() ) { - setFont( UIThemeManager::instance()->getDefaultFont() ); - } else { - eePRINTL( "UITextBox::UITextBox : Created a UI TextBox without a defined font." ); - } + mTextCache->setFont( mFontStyleConfig.font ); + mTextCache->setColor( mFontStyleConfig.fontColor ); + mTextCache->setShadowColor( mFontStyleConfig.fontShadowColor ); autoAlign(); } @@ -137,39 +114,39 @@ void UITextBox::setText( const String& text ) { } const ColorA& UITextBox::getFontColor() const { - return mFontColor; + return mFontStyleConfig.fontColor; } void UITextBox::setFontColor( const ColorA& color ) { - mFontColor = color; + mFontStyleConfig.fontColor = color; mTextCache->setColor( color ); setAlpha( color.a() ); } const ColorA& UITextBox::getFontShadowColor() const { - return mFontShadowColor; + return mFontStyleConfig.fontShadowColor; } void UITextBox::setFontShadowColor( const ColorA& color ) { - mFontShadowColor = color; - mTextCache->setShadowColor( mFontShadowColor ); + mFontStyleConfig.fontShadowColor = color; + mTextCache->setShadowColor( mFontStyleConfig.fontShadowColor ); } const ColorA& UITextBox::getSelectionBackColor() const { - return mFontSelectionBackColor; + return mFontStyleConfig.fontSelectionBackColor; } void UITextBox::setSelectionBackColor( const ColorA& color ) { - mFontSelectionBackColor = color; + mFontStyleConfig.fontSelectionBackColor = color; } void UITextBox::setAlpha( const Float& alpha ) { UIControlAnim::setAlpha( alpha ); - mFontColor.Alpha = (Uint8)alpha; - mFontShadowColor.Alpha = (Uint8)alpha; + mFontStyleConfig.fontColor.Alpha = (Uint8)alpha; + mFontStyleConfig.fontShadowColor.Alpha = (Uint8)alpha; - mTextCache->setAlpha( mFontColor.Alpha ); + mTextCache->setAlpha( mFontStyleConfig.fontColor.Alpha ); } void UITextBox::autoShrink() { @@ -257,8 +234,8 @@ const Recti& UITextBox::getPadding() const { void UITextBox::setTheme( UITheme * Theme ) { UIControlAnim::setTheme( Theme ); - if ( NULL == mTextCache->getFont() && NULL != Theme->getFont() ) { - mTextCache->setFont( Theme->getFont() ); + if ( NULL == mTextCache->getFont() && NULL != Theme->getFontStyleConfig().getFont() ) { + mTextCache->setFont( Theme->getFontStyleConfig().getFont() ); } } @@ -354,7 +331,7 @@ void UITextBox::drawSelection( TextCache * textCache ) { Vector2i initPos, endPos; Primitives P; - P.setColor( mFontSelectionBackColor ); + P.setColor( mFontStyleConfig.fontSelectionBackColor ); do { initPos = textCache->getFont()->getCursorPos( textCache->getText(), init ); @@ -381,6 +358,11 @@ bool UITextBox::isTextSelectionEnabled() const { return 0 != ( mFlags & UI_TEXT_SELECTION_ENABLED ); } +FontStyleConfig UITextBox::getFontStyleConfig() const +{ + return mFontStyleConfig; +} + void UITextBox::selCurInit( const Int32& init ) { mSelCurInit = init; } @@ -397,4 +379,12 @@ Int32 UITextBox::selCurEnd() { return mSelCurEnd; } +void UITextBox::setFontStyleConfig( const FontStyleConfig& fontStyleConfig ) { + mFontStyleConfig = fontStyleConfig; + + setFont( mFontStyleConfig.getFont() ); + setFontColor( mFontStyleConfig.getFontColor() ); + setFontShadowColor( mFontStyleConfig.getFontShadowColor() ); +} + }} diff --git a/src/eepp/ui/uitextedit.cpp b/src/eepp/ui/uitextedit.cpp index 5dc251c49..c45b20d3b 100644 --- a/src/eepp/ui/uitextedit.cpp +++ b/src/eepp/ui/uitextedit.cpp @@ -33,9 +33,7 @@ UITextEdit::UITextEdit( UITextEdit::CreateParams& Params ) : TIParams.Size = mSize; TIParams.Flags = UI_VALIGN_TOP | UI_HALIGN_LEFT | UI_TEXT_SELECTION_ENABLED | extraFlags; TIParams.MaxLength = 1024 * 1024 * 10; - TIParams.Font = Params.Font; - TIParams.FontColor = Params.FontColor; - TIParams.FontShadowColor = Params.FontShadowColor; + TIParams.fontStyleConfig = Params.fontStyleConfig; if ( Params.WordWrap && !( mFlags & UI_WORD_WRAP ) ) mFlags |= UI_WORD_WRAP; @@ -490,4 +488,14 @@ const UI_SCROLLBAR_MODE& UITextEdit::getHorizontalScrollMode() { return mHScrollBarMode; } +FontStyleConfig UITextEdit::getFontStyleConfig() const { + return mTextInput->getFontStyleConfig(); +} + +void UITextEdit::setFontStyleConfig(const FontStyleConfig & fontStyleConfig) { + if ( NULL != mTextInput ) { + mTextInput->setFontStyleConfig( fontStyleConfig ); + } +} + }} diff --git a/src/eepp/ui/uitextinput.cpp b/src/eepp/ui/uitextinput.cpp index cd8f3cdda..617e1d455 100644 --- a/src/eepp/ui/uitextinput.cpp +++ b/src/eepp/ui/uitextinput.cpp @@ -103,7 +103,7 @@ void UITextInput::drawWaitingCursor() { GLi->lineSmooth( false ); Primitives P; - P.setColor( mFontColor ); + P.setColor( mFontStyleConfig.fontColor ); Float CurPosX = mScreenPos.x + mRealAlignOffset.x + mCurPos.x + PixelDensity::dpToPxI( 1.f ) + mRealPadding.Left; Float CurPosY = mScreenPos.y + mRealAlignOffset.y + mCurPos.y + mRealPadding.Top; diff --git a/src/eepp/ui/uitextinputpassword.cpp b/src/eepp/ui/uitextinputpassword.cpp index 8a45e3631..ce5b27e62 100644 --- a/src/eepp/ui/uitextinputpassword.cpp +++ b/src/eepp/ui/uitextinputpassword.cpp @@ -10,9 +10,7 @@ UITextInputPassword::UITextInputPassword( const UITextInput::CreateParams& Param UITextInput( Params ) { mPassCache = eeNew( TextCache, () ); - mPassCache->setFont( mTextCache->getFont() ); - mPassCache->setColor( mFontColor ); - mPassCache->setShadowColor( mFontShadowColor ); + setFontStyleConfig( mFontStyleConfig ); autoAlign(); } @@ -21,9 +19,7 @@ UITextInputPassword::UITextInputPassword() : UITextInput() { mPassCache = eeNew( TextCache, () ); - mPassCache->setFont( mTextCache->getFont() ); - mPassCache->setColor( mFontColor ); - mPassCache->setShadowColor( mFontShadowColor ); + setFontStyleConfig( mFontStyleConfig ); autoAlign(); } @@ -137,6 +133,14 @@ TextCache *UITextInputPassword::getPassCache() const { return mPassCache; } +void UITextInputPassword::setFontStyleConfig(const FontStyleConfig & fontStyleConfig) { + UITextInput::setFontStyleConfig( fontStyleConfig ); + + mPassCache->setFont( mFontStyleConfig.getFont() ); + mPassCache->setColor( mFontStyleConfig.getFontColor() ); + mPassCache->setShadowColor( mFontStyleConfig.getFontShadowColor() ); +} + const String& UITextInputPassword::getText() { return UITextBox::getText(); } diff --git a/src/eepp/ui/uitheme.cpp b/src/eepp/ui/uitheme.cpp index d1aad3b53..9e76bc146 100644 --- a/src/eepp/ui/uitheme.cpp +++ b/src/eepp/ui/uitheme.cpp @@ -326,14 +326,16 @@ UITheme::UITheme(const std::string& name, const std::string& Abbr, Graphics::Fon mNameHash( String::hash( mName ) ), mAbbr( Abbr ), mTextureAtlas( NULL ), - mFont( defaultFont ), - mFontColor( 0, 0, 0, 255 ), - mFontShadowColor( 255, 255, 255, 200 ), - mFontOverColor( 0, 0, 0, 255 ), - mFontSelectedColor( 0, 0, 0, 255 ), - mFontSelectionBackColor( 150, 150, 150, 255 ), mUseDefaultThemeValues( true ) { + mFontStyleConfig.font = defaultFont; + mFontStyleConfig.fontShadowColor = ColorA( 255, 255, 255, 200 ); + mFontStyleConfig.fontColor = mFontStyleConfig.fontOverColor = mFontStyleConfig.fontSelectedColor = ColorA( 0, 0, 0, 255 ); + mFontStyleConfig.fontSelectionBackColor = ColorA( 150, 150, 150, 255 ); + + if ( NULL == defaultFont ) { + mFontStyleConfig.font = UIThemeManager::instance()->getDefaultFont(); + } } UITheme::~UITheme() { @@ -363,46 +365,6 @@ UISkin * UITheme::add( UISkin * Resource ) { return ResourceManager::add( Resource ); } -void UITheme::setFont( Graphics::Font * Font ) { - mFont = Font; -} - -Graphics::Font * UITheme::getFont() const { - return mFont; -} - -const ColorA& UITheme::getFontColor() const { - return mFontColor; -} - -const ColorA& UITheme::getFontShadowColor() const { - return mFontShadowColor; -} - -const ColorA& UITheme::getFontOverColor() const { - return mFontOverColor; -} - -const ColorA& UITheme::getFontSelectedColor() const { - return mFontSelectedColor; -} - -void UITheme::setFontColor( const ColorA& Color ) { - mFontColor = Color; -} - -void UITheme::setFontShadowColor( const ColorA& Color ) { - mFontShadowColor = Color; -} - -void UITheme::setFontOverColor( const ColorA& Color ) { - mFontOverColor = Color; -} - -void UITheme::setFontSelectedColor( const ColorA& Color ) { - mFontSelectedColor = Color; -} - void UITheme::setUseDefaultThemeValues( const bool& Use ) { mUseDefaultThemeValues = Use; } @@ -493,18 +455,6 @@ UITextBox * UITheme::createTextBox( const String& Text, UIControl * Parent, cons return Ctrl; } -UITooltip * UITheme::createTooltip( UIControl * TooltipOf, UIControl * Parent, const Sizei& Size, const Vector2i& Pos, const Uint32& Flags ) { - UITooltip::CreateParams TooltipParams; - TooltipParams.setParent( Parent ); - TooltipParams.setPosition( Pos ); - TooltipParams.setSize( Size ); - TooltipParams.Flags = Flags; - UITooltip * Ctrl = eeNew( UITooltip, ( TooltipParams, TooltipOf ) ); - Ctrl->setVisible( true ); - Ctrl->setEnabled( true ); - return Ctrl; -} - UITextEdit * UITheme::createTextEdit( UIControl * Parent, const Sizei& Size, const Vector2i& Pos, const Uint32& Flags, UI_SCROLLBAR_MODE HScrollBar, UI_SCROLLBAR_MODE VScrollBar, bool WordWrap ) { UITextEdit::CreateParams TextEditParams; TextEditParams.setParent( Parent ); @@ -590,19 +540,6 @@ UISlider * UITheme::createSlider( UIControl * Parent, const Sizei& Size, const V return Ctrl; } -UIComboBox * UITheme::createComboBox( UIControl * Parent, const Sizei& Size, const Vector2i& Pos, const Uint32& Flags, Uint32 MinNumVisibleItems, bool PopUpToMainControl, UIListBox * ListBox ) { - UIComboBox::CreateParams ComboParams; - ComboParams.setParent( Parent ); - ComboParams.setPosition( Pos ); - ComboParams.setSize( Size ); - ComboParams.Flags = Flags; - - UIComboBox * Ctrl = eeNew( UIComboBox, ( ComboParams ) ); - Ctrl->setVisible( true ); - Ctrl->setEnabled( true ); - return Ctrl; -} - UIDropDownList * UITheme::createDropDownList( UIControl * Parent, const Sizei& Size, const Vector2i& Pos, const Uint32& Flags, Uint32 MinNumVisibleItems, bool PopUpToMainControl, UIListBox * ListBox ) { UIDropDownList::CreateParams DDLParams; DDLParams.setParent( Parent ); @@ -665,23 +602,6 @@ UIPopUpMenu * UITheme::createPopUpMenu( UIControl * Parent, const Sizei& Size, c return eeNew( UIPopUpMenu, ( MenuParams ) ); } -UIProgressBar * UITheme::createProgressBar( UIControl * Parent, const Sizei& Size, const Vector2i& Pos, const Uint32& Flags, bool DisplayPercent, bool VerticalExpand, Vector2f MovementSpeed, Rectf FillerMargin ) { - UIProgressBar::CreateParams PBParams; - PBParams.setParent( Parent ); - PBParams.setPosition( Pos ); - PBParams.setSize( Size ); - PBParams.Flags = Flags; - PBParams.DisplayPercent = DisplayPercent; - PBParams.VerticalExpand = VerticalExpand; - PBParams.MovementSpeed = MovementSpeed; - PBParams.FillerMargin = FillerMargin; - - UIProgressBar * Ctrl = eeNew( UIProgressBar, ( PBParams ) ); - Ctrl->setVisible( true ); - Ctrl->setEnabled( true ); - return Ctrl; -} - UIPushButton * UITheme::createPushButton( UIControl * Parent, const Sizei& Size, const Vector2i& Pos, const Uint32& Flags, SubTexture * Icon, Int32 IconHorizontalMargin, bool IconAutoMargin ) { UIPushButton::CreateParams ButtonParams; ButtonParams.setParent( Parent ); @@ -726,10 +646,10 @@ UIWinMenu * UITheme::createWinMenu( UIControl * Parent, const Sizei& Size, const WinMenuParams.setPosition( Pos ); WinMenuParams.setSize( Size ); WinMenuParams.Flags = Flags; - WinMenuParams.MarginBetweenButtons = MarginBetweenButtons; - WinMenuParams.ButtonMargin = ButtonMargin; - WinMenuParams.MenuHeight = MenuHeight; - WinMenuParams.FirstButtonMargin = FirstButtonMargin; + WinMenuParams.marginBetweenButtons = MarginBetweenButtons; + WinMenuParams.buttonMargin = ButtonMargin; + WinMenuParams.menuHeight = MenuHeight; + WinMenuParams.firstButtonMargin = FirstButtonMargin; UIWinMenu * Ctrl = eeNew( UIWinMenu, ( WinMenuParams ) ); Ctrl->setVisible( true ); @@ -778,55 +698,72 @@ UIMessageBox * UITheme::createMessageBox( UI_MSGBOX_TYPE Type, const String& Mes return eeNew( UIMessageBox, ( MsgBoxParams ) ); } -UITabWidget * UITheme::createTabWidget( UIControl *Parent, const Sizei &Size, const Vector2i &Pos, const Uint32 &Flags, const bool &TabsClosable, const bool &SpecialBorderTabs, const Int32 &TabSeparation, const Uint32 &MaxTextLength, const Uint32 &TabWidgetHeight, const Uint32 &TabTextAlign, const Uint32 &MinTabWidth, const Uint32 &MaxTabWidth ) { - UITabWidget::CreateParams TabWidgetParams; - TabWidgetParams.setParent( Parent ); - TabWidgetParams.setPosition( Pos ); - TabWidgetParams.setSize( Size ); - TabWidgetParams.Flags = Flags; - TabWidgetParams.TabsClosable = TabsClosable; - TabWidgetParams.SpecialBorderTabs = SpecialBorderTabs; - TabWidgetParams.TabSeparation = TabSeparation; - TabWidgetParams.MaxTextLength = MaxTextLength; - TabWidgetParams.TabWidgetHeight = TabWidgetHeight; - TabWidgetParams.TabTextAlign = TabTextAlign; - TabWidgetParams.MinTabWidth = MinTabWidth; - TabWidgetParams.MaxTabWidth = MaxTabWidth; - - UITabWidget * Ctrl = eeNew( UITabWidget, ( TabWidgetParams ) ); - Ctrl->setVisible( true ); - Ctrl->setEnabled( true ); - return Ctrl; -} - -ColorA UITheme::getMenuFontColor() const -{ +ColorA UITheme::getMenuFontColor() const { return mMenuFontColor; } -void UITheme::setMenuFontColor(const ColorA & menuFontColor) -{ +void UITheme::setMenuFontColor(const ColorA & menuFontColor) { mMenuFontColor = menuFontColor; } -ColorA UITheme::getMenuFontColorOver() const -{ +ColorA UITheme::getMenuFontColorOver() const { return mMenuFontColorOver; } -void UITheme::setMenuFontColorOver(const ColorA & menuFontColorOver) -{ +void UITheme::setMenuFontColorOver(const ColorA & menuFontColorOver) { mMenuFontColorOver = menuFontColorOver; } -ColorA UITheme::getFontSelectionBackColor() const -{ - return mFontSelectionBackColor; +ColorA UITheme::getTooltipFontColor() const { + return mTooltipFontColor; } -void UITheme::setFontSelectionBackColor(const ColorA & fontSelectionBackColor) -{ - mFontSelectionBackColor = fontSelectionBackColor; +void UITheme::setTooltipFontColor(const ColorA & tooltipFontColor) { + mTooltipFontColor = tooltipFontColor; +} + +Recti UITheme::getTooltipPadding() const { + return mTooltipPadding; +} + +void UITheme::setTooltipPadding(const Recti & tooltipPadding) { + mTooltipPadding = tooltipPadding; +} + +Int32 UITheme::getTabSeparation() const { + return mTabSeparation; +} + +void UITheme::setTabSeparation(const Int32 & tabSeparation) { + mTabSeparation = tabSeparation; +} + +void UITheme::setFontStyleConfig(const FontStyleConfig & fontConfig) { + mFontStyleConfig = fontConfig; +} + +TabWidgetStyleConfig UITheme::getTabWidgetStyleConfig() { + TabWidgetStyleConfig tabWidgetStyleConfig( getFontStyleConfig() ); + tabWidgetStyleConfig.tabSeparation = 0; + tabWidgetStyleConfig.maxTextLength = 30; + tabWidgetStyleConfig.tabWidgetHeight = 0; + tabWidgetStyleConfig.tabTextAlign = ( UI_HALIGN_CENTER | UI_VALIGN_CENTER ); + tabWidgetStyleConfig.minTabWidth = 32; + tabWidgetStyleConfig.maxTabWidth = 210; + tabWidgetStyleConfig.tabsClosable = false; + tabWidgetStyleConfig.specialBorderTabs = false; + tabWidgetStyleConfig.drawLineBelowTabs = false; + tabWidgetStyleConfig.lineBelowTabsYOffset = 0; + return tabWidgetStyleConfig; +} + +ProgressBarStyleConfig UITheme::getProgressBarStyleConfig() { + ProgressBarStyleConfig progressBarStyleConfig( getFontStyleConfig() ); + return progressBarStyleConfig; +} + +FontStyleConfig UITheme::getFontStyleConfig() const { + return mFontStyleConfig; } }} diff --git a/src/eepp/ui/uithememanager.cpp b/src/eepp/ui/uithememanager.cpp index 41427ee5a..ddb3569ca 100644 --- a/src/eepp/ui/uithememanager.cpp +++ b/src/eepp/ui/uithememanager.cpp @@ -14,9 +14,9 @@ UIThemeManager::UIThemeManager() : mEnableDefaultEffects( false ), mFadeInTime( Milliseconds( 100.f ) ), mFadeOutTime( Milliseconds ( 100.f ) ), - mtooltipTimeToShow( Milliseconds( 200 ) ), - mtooltipFollowMouse( true ), - mcursorSize( 16, 16 ) + mTooltipTimeToShow( Milliseconds( 200 ) ), + mTooltipFollowMouse( true ), + mCursorSize( 16, 16 ) { } @@ -25,6 +25,15 @@ UIThemeManager::~UIThemeManager() { void UIThemeManager::setDefaultFont( Font * Font ) { mFont = Font; + + if ( NULL != mThemeDefault ) { + FontStyleConfig fontStyleConfig = mThemeDefault->getFontStyleConfig(); + + if ( NULL == fontStyleConfig.getFont() && NULL != mFont ) { + fontStyleConfig.font = mFont; + mThemeDefault->setFontStyleConfig( fontStyleConfig ); + } + } } Font * UIThemeManager::getDefaultFont() const { @@ -46,6 +55,13 @@ void UIThemeManager::setTheme( UITheme * Theme ) { void UIThemeManager::setDefaultTheme( UITheme * Theme ) { mThemeDefault = Theme; + + FontStyleConfig fontStyleConfig = mThemeDefault->getFontStyleConfig(); + + if ( NULL == fontStyleConfig.getFont() && NULL != mFont ) { + fontStyleConfig.font = mFont; + mThemeDefault->setFontStyleConfig( fontStyleConfig ); + } } void UIThemeManager::setDefaultTheme( const std::string& Theme ) { @@ -94,27 +110,35 @@ void UIThemeManager::setControlsFadeOutTime( const Time& Time ) { } void UIThemeManager::setTooltipTimeToShow( const Time& Time ) { - mtooltipTimeToShow = Time; + mTooltipTimeToShow = Time; } const Time& UIThemeManager::getTooltipTimeToShow() const { - return mtooltipTimeToShow; + return mTooltipTimeToShow; } void UIThemeManager::setTooltipFollowMouse( const bool& Follow ) { - mtooltipFollowMouse = Follow; + mTooltipFollowMouse = Follow; } const bool& UIThemeManager::getTooltipFollowMouse() const { - return mtooltipFollowMouse; + return mTooltipFollowMouse; } void UIThemeManager::setCursorSize( const Sizei& Size ) { - mcursorSize = Size; + mCursorSize = Size; } const Sizei& UIThemeManager::getCursorSize() const { - return mcursorSize; + return mCursorSize; +} + +FontStyleConfig UIThemeManager::getDefaultFontStyleConfig() { + if ( NULL != getDefaultTheme() ) { + return getDefaultTheme()->getFontStyleConfig(); + } + + return FontStyleConfig(); } }} diff --git a/src/eepp/ui/uitooltip.cpp b/src/eepp/ui/uitooltip.cpp index 92d004a10..51c58f3db 100644 --- a/src/eepp/ui/uitooltip.cpp +++ b/src/eepp/ui/uitooltip.cpp @@ -5,34 +5,38 @@ namespace EE { namespace UI { -UITooltip::UITooltip( UITooltip::CreateParams& Params, UIControl * TooltipOf ) : - UIControlAnim( Params ), - mFontColor( Params.FontColor ), - mFontShadowColor( Params.FontShadowColor ), +UITooltip::UITooltip() : + UIControlAnim(), mAlignOffset( 0.f, 0.f ), - mPadding( Params.Padding ), + mPadding(), mTooltipTime( Time::Zero ), - mTooltipOf( TooltipOf ) + mTooltipOf() { - setPadding( mPadding ); + setFlags( UI_CONTROL_DEFAULT_FLAGS_CENTERED | UI_AUTO_PADDING | UI_AUTO_SIZE ); mTextCache = eeNew( TextCache, () ); - mTextCache->setFont( Params.Font ); - mTextCache->setColor( mFontColor ); - mTextCache->setShadowColor( mFontShadowColor ); - if ( NULL == Params.Font ) { - if ( NULL != UIThemeManager::instance()->getDefaultFont() ) - mTextCache->setFont( UIThemeManager::instance()->getDefaultFont() ); - else - eePRINTL( "UITooltip::UITextBox : Created a UI TextBox without a defined font." ); + mFontStyleConfig = UIThemeManager::instance()->getDefaultFontStyleConfig(); + + UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); + + if ( NULL != Theme ) { + if ( Theme->getTooltipPadding() != Recti() ) + setPadding( Theme->getTooltipPadding() ); + + setFont( mFontStyleConfig.font ); + setFontColor( Theme->getTooltipFontColor() ); + setFontShadowColor( mFontStyleConfig.fontShadowColor ); + } + + if ( NULL == getFont() && NULL != UIThemeManager::instance()->getDefaultFont() ) { + setFont( UIThemeManager::instance()->getDefaultFont() ); + } else { + eePRINTL( "UITooltip::UITooltip : Created a UI TextBox without a defined font." ); } autoPadding(); - if ( Params.ParentCtrl != UIManager::instance()->getMainControl() ) - setParent( UIManager::instance()->getMainControl() ); - applyDefaultTheme(); } @@ -56,14 +60,10 @@ void UITooltip::setTheme( UITheme * Theme ) { UIControl::setThemeControl( Theme, "tooltip" ); autoPadding(); - - if ( NULL == mTextCache->getFont() && NULL != Theme->getFont() ) { - mTextCache->setFont( Theme->getFont() ); - } } void UITooltip::autoPadding() { - if ( mFlags & UI_AUTO_PADDING ) { + if ( ( mFlags & UI_AUTO_PADDING ) && mPadding == Recti() ) { setPadding( makePadding( true, true, true, true ) ); } } @@ -127,31 +127,32 @@ void UITooltip::setText( const String& text ) { onTextChanged(); } -const ColorA& UITooltip::getColor() const { - return mFontColor; +const ColorA& UITooltip::getFontColor() const { + return mFontStyleConfig.fontColor; } -void UITooltip::setColor( const ColorA& color ) { - mFontColor = color; +void UITooltip::setFontColor( const ColorA& color ) { + mFontStyleConfig.fontColor = color; + mTextCache->setColor( mFontStyleConfig.fontColor ); setAlpha( color.a() ); } -const ColorA& UITooltip::getShadowColor() const { - return mFontShadowColor; +const ColorA& UITooltip::getFontShadowColor() const { + return mFontStyleConfig.fontShadowColor; } -void UITooltip::setShadowColor( const ColorA& color ) { - mFontShadowColor = color; +void UITooltip::setFontShadowColor( const ColorA& color ) { + mFontStyleConfig.fontShadowColor = color; setAlpha( color.a() ); - mTextCache->setShadowColor( mFontColor ); + mTextCache->setShadowColor( mFontStyleConfig.fontShadowColor ); } void UITooltip::setAlpha( const Float& alpha ) { UIControlAnim::setAlpha( alpha ); - mFontColor.Alpha = (Uint8)alpha; - mFontShadowColor.Alpha = (Uint8)alpha; + mFontStyleConfig.fontColor.Alpha = (Uint8)alpha; + mFontStyleConfig.fontShadowColor.Alpha = (Uint8)alpha; - mTextCache->setColor( mFontColor ); + mTextCache->setColor( mFontStyleConfig.fontColor ); } void UITooltip::autoSize() { @@ -252,4 +253,24 @@ const Time& UITooltip::getTooltipTime() const { return mTooltipTime; } +UIControl * UITooltip::getTooltipOf() const { + return mTooltipOf; +} + +void UITooltip::setTooltipOf(UIControl * tooltipOf) { + mTooltipOf = tooltipOf; +} + +FontStyleConfig UITooltip::getFontStyleConfig() const { + return mFontStyleConfig; +} + +void UITooltip::setFontStyleConfig(const FontStyleConfig & fontStyleConfig) { + mFontStyleConfig = fontStyleConfig; + + setFont( mFontStyleConfig.font ); + setFontColor( mFontStyleConfig.fontColor ); + setFontShadowColor( mFontStyleConfig.fontShadowColor ); +} + }} diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index 5ab042bff..8ce566e95 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -881,7 +881,7 @@ void UIWindow::setTitle( const String& Text ) { UITextBox::CreateParams Params; Params.setParent( this ); Params.Flags = UI_CLIP_ENABLE | UI_VALIGN_CENTER; - Params.FontColor = mTitleFontColor; + Params.fontStyleConfig.fontColor = mTitleFontColor; if ( mFlags & UI_HALIGN_CENTER ) Params.Flags |= UI_HALIGN_CENTER; diff --git a/src/eepp/ui/uiwinmenu.cpp b/src/eepp/ui/uiwinmenu.cpp index afef886c8..01fb4545c 100644 --- a/src/eepp/ui/uiwinmenu.cpp +++ b/src/eepp/ui/uiwinmenu.cpp @@ -6,16 +6,12 @@ namespace EE { namespace UI { UIWinMenu::UIWinMenu( const UIWinMenu::CreateParams& Params ) : UIComplexControl( Params ), - mFont( Params.Font ), - mFontColor( Params.FontColor ), - mFontShadowColor( Params.FontShadowColor ), - mFontOverColor( Params.FontOverColor ), - mFontSelectedColor( Params.FontSelectedColor ), + mFontStyleConfig( Params.fontStyleConfig ), mCurrentMenu( NULL ), - mMarginBetweenButtons( Params.MarginBetweenButtons ), - mButtonMargin( Params.ButtonMargin ), - mFirstButtonMargin( Params.FirstButtonMargin ), - mMenuHeight( Params.MenuHeight ) + mMarginBetweenButtons( Params.marginBetweenButtons ), + mButtonMargin( Params.buttonMargin ), + mFirstButtonMargin( Params.firstButtonMargin ), + mMenuHeight( Params.menuHeight ) { if ( !(mFlags & UI_ANCHOR_RIGHT) ) mFlags |= UI_ANCHOR_RIGHT; @@ -38,18 +34,7 @@ UIWinMenu::UIWinMenu() : if ( !(mFlags & UI_ANCHOR_RIGHT) ) mFlags |= UI_ANCHOR_RIGHT; - UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); - - if ( NULL != Theme ) { - mFont = Theme->getFont(); - mFontColor = Theme->getFontColor(); - mFontShadowColor = Theme->getFontShadowColor(); - mFontOverColor = Theme->getFontOverColor(); - mFontSelectedColor = Theme->getFontSelectedColor(); - } - - if ( NULL == mFont ) - mFont = UIThemeManager::instance()->getDefaultFont(); + mFontStyleConfig = UIThemeManager::instance()->getDefaultFontStyleConfig(); onParentChange(); @@ -78,10 +63,7 @@ void UIWinMenu::addMenuButton( const String& ButtonText, UIPopUpMenu * Menu ) { if ( mFlags & UI_DRAW_SHADOW ) ButtonParams.Flags |= UI_DRAW_SHADOW; - ButtonParams.Font = mFont; - ButtonParams.FontColor = mFontColor; - ButtonParams.FontShadowColor = mFontShadowColor; - ButtonParams.FontOverColor = mFontOverColor; + ButtonParams.fontStyleConfig = mFontStyleConfig; UISelectButton * Button = eeNew( UISelectButton, ( ButtonParams ) ); Button->setText( ButtonText ); @@ -149,15 +131,6 @@ UIPopUpMenu * UIWinMenu::getPopUpMenu( const String& ButtonText ) { return NULL; } -ColorA UIWinMenu::getFontShadowColor() const { - return mFontShadowColor; -} - -void UIWinMenu::setFontShadowColor(const ColorA & fontShadowColor) { - mFontShadowColor = fontShadowColor; - refreshButtons(); -} - Uint32 UIWinMenu::getMarginBetweenButtons() const { return mMarginBetweenButtons; } @@ -167,8 +140,12 @@ void UIWinMenu::setMarginBetweenButtons(const Uint32 & marginBetweenButtons) { refreshButtons(); } -void UIWinMenu::setFont(Graphics::Font * font) { - mFont = font; +FontStyleConfig UIWinMenu::getFontStyleConfig() const { + return mFontStyleConfig; +} + +void UIWinMenu::setFontStyleConfig(const FontStyleConfig & fontStyleConfig) { + mFontStyleConfig = fontStyleConfig; refreshButtons(); } @@ -208,10 +185,7 @@ void UIWinMenu::refreshButtons() { UISelectButton * pbut = it->first; UITextBox * tbox = pbut->getTextBox(); - pbut->setFont( mFont ); - pbut->setFontColor( mFontColor ); - pbut->setFontOverColor( mFontOverColor ); - pbut->setFontShadowColor( mFontShadowColor ); + pbut->setFontStyleConfig( mFontStyleConfig ); pbut->setSize( PixelDensity::pxToDpI( tbox->getTextWidth() ) + mButtonMargin, getSize().getHeight() ); pbut->setPosition( xpos, ycenter ); @@ -329,35 +303,6 @@ void UIWinMenu::onComplexControlFocusLoss() { unselectButtons(); } - -void UIWinMenu::setFontColor( const ColorA& Color ) { - mFontColor = Color; -} - -const ColorA& UIWinMenu::getFontColor() const { - return mFontColor; -} - -void UIWinMenu::setFontOverColor( const ColorA& Color ) { - mFontOverColor = Color; -} - -const ColorA& UIWinMenu::getFontOverColor() const { - return mFontOverColor; -} - -void UIWinMenu::setFontSelectedColor( const ColorA& Color ) { - mFontSelectedColor = Color; -} - -const ColorA& UIWinMenu::getFontSelectedColor() const { - return mFontSelectedColor; -} - -Graphics::Font * UIWinMenu::getFont() const { - return mFont; -} - void UIWinMenu::destroyMenues() { if ( !UIManager::instance()->isShootingDown() ) { for ( WinMenuList::iterator it = mButtons.begin(); it != mButtons.end(); it++ ) { diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index e327c9b35..65178f5ce 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -426,7 +426,8 @@ void EETest::createUI() { mScrollBar->setEnabled( true ); mScrollBar->addEventListener( UIEvent::EventOnValueChange, cb::Make1( this, &EETest::onValueChange ) ); - mProgressBar = mTheme->createProgressBar( C, Sizei( 200, 20 ), Vector2i( 20, 190 ) ); + mProgressBar = UIProgressBar::New(); + mProgressBar->setParent( C )->setSize( 200, 24 )->setPosition( 20, 190 ); TextParams.setPosition( 20, 5 ); mTextBoxValue = eeNew( UITextBox, ( TextParams ) ); @@ -466,15 +467,8 @@ void EETest::createUI() { mDropDownList->getListBox()->addListBoxItems( combostrs ); mDropDownList->getListBox()->setSelected( 0 ); - UIComboBox::CreateParams ComboParams; - ComboParams.setParent( C ); - ComboParams.setPosition( 20, 80 ); - ComboParams.Size = Sizei( 100, 1 ); - ComboParams.Flags = UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_VALIGN_CENTER | UI_HALIGN_LEFT | UI_AUTO_SIZE | UI_TOUCH_DRAG_ENABLED | UI_TEXT_SELECTION_ENABLED; - UIComboBox * mComboBox = eeNew( UIComboBox, ( ComboParams ) ); - mComboBox->setVisible( true ); - mComboBox->setEnabled( true ); - + UIComboBox * mComboBox = UIComboBox::New(); + mComboBox->setParent( C )->setPosition( 20, 80 )->setSize( 100, 1 ); mComboBox->getListBox()->addListBoxItems( combostrs ); mComboBox->getListBox()->setSelected( 0 ); @@ -797,7 +791,11 @@ void EETest::createDecoratedWindow() { mUIWindow->addShortcut( KEY_C, KEYMOD_ALT, Button ); - UITabWidget * TabWidget = mTheme->createTabWidget( mUIWindow->getContainer(), Sizei( 510, 250 ), Vector2i( 10, 55 ), UI_HALIGN_CENTER | UI_VALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM | UI_ANCHOR_LEFT | UI_ANCHOR_TOP ); + UITabWidget * TabWidget = UITabWidget::New(); + TabWidget->setParent( mUIWindow->getContainer() )->setSize( 510, 250 )->setPosition( 10, 55 )-> + setFlags( UI_HALIGN_CENTER | UI_VALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM | UI_ANCHOR_LEFT | UI_ANCHOR_TOP ); + + //mTheme->createTabWidget( mUIWindow->getContainer(), Sizei( 510, 250 ), Vector2i( 10, 55 ), UI_HALIGN_CENTER | UI_VALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM | UI_ANCHOR_LEFT | UI_ANCHOR_TOP ); UITextEdit * TEdit = mTheme->createTextEdit( TabWidget, Sizei(), Vector2i() ); TEdit->setText( mBuda );