diff --git a/include/eepp/gaming/mapeditor/mapeditor.hpp b/include/eepp/gaming/mapeditor/mapeditor.hpp index 310f4f0f9..80d0f8531 100644 --- a/include/eepp/gaming/mapeditor/mapeditor.hpp +++ b/include/eepp/gaming/mapeditor/mapeditor.hpp @@ -11,7 +11,7 @@ namespace EE { namespace UI { class UIMessageBox; -class UITextBox; +class UITextView; }} using namespace EE::UI; @@ -37,9 +37,9 @@ class EE_API MapEditor { Private::UIMap * mUIMap; MapEditorCloseCb mCloseCb; UIDropDownList * mTextureAtlasesList; - UIComplexControl * mWinContainer; + UIWidget * mWinContainer; UIListBox * mSubTextureList; - UIGfx * mGfxPreview; + UIImage * mGfxPreview; TextureAtlas * mCurSG; UIScrollBar * mMapHScroll; UIScrollBar * mMapVScroll; @@ -55,11 +55,11 @@ class EE_API MapEditor { UIPushButton * mBtnGOTypeAdd; Uint32 mCurGOType; Uint32 mCurGOFlags; - UIComplexControl * mSubTextureCont; - UIComplexControl * mLightCont; - UIComplexControl * mObjectCont; - UIComplexControl * mSGCont; - UIComplexControl * mDICont; + UIWidget * mSubTextureCont; + UIWidget * mLightCont; + UIWidget * mObjectCont; + UIWidget * mSGCont; + UIWidget * mDICont; UICheckBox * mChkDI; UITextInput * mDataIdInput; UIMenuCheckBox * mLayerChkVisible; @@ -71,16 +71,16 @@ class EE_API MapEditor { UICheckBox * mChkClampToTile; //! Light Color - UIComplexControl * mUIBaseColor; + UIWidget * mUIBaseColor; UISlider * mUIRedSlider; UISlider * mUIGreenSlider; UISlider * mUIBlueSlider; - UITextBox * mUIRedTxt; - UITextBox * mUIGreenTxt; - UITextBox * mUIBlueTxt; + UITextView * mUIRedTxt; + UITextView * mUIGreenTxt; + UITextView * mUIBlueTxt; UISpinBox * mLightRadius; UICheckBox * mLightTypeChk; - UITextBox * mTileBox; + UITextView * mTileBox; Int32 mLastSelButtonY; bool mMouseScrolling; diff --git a/include/eepp/ui.hpp b/include/eepp/ui.hpp index 868246a77..100e77c29 100644 --- a/include/eepp/ui.hpp +++ b/include/eepp/ui.hpp @@ -14,10 +14,10 @@ #include #include #include -#include +#include #include -#include -#include +#include +#include #include #include #include @@ -33,12 +33,12 @@ #include #include #include -#include +#include #include #include #include -#include -#include +#include +#include #include #include #include @@ -46,6 +46,7 @@ #include #include #include +#include #include #include diff --git a/include/eepp/ui/tools/textureatlaseditor.hpp b/include/eepp/ui/tools/textureatlaseditor.hpp index 838a2fd5d..d1f75ad3e 100644 --- a/include/eepp/ui/tools/textureatlaseditor.hpp +++ b/include/eepp/ui/tools/textureatlaseditor.hpp @@ -71,7 +71,7 @@ class EE_API TextureAtlasEditor { void onSubTextureChange( const UIEvent * Event ); - UITextBox * createTextBox( Vector2i Pos, const String& Text ); + UITextView * createTextBox( Vector2i Pos, const String& Text ); void updateControls(); diff --git a/include/eepp/ui/uicheckbox.hpp b/include/eepp/ui/uicheckbox.hpp index 4b07047d3..1bbf4e1b8 100644 --- a/include/eepp/ui/uicheckbox.hpp +++ b/include/eepp/ui/uicheckbox.hpp @@ -1,12 +1,12 @@ #ifndef EE_UICUICHECKBOX_H #define EE_UICUICHECKBOX_H -#include +#include #include namespace EE { namespace UI { -class EE_API UICheckBox : public UITextBox { +class EE_API UICheckBox : public UITextView { public: static UICheckBox * New(); @@ -24,8 +24,6 @@ class EE_API UICheckBox : public UITextBox { void setActive( const bool& active ); - virtual void setPadding( const Recti& padding ); - UIControlAnim * getActiveButton() const; UIControlAnim * getInactiveButton() const; @@ -53,6 +51,8 @@ class EE_API UICheckBox : public UITextBox { virtual void onThemeLoaded(); virtual void onAutoSize(); + + virtual void onPaddingChange(); }; }} diff --git a/include/eepp/ui/uicombobox.hpp b/include/eepp/ui/uicombobox.hpp index 7992e7436..af5d58f32 100644 --- a/include/eepp/ui/uicombobox.hpp +++ b/include/eepp/ui/uicombobox.hpp @@ -5,7 +5,7 @@ namespace EE { namespace UI { -class EE_API UIComboBox : public UIComplexControl { +class EE_API UIComboBox : public UIWidget { public: static UIComboBox * New(); diff --git a/include/eepp/ui/uicommondialog.hpp b/include/eepp/ui/uicommondialog.hpp index 484fe5187..9a66c0e38 100644 --- a/include/eepp/ui/uicommondialog.hpp +++ b/include/eepp/ui/uicommondialog.hpp @@ -2,7 +2,7 @@ #define EE_UICUICOMMONDIALOG_HPP #include -#include +#include #include #include #include diff --git a/include/eepp/ui/uicomplexcontrol.hpp b/include/eepp/ui/uicomplexcontrol.hpp deleted file mode 100644 index 884fd4690..000000000 --- a/include/eepp/ui/uicomplexcontrol.hpp +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef EE_UICUICOMPLEXCONTROL_HPP -#define EE_UICUICOMPLEXCONTROL_HPP - -#include -#include - -namespace EE { namespace UI { - -class EE_API UIComplexControl : public UIControlAnim { - public: - static UIComplexControl * New(); - - UIComplexControl(); - - virtual ~UIComplexControl(); - - virtual Uint32 getType() const; - - virtual bool isType( const Uint32& type ) const; - - virtual void update(); - - virtual UIControl * setSize( const Sizei& size ); - - virtual UIControl * setFlags( const Uint32& flags ); - - virtual UIControl * unsetFlags( const Uint32& flags ); - - virtual UIComplexControl * setAnchors( const Uint32& flags ); - - UIControl * setSize( const Int32& Width, const Int32& Height ); - - const Sizei& getSize(); - - UITooltip * getTooltip(); - - void tooltipRemove(); - - void setTooltipText( const String& Text ); - - String getTooltipText(); - - void updateAnchorsDistances(); - protected: - UITooltip * mTooltip; - Sizei mMinControlSize; - Recti mDistToBorder; - - void createTooltip(); - - virtual void onParentSizeChange( const Vector2i& SizeChange ); - - virtual void onPositionChange(); - - virtual void onAutoSize(); - - void updateAnchors( const Vector2i & SizeChange ); -}; - -}} - -#endif diff --git a/include/eepp/ui/uicontrol.hpp b/include/eepp/ui/uicontrol.hpp index 5482a8370..4c3c2553c 100644 --- a/include/eepp/ui/uicontrol.hpp +++ b/include/eepp/ui/uicontrol.hpp @@ -153,7 +153,7 @@ class EE_API UIControl { Uint32 isDragable(); - Uint32 isComplex(); + Uint32 isWidget(); Uint32 isClipped(); @@ -232,6 +232,8 @@ class EE_API UIControl { Uint32 getIdHash() const; UIControl * find( const std::string& id ); + + UIControl * getWindowContainer(); protected: typedef std::map< Uint32, std::map > UIEventsMap; friend class UIManager; @@ -335,6 +337,8 @@ class EE_API UIControl { virtual void onThemeLoaded(); + virtual void onChildCountChange(); + virtual UIControl * overFind( const Vector2f& Point ); void clipMe(); diff --git a/include/eepp/ui/uicontrolanim.hpp b/include/eepp/ui/uicontrolanim.hpp index 09fae5e93..d611898e9 100644 --- a/include/eepp/ui/uicontrolanim.hpp +++ b/include/eepp/ui/uicontrolanim.hpp @@ -3,11 +3,11 @@ #include #include -#include +#include namespace EE { namespace UI { -class EE_API UIControlAnim : public UIDragable { +class EE_API UIControlAnim : public UIDragableControl { public: static UIControlAnim * New(); diff --git a/include/eepp/ui/uidragable.hpp b/include/eepp/ui/uidragablecontrol.hpp similarity index 87% rename from include/eepp/ui/uidragable.hpp rename to include/eepp/ui/uidragablecontrol.hpp index 9ffca9ae9..5a6325ef3 100644 --- a/include/eepp/ui/uidragable.hpp +++ b/include/eepp/ui/uidragablecontrol.hpp @@ -5,11 +5,11 @@ namespace EE { namespace UI { -class EE_API UIDragable : public UIControl { +class EE_API UIDragableControl : public UIControl { public: - static UIDragable * New(); + static UIDragableControl * New(); - UIDragable(); + UIDragableControl(); virtual Uint32 getType() const; @@ -33,7 +33,7 @@ class EE_API UIDragable : public UIControl { const Uint32& getDragButton() const; protected: - virtual ~UIDragable(); + virtual ~UIDragableControl(); Vector2i mDragPoint; Uint32 mDragButton; diff --git a/include/eepp/ui/uihelper.hpp b/include/eepp/ui/uihelper.hpp index b272f08a6..8d329468c 100644 --- a/include/eepp/ui/uihelper.hpp +++ b/include/eepp/ui/uihelper.hpp @@ -71,10 +71,10 @@ enum UI_CONTROL_TYPES { UI_TYPE_CONTROL = 0, UI_TYPE_CONTROL_DRAGABLE, UI_TYPE_CONTROL_ANIM, - UI_TYPE_CONTROL_COMPLEX, - UI_TYPE_GFX, + UI_TYPE_WIDGET, + UI_TYPE_IMAGE, UI_TYPE_SPRITE, - UI_TYPE_TEXTBOX, + UI_TYPE_TEXTVIEW, UI_TYPE_TEXTINPUT, UI_TYPE_PUSHBUTTON, UI_TYPE_CHECKBOX, @@ -86,7 +86,7 @@ enum UI_CONTROL_TYPES { UI_TYPE_LISTBOX, UI_TYPE_LISTBOXITEM, UI_TYPE_DROPDOWNLIST, - UI_TYPE_SEPARATOR, + UI_TYPE_MENU_SEPARATOR, UI_TYPE_COMBOBOX, UI_TYPE_MENU, UI_TYPE_MENUITEM, @@ -94,7 +94,7 @@ enum UI_CONTROL_TYPES { UI_TYPE_MENUSUBMENU, UI_TYPE_TEXTEDIT, UI_TYPE_TOOLTIP, - UI_TYPE_GENERICGRID, + UI_TYPE_TABLE, UI_TYPE_WINDOW, UI_TYPE_WINMENU, UI_TYPE_SELECTBUTTON, @@ -102,6 +102,7 @@ enum UI_CONTROL_TYPES { UI_TYPE_COMMONDIALOG, UI_TYPE_TAB, UI_TYPE_TABWIDGET, + UI_TYPE_LINEAR_LAYOUT, UI_TYPE_USER = 100 }; @@ -150,6 +151,12 @@ enum UI_ORIENTATION { UI_HORIZONTAL }; +enum LayoutSizeRules { + FIXED, + MATCH_PARENT, + WRAP_CONTENT +}; + static const Uint32 UI_CONTROL_DEFAULT_ALIGN = UI_HALIGN_LEFT | UI_VALIGN_CENTER; static const Uint32 UI_CONTROL_ALIGN_CENTER = UI_HALIGN_CENTER | UI_VALIGN_CENTER; diff --git a/include/eepp/ui/uigfx.hpp b/include/eepp/ui/uiimage.hpp similarity index 85% rename from include/eepp/ui/uigfx.hpp rename to include/eepp/ui/uiimage.hpp index 504901e09..f59d16777 100644 --- a/include/eepp/ui/uigfx.hpp +++ b/include/eepp/ui/uiimage.hpp @@ -1,17 +1,17 @@ #ifndef EE_UICUIGFX_H #define EE_UICUIGFX_H -#include +#include namespace EE { namespace UI { -class EE_API UIGfx : public UIComplexControl { +class EE_API UIImage : public UIWidget { public: - static UIGfx * New(); + static UIImage * New(); - UIGfx(); + UIImage(); - virtual ~UIGfx(); + virtual ~UIImage(); virtual Uint32 getType() const; diff --git a/include/eepp/ui/uilinearlayout.hpp b/include/eepp/ui/uilinearlayout.hpp new file mode 100644 index 000000000..2551d5ebc --- /dev/null +++ b/include/eepp/ui/uilinearlayout.hpp @@ -0,0 +1,48 @@ +#ifndef UI_UILINEARLAYOUT_HPP +#define UI_UILINEARLAYOUT_HPP + +#include + +namespace EE { namespace UI { + +class UILinearLayout : public UIWidget { + public: + static UILinearLayout * New(); + + static UILinearLayout * NewVertical(); + + static UILinearLayout * NewHorizontal(); + + UILinearLayout(); + + virtual Uint32 getType() const; + + virtual bool isType( const Uint32& type ) const; + + UI_ORIENTATION getOrientation() const; + + UILinearLayout * setOrientation(const UI_ORIENTATION & getOrientation); + + UILinearLayout * add( UIWidget * widget ); + protected: + UI_ORIENTATION mOrientation; + + virtual void onSizeChange(); + + virtual void onParentSizeChange( const Vector2i& SizeChange ); + + virtual void onChildCountChange(); + + void pack(); + + void packVertical(); + + void packHorizontal(); + + Sizei getTotalUsedSize(); +}; + +}} + +#endif + diff --git a/include/eepp/ui/uilistbox.hpp b/include/eepp/ui/uilistbox.hpp index 489c4f38f..a4ca66f82 100644 --- a/include/eepp/ui/uilistbox.hpp +++ b/include/eepp/ui/uilistbox.hpp @@ -8,7 +8,7 @@ namespace EE { namespace UI { -class EE_API UIListBox : public UIComplexControl { +class EE_API UIListBox : public UIWidget { public: static UIListBox * New(); @@ -120,20 +120,20 @@ class EE_API UIListBox : public UIComplexControl { void setTouchDragDeceleration(const Float & touchDragDeceleration); - TooltipStyleConfig getFontStyleConfig() const; + FontStyleConfig getFontStyleConfig() const; - void setFontStyleConfig(const TooltipStyleConfig & fontStyleConfig); + void setFontStyleConfig(const FontStyleConfig & fontStyleConfig); protected: friend class UIListBoxItem; friend class UIItemContainer; friend class UIDropDownList; - TooltipStyleConfig mFontStyleConfig; + FontStyleConfig mFontStyleConfig; Uint32 mRowHeight; UI_SCROLLBAR_MODE mVScrollMode; UI_SCROLLBAR_MODE mHScrollMode; bool mSmoothScroll; - Recti mPaddingContainer; + Recti mContainerPadding; Recti mHScrollPadding; Recti mVScrollPadding; UIItemContainer * mContainer; diff --git a/include/eepp/ui/uilistboxitem.hpp b/include/eepp/ui/uilistboxitem.hpp index afa6a9c3c..4424c95c6 100644 --- a/include/eepp/ui/uilistboxitem.hpp +++ b/include/eepp/ui/uilistboxitem.hpp @@ -1,14 +1,14 @@ #ifndef EE_UICUILISTBOXITEM_HPP #define EE_UICUILISTBOXITEM_HPP -#include +#include #include namespace EE { namespace UI { class UIListBox; -class EE_API UIListBoxItem : public UITextBox { +class EE_API UIListBoxItem : public UITextView { public: static UIListBoxItem * New(); diff --git a/include/eepp/ui/uimenu.hpp b/include/eepp/ui/uimenu.hpp index 20a3490f1..c259ab0bb 100644 --- a/include/eepp/ui/uimenu.hpp +++ b/include/eepp/ui/uimenu.hpp @@ -5,12 +5,12 @@ #include #include #include -#include +#include #include namespace EE { namespace UI { -class EE_API UIMenu : public UIComplexControl { +class EE_API UIMenu : public UIWidget { public: static UIMenu * New(); diff --git a/include/eepp/ui/uiseparator.hpp b/include/eepp/ui/uimenuseparator.hpp similarity index 67% rename from include/eepp/ui/uiseparator.hpp rename to include/eepp/ui/uimenuseparator.hpp index 7974a6b42..02e3f0c35 100644 --- a/include/eepp/ui/uiseparator.hpp +++ b/include/eepp/ui/uimenuseparator.hpp @@ -5,13 +5,13 @@ namespace EE { namespace UI { -class EE_API UISeparator : public UIControlAnim { +class EE_API UIMenuSeparator : public UIControlAnim { public: - static UISeparator * New(); + static UIMenuSeparator * New(); - UISeparator(); + UIMenuSeparator(); - virtual ~UISeparator(); + virtual ~UIMenuSeparator(); virtual Uint32 getType() const; diff --git a/include/eepp/ui/uimenusubmenu.hpp b/include/eepp/ui/uimenusubmenu.hpp index 9aa692f05..117537fd9 100644 --- a/include/eepp/ui/uimenusubmenu.hpp +++ b/include/eepp/ui/uimenusubmenu.hpp @@ -25,7 +25,7 @@ class EE_API UIMenuSubMenu : public UIMenuItem { UIMenu * getSubMenu() const; - UIGfx * getArrow() const; + UIImage * getArrow() const; void showSubMenu(); @@ -38,7 +38,7 @@ class EE_API UIMenuSubMenu : public UIMenuItem { protected: UIMenu * mSubMenu; UISkin * mSkinArrow; - UIGfx * mArrow; + UIImage * mArrow; Float mTimeOver; Float mMaxTime; Uint32 mCbId; diff --git a/include/eepp/ui/uimessagebox.hpp b/include/eepp/ui/uimessagebox.hpp index bd46ae8fa..16a961dd2 100644 --- a/include/eepp/ui/uimessagebox.hpp +++ b/include/eepp/ui/uimessagebox.hpp @@ -2,7 +2,7 @@ #define EE_UICUIMESSAGEBOX_HPP #include -#include +#include #include namespace EE { namespace UI { @@ -19,7 +19,7 @@ class EE_API UIMessageBox : public UIWindow { virtual void setTheme( UITheme * Theme ); - UITextBox * getTextBox() const; + UITextView * getTextBox() const; UIPushButton * getButtonOK() const; @@ -32,7 +32,7 @@ class EE_API UIMessageBox : public UIWindow { void setCloseWithKey(const Uint32 & closeWithKey); protected: UI_MSGBOX_TYPE mMsgBoxType; - UITextBox * mTextBox; + UITextView * mTextBox; UIPushButton * mButtonOK; UIPushButton * mButtonCancel; Uint32 mCloseWithKey; diff --git a/include/eepp/ui/uiprogressbar.hpp b/include/eepp/ui/uiprogressbar.hpp index 725299c58..f02cd98ad 100644 --- a/include/eepp/ui/uiprogressbar.hpp +++ b/include/eepp/ui/uiprogressbar.hpp @@ -2,12 +2,12 @@ #define EE_UICPROGRESSBAR_HPP #include -#include +#include #include namespace EE { namespace UI { -class EE_API UIProgressBar : public UIComplexControl { +class EE_API UIProgressBar : public UIWidget { public: static UIProgressBar * New(); @@ -47,13 +47,13 @@ class EE_API UIProgressBar : public UIComplexControl { const bool& getDisplayPercent() const; - UITextBox * getTextBox() const; + UITextView * getTextBox() const; protected: ProgressBarStyleConfig mStyleConfig; Float mProgress; Float mTotalSteps; ScrollParallax * mParallax; - UITextBox * mTextBox; + UITextView * mTextBox; virtual Uint32 onValueChange(); diff --git a/include/eepp/ui/uipushbutton.hpp b/include/eepp/ui/uipushbutton.hpp index cd32b06e8..8d44d1ce7 100644 --- a/include/eepp/ui/uipushbutton.hpp +++ b/include/eepp/ui/uipushbutton.hpp @@ -1,13 +1,13 @@ #ifndef EE_UICUIPUSHBUTTON_HPP #define EE_UICUIPUSHBUTTON_HPP -#include -#include -#include +#include +#include +#include namespace EE { namespace UI { -class EE_API UIPushButton : public UIComplexControl { +class EE_API UIPushButton : public UIWidget { public: static UIPushButton * New(); @@ -23,9 +23,9 @@ class EE_API UIPushButton : public UIComplexControl { virtual UIPushButton * setIcon( SubTexture * icon ); - virtual UIGfx * getIcon() const; + virtual UIImage * getIcon() const; - virtual void setText( const String& text ); + virtual UIPushButton * setText( const String& text ); virtual const String& getText(); @@ -37,7 +37,7 @@ class EE_API UIPushButton : public UIComplexControl { const Int32& getIconHorizontalMargin() const; - UITextBox * getTextBox() const; + UITextView * getTextBox() const; void setFont( Font * font ); @@ -60,8 +60,8 @@ class EE_API UIPushButton : public UIComplexControl { void setStyleConfig(const PushButtonStyleConfig & styleConfig); protected: PushButtonStyleConfig mStyleConfig; - UIGfx * mIcon; - UITextBox * mTextBox; + UIImage * mIcon; + UITextView * mTextBox; virtual void onSizeChange(); diff --git a/include/eepp/ui/uiradiobutton.hpp b/include/eepp/ui/uiradiobutton.hpp index 9565314e5..f63c580ae 100644 --- a/include/eepp/ui/uiradiobutton.hpp +++ b/include/eepp/ui/uiradiobutton.hpp @@ -1,12 +1,12 @@ #ifndef EE_UICUIRADIOBUTTON_H #define EE_UICUIRADIOBUTTON_H -#include +#include #include namespace EE { namespace UI { -class EE_API UIRadioButton : public UITextBox { +class EE_API UIRadioButton : public UITextView { public: static UIRadioButton * New(); @@ -24,8 +24,6 @@ class EE_API UIRadioButton : public UITextBox { void setActive( const bool& active ); - virtual void setPadding( const Recti& padding ); - UIControlAnim * getActiveButton() const; UIControlAnim * getInactiveButton() const; @@ -57,6 +55,8 @@ class EE_API UIRadioButton : public UITextBox { virtual void onAutoSize(); virtual void onThemeLoaded(); + + virtual void onPaddingChange(); }; }} diff --git a/include/eepp/ui/uiscrollbar.hpp b/include/eepp/ui/uiscrollbar.hpp index 213a1d545..956054952 100644 --- a/include/eepp/ui/uiscrollbar.hpp +++ b/include/eepp/ui/uiscrollbar.hpp @@ -1,12 +1,12 @@ #ifndef EE_UICUISCROLLBAR_HPP #define EE_UICUISCROLLBAR_HPP -#include +#include #include namespace EE { namespace UI { -class EE_API UIScrollBar : public UIComplexControl { +class EE_API UIScrollBar : public UIWidget { public: static UIScrollBar * New(); diff --git a/include/eepp/ui/uislider.hpp b/include/eepp/ui/uislider.hpp index 70fdc0aac..4aefdf23f 100644 --- a/include/eepp/ui/uislider.hpp +++ b/include/eepp/ui/uislider.hpp @@ -1,12 +1,12 @@ #ifndef EE_UIUISlider_HPP #define EE_UIUISlider_HPP -#include +#include #include namespace EE { namespace UI { -class EE_API UISlider : public UIComplexControl { +class EE_API UISlider : public UIWidget { public: static UISlider * New(); @@ -42,7 +42,7 @@ class EE_API UISlider : public UIComplexControl { UIControl * getBackSlider() const; - UIDragable * getSliderButton() const; + UIDragableControl * getSliderButton() const; void adjustChilds(); diff --git a/include/eepp/ui/uispinbox.hpp b/include/eepp/ui/uispinbox.hpp index 8a83ded20..b6eef9bec 100644 --- a/include/eepp/ui/uispinbox.hpp +++ b/include/eepp/ui/uispinbox.hpp @@ -6,7 +6,7 @@ namespace EE { namespace UI { -class EE_API UISpinBox : public UIComplexControl { +class EE_API UISpinBox : public UIWidget { public: static UISpinBox * New(); diff --git a/include/eepp/ui/uisprite.hpp b/include/eepp/ui/uisprite.hpp index fee432aa3..a0b23dcbc 100644 --- a/include/eepp/ui/uisprite.hpp +++ b/include/eepp/ui/uisprite.hpp @@ -1,7 +1,7 @@ #ifndef EE_UICUISPRITE_HPP #define EE_UICUISPRITE_HPP -#include +#include namespace EE { namespace Graphics { class Sprite; @@ -9,7 +9,7 @@ class Sprite; namespace EE { namespace UI { -class EE_API UISprite : public UIComplexControl { +class EE_API UISprite : public UIWidget { public: static UISprite * New(); diff --git a/include/eepp/ui/uitab.hpp b/include/eepp/ui/uitab.hpp index b414bebf1..6eb63d659 100644 --- a/include/eepp/ui/uitab.hpp +++ b/include/eepp/ui/uitab.hpp @@ -27,7 +27,7 @@ class EE_API UITab : public UISelectButton { virtual const String& getText(); - virtual void setText( const String& text ); + virtual UIPushButton * setText( const String& text ); virtual void update(); protected: diff --git a/include/eepp/ui/uigenericgrid.hpp b/include/eepp/ui/uitable.hpp similarity index 75% rename from include/eepp/ui/uigenericgrid.hpp rename to include/eepp/ui/uitable.hpp index a0685c49f..0ce7862a6 100644 --- a/include/eepp/ui/uigenericgrid.hpp +++ b/include/eepp/ui/uitable.hpp @@ -2,19 +2,19 @@ #define EE_UICUIGENERICGRID_HPP #include -#include +#include #include #include namespace EE { namespace UI { -class EE_API UIGenericGrid : public UIComplexControl { +class EE_API UITable : public UIWidget { public: - static UIGenericGrid * New(); + static UITable * New(); - UIGenericGrid(); + UITable(); - ~UIGenericGrid(); + ~UITable(); virtual Uint32 getType() const; @@ -22,29 +22,29 @@ class EE_API UIGenericGrid : public UIComplexControl { virtual void setTheme( UITheme * Theme ); - void add( UIGridCell * Cell ); + void add( UITableCell * Cell ); - void remove( UIGridCell * Cell ); + void remove( UITableCell * Cell ); void remove( std::vector ItemsIndex ); void remove( Uint32 ItemIndex ); - UIGenericGrid * setCollumnWidth( const Uint32& CollumnIndex, const Uint32& collumnWidth ); + UITable * setCollumnWidth( const Uint32& CollumnIndex, const Uint32& collumnWidth ); const Uint32& getCollumnWidth( const Uint32& CollumnIndex ) const; Uint32 getCount() const; - UIGenericGrid * setCollumnsCount(const Uint32 & collumnsCount); + UITable * setCollumnsCount(const Uint32 & collumnsCount); const Uint32& getCollumnsCount() const; - UIGenericGrid * setRowHeight( const Uint32& height ); + UITable * setRowHeight( const Uint32& height ); const Uint32& getRowHeight() const; - UIGridCell * getCell( const Uint32& CellIndex ) const; + UITableCell * getCell( const Uint32& CellIndex ) const; void setVerticalScrollMode( const UI_SCROLLBAR_MODE& Mode ); @@ -60,15 +60,15 @@ class EE_API UIGenericGrid : public UIComplexControl { UIScrollBar * getHorizontalScrollBar() const; - Uint32 getItemIndex( UIGridCell * Item ); + Uint32 getItemIndex( UITableCell * Item ); - UIGridCell * getItemSelected(); + UITableCell * getItemSelected(); Uint32 getItemSelectedIndex() const; Uint32 onMessage( const UIMessage * Msg ); - UIItemContainer * getContainer() const; + UIItemContainer * getContainer() const; virtual void update(); @@ -87,18 +87,22 @@ class EE_API UIGenericGrid : public UIComplexControl { Float getTouchDragDeceleration() const; void setTouchDragDeceleration(const Float & touchDragDeceleration); - protected: - friend class UIItemContainer; - friend class UIGridCell; - Recti mPadding; + Recti getContainerPadding() const; + + void setContainerPadding( const Recti & containerPadding); + protected: + friend class UIItemContainer; + friend class UITableCell; + + Recti mContainerPadding; bool mSmoothScroll; - UIItemContainer * mContainer; + UIItemContainer * mContainer; UIScrollBar * mVScrollBar; UIScrollBar * mHScrollBar; UI_SCROLLBAR_MODE mVScrollMode; UI_SCROLLBAR_MODE mHScrollMode; - std::vector mItems; + std::vector mItems; Uint32 mCollumnsCount; Uint32 mRowHeight; std::vector mCollumnsWidth; diff --git a/include/eepp/ui/uigridcell.hpp b/include/eepp/ui/uitablecell.hpp similarity index 70% rename from include/eepp/ui/uigridcell.hpp rename to include/eepp/ui/uitablecell.hpp index 0509e2cb9..0f0e6b848 100644 --- a/include/eepp/ui/uigridcell.hpp +++ b/include/eepp/ui/uitablecell.hpp @@ -1,20 +1,20 @@ #ifndef EE_UICUIGRIDCELL_HPP #define EE_UICUIGRIDCELL_HPP -#include +#include #include namespace EE { namespace UI { -class UIGenericGrid; +class UITable; -class EE_API UIGridCell : public UIComplexControl { +class EE_API UITableCell : public UIWidget { public: - static UIGridCell * New(); + static UITableCell * New(); - UIGridCell(); + UITableCell(); - virtual ~UIGridCell(); + virtual ~UITableCell(); virtual void setTheme( UITheme * Theme ); @@ -32,12 +32,12 @@ class EE_API UIGridCell : public UIComplexControl { virtual Uint32 onMessage( const UIMessage * Msg ); protected: - friend class UIItemContainer; - friend class UIGenericGrid; + friend class UIItemContainer; + friend class UITable; std::vector mCells; - UIGenericGrid * gridParent() const; + UITable * gridParent() const; void fixCell(); diff --git a/include/eepp/ui/uitabwidget.hpp b/include/eepp/ui/uitabwidget.hpp index 9add8dba7..65398e68d 100644 --- a/include/eepp/ui/uitabwidget.hpp +++ b/include/eepp/ui/uitabwidget.hpp @@ -1,13 +1,13 @@ #ifndef EE_UICUITABWIDGET_HPP #define EE_UICUITABWIDGET_HPP -#include +#include #include #include namespace EE { namespace UI { -class EE_API UITabWidget : public UIComplexControl { +class EE_API UITabWidget : public UIWidget { public: static UITabWidget * New(); @@ -47,9 +47,9 @@ class EE_API UITabWidget : public UIComplexControl { Uint32 getSelectedTabIndex() const; - UIComplexControl * getTabContainer() const; + UIWidget * getTabContainer() const; - UIComplexControl * getControlContainer() const; + UIWidget * getControlContainer() const; virtual void draw(); @@ -121,8 +121,8 @@ class EE_API UITabWidget : public UIComplexControl { protected: friend class UITab; - UIComplexControl * mCtrlContainer; - UIComplexControl * mTabContainer; + UIWidget * mCtrlContainer; + UIWidget * mTabContainer; TabWidgetStyleConfig mStyleConfig; std::deque mTabs; UITab * mTabSelected; diff --git a/include/eepp/ui/uitextedit.hpp b/include/eepp/ui/uitextedit.hpp index 91779f06c..bb6d01b87 100644 --- a/include/eepp/ui/uitextedit.hpp +++ b/include/eepp/ui/uitextedit.hpp @@ -7,7 +7,7 @@ namespace EE { namespace UI { -class EE_API UITextEdit : public UIComplexControl { +class EE_API UITextEdit : public UIWidget { public: static UITextEdit * New(); @@ -45,17 +45,17 @@ class EE_API UITextEdit : public UIComplexControl { const UI_SCROLLBAR_MODE& getHorizontalScrollMode(); - TooltipStyleConfig getFontStyleConfig() const; + FontStyleConfig getFontStyleConfig() const; - void setFontStyleConfig(const TooltipStyleConfig & fontStyleConfig); + void setFontStyleConfig(const FontStyleConfig & fontStyleConfig); protected: UITextInput * mTextInput; UIScrollBar * mHScrollBar; UIScrollBar * mVScrollBar; UI_SCROLLBAR_MODE mHScrollBarMode; UI_SCROLLBAR_MODE mVScrollBarMode; - Recti mPadding; bool mSkipValueChange; + Recti mContainerPadding; virtual void onSizeChange(); diff --git a/include/eepp/ui/uitextinput.hpp b/include/eepp/ui/uitextinput.hpp index cddee00e9..a5506710b 100644 --- a/include/eepp/ui/uitextinput.hpp +++ b/include/eepp/ui/uitextinput.hpp @@ -2,12 +2,12 @@ #define EE_UICUITEXTINPUT_H #include -#include +#include #include namespace EE { namespace UI { -class EE_API UITextInput : public UITextBox { +class EE_API UITextInput : public UITextView { public: static UITextInput * New(); @@ -35,7 +35,7 @@ class EE_API UITextInput : public UITextBox { virtual const String& getText(); - virtual UITextBox * setText( const String& text ); + virtual UITextView * setText( const String& text ); virtual void shrinkText( const Uint32& MaxWidth ); diff --git a/include/eepp/ui/uitextinputpassword.hpp b/include/eepp/ui/uitextinputpassword.hpp index 2b4dd0aca..6f9be85af 100644 --- a/include/eepp/ui/uitextinputpassword.hpp +++ b/include/eepp/ui/uitextinputpassword.hpp @@ -18,7 +18,7 @@ class UITextInputPassword : public UITextInput virtual const String& getText(); - virtual UITextBox * setText( const String& text ); + virtual UITextView * setText( const String& text ); TextCache * getPassCache() const; diff --git a/include/eepp/ui/uitextbox.hpp b/include/eepp/ui/uitextview.hpp similarity index 86% rename from include/eepp/ui/uitextbox.hpp rename to include/eepp/ui/uitextview.hpp index 0c6dc21cc..2429e2807 100644 --- a/include/eepp/ui/uitextbox.hpp +++ b/include/eepp/ui/uitextview.hpp @@ -1,17 +1,17 @@ #ifndef EE_UICUITEXTBOX_H #define EE_UICUITEXTBOX_H -#include +#include namespace EE { namespace UI { -class EE_API UITextBox : public UIComplexControl { +class EE_API UITextView : public UIWidget { public: - static UITextBox * New(); + static UITextView * New(); - UITextBox(); + UITextView(); - virtual ~UITextBox(); + virtual ~UITextView(); virtual Uint32 getType() const; @@ -27,7 +27,7 @@ class EE_API UITextBox : public UIComplexControl { virtual const String& getText(); - virtual UITextBox * setText( const String& text ); + virtual UITextView * setText( const String& text ); const ColorA& getFontColor() const; @@ -41,10 +41,6 @@ class EE_API UITextBox : public UIComplexControl { void setSelectionBackColor( const ColorA& color ); - virtual void setPadding( const Recti& padding ); - - const Recti& getPadding() const; - virtual void setTheme( UITheme * Theme ); TextCache * getTextCache(); @@ -64,16 +60,20 @@ class EE_API UITextBox : public UIComplexControl { virtual void setFontStyleConfig( const TooltipStyleConfig& fontStyleConfig ); TooltipStyleConfig getFontStyleConfig() const; + + const Recti& getPadding() const; + + void setPadding(const Recti & padding); protected: TextCache * mTextCache; String mString; TooltipStyleConfig mFontStyleConfig; Vector2i mAlignOffset; Vector2f mRealAlignOffset; - Recti mPadding; - Recti mRealPadding; Int32 mSelCurInit; Int32 mSelCurEnd; + Recti mPadding; + Recti mRealPadding; virtual void drawSelection(TextCache * textCache); @@ -89,6 +89,8 @@ class EE_API UITextBox : public UIComplexControl { virtual void onFontChanged(); + virtual void onPaddingChange(); + virtual Uint32 onFocusLoss(); virtual Uint32 onMouseDoubleClick( const Vector2i& position, const Uint32 flags ); diff --git a/include/eepp/ui/uitheme.hpp b/include/eepp/ui/uitheme.hpp index 4955900a2..f97845d71 100644 --- a/include/eepp/ui/uitheme.hpp +++ b/include/eepp/ui/uitheme.hpp @@ -28,14 +28,14 @@ class UIRadioButton; class UIScrollBar; class UISlider; class UISpinBox; -class UITextBox; +class UITextView; class UITextEdit; class UITextInput; class UITextInputPassword; class UITooltip; class UIWindow; class UIWinMenu; -class UIGfx; +class UIImage; class UISprite; class UIMenu; class UICommonDialog; diff --git a/include/eepp/ui/uiwidget.hpp b/include/eepp/ui/uiwidget.hpp new file mode 100644 index 000000000..cdb3e1b2f --- /dev/null +++ b/include/eepp/ui/uiwidget.hpp @@ -0,0 +1,94 @@ +#ifndef EE_UIUIWIDGET_HPP +#define EE_UIUIWIDGET_HPP + +#include +#include + +namespace EE { namespace UI { + +class EE_API UIWidget : public UIControlAnim { + public: + static UIWidget * New(); + + UIWidget(); + + virtual ~UIWidget(); + + virtual Uint32 getType() const; + + virtual bool isType( const Uint32& type ) const; + + virtual void update(); + + virtual UIControl * setSize( const Sizei& size ); + + virtual UIControl * setFlags( const Uint32& flags ); + + virtual UIControl * unsetFlags( const Uint32& flags ); + + virtual UIWidget * setAnchors( const Uint32& flags ); + + UIControl * setSize( const Int32& Width, const Int32& Height ); + + const Sizei& getSize(); + + UITooltip * getTooltip(); + + void tooltipRemove(); + + UIWidget * setTooltipText( const String& Text ); + + String getTooltipText(); + + void updateAnchorsDistances(); + + Recti getLayoutMargin() const; + + UIWidget * setLayoutMargin(const Recti & margin); + + Float getLayoutWeight() const; + + UIWidget * setLayoutWeight(const Float & weight); + + Uint32 getLayoutGravity() const; + + UIWidget * setLayoutGravity(const Uint32 & layoutGravity); + + LayoutSizeRules getLayoutWidthRules() const; + + UIWidget * setLayoutWidthRules(const LayoutSizeRules & layoutWidthRules); + + LayoutSizeRules getLayoutHeightRules() const; + + UIWidget * setLayoutHeightRules(const LayoutSizeRules & layoutHeightRules); + + UIWidget * setLayoutSizeRules( const LayoutSizeRules & layoutWidthRules, const LayoutSizeRules & layoutHeightRules ); + protected: + friend class UILinearLayout; + + UITooltip * mTooltip; + Sizei mMinControlSize; + Recti mDistToBorder; + Recti mLayoutMargin; + Recti mRealMargin; + Float mLayoutWeight; + Uint32 mLayoutGravity; + LayoutSizeRules mLayoutWidthRules; + LayoutSizeRules mLayoutHeightRules; + + void createTooltip(); + + virtual void onParentSizeChange( const Vector2i& SizeChange ); + + virtual void onPositionChange(); + + virtual void onAutoSize(); + + void updateAnchors( const Vector2i & SizeChange ); + + void alignAgainstLayout(); +}; + +}} + +#endif diff --git a/include/eepp/ui/uiwindow.hpp b/include/eepp/ui/uiwindow.hpp index 6ab844fb1..6feac03b6 100644 --- a/include/eepp/ui/uiwindow.hpp +++ b/include/eepp/ui/uiwindow.hpp @@ -1,13 +1,13 @@ #ifndef EE_UICUIWINDOW_HPP #define EE_UICUIWINDOW_HPP -#include +#include #include -#include +#include namespace EE { namespace UI { -class EE_API UIWindow : public UIComplexControl { +class EE_API UIWindow : public UIWidget { public: static UIWindow * New(); @@ -61,7 +61,7 @@ class EE_API UIWindow : public UIComplexControl { String getTitle() const; - UITextBox * getTitleTextBox() const; + UITextView * getTitleTextBox() const; bool addShortcut( const Uint32& KeyCode, const Uint32& Mod, UIPushButton * Button ); @@ -69,7 +69,7 @@ class EE_API UIWindow : public UIComplexControl { bool isModal(); - UIComplexControl * getModalControl() const; + UIWidget * getModalControl() const; void maximize(); @@ -132,9 +132,9 @@ class EE_API UIWindow : public UIComplexControl { UIControlAnim * mButtonClose; UIControlAnim * mButtonMinimize; UIControlAnim * mButtonMaximize; - UITextBox * mTitle; + UITextView * mTitle; - UIComplexControl * mModalCtrl; + UIWidget * mModalCtrl; Vector2i mNonMaxPos; Sizei mNonMaxSize; diff --git a/include/eepp/ui/uiwinmenu.hpp b/include/eepp/ui/uiwinmenu.hpp index e5541ab6c..f37fba450 100644 --- a/include/eepp/ui/uiwinmenu.hpp +++ b/include/eepp/ui/uiwinmenu.hpp @@ -2,13 +2,13 @@ #define EE_UICUIWINMENU_HPP #include -#include +#include #include #include namespace EE { namespace UI { -class EE_API UIWinMenu : public UIComplexControl { +class EE_API UIWinMenu : public UIWidget { public: static UIWinMenu * New(); diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 962d870ca..ff6018f71 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/projects/linux/ee.files b/projects/linux/ee.files index 9f13b79cb..0414d45ac 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -1,11 +1,27 @@ ../../include/eepp/graphics/font.hpp +../../include/eepp/ui/uidragablecontrol.hpp +../../include/eepp/ui/uiimage.hpp +../../include/eepp/ui/uilinearlayout.hpp +../../include/eepp/ui/uimenuseparator.hpp +../../include/eepp/ui/uitable.hpp +../../include/eepp/ui/uitablecell.hpp +../../include/eepp/ui/uitextview.hpp ../../include/eepp/ui/uithemeconfig.hpp ../../include/eepp/ui/uithemedefault.hpp +../../include/eepp/ui/uiwidget.hpp ../../src/eepp/gaming/mapobjectlayer.cpp ../../src/eepp/graphics/globalbatchrenderer.cpp ../../src/eepp/graphics/pixeldensity.cpp ../../src/eepp/graphics/pixelperfect.cpp +../../src/eepp/ui/uidragablecontrol.cpp +../../src/eepp/ui/uiimage.cpp +../../src/eepp/ui/uilinearlayout.cpp +../../src/eepp/ui/uimenuseparator.cpp +../../src/eepp/ui/uitable.cpp +../../src/eepp/ui/uitablecell.cpp +../../src/eepp/ui/uitextview.cpp ../../src/eepp/ui/uithemedefault.cpp +../../src/eepp/ui/uiwidget.cpp ee.config ee.includes ../../../eeiv/src/capp.cpp @@ -229,7 +245,6 @@ ee.includes ../../include/eepp/ui/uitheme.hpp ../../include/eepp/ui/uitextinput.hpp ../../include/eepp/ui/uitextedit.hpp -../../include/eepp/ui/uitextbox.hpp ../../include/eepp/ui/uitabwidget.hpp ../../include/eepp/ui/uitab.hpp ../../include/eepp/ui/uisprite.hpp @@ -240,7 +255,6 @@ ee.includes ../../include/eepp/ui/uiskinsimple.hpp ../../include/eepp/ui/uiskincomplex.hpp ../../include/eepp/ui/uiskin.hpp -../../include/eepp/ui/uiseparator.hpp ../../include/eepp/ui/uiselectbutton.hpp ../../include/eepp/ui/uiscrollbar.hpp ../../include/eepp/ui/uiradiobutton.hpp @@ -256,17 +270,12 @@ ee.includes ../../include/eepp/ui/uimanager.hpp ../../include/eepp/ui/uilistboxitem.hpp ../../include/eepp/ui/uilistbox.hpp -../../include/eepp/ui/uigridcell.hpp -../../include/eepp/ui/uigfx.hpp -../../include/eepp/ui/uigenericgrid.hpp ../../include/eepp/ui/uieventmouse.hpp ../../include/eepp/ui/uieventkey.hpp ../../include/eepp/ui/uievent.hpp ../../include/eepp/ui/uidropdownlist.hpp -../../include/eepp/ui/uidragable.hpp ../../include/eepp/ui/uicontrolanim.hpp ../../include/eepp/ui/uicontrol.hpp -../../include/eepp/ui/uicomplexcontrol.hpp ../../include/eepp/ui/uicommondialog.hpp ../../include/eepp/ui/uicombobox.hpp ../../include/eepp/ui/uicheckbox.hpp @@ -283,7 +292,6 @@ ee.includes ../../src/eepp/ui/uitheme.cpp ../../src/eepp/ui/uitextinput.cpp ../../src/eepp/ui/uitextedit.cpp -../../src/eepp/ui/uitextbox.cpp ../../src/eepp/ui/uitabwidget.cpp ../../src/eepp/ui/uitab.cpp ../../src/eepp/ui/uisprite.cpp @@ -294,7 +302,6 @@ ee.includes ../../src/eepp/ui/uiskinsimple.cpp ../../src/eepp/ui/uiskincomplex.cpp ../../src/eepp/ui/uiskin.cpp -../../src/eepp/ui/uiseparator.cpp ../../src/eepp/ui/uiselectbutton.cpp ../../src/eepp/ui/uiscrollbar.cpp ../../src/eepp/ui/uiradiobutton.cpp @@ -310,17 +317,12 @@ ee.includes ../../src/eepp/ui/uimanager.cpp ../../src/eepp/ui/uilistboxitem.cpp ../../src/eepp/ui/uilistbox.cpp -../../src/eepp/ui/uigridcell.cpp -../../src/eepp/ui/uigfx.cpp -../../src/eepp/ui/uigenericgrid.cpp ../../src/eepp/ui/uieventmouse.cpp ../../src/eepp/ui/uieventkey.cpp ../../src/eepp/ui/uievent.cpp ../../src/eepp/ui/uidropdownlist.cpp -../../src/eepp/ui/uidragable.cpp ../../src/eepp/ui/uicontrolanim.cpp ../../src/eepp/ui/uicontrol.cpp -../../src/eepp/ui/uicomplexcontrol.cpp ../../src/eepp/ui/uicommondialog.cpp ../../src/eepp/ui/uicombobox.cpp ../../src/eepp/ui/uicheckbox.cpp diff --git a/projects/linux/ee.includes b/projects/linux/ee.includes index b77e93fb5..ab6130e9a 100644 --- a/projects/linux/ee.includes +++ b/projects/linux/ee.includes @@ -6,3 +6,4 @@ ../../include/eepp/graphics ../../src/eepp/graphics ../../include/eepp/ui +../../src/eepp/ui diff --git a/src/eepp/gaming/mapeditor/mapeditor.cpp b/src/eepp/gaming/mapeditor/mapeditor.cpp index faa513a43..9e2aae0be 100644 --- a/src/eepp/gaming/mapeditor/mapeditor.cpp +++ b/src/eepp/gaming/mapeditor/mapeditor.cpp @@ -39,8 +39,8 @@ using namespace EE::Gaming::Private; namespace EE { namespace Gaming { -static UITextBox * createTextBox( const String& Text = "", UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE ) { - UITextBox * Ctrl = UITextBox::New(); +static UITextView * createTextBox( const String& Text = "", UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE ) { + UITextView * Ctrl = UITextView::New(); Ctrl->resetFlags( Flags )->setParent( Parent )->setPosition( Pos )->setSize( Size )->setVisible( true )->setEnabled( false ); Ctrl->setText( Text ); return Ctrl; @@ -172,7 +172,7 @@ void MapEditor::createWinMenu() { WinMenu->addMenuButton( "Atlases", PU6 ); PU6->addEventListener( UIEvent::EventOnItemClicked, cb::Make1( this, &MapEditor::mapMenuClick ) ); - mWinContainer = UIComplexControl::New(); + mWinContainer = UIWidget::New(); mWinContainer->setFlags( UI_REPORT_SIZE_CHANGE_TO_CHILDS ); mWinContainer->setParent( mUIContainer ); mWinContainer->setPosition( 0, WinMenu->getSize().getHeight() ); @@ -186,17 +186,17 @@ void MapEditor::createETGMenu() { Int32 ContPosX = mWinContainer->getSize().getWidth() - Width - DistToBorder; Int32 DistFromTopMenu = 4; - mSubTextureCont = UIComplexControl::New(); + mSubTextureCont = UIWidget::New(); mSubTextureCont->setParent( mWinContainer ); mSubTextureCont->setSize( Sizei( Width + DistToBorder, mWinContainer->getSize().getHeight() ) ); mSubTextureCont->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); - mLightCont = UIComplexControl::New(); + mLightCont = UIWidget::New(); mLightCont->setParent( mWinContainer ); mLightCont->setSize( mSubTextureCont->getSize() ); mLightCont->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); - mObjectCont = UIComplexControl::New(); + mObjectCont = UIWidget::New(); mObjectCont->setParent( mWinContainer ); mObjectCont->setSize( mSubTextureCont->getSize() ); mObjectCont->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); @@ -259,7 +259,7 @@ void MapEditor::fillGotyList() { } void MapEditor::createSubTextureContainer( Int32 Width ) { - UITextBox * Txt; + UITextView * Txt; Uint32 TxtFlags = UI_CONTROL_DEFAULT_ALIGN | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP | UI_DRAW_SHADOW; Txt = createTextBox( "Add Game Object as...", mSubTextureCont, Sizei( Width, 16 ), Vector2i( TAB_CONT_X_DIST, 4 ), TxtFlags ); @@ -332,7 +332,7 @@ void MapEditor::createSubTextureContainer( Int32 Width ) { mChkDI->setTooltipText( "If the resource it's not a sprite,\nyou can reference it with a data id" ); mChkDI->addEventListener( UIEvent::EventOnValueChange, cb::Make1( this, &MapEditor::chkClickDI ) ); - mSGCont = UIComplexControl::New(); + mSGCont = UIWidget::New(); mSGCont->setParent( mSubTextureCont )->setPosition( TAB_CONT_X_DIST, mChkDI->getPosition().y + mChkDI->getSize().getHeight() + 8 )->setSize( Width, 400 ); mSGCont->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); mSGCont->setEnabled( true ); @@ -351,14 +351,14 @@ void MapEditor::createSubTextureContainer( Int32 Width ) { mSubTextureList->setAnchors(UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); mSubTextureList->addEventListener( UIEvent::EventOnItemSelected, cb::Make1( this, &MapEditor::onSubTextureChange ) ); - mGfxPreview = UIGfx::New(); + mGfxPreview = UIImage::New(); mGfxPreview->resetFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP | UI_AUTO_FIT ) ->setParent( mSGCont )->setSize( Width, Width ) ->setPosition( 0, mSubTextureList->getPosition().y + mSubTextureList->getSize().getHeight() + 4 ); mGfxPreview->setBorderEnabled( true )->setColor( ColorA( 0, 0, 0, 200 ) ); - mDICont = UIComplexControl::New(); + mDICont = UIWidget::New(); mDICont->setParent( mSubTextureCont )->setPosition( TAB_CONT_X_DIST, mChkDI->getPosition().y + mChkDI->getSize().getHeight() + 8 ); mDICont->setSize( Width, 400 ); mDICont->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP ); @@ -379,9 +379,9 @@ void MapEditor::createLighContainer() { NewLightBut->setText( "New Light" ); NewLightBut->addEventListener( UIEvent::EventMouseClick, cb::Make1( this, &MapEditor::onNewLight ) ); - UITextBox * Txt = createTextBox( "Light Color:", mLightCont, Sizei(), Vector2i( TAB_CONT_X_DIST, 32 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); + UITextView * Txt = createTextBox( "Light Color:", mLightCont, Sizei(), Vector2i( TAB_CONT_X_DIST, 32 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); - mUIBaseColor = UIComplexControl::New(); + mUIBaseColor = UIWidget::New(); mUIBaseColor->setFlags( UI_FILL_BACKGROUND | UI_BORDER ); mUIBaseColor->setParent( mLightCont ); mUIBaseColor->setPosition( Txt->getPosition().x, Txt->getPosition().y + Txt->getSize().getHeight() + 4 ); diff --git a/src/eepp/gaming/mapeditor/maplayerproperties.cpp b/src/eepp/gaming/mapeditor/maplayerproperties.cpp index 04d872bee..372b3657c 100644 --- a/src/eepp/gaming/mapeditor/maplayerproperties.cpp +++ b/src/eepp/gaming/mapeditor/maplayerproperties.cpp @@ -29,7 +29,7 @@ MapLayerProperties::MapLayerProperties( MapLayer * Map, RefreshLayerListCb Cb ) Int32 InitialY = 16; Int32 DistFromTitle = 18; - UITextBox * Txt = UITextBox::New(); + UITextView * Txt = UITextView::New(); Txt->setFlags( UI_DRAW_SHADOW | UI_AUTO_SIZE )->setParent( mUIWindow->getContainer() )->setPosition( 50, InitialY ); Txt->setText( "Layer name:" ); @@ -38,12 +38,12 @@ MapLayerProperties::MapLayerProperties( MapLayer * Map, RefreshLayerListCb Cb ) mUIInput->setText( mLayer->getName() ); mUIInput->addEventListener( UIEvent::EventOnPressEnter, cb::Make1( this, &MapLayerProperties::onOKClick ) ); - UITextBox * TxtBox = UITextBox::New(); + UITextView * TxtBox = UITextView::New(); TxtBox->setParent( mUIWindow->getContainer() )->setSize( 192, 24 )->setHorizontalAlign( UI_HALIGN_CENTER )->setFlags( UI_DRAW_SHADOW ) ->setPosition( 50, mUIInput->getPosition().y + mUIInput->getSize().getHeight() + 12 ); TxtBox->setText( "Property Name" ); - TxtBox = UITextBox::New(); + TxtBox = UITextView::New(); TxtBox->setParent( mUIWindow->getContainer() )->setSize( 192, 24 )->setHorizontalAlign( UI_HALIGN_CENTER )->setFlags( UI_DRAW_SHADOW ) ->setPosition( 50+192, mUIInput->getPosition().y + mUIInput->getSize().getHeight() + 12 ); TxtBox->setText( "Property Value" ); @@ -63,7 +63,7 @@ MapLayerProperties::MapLayerProperties( MapLayer * Map, RefreshLayerListCb Cb ) CancelButton->setText( "Cancel" ); CancelButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ); - mGenGrid = UIGenericGrid::New(); + mGenGrid = UITable::New(); mGenGrid->setParent( mUIWindow->getContainer() ); mGenGrid->setSize( 400, 340 )->setPosition( 50, TxtBox->getPosition().y + TxtBox->getSize().getHeight() ); mGenGrid->setRowHeight( 24 )->setCollumnsCount( 5 ); @@ -109,7 +109,7 @@ void MapLayerProperties::saveProperties() { mLayer->clearProperties(); for ( Uint32 i = 0; i < mGenGrid->getCount(); i++ ) { - UIGridCell * Cell = mGenGrid->getCell( i ); + UITableCell * Cell = mGenGrid->getCell( i ); UITextInput * Input = reinterpret_cast( Cell->getCell( 1 ) ); UITextInput * Input2 = reinterpret_cast( Cell->getCell( 3 ) ); @@ -124,7 +124,7 @@ void MapLayerProperties::loadProperties() { MapLayer::PropertiesMap& Proper = mLayer->getProperties(); for ( MapLayer::PropertiesMap::iterator it = Proper.begin(); it != Proper.end(); it++ ) { - UIGridCell * Cell = createCell(); + UITableCell * Cell = createCell(); UITextInput * Input = reinterpret_cast( Cell->getCell( 1 ) ); UITextInput * Input2 = reinterpret_cast( Cell->getCell( 3 ) ); @@ -193,8 +193,8 @@ void MapLayerProperties::createGridElems() { } } -UIGridCell * MapLayerProperties::createCell() { - UIGridCell * Cell = UIGridCell::New(); +UITableCell * MapLayerProperties::createCell() { + UITableCell * Cell = UITableCell::New(); UITextInput * TxtInput = UITextInput::New(); UITextInput * TxtInput2 = UITextInput::New(); @@ -202,11 +202,11 @@ UIGridCell * MapLayerProperties::createCell() { TxtInput->setMaxLength( LAYER_NAME_SIZE ); TxtInput2->setMaxLength( LAYER_NAME_SIZE ); - Cell->setCell( 0, UIComplexControl::New() ); + Cell->setCell( 0, UIWidget::New() ); Cell->setCell( 1, TxtInput ); - Cell->setCell( 2, UIComplexControl::New() ); + Cell->setCell( 2, UIWidget::New() ); Cell->setCell( 3, TxtInput2 ); - Cell->setCell( 4, UIComplexControl::New() ); + Cell->setCell( 4, UIWidget::New() ); return Cell; } diff --git a/src/eepp/gaming/mapeditor/maplayerproperties.hpp b/src/eepp/gaming/mapeditor/maplayerproperties.hpp index 54147eec7..949e9d1e3 100644 --- a/src/eepp/gaming/mapeditor/maplayerproperties.hpp +++ b/src/eepp/gaming/mapeditor/maplayerproperties.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include using namespace EE::UI; @@ -25,7 +25,7 @@ class EE_API MapLayerProperties { protected: UITheme * mUITheme; UIWindow * mUIWindow; - UIGenericGrid * mGenGrid; + UITable * mGenGrid; MapLayer * mLayer; UITextInput * mUIInput; RefreshLayerListCb mRefreshCb; @@ -46,7 +46,7 @@ class EE_API MapLayerProperties { void loadProperties(); - UIGridCell * createCell(); + UITableCell * createCell(); }; }}} diff --git a/src/eepp/gaming/mapeditor/mapobjectproperties.cpp b/src/eepp/gaming/mapeditor/mapobjectproperties.cpp index 437d34bbb..8a9d6cb44 100644 --- a/src/eepp/gaming/mapeditor/mapobjectproperties.cpp +++ b/src/eepp/gaming/mapeditor/mapobjectproperties.cpp @@ -3,8 +3,8 @@ namespace EE { namespace Gaming { namespace Private { -static UITextBox * createTextBox( const String& Text = "", UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE ) { - UITextBox * Ctrl = UITextBox::New(); +static UITextView * createTextBox( const String& Text = "", UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE ) { + UITextView * Ctrl = UITextView::New(); Ctrl->resetFlags( Flags )->setParent( Parent )->setPosition( Pos )->setSize( Size )->setVisible( true )->setEnabled( false ); Ctrl->setText( Text ); return Ctrl; @@ -35,14 +35,14 @@ MapObjectProperties::MapObjectProperties( GameObjectObject * Obj ) : Int32 InitialY = 16; Int32 DistFromTitle = 18; - UITextBox * Txt = createTextBox( "Object name:", mUIWindow->getContainer(), Sizei(), Vector2i( 50, InitialY ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); + UITextView * Txt = createTextBox( "Object name:", mUIWindow->getContainer(), Sizei(), Vector2i( 50, InitialY ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); mUIInput = UITextInput::New(); mUIInput->setParent( mUIWindow->getContainer() )->setSize( 120, 0 )->setPosition( Txt->getPosition().x + DistFromTitle, Txt->getPosition().y + DistFromTitle ); mUIInput->setMaxLength( 64 ); mUIInput->setText( mObj->getName() ); mUIInput->addEventListener( UIEvent::EventOnPressEnter, cb::Make1( this, &MapObjectProperties::onOKClick ) ); - UITextBox * Txt2 = createTextBox( "Object type:", mUIWindow->getContainer(), Sizei(), Vector2i( 50+192, InitialY ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); + UITextView * Txt2 = createTextBox( "Object type:", mUIWindow->getContainer(), Sizei(), Vector2i( 50+192, InitialY ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); mUIInput2 = UITextInput::New(); mUIInput2->setParent( mUIWindow->getContainer() )->setSize( 120, 0 )->setPosition( Txt2->getPosition().x + DistFromTitle, Txt2->getPosition().y + DistFromTitle ); mUIInput2->setMaxLength( 64 ); @@ -51,7 +51,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject * Obj ) : Uint32 TxtBoxFlags = UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_HALIGN_CENTER | UI_VALIGN_CENTER; createTextBox( "Property Name", mUIWindow->getContainer(), Sizei(192, 24), Vector2i( 50, mUIInput->getPosition().y + mUIInput->getSize().getHeight() + 12 ), TxtBoxFlags ); - UITextBox * TxtBox = createTextBox( "Property Value", mUIWindow->getContainer(), Sizei(192, 24), Vector2i( 50+192, mUIInput->getPosition().y + mUIInput->getSize().getHeight() + 12 ), TxtBoxFlags ); + UITextView * TxtBox = createTextBox( "Property Value", mUIWindow->getContainer(), Sizei(192, 24), Vector2i( 50+192, mUIInput->getPosition().y + mUIInput->getSize().getHeight() + 12 ), TxtBoxFlags ); UIPushButton * OKButton = UIPushButton::New(); OKButton->setParent( mUIWindow->getContainer() )->setSize( 80, 0 ); @@ -68,7 +68,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject * Obj ) : CancelButton->setText( "Cancel" ); CancelButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ); - mGenGrid = UIGenericGrid::New(); + mGenGrid = UITable::New(); mGenGrid->setParent( mUIWindow->getContainer() ); mGenGrid->setSize( 400, 340 )->setPosition( 50, TxtBox->getPosition().y + TxtBox->getSize().getHeight() ); mGenGrid->setRowHeight( 24 )->setCollumnsCount( 5 ); @@ -114,7 +114,7 @@ void MapObjectProperties::saveProperties() { mObj->clearProperties(); for ( Uint32 i = 0; i < mGenGrid->getCount(); i++ ) { - UIGridCell * Cell = mGenGrid->getCell( i ); + UITableCell * Cell = mGenGrid->getCell( i ); UITextInput * Input = reinterpret_cast( Cell->getCell( 1 ) ); UITextInput * Input2 = reinterpret_cast( Cell->getCell( 3 ) ); @@ -129,7 +129,7 @@ void MapObjectProperties::loadProperties() { GameObjectObject::PropertiesMap& Proper = mObj->getProperties(); for ( GameObjectObject::PropertiesMap::iterator it = Proper.begin(); it != Proper.end(); it++ ) { - UIGridCell * Cell = createCell(); + UITableCell * Cell = createCell(); UITextInput * Input = reinterpret_cast( Cell->getCell( 1 ) ); UITextInput * Input2 = reinterpret_cast( Cell->getCell( 3 ) ); @@ -195,8 +195,8 @@ void MapObjectProperties::createGridElems() { } } -UIGridCell * MapObjectProperties::createCell() { - UIGridCell * Cell = UIGridCell::New(); +UITableCell * MapObjectProperties::createCell() { + UITableCell * Cell = UITableCell::New(); UITextInput * TxtInput = UITextInput::New(); UITextInput * TxtInput2 = UITextInput::New(); @@ -204,11 +204,11 @@ UIGridCell * MapObjectProperties::createCell() { TxtInput->setMaxLength( LAYER_NAME_SIZE ); TxtInput2->setMaxLength( LAYER_NAME_SIZE ); - Cell->setCell( 0, UIComplexControl::New() ); + Cell->setCell( 0, UIWidget::New() ); Cell->setCell( 1, TxtInput ); - Cell->setCell( 2, UIComplexControl::New() ); + Cell->setCell( 2, UIWidget::New() ); Cell->setCell( 3, TxtInput2 ); - Cell->setCell( 4, UIComplexControl::New() ); + Cell->setCell( 4, UIWidget::New() ); return Cell; } diff --git a/src/eepp/gaming/mapeditor/mapobjectproperties.hpp b/src/eepp/gaming/mapeditor/mapobjectproperties.hpp index 6bdcccbae..8655d8d10 100644 --- a/src/eepp/gaming/mapeditor/mapobjectproperties.hpp +++ b/src/eepp/gaming/mapeditor/mapobjectproperties.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include using namespace EE::UI; @@ -23,7 +23,7 @@ class MapObjectProperties { protected: UITheme * mUITheme; UIWindow * mUIWindow; - UIGenericGrid * mGenGrid; + UITable * mGenGrid; GameObjectObject * mObj; UITextInput * mUIInput; UITextInput * mUIInput2; @@ -44,7 +44,7 @@ class MapObjectProperties { void loadProperties(); - UIGridCell * createCell(); + UITableCell * createCell(); }; }}} diff --git a/src/eepp/gaming/mapeditor/tilemapproperties.cpp b/src/eepp/gaming/mapeditor/tilemapproperties.cpp index 30312b39d..0a616e65f 100644 --- a/src/eepp/gaming/mapeditor/tilemapproperties.cpp +++ b/src/eepp/gaming/mapeditor/tilemapproperties.cpp @@ -2,8 +2,8 @@ namespace EE { namespace Gaming { namespace Private { -static UITextBox * createTextBox( const String& Text = "", UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE ) { - UITextBox * Ctrl = UITextBox::New(); +static UITextView * createTextBox( const String& Text = "", UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE ) { + UITextView * Ctrl = UITextView::New(); Ctrl->resetFlags( Flags )->setParent( Parent )->setPosition( Pos )->setSize( Size )->setVisible( true )->setEnabled( false ); Ctrl->setText( Text ); return Ctrl; @@ -37,9 +37,9 @@ TileMapProperties::TileMapProperties( TileMap * Map ) : if ( mMap->getLightsEnabled() ) { DiffIfLights = 100; - UITextBox * Txt = createTextBox( "Map Base Color:", mUIWindow->getContainer(), Sizei(), Vector2i( 50, 16 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); + UITextView * Txt = createTextBox( "Map Base Color:", mUIWindow->getContainer(), Sizei(), Vector2i( 50, 16 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); - mUIBaseColor = UIComplexControl::New(); + mUIBaseColor = UIWidget::New(); mUIBaseColor->setFlags( UI_FILL_BACKGROUND | UI_BORDER ); mUIBaseColor->setParent( mUIWindow->getContainer() ); mUIBaseColor->setPosition( Txt->getPosition().x, Txt->getPosition().y + Txt->getSize().getHeight() + 4 ); @@ -77,7 +77,7 @@ TileMapProperties::TileMapProperties( TileMap * Map ) : } Uint32 TxtBoxFlags = UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_HALIGN_CENTER | UI_VALIGN_CENTER; - UITextBox * TxtBox = createTextBox( "Property Name", mUIWindow->getContainer(), Sizei(192, 24), Vector2i( 50, 10 + DiffIfLights ), TxtBoxFlags ); + UITextView * TxtBox = createTextBox( "Property Name", mUIWindow->getContainer(), Sizei(192, 24), Vector2i( 50, 10 + DiffIfLights ), TxtBoxFlags ); createTextBox( "Property Value", mUIWindow->getContainer(), Sizei(192, 24), Vector2i(50+192, TxtBox->getPosition().y ), TxtBoxFlags ); UIPushButton * OKButton = UIPushButton::New(); @@ -95,7 +95,7 @@ TileMapProperties::TileMapProperties( TileMap * Map ) : CancelButton->setText( "Cancel" ); CancelButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ); - mGenGrid = UIGenericGrid::New(); + mGenGrid = UITable::New(); mGenGrid->setParent( mUIWindow->getContainer() ); mGenGrid->setSize( 400, 310 )->setPosition( 50, TxtBox->getPosition().y + TxtBox->getSize().getHeight() ); mGenGrid->setRowHeight( 24 )->setCollumnsCount( 5 ); @@ -175,7 +175,7 @@ void TileMapProperties::saveProperties() { mMap->clearProperties(); for ( Uint32 i = 0; i < mGenGrid->getCount(); i++ ) { - UIGridCell * Cell = mGenGrid->getCell( i ); + UITableCell * Cell = mGenGrid->getCell( i ); UITextInput * Input = reinterpret_cast( Cell->getCell( 1 ) ); UITextInput * Input2 = reinterpret_cast( Cell->getCell( 3 ) ); @@ -190,7 +190,7 @@ void TileMapProperties::loadProperties() { TileMap::PropertiesMap& Proper = mMap->getProperties(); for ( TileMap::PropertiesMap::iterator it = Proper.begin(); it != Proper.end(); it++ ) { - UIGridCell * Cell = createCell(); + UITableCell * Cell = createCell(); UITextInput * Input = reinterpret_cast( Cell->getCell( 1 ) ); UITextInput * Input2 = reinterpret_cast( Cell->getCell( 3 ) ); @@ -253,8 +253,8 @@ void TileMapProperties::createGridElems() { } } -UIGridCell * TileMapProperties::createCell() { - UIGridCell * Cell = UIGridCell::New(); +UITableCell * TileMapProperties::createCell() { + UITableCell * Cell = UITableCell::New(); UITextInput * TxtInput = UITextInput::New(); UITextInput * TxtInput2 = UITextInput::New(); @@ -262,11 +262,11 @@ UIGridCell * TileMapProperties::createCell() { TxtInput->setMaxLength( LAYER_NAME_SIZE ); TxtInput2->setMaxLength( LAYER_NAME_SIZE ); - Cell->setCell( 0, UIComplexControl::New() ); + Cell->setCell( 0, UIWidget::New() ); Cell->setCell( 1, TxtInput ); - Cell->setCell( 2, UIComplexControl::New() ); + Cell->setCell( 2, UIWidget::New() ); Cell->setCell( 3, TxtInput2 ); - Cell->setCell( 4, UIComplexControl::New() ); + Cell->setCell( 4, UIWidget::New() ); return Cell; } diff --git a/src/eepp/gaming/mapeditor/tilemapproperties.hpp b/src/eepp/gaming/mapeditor/tilemapproperties.hpp index d966818e7..c051d74d0 100644 --- a/src/eepp/gaming/mapeditor/tilemapproperties.hpp +++ b/src/eepp/gaming/mapeditor/tilemapproperties.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include @@ -21,15 +21,15 @@ class EE_API TileMapProperties { protected: UITheme * mUITheme; UIWindow * mUIWindow; - UIGenericGrid * mGenGrid; + UITable * mGenGrid; TileMap * mMap; - UIComplexControl * mUIBaseColor; + UIWidget * mUIBaseColor; UISlider * mUIRedSlider; UISlider * mUIGreenSlider; UISlider * mUIBlueSlider; - UITextBox * mUIRedTxt; - UITextBox * mUIGreenTxt; - UITextBox * mUIBlueTxt; + UITextView * mUIRedTxt; + UITextView * mUIGreenTxt; + UITextView * mUIBlueTxt; void onWindowClose( const UIEvent * Event ); @@ -53,7 +53,7 @@ class EE_API TileMapProperties { void loadProperties(); - UIGridCell * createCell(); + UITableCell * createCell(); }; }}} diff --git a/src/eepp/gaming/mapeditor/uigotypenew.cpp b/src/eepp/gaming/mapeditor/uigotypenew.cpp index 6e837c511..7f384795c 100644 --- a/src/eepp/gaming/mapeditor/uigotypenew.cpp +++ b/src/eepp/gaming/mapeditor/uigotypenew.cpp @@ -23,7 +23,7 @@ UIGOTypeNew::UIGOTypeNew( cb::Callback2 Cb ) : Int32 InitialY = 16; Int32 DistFromTitle = 18; - UITextBox * Txt = UITextBox::New(); + UITextView * Txt = UITextView::New(); Txt->setFlags( UI_DRAW_SHADOW | UI_AUTO_SIZE )->setParent( mUIWindow->getContainer() )->setPosition( 16, InitialY ); Txt->setText( "GameObject Type Name" ); diff --git a/src/eepp/gaming/mapeditor/uimap.cpp b/src/eepp/gaming/mapeditor/uimap.cpp index b960230a0..493ce5ce4 100644 --- a/src/eepp/gaming/mapeditor/uimap.cpp +++ b/src/eepp/gaming/mapeditor/uimap.cpp @@ -81,7 +81,7 @@ TileMap * UIMap::Map() const { } void UIMap::draw() { - UIComplexControl::draw(); + UIWidget::draw(); if ( NULL != mMap ) { mMap->draw(); @@ -89,7 +89,7 @@ void UIMap::draw() { } void UIMap::updateScreenPos() { - UIComplexControl::updateScreenPos(); + UIWidget::updateScreenPos(); if ( NULL != mMap ) { mMap->setPosition( mScreenPos ); @@ -97,7 +97,7 @@ void UIMap::updateScreenPos() { } void UIMap::update() { - UIComplexControl::update(); + UIWidget::update(); if ( NULL != mMap ) { mMap->update(); @@ -326,7 +326,7 @@ void UIMap::onSizeChange() { mMap->setViewSize( mRealSize ); } - UIComplexControl::onSizeChange(); + UIWidget::onSizeChange(); } Uint32 UIMap::onMouseMove( const Vector2i& Pos, const Uint32 Flags ) { @@ -345,7 +345,7 @@ Uint32 UIMap::onMouseMove( const Vector2i& Pos, const Uint32 Flags ) { } } - return UIComplexControl::onMouseMove( Pos, Flags ); + return UIWidget::onMouseMove( Pos, Flags ); } void UIMap::addLight( MapLight * Light ) { @@ -502,7 +502,7 @@ void UIMap::clearLights() { } void UIMap::onAlphaChange() { - UIComplexControl::onAlphaChange(); + UIWidget::onAlphaChange(); if ( NULL != mMap ) { mMap->setBackAlpha( (Uint8)mAlpha ); @@ -585,7 +585,7 @@ void UIMap::createObjPopUpMenu() { } } -void UIMap::setTileBox( UITextBox * tilebox ) { +void UIMap::setTileBox( UITextView * tilebox ) { mTileBox = tilebox; } diff --git a/src/eepp/gaming/mapeditor/uimap.hpp b/src/eepp/gaming/mapeditor/uimap.hpp index 4d4329a3b..e3176a9fc 100644 --- a/src/eepp/gaming/mapeditor/uimap.hpp +++ b/src/eepp/gaming/mapeditor/uimap.hpp @@ -2,8 +2,8 @@ #define EE_GAMINGCUIMAP_HPP #include -#include -#include +#include +#include #include #include #include @@ -18,7 +18,7 @@ class GameObjectObject; namespace Private { -class EE_API UIMap : public UIComplexControl { +class EE_API UIMap : public UIWidget { public: static UIMap * New( UITheme * Theme, TileMap * Map = NULL ); @@ -85,7 +85,7 @@ class EE_API UIMap : public UIComplexControl { void createObjPopUpMenu(); - void setTileBox( UITextBox * tilebox ); + void setTileBox( UITextView * tilebox ); void replaceMap( TileMap * newMap ); protected: @@ -128,7 +128,7 @@ class EE_API UIMap : public UIComplexControl { Rectf mSelPointRect; bool mSelPoint; - UITextBox * mTileBox; + UITextView * mTileBox; Vector2i mLastMouseTilePos; UpdateScrollCb mUpdateScrollCb; diff --git a/src/eepp/gaming/mapeditor/uimaplayernew.cpp b/src/eepp/gaming/mapeditor/uimaplayernew.cpp index 598ddbf5e..cbbc4db7c 100644 --- a/src/eepp/gaming/mapeditor/uimaplayernew.cpp +++ b/src/eepp/gaming/mapeditor/uimaplayernew.cpp @@ -29,7 +29,7 @@ UIMapLayerNew::UIMapLayerNew( UIMap * Map, EE_LAYER_TYPE Type, NewLayerCb newLay Int32 InitialY = 16; Int32 DistFromTitle = 18; - UITextBox * Txt = UITextBox::New(); + UITextView * Txt = UITextView::New(); Txt->setFlags( UI_DRAW_SHADOW | UI_AUTO_SIZE )->setParent( mUIWindow->getContainer() )->setPosition( 16, InitialY ); Txt->setText( "Layer Name" ); diff --git a/src/eepp/gaming/mapeditor/uimapnew.cpp b/src/eepp/gaming/mapeditor/uimapnew.cpp index fb3029ccb..5ac3ee2e4 100644 --- a/src/eepp/gaming/mapeditor/uimapnew.cpp +++ b/src/eepp/gaming/mapeditor/uimapnew.cpp @@ -5,8 +5,8 @@ namespace EE { namespace Gaming { namespace Private { -static UITextBox * createTextBox( const String& Text = "", UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE ) { - UITextBox * Ctrl = UITextBox::New(); +static UITextView * createTextBox( const String& Text = "", UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE ) { + UITextView * Ctrl = UITextView::New(); Ctrl->resetFlags( Flags )->setParent( Parent )->setPosition( Pos )->setSize( Size )->setVisible( true )->setEnabled( false ); Ctrl->setText( Text ); return Ctrl; @@ -40,7 +40,7 @@ UIMapNew::UIMapNew( UIMap * Map, cb::Callback0 NewMapCb, bool ResizeMap ) Int32 InitialY = 16; Int32 DistFromTitle = 18; - UITextBox * Txt = createTextBox( "Map Size", mUIWindow->getContainer(), Sizei(), Vector2i( 16, InitialY ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); + UITextView * Txt = createTextBox( "Map Size", mUIWindow->getContainer(), Sizei(), Vector2i( 16, InitialY ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); Txt = createTextBox( "Width:", mUIWindow->getContainer(), Sizei( 46, 24 ), Vector2i( Txt->getPosition().x + DistFromTitle, Txt->getPosition().y + DistFromTitle ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW ); @@ -138,7 +138,7 @@ UIMapNew::UIMapNew( UIMap * Map, cb::Callback0 NewMapCb, bool ResizeMap ) Txt = createTextBox( "Map Base Color:", mUIWindow->getContainer(), Sizei(), Vector2i( Txt->getPosition().x, mUIClipArea->getPosition().y + mUIClipArea->getSize().getHeight() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); - mUIBaseColor = UIComplexControl::New(); + mUIBaseColor = UIWidget::New(); mUIBaseColor->setFlags( UI_FILL_BACKGROUND | UI_BORDER ); mUIBaseColor->getBorder()->setColor( ColorA( 100, 100, 100, 200 ) ); mUIBaseColor->getBackground()->setColor( ResizeMap ? mUIMap->Map()->getBaseColor() : ColorA( 255, 255, 255, 255 ) ); diff --git a/src/eepp/gaming/mapeditor/uimapnew.hpp b/src/eepp/gaming/mapeditor/uimapnew.hpp index aaee2e9ab..c7cd87df6 100644 --- a/src/eepp/gaming/mapeditor/uimapnew.hpp +++ b/src/eepp/gaming/mapeditor/uimapnew.hpp @@ -27,13 +27,13 @@ class EE_API UIMapNew { UICheckBox * mUILightsByVertex; UICheckBox * mUIClampBorders; UICheckBox * mUIClipArea; - UIComplexControl * mUIBaseColor; + UIWidget * mUIBaseColor; UISlider * mUIRedSlider; UISlider * mUIGreenSlider; UISlider * mUIBlueSlider; - UITextBox * mUIRedTxt; - UITextBox * mUIGreenTxt; - UITextBox * mUIBlueTxt; + UITextView * mUIRedTxt; + UITextView * mUIGreenTxt; + UITextView * mUIBlueTxt; cb::Callback0 mNewMapCb; diff --git a/src/eepp/ui/tools/textureatlaseditor.cpp b/src/eepp/ui/tools/textureatlaseditor.cpp index 3b168c3a7..902d50a4a 100644 --- a/src/eepp/ui/tools/textureatlaseditor.cpp +++ b/src/eepp/ui/tools/textureatlaseditor.cpp @@ -35,7 +35,7 @@ TextureAtlasEditor::TextureAtlasEditor( UIWindow * AttatchTo, const TGEditorClos mUIContainer = mUIWindow->getContainer(); } - UITextBox * TxtBox; + UITextView * TxtBox; Uint32 InitY = 230; createTextBox( Vector2i( mUIContainer->getSize().getWidth() - 205, 30 ), "SubTexture List:" ); @@ -215,8 +215,8 @@ void TextureAtlasEditor::onDestHChange( const UIEvent * Event ) { } } -UITextBox * TextureAtlasEditor::createTextBox( Vector2i Pos, const String& Text ) { - UITextBox * txtBox = UITextBox::New(); +UITextView * TextureAtlasEditor::createTextBox( Vector2i Pos, const String& Text ) { + UITextView * txtBox = UITextView::New(); txtBox->resetFlags( UI_CONTROL_DEFAULT_ALIGN | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_DRAW_SHADOW | UI_AUTO_SIZE ); txtBox->setParent( mUIContainer ); txtBox->setPosition( Pos ); diff --git a/src/eepp/ui/tools/textureatlasnew.cpp b/src/eepp/ui/tools/textureatlasnew.cpp index 03498b36d..7d3d278db 100644 --- a/src/eepp/ui/tools/textureatlasnew.cpp +++ b/src/eepp/ui/tools/textureatlasnew.cpp @@ -102,8 +102,8 @@ TextureAtlasNew::TextureAtlasNew( TGCreateCb NewTGCb ) : TextureAtlasNew::~TextureAtlasNew() { } -UITextBox * TextureAtlasNew::createTxtBox( Vector2i Pos, const String& Text ) { - UITextBox * textBox = UITextBox::New(); +UITextView * TextureAtlasNew::createTxtBox( Vector2i Pos, const String& Text ) { + UITextView * textBox = UITextView::New(); textBox->setParent( mUIWindow->getContainer() ) ->setPosition( Pos ) ->setFlags( UI_DRAW_SHADOW | UI_AUTO_SIZE ) diff --git a/src/eepp/ui/tools/textureatlasnew.hpp b/src/eepp/ui/tools/textureatlasnew.hpp index e53087e61..4d889d47f 100644 --- a/src/eepp/ui/tools/textureatlasnew.hpp +++ b/src/eepp/ui/tools/textureatlasnew.hpp @@ -34,7 +34,7 @@ class EE_API TextureAtlasNew { void okClick( const UIEvent * Event ); - UITextBox * createTxtBox( Vector2i Pos, const String& Text ); + UITextView * createTxtBox( Vector2i Pos, const String& Text ); void onDialogFolderSelect( const UIEvent * Event ); diff --git a/src/eepp/ui/tools/textureatlassubtextureeditor.cpp b/src/eepp/ui/tools/textureatlassubtextureeditor.cpp index 63ec3dafd..049d462f4 100644 --- a/src/eepp/ui/tools/textureatlassubtextureeditor.cpp +++ b/src/eepp/ui/tools/textureatlassubtextureeditor.cpp @@ -6,7 +6,7 @@ namespace EE { namespace UI { namespace Tools { TextureAtlasSubTextureEditor::TextureAtlasSubTextureEditor( TextureAtlasEditor * Editor ) : - UIComplexControl(), + UIWidget(), mGfx( NULL ), mEditor( Editor ) { @@ -16,13 +16,13 @@ TextureAtlasSubTextureEditor::TextureAtlasSubTextureEditor( TextureAtlasEditor * mTheme = UIThemeManager::instance()->getDefaultTheme(); - mGfx = UIGfx::New(); + mGfx = UIImage::New(); mGfx->setParent( this ); mGfx->setVisible( true ); mGfx->setEnabled( true ); mGfx->unsetFlags( UI_FIT_TO_CONTROL ); - mDrag = UIDragable::New(); + mDrag = UIDragableControl::New(); mDrag->setParent( this ); mDrag->setSize( 64000, 64000 ); mDrag->setEnabled( true ); @@ -46,13 +46,13 @@ void TextureAtlasSubTextureEditor::draw() { P.drawLine( Line2f( Vector2f( mScreenPos.x, mScreenPos.y + uiCenterPx.y ), Vector2f( mScreenPos.x + mRealSize.getWidth(), mScreenPos.y + uiCenterPx.y ) ) ); P.drawLine( Line2f( Vector2f( mScreenPos.x + uiCenterPx.x, mScreenPos.y ), Vector2f( mScreenPos.x + uiCenterPx.x, mScreenPos.y + mRealSize.getHeight() ) ) ); - UIComplexControl::draw(); + UIWidget::draw(); } void TextureAtlasSubTextureEditor::update() { Vector2i Pos = mDrag->getRealPosition(); - UIComplexControl::update(); + UIWidget::update(); if ( NULL != mGfx->getSubTexture() && mDrag->isDragEnabled() && mDrag->isDragging() && Pos != mDrag->getRealPosition() ) { Vector2i Diff = -( Pos - mDrag->getRealPosition() ); @@ -80,7 +80,7 @@ void TextureAtlasSubTextureEditor::setSubTexture( Graphics::SubTexture * subText mGfx->setSubTexture( subTexture ); } -UIGfx * TextureAtlasSubTextureEditor::getGfx() const { +UIImage * TextureAtlasSubTextureEditor::getGfx() const { return mGfx; } diff --git a/src/eepp/ui/tools/textureatlassubtextureeditor.hpp b/src/eepp/ui/tools/textureatlassubtextureeditor.hpp index d58a1a447..d782d6058 100644 --- a/src/eepp/ui/tools/textureatlassubtextureeditor.hpp +++ b/src/eepp/ui/tools/textureatlassubtextureeditor.hpp @@ -2,15 +2,15 @@ #define EE_UITOOLSCTEXTUREATLASSUBTEXTUREEDITOR_HPP #include -#include +#include #include -#include +#include namespace EE { namespace UI { namespace Tools { class TextureAtlasEditor; -class EE_API TextureAtlasSubTextureEditor : public UIComplexControl { +class EE_API TextureAtlasSubTextureEditor : public UIWidget { public: TextureAtlasSubTextureEditor( TextureAtlasEditor * Editor ); @@ -24,11 +24,11 @@ class EE_API TextureAtlasSubTextureEditor : public UIComplexControl { void setSubTexture( Graphics::SubTexture * subTexture ); - UIGfx * getGfx() const; + UIImage * getGfx() const; protected: UITheme * mTheme; - UIGfx * mGfx; - UIDragable * mDrag; + UIImage * mGfx; + UIDragableControl * mDrag; Vector2i mUICenter; TextureAtlasEditor * mEditor; diff --git a/src/eepp/ui/uicheckbox.cpp b/src/eepp/ui/uicheckbox.cpp index f4ddac109..1b0fcd9a9 100644 --- a/src/eepp/ui/uicheckbox.cpp +++ b/src/eepp/ui/uicheckbox.cpp @@ -10,7 +10,7 @@ UICheckBox * UICheckBox::New() { } UICheckBox::UICheckBox() : - UITextBox(), + UITextView(), mActive( false ), mTextSeparation( 4 ) { @@ -28,7 +28,7 @@ UICheckBox::UICheckBox() : mInactiveButton->setPosition( 0, 0 ); mInactiveButton->setSize( 16, 16 ); - setPadding( Recti(0,0,0,0) ); + onPaddingChange(); applyDefaultTheme(); } @@ -42,7 +42,7 @@ Uint32 UICheckBox::getType() const { } bool UICheckBox::isType( const Uint32& type ) const { - return UICheckBox::getType() == type ? true : UITextBox::isType( type ); + return UICheckBox::getType() == type ? true : UITextView::isType( type ); } void UICheckBox::setTheme( UITheme * Theme ) { @@ -71,12 +71,14 @@ void UICheckBox::onThemeLoaded() { mMinControlSize = mActiveButton->getSkinSize(); - setPadding( Recti(0,0,0,0) ); + onPaddingChange(); } void UICheckBox::onAutoSize() { if ( mFlags & UI_AUTO_SIZE ) { - setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mActiveButton->getRealSize().getWidth() + mTextSeparation ); + if ( mSize.getWidth() == 0 ) { + setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mActiveButton->getRealSize().getWidth() + mTextSeparation ); + } if ( mSize.getHeight() == 0 ) { setInternalHeight( mActiveButton->getSize().getHeight() ); @@ -88,7 +90,7 @@ void UICheckBox::onAutoSize() { } void UICheckBox::onSizeChange() { - UITextBox::onSizeChange(); + UITextView::onSizeChange(); mActiveButton->centerVertical(); mInactiveButton->centerVertical(); @@ -136,9 +138,7 @@ const bool& UICheckBox::isActive() const { return mActive; } -void UICheckBox::setPadding( const Recti& padding ) { - UITextBox::setPadding( padding ); - +void UICheckBox::onPaddingChange() { mActiveButton->setPosition( mPadding.Left, mActiveButton->getPosition().y ); mInactiveButton->setPosition( mPadding.Left, mInactiveButton->getPosition().y ); @@ -164,7 +164,7 @@ void UICheckBox::setTextSeparation(const Int32 & textSeparation) { } Uint32 UICheckBox::onKeyDown( const UIEventKey& Event ) { - UITextBox::onKeyDown( Event ); + UITextView::onKeyDown( Event ); if ( Event.getKeyCode() == KEY_SPACE ) { if ( Sys::getTicks() - mLastTick > 250 ) { @@ -178,7 +178,7 @@ Uint32 UICheckBox::onKeyDown( const UIEventKey& Event ) { } void UICheckBox::onAlphaChange() { - UITextBox::onAlphaChange(); + UITextView::onAlphaChange(); mActiveButton->setAlpha( mAlpha ); mInactiveButton->setAlpha( mAlpha ); diff --git a/src/eepp/ui/uicombobox.cpp b/src/eepp/ui/uicombobox.cpp index 18f26cdbc..b559a4e47 100644 --- a/src/eepp/ui/uicombobox.cpp +++ b/src/eepp/ui/uicombobox.cpp @@ -8,7 +8,7 @@ UIComboBox *UIComboBox::New() { } UIComboBox::UIComboBox() : - UIComplexControl(), + UIWidget(), mDropDownList( NULL ), mButton( NULL ) { @@ -23,7 +23,7 @@ Uint32 UIComboBox::getType() const { } bool UIComboBox::isType( const Uint32& type ) const { - return UIComboBox::getType() == type ? true : UIComplexControl::isType( type ); + return UIComboBox::getType() == type ? true : UIWidget::isType( type ); } void UIComboBox::setTheme( UITheme * Theme ) { @@ -96,13 +96,13 @@ void UIComboBox::onButtonClick( const UIEvent * Event ) { } void UIComboBox::onSizeChange() { - UIComplexControl::onSizeChange(); + UIWidget::onSizeChange(); updateControls(); } void UIComboBox::onPositionChange() { - UIComplexControl::onPositionChange(); + UIWidget::onPositionChange(); updateControls(); } diff --git a/src/eepp/ui/uicommondialog.cpp b/src/eepp/ui/uicommondialog.cpp index 9050198e7..2feca60c8 100644 --- a/src/eepp/ui/uicommondialog.cpp +++ b/src/eepp/ui/uicommondialog.cpp @@ -43,7 +43,7 @@ UICommonDialog::UICommonDialog( Uint32 CDLFlags , std::string DefaultFilePattern setTitle( "Select a file" ); } - UITextBox * lookIn = UITextBox::New(); + UITextView * lookIn = UITextView::New(); lookIn->setParent( getContainer() ); lookIn->setPosition( 6, 13 ); lookIn->setVisible( true ); @@ -96,7 +96,7 @@ UICommonDialog::UICommonDialog( Uint32 CDLFlags , std::string DefaultFilePattern ); mList->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_BOTTOM ); - UITextBox * fileName = UITextBox::New(); + UITextView * fileName = UITextView::New(); fileName->setParent( getContainer() ); fileName->setPosition( 6, mButtonOpen->getPosition().y ); fileName->setSize( 74, fileName->getTextHeight() ); @@ -105,7 +105,7 @@ UICommonDialog::UICommonDialog( Uint32 CDLFlags , std::string DefaultFilePattern fileName->setEnabled( false ); fileName->setText( "File Name:" ); - UITextBox * fileTypes = UITextBox::New(); + UITextView * fileTypes = UITextView::New(); fileTypes->setParent( getContainer() ); fileTypes->setSize( 74, fileTypes->getTextHeight() ); fileTypes->setPosition( fileName->getPosition().x, mButtonCancel->getPosition().y ); diff --git a/src/eepp/ui/uicontrol.cpp b/src/eepp/ui/uicontrol.cpp index 4127285fc..8353fb9b8 100644 --- a/src/eepp/ui/uicontrol.cpp +++ b/src/eepp/ui/uicontrol.cpp @@ -356,8 +356,8 @@ void UIControl::drawOverControl() { void UIControl::drawDebugData() { if ( UIManager::instance()->getDrawDebugData() ) { - if ( isComplex() ) { - UIComplexControl * me = static_cast( this ); + if ( isWidget() ) { + UIWidget * me = static_cast( this ); if ( UIManager::instance()->getOverControl() == this ) { String text( String::strFormated( "X: %d Y: %d\nW: %d H: %d", mPos.x, mPos.y, mSize.x, mSize.y ) ); @@ -817,6 +817,8 @@ void UIControl::childAdd( UIControl * ChildCtrl ) { ChildCtrl->mNext = NULL; mChildLast = ChildCtrl; } + + onChildCountChange(); } void UIControl::childAddAt( UIControl * ChildCtrl, Uint32 Pos ) { @@ -863,6 +865,8 @@ void UIControl::childAddAt( UIControl * ChildCtrl, Uint32 Pos ) { } } } + + onChildCountChange(); } void UIControl::childRemove( UIControl * ChildCtrl ) { @@ -890,6 +894,8 @@ void UIControl::childRemove( UIControl * ChildCtrl ) { ChildCtrl->mPrev = NULL; } + + onChildCountChange(); } void UIControl::childsCloseAll() { @@ -1068,7 +1074,7 @@ Uint32 UIControl::isDragable() { return mControlFlags & UI_CTRL_FLAG_DRAGABLE; } -Uint32 UIControl::isComplex() { +Uint32 UIControl::isWidget() { return mControlFlags & UI_CTRL_FLAG_COMPLEX; } @@ -1431,7 +1437,7 @@ UIControl * UIControl::getNextComplexControl() { while( NULL != ChildLoop ) { if ( ChildLoop->isVisible() && ChildLoop->isEnabled() ) { - if ( ChildLoop->isComplex() ) { + if ( ChildLoop->isWidget() ) { return ChildLoop; } else { Found = ChildLoop->getNextComplexControl(); @@ -1446,7 +1452,7 @@ UIControl * UIControl::getNextComplexControl() { } if ( NULL != mNext ) { - if ( mNext->isVisible() && mNext->isEnabled() && mNext->isComplex() ) { + if ( mNext->isVisible() && mNext->isEnabled() && mNext->isWidget() ) { return mNext; } else { return mNext->getNextComplexControl(); @@ -1456,7 +1462,7 @@ UIControl * UIControl::getNextComplexControl() { while ( NULL != ChildLoop ) { if ( NULL != ChildLoop->mNext ) { - if ( ChildLoop->mNext->isVisible() && ChildLoop->mNext->isEnabled() && ChildLoop->mNext->isComplex() ) { + if ( ChildLoop->mNext->isVisible() && ChildLoop->mNext->isEnabled() && ChildLoop->mNext->isWidget() ) { return ChildLoop->mNext; } else { return ChildLoop->mNext->getNextComplexControl(); @@ -1473,6 +1479,9 @@ UIControl * UIControl::getNextComplexControl() { void UIControl::onThemeLoaded() { } +void UIControl::onChildCountChange() { +} + void UIControl::worldToControl( Vector2i& pos ) const { Vector2f Pos( pos.x, pos.y ); @@ -1547,4 +1556,23 @@ void UIControl::controlToWorld( Vector2i& pos ) const { pos = Vector2i( eeceil( Pos.x ), eeceil( Pos.y ) ); } +UIControl * UIControl::getWindowContainer() { + UIControl * Ctrl = this; + + while ( Ctrl != NULL ) { + if ( Ctrl->isType( UI_TYPE_WINDOW ) ) { + if ( UIManager::instance()->getMainControl() == Ctrl ) { + return Ctrl; + } else { + return static_cast( Ctrl )->getContainer(); + } + + } + + Ctrl = Ctrl->getParent(); + } + + return NULL; +} + }} diff --git a/src/eepp/ui/uicontrolanim.cpp b/src/eepp/ui/uicontrolanim.cpp index 963c6ae40..c022f7ae9 100644 --- a/src/eepp/ui/uicontrolanim.cpp +++ b/src/eepp/ui/uicontrolanim.cpp @@ -11,7 +11,7 @@ UIControlAnim * UIControlAnim::New() { } UIControlAnim::UIControlAnim() : - UIDragable(), + UIDragableControl(), mAngle(0.f), mScale(1.f,1.f), mAlpha(255.f), @@ -49,8 +49,7 @@ void UIControlAnim::draw() { if ( mVisible && 0.f != mAlpha ) { drawBackground(); - if ( mFlags & UI_BORDER ) - drawBorder(); + drawBorder(); drawSkin(); @@ -200,7 +199,7 @@ void UIControlAnim::matrixUnset() { } void UIControlAnim::update() { - UIDragable::update(); + UIDragableControl::update(); if ( NULL != mMoveAnim && mMoveAnim->isEnabled() ) { mMoveAnim->update( getElapsed() ); @@ -435,7 +434,7 @@ void UIControlAnim::updateQuad() { } void UIControlAnim::onSizeChange() { - UIDragable::onSizeChange(); + UIDragableControl::onSizeChange(); updateOriginPoint(); } diff --git a/src/eepp/ui/uidragable.cpp b/src/eepp/ui/uidragablecontrol.cpp similarity index 63% rename from src/eepp/ui/uidragable.cpp rename to src/eepp/ui/uidragablecontrol.cpp index 5fd845523..dabfb51ea 100644 --- a/src/eepp/ui/uidragable.cpp +++ b/src/eepp/ui/uidragablecontrol.cpp @@ -1,32 +1,32 @@ -#include +#include #include #include namespace EE { namespace UI { -UIDragable * UIDragable::New() { - return eeNew( UIDragable, () ); +UIDragableControl * UIDragableControl::New() { + return eeNew( UIDragableControl, () ); } -UIDragable::UIDragable() : +UIDragableControl::UIDragableControl() : UIControl(), mDragButton( EE_BUTTON_LMASK ) { mControlFlags |= UI_CTRL_FLAG_DRAGABLE; } -UIDragable::~UIDragable() { +UIDragableControl::~UIDragableControl() { } -Uint32 UIDragable::getType() const { +Uint32 UIDragableControl::getType() const { return UI_TYPE_CONTROL_DRAGABLE; } -bool UIDragable::isType( const Uint32& type ) const { - return UIDragable::getType() == type ? true : UIControl::isType( type ); +bool UIDragableControl::isType( const Uint32& type ) const { + return UIDragableControl::getType() == type ? true : UIControl::isType( type ); } -Uint32 UIDragable::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UIDragableControl::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { if ( !( UIManager::instance()->getLastPressTrigger() & mDragButton ) && ( Flags & mDragButton ) && isDragEnabled() && !isDragging() ) { setDragging( true ); mDragPoint = Pos; @@ -36,7 +36,7 @@ Uint32 UIDragable::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { return 1; } -Uint32 UIDragable::onMouseUp( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UIDragableControl::onMouseUp( const Vector2i& Pos, const Uint32 Flags ) { if ( isDragEnabled() && isDragging() && ( Flags & mDragButton ) ) { setDragging( false ); } @@ -45,15 +45,15 @@ Uint32 UIDragable::onMouseUp( const Vector2i& Pos, const Uint32 Flags ) { return 1; } -const Vector2i& UIDragable::getDragPoint() const { +const Vector2i& UIDragableControl::getDragPoint() const { return mDragPoint; } -void UIDragable::setDragPoint( const Vector2i& Point ) { +void UIDragableControl::setDragPoint( const Vector2i& Point ) { mDragPoint = Point; } -void UIDragable::update() { +void UIDragableControl::update() { UIControl::update(); if ( !isDragEnabled() ) @@ -87,31 +87,31 @@ void UIDragable::update() { } } -Uint32 UIDragable::onDrag( const Vector2i& Pos ) { +Uint32 UIDragableControl::onDrag( const Vector2i& Pos ) { return 1; } -Uint32 UIDragable::OnDragStart( const Vector2i& Pos ) { +Uint32 UIDragableControl::OnDragStart( const Vector2i& Pos ) { return 1; } -Uint32 UIDragable::OnDragEnd( const Vector2i& Pos ) { +Uint32 UIDragableControl::OnDragEnd( const Vector2i& Pos ) { return 1; } -bool UIDragable::isDragEnabled() const { +bool UIDragableControl::isDragEnabled() const { return 0 != ( mFlags & UI_DRAG_ENABLE ); } -void UIDragable::setDragEnabled( const bool& enable ) { +void UIDragableControl::setDragEnabled( const bool& enable ) { writeFlag( UI_DRAG_ENABLE, true == enable ); } -bool UIDragable::isDragging() const { +bool UIDragableControl::isDragging() const { return 0 != ( mControlFlags & UI_CTRL_FLAG_DRAGGING ); } -void UIDragable::setDragging( const bool& dragging ) { +void UIDragableControl::setDragging( const bool& dragging ) { writeCtrlFlag( UI_CTRL_FLAG_DRAGGING, true == dragging ); if ( dragging ) { @@ -127,11 +127,11 @@ void UIDragable::setDragging( const bool& dragging ) { } } -void UIDragable::setDragButton( const Uint32& Button ) { +void UIDragableControl::setDragButton( const Uint32& Button ) { mDragButton = Button; } -const Uint32& UIDragable::getDragButton() const { +const Uint32& UIDragableControl::getDragButton() const { return mDragButton; } diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index 517ea4a8d..26f552a0d 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -57,7 +57,7 @@ void UIDropDownList::setTheme( UITheme * Theme ) { } void UIDropDownList::onSizeChange() { - UIComplexControl::onSizeChange(); + UIWidget::onSizeChange(); autoSizeControl(); } diff --git a/src/eepp/ui/uigfx.cpp b/src/eepp/ui/uiimage.cpp similarity index 77% rename from src/eepp/ui/uigfx.cpp rename to src/eepp/ui/uiimage.cpp index 0f66e6ba1..37aa79cb7 100644 --- a/src/eepp/ui/uigfx.cpp +++ b/src/eepp/ui/uiimage.cpp @@ -1,14 +1,14 @@ -#include +#include #include namespace EE { namespace UI { -UIGfx *UIGfx::New() { - return eeNew( UIGfx, () ); +UIImage * UIImage::New() { + return eeNew( UIImage, () ); } -UIGfx::UIGfx() : - UIComplexControl(), +UIImage::UIImage() : + UIWidget(), mSubTexture( NULL ), mColor(), mRender( RN_NORMAL ), @@ -19,18 +19,18 @@ UIGfx::UIGfx() : onAutoSize(); } -UIGfx::~UIGfx() { +UIImage::~UIImage() { } -Uint32 UIGfx::getType() const { - return UI_TYPE_GFX; +Uint32 UIImage::getType() const { + return UI_TYPE_IMAGE; } -bool UIGfx::isType( const Uint32& type ) const { - return UIGfx::getType() == type ? true : UIComplexControl::isType( type ); +bool UIImage::isType( const Uint32& type ) const { + return UIImage::getType() == type ? true : UIWidget::isType( type ); } -void UIGfx::setSubTexture( Graphics::SubTexture * subTexture ) { +void UIImage::setSubTexture( Graphics::SubTexture * subTexture ) { mSubTexture = subTexture; onAutoSize(); @@ -42,7 +42,7 @@ void UIGfx::setSubTexture( Graphics::SubTexture * subTexture ) { autoAlign(); } -void UIGfx::onAutoSize() { +void UIImage::onAutoSize() { if ( ( mFlags & UI_AUTO_SIZE ) && Sizei::Zero == mSize ) { if ( NULL != mSubTexture ) { setSize( mSubTexture->getDpSize() ); @@ -50,7 +50,7 @@ void UIGfx::onAutoSize() { } } -void UIGfx::draw() { +void UIImage::draw() { UIControlAnim::draw(); if ( mVisible ) { @@ -111,37 +111,37 @@ void UIGfx::draw() { } } -void UIGfx::drawSubTexture() { +void UIImage::drawSubTexture() { mSubTexture->draw( (Float)mScreenPos.x + mAlignOffset.x, (Float)mScreenPos.y + mAlignOffset.y, mColor, 0.f, Vector2f::One, getBlendMode(), mRender ); } -void UIGfx::setAlpha( const Float& alpha ) { +void UIImage::setAlpha( const Float& alpha ) { UIControlAnim::setAlpha( alpha ); mColor.Alpha = (Uint8)alpha; } -Graphics::SubTexture * UIGfx::getSubTexture() const { +Graphics::SubTexture * UIImage::getSubTexture() const { return mSubTexture; } -const ColorA& UIGfx::getColor() const { +const ColorA& UIImage::getColor() const { return mColor; } -void UIGfx::setColor( const ColorA& col ) { +void UIImage::setColor( const ColorA& col ) { mColor = col; setAlpha( col.a() ); } -const EE_RENDER_MODE& UIGfx::getRenderMode() const { +const EE_RENDER_MODE& UIImage::getRenderMode() const { return mRender; } -void UIGfx::setRenderMode( const EE_RENDER_MODE& render ) { +void UIImage::setRenderMode( const EE_RENDER_MODE& render ) { mRender = render; } -void UIGfx::autoAlign() { +void UIImage::autoAlign() { if ( NULL == mSubTexture ) return; @@ -162,18 +162,18 @@ void UIGfx::autoAlign() { } } -void UIGfx::onSizeChange() { +void UIImage::onSizeChange() { onAutoSize(); autoAlign(); UIControlAnim::onSizeChange(); } -void UIGfx::onAlignChange() { +void UIImage::onAlignChange() { onAutoSize(); autoAlign(); } -const Vector2i& UIGfx::getAlignOffset() const { +const Vector2i& UIImage::getAlignOffset() const { return mAlignOffset; } diff --git a/src/eepp/ui/uilinearlayout.cpp b/src/eepp/ui/uilinearlayout.cpp new file mode 100644 index 000000000..6d49f03e8 --- /dev/null +++ b/src/eepp/ui/uilinearlayout.cpp @@ -0,0 +1,293 @@ +#include + +namespace EE { namespace UI { + +UILinearLayout * UILinearLayout::New() { + return eeNew( UILinearLayout, () ); +} + +UILinearLayout * UILinearLayout::NewVertical() { + return eeNew( UILinearLayout, () ); +} + +UILinearLayout * UILinearLayout::NewHorizontal() { + return ( eeNew( UILinearLayout, () ) )->setOrientation( UI_HORIZONTAL ); +} + +UILinearLayout::UILinearLayout() : + UIWidget(), + mOrientation( UI_VERTICAL ) +{ + setFlags( UI_CLIP_ENABLE ); +} + +Uint32 UILinearLayout::getType() const { + return UI_TYPE_LINEAR_LAYOUT; +} + +bool UILinearLayout::isType( const Uint32& type ) const { + return UIWidget::getType() == type ? true : UIWidget::isType( type ); +} + +UI_ORIENTATION UILinearLayout::getOrientation() const { + return mOrientation; +} + +UILinearLayout * UILinearLayout::setOrientation(const UI_ORIENTATION & orientation) { + mOrientation = orientation; + return this; +} + +UILinearLayout * UILinearLayout::add( UIWidget * widget ) { + widget->setParent( this ); + return this; +} + +void UILinearLayout::onSizeChange() { + pack(); +} + +void UILinearLayout::onParentSizeChange( const Vector2i& SizeChange ) { + pack(); +} + +void UILinearLayout::onChildCountChange() { + pack(); +} + +void UILinearLayout::pack() { + if ( mOrientation == UI_VERTICAL ) + packVertical(); + else + packHorizontal(); +} + +void UILinearLayout::packVertical() { + if ( getLayoutWidthRules() == MATCH_PARENT && 0 == mLayoutWeight ) { + setInternalWidth( getParent()->getSize().getWidth() - mLayoutMargin.Left - mLayoutMargin.Right ); + } + + if ( getLayoutHeightRules() == MATCH_PARENT ) { + setInternalHeight( getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom ); + } + + UIControl * ChildLoop = mChild; + + while ( NULL != ChildLoop ) { + if ( ChildLoop->isWidget() ) { + UIWidget * widget = static_cast( ChildLoop ); + + if ( widget->getLayoutHeightRules() == WRAP_CONTENT ) { + widget->setFlags( UI_AUTO_SIZE ); + } + + switch ( widget->getLayoutWidthRules() ) { + case WRAP_CONTENT: + { + widget->setFlags( UI_AUTO_SIZE ); + break; + } + case MATCH_PARENT: + { + widget->setSize( mSize.getWidth() - widget->getLayoutMargin().Left - widget->getLayoutMargin().Right, widget->getSize().getHeight() ); + break; + } + case FIXED: + default: + { + } + } + } + + ChildLoop = ChildLoop->getNextControl(); + } + + Int32 curY = 0; + Int32 maxX = 0; + Sizei freeSize = getTotalUsedSize(); + + ChildLoop = mChild; + + while ( NULL != ChildLoop ) { + if ( ChildLoop->isWidget() ) { + UIWidget * widget = static_cast( ChildLoop ); + Recti margin = widget->getLayoutMargin(); + + curY += margin.Top; + + Vector2i pos( 0, curY ); + + if ( widget->getLayoutWeight() != 0 ) { + Float size = (Float)( mSize.getHeight() - freeSize.getHeight() ) * widget->getLayoutWeight(); + + widget->setSize( widget->getSize().getWidth(), (Int32)size ); + } + + switch ( fontHAlignGet( widget->getLayoutGravity() ) ) { + case UI_HALIGN_CENTER: + pos.x = ( mSize.getWidth() - widget->getSize().getWidth() ) / 2; + break; + case UI_HALIGN_RIGHT: + pos.x = mSize.getWidth() - widget->getSize().getWidth() - widget->getLayoutMargin().Right; + break; + case UI_HALIGN_LEFT: + default: + pos.x = widget->getLayoutMargin().Left; + break; + } + + widget->setPosition( pos ); + + curY += widget->getSize().getHeight() + margin.Bottom; + + maxX = eemax( maxX, (Int32)( widget->getSize().getWidth() + widget->getLayoutMargin().Left + widget->getLayoutMargin().Right ) ); + } + + ChildLoop = ChildLoop->getNextControl(); + } + + if ( getLayoutHeightRules() == WRAP_CONTENT ) { + setInternalHeight( curY ); + } else if ( getLayoutHeightRules() == MATCH_PARENT ) { + setInternalHeight( getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom ); + } + + if ( getLayoutHeightRules() == WRAP_CONTENT && mSize.getWidth() != maxX ) { + setInternalWidth( maxX ); + packVertical(); + } + + alignAgainstLayout(); +} + +void UILinearLayout::packHorizontal() { + if ( getLayoutWidthRules() == MATCH_PARENT ) { + setInternalWidth( getParent()->getSize().getWidth() - mLayoutMargin.Left - mLayoutMargin.Right ); + } + + if ( getLayoutHeightRules() == MATCH_PARENT && 0 == mLayoutWeight ) { + setInternalHeight( getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom ); + } + + UIControl * ChildLoop = mChild; + + while ( NULL != ChildLoop ) { + if ( ChildLoop->isWidget() ) { + UIWidget * widget = static_cast( ChildLoop ); + + if ( widget->getLayoutWidthRules() == WRAP_CONTENT ) { + widget->setFlags( UI_AUTO_SIZE ); + } + + switch ( widget->getLayoutHeightRules() ) { + case WRAP_CONTENT: + { + widget->setFlags( UI_AUTO_SIZE ); + break; + } + case MATCH_PARENT: + { + widget->setSize( widget->getSize().getWidth(), mSize.getHeight() - widget->getLayoutMargin().Top - widget->getLayoutMargin().Bottom ); + break; + } + case FIXED: + default: + { + } + } + } + + ChildLoop = ChildLoop->getNextControl(); + } + + Int32 curX = 0; + Int32 maxY = 0; + Sizei freeSize = getTotalUsedSize(); + + ChildLoop = mChild; + + while ( NULL != ChildLoop ) { + if ( ChildLoop->isWidget() ) { + UIWidget * widget = static_cast( ChildLoop ); + Recti margin = widget->getLayoutMargin(); + + curX += margin.Left; + + Vector2i pos( curX, 0 ); + + if ( widget->getLayoutWeight() != 0 ) { + Float size = (Float)( mSize.getWidth() - freeSize.getWidth() ) * widget->getLayoutWeight(); + + widget->setSize( (Int32)size, widget->getSize().getHeight() ); + } + + switch ( fontVAlignGet( widget->getLayoutGravity() ) ) { + case UI_VALIGN_CENTER: + pos.y = ( mSize.getHeight() - widget->getSize().getHeight() ) / 2; + break; + case UI_VALIGN_BOTTOM: + pos.y = mSize.getHeight() - widget->getSize().getHeight() - widget->getLayoutMargin().Bottom; + break; + case UI_VALIGN_TOP: + default: + pos.y = widget->getLayoutMargin().Left; + break; + } + + widget->setPosition( pos ); + + curX += widget->getSize().getWidth() + margin.Right; + + maxY = eemax( maxY, (Int32)( widget->getSize().getHeight() + widget->getLayoutMargin().Top + widget->getLayoutMargin().Bottom ) ); + } + + ChildLoop = ChildLoop->getNextControl(); + } + + if ( getLayoutWidthRules() == WRAP_CONTENT ) { + setInternalWidth( curX ); + } else if ( getLayoutWidthRules() == MATCH_PARENT ) { + setInternalWidth( getParent()->getSize().getWidth() - mLayoutMargin.Left - mLayoutMargin.Right ); + } + + if ( getLayoutHeightRules() == WRAP_CONTENT && mSize.getHeight() != maxY ) { + setInternalHeight( maxY ); + packHorizontal(); + } + + alignAgainstLayout(); +} + +Sizei UILinearLayout::getTotalUsedSize() { + UIControl * ChildLoop = mChild; + Sizei size( 0, 0 ); + + while ( NULL != ChildLoop ) { + if ( ChildLoop->isWidget() ) { + UIWidget * widget = static_cast( ChildLoop ); + Recti margin = widget->getLayoutMargin(); + + size.x += margin.Left + margin.Right; + + size.y += margin.Top + margin.Bottom; + + if ( widget->getLayoutWidthRules() == FIXED || widget->getLayoutWidthRules() == WRAP_CONTENT ) { + if ( 0 == widget->getLayoutWeight() && mOrientation == UI_HORIZONTAL ) { + size.x += widget->getSize().getWidth(); + } + } + + if ( widget->getLayoutHeightRules() == FIXED || widget->getLayoutHeightRules() == WRAP_CONTENT ) { + if ( 0 == widget->getLayoutWeight() && mOrientation == UI_VERTICAL ) { + size.y += widget->getSize().getHeight(); + } + } + } + + ChildLoop = ChildLoop->getNextControl(); + } + + return size; +} + +}} diff --git a/src/eepp/ui/uilistbox.cpp b/src/eepp/ui/uilistbox.cpp index 7df6b746c..74cc58519 100644 --- a/src/eepp/ui/uilistbox.cpp +++ b/src/eepp/ui/uilistbox.cpp @@ -11,12 +11,12 @@ UIListBox * UIListBox::New() { } UIListBox::UIListBox() : - UIComplexControl(), + UIWidget(), mRowHeight(0), mVScrollMode( UI_SCROLLBAR_AUTO ), mHScrollMode( UI_SCROLLBAR_AUTO ), mSmoothScroll( true ), - mPaddingContainer(), + mContainerPadding(), mHScrollPadding(), mVScrollPadding(), mContainer( NULL ), @@ -75,7 +75,7 @@ Uint32 UIListBox::getType() const { } bool UIListBox::isType( const Uint32& type ) const { - return UIListBox::getType() == type ? true : UIComplexControl::isType( type ); + return UIListBox::getType() == type ? true : UIWidget::isType( type ); } void UIListBox::setTheme( UITheme * Theme ) { @@ -88,7 +88,7 @@ void UIListBox::setTheme( UITheme * Theme ) { void UIListBox::autoPadding() { if ( mFlags & UI_AUTO_PADDING ) { - mPaddingContainer = makePadding(); + mContainerPadding = makePadding(); } } @@ -369,12 +369,12 @@ void UIListBox::itemUpdateSize( UIListBoxItem * Item ) { } void UIListBox::containerResize() { - mContainer->setPosition( mPaddingContainer.Left, mPaddingContainer.Top ); + mContainer->setPosition( mContainerPadding.Left, mContainerPadding.Top ); if( mHScrollBar->isVisible() ) - mContainer->setSize( mSize.getWidth() - mPaddingContainer.Right - mPaddingContainer.Left, mSize.getHeight() - mPaddingContainer.Top - mHScrollBar->getSize().getHeight() ); + mContainer->setSize( mSize.getWidth() - mContainerPadding.Right - mContainerPadding.Left, mSize.getHeight() - mContainerPadding.Top - mHScrollBar->getSize().getHeight() ); else - mContainer->setSize( mSize.getWidth() - mPaddingContainer.Right - mPaddingContainer.Left, mSize.getHeight() - mPaddingContainer.Bottom - mPaddingContainer.Top ); + mContainer->setSize( mSize.getWidth() - mContainerPadding.Right - mContainerPadding.Left, mSize.getHeight() - mContainerPadding.Bottom - mContainerPadding.Top ); } void UIListBox::createItemIndex( const Uint32& i ) { @@ -715,8 +715,8 @@ Graphics::Font * UIListBox::getFont() const { } void UIListBox::setContainerPadding( const Recti& Padding ) { - if ( Padding != mPaddingContainer ) { - mPaddingContainer = Padding; + if ( Padding != mContainerPadding ) { + mContainerPadding = Padding; containerResize(); updateScroll(); @@ -724,7 +724,7 @@ void UIListBox::setContainerPadding( const Recti& Padding ) { } const Recti& UIListBox::getContainerPadding() const { - return mPaddingContainer; + return mContainerPadding; } void UIListBox::setSmoothScroll( const bool& soft ) { @@ -892,7 +892,7 @@ Uint32 UIListBox::onMessage( const UIMessage * Msg ) { } void UIListBox::onAlphaChange() { - UIComplexControl::onAlphaChange(); + UIWidget::onAlphaChange(); if ( mItems.size() ) { for ( Uint32 i = mVisibleFirst; i <= mVisibleLast; i++ ) { @@ -963,11 +963,11 @@ void UIListBox::setTouchDragDeceleration(const Float & touchDragDeceleration) { mTouchDragDeceleration = touchDragDeceleration; } -TooltipStyleConfig UIListBox::getFontStyleConfig() const { +FontStyleConfig UIListBox::getFontStyleConfig() const { return mFontStyleConfig; } -void UIListBox::setFontStyleConfig(const TooltipStyleConfig & fontStyleConfig) { +void UIListBox::setFontStyleConfig(const FontStyleConfig & fontStyleConfig) { mFontStyleConfig = fontStyleConfig; setFont( mFontStyleConfig.Font ); @@ -1030,7 +1030,7 @@ void UIListBox::update() { } } - UIComplexControl::update(); + UIWidget::update(); } }} diff --git a/src/eepp/ui/uilistboxitem.cpp b/src/eepp/ui/uilistboxitem.cpp index 42a85b1e8..07c3d877d 100644 --- a/src/eepp/ui/uilistboxitem.cpp +++ b/src/eepp/ui/uilistboxitem.cpp @@ -9,7 +9,7 @@ UIListBoxItem * UIListBoxItem::New() { } UIListBoxItem::UIListBoxItem() : - UITextBox() + UITextView() { applyDefaultTheme(); } @@ -27,7 +27,7 @@ Uint32 UIListBoxItem::getType() const { } bool UIListBoxItem::isType( const Uint32& type ) const { - return UIListBoxItem::getType() == type ? true : UITextBox::isType( type ); + return UIListBoxItem::getType() == type ? true : UITextView::isType( type ); } void UIListBoxItem::setTheme( UITheme * Theme ) { @@ -78,7 +78,7 @@ void UIListBoxItem::select() { } void UIListBoxItem::update() { - UITextBox::update(); + UITextView::update(); if ( mEnabled && mVisible ) { UIListBox * LBParent = reinterpret_cast ( getParent()->getParent() ); diff --git a/src/eepp/ui/uimenu.cpp b/src/eepp/ui/uimenu.cpp index 4eefcf4e3..6f404635b 100644 --- a/src/eepp/ui/uimenu.cpp +++ b/src/eepp/ui/uimenu.cpp @@ -9,7 +9,7 @@ UIMenu *UIMenu::New() { } UIMenu::UIMenu() : - UIComplexControl(), + UIWidget(), mMaxWidth( 0 ), mNextPosY( 0 ), mBiggestIcon( 0 ), @@ -42,7 +42,7 @@ Uint32 UIMenu::getType() const { } bool UIMenu::isType( const Uint32& type ) const { - return UIMenu::getType() == type ? true : UIComplexControl::isType( type ); + return UIMenu::getType() == type ? true : UIWidget::isType( type ); } void UIMenu::setTheme( UITheme * Theme ) { @@ -177,7 +177,7 @@ void UIMenu::setControlSize( UIControl * Control, const Uint32& Pos ) { } Uint32 UIMenu::addSeparator() { - UISeparator * Control = UISeparator::New(); + UIMenuSeparator * Control = UIMenuSeparator::New(); Control->setParent( this ); Control->setPosition( mStyleConfig.Padding.Left, mStyleConfig.Padding.Top + mNextPosY ); Control->setSize( mSize.getWidth() - mStyleConfig.Padding.Left - mStyleConfig.Padding.Right, 3 ); @@ -398,7 +398,7 @@ void UIMenu::setItemSelected( UIControl * Item ) { void UIMenu::trySelect( UIControl * Ctrl, bool Up ) { if ( mItems.size() ) { - if ( !Ctrl->isType( UI_TYPE_SEPARATOR ) ) { + if ( !Ctrl->isType( UI_TYPE_MENU_SEPARATOR ) ) { setItemSelected( Ctrl ); } else { Uint32 Index = getItemIndex( Ctrl ); @@ -407,7 +407,7 @@ void UIMenu::trySelect( UIControl * Ctrl, bool Up ) { if ( Up ) { if ( Index > 0 ) { for ( Int32 i = (Int32)Index - 1; i >= 0; i-- ) { - if ( !mItems[i]->isType( UI_TYPE_SEPARATOR ) ) { + if ( !mItems[i]->isType( UI_TYPE_MENU_SEPARATOR ) ) { setItemSelected( mItems[i] ); return; } @@ -417,7 +417,7 @@ void UIMenu::trySelect( UIControl * Ctrl, bool Up ) { setItemSelected( mItems[ mItems.size() ] ); } else { for ( Uint32 i = Index + 1; i < mItems.size(); i++ ) { - if ( !mItems[i]->isType( UI_TYPE_SEPARATOR ) ) { + if ( !mItems[i]->isType( UI_TYPE_MENU_SEPARATOR ) ) { setItemSelected( mItems[i] ); return; } @@ -499,7 +499,7 @@ Uint32 UIMenu::onKeyDown( const UIEventKey& Event ) { } } - return UIComplexControl::onKeyDown( Event ); + return UIWidget::onKeyDown( Event ); } const Recti& UIMenu::getPadding() const { diff --git a/src/eepp/ui/uimenuseparator.cpp b/src/eepp/ui/uimenuseparator.cpp new file mode 100644 index 000000000..b84e78861 --- /dev/null +++ b/src/eepp/ui/uimenuseparator.cpp @@ -0,0 +1,35 @@ +#include +#include + +namespace EE { namespace UI { + +UIMenuSeparator * UIMenuSeparator::New() { + return eeNew( UIMenuSeparator, () ); +} + +UIMenuSeparator::UIMenuSeparator() : + UIControlAnim() +{ + applyDefaultTheme(); +} + +UIMenuSeparator::~UIMenuSeparator() { +} + +Uint32 UIMenuSeparator::getType() const { + return UI_TYPE_MENU_SEPARATOR; +} + +bool UIMenuSeparator::isType( const Uint32& type ) const { + return UIMenuSeparator::getType() == type ? true : UIControlAnim::isType( type ); +} + +void UIMenuSeparator::setTheme( UITheme * Theme ) { + UIControl::setThemeControl( Theme, "separator" ); + + if ( NULL != getSkin() ) { + setSize( Sizei( mSize.getWidth(), getSkin()->getSize().getHeight() ) ); + } +} + +}} diff --git a/src/eepp/ui/uimenusubmenu.cpp b/src/eepp/ui/uimenusubmenu.cpp index a1ca9dae1..8563cb98b 100644 --- a/src/eepp/ui/uimenusubmenu.cpp +++ b/src/eepp/ui/uimenusubmenu.cpp @@ -18,7 +18,7 @@ UIMenuSubMenu::UIMenuSubMenu() : mCbId( 0 ), mCbId2( 0 ) { - mArrow = UIGfx::New(); + mArrow = UIImage::New(); mArrow->setParent( this ); mArrow->setFlags( UI_AUTO_SIZE ); mArrow->setVisible( true ); @@ -123,7 +123,7 @@ Uint32 UIMenuSubMenu::onMouseExit( const Vector2i &Pos, const Uint32 Flags ) { return 1; } -UIGfx * UIMenuSubMenu::getArrow() const { +UIImage * UIMenuSubMenu::getArrow() const { return mArrow; } diff --git a/src/eepp/ui/uimessagebox.cpp b/src/eepp/ui/uimessagebox.cpp index 8176ed53e..d411e9dda 100644 --- a/src/eepp/ui/uimessagebox.cpp +++ b/src/eepp/ui/uimessagebox.cpp @@ -14,7 +14,7 @@ UIMessageBox::UIMessageBox( UI_MSGBOX_TYPE type , String message ) : { setInternalSize( Sizei( 1024, 1024 ) ); - mTextBox = UITextBox::New(); + mTextBox = UITextView::New(); mTextBox->setParent( getContainer() ) ->setHorizontalAlign( UI_HALIGN_CENTER ) ->setVerticalAlign( UI_VALIGN_CENTER ); @@ -127,7 +127,7 @@ Uint32 UIMessageBox::onMessage( const UIMessage * Msg ) { return UIWindow::onMessage( Msg ); } -UITextBox * UIMessageBox::getTextBox() const { +UITextView * UIMessageBox::getTextBox() const { return mTextBox; } diff --git a/src/eepp/ui/uiprogressbar.cpp b/src/eepp/ui/uiprogressbar.cpp index 170d9d92e..defae54ac 100644 --- a/src/eepp/ui/uiprogressbar.cpp +++ b/src/eepp/ui/uiprogressbar.cpp @@ -7,7 +7,7 @@ UIProgressBar *UIProgressBar::New() { } UIProgressBar::UIProgressBar() : - UIComplexControl(), + UIWidget(), mProgress( 0.f ), mTotalSteps( 100.f ), mParallax( NULL ) @@ -16,7 +16,7 @@ UIProgressBar::UIProgressBar() : UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); - mTextBox = UITextBox::New(); + mTextBox = UITextView::New(); mTextBox->setHorizontalAlign( UI_HALIGN_CENTER ); mTextBox->setParent( this ); mTextBox->setEnabled( false ); @@ -40,7 +40,7 @@ Uint32 UIProgressBar::getType() const { } bool UIProgressBar::isType( const Uint32& type ) const { - return UIProgressBar::getType() == type ? true : UIComplexControl::isType( type ); + return UIProgressBar::getType() == type ? true : UIWidget::isType( type ); } void UIProgressBar::draw() { @@ -200,7 +200,7 @@ void UIProgressBar::updateTextBox() { mTextBox->center(); } -UITextBox * UIProgressBar::getTextBox() const { +UITextView * UIProgressBar::getTextBox() const { return mTextBox; } diff --git a/src/eepp/ui/uipushbutton.cpp b/src/eepp/ui/uipushbutton.cpp index 8b097d3a3..99915d744 100644 --- a/src/eepp/ui/uipushbutton.cpp +++ b/src/eepp/ui/uipushbutton.cpp @@ -8,7 +8,7 @@ UIPushButton * UIPushButton::New() { } UIPushButton::UIPushButton() : - UIComplexControl(), + UIWidget(), mIcon( NULL ), mTextBox( NULL ) { @@ -28,7 +28,7 @@ UIPushButton::UIPushButton() : GfxFlags = UI_AUTO_SIZE | UI_VALIGN_CENTER | UI_HALIGN_CENTER; } - mIcon = UIGfx::New(); + mIcon = UIImage::New(); mIcon->setParent( this ); mIcon->setFlags( GfxFlags ); mIcon->unsetFlags( UI_AUTO_SIZE | UI_FIT_TO_CONTROL ); @@ -40,7 +40,7 @@ UIPushButton::UIPushButton() : mIcon->setVisible( true ); mIcon->setEnabled( false ); - mTextBox = UITextBox::New(); + mTextBox = UITextView::New(); mTextBox->setParent( this ); mTextBox->setVisible( true ); mTextBox->setEnabled( false ); @@ -62,7 +62,7 @@ Uint32 UIPushButton::getType() const { } bool UIPushButton::isType( const Uint32& type ) const { - return UIPushButton::getType() == type ? true : UIComplexControl::isType( type ); + return UIPushButton::getType() == type ? true : UIWidget::isType( type ); } void UIPushButton::onSizeChange() { @@ -154,13 +154,14 @@ UIPushButton * UIPushButton::setIcon( SubTexture * Icon ) { return this; } -UIGfx * UIPushButton::getIcon() const { +UIImage * UIPushButton::getIcon() const { return mIcon; } -void UIPushButton::setText( const String& text ) { +UIPushButton * UIPushButton::setText( const String& text ) { mTextBox->setText( text ); onSizeChange(); + return this; } const String& UIPushButton::getText() { @@ -184,7 +185,7 @@ const Int32& UIPushButton::getIconHorizontalMargin() const { return mStyleConfig.IconHorizontalMargin; } -UITextBox * UIPushButton::getTextBox() const { +UITextView * UIPushButton::getTextBox() const { return mTextBox; } @@ -227,7 +228,7 @@ Uint32 UIPushButton::onKeyDown( const UIEventKey& Event ) { setSkinState( UISkinState::StateMouseDown ); } - return UIComplexControl::onKeyDown( Event ); + return UIWidget::onKeyDown( Event ); } Uint32 UIPushButton::onKeyUp( const UIEventKey& Event ) { @@ -235,7 +236,7 @@ Uint32 UIPushButton::onKeyUp( const UIEventKey& Event ) { setPrevSkinState(); } - return UIComplexControl::onKeyUp( Event ); + return UIWidget::onKeyUp( Event ); } const ColorA& UIPushButton::getFontColor() const { return mStyleConfig.FontColor; diff --git a/src/eepp/ui/uiradiobutton.cpp b/src/eepp/ui/uiradiobutton.cpp index 6a87c339e..45a83ea99 100644 --- a/src/eepp/ui/uiradiobutton.cpp +++ b/src/eepp/ui/uiradiobutton.cpp @@ -10,7 +10,7 @@ UIRadioButton * UIRadioButton::New() { } UIRadioButton::UIRadioButton() : - UITextBox(), + UITextView(), mActiveButton(NULL), mInactiveButton(NULL), mActive( false ), @@ -30,7 +30,7 @@ UIRadioButton::UIRadioButton() : mInactiveButton->setPosition( 0, 0 ); mInactiveButton->setSize( 16, 16 ); - setPadding( Recti(0,0,0,0) ); + onPaddingChange(); applyDefaultTheme(); } @@ -43,7 +43,7 @@ Uint32 UIRadioButton::getType() const { } bool UIRadioButton::isType( const Uint32& type ) const { - return UIRadioButton::getType() == type ? true : UITextBox::isType( type ); + return UIRadioButton::getType() == type ? true : UITextView::isType( type ); } void UIRadioButton::setTheme( UITheme * Theme ) { @@ -72,7 +72,7 @@ void UIRadioButton::onThemeLoaded() { mMinControlSize = mActiveButton->getSkinSize(); - setPadding( Recti(0,0,0,0) ); + onPaddingChange(); } void UIRadioButton::onAutoSize() { @@ -85,7 +85,7 @@ void UIRadioButton::onAutoSize() { } void UIRadioButton::onSizeChange() { - UITextBox::onSizeChange(); + UITextView::onSizeChange(); mActiveButton->centerVertical(); mInactiveButton->centerVertical(); @@ -199,9 +199,7 @@ const bool& UIRadioButton::isActive() const { return mActive; } -void UIRadioButton::setPadding( const Recti& padding ) { - UITextBox::setPadding( padding ); - +void UIRadioButton::onPaddingChange() { mActiveButton->setPosition( mPadding.Left, mActiveButton->getPosition().y ); mInactiveButton->setPosition( mPadding.Left, mInactiveButton->getPosition().y ); @@ -235,11 +233,11 @@ Uint32 UIRadioButton::onKeyDown( const UIEventKey& Event ) { } } - return UITextBox::onKeyDown( Event ); + return UITextView::onKeyDown( Event ); } void UIRadioButton::onAlphaChange() { - UITextBox::onAlphaChange(); + UITextView::onAlphaChange(); mActiveButton->setAlpha( mAlpha ); mInactiveButton->setAlpha( mAlpha ); diff --git a/src/eepp/ui/uiscrollbar.cpp b/src/eepp/ui/uiscrollbar.cpp index 4315dfedf..f484364a0 100644 --- a/src/eepp/ui/uiscrollbar.cpp +++ b/src/eepp/ui/uiscrollbar.cpp @@ -9,7 +9,7 @@ UIScrollBar * UIScrollBar::New() { } UIScrollBar::UIScrollBar() : - UIComplexControl() + UIWidget() { mFlags |= UI_AUTO_SIZE; @@ -41,7 +41,7 @@ Uint32 UIScrollBar::getType() const { } bool UIScrollBar::isType( const Uint32& type ) const { - return UIScrollBar::getType() == type ? true : UIComplexControl::isType( type ); + return UIScrollBar::getType() == type ? true : UIWidget::isType( type ); } void UIScrollBar::setTheme( UITheme * Theme ) { @@ -105,7 +105,7 @@ void UIScrollBar::onSizeChange() { mSlider->adjustChilds(); - UIComplexControl::onSizeChange(); + UIWidget::onSizeChange(); } void UIScrollBar::adjustChilds() { diff --git a/src/eepp/ui/uiseparator.cpp b/src/eepp/ui/uiseparator.cpp deleted file mode 100644 index 9c974e607..000000000 --- a/src/eepp/ui/uiseparator.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -namespace EE { namespace UI { - -UISeparator * UISeparator::New() { - return eeNew( UISeparator, () ); -} - -UISeparator::UISeparator() : - UIControlAnim() -{ - applyDefaultTheme(); -} - -UISeparator::~UISeparator() { -} - -Uint32 UISeparator::getType() const { - return UI_TYPE_SEPARATOR; -} - -bool UISeparator::isType( const Uint32& type ) const { - return UISeparator::getType() == type ? true : UIControlAnim::isType( type ); -} - -void UISeparator::setTheme( UITheme * Theme ) { - UIControl::setThemeControl( Theme, "separator" ); - - if ( NULL != getSkin() ) { - setSize( Sizei( mSize.getWidth(), getSkin()->getSize().getHeight() ) ); - } -} - -}} diff --git a/src/eepp/ui/uislider.cpp b/src/eepp/ui/uislider.cpp index 7e9c20c9a..b26d2d923 100644 --- a/src/eepp/ui/uislider.cpp +++ b/src/eepp/ui/uislider.cpp @@ -9,7 +9,7 @@ UISlider *UISlider::New() { } UISlider::UISlider() : - UIComplexControl(), + UIWidget(), mOrientation( UI_HORIZONTAL ), mBackSlider( NULL ), mSlider( NULL ), @@ -64,7 +64,7 @@ Uint32 UISlider::getType() const { } bool UISlider::isType( const Uint32& type ) const { - return UISlider::getType() == type ? true : UIComplexControl::isType( type ); + return UISlider::getType() == type ? true : UIWidget::isType( type ); } void UISlider::setTheme( UITheme * Theme ) { @@ -86,7 +86,7 @@ void UISlider::setTheme( UITheme * Theme ) { } void UISlider::onSizeChange() { - UIComplexControl::onSizeChange(); + UIWidget::onSizeChange(); adjustChilds(); } @@ -307,7 +307,7 @@ Uint32 UISlider::onKeyDown( const UIEventKey &Event ) { } } - return UIComplexControl::onKeyDown( Event ); + return UIWidget::onKeyDown( Event ); } void UISlider::manageClick( const Uint32& Flags ) { @@ -388,7 +388,7 @@ UIControl * UISlider::getBackSlider() const { return mBackSlider; } -UIDragable * UISlider::getSliderButton() const { +UIDragableControl * UISlider::getSliderButton() const { return mSlider; } diff --git a/src/eepp/ui/uispinbox.cpp b/src/eepp/ui/uispinbox.cpp index 833b6ae91..d75a80b32 100644 --- a/src/eepp/ui/uispinbox.cpp +++ b/src/eepp/ui/uispinbox.cpp @@ -8,7 +8,7 @@ UISpinBox * UISpinBox::New() { } UISpinBox::UISpinBox() : - UIComplexControl(), + UIWidget(), mMinValue( 0.f ), mMaxValue( 1024.f ), mValue( 0 ), @@ -48,7 +48,7 @@ Uint32 UISpinBox::getType() const { } bool UISpinBox::isType( const Uint32& type ) const { - return UISpinBox::getType() == type ? true : UIComplexControl::isType( type ); + return UISpinBox::getType() == type ? true : UIWidget::isType( type ); } void UISpinBox::setTheme( UITheme * Theme ) { @@ -159,7 +159,7 @@ void UISpinBox::internalValue( const Float& Val, const bool& Force ) { } void UISpinBox::onSizeChange() { - UIComplexControl::onSizeChange(); + UIWidget::onSizeChange(); adjustChilds(); } diff --git a/src/eepp/ui/uisprite.cpp b/src/eepp/ui/uisprite.cpp index 84528f4c1..782b8c670 100644 --- a/src/eepp/ui/uisprite.cpp +++ b/src/eepp/ui/uisprite.cpp @@ -8,7 +8,7 @@ UISprite * UISprite::New() { } UISprite::UISprite() : - UIComplexControl(), + UIWidget(), mSprite( NULL ), mRender( RN_NORMAL ), mAlignOffset(0,0), @@ -26,7 +26,7 @@ Uint32 UISprite::getType() const { } bool UISprite::isType( const Uint32& type ) const { - return UISprite::getType() == type ? true : UIComplexControl::isType( type ); + return UISprite::getType() == type ? true : UIWidget::isType( type ); } Uint32 UISprite::deallocSprite() { @@ -69,7 +69,7 @@ void UISprite::draw() { } void UISprite::update() { - UIComplexControl::update(); + UIWidget::update(); if ( NULL != mSprite ) mSprite->update(); diff --git a/src/eepp/ui/uitab.cpp b/src/eepp/ui/uitab.cpp index d62b7f618..b6fe6a377 100644 --- a/src/eepp/ui/uitab.cpp +++ b/src/eepp/ui/uitab.cpp @@ -100,7 +100,7 @@ const String& UITab::getText() { return UIPushButton::getText(); } -void UITab::setText( const String &text ) { +UIPushButton * UITab::setText( const String &text ) { UITabWidget * tTabW = getTabWidget(); if ( NULL != tTabW ) { @@ -109,13 +109,14 @@ void UITab::setText( const String &text ) { onAutoSize(); - return; + return this; } } UIPushButton::setText( text ); onAutoSize(); + return this; } void UITab::onAutoSize() { diff --git a/src/eepp/ui/uigenericgrid.cpp b/src/eepp/ui/uitable.cpp similarity index 78% rename from src/eepp/ui/uigenericgrid.cpp rename to src/eepp/ui/uitable.cpp index a877039c3..5ef10be6b 100644 --- a/src/eepp/ui/uigenericgrid.cpp +++ b/src/eepp/ui/uitable.cpp @@ -1,15 +1,15 @@ -#include +#include #include namespace EE { namespace UI { -UIGenericGrid * UIGenericGrid::New() { - return eeNew( UIGenericGrid, () ); +UITable * UITable::New() { + return eeNew( UITable, () ); } -UIGenericGrid::UIGenericGrid() : - UIComplexControl(), - mPadding(), +UITable::UITable() : + UIWidget(), + mContainerPadding(), mSmoothScroll( false ), mContainer( NULL ), mVScrollBar( NULL ), @@ -31,12 +31,12 @@ UIGenericGrid::UIGenericGrid() : { setFlags( UI_AUTO_PADDING ); - mContainer = eeNew( UIItemContainer , () ); + mContainer = eeNew( UIItemContainer , () ); mContainer->setVisible( true ); mContainer->setEnabled( true ); mContainer->setParent( this ); - mContainer->setPosition( mPadding.Left, mPadding.Top ); - mContainer->setSize( mSize.getWidth() - mPadding.Right - mPadding.Left, mSize.getHeight() - mPadding.Top - mPadding.Bottom ); + mContainer->setPosition( mContainerPadding.Left, mContainerPadding.Top ); + mContainer->setSize( mSize.getWidth() - mContainerPadding.Right - mContainerPadding.Left, mSize.getHeight() - mContainerPadding.Top - mContainerPadding.Bottom ); mVScrollBar = UIScrollBar::New(); mVScrollBar->setOrientation( UI_VERTICAL ); @@ -55,24 +55,24 @@ UIGenericGrid::UIGenericGrid() : mVScrollBar->setVisible( UI_SCROLLBAR_ALWAYS_ON == mVScrollMode ); mVScrollBar->setEnabled( UI_SCROLLBAR_ALWAYS_ON == mVScrollMode ); - mVScrollBar->addEventListener( UIEvent::EventOnValueChange, cb::Make1( this, &UIGenericGrid::onScrollValueChange ) ); - mHScrollBar->addEventListener( UIEvent::EventOnValueChange, cb::Make1( this, &UIGenericGrid::onScrollValueChange ) ); + mVScrollBar->addEventListener( UIEvent::EventOnValueChange, cb::Make1( this, &UITable::onScrollValueChange ) ); + mHScrollBar->addEventListener( UIEvent::EventOnValueChange, cb::Make1( this, &UITable::onScrollValueChange ) ); applyDefaultTheme(); } -UIGenericGrid::~UIGenericGrid() { +UITable::~UITable() { } -Uint32 UIGenericGrid::getType() const { - return UI_TYPE_GENERICGRID; +Uint32 UITable::getType() const { + return UI_TYPE_TABLE; } -bool UIGenericGrid::isType( const Uint32& type ) const { - return UIGenericGrid::getType() == type ? true : UIControlAnim::isType( type ); +bool UITable::isType( const Uint32& type ) const { + return UITable::getType() == type ? true : UIControlAnim::isType( type ); } -void UIGenericGrid::setDefaultCollumnsWidth() { +void UITable::setDefaultCollumnsWidth() { if ( mCollWidthAssigned || 0 == mCollumnsCount || 0 == mRowHeight ) return; @@ -100,11 +100,11 @@ void UIGenericGrid::setDefaultCollumnsWidth() { updateCells(); } -void UIGenericGrid::onScrollValueChange( const UIEvent * Event ) { +void UITable::onScrollValueChange( const UIEvent * Event ) { updateScroll( true ); } -void UIGenericGrid::setTheme( UITheme * Theme ) { +void UITable::setTheme( UITheme * Theme ) { UIControl::setThemeControl( Theme, "genericgrid" ); autoPadding(); @@ -112,13 +112,13 @@ void UIGenericGrid::setTheme( UITheme * Theme ) { onSizeChange(); } -void UIGenericGrid::autoPadding() { +void UITable::autoPadding() { if ( mFlags & UI_AUTO_PADDING ) { - mPadding = makePadding(); + mContainerPadding = makePadding(); } } -void UIGenericGrid::onSizeChange() { +void UITable::onSizeChange() { mVScrollBar->setPosition( mSize.getWidth() - mVScrollBar->getSize().getWidth(), 0 ); mVScrollBar->setSize( mVScrollBar->getSize().getWidth(), mSize.getHeight() ); @@ -138,13 +138,13 @@ void UIGenericGrid::onSizeChange() { updateScroll(); } -void UIGenericGrid::containerResize() { - mContainer->setPosition( mPadding.Left, mPadding.Top ); +void UITable::containerResize() { + mContainer->setPosition( mContainerPadding.Left, mContainerPadding.Top ); if( mHScrollBar->isVisible() ) - mContainer->setSize( mSize.getWidth() - mPadding.Right, mSize.getHeight() - mPadding.Top - mHScrollBar->getSize().getHeight() ); + mContainer->setSize( mSize.getWidth() - mContainerPadding.Right, mSize.getHeight() - mContainerPadding.Top - mHScrollBar->getSize().getHeight() ); else - mContainer->setSize( mSize.getWidth() - mPadding.Right, mSize.getHeight() - mPadding.Bottom - mPadding.Top ); + mContainer->setSize( mSize.getWidth() - mContainerPadding.Right, mSize.getHeight() - mContainerPadding.Bottom - mContainerPadding.Top ); if ( mVScrollBar->isVisible() ) mContainer->setSize( mContainer->getSize().getWidth() - mVScrollBar->getSize().getWidth(), mContainer->getSize().getHeight() ); @@ -152,7 +152,7 @@ void UIGenericGrid::containerResize() { setDefaultCollumnsWidth(); } -void UIGenericGrid::updateVScroll() { +void UITable::updateVScroll() { if ( mItemsNotVisible <= 0 ) { if ( UI_SCROLLBAR_ALWAYS_ON == mVScrollMode ) { mVScrollBar->setVisible( true ); @@ -174,7 +174,7 @@ void UIGenericGrid::updateVScroll() { containerResize(); } -void UIGenericGrid::updateHScroll() { +void UITable::updateHScroll() { if ( mContainer->isClipped() && ( UI_SCROLLBAR_AUTO == mHScrollMode || UI_SCROLLBAR_ALWAYS_ON == mHScrollMode ) ) { if ( mContainer->getSize().getWidth() < (Int32)mTotalWidth ) { mHScrollBar->setVisible( true ); @@ -200,7 +200,7 @@ void UIGenericGrid::updateHScroll() { } } -void UIGenericGrid::setHScrollStep() { +void UITable::setHScrollStep() { Float width = (Float)mContainer->getRealSize().getWidth(); if ( ( mItemsNotVisible > 0 && UI_SCROLLBAR_AUTO == mVScrollMode ) || UI_SCROLLBAR_ALWAYS_ON == mVScrollMode ) @@ -221,11 +221,11 @@ void UIGenericGrid::setHScrollStep() { mHScrollBar->setClickStep( stepVal ); } -void UIGenericGrid::updateScroll( bool FromScrollChange ) { +void UITable::updateScroll( bool FromScrollChange ) { if ( !mItems.size() ) return; - UIGridCell * Item; + UITableCell * Item; Uint32 i, RelPos = 0, RelPosMax; Int32 ItemPos, ItemPosMax; Int32 tHLastScroll = mHScrollInit; @@ -327,13 +327,13 @@ void UIGenericGrid::updateScroll( bool FromScrollChange ) { setHScrollStep(); } -void UIGenericGrid::updateSize() { +void UITable::updateSize() { updateCollumnsPos(); mTotalHeight = mItems.size() * mRowHeight; } -void UIGenericGrid::add( UIGridCell * Cell ) { +void UITable::add( UITableCell * Cell ) { Cell->setParent( getContainer() ); mItems.push_back( Cell ); @@ -352,13 +352,13 @@ void UIGenericGrid::add( UIGridCell * Cell ) { mVScrollBar->setPageStep( ( (Float)mContainer->getSize().getHeight() /(Float) mRowHeight ) / (Float)mItems.size() ); } -void UIGenericGrid::remove( UIGridCell * Cell ) { +void UITable::remove( UITableCell * Cell ) { return remove( getItemIndex( Cell ) ); } -void UIGenericGrid::remove( std::vector ItemsIndex ) { +void UITable::remove( std::vector ItemsIndex ) { if ( ItemsIndex.size() && eeINDEX_NOT_FOUND != ItemsIndex[0] ) { - std::vector ItemsCpy; + std::vector ItemsCpy; bool erase; for ( Uint32 i = 0; i < mItems.size(); i++ ) { @@ -392,11 +392,11 @@ void UIGenericGrid::remove( std::vector ItemsIndex ) { } } -void UIGenericGrid::remove( Uint32 ItemIndex ) { +void UITable::remove( Uint32 ItemIndex ) { remove( std::vector ( 1, ItemIndex ) ); } -UIGenericGrid * UIGenericGrid::setCollumnWidth( const Uint32& CollumnIndex, const Uint32& CollumnWidth ) { +UITable * UITable::setCollumnWidth( const Uint32& CollumnIndex, const Uint32& CollumnWidth ) { eeASSERT( CollumnIndex < mCollumnsCount ); mCollWidthAssigned = true; @@ -410,11 +410,11 @@ UIGenericGrid * UIGenericGrid::setCollumnWidth( const Uint32& CollumnIndex, cons return this; } -Uint32 UIGenericGrid::getCount() const { +Uint32 UITable::getCount() const { return mItems.size(); } -UIGenericGrid * UIGenericGrid::setCollumnsCount(const Uint32 & collumnsCount) { +UITable * UITable::setCollumnsCount(const Uint32 & collumnsCount) { mCollumnsCount = collumnsCount; mCollumnsWidth.resize( mCollumnsCount, 0 ); @@ -425,17 +425,17 @@ UIGenericGrid * UIGenericGrid::setCollumnsCount(const Uint32 & collumnsCount) { return this; } -const Uint32& UIGenericGrid::getCollumnsCount() const { +const Uint32& UITable::getCollumnsCount() const { return mCollumnsCount; } -const Uint32& UIGenericGrid::getCollumnWidth( const Uint32& CollumnIndex ) const { +const Uint32& UITable::getCollumnWidth( const Uint32& CollumnIndex ) const { eeASSERT( CollumnIndex < mCollumnsCount ); return mCollumnsWidth[ CollumnIndex ]; } -UIGenericGrid * UIGenericGrid::setRowHeight( const Uint32& height ) { +UITable * UITable::setRowHeight( const Uint32& height ) { if ( mRowHeight != height ) { mRowHeight = height; @@ -447,29 +447,29 @@ UIGenericGrid * UIGenericGrid::setRowHeight( const Uint32& height ) { return this; } -const Uint32& UIGenericGrid::getRowHeight() const { +const Uint32& UITable::getRowHeight() const { return mRowHeight; } -UIGridCell * UIGenericGrid::getCell( const Uint32& CellIndex ) const { +UITableCell * UITable::getCell( const Uint32& CellIndex ) const { eeASSERT( CellIndex < mItems.size() ); return mItems[ CellIndex ]; } -Uint32 UIGenericGrid::getCellPosition( const Uint32& CollumnIndex ) { +Uint32 UITable::getCellPosition( const Uint32& CollumnIndex ) { eeASSERT( CollumnIndex < mCollumnsCount ); return mCollumnsPos[ CollumnIndex ]; } -void UIGenericGrid::updateCells() { +void UITable::updateCells() { for ( Uint32 i = 0; i < mItems.size(); i++ ) { mItems[i]->fixCell(); } } -void UIGenericGrid::updateCollumnsPos() { +void UITable::updateCollumnsPos() { Uint32 Pos = 0; for ( Uint32 i = 0; i < mCollumnsCount; i++ ) { @@ -481,14 +481,14 @@ void UIGenericGrid::updateCollumnsPos() { mTotalWidth = Pos; } -void UIGenericGrid::onAlphaChange() { +void UITable::onAlphaChange() { UIControlAnim::onAlphaChange(); mVScrollBar->setAlpha( mAlpha ); mHScrollBar->setAlpha( mAlpha ); } -void UIGenericGrid::setVerticalScrollMode( const UI_SCROLLBAR_MODE& Mode ) { +void UITable::setVerticalScrollMode( const UI_SCROLLBAR_MODE& Mode ) { if ( Mode != mVScrollMode ) { mVScrollMode = Mode; @@ -496,11 +496,11 @@ void UIGenericGrid::setVerticalScrollMode( const UI_SCROLLBAR_MODE& Mode ) { } } -const UI_SCROLLBAR_MODE& UIGenericGrid::getVerticalScrollMode() { +const UI_SCROLLBAR_MODE& UITable::getVerticalScrollMode() { return mVScrollMode; } -void UIGenericGrid::setHorizontalScrollMode( const UI_SCROLLBAR_MODE& Mode ) { +void UITable::setHorizontalScrollMode( const UI_SCROLLBAR_MODE& Mode ) { if ( Mode != mHScrollMode ) { mHScrollMode = Mode; @@ -518,19 +518,19 @@ void UIGenericGrid::setHorizontalScrollMode( const UI_SCROLLBAR_MODE& Mode ) { } } -const UI_SCROLLBAR_MODE& UIGenericGrid::getHorizontalScrollMode() { +const UI_SCROLLBAR_MODE& UITable::getHorizontalScrollMode() { return mHScrollMode; } -UIScrollBar * UIGenericGrid::getVerticalScrollBar() const { +UIScrollBar * UITable::getVerticalScrollBar() const { return mVScrollBar; } -UIScrollBar * UIGenericGrid::getHorizontalScrollBar() const { +UIScrollBar * UITable::getHorizontalScrollBar() const { return mHScrollBar; } -Uint32 UIGenericGrid::getItemIndex( UIGridCell * Item ) { +Uint32 UITable::getItemIndex( UITableCell * Item ) { for ( Uint32 i = 0; i < mItems.size(); i++ ) { if ( Item == mItems[i] ) return i; @@ -539,24 +539,24 @@ Uint32 UIGenericGrid::getItemIndex( UIGridCell * Item ) { return eeINDEX_NOT_FOUND; } -Uint32 UIGenericGrid::onSelected() { +Uint32 UITable::onSelected() { sendCommonEvent( UIEvent::EventOnItemSelected ); return 1; } -UIGridCell * UIGenericGrid::getItemSelected() { +UITableCell * UITable::getItemSelected() { if ( -1 != mSelected ) return mItems[ mSelected ]; return NULL; } -Uint32 UIGenericGrid::getItemSelectedIndex() const { +Uint32 UITable::getItemSelectedIndex() const { return mSelected; } -Uint32 UIGenericGrid::onMessage( const UIMessage * Msg ) { +Uint32 UITable::onMessage( const UIMessage * Msg ) { switch ( Msg->getMsg() ) { case UIMessage::MsgFocusLoss: { @@ -573,31 +573,31 @@ Uint32 UIGenericGrid::onMessage( const UIMessage * Msg ) { return 0; } -UIItemContainer * UIGenericGrid::getContainer() const { +UIItemContainer * UITable::getContainer() const { return mContainer; } -bool UIGenericGrid::isTouchDragEnabled() const { +bool UITable::isTouchDragEnabled() const { return 0 != ( mFlags & UI_TOUCH_DRAG_ENABLED ); } -void UIGenericGrid::setTouchDragEnabled( const bool& enable ) { +void UITable::setTouchDragEnabled( const bool& enable ) { writeFlag( UI_TOUCH_DRAG_ENABLED, true == enable ); } -bool UIGenericGrid::isTouchDragging() const { +bool UITable::isTouchDragging() const { return 0 != ( mControlFlags & UI_CTRL_FLAG_TOUCH_DRAGGING ); } -void UIGenericGrid::setTouchDragging( const bool& dragging ) { +void UITable::setTouchDragging( const bool& dragging ) { writeCtrlFlag( UI_CTRL_FLAG_TOUCH_DRAGGING, true == dragging ); } -bool UIGenericGrid::getSmoothScroll() const { +bool UITable::getSmoothScroll() const { return mSmoothScroll; } -void UIGenericGrid::setSmoothScroll(bool smoothScroll) { +void UITable::setSmoothScroll(bool smoothScroll) { mSmoothScroll = smoothScroll; if ( mSmoothScroll ) { @@ -607,15 +607,26 @@ void UIGenericGrid::setSmoothScroll(bool smoothScroll) { } } -Float UIGenericGrid::getTouchDragDeceleration() const { +Float UITable::getTouchDragDeceleration() const { return mTouchDragDeceleration; } -void UIGenericGrid::setTouchDragDeceleration(const Float & touchDragDeceleration) { +void UITable::setTouchDragDeceleration(const Float & touchDragDeceleration) { mTouchDragDeceleration = touchDragDeceleration; } -void UIGenericGrid::update() { +Recti UITable::getContainerPadding() const { + return mContainerPadding; +} + +void UITable::setContainerPadding(const Recti & containerPadding) { + if ( containerPadding != mContainerPadding ) { + mContainerPadding = containerPadding; + containerResize(); + } +} + +void UITable::update() { if ( mEnabled && mVisible ) { if ( mFlags & UI_TOUCH_DRAG_ENABLED ) { Uint32 Press = UIManager::instance()->getPressTrigger(); @@ -671,7 +682,7 @@ void UIGenericGrid::update() { } } - UIComplexControl::update(); + UIWidget::update(); } }} diff --git a/src/eepp/ui/uigridcell.cpp b/src/eepp/ui/uitablecell.cpp similarity index 71% rename from src/eepp/ui/uigridcell.cpp rename to src/eepp/ui/uitablecell.cpp index 21da75276..bf0ddd1d1 100644 --- a/src/eepp/ui/uigridcell.cpp +++ b/src/eepp/ui/uitablecell.cpp @@ -1,20 +1,20 @@ -#include -#include +#include +#include #include namespace EE { namespace UI { -UIGridCell * UIGridCell::New() { - return eeNew( UIGridCell, () ); +UITableCell * UITableCell::New() { + return eeNew( UITableCell, () ); } -UIGridCell::UIGridCell() : - UIComplexControl() +UITableCell::UITableCell() : + UIWidget() { applyDefaultTheme(); } -UIGridCell::~UIGridCell() { +UITableCell::~UITableCell() { if ( UIManager::instance()->getFocusControl() == this ) mParentCtrl->setFocus(); @@ -22,18 +22,18 @@ UIGridCell::~UIGridCell() { UIManager::instance()->setOverControl( mParentCtrl ); } -void UIGridCell::setTheme( UITheme * Theme ) { +void UITableCell::setTheme( UITheme * Theme ) { UIControl::setThemeControl( Theme, "gridcell" ); } -UIGenericGrid * UIGridCell::gridParent() const { - return reinterpret_cast ( mParentCtrl->getParent() ); +UITable * UITableCell::gridParent() const { + return reinterpret_cast ( mParentCtrl->getParent() ); } -void UIGridCell::setCell( const Uint32& CollumnIndex, UIControl * Ctrl ) { +void UITableCell::setCell( const Uint32& CollumnIndex, UIControl * Ctrl ) { eeASSERT( CollumnIndex < gridParent()->getCollumnsCount() ); - UIGenericGrid * P = gridParent(); + UITable * P = gridParent(); mCells[ CollumnIndex ] = Ctrl; @@ -47,16 +47,16 @@ void UIGridCell::setCell( const Uint32& CollumnIndex, UIControl * Ctrl ) { Ctrl->setEnabled( true ); } -UIControl * UIGridCell::getCell( const Uint32& CollumnIndex ) const { +UIControl * UITableCell::getCell( const Uint32& CollumnIndex ) const { eeASSERT( CollumnIndex < gridParent()->getCollumnsCount() ); return mCells[ CollumnIndex ]; } -void UIGridCell::fixCell() { +void UITableCell::fixCell() { onAutoSize(); - UIGenericGrid * P = gridParent(); + UITable * P = gridParent(); for ( Uint32 i = 0; i < mCells.size(); i++ ) { mCells[i]->setPosition ( P->getCellPosition( i ) , 0 ); @@ -64,9 +64,9 @@ void UIGridCell::fixCell() { } } -void UIGridCell::update() { +void UITableCell::update() { if ( mEnabled && mVisible ) { - UIGenericGrid * MyParent = reinterpret_cast ( getParent()->getParent() ); + UITable * MyParent = reinterpret_cast ( getParent()->getParent() ); Uint32 Flags = UIManager::instance()->getInput()->getClickTrigger(); if ( NULL != MyParent && MyParent->getAlpha() != mAlpha ) { @@ -86,11 +86,11 @@ void UIGridCell::update() { } } - UIComplexControl::update(); + UIWidget::update(); } -void UIGridCell::select() { - UIGenericGrid * MyParent = reinterpret_cast ( getParent()->getParent() ); +void UITableCell::select() { + UITable * MyParent = reinterpret_cast ( getParent()->getParent() ); if ( MyParent->getItemSelected() != this ) { if ( NULL != MyParent->getItemSelected() ) @@ -110,18 +110,18 @@ void UIGridCell::select() { } } -void UIGridCell::unselect() { +void UITableCell::unselect() { if ( mControlFlags & UI_CTRL_FLAG_SELECTED ) mControlFlags &= ~UI_CTRL_FLAG_SELECTED; setSkinState( UISkinState::StateNormal ); } -bool UIGridCell::isSelected() const { +bool UITableCell::isSelected() const { return 0 != ( mControlFlags & UI_CTRL_FLAG_SELECTED ); } -Uint32 UIGridCell::onMouseExit( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UITableCell::onMouseExit( const Vector2i& Pos, const Uint32 Flags ) { UIControl::onMouseExit( Pos, Flags ); if ( mControlFlags & UI_CTRL_FLAG_SELECTED ) @@ -130,7 +130,7 @@ Uint32 UIGridCell::onMouseExit( const Vector2i& Pos, const Uint32 Flags ) { return 1; } -Uint32 UIGridCell::onMessage( const UIMessage * Msg ) { +Uint32 UITableCell::onMessage( const UIMessage * Msg ) { switch( Msg->getMsg() ) { case UIMessage::MsgMouseEnter: { @@ -159,19 +159,19 @@ Uint32 UIGridCell::onMessage( const UIMessage * Msg ) { return 0; } -void UIGridCell::onAutoSize() { - UIGenericGrid * MyParent = reinterpret_cast ( getParent()->getParent() ); +void UITableCell::onAutoSize() { + UITable * MyParent = reinterpret_cast ( getParent()->getParent() ); setSize( MyParent->mTotalWidth, MyParent->mRowHeight ); } -void UIGridCell::onStateChange() { +void UITableCell::onStateChange() { if ( isSelected() && mSkinState->getState() != UISkinState::StateSelected ) { setSkinState( UISkinState::StateSelected ); } } -void UIGridCell::onParentChange() { +void UITableCell::onParentChange() { if ( NULL != getParent() && NULL != gridParent() ) mCells.resize( gridParent()->getCollumnsCount(), NULL ); } diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp index 3308ad9be..177825a3a 100644 --- a/src/eepp/ui/uitabwidget.cpp +++ b/src/eepp/ui/uitabwidget.cpp @@ -10,7 +10,7 @@ UITabWidget * UITabWidget::New() { } UITabWidget::UITabWidget() : - UIComplexControl(), + UIWidget(), mTabSelected( NULL ), mTabSelectedIndex( eeINDEX_NOT_FOUND ) { @@ -22,11 +22,11 @@ UITabWidget::UITabWidget() : mStyleConfig = Theme->getTabWidgetStyleConfig(); } - mTabContainer = UIComplexControl::New(); + mTabContainer = UIWidget::New(); mTabContainer->setParent( this )->setPosition( 0, 0 )->setSize( mSize.getWidth(), mStyleConfig.TabWidgetHeight )->setVisible( true )->setEnabled( true ); mTabContainer->setFlags( UI_CLIP_ENABLE | UI_ANCHOR_RIGHT ); - mCtrlContainer = UIComplexControl::New(); + mCtrlContainer = UIWidget::New(); 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 ); @@ -44,7 +44,7 @@ Uint32 UITabWidget::getType() const { } bool UITabWidget::isType( const Uint32& type ) const { - return UITabWidget::getType() == type ? true : UIComplexControl::isType( type ); + return UITabWidget::getType() == type ? true : UIWidget::isType( type ); } void UITabWidget::setTheme( UITheme * Theme ) { @@ -80,7 +80,7 @@ void UITabWidget::seContainerSize() { } void UITabWidget::draw() { - UIComplexControl::draw(); + UIWidget::draw(); if ( mStyleConfig.DrawLineBelowTabs ) { bool smooth = GLi->isLineSmooth(); @@ -545,11 +545,11 @@ void UITabWidget::applyThemeToTabs() { } } -UIComplexControl * UITabWidget::getTabContainer() const { +UIWidget * UITabWidget::getTabContainer() const { return mTabContainer; } -UIComplexControl * UITabWidget::getControlContainer() const { +UIWidget * UITabWidget::getControlContainer() const { return mCtrlContainer; } diff --git a/src/eepp/ui/uitextedit.cpp b/src/eepp/ui/uitextedit.cpp index 021b7b267..2ede8f133 100644 --- a/src/eepp/ui/uitextedit.cpp +++ b/src/eepp/ui/uitextedit.cpp @@ -10,7 +10,7 @@ UITextEdit *UITextEdit::New() { } UITextEdit::UITextEdit() : - UIComplexControl(), + UIWidget(), mTextInput( NULL ), mHScrollBar( NULL ), mVScrollBar( NULL ), @@ -64,7 +64,7 @@ Uint32 UITextEdit::getType() const { } bool UITextEdit::isType( const Uint32& type ) const { - return UITextEdit::getType() == type ? true : UIComplexControl::isType( type ); + return UITextEdit::getType() == type ? true : UIWidget::isType( type ); } void UITextEdit::setTheme( UITheme * Theme ) { @@ -84,7 +84,7 @@ void UITextEdit::onSizeChange() { mHScrollBar->setSize( mSize.getWidth(), mHScrollBar->getSize().getHeight() ); mVScrollBar->setSize( mVScrollBar->getSize().getWidth(), mSize.getHeight() ); - mTextInput->setPosition( PixelDensity::pxToDpI( mPadding.Left ), PixelDensity::pxToDpI( mPadding.Top ) ); + mTextInput->setPosition( PixelDensity::pxToDpI( mContainerPadding.Left ), PixelDensity::pxToDpI( mContainerPadding.Top ) ); scrollbarsSet(); @@ -92,7 +92,7 @@ void UITextEdit::onSizeChange() { } void UITextEdit::onParentSizeChange( const Vector2i& SizeChange ) { - UIComplexControl::onParentSizeChange( SizeChange ); + UIWidget::onParentSizeChange( SizeChange ); onInputSizeChange( NULL ); } @@ -102,12 +102,12 @@ void UITextEdit::onAlphaChange() { mHScrollBar->setAlpha( mAlpha ); mVScrollBar->setAlpha( mAlpha ); - UIComplexControl::onAlphaChange(); + UIWidget::onAlphaChange(); } void UITextEdit::fixScroll() { - int Width = mRealSize.getWidth() - mPadding.Left - mPadding.Right; - int Height = mRealSize.getHeight() - mPadding.Top - mPadding.Bottom; + int Width = mRealSize.getWidth() - mContainerPadding.Left - mContainerPadding.Right; + int Height = mRealSize.getHeight() - mContainerPadding.Top - mContainerPadding.Bottom; if ( mHScrollBar->isVisible() ) Height -= mHScrollBar->getRealSize().getHeight(); @@ -120,7 +120,7 @@ void UITextEdit::fixScroll() { pos = diff * mVScrollBar->getValue(); - mTextInput->setPixelsPosition( mTextInput->getRealPosition().x, mPadding.Top - pos ); + mTextInput->setPixelsPosition( mTextInput->getRealPosition().x, mContainerPadding.Top - pos ); } if ( mTextInput->getRealSize().getWidth() - Width >= 0 ) { @@ -128,7 +128,7 @@ void UITextEdit::fixScroll() { pos = diff * mHScrollBar->getValue(); - mTextInput->setPixelsPosition( mPadding.Left - pos, mTextInput->getRealPosition().y ); + mTextInput->setPixelsPosition( mContainerPadding.Left - pos, mTextInput->getRealPosition().y ); } } @@ -148,7 +148,7 @@ void UITextEdit::scrollbarsSet() { } case UI_SCROLLBAR_AUTO: { - if ( mTextInput->getTextWidth() > mRealSize.getWidth() - mPadding.Left - mPadding.Right ) { + if ( mTextInput->getTextWidth() > mRealSize.getWidth() - mContainerPadding.Left - mContainerPadding.Right ) { mHScrollBar->setVisible( true ); mHScrollBar->setEnabled( true ); } else { @@ -179,7 +179,7 @@ void UITextEdit::scrollbarsSet() { if ( mHScrollBar->isVisible() ) extraH = mHScrollBar->getRealSize().getHeight(); - if ( mTextInput->getTextHeight() > mRealSize.getHeight() - mPadding.Top - mPadding.Bottom - extraH ) { + if ( mTextInput->getTextHeight() > mRealSize.getHeight() - mContainerPadding.Top - mContainerPadding.Bottom - extraH ) { mVScrollBar->setVisible( true ); mVScrollBar->setEnabled( true ); } else { @@ -197,7 +197,7 @@ void UITextEdit::scrollbarsSet() { } if ( UI_SCROLLBAR_AUTO == mHScrollBarMode && mVScrollBar->isVisible() && !mHScrollBar->isVisible() ) { - if ( mTextInput->getTextWidth() > mRealSize.getWidth() - mPadding.Left - mPadding.Right - mVScrollBar->getRealSize().getWidth() ) { + if ( mTextInput->getTextWidth() > mRealSize.getWidth() - mContainerPadding.Left - mContainerPadding.Right - mVScrollBar->getRealSize().getWidth() ) { mHScrollBar->setVisible( true ); mHScrollBar->setEnabled( true ); } @@ -215,7 +215,7 @@ void UITextEdit::scrollbarsSet() { if ( mHScrollBar->isVisible() ) extraH = mHScrollBar->getRealSize().getHeight(); - Int32 totH = mRealSize.getHeight() - mPadding.Top - mPadding.Bottom - extraH; + Int32 totH = mRealSize.getHeight() - mContainerPadding.Top - mContainerPadding.Bottom - extraH; if ( mTextInput->getTextHeight() > totH ) { mVScrollBar->setPageStep( (Float)totH / (Float)mTextInput->getTextHeight() ); @@ -223,7 +223,7 @@ void UITextEdit::scrollbarsSet() { } if ( mHScrollBar->isVisible() ) { - Int32 totW = mRealSize.getWidth() - mPadding.Left - mPadding.Right - mVScrollBar->getRealSize().getWidth(); + Int32 totW = mRealSize.getWidth() - mContainerPadding.Left - mContainerPadding.Right - mVScrollBar->getRealSize().getWidth(); if ( mTextInput->getTextWidth() > totW ) { mHScrollBar->setPageStep( (Float)totW / (Float)mTextInput->getTextWidth() ); @@ -234,7 +234,7 @@ void UITextEdit::scrollbarsSet() { void UITextEdit::autoPadding() { if ( mFlags & UI_AUTO_PADDING ) { - mPadding = PixelDensity::dpToPxI( makePadding() ); + mContainerPadding = PixelDensity::dpToPxI( makePadding() ); } } @@ -273,8 +273,8 @@ void UITextEdit::setText( const String& Txt ) { } void UITextEdit::onInputSizeChange( const UIEvent * Event ) { - int Width = mRealSize.getWidth() - mPadding.Left - mPadding.Right; - int Height = mRealSize.getHeight() - mPadding.Top - mPadding.Bottom; + int Width = mRealSize.getWidth() - mContainerPadding.Left - mContainerPadding.Right; + int Height = mRealSize.getHeight() - mContainerPadding.Top - mContainerPadding.Bottom; if ( NULL != Event ) { if ( Event->getEventType() == UIEvent::EventOnPressEnter ) { @@ -332,8 +332,8 @@ void UITextEdit::onCursorPosChange( const UIEvent * Event ) { } void UITextEdit::fixScrollToCursor() { - int Width = mRealSize.getWidth() - mPadding.Left - mPadding.Right; - int Height = mRealSize.getHeight() - mPadding.Top - mPadding.Bottom; + int Width = mRealSize.getWidth() - mContainerPadding.Left - mContainerPadding.Right; + int Height = mRealSize.getHeight() - mContainerPadding.Top - mContainerPadding.Bottom; if ( mVScrollBar->isVisible() ) Width -= mVScrollBar->getRealSize().getWidth(); @@ -357,15 +357,15 @@ void UITextEdit::fixScrollToCursor() { Float tH = (Float)(LineNum + 1) * (Float)mTextInput->getTextCache()->getFont()->getFontHeight(); if ( tW > Width ) { - mTextInput->setPixelsPosition( mPadding.Left + Width - tW, mTextInput->getRealPosition().y ); + mTextInput->setPixelsPosition( mContainerPadding.Left + Width - tW, mTextInput->getRealPosition().y ); } else { - mTextInput->setPixelsPosition( mPadding.Left, mTextInput->getRealPosition().y ); + mTextInput->setPixelsPosition( mContainerPadding.Left, mTextInput->getRealPosition().y ); } if ( tH > Height ) { - mTextInput->setPixelsPosition( mTextInput->getRealPosition().x, mPadding.Top + Height - tH ); + mTextInput->setPixelsPosition( mTextInput->getRealPosition().x, mContainerPadding.Top + Height - tH ); } else { - mTextInput->setPixelsPosition( mTextInput->getRealPosition().x, mPadding.Top ); + mTextInput->setPixelsPosition( mTextInput->getRealPosition().x, mContainerPadding.Top ); } mHScrollBar->setValue( tW / mTextInput->getRealSize().getWidth() ); @@ -424,11 +424,11 @@ const UI_SCROLLBAR_MODE& UITextEdit::getHorizontalScrollMode() { return mHScrollBarMode; } -TooltipStyleConfig UITextEdit::getFontStyleConfig() const { +FontStyleConfig UITextEdit::getFontStyleConfig() const { return mTextInput->getFontStyleConfig(); } -void UITextEdit::setFontStyleConfig(const TooltipStyleConfig & fontStyleConfig) { +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 7c03450c4..84c7217db 100644 --- a/src/eepp/ui/uitextinput.cpp +++ b/src/eepp/ui/uitextinput.cpp @@ -13,7 +13,7 @@ UITextInput * UITextInput::New() { } UITextInput::UITextInput() : - UITextBox(), + UITextView(), mCursorPos(0), mAllowEditing( true ), mShowingWait( true ) @@ -37,7 +37,7 @@ Uint32 UITextInput::getType() const { } bool UITextInput::isType( const Uint32& type ) const { - return UITextInput::getType() == type ? true : UITextBox::isType( type ); + return UITextInput::getType() == type ? true : UITextView::isType( type ); } void UITextInput::update() { @@ -45,12 +45,12 @@ void UITextInput::update() { UIManager::instance()->setCursor( EE_CURSOR_IBEAM ); } - UITextBox::update(); + UITextView::update(); if ( mTextBuffer.changedSinceLastUpdate() ) { Vector2f offSet = mRealAlignOffset; - UITextBox::setText( mTextBuffer.getBuffer() ); + UITextView::setText( mTextBuffer.getBuffer() ); updateText(); @@ -113,7 +113,7 @@ void UITextInput::drawWaitingCursor() { } void UITextInput::draw() { - UITextBox::draw(); + UITextView::draw(); drawWaitingCursor(); } @@ -132,7 +132,7 @@ Uint32 UITextInput::onFocus() { Uint32 UITextInput::onFocusLoss() { mTextBuffer.setActive( false ); - return UITextBox::onFocusLoss(); + return UITextView::onFocusLoss(); } Uint32 UITextInput::onPressEnter() { @@ -182,7 +182,7 @@ void UITextInput::setTheme( UITheme * Theme ) { } void UITextInput::onThemeLoaded() { - UITextBox::onThemeLoaded(); + UITextView::onThemeLoaded(); mMinControlSize.y = eemax( mMinControlSize.y, getSkinSize().getHeight() ); @@ -219,8 +219,8 @@ const bool& UITextInput::getAllowEditing() const { return mAllowEditing; } -UITextBox * UITextInput::setText( const String& text ) { - UITextBox::setText( text ); +UITextView * UITextInput::setText( const String& text ) { + UITextView::setText( text ); mTextBuffer.setBuffer( text ); @@ -230,13 +230,13 @@ UITextBox * UITextInput::setText( const String& text ) { } const String& UITextInput::getText() { - return UITextBox::getText(); + return UITextView::getText(); } void UITextInput::shrinkText( const Uint32& MaxWidth ) { mTextCache->setText( mTextBuffer.getBuffer() ); - UITextBox::shrinkText( MaxWidth ); + UITextView::shrinkText( MaxWidth ); mTextBuffer.setBuffer( mTextCache->getText() ); @@ -260,11 +260,11 @@ Uint32 UITextInput::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { } } - return UITextBox::onMouseClick( Pos, Flags ); + return UITextView::onMouseClick( Pos, Flags ); } Uint32 UITextInput::onMouseDoubleClick( const Vector2i& Pos, const Uint32 Flags ) { - UITextBox::onMouseDoubleClick( Pos, Flags ); + UITextView::onMouseDoubleClick( Pos, Flags ); if ( isTextSelectionEnabled() && ( Flags & EE_BUTTON_LMASK ) && selCurEnd() != -1 ) { mTextBuffer.setCursorPos( selCurEnd() ); diff --git a/src/eepp/ui/uitextinputpassword.cpp b/src/eepp/ui/uitextinputpassword.cpp index 2d8daf6f2..35fa67bce 100644 --- a/src/eepp/ui/uitextinputpassword.cpp +++ b/src/eepp/ui/uitextinputpassword.cpp @@ -122,7 +122,7 @@ void UITextInputPassword::updatePass( const String& pass ) { mPassCache->setText( newTxt ); } -UITextBox * UITextInputPassword::setText( const String& text ) { +UITextView * UITextInputPassword::setText( const String& text ) { UITextInput::setText( text ); updatePass( text ); @@ -143,7 +143,7 @@ void UITextInputPassword::setFontStyleConfig(const TooltipStyleConfig & fontStyl } const String& UITextInputPassword::getText() { - return UITextBox::getText(); + return UITextView::getText(); } diff --git a/src/eepp/ui/uitextbox.cpp b/src/eepp/ui/uitextview.cpp similarity index 73% rename from src/eepp/ui/uitextbox.cpp rename to src/eepp/ui/uitextview.cpp index 1d9ada471..b809f7a64 100644 --- a/src/eepp/ui/uitextbox.cpp +++ b/src/eepp/ui/uitextview.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -8,12 +8,12 @@ namespace EE { namespace UI { -UITextBox *UITextBox::New() { - return eeNew( UITextBox, () ); +UITextView * UITextView::New() { + return eeNew( UITextView, () ); } -UITextBox::UITextBox() : - UIComplexControl(), +UITextView::UITextView() : + UIWidget(), mRealAlignOffset( 0.f, 0.f ), mSelCurInit( -1 ), mSelCurEnd( -1 ) @@ -28,19 +28,19 @@ UITextBox::UITextBox() : autoAlign(); } -UITextBox::~UITextBox() { +UITextView::~UITextView() { eeSAFE_DELETE( mTextCache ); } -Uint32 UITextBox::getType() const { - return UI_TYPE_TEXTBOX; +Uint32 UITextView::getType() const { + return UI_TYPE_TEXTVIEW; } -bool UITextBox::isType( const Uint32& type ) const { - return UITextBox::getType() == type ? true : UIComplexControl::isType( type ); +bool UITextView::isType( const Uint32& type ) const { + return UITextView::getType() == type ? true : UIWidget::isType( type ); } -void UITextBox::draw() { +void UITextView::draw() { if ( mVisible && 0.f != mAlpha ) { UIControlAnim::draw(); @@ -67,11 +67,11 @@ void UITextBox::draw() { } } -Graphics::Font * UITextBox::getFont() const { +Graphics::Font * UITextView::getFont() const { return mTextCache->getFont(); } -void UITextBox::setFont( Graphics::Font * font ) { +void UITextView::setFont( Graphics::Font * font ) { if ( mTextCache->getFont() != font ) { mTextCache->setFont( font ); autoShrink(); @@ -81,14 +81,14 @@ void UITextBox::setFont( Graphics::Font * font ) { } } -const String& UITextBox::getText() { +const String& UITextView::getText() { if ( mFlags & UI_WORD_WRAP ) return mString; return mTextCache->getText(); } -UITextBox * UITextBox::setText( const String& text ) { +UITextView * UITextView::setText( const String& text ) { if ( mFlags & UI_WORD_WRAP ) { mString = text; mTextCache->setText( mString ); @@ -104,35 +104,35 @@ UITextBox * UITextBox::setText( const String& text ) { return this; } -const ColorA& UITextBox::getFontColor() const { +const ColorA& UITextView::getFontColor() const { return mFontStyleConfig.FontColor; } -void UITextBox::setFontColor( const ColorA& color ) { +void UITextView::setFontColor( const ColorA& color ) { mFontStyleConfig.FontColor = color; mTextCache->setColor( color ); setAlpha( color.a() ); } -const ColorA& UITextBox::getFontShadowColor() const { +const ColorA& UITextView::getFontShadowColor() const { return mFontStyleConfig.FontShadowColor; } -void UITextBox::setFontShadowColor( const ColorA& color ) { +void UITextView::setFontShadowColor( const ColorA& color ) { mFontStyleConfig.FontShadowColor = color; mTextCache->setShadowColor( mFontStyleConfig.FontShadowColor ); } -const ColorA& UITextBox::getSelectionBackColor() const { +const ColorA& UITextView::getSelectionBackColor() const { return mFontStyleConfig.FontSelectionBackColor; } -void UITextBox::setSelectionBackColor( const ColorA& color ) { +void UITextView::setSelectionBackColor( const ColorA& color ) { mFontStyleConfig.FontSelectionBackColor = color; } -void UITextBox::setAlpha( const Float& alpha ) { +void UITextView::setAlpha( const Float& alpha ) { UIControlAnim::setAlpha( alpha ); mFontStyleConfig.FontColor.Alpha = (Uint8)alpha; mFontStyleConfig.FontShadowColor.Alpha = (Uint8)alpha; @@ -140,13 +140,13 @@ void UITextBox::setAlpha( const Float& alpha ) { mTextCache->setAlpha( mFontStyleConfig.FontColor.Alpha ); } -void UITextBox::autoShrink() { +void UITextView::autoShrink() { if ( mFlags & UI_WORD_WRAP ) { shrinkText( mRealSize.getWidth() ); } } -void UITextBox::shrinkText( const Uint32& MaxWidth ) { +void UITextView::shrinkText( const Uint32& MaxWidth ) { if ( mFlags & UI_WORD_WRAP ) { mTextCache->setText( mString ); } @@ -155,13 +155,15 @@ void UITextBox::shrinkText( const Uint32& MaxWidth ) { mTextCache->cacheWidth(); } -void UITextBox::onAutoSize() { - if ( ( mFlags & UI_AUTO_SIZE ) ) { +void UITextView::onAutoSize() { + if ( ( mFlags & UI_AUTO_SIZE && 0 == mSize.getHeight() ) ) { setInternalPixelsSize( Sizei( (int)mTextCache->getTextWidth(), (int)mTextCache->getTextHeight() ) ); + + autoAlign(); } } -void UITextBox::autoAlign() { +void UITextView::autoAlign() { switch ( fontHAlignGet( getFlags() ) ) { case UI_HALIGN_CENTER: mRealAlignOffset.x = (Float)( (Int32)( mRealSize.x - mTextCache->getTextWidth() ) / 2 ); @@ -189,14 +191,14 @@ void UITextBox::autoAlign() { mAlignOffset = PixelDensity::pxToDpI( mRealAlignOffset ); } -Uint32 UITextBox::onFocusLoss() { +Uint32 UITextView::onFocusLoss() { selCurInit( -1 ); selCurEnd( -1 ); return 1; } -void UITextBox::onSizeChange() { +void UITextView::onSizeChange() { autoShrink(); onAutoSize(); autoAlign(); @@ -206,24 +208,15 @@ void UITextBox::onSizeChange() { mTextCache->cacheWidth(); } -void UITextBox::onTextChanged() { +void UITextView::onTextChanged() { sendCommonEvent( UIEvent::EventOnTextChanged ); } -void UITextBox::onFontChanged() { +void UITextView::onFontChanged() { sendCommonEvent( UIEvent::EventOnFontChanged ); } -void UITextBox::setPadding( const Recti& padding ) { - mPadding = padding; - mRealPadding = PixelDensity::dpToPxI( padding ); -} - -const Recti& UITextBox::getPadding() const { - return mPadding; -} - -void UITextBox::setTheme( UITheme * Theme ) { +void UITextView::setTheme( UITheme * Theme ) { UIControlAnim::setTheme( Theme ); if ( NULL == mTextCache->getFont() && NULL != Theme->getFontStyleConfig().getFont() ) { @@ -231,27 +224,27 @@ void UITextBox::setTheme( UITheme * Theme ) { } } -TextCache * UITextBox::getTextCache() { +TextCache * UITextView::getTextCache() { return mTextCache; } -Float UITextBox::getTextWidth() { +Float UITextView::getTextWidth() { return mTextCache->getTextWidth(); } -Float UITextBox::getTextHeight() { +Float UITextView::getTextHeight() { return mTextCache->getTextHeight(); } -const int& UITextBox::getNumLines() const { +const int& UITextView::getNumLines() const { return mTextCache->getNumLines(); } -const Vector2i& UITextBox::getAlignOffset() const { +const Vector2i& UITextView::getAlignOffset() const { return mAlignOffset; } -Uint32 UITextBox::onMouseDoubleClick( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UITextView::onMouseDoubleClick( const Vector2i& Pos, const Uint32 Flags ) { if ( isTextSelectionEnabled() && ( Flags & EE_BUTTON_LMASK ) ) { Vector2i controlPos( Pos ); worldToControl( controlPos ); @@ -271,10 +264,10 @@ Uint32 UITextBox::onMouseDoubleClick( const Vector2i& Pos, const Uint32 Flags ) } } - return UIComplexControl::onMouseDoubleClick( Pos, Flags ); + return UIWidget::onMouseDoubleClick( Pos, Flags ); } -Uint32 UITextBox::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UITextView::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { if ( isTextSelectionEnabled() && ( Flags & EE_BUTTON_LMASK ) ) { if ( selCurInit() == selCurEnd() ) { selCurInit( -1 ); @@ -287,7 +280,7 @@ Uint32 UITextBox::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { return 1; } -Uint32 UITextBox::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UITextView::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { if ( isTextSelectionEnabled() && ( Flags & EE_BUTTON_LMASK ) ) { Vector2i controlPos( Pos ); worldToControl( controlPos ); @@ -307,10 +300,10 @@ Uint32 UITextBox::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { mControlFlags |= UI_CTRL_FLAG_SELECTING; } - return UIComplexControl::onMouseDown( Pos, Flags ); + return UIWidget::onMouseDown( Pos, Flags ); } -void UITextBox::drawSelection( TextCache * textCache ) { +void UITextView::drawSelection( TextCache * textCache ) { if ( selCurInit() != selCurEnd() ) { Int32 init = eemin( selCurInit(), selCurEnd() ); Int32 end = eemax( selCurInit(), selCurEnd() ); @@ -346,36 +339,36 @@ void UITextBox::drawSelection( TextCache * textCache ) { } } -bool UITextBox::isTextSelectionEnabled() const { +bool UITextView::isTextSelectionEnabled() const { return 0 != ( mFlags & UI_TEXT_SELECTION_ENABLED ); } -TooltipStyleConfig UITextBox::getFontStyleConfig() const +TooltipStyleConfig UITextView::getFontStyleConfig() const { return mFontStyleConfig; } -void UITextBox::selCurInit( const Int32& init ) { +void UITextView::selCurInit( const Int32& init ) { mSelCurInit = init; } -void UITextBox::selCurEnd( const Int32& end ) { +void UITextView::selCurEnd( const Int32& end ) { mSelCurEnd = end; } -Int32 UITextBox::selCurInit() { +Int32 UITextView::selCurInit() { return mSelCurInit; } -Int32 UITextBox::selCurEnd() { +Int32 UITextView::selCurEnd() { return mSelCurEnd; } -void UITextBox::onAlignChange() { +void UITextView::onAlignChange() { autoAlign(); } -void UITextBox::setFontStyleConfig( const TooltipStyleConfig& fontStyleConfig ) { +void UITextView::setFontStyleConfig( const TooltipStyleConfig& fontStyleConfig ) { mFontStyleConfig = fontStyleConfig; setFont( mFontStyleConfig.getFont() ); @@ -383,4 +376,19 @@ void UITextBox::setFontStyleConfig( const TooltipStyleConfig& fontStyleConfig ) setFontShadowColor( mFontStyleConfig.getFontShadowColor() ); } +const Recti& UITextView::getPadding() const { + return mPadding; +} + +void UITextView::setPadding(const Recti & padding) { + if ( padding != mPadding ) { + mPadding = padding; + mRealPadding = PixelDensity::dpToPxI( mPadding ); + onPaddingChange(); + } +} + +void UITextView::onPaddingChange() { +} + }} diff --git a/src/eepp/ui/uitheme.cpp b/src/eepp/ui/uitheme.cpp index c962fdd41..9e1081b85 100644 --- a/src/eepp/ui/uitheme.cpp +++ b/src/eepp/ui/uitheme.cpp @@ -19,14 +19,14 @@ #include #include #include -#include +#include #include #include #include #include #include #include -#include +#include #include #include #include diff --git a/src/eepp/ui/uitooltip.cpp b/src/eepp/ui/uitooltip.cpp index 2ea142651..e4ee38094 100644 --- a/src/eepp/ui/uitooltip.cpp +++ b/src/eepp/ui/uitooltip.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include namespace EE { namespace UI { @@ -40,8 +40,8 @@ UITooltip::UITooltip() : UITooltip::~UITooltip() { eeSAFE_DELETE( mTextCache ); - if ( NULL != mTooltipOf && mTooltipOf->isComplex() ) { - reinterpret_cast( mTooltipOf )->tooltipRemove(); + if ( NULL != mTooltipOf && mTooltipOf->isWidget() ) { + reinterpret_cast( mTooltipOf )->tooltipRemove(); } } diff --git a/src/eepp/ui/uicomplexcontrol.cpp b/src/eepp/ui/uiwidget.cpp similarity index 58% rename from src/eepp/ui/uicomplexcontrol.cpp rename to src/eepp/ui/uiwidget.cpp index 9fdc81885..910bc25d5 100644 --- a/src/eepp/ui/uicomplexcontrol.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -1,41 +1,97 @@ -#include +#include #include namespace EE { namespace UI { -UIComplexControl * UIComplexControl::New() { - return eeNew( UIComplexControl, () ); +UIWidget * UIWidget::New() { + return eeNew( UIWidget, () ); } -UIComplexControl::UIComplexControl() : +UIWidget::UIWidget() : UIControlAnim(), mTooltip( NULL ), - mMinControlSize() + mMinControlSize(), + mLayoutWeight(0), + mLayoutGravity(0), + mLayoutWidthRules(WRAP_CONTENT), + mLayoutHeightRules(WRAP_CONTENT) { mControlFlags |= UI_CTRL_FLAG_COMPLEX; updateAnchorsDistances(); } -UIComplexControl::~UIComplexControl() { +UIWidget::~UIWidget() { eeSAFE_DELETE( mTooltip ); } -Uint32 UIComplexControl::getType() const { - return UI_TYPE_CONTROL_COMPLEX; +Uint32 UIWidget::getType() const { + return UI_TYPE_WIDGET; } -bool UIComplexControl::isType( const Uint32& type ) const { - return UIComplexControl::getType() == type ? true : UIControlAnim::isType( type ); +bool UIWidget::isType( const Uint32& type ) const { + return UIWidget::getType() == type ? true : UIControlAnim::isType( type ); } -void UIComplexControl::updateAnchorsDistances() { +void UIWidget::updateAnchorsDistances() { if ( NULL != mParentCtrl ) { mDistToBorder = Recti( mRealPos.x, mRealPos.y, mParentCtrl->getRealSize().x - ( mRealPos.x + mRealSize.x ), mParentCtrl->getRealSize().y - ( mRealPos.y + mRealSize.y ) ); } } -void UIComplexControl::update() { +Recti UIWidget::getLayoutMargin() const { + return mLayoutMargin; +} + +UIWidget * UIWidget::setLayoutMargin(const Recti & margin) { + mLayoutMargin = margin; + mRealMargin = PixelDensity::dpToPxI( margin ); + return this; +} + +Float UIWidget::getLayoutWeight() const { + return mLayoutWeight; +} + +UIWidget * UIWidget::setLayoutWeight(const Float & weight) { + mLayoutWeight = weight; + return this; +} + +Uint32 UIWidget::getLayoutGravity() const { + return mLayoutGravity; +} + +UIWidget * UIWidget::setLayoutGravity(const Uint32 & layoutGravity) { + mLayoutGravity = layoutGravity; + return this; +} + +LayoutSizeRules UIWidget::getLayoutWidthRules() const { + return mLayoutWidthRules; +} + +UIWidget * UIWidget::setLayoutWidthRules(const LayoutSizeRules & layoutWidthRules) { + mLayoutWidthRules = layoutWidthRules; + return this; +} + +LayoutSizeRules UIWidget::getLayoutHeightRules() const { + return mLayoutHeightRules; +} + +UIWidget * UIWidget::setLayoutHeightRules(const LayoutSizeRules & layoutHeightRules) { + mLayoutHeightRules = layoutHeightRules; + return this; +} + +UIWidget * UIWidget::setLayoutSizeRules(const LayoutSizeRules & layoutWidthRules, const LayoutSizeRules & layoutHeightRules) { + mLayoutWidthRules = layoutWidthRules; + mLayoutHeightRules = layoutHeightRules; + return this; +} + +void UIWidget::update() { if ( mVisible && NULL != mTooltip && mTooltip->getText().size() ) { if ( isMouseOverMeOrChilds() ) { UIManager * uiManager = UIManager::instance(); @@ -88,7 +144,7 @@ void UIComplexControl::update() { UIControlAnim::update(); } -void UIComplexControl::createTooltip() { +void UIWidget::createTooltip() { if ( NULL != mTooltip ) return; @@ -97,7 +153,7 @@ void UIComplexControl::createTooltip() { mTooltip->setTooltipOf( this ); } -void UIComplexControl::setTooltipText( const String& Text ) { +UIWidget * UIWidget::setTooltipText( const String& Text ) { if ( NULL == mTooltip ) { // If the tooltip wasn't created it will avoid to create a new one if the string is "" if ( Text.size() ) { createTooltip(); @@ -107,20 +163,22 @@ void UIComplexControl::setTooltipText( const String& Text ) { } else { // but if it's created, i will allow it mTooltip->setText( Text ); } + + return this; } -String UIComplexControl::getTooltipText() { +String UIWidget::getTooltipText() { if ( NULL != mTooltip ) return mTooltip->getText(); return String(); } -void UIComplexControl::tooltipRemove() { +void UIWidget::tooltipRemove() { mTooltip = NULL; } -UIControl * UIComplexControl::setSize( const Sizei& size ) { +UIControl * UIWidget::setSize( const Sizei& size ) { Sizei s( size ); if ( s.x < mMinControlSize.x ) @@ -132,7 +190,7 @@ UIControl * UIComplexControl::setSize( const Sizei& size ) { return UIControlAnim::setSize( s ); } -UIControl * UIComplexControl::setFlags(const Uint32 & flags) { +UIControl * UIWidget::setFlags(const Uint32 & flags) { if ( flags & ( UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ) ) { updateAnchorsDistances(); } @@ -144,7 +202,7 @@ UIControl * UIComplexControl::setFlags(const Uint32 & flags) { return UIControlAnim::setFlags( flags ); } -UIControl * UIComplexControl::unsetFlags(const Uint32 & flags) { +UIControl * UIWidget::unsetFlags(const Uint32 & flags) { if ( flags & ( UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ) ) { updateAnchorsDistances(); } @@ -152,35 +210,35 @@ UIControl * UIComplexControl::unsetFlags(const Uint32 & flags) { return UIControlAnim::unsetFlags( flags ); } -UIComplexControl * UIComplexControl::setAnchors(const Uint32 & flags) { +UIWidget * UIWidget::setAnchors(const Uint32 & flags) { mFlags &= ~(UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM); mFlags |= flags; updateAnchorsDistances(); return this; } -UIControl * UIComplexControl::setSize( const Int32& Width, const Int32& Height ) { +UIControl * UIWidget::setSize( const Int32& Width, const Int32& Height ) { return UIControlAnim::setSize( Width, Height ); } -const Sizei& UIComplexControl::getSize() { +const Sizei& UIWidget::getSize() { return UIControlAnim::getSize(); } -void UIComplexControl::onParentSizeChange( const Vector2i& SizeChange ) { +void UIWidget::onParentSizeChange( const Vector2i& SizeChange ) { updateAnchors( SizeChange ); UIControlAnim::onParentSizeChange( SizeChange ); } -void UIComplexControl::onPositionChange() { +void UIWidget::onPositionChange() { updateAnchorsDistances(); UIControlAnim::onPositionChange(); } -void UIComplexControl::onAutoSize() { +void UIWidget::onAutoSize() { } -void UIComplexControl::updateAnchors( const Vector2i& SizeChange ) { +void UIWidget::updateAnchors( const Vector2i& SizeChange ) { if ( !( mFlags & ( UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ) ) ) return; @@ -216,4 +274,34 @@ void UIComplexControl::updateAnchors( const Vector2i& SizeChange ) { setSize( newSize ); } +void UIWidget::alignAgainstLayout() { + Vector2i pos = mPos; + + switch ( fontHAlignGet( mLayoutGravity ) ) { + case UI_HALIGN_CENTER: + pos.x = ( getParent()->getSize().getWidth() - mSize.getWidth() ) / 2; + break; + case UI_HALIGN_RIGHT: + pos.x = getParent()->getSize().getWidth() - mLayoutMargin.Right; + break; + case UI_HALIGN_LEFT: + pos.x = mLayoutMargin.Left; + break; + } + + switch ( fontVAlignGet( mLayoutGravity ) ) { + case UI_VALIGN_CENTER: + pos.y = ( getParent()->getSize().getHeight() - mSize.getHeight() ) / 2; + break; + case UI_VALIGN_BOTTOM: + pos.y = getParent()->getSize().getHeight() - mLayoutMargin.Bottom; + break; + case UI_VALIGN_TOP: + pos.y = mLayoutMargin.Top; + break; + } + + setInternalPosition( pos ); +} + }} diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index 216883cd8..da81506a2 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -9,7 +9,7 @@ UIWindow * UIWindow::New() { } UIWindow::UIWindow() : - UIComplexControl(), + UIWidget(), mWindowDecoration( NULL ), mBorderLeft( NULL ), mBorderRight( NULL ), @@ -162,7 +162,7 @@ void UIWindow::createModalControl() { UIControl * Ctrl = UIManager::instance()->getMainControl(); if ( NULL == mModalCtrl ) { - mModalCtrl = UIComplexControl::New(); + mModalCtrl = UIWidget::New(); mModalCtrl->setParent( Ctrl )->setPosition(0,0)->setSize( Ctrl->getSize() ); mModalCtrl->setAnchors( UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ); } else { @@ -220,7 +220,7 @@ Uint32 UIWindow::getType() const { } bool UIWindow::isType( const Uint32& type ) const { - return UIWindow::getType() == type ? true : UIComplexControl::isType( type ); + return UIWindow::getType() == type ? true : UIWidget::isType( type ); } void UIWindow::onContainerPosChange( const UIEvent * Event ) { @@ -261,7 +261,7 @@ void UIWindow::closeWindow() { } void UIWindow::close() { - UIComplexControl::close(); + UIWidget::close(); enableByModal(); } @@ -279,7 +279,7 @@ void UIWindow::onButtonMinimizeClick( const UIEvent * Event ) { } void UIWindow::setTheme( UITheme *Theme ) { - UIComplexControl::setTheme( Theme ); + UIWidget::setTheme( Theme ); mContainer->setThemeControl ( Theme, "winback" ); @@ -356,7 +356,7 @@ void UIWindow::onSizeChange() { } else { fixChildsSize(); - UIComplexControl::onSizeChange(); + UIWidget::onSizeChange(); } } @@ -367,9 +367,9 @@ UIControl * UIWindow::setSize( const Sizei& Size ) { size.x += mBorderLeft->getSize().getWidth() + mBorderRight->getSize().getWidth(); size.y += mWindowDecoration->getSize().getHeight() + mBorderBottom->getSize().getHeight(); - UIComplexControl::setSize( size ); + UIWidget::setSize( size ); } else { - UIComplexControl::setSize( Size ); + UIWidget::setSize( Size ); } return this; @@ -386,12 +386,12 @@ UIWindow *UIWindow::setSizeWithDecoration(const Int32 & Width, const Int32 & Hei } UIWindow *UIWindow::setSizeWithDecoration(const Sizei & size) { - UIComplexControl::setSize( size ); + UIWidget::setSize( size ); return this; } const Sizei& UIWindow::getSize() { - return UIComplexControl::getSize(); + return UIWidget::getSize(); } void UIWindow::fixChildsSize() { @@ -507,7 +507,7 @@ Uint32 UIWindow::onMessage( const UIMessage * Msg ) { } } - return UIComplexControl::onMessage( Msg ); + return UIWidget::onMessage( Msg ); } void UIWindow::doResize ( const UIMessage * Msg ) { @@ -729,7 +729,7 @@ void UIWindow::internalSize( Sizei Size ) { } void UIWindow::draw() { - UIComplexControl::draw(); + UIWidget::draw(); if ( mStyleConfig.WinFlags & UI_WIN_DRAW_SHADOW ) { Primitives P; @@ -766,7 +766,7 @@ void UIWindow::draw() { void UIWindow::update() { resizeCursor(); - UIComplexControl::update(); + UIWidget::update(); updateResize(); } @@ -849,7 +849,7 @@ void UIWindow::onAlphaChange() { } } - UIComplexControl::onAlphaChange(); + UIWidget::onAlphaChange(); } void UIWindow::setBaseAlpha( const Uint8& Alpha ) { @@ -866,7 +866,7 @@ const Uint8& UIWindow::getBaseAlpha() const { void UIWindow::setTitle( const String& Text ) { if ( NULL == mTitle ) { - mTitle = UITextBox::New(); + mTitle = UITextView::New(); mTitle->setParent( this ); mTitle->setHorizontalAlign( getHorizontalAlign() ); mTitle->setVerticalAlign( getVerticalAlign() ); @@ -898,7 +898,7 @@ String UIWindow::getTitle() const { return String(); } -UITextBox * UIWindow::getTitleTextBox() const { +UITextView * UIWindow::getTitleTextBox() const { return mTitle; } @@ -928,7 +928,7 @@ Uint32 UIWindow::onMouseDoubleClick( const Vector2i &Pos, const Uint32 Flags ) { Uint32 UIWindow::onKeyDown( const UIEventKey &Event ) { checkShortcuts( Event.getKeyCode(), Event.getMod() ); - return UIComplexControl::onKeyDown( Event ); + return UIWidget::onKeyDown( Event ); } void UIWindow::checkShortcuts( const Uint32& KeyCode, const Uint32& Mod ) { @@ -1027,7 +1027,7 @@ bool UIWindow::isModal() { return 0 != ( mStyleConfig.WinFlags & UI_WIN_MODAL ); } -UIComplexControl * UIWindow::getModalControl() const { +UIWidget * UIWindow::getModalControl() const { return mModalCtrl; } diff --git a/src/eepp/ui/uiwinmenu.cpp b/src/eepp/ui/uiwinmenu.cpp index 97b299425..7488d8504 100644 --- a/src/eepp/ui/uiwinmenu.cpp +++ b/src/eepp/ui/uiwinmenu.cpp @@ -9,7 +9,7 @@ UIWinMenu * UIWinMenu::New() { } UIWinMenu::UIWinMenu() : - UIComplexControl(), + UIWidget(), mCurrentMenu( NULL ) { if ( !(mFlags & UI_ANCHOR_RIGHT) ) @@ -34,7 +34,7 @@ Uint32 UIWinMenu::getType() const { } bool UIWinMenu::isType( const Uint32& type ) const { - return UIWinMenu::getType() == type ? true : UIComplexControl::isType( type ); + return UIWinMenu::getType() == type ? true : UIWidget::isType( type ); } void UIWinMenu::addMenuButton( const String& ButtonText, UIPopUpMenu * Menu ) { @@ -56,7 +56,7 @@ void UIWinMenu::addMenuButton( const String& ButtonText, UIPopUpMenu * Menu ) { Menu->setVisible( false ); Menu->setEnabled( false ); - Menu->setParent( getParent() ); + Menu->setParent( getWindowContainer() ); Menu->addEventListener( UIEvent::EventOnComplexControlFocusLoss, cb::Make1( this, &UIWinMenu::onMenuFocusLoss ) ); mButtons.push_back( std::make_pair( Button, Menu ) ); @@ -65,7 +65,7 @@ void UIWinMenu::addMenuButton( const String& ButtonText, UIPopUpMenu * Menu ) { } void UIWinMenu::setTheme( UITheme * Theme ) { - UIComplexControl::setThemeControl( Theme, "winmenu" ); + UIWidget::setThemeControl( Theme, "winmenu" ); for ( WinMenuList::iterator it = mButtons.begin(); it != mButtons.end(); it++ ) { it->first->setThemeControl( Theme, "winmenubutton" ); @@ -173,7 +173,7 @@ void UIWinMenu::refreshButtons() { for ( WinMenuList::iterator it = mButtons.begin(); it != mButtons.end(); it++ ) { UISelectButton * pbut = it->first; - UITextBox * tbox = pbut->getTextBox(); + UITextView * tbox = pbut->getTextBox(); pbut->setStyleConfig( mStyleConfig ); pbut->setSize( PixelDensity::pxToDpI( tbox->getTextWidth() ) + mStyleConfig.ButtonMargin, getSize().getHeight() ); @@ -282,7 +282,7 @@ void UIWinMenu::onMenuFocusLoss( const UIEvent * Event ) { } void UIWinMenu::onComplexControlFocusLoss() { - UIComplexControl::onComplexControlFocusLoss(); + UIWidget::onComplexControlFocusLoss(); if ( NULL != mCurrentMenu ) { mCurrentMenu->hide(); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 8ed68c08a..4b85f3a52 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -320,7 +320,7 @@ void EETest::createUI() { sprite->setPosition( 160, 100 ); sprite->setDeallocSprite( true ); - UITextBox * Text = UITextBox::New(); + UITextView * Text = UITextView::New(); Text->setParent( C )->setEnabled( false )->setSize( 320, 240 )->setHorizontalAlign( UI_HALIGN_RIGHT )->setVerticalAlign( UI_VALIGN_TOP ); Text->setText( "Turn around\nJust Turn Around\nAround!" ); @@ -362,7 +362,7 @@ void EETest::createUI() { mProgressBar = UIProgressBar::New(); mProgressBar->setParent( C )->setSize( 200, 24 )->setPosition( 20, 190 ); - mTextBoxValue = UITextBox::New(); + mTextBoxValue = UITextView::New(); mTextBoxValue->setParent( C )->setPosition( 20, 0 )->setFlags( UI_AUTO_SIZE ); mTextBoxValue->setVisible( true ); onValueChange( NULL ); @@ -442,16 +442,16 @@ void EETest::createUI() { TextEdit->setParent( C )->setPosition( 5, 245 )->setSize( 315, 130 ); TextEdit->setText( mBuda ); - UIGenericGrid * genGrid = UIGenericGrid::New(); + UITable * genGrid = UITable::New(); genGrid->setSmoothScroll( true ); genGrid->setParent( C )->setPosition( 325, 245 )->setSize( 200, 130 ); genGrid->setCollumnsCount( 3 )->setRowHeight( 24 ); for ( Uint32 i = 0; i < 15; i++ ) { - UIGridCell * Cell = UIGridCell::New(); - UITextBox * TxtBox = UITextBox::New(); + UITableCell * Cell = UITableCell::New(); + UITextView * TxtBox = UITextView::New(); UITextInput * TxtInput = UITextInput::New(); - UIGfx * TxtGfx = UIGfx::New(); + UIImage * TxtGfx = UIImage::New(); Cell->setParent( genGrid->getContainer() ); @@ -520,7 +520,7 @@ void EETest::createNewUI() { cbox->setText( "Happy CheckBox :)" ); cbox->setFontColor( 0x000000FF ); - UIGfx * gfx = UIGfx::New(); + UIImage * gfx = UIImage::New(); gfx->setPosition( 50, 140 )->setSize( 16, 16 ); gfx->setBackgroundFillEnabled( true )->setColor( 0x33333333 ); gfx->setSubTexture( mTheme->getIconByName( "ok" ) ); @@ -583,7 +583,7 @@ void EETest::createNewUI() { UISpinBox * spinBox = UISpinBox::New(); spinBox->setPosition( 350, 210 )->setSize( 200, 0 ); - UIGenericGrid * genGrid = UIGenericGrid::New(); + UITable * genGrid = UITable::New(); genGrid->setSmoothScroll( true ); genGrid->setPosition( 350, 250 )->setSize( 200, 130 ); genGrid->setCollumnsCount( 3 )->setRowHeight( 24 ); @@ -592,10 +592,10 @@ void EETest::createNewUI() { genGrid->setCollumnWidth( 2, 100 ); for ( Uint32 i = 0; i < 15; i++ ) { - UIGridCell * Cell = UIGridCell::New(); - UITextBox * TxtBox = UITextBox::New(); + UITableCell * Cell = UITableCell::New(); + UITextView * TxtBox = UITextView::New(); UITextInput * TxtInput = UITextInput::New(); - UIGfx * TxtGfx = UIGfx::New(); + UIImage * TxtGfx = UIImage::New(); TxtGfx->unsetFlags( UI_AUTO_SIZE ); Cell->setParent( genGrid->getContainer() ); @@ -634,11 +634,59 @@ void EETest::createNewUI() { UITabWidget * TabWidget = UITabWidget::New(); TabWidget->setPosition( 350, 530 )->setSize( 200, 64 ); - TabWidget->add( "Tab 1", UIComplexControl::New()->setThemeControl( "winback" ), mTheme->getIconByName( "ok" ) ); - TabWidget->add( "Tab 2", UIComplexControl::New()->setThemeControl( "winback" ), mTheme->getIconByName( "go-up" ) ); - TabWidget->add( "Tab 3", UIComplexControl::New()->setThemeControl( "winback" ), mTheme->getIconByName( "add" ) ); + TabWidget->add( "Tab 1", UIWidget::New()->setThemeControl( "winback" ), mTheme->getIconByName( "ok" ) ); + TabWidget->add( "Tab 2", UIWidget::New()->setThemeControl( "winback" ), mTheme->getIconByName( "go-up" ) ); + TabWidget->add( "Tab 3", UIWidget::New()->setThemeControl( "winback" ), mTheme->getIconByName( "add" ) ); /**/ + /**/ + UIWindow * win = UIWindow::New(); + win->setSize( 500, 500 ); + win->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_RESIZEABLE | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MINIMIZE_BUTTON ); + + UILinearLayout * layWin = UILinearLayout::NewVertical(); + layWin->setLayoutSizeRules( MATCH_PARENT, MATCH_PARENT ); + layWin->setParent( win->getContainer() ); + + UILinearLayout * layPar = UILinearLayout::NewHorizontal(); + layPar->setParent( layWin ); + layPar->setLayoutMargin( Recti( 16, 16, 16, 16 ) ); + layPar->setLayoutSizeRules( MATCH_PARENT, WRAP_CONTENT ); + layPar->setLayoutGravity( UI_VALIGN_CENTER | UI_HALIGN_CENTER ); + layPar->setBackgroundFillEnabled( true )->setColor( 0x999999FF ); + + UILinearLayout * lay = UILinearLayout::NewVertical(); + lay->setLayoutGravity( UI_HALIGN_CENTER | UI_VALIGN_CENTER ); + lay->setLayoutSizeRules( MATCH_PARENT, WRAP_CONTENT ); + lay->setBackgroundFillEnabled( true )->setColor( 0x333333FF ); + lay->setLayoutWeight( 0.7f ); + + UITextView::New()->setText( "Text on test 1" )->setLayoutMargin( Recti( 10, 10, 10, 10 ) )->setLayoutSizeRules( WRAP_CONTENT, WRAP_CONTENT )->setParent( lay ); + UITextView::New()->setText( "Text on test 2" )->setLayoutMargin( Recti( 10, 10, 10, 10 ) )->setLayoutSizeRules( MATCH_PARENT, WRAP_CONTENT )->setParent( lay ); + UICheckBox::New()->setText( "Checkbox" )->setLayoutMargin( Recti( 10, 10, 10, 10 ) )->setLayoutSizeRules( MATCH_PARENT, WRAP_CONTENT )->setParent( lay ); + UITextView::New()->setText( "Text on test 3" )->setLayoutMargin( Recti( 10, 10, 10, 10 ) )->setLayoutSizeRules( MATCH_PARENT, WRAP_CONTENT )->setParent( lay ); + UITextView::New()->setText( "Text on test 4" )->setLayoutMargin( Recti( 10, 10, 10, 10 ) )->setLayoutSizeRules( MATCH_PARENT, WRAP_CONTENT )->setParent( lay ); + UITextInput::New()->setLayoutMargin( Recti( 10, 10, 10, 10 ) )->setLayoutSizeRules( MATCH_PARENT, WRAP_CONTENT )->setParent( lay ); + + UILinearLayout * lay2 = UILinearLayout::NewVertical(); + lay2->setLayoutGravity( UI_HALIGN_CENTER | UI_VALIGN_CENTER ); + lay2->setLayoutSizeRules( FIXED, MATCH_PARENT ); + lay2->setBackgroundFillEnabled( true )->setColor( 0x000000FF ); + lay2->setLayoutWeight( 0.3f ); + + UIPushButton::New()->setText( "PushButton" )->setLayoutMargin( Recti( 10, 10, 10, 10 ) )->setLayoutSizeRules( MATCH_PARENT, WRAP_CONTENT )->setLayoutGravity( UI_VALIGN_CENTER )->setParent( lay2 ); + UIListBox * lbox = UIListBox::New(); + lbox->setLayoutMargin( Recti( 10, 10, 10, 10 ) )->setLayoutSizeRules( MATCH_PARENT, FIXED )->setSize( 0, 120 )->setParent( lay2 ); + lbox->addListBoxItems( { "This", "is", "a", "ListBox" } ); + lay2->setParent( layPar ); + lay->setParent( layPar ); + + UIDropDownList * drop = UIDropDownList::New(); + drop->setLayoutMargin( Recti( 10, 10, 10, 10 ) )->setLayoutSizeRules( MATCH_PARENT, WRAP_CONTENT )->setParent( layWin ); + drop->getListBox()->addListBoxItems( { "Car", "Bus", "Plane", "Submarine" } ); + drop->getListBox()->setSelected(0); + win->show(); + /**/ } void EETest::createMapEditor() { @@ -686,9 +734,20 @@ void EETest::createCommonDialog() { CDialog->show(); } -void EETest::createWinMenu() { +void EETest::createDecoratedWindow() { + mUIWindow = UIWindow::New(); + mUIWindow->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON ) + ->setMinWindowSize( 530, 350 )->setPosition( 200, 50 ); + + mUIWindow->addEventListener( UIEvent::EventOnWindowCloseClick, cb::Make1( this, &EETest::onCloseClick ) ); + mUIWindow->setTitle( "Test Window" ); + + UILinearLayout * lay = UILinearLayout::NewVertical(); + lay->setLayoutSizeRules( MATCH_PARENT, MATCH_PARENT ); + lay->setParent( mUIWindow->getContainer() ); + UIWinMenu * WinMenu = UIWinMenu::New(); - WinMenu->setParent( mUIWindow->getContainer() ); + WinMenu->setLayoutSizeRules( MATCH_PARENT, WRAP_CONTENT )->setParent( lay ); UIPopUpMenu * PopMenu = UIPopUpMenu::New(); PopMenu->add( "File" ); @@ -704,28 +763,20 @@ void EETest::createWinMenu() { WinMenu->addMenuButton( "File", PopMenu ); WinMenu->addMenuButton( "Edit", PopMenu2 ); -} - -void EETest::createDecoratedWindow() { - mUIWindow = UIWindow::New(); - mUIWindow->setWinFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON ) - ->setMinWindowSize( 530, 350 )->setPosition( 200, 50 ); - - mUIWindow->addEventListener( UIEvent::EventOnWindowCloseClick, cb::Make1( this, &EETest::onCloseClick ) ); - mUIWindow->setTitle( "Test Window" ); - mUIWindow->toBack(); UIPushButton * Button = UIPushButton::New(); - Button->setParent( mUIWindow->getContainer() )->setSize( 510, 22 )->setPosition( 10, 28 ); - Button->setAnchors( UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT ); + Button->setLayoutMargin( Recti( 5, 5, 5, 5 ) ); Button->setText( "Click Me" ); + Button->setLayoutSizeRules( MATCH_PARENT, WRAP_CONTENT )->setParent( lay ); Button->addEventListener( UIEvent::EventMouseClick, cb::Make1( this, &EETest::onButtonClick ) ); mUIWindow->addShortcut( KEY_C, KEYMOD_ALT, Button ); 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 ); + TabWidget->setLayoutMargin( Recti( 5, 5, 5, 5 ) ) + ->setLayoutWeight( 1 ) + ->setLayoutSizeRules( MATCH_PARENT, WRAP_CONTENT ) + ->setParent( lay )->setFlags( UI_HALIGN_CENTER | UI_VALIGN_CENTER ); UITextEdit * TEdit = UITextEdit::New(); TEdit->setParent( TabWidget ); @@ -738,14 +789,12 @@ void EETest::createDecoratedWindow() { Txt->setText( mBuda ); TabWidget->add( "TextInput", Txt ); - UITextBox * txtBox = UITextBox::New(); + UITextView * txtBox = UITextView::New(); txtBox->resetFlags( UI_HALIGN_LEFT | UI_VALIGN_TOP | UI_AUTO_PADDING | UI_WORD_WRAP | UI_TEXT_SELECTION_ENABLED ); txtBox->setParent( TabWidget ); txtBox->setText( mBuda ); TabWidget->add( "TextBox", txtBox ); - - createWinMenu(); } void EETest::onCloseClick( const UIEvent * Event ) { @@ -856,7 +905,7 @@ void EETest::onButtonClick( const UIEvent * Event ) { const UIEventMouse * MouseEvent = reinterpret_cast ( Event ); if ( MouseEvent->getFlags() & EE_BUTTONS_LRM ) { - UIGfx * Gfx = UIGfx::New(); + UIImage * Gfx = UIImage::New(); Gfx->setSubTexture( mTheme->getIconByName( "ok" ) ); Gfx->setEnabled( false ); @@ -864,7 +913,7 @@ void EETest::onButtonClick( const UIEvent * Event ) { Gfx->startMovement( Vector2i( Math::randi( 0, mWindow->getWidth() ), -64 ), Vector2i( Math::randi( 0, mWindow->getWidth() ), mWindow->getHeight() + 64 ), Milliseconds( 2500 ) ); Gfx->closeFadeOut( Milliseconds( 3500 ) ); - mListBox->addListBoxItem( "Test ListBox " + String::toStr( mListBox->getCount() + 1 ) + " testing it right now!" ); + //mListBox->addListBoxItem( "Test ListBox " + String::toStr( mListBox->getCount() + 1 ) + " testing it right now!" ); } } diff --git a/src/test/eetest.hpp b/src/test/eetest.hpp index 8578345dd..5a6f8794a 100644 --- a/src/test/eetest.hpp +++ b/src/test/eetest.hpp @@ -159,12 +159,11 @@ class EETest : private Thread { void onSliderValueChange( const UIEvent * Event ); void onWinMouseUp( const UIEvent * Event ); void createDecoratedWindow(); - void createWinMenu(); void createUIThemeTextureAtlas(); UIControlAnim * C; UIScrollBar * mScrollBar; - UITextBox * mTextBoxValue; + UITextView * mTextBoxValue; UISlider * mSlider; UIProgressBar * mProgressBar; UIListBox * mListBox;