Working on a new way to style the widgets from the themes.

--HG--
branch : dev
This commit is contained in:
Martí­n Lucas Golini
2017-02-28 05:35:51 -03:00
parent 39eb7e8f01
commit 5ddbc69a9f
46 changed files with 743 additions and 1126 deletions

View File

@@ -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();
};
}}

View File

@@ -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();

View File

@@ -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 );

View File

@@ -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 );
};
}}

View File

@@ -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<UIListBox>;
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<UIListBox> * mContainer;
UIScrollBar * mVScrollBar;
UIScrollBar * mHScrollBar;
Graphics::Font * mFont;
ColorA mFontColor;
ColorA mFontOverColor;
ColorA mFontSelectedColor;
Uint32 mLastPos;
Uint32 mMaxTextWidth;
Int32 mHScrollInit;

View File

@@ -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<UIControl *> mItems;
Recti mPadding;
Font * mFont;
ColorA mFontColor;
ColorA mFontShadowColor;
ColorA mFontOverColor;
ColorA mFontSelectedColor;
FontStyleConfig mFontStyleConfig;
Uint32 mMinWidth;
Uint32 mMinSpaceForIcons;
Uint32 mMinRightMargin;

View File

@@ -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();

View File

@@ -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;

View File

@@ -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;
};
}}

View File

@@ -30,7 +30,6 @@ class EE_API UITab : public UISelectButton {
virtual void setText( const String& text );
virtual void update();
protected:
UIControl * mControlOwned;

View File

@@ -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<UITab*> mTabs;
UITab * mTabSelected;
Uint32 mTabSelectedIndex;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -2,6 +2,7 @@
#define EE_UICUITHEME_HPP
#include <eepp/ui/base.hpp>
#include <eepp/ui/uithemeconfig.hpp>
#include <eepp/ui/uihelper.hpp>
#include <eepp/ui/uiskin.hpp>
#include <eepp/system/resourcemanager.hpp>
@@ -74,30 +75,6 @@ class EE_API UITheme : protected ResourceManager<UISkin> {
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<UISkin> {
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<UISkin> {
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<UISkin> {
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<UISkin> {
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<std::string> mUIElements;
std::list<std::string> mUIIcons;

View File

@@ -0,0 +1,127 @@
#ifndef EE_UICUITHEMECONFIG_HPP
#define EE_UICUITHEMECONFIG_HPP
#include <eepp/ui/base.hpp>
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

View File

@@ -57,6 +57,8 @@ class EE_API UIThemeManager : public ResourceManager<UITheme> {
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<UITheme> {
Time mFadeInTime;
Time mFadeOutTime;
Time mtooltipTimeToShow;
bool mtooltipFollowMouse;
Time mTooltipTimeToShow;
bool mTooltipFollowMouse;
Sizei mcursorSize;
Sizei mCursorSize;
UIThemeManager();
};

View File

@@ -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;

View File

@@ -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;