diff --git a/include/eepp/ui/uicombobox.hpp b/include/eepp/ui/uicombobox.hpp index 0205b2c24..6e64ea5cd 100644 --- a/include/eepp/ui/uicombobox.hpp +++ b/include/eepp/ui/uicombobox.hpp @@ -9,6 +9,8 @@ class EE_API UIComboBox : public UIDropDownList { public: UIComboBox( UIComboBox::CreateParams& Params ); + UIComboBox(); + virtual ~UIComboBox(); virtual Uint32 getType() const; @@ -30,6 +32,8 @@ class EE_API UIComboBox : public UIDropDownList { void createButton(); virtual void onControlClear( const UIEvent *Event ); + + virtual void onSizeChange(); }; }} diff --git a/include/eepp/ui/uicontrol.hpp b/include/eepp/ui/uicontrol.hpp index d7e335dea..e44a80eec 100644 --- a/include/eepp/ui/uicontrol.hpp +++ b/include/eepp/ui/uicontrol.hpp @@ -174,6 +174,8 @@ class EE_API UIControl { void setFlags( const Uint32& flags ); + void unsetFlags( const Uint32& flags ); + void setBlendMode( const EE_BLEND_MODE& blend ); EE_BLEND_MODE getBlendMode(); @@ -197,6 +199,10 @@ class EE_API UIControl { Uint32 isClipped(); + Uint32 isRotated(); + + bool isMeOrParentTreeRotated(); + Uint32 addEventListener( const Uint32& EventType, const UIEventCallback& Callback ); void removeEventListener( const Uint32& CallbackId ); @@ -403,6 +409,12 @@ class EE_API UIControl { Rectf getRectf(); + void drawHighlightFocus(); + + void drawOverControl(); + + void drawDebugData(); + void setInternalPosition( const Vector2i& Pos ); void setInternalSize( const Sizei& size ); diff --git a/include/eepp/ui/uidropdownlist.hpp b/include/eepp/ui/uidropdownlist.hpp index 3989baeb6..b58b3ebd0 100644 --- a/include/eepp/ui/uidropdownlist.hpp +++ b/include/eepp/ui/uidropdownlist.hpp @@ -27,6 +27,8 @@ class EE_API UIDropDownList : public UITextInput { UIDropDownList( UIDropDownList::CreateParams& Params ); + UIDropDownList(); + virtual ~UIDropDownList(); virtual Uint32 getType() const; diff --git a/include/eepp/ui/uihelper.hpp b/include/eepp/ui/uihelper.hpp index 5fd1207d6..724940689 100644 --- a/include/eepp/ui/uihelper.hpp +++ b/include/eepp/ui/uihelper.hpp @@ -21,6 +21,7 @@ enum UI_CONTROL_FLAGS_VALUES { UI_CTRL_FLAG_TOUCH_DRAGGING = (1<<12), UI_CTRL_FLAG_DISABLED_BY_MODAL_WINDOW = (1<<13), UI_CTRL_FLAG_SELECTING = (1<<14), + UI_CTRL_FLAG_ROTATED = (1<<15), UI_CTRL_FLAG_FREE_USE = (1<<31) }; @@ -111,7 +112,8 @@ enum UI_SCROLLBAR_MODE { enum UI_MANAGER_FLAGS { UI_MANAGER_HIGHLIGHT_FOCUS = ( 1 << 0 ), - UI_MANAGER_HIGHLIGHT_OVER = ( 1 << 1 ) + UI_MANAGER_HIGHLIGHT_OVER = ( 1 << 1 ), + UI_MANAGER_DRAW_DEBUG_DATA = ( 1 << 2 ) }; enum UI_WINDOW_FLAGS { diff --git a/include/eepp/ui/uiitemcontainer.hpp b/include/eepp/ui/uiitemcontainer.hpp index 442dd059c..3123decb3 100644 --- a/include/eepp/ui/uiitemcontainer.hpp +++ b/include/eepp/ui/uiitemcontainer.hpp @@ -10,6 +10,8 @@ class UIItemContainer : public UIControl { public: UIItemContainer( UIControl::CreateParams& Params ); + UIItemContainer(); + ~UIItemContainer(); void update(); @@ -25,6 +27,12 @@ UIItemContainer::UIItemContainer( UIControl::CreateParams& Params ) { } +template +UIItemContainer::UIItemContainer() : + UIControl() +{ +} + template UIItemContainer::~UIItemContainer() { diff --git a/include/eepp/ui/uilistbox.hpp b/include/eepp/ui/uilistbox.hpp index 5bd037620..550d2a64b 100644 --- a/include/eepp/ui/uilistbox.hpp +++ b/include/eepp/ui/uilistbox.hpp @@ -56,6 +56,8 @@ class EE_API UIListBox : public UIComplexControl { UIListBox( UIListBox::CreateParams& Params ); + UIListBox(); + virtual ~UIListBox(); virtual Uint32 getType() const; diff --git a/include/eepp/ui/uilistboxitem.hpp b/include/eepp/ui/uilistboxitem.hpp index 61e77512d..517a28c21 100644 --- a/include/eepp/ui/uilistboxitem.hpp +++ b/include/eepp/ui/uilistboxitem.hpp @@ -12,6 +12,8 @@ class EE_API UIListBoxItem : public UITextBox { public: UIListBoxItem( const UITextBox::CreateParams& Params ); + UIListBoxItem(); + virtual ~UIListBoxItem(); virtual Uint32 getType() const; diff --git a/include/eepp/ui/uimanager.hpp b/include/eepp/ui/uimanager.hpp index 683180f53..d9be2ad17 100644 --- a/include/eepp/ui/uimanager.hpp +++ b/include/eepp/ui/uimanager.hpp @@ -47,10 +47,18 @@ class EE_API UIManager { const Uint32& getLastPressTrigger() const; + void clipPlaneEnable( const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height ); + + void clipPlaneDisable(); + void clipEnable( const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height ); void clipDisable(); + void clipSmartEnable( UIControl * ctrl, const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height ); + + void clipSmartDisable( UIControl * ctrl ); + void sendKeyUp( const Uint32& KeyCode, const Uint16& Char, const Uint32& Mod ); void sendKeyDown( const Uint32& KeyCode, const Uint16& Char, const Uint32& Mod ); @@ -59,6 +67,10 @@ class EE_API UIManager { bool getHighlightFocus() const; + void setDrawDebugData( bool debug ); + + bool getDrawDebugData() const; + void setHighlightFocusColor( const ColorA& Color ); const ColorA& getHighlightFocusColor() const; diff --git a/include/eepp/ui/uiscrollbar.hpp b/include/eepp/ui/uiscrollbar.hpp index 006d5c1ea..53bb2ed69 100644 --- a/include/eepp/ui/uiscrollbar.hpp +++ b/include/eepp/ui/uiscrollbar.hpp @@ -23,6 +23,8 @@ class EE_API UIScrollBar : public UIComplexControl { UIScrollBar( const UIScrollBar::CreateParams& Params ); + UIScrollBar(); + virtual ~UIScrollBar(); virtual Uint32 getType() const; diff --git a/src/eepp/ui/uicombobox.cpp b/src/eepp/ui/uicombobox.cpp index 2caf02873..11569f3c8 100644 --- a/src/eepp/ui/uicombobox.cpp +++ b/src/eepp/ui/uicombobox.cpp @@ -12,6 +12,15 @@ UIComboBox::UIComboBox( UIComboBox::CreateParams& Params ) : applyDefaultTheme(); } +UIComboBox::UIComboBox() : + UIDropDownList(), + mButton( NULL ) +{ + setAllowEditing( true ); + + applyDefaultTheme(); +} + UIComboBox::~UIComboBox() { } @@ -28,16 +37,12 @@ void UIComboBox::setTheme( UITheme * Theme ) { autoSizeControl(); - createButton(); - autoPadding(); onSizeChange(); } void UIComboBox::createButton() { - eeSAFE_DELETE( mButton ); - Int32 btnWidth = 0; if ( NULL != mSkinState && NULL != mSkinState->getSkin() ) { @@ -51,16 +56,19 @@ void UIComboBox::createButton() { } } - UIControl::CreateParams Params; - Params.setParent( this ), - Params.Size = Sizei( btnWidth, mSize.getHeight() ); - Params.setPosition( mSize.getWidth() - btnWidth, 0 ); - mButton = eeNew( UIControl, ( Params ) ); - mButton->setVisible( true ); - mButton->setEnabled( true ); - mButton->addEventListener( UIEvent::EventMouseClick, cb::Make1( this, &UIComboBox::onButtonClick ) ); - mButton->addEventListener( UIEvent::EventMouseEnter, cb::Make1( this, &UIComboBox::onButtonEnter ) ); - mButton->addEventListener( UIEvent::EventMouseExit, cb::Make1( this, &UIComboBox::onButtonExit ) ); + if ( NULL == mButton ) { + mButton = eeNew( UIControl, () ); + mButton->setParent( this ); + mButton->setVisible( true ); + mButton->setEnabled( true ); + mButton->addEventListener( UIEvent::EventMouseClick, cb::Make1( this, &UIComboBox::onButtonClick ) ); + mButton->addEventListener( UIEvent::EventMouseEnter, cb::Make1( this, &UIComboBox::onButtonEnter ) ); + mButton->addEventListener( UIEvent::EventMouseExit, cb::Make1( this, &UIComboBox::onButtonExit ) ); + + } + + mButton->setPixelsSize( btnWidth, mRealSize.getHeight() ); + mButton->setPixelsPosition( mRealSize.getWidth() - btnWidth, 0 ); } void UIComboBox::onButtonClick( const UIEvent * Event ) { @@ -94,4 +102,10 @@ Uint32 UIComboBox::onMouseClick( const Vector2i& position, const Uint32 Flags ) void UIComboBox::onControlClear( const UIEvent *Event ) { } +void UIComboBox::onSizeChange() { + UIDropDownList::onSizeChange(); + + createButton(); +} + }} diff --git a/src/eepp/ui/uicontrol.cpp b/src/eepp/ui/uicontrol.cpp index 943a1f751..5a0c4ff03 100644 --- a/src/eepp/ui/uicontrol.cpp +++ b/src/eepp/ui/uicontrol.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include namespace EE { namespace UI { @@ -327,6 +328,39 @@ void UIControl::close() { UIManager::instance()->addToCloseQueue( this ); } +void UIControl::drawHighlightFocus() { + if ( UIManager::instance()->getHighlightFocus() && UIManager::instance()->getFocusControl() == this ) { + Primitives P; + P.setFillMode( DRAW_LINE ); + P.setBlendMode( getBlendMode() ); + P.setColor( UIManager::instance()->getHighlightFocusColor() ); + P.setLineWidth( dpToPxI( 1 ) ); + P.drawRectangle( getRectf() ); + } +} + +void UIControl::drawOverControl() { + if ( UIManager::instance()->getHighlightOver() && UIManager::instance()->getOverControl() == this ) { + Primitives P; + P.setFillMode( DRAW_LINE ); + P.setBlendMode( getBlendMode() ); + P.setColor( UIManager::instance()->getHighlightOverColor() ); + P.setLineWidth( dpToPxI( 1 ) ); + P.drawRectangle( getRectf() ); + } +} + +void UIControl::drawDebugData() { + Graphics::Font * font = UIThemeManager::instance()->getDefaultFont(); + + if ( UIManager::instance()->getDrawDebugData() && font != NULL ) { + String text( String::strFormated( "X: %d Y: %d\nW: %d H: %d", mRealPos.x, mRealPos.y, mRealSize.x, mRealSize.y ) ); + + font->setColor( ColorA( 255, 0, 255, 255 ) ); + font->draw( text, mScreenPos.x, mScreenPos.y ); + } +} + void UIControl::draw() { if ( mVisible ) { if ( mFlags & UI_FILL_BACKGROUND ) @@ -336,23 +370,13 @@ void UIControl::draw() { borderDraw(); if ( NULL != mSkinState ) - mSkinState->draw( mScreenPosf.x, mScreenPosf.y, (Float)mSize.getWidth(), (Float)mSize.getHeight(), 255 ); + mSkinState->draw( mScreenPosf.x, mScreenPosf.y, (Float)mRealSize.getWidth(), (Float)mRealSize.getHeight(), 255 ); - if ( UIManager::instance()->getHighlightFocus() && UIManager::instance()->getFocusControl() == this ) { - Primitives P; - P.setFillMode( DRAW_LINE ); - P.setBlendMode( getBlendMode() ); - P.setColor( UIManager::instance()->getHighlightFocusColor() ); - P.drawRectangle( getRectf() ); - } + drawHighlightFocus(); - if ( UIManager::instance()->getHighlightOver() && UIManager::instance()->getOverControl() == this ) { - Primitives P; - P.setFillMode( DRAW_LINE ); - P.setBlendMode( getBlendMode() ); - P.setColor( UIManager::instance()->getHighlightOverColor() ); - P.drawRectangle( getRectf() ); - } + drawOverControl(); + + drawDebugData(); } } @@ -561,6 +585,11 @@ void UIControl::setFlags( const Uint32& flags ) { mBorder = eeNew( UIBorder, () ); } +void UIControl::unsetFlags(const Uint32 & flags) { + if ( mFlags & flags ) + mFlags &= ~flags; +} + void UIControl::setBlendMode( const EE_BLEND_MODE& blend ) { mBlend = static_cast ( blend ); } @@ -769,15 +798,15 @@ void UIControl::internalDraw() { void UIControl::clipMe() { if ( mFlags & UI_CLIP_ENABLE ) { if ( mFlags & UI_BORDER ) - UIManager::instance()->clipEnable( mScreenPos.x, mScreenPos.y, mRealSize.getWidth(), mRealSize.getHeight() + 1 ); + UIManager::instance()->clipSmartEnable( this, mScreenPos.x, mScreenPos.y, mRealSize.getWidth(), mRealSize.getHeight() + 1 ); else - UIManager::instance()->clipEnable( mScreenPos.x, mScreenPos.y, mRealSize.getWidth(), mRealSize.getHeight() ); + UIManager::instance()->clipSmartEnable( this, mScreenPos.x, mScreenPos.y, mRealSize.getWidth(), mRealSize.getHeight() ); } } void UIControl::clipDisable() { if ( mFlags & UI_CLIP_ENABLE ) - UIManager::instance()->clipDisable(); + UIManager::instance()->clipSmartDisable( this ); } void UIControl::matrixSet() { @@ -1025,6 +1054,23 @@ Uint32 UIControl::isClipped() { return mFlags & UI_CLIP_ENABLE; } +Uint32 UIControl::isRotated() { + return mControlFlags & UI_CTRL_FLAG_ROTATED; +} + +bool UIControl::isMeOrParentTreeRotated() { + UIControl * Ctrl = this; + + while( NULL != Ctrl ) { + if ( Ctrl->isRotated() ) + return true; + + Ctrl = Ctrl->getParent(); + } + + return false; +} + Polygon2f& UIControl::getPolygon() { return mPoly; } diff --git a/src/eepp/ui/uicontrolanim.cpp b/src/eepp/ui/uicontrolanim.cpp index d93bf8b5f..8980e5fa9 100644 --- a/src/eepp/ui/uicontrolanim.cpp +++ b/src/eepp/ui/uicontrolanim.cpp @@ -62,21 +62,11 @@ void UIControlAnim::draw() { if ( NULL != mSkinState ) mSkinState->draw( mScreenPosf.x, mScreenPosf.y, (Float)mRealSize.getWidth(), (Float)mRealSize.getHeight(), (Uint32)mAlpha ); - if ( UIManager::instance()->getHighlightFocus() && UIManager::instance()->getFocusControl() == this ) { - Primitives P; - P.setFillMode( DRAW_LINE ); - P.setBlendMode( getBlendMode() ); - P.setColor( UIManager::instance()->getHighlightFocusColor() ); - P.drawRectangle( getRectf() ); - } + drawHighlightFocus(); - if ( UIManager::instance()->getHighlightOver() && UIManager::instance()->getOverControl() == this ) { - Primitives P; - P.setFillMode( DRAW_LINE ); - P.setBlendMode( getBlendMode() ); - P.setColor( UIManager::instance()->getHighlightOverColor() ); - P.drawRectangle( getRectf() ); - } + drawOverControl(); + + drawDebugData(); } } @@ -103,6 +93,14 @@ Vector2f UIControlAnim::getRotationCenter() { void UIControlAnim::setRotation( const Float& angle ) { mAngle = angle; + + if ( mAngle != 0.f ) { + mControlFlags |= UI_CTRL_FLAG_ROTATED; + } else { + if ( mControlFlags & UI_CTRL_FLAG_ROTATED ) + mControlFlags &= ~UI_CTRL_FLAG_ROTATED; + } + onAngleChange(); } diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index 1fae3a76c..d8bc086d9 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -46,6 +46,43 @@ UIDropDownList::UIDropDownList( UIDropDownList::CreateParams& Params ) : mListBox->addEventListener( UIEvent::EventOnControlClear, cb::Make1( this, &UIDropDownList::onControlClear ) ); } +UIDropDownList::UIDropDownList() : + UITextInput(), + mListBox( NULL ), + mMinNumVisibleItems( 10 ), + mPopUpToMainControl( false ) +{ + setFlags( UI_CLIP_ENABLE | UI_AUTO_SIZE | UI_AUTO_PADDING ); + + setAllowEditing( false ); + + applyDefaultTheme(); + + Uint32 flags = UI_CLIP_ENABLE | UI_AUTO_PADDING; + + UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); + + if ( NULL != Theme ) { + mListBox = Theme->createListBox( NULL, Sizei( mSize.getWidth(), mMinNumVisibleItems * mSize.getHeight() ),Vector2i(), flags ); + } else { + UIListBox::CreateParams LBParams; + LBParams.Size = Sizei( mSize.getWidth(), mMinNumVisibleItems * mSize.getHeight() ); + LBParams.Flags = flags; + LBParams.FontSelectedColor = ColorA( 255, 255, 255, 255 ); + mListBox = eeNew( UIListBox, ( LBParams ) ); + } + + mListBox->setEnabled( false ); + mListBox->setVisible( false ); + + mListBox->addEventListener( UIEvent::EventOnComplexControlFocusLoss, cb::Make1( this, &UIDropDownList::onListBoxFocusLoss ) ); + mListBox->addEventListener( UIEvent::EventOnItemSelected , cb::Make1( this, &UIDropDownList::onItemSelected ) ); + mListBox->addEventListener( UIEvent::EventOnItemClicked, cb::Make1( this, &UIDropDownList::onItemClicked ) ); + mListBox->addEventListener( UIEvent::EventOnItemKeyDown, cb::Make1( this, &UIDropDownList::onItemKeyDown ) ); + mListBox->addEventListener( UIEvent::EventKeyDown , cb::Make1( this, &UIDropDownList::onItemKeyDown ) ); + mListBox->addEventListener( UIEvent::EventOnControlClear, cb::Make1( this, &UIDropDownList::onControlClear ) ); +} + UIDropDownList::~UIDropDownList() { destroyListBox(); } @@ -70,10 +107,12 @@ void UIDropDownList::setTheme( UITheme * Theme ) { void UIDropDownList::onSizeChange() { UIComplexControl::onSizeChange(); + + autoSizeControl(); } void UIDropDownList::autoSizeControl() { - if ( mFlags & UI_AUTO_SIZE ) { + if ( mFlags & UI_AUTO_SIZE || 0 == mSize.getHeight() ) { setPixelsSize( mRealSize.x, getSkinSize().getHeight() ); } } diff --git a/src/eepp/ui/uilistbox.cpp b/src/eepp/ui/uilistbox.cpp index 52de23ea4..832d6ddbd 100644 --- a/src/eepp/ui/uilistbox.cpp +++ b/src/eepp/ui/uilistbox.cpp @@ -78,6 +78,71 @@ UIListBox::UIListBox( UIListBox::CreateParams& Params ) : applyDefaultTheme(); } + +UIListBox::UIListBox() : + UIComplexControl(), + mContainer( NULL ), + mVScrollBar( NULL ), + mHScrollBar( NULL ), + mLastPos( eeINDEX_NOT_FOUND ), + mMaxTextWidth(0), + mHScrollInit(0), + mItemsNotVisible(0), + mLastTickMove(0), + mVisibleFirst(0), + mVisibleLast(0), + mTouchDragAcceleration(0) +{ + setFlags( UI_CLIP_ENABLE | UI_AUTO_PADDING ); + + if ( NULL != UIThemeManager::instance()->getDefaultFont() ) + mFont = UIThemeManager::instance()->getDefaultFont(); + + UIControl::CreateParams CParams; + CParams.setParent( this ); + CParams.setPosition( mPaddingContainer.Left, mPaddingContainer.Top ); + CParams.Size = Sizei( mSize.getWidth() - mPaddingContainer.Right - mPaddingContainer.Left, mSize.getHeight() - mPaddingContainer.Top - mPaddingContainer.Bottom ); + CParams.Flags = mFlags; + mContainer = eeNew( UIItemContainer, ( CParams ) ); + mContainer->setVisible( true ); + mContainer->setEnabled( true ); + + if ( mFlags & UI_CLIP_ENABLE ) + mFlags &= ~UI_CLIP_ENABLE; + + UIScrollBar::CreateParams ScrollBarP; + ScrollBarP.setParent( this ); + ScrollBarP.Size = Sizei( 15, mSize.getHeight() ); + ScrollBarP.setPosition( mSize.getWidth() - 15, 0 ); + ScrollBarP.Flags = UI_AUTO_SIZE; + ScrollBarP.VerticalScrollBar = true; + mVScrollBar = eeNew( UIScrollBar, ( ScrollBarP ) ); + + ScrollBarP.Size = Sizei( mSize.getWidth() - mVScrollBar->getSize().getWidth(), 15 ); + ScrollBarP.setPosition( 0, mSize.getHeight() - 15 ); + ScrollBarP.VerticalScrollBar = false; + mHScrollBar = eeNew( UIScrollBar, ( ScrollBarP ) ); + + if ( UI_SCROLLBAR_ALWAYS_ON == mHScrollMode ) { + mHScrollBar->setVisible( true ); + mHScrollBar->setEnabled( true ); + } + + if ( UI_SCROLLBAR_ALWAYS_ON == mVScrollMode ) { + mVScrollBar->setVisible( true ); + mVScrollBar->setEnabled( true ); + } + + mVScrollBar->addEventListener( UIEvent::EventOnValueChange, cb::Make1( this, &UIListBox::onScrollValueChange ) ); + mHScrollBar->addEventListener( UIEvent::EventOnValueChange, cb::Make1( this, &UIListBox::onHScrollValueChange ) ); + + setSmoothScroll( true ); + + setRowHeight(); + + applyDefaultTheme(); +} + UIListBox::~UIListBox() { } @@ -155,7 +220,7 @@ Uint32 UIListBox::addListBoxItem( const String& Text ) { Uint32 twidth = mFont->getTextWidth( Text ); if ( twidth > mMaxTextWidth ) { - mMaxTextWidth = twidth; + mMaxTextWidth = (Uint32)pxToDpI( twidth ); updateListBoxItemsSize(); } @@ -335,7 +400,7 @@ void UIListBox::findMaxWidth() { width = mFont->getTextWidth( mTexts[i] ); if ( width > (Int32)mMaxTextWidth ) - mMaxTextWidth = (Uint32)width; + mMaxTextWidth = (Uint32)pxToDpI( width ); } } @@ -351,7 +416,7 @@ void UIListBox::itemUpdateSize( UIListBoxItem * Item ) { Int32 width = (Int32)Item->getTextWidth(); if ( width > (Int32)mMaxTextWidth ) - mMaxTextWidth = (Uint32)width; + mMaxTextWidth = (Uint32)pxToDpI( width ); if ( !mHScrollBar->isVisible() ) { if ( width < mContainer->getSize().getWidth() ) diff --git a/src/eepp/ui/uilistboxitem.cpp b/src/eepp/ui/uilistboxitem.cpp index 532b05d2e..8f8132eb8 100644 --- a/src/eepp/ui/uilistboxitem.cpp +++ b/src/eepp/ui/uilistboxitem.cpp @@ -10,6 +10,12 @@ UIListBoxItem::UIListBoxItem( const UITextBox::CreateParams& Params ) : applyDefaultTheme(); } +UIListBoxItem::UIListBoxItem() : + UITextBox() +{ + applyDefaultTheme(); +} + UIListBoxItem::~UIListBoxItem() { if ( UIManager::instance()->getFocusControl() == this ) mParentCtrl->setFocus(); diff --git a/src/eepp/ui/uimanager.cpp b/src/eepp/ui/uimanager.cpp index d130f0517..5e88d3b12 100644 --- a/src/eepp/ui/uimanager.cpp +++ b/src/eepp/ui/uimanager.cpp @@ -285,14 +285,38 @@ const Uint32& UIManager::getLastPressTrigger() const { return mKM->getLastPressTrigger(); } -void UIManager::clipEnable( const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height ) { +void UIManager::clipPlaneEnable( const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height ) { mWindow->clipPlaneEnable( x, y, Width, Height ); } -void UIManager::clipDisable() { +void UIManager::clipPlaneDisable() { mWindow->clipPlaneDisable(); } +void UIManager::clipEnable( const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height ) { + mWindow->clipEnable( x, y, Width, Height ); +} + +void UIManager::clipDisable() { + mWindow->clipDisable(); +} + +void UIManager::clipSmartEnable(UIControl * ctrl, const Int32 & x, const Int32 & y, const Uint32 & Width, const Uint32 & Height) { + if ( ctrl->isMeOrParentTreeRotated() ) { + clipPlaneEnable( x, y, Width, Height ); + } else { + clipEnable( x, y, Width, Height ); + } +} + +void UIManager::clipSmartDisable(UIControl * ctrl) { + if ( ctrl->isMeOrParentTreeRotated() ) { + clipPlaneDisable(); + } else { + clipDisable(); + } +} + void UIManager::setHighlightFocus( bool Highlight ) { BitOp::setBitFlagValue( &mFlags, UI_MANAGER_HIGHLIGHT_FOCUS, Highlight ? 1 : 0 ); } @@ -301,6 +325,14 @@ bool UIManager::getHighlightFocus() const { return 0 != ( mFlags & UI_MANAGER_HIGHLIGHT_FOCUS ); } +void UIManager::setDrawDebugData( bool debug ) { + BitOp::setBitFlagValue( &mFlags, UI_MANAGER_DRAW_DEBUG_DATA, debug ? 1 : 0 ); +} + +bool UIManager::getDrawDebugData() const { + return 0 != ( mFlags & UI_MANAGER_DRAW_DEBUG_DATA ); +} + void UIManager::setHighlightFocusColor( const ColorA& Color ) { mHighlightFocusColor = Color; } diff --git a/src/eepp/ui/uiscrollbar.cpp b/src/eepp/ui/uiscrollbar.cpp index 0f8d1f6ee..1a4e30848 100644 --- a/src/eepp/ui/uiscrollbar.cpp +++ b/src/eepp/ui/uiscrollbar.cpp @@ -42,6 +42,32 @@ UIScrollBar::UIScrollBar( const UIScrollBar::CreateParams& Params ) : applyDefaultTheme(); } +UIScrollBar::UIScrollBar() : + UIComplexControl() +{ + mBtnDown = eeNew( UIControlAnim, () ); + mBtnUp = eeNew( UIControlAnim, () ); + mBtnUp->setParent( this ); + mBtnUp->setVisible( true ); + mBtnUp->setEnabled( true ); + mBtnUp->setSize( 16, 16 ); + mBtnDown->setParent( this ); + mBtnDown->setVisible( true ); + mBtnDown->setEnabled( true ); + mBtnDown->setSize( 16, 16 ); + + mSlider = eeNew( UISlider, () ); + mSlider->setParent( this ); + mSlider->setVisible( true ); + mSlider->setEnabled( true ); + + mSlider->addEventListener( UIEvent::EventOnValueChange, cb::Make1( this, &UIScrollBar::onValueChangeCb ) ); + + adjustChilds(); + + applyDefaultTheme(); +} + UIScrollBar::~UIScrollBar() { } diff --git a/src/eepp/ui/uislider.cpp b/src/eepp/ui/uislider.cpp index 3fa305c10..67f824b42 100644 --- a/src/eepp/ui/uislider.cpp +++ b/src/eepp/ui/uislider.cpp @@ -23,7 +23,7 @@ UISlider::UISlider( const UISlider::CreateParams& Params ) : if ( !mVertical ) BgParams.Size = Sizei( mSize.getWidth() - 16, 8 ); else - BgParams.Size = Sizei( 8, mSize.getWidth() - 16 ); + BgParams.Size = Sizei( 8, mSize.getHeight() - 16 ); mBackSlider = eeNew( UIControlAnim, ( BgParams ) ); mBackSlider->setVisible( true ); @@ -66,7 +66,7 @@ UISlider::UISlider() : if ( !mVertical ) bgSize = dpToPxI( Sizei( mSize.getWidth() - 16, 8 ) ); else - bgSize = dpToPxI( Sizei( 8, mSize.getWidth() - 16 ) ); + bgSize = dpToPxI( Sizei( 8, mSize.getHeight() - 16 ) ); mBackSlider = eeNew( UIControlAnim, () ); mBackSlider->setParent( this ); diff --git a/src/eepp/ui/uitextbox.cpp b/src/eepp/ui/uitextbox.cpp index 46afcc139..70d9baafc 100644 --- a/src/eepp/ui/uitextbox.cpp +++ b/src/eepp/ui/uitextbox.cpp @@ -77,7 +77,8 @@ void UITextBox::draw() { if ( mTextCache->getTextWidth() ) { if ( mFlags & UI_CLIP_ENABLE ) { - UIManager::instance()->clipEnable( + UIManager::instance()->clipSmartEnable( + this, mScreenPos.x + mRealPadding.Left, mScreenPos.y + mRealPadding.Top, mRealSize.getWidth() - mRealPadding.Left - mRealPadding.Right, @@ -89,7 +90,7 @@ void UITextBox::draw() { mTextCache->draw( (Float)mScreenPos.x + mAlignOffset.x + (Float)mRealPadding.Left, (Float)mScreenPos.y + mAlignOffset.y + (Float)mRealPadding.Top, Vector2f::One, 0.f, getBlendMode() ); if ( mFlags & UI_CLIP_ENABLE ) { - UIManager::instance()->clipDisable(); + UIManager::instance()->clipSmartDisable( this ); } } } diff --git a/src/eepp/ui/uitextinput.cpp b/src/eepp/ui/uitextinput.cpp index fb9f45986..53e69e341 100644 --- a/src/eepp/ui/uitextinput.cpp +++ b/src/eepp/ui/uitextinput.cpp @@ -30,6 +30,8 @@ UITextInput::UITextInput() : mAllowEditing( true ), mShowingWait( true ) { + setFlags( UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_AUTO_SIZE ); + mTextBuffer.start(); mTextBuffer.setActive( false ); mTextBuffer.setFreeEditing( true ); @@ -80,6 +82,8 @@ void UITextInput::update() { if ( mCursorPos != mTextBuffer.getCursorPos() ) { alignFix(); mCursorPos = mTextBuffer.getCursorPos(); + mWaitCursorTime = 0.f; + mShowingWait = true; onCursorPosChange(); } } @@ -191,7 +195,7 @@ void UITextInput::setTheme( UITheme * Theme ) { } void UITextInput::autoSize() { - if ( mFlags & UI_AUTO_SIZE ) { + if ( ( mFlags & UI_AUTO_SIZE ) || 0 == mSize.getHeight() ) { setPixelsSize( mRealSize.x, getSkinSize().getHeight() ); } } diff --git a/src/eepp/ui/uitextinputpassword.cpp b/src/eepp/ui/uitextinputpassword.cpp index f3e6f2745..93d27d9ed 100644 --- a/src/eepp/ui/uitextinputpassword.cpp +++ b/src/eepp/ui/uitextinputpassword.cpp @@ -30,7 +30,8 @@ void UITextInputPassword::draw() { if ( mPassCache->getTextWidth() ) { if ( mFlags & UI_CLIP_ENABLE ) { - UIManager::instance()->clipEnable( + UIManager::instance()->clipSmartEnable( + this, mScreenPos.x + mRealPadding.Left, mScreenPos.y + mRealPadding.Top, mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, @@ -42,7 +43,7 @@ void UITextInputPassword::draw() { mPassCache->draw( (Float)mScreenPos.x + mAlignOffset.x + (Float)mRealPadding.Left, (Float)mScreenPos.y + mAlignOffset.y + (Float)mRealPadding.Top, Vector2f::One, 0.f, getBlendMode() ); if ( mFlags & UI_CLIP_ENABLE ) { - UIManager::instance()->clipDisable(); + UIManager::instance()->clipSmartDisable( this ); } } } diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 0aa0cb0db..0a05de9c2 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -277,6 +277,15 @@ void EETest::createUI() { UIThemeManager::instance()->setDefaultEffectsEnabled( true ); UIThemeManager::instance()->setDefaultFont( TTF ); UIThemeManager::instance()->setDefaultTheme( mThemeName ); + + Int32 wsize = 100; + std::vector str(wsize); + + if ( wsize ) { + for ( Int32 i = 1; i <= wsize; i++ ) + str[i-1] = "Test ListBox " + String::toStr(i) + " testing it right now!"; + } + /**/ UIControl::CreateParams Params( UIManager::instance()->getMainControl(), Vector2i(0,0), Sizei( 530, 380 ), UI_FILL_BACKGROUND | UI_CLIP_ENABLE | UI_BORDER ); @@ -426,16 +435,7 @@ void EETest::createUI() { mListBox->setVisible( true ); mListBox->setEnabled( true ); - Int32 wsize = 100; - - if ( wsize ) { - std::vector str(wsize); - - for ( Int32 i = 1; i <= wsize; i++ ) - str[i-1] = "Test ListBox " + String::toStr(i) + " testing it right now!"; - - mListBox->addListBoxItems( str ); - } + mListBox->addListBoxItems( str ); UIDropDownList::CreateParams DDLParams; DDLParams.setParent( C ); @@ -620,6 +620,38 @@ void EETest::createUI() { slider->setSize( 16, 100 ); slider->setVisible( true ); slider->setEnabled( true ); + + UITextInput * textInput = eeNew( UITextInput, () ); + textInput->setPosition( 50, 210 ); + textInput->setSize( 100, 0 ); + textInput->setVisible( true ); + textInput->setEnabled( true ); + + UIDropDownList * dropdownList = eeNew( UIDropDownList, () ); + dropdownList->setPosition( 50, 250 ); + dropdownList->setSize( 100, 0 ); + dropdownList->setVisible( true ); + dropdownList->setEnabled( true ); + dropdownList->getListBox()->addListBoxItem( "Test 1" ); + dropdownList->getListBox()->addListBoxItem( "Test 2" ); + dropdownList->getListBox()->addListBoxItem( "Test 3" ); + + UIComboBox * comboBox = eeNew( UIComboBox, () ); + comboBox->setPosition( 50, 280 ); + comboBox->setSize( 100, 0 ); + comboBox->setVisible( true ); + comboBox->setEnabled( true ); + comboBox->getListBox()->addListBoxItem( "Test 1" ); + comboBox->getListBox()->addListBoxItem( "Test 2" ); + comboBox->getListBox()->addListBoxItem( "Test 3" ); + comboBox->getListBox()->setSelected( 0 ); + + UIListBox * listBox = eeNew( UIListBox, () ); + listBox->setPosition( 50, 320 ); + listBox->setSize( 100, 160 ); + listBox->setVisible( true ); + listBox->setEnabled( true ); + listBox->addListBoxItems( str ); } void EETest::createMapEditor() {