From c14dcc0be9464224cb0d5741d574fc02436f194a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=C2=ADn=20Lucas=20Golini?= Date: Sun, 5 Mar 2017 17:30:41 -0300 Subject: [PATCH] Minor clean up. --HG-- branch : dev --- include/eepp/ui/uicombobox.hpp | 4 ++-- include/eepp/ui/uicomplexcontrol.hpp | 2 ++ include/eepp/ui/uidragable.hpp | 4 ++++ include/eepp/ui/uiwindow.hpp | 18 +++++++-------- src/eepp/ui/uicombobox.cpp | 2 +- src/eepp/ui/uicomplexcontrol.cpp | 34 +++++++++++++++------------- src/eepp/ui/uicontrol.cpp | 2 +- src/eepp/ui/uicontrolanim.cpp | 2 +- src/eepp/ui/uiwindow.cpp | 25 +++++++++++++------- 9 files changed, 55 insertions(+), 38 deletions(-) diff --git a/include/eepp/ui/uicombobox.hpp b/include/eepp/ui/uicombobox.hpp index 97643d970..7992e7436 100644 --- a/include/eepp/ui/uicombobox.hpp +++ b/include/eepp/ui/uicombobox.hpp @@ -23,14 +23,14 @@ class EE_API UIComboBox : public UIComplexControl { UIDropDownList * getDropDownList() const { return mDropDownList; } - UIComplexControl * getButton() const { return mButton; } + UIControlAnim * getButton() const { return mButton; } InputTextBuffer * getInputTextBuffer(); const String& getText(); protected: UIDropDownList * mDropDownList; - UIComplexControl * mButton; + UIControlAnim * mButton; void onButtonClick( const UIEvent * Event ); diff --git a/include/eepp/ui/uicomplexcontrol.hpp b/include/eepp/ui/uicomplexcontrol.hpp index 36c728dfc..884fd4690 100644 --- a/include/eepp/ui/uicomplexcontrol.hpp +++ b/include/eepp/ui/uicomplexcontrol.hpp @@ -53,6 +53,8 @@ class EE_API UIComplexControl : public UIControlAnim { virtual void onPositionChange(); virtual void onAutoSize(); + + void updateAnchors( const Vector2i & SizeChange ); }; }} diff --git a/include/eepp/ui/uidragable.hpp b/include/eepp/ui/uidragable.hpp index 3757ddc15..9ffca9ae9 100644 --- a/include/eepp/ui/uidragable.hpp +++ b/include/eepp/ui/uidragable.hpp @@ -16,17 +16,21 @@ class EE_API UIDragable : public UIControl { virtual bool isType( const Uint32& type ) const; bool isDragging() const; + void setDragging( const bool& dragging ); const Vector2i& getDragPoint() const; + void setDragPoint( const Vector2i& Point ); virtual void update(); bool isDragEnabled() const; + void setDragEnabled( const bool& enable ); void setDragButton( const Uint32& Button ); + const Uint32& getDragButton() const; protected: virtual ~UIDragable(); diff --git a/include/eepp/ui/uiwindow.hpp b/include/eepp/ui/uiwindow.hpp index 94d4d02b6..6ab844fb1 100644 --- a/include/eepp/ui/uiwindow.hpp +++ b/include/eepp/ui/uiwindow.hpp @@ -35,11 +35,11 @@ class EE_API UIWindow : public UIComplexControl { UIControlAnim * getContainer() const; - UIComplexControl * getButtonClose() const; + UIControlAnim * getButtonClose() const; - UIComplexControl * getButtonMaximize() const; + UIControlAnim * getButtonMaximize() const; - UIComplexControl * getButtonMinimize() const; + UIControlAnim * getButtonMinimize() const; virtual void draw(); @@ -69,7 +69,7 @@ class EE_API UIWindow : public UIComplexControl { bool isModal(); - UIControlAnim * getModalControl() const; + UIComplexControl * getModalControl() const; void maximize(); @@ -127,12 +127,12 @@ class EE_API UIWindow : public UIComplexControl { UIControlAnim * mBorderLeft; UIControlAnim * mBorderRight; UIControlAnim * mBorderBottom; - UIComplexControl * mContainer; + UIControlAnim * mContainer; - UIComplexControl * mButtonClose; - UIComplexControl * mButtonMinimize; - UIComplexControl * mButtonMaximize; - UITextBox * mTitle; + UIControlAnim * mButtonClose; + UIControlAnim * mButtonMinimize; + UIControlAnim * mButtonMaximize; + UITextBox * mTitle; UIComplexControl * mModalCtrl; diff --git a/src/eepp/ui/uicombobox.cpp b/src/eepp/ui/uicombobox.cpp index 0b9e1b868..18f26cdbc 100644 --- a/src/eepp/ui/uicombobox.cpp +++ b/src/eepp/ui/uicombobox.cpp @@ -38,7 +38,7 @@ void UIComboBox::setTheme( UITheme * Theme ) { } if ( NULL == mButton ) { - mButton = UIComplexControl::New(); + mButton = UIControlAnim::New(); mButton->setParent( this ); mButton->setVisible( true ); mButton->setEnabled( true ); diff --git a/src/eepp/ui/uicomplexcontrol.cpp b/src/eepp/ui/uicomplexcontrol.cpp index 595420d52..9fdc81885 100644 --- a/src/eepp/ui/uicomplexcontrol.cpp +++ b/src/eepp/ui/uicomplexcontrol.cpp @@ -168,11 +168,25 @@ const Sizei& UIComplexControl::getSize() { } void UIComplexControl::onParentSizeChange( const Vector2i& SizeChange ) { + updateAnchors( SizeChange ); + UIControlAnim::onParentSizeChange( SizeChange ); +} + +void UIComplexControl::onPositionChange() { + updateAnchorsDistances(); + UIControlAnim::onPositionChange(); +} + +void UIComplexControl::onAutoSize() { +} + +void UIComplexControl::updateAnchors( const Vector2i& SizeChange ) { + if ( !( mFlags & ( UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ) ) ) + return; + Sizei newSize( mSize ); - if ( mFlags & UI_ANCHOR_LEFT ) { - // Nothing ? - } else { + if ( !( mFlags & UI_ANCHOR_LEFT ) ) { setInternalPosition( Vector2i( mPos.x += SizeChange.x, mPos.y ) ); } @@ -185,9 +199,7 @@ void UIComplexControl::onParentSizeChange( const Vector2i& SizeChange ) { } } - if ( mFlags & UI_ANCHOR_TOP ) { - // Nothing ? - } else { + if ( !( mFlags & UI_ANCHOR_TOP ) ) { setInternalPosition( Vector2i( mPos.x, mPos.y += SizeChange.y ) ); } @@ -202,16 +214,6 @@ void UIComplexControl::onParentSizeChange( const Vector2i& SizeChange ) { if ( newSize != mSize ) setSize( newSize ); - - UIControlAnim::onParentSizeChange( SizeChange ); -} - -void UIComplexControl::onPositionChange() { - updateAnchorsDistances(); - UIControlAnim::onPositionChange(); -} - -void UIComplexControl::onAutoSize() { } }} diff --git a/src/eepp/ui/uicontrol.cpp b/src/eepp/ui/uicontrol.cpp index c162d9057..4127285fc 100644 --- a/src/eepp/ui/uicontrol.cpp +++ b/src/eepp/ui/uicontrol.cpp @@ -9,7 +9,7 @@ namespace EE { namespace UI { -UIControl *UIControl::New() { +UIControl * UIControl::New() { return eeNew( UIControl, () ); } diff --git a/src/eepp/ui/uicontrolanim.cpp b/src/eepp/ui/uicontrolanim.cpp index 76d26d414..963c6ae40 100644 --- a/src/eepp/ui/uicontrolanim.cpp +++ b/src/eepp/ui/uicontrolanim.cpp @@ -6,7 +6,7 @@ namespace EE { namespace UI { -UIControlAnim *UIControlAnim::New() { +UIControlAnim * UIControlAnim::New() { return eeNew( UIControlAnim, () ); } diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index cff946001..216883cd8 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -34,7 +34,7 @@ UIWindow::UIWindow() : mStyleConfig = theme->getWindowStyleConfig(); } - mContainer = UIComplexControl::New(); + mContainer = UIControlAnim::New(); mContainer->setParent( this ); mContainer->setFlags( UI_REPORT_SIZE_CHANGE_TO_CHILDS ); mContainer->setSize( mSize ); @@ -92,7 +92,7 @@ void UIWindow::updateWinFlags() { if ( mStyleConfig.WinFlags & UI_WIN_CLOSE_BUTTON ) { if ( NULL == mButtonClose ) { - mButtonClose = UIComplexControl::New(); + mButtonClose = UIControlAnim::New(); needsUpdate = true; } @@ -103,11 +103,14 @@ void UIWindow::updateWinFlags() { if ( mStyleConfig.WinFlags & UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS && 0 == mCloseListener ) { mCloseListener = mButtonClose->addEventListener( UIEvent::EventMouseClick, cb::Make1( this, &UIWindow::onButtonCloseClick ) ); } + } else if ( NULL != mButtonClose ) { + mButtonClose->setVisible( false )->setEnabled( false )->close(); + mButtonClose = NULL; } if ( ( mStyleConfig.WinFlags & UI_WIN_RESIZEABLE ) && ( mStyleConfig.WinFlags & UI_WIN_MAXIMIZE_BUTTON ) ) { if ( NULL == mButtonMaximize ) { - mButtonMaximize = UIComplexControl::New(); + mButtonMaximize = UIControlAnim::New(); needsUpdate = true; } @@ -118,11 +121,14 @@ void UIWindow::updateWinFlags() { if ( mStyleConfig.WinFlags & UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS && 0 == mMaximizeListener ) { mMaximizeListener = mButtonMaximize->addEventListener( UIEvent::EventMouseClick, cb::Make1( this, &UIWindow::onButtonMaximizeClick ) ); } + } else if ( NULL != mButtonMaximize ) { + mButtonMaximize->setVisible( false )->setEnabled( false )->close(); + mButtonMaximize = NULL; } if ( mStyleConfig.WinFlags & UI_WIN_MINIMIZE_BUTTON ) { if ( NULL == mButtonMinimize ) { - mButtonMinimize = UIComplexControl::New(); + mButtonMinimize = UIControlAnim::New(); needsUpdate = true; } @@ -133,6 +139,9 @@ void UIWindow::updateWinFlags() { if ( mStyleConfig.WinFlags & UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS && 0 == mMinimizeListener ) { mMinimizeListener = mButtonMinimize->addEventListener( UIEvent::EventMouseClick, cb::Make1( this, &UIWindow::onButtonMinimizeClick ) ); } + } else if ( NULL != mButtonMinimize ) { + mButtonMinimize->setVisible( false )->setEnabled( false )->close(); + mButtonMinimize = NULL; } setDragEnabled( true ); @@ -766,15 +775,15 @@ UIControlAnim * UIWindow::getContainer() const { return mContainer; } -UIComplexControl * UIWindow::getButtonClose() const { +UIControlAnim * UIWindow::getButtonClose() const { return mButtonClose; } -UIComplexControl * UIWindow::getButtonMaximize() const { +UIControlAnim * UIWindow::getButtonMaximize() const { return mButtonMaximize; } -UIComplexControl * UIWindow::getButtonMinimize() const { +UIControlAnim * UIWindow::getButtonMinimize() const { return mButtonMinimize; } @@ -1018,7 +1027,7 @@ bool UIWindow::isModal() { return 0 != ( mStyleConfig.WinFlags & UI_WIN_MODAL ); } -UIControlAnim * UIWindow::getModalControl() const { +UIComplexControl * UIWindow::getModalControl() const { return mModalCtrl; }