diff --git a/src/graphics/ctextcache.cpp b/src/graphics/ctextcache.cpp index 1bdb6980a..7153d279b 100644 --- a/src/graphics/ctextcache.cpp +++ b/src/graphics/ctextcache.cpp @@ -126,7 +126,7 @@ const std::vector& cTextCache::LinesWidth() { return mLinesWidth; } -void cTextCache::Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, const EE_PRE_BLEND_FUNC& Effect ) { +void cTextCache::Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags, const eeFloat& Scale, const eeFloat& Angle, EE_PRE_BLEND_FUNC Effect ) { if ( NULL != mFont ) { if ( mFlags != Flags ) { mFlags = Flags; diff --git a/src/graphics/ctextcache.hpp b/src/graphics/ctextcache.hpp index 15cebc609..a9c6849d6 100644 --- a/src/graphics/ctextcache.hpp +++ b/src/graphics/ctextcache.hpp @@ -38,7 +38,7 @@ class EE_API cTextCache { std::vector& Colors(); - void Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags = 0, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0, const EE_PRE_BLEND_FUNC& Effect = ALPHA_NORMAL ); + void Draw( const eeFloat& X, const eeFloat& Y, const Uint32& Flags = 0, const eeFloat& Scale = 1.0f, const eeFloat& Angle = 0, EE_PRE_BLEND_FUNC Effect = ALPHA_NORMAL ); void Cache(); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 9ed84d74d..dfb660591 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -63,6 +63,10 @@ void cEETest::Init() { run = ( mWindow->Created() && PAK.IsOpen() ); if ( run ) { + std::cout << "Size of Callback0: " << sizeof( cb::Callback0 ) << std::endl; + std::cout << "Size of cWaypoints: " << sizeof( cWaypoints ) << std::endl; + std::cout << "Size of UIEventsMap: " << sizeof( std::map< Uint32, std::map > ) << std::endl; + std::cout << "Size of eePolygon2f: " << sizeof(eePolygon2f) << std::endl; std::cout << "Size of cTexture: " << sizeof(cTexture) << std::endl; std::cout << "Size of cShape: " << sizeof(Graphics::cShape) << std::endl; std::cout << "Size of cSprite: " << sizeof(cSprite) << std::endl; @@ -643,7 +647,7 @@ void cEETest::CloseClick( const cUIEvent * Event ) { } void cEETest::ItemClick( const cUIEvent * Event ) { - if ( !Event->Ctrl()->IsType( UI_TYPE_MENUITEM ) ) + if ( !Event->Ctrl()->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) return; const String& txt = reinterpret_cast ( Event->Ctrl() )->Text(); diff --git a/src/ui/cuicheckbox.cpp b/src/ui/cuicheckbox.cpp index 607738391..758978578 100644 --- a/src/ui/cuicheckbox.cpp +++ b/src/ui/cuicheckbox.cpp @@ -6,7 +6,7 @@ cUICheckBox::cUICheckBox( const cUITextBox::CreateParams& Params ) : cUITextBox( Params ), mActive( false ) { - mType |= UI_TYPE_GET(UI_TYPE_CHECKBOX); + mType = UI_TYPE_CHECKBOX; cUIControlAnim::CreateParams ButtonParams( Params ); diff --git a/src/ui/cuicombobox.cpp b/src/ui/cuicombobox.cpp index 98cc3efe7..b09da8204 100644 --- a/src/ui/cuicombobox.cpp +++ b/src/ui/cuicombobox.cpp @@ -6,7 +6,7 @@ cUIComboBox::cUIComboBox( cUIComboBox::CreateParams& Params ) : cUIDropDownList( Params ), mButton( NULL ) { - mType |= UI_TYPE_GET( UI_TYPE_COMBOBOX ); + mType = UI_TYPE_COMBOBOX; AllowEditing( true ); diff --git a/src/ui/cuicommondialog.cpp b/src/ui/cuicommondialog.cpp index 2d1687320..0cab2e0ce 100644 --- a/src/ui/cuicommondialog.cpp +++ b/src/ui/cuicommondialog.cpp @@ -11,6 +11,8 @@ cUICommonDialog::cUICommonDialog( const cUICommonDialog::CreateParams& Params ) cUIWindow( Params ), mCurPath( Params.DefaultDirectory ) { + mType = UI_TYPE_COMMONDIALOG; + if ( mSize.Width() < CDLG_MIN_WIDTH ) mSize.x = CDLG_MIN_WIDTH; @@ -179,7 +181,7 @@ Uint32 cUICommonDialog::OnMessage( const cUIMessage *Msg ) { } case cUIMessage::MsgDoubleClick: { - if ( Msg->Sender()->IsType( UI_TYPE_LISTBOXITEM ) ) { + if ( Msg->Sender()->IsTypeOrInheritsFrom( UI_TYPE_LISTBOXITEM ) ) { std::string newPath = mCurPath + mList->GetItemSelectedText(); if ( IsDirectory( newPath ) ) { diff --git a/src/ui/cuicomplexcontrol.cpp b/src/ui/cuicomplexcontrol.cpp index 1fca22b2a..39743ba88 100644 --- a/src/ui/cuicomplexcontrol.cpp +++ b/src/ui/cuicomplexcontrol.cpp @@ -8,7 +8,8 @@ cUIComplexControl::cUIComplexControl( const cUIComplexControl::CreateParams& Par mTooltip( NULL ), mMinControlSize( Params.MinControlSize ) { - mType |= UI_TYPE_GET( UI_TYPE_CONTROL_COMPLEX ); + mType = UI_TYPE_CONTROL_COMPLEX; + mControlFlags |= UI_CTRL_FLAG_COMPLEX; CalcDistToBorder(); diff --git a/src/ui/cuicontrol.cpp b/src/ui/cuicontrol.cpp index 2ccf0817f..6a8a48c07 100644 --- a/src/ui/cuicontrol.cpp +++ b/src/ui/cuicontrol.cpp @@ -4,24 +4,24 @@ namespace EE { namespace UI { cUIControl::cUIControl( const CreateParams& Params ) : - mVisible( false ), - mEnabled( false ), mPos( Params.Pos ), mSize( Params.Size ), - mParentCtrl( Params.ParentCtrl ), mFlags( Params.Flags ), - mType( 0 ), + mType( UI_TYPE_CONTROL ), mData( 0 ), + mParentCtrl( Params.ParentCtrl ), mChild( NULL ), mChildLast( NULL ), mNext( NULL ), mPrev( NULL ), + mSkinState( NULL ), mBackground( NULL ), mBorder( NULL ), mControlFlags( 0 ), mBlend( Params.Blend ), - mNumCallBacks(0), - mSkinState(NULL) + mNumCallBacks( 0 ), + mVisible( false ), + mEnabled( false ) { if ( NULL == mParentCtrl && NULL != cUIManager::instance()->MainControl() ) { mParentCtrl = cUIManager::instance()->MainControl(); @@ -94,7 +94,15 @@ Uint32 cUIControl::Type() const { } bool cUIControl::IsType( const Uint32& Type ) const { - return ( mType & UI_TYPE_GET(Type) ) != 0; + return mType == Type; +} + +bool cUIControl::InheritsFrom( const Uint32 Type ) { + return false; +} + +bool cUIControl::IsTypeOrInheritsFrom( const Uint32 Type ) { + return IsType( Type ) || InheritsFrom( Type ); } void cUIControl::MessagePost( const cUIMessage * Msg ) { @@ -433,11 +441,11 @@ void cUIControl::Flags( const Uint32& flags ) { } void cUIControl::Blend( const EE_PRE_BLEND_FUNC& blend ) { - mBlend = blend; + mBlend = static_cast ( blend ); } -EE_PRE_BLEND_FUNC& cUIControl::Blend() { - return mBlend; +EE_PRE_BLEND_FUNC cUIControl::Blend() { + return static_cast ( mBlend ); } void cUIControl::ToFront() { @@ -501,9 +509,9 @@ void cUIControl::BorderDraw() { P.SetColor( mBorder->Color() ); if ( mFlags & UI_CLIP_ENABLE ) - P.DrawRectangle( (eeFloat)mScreenPos.x + 0.1f, (eeFloat)mScreenPos.y + 0.1f, (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f, 0.f, 1.f, EE_DRAW_LINE, mBlend, (eeFloat)mBorder->Width(), mBackground->Corners() ); + P.DrawRectangle( (eeFloat)mScreenPos.x + 0.1f, (eeFloat)mScreenPos.y + 0.1f, (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f, 0.f, 1.f, EE_DRAW_LINE, Blend(), (eeFloat)mBorder->Width(), mBackground->Corners() ); else - P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, mBlend, (eeFloat)mBorder->Width(), mBackground->Corners() ); + P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, Blend(), (eeFloat)mBorder->Width(), mBackground->Corners() ); } const Uint32& cUIControl::ControlFlags() const { @@ -747,7 +755,7 @@ cUIControl * cUIControl::ChildGetLast() const { cUIControl * cUIControl::OverFind( const eeVector2f& Point ) { cUIControl * pOver = NULL; - if ( mVisible && mEnabled ) { + if ( mEnabled && mVisible ) { UpdateQuad(); if ( PointInsidePolygon2( mPoly, Point ) ) { @@ -800,11 +808,18 @@ Uint32 cUIControl::IsAnimated() { return mControlFlags & UI_CTRL_FLAG_ANIM; } +Uint32 cUIControl::IsDragable() { + return mControlFlags & UI_CTRL_FLAG_DRAGABLE; +} + +Uint32 cUIControl::IsComplex() { + return mControlFlags & UI_CTRL_FLAG_COMPLEX; +} + Uint32 cUIControl::IsClipped() { return mFlags & UI_CLIP_ENABLE; } - const eePolygon2f& cUIControl::GetPolygon() const { return mPoly; } @@ -847,7 +862,7 @@ Uint32 cUIControl::AddEventListener( const Uint32& EventType, const UIEventCallb } void cUIControl::RemoveEventListener( const Uint32& CallbackId ) { - std::map< Uint32, std::map >::iterator it; + UIEventsMap::iterator it; for ( it = mEvents.begin(); it != mEvents.end(); ++it ) { std::map event = it->second; @@ -1098,7 +1113,7 @@ cUIControl * cUIControl::NextComplexControl() { while( NULL != ChildLoop ) { if ( ChildLoop->Visible() ) { - if ( ChildLoop->IsType( UI_TYPE_CONTROL_COMPLEX ) ) { + if ( ChildLoop->IsComplex() ) { return ChildLoop; } else { Found = ChildLoop->NextComplexControl(); @@ -1113,7 +1128,7 @@ cUIControl * cUIControl::NextComplexControl() { } if ( NULL != mNext ) { - if ( mNext->Visible() && mNext->IsType( UI_TYPE_CONTROL_COMPLEX ) ) { + if ( mNext->Visible() && mNext->IsComplex() ) { return mNext; } else { return mNext->NextComplexControl(); @@ -1123,7 +1138,7 @@ cUIControl * cUIControl::NextComplexControl() { while ( NULL != ChildLoop ) { if ( NULL != ChildLoop->mNext ) { - if ( ChildLoop->mNext->Visible() && ChildLoop->mNext->IsType( UI_TYPE_CONTROL_COMPLEX ) ) { + if ( ChildLoop->mNext->Visible() && ChildLoop->mNext->IsComplex() ) { return ChildLoop->mNext; } else { return ChildLoop->mNext->NextComplexControl(); diff --git a/src/ui/cuicontrol.hpp b/src/ui/cuicontrol.hpp index 275a1b996..4dcd3873c 100644 --- a/src/ui/cuicontrol.hpp +++ b/src/ui/cuicontrol.hpp @@ -82,6 +82,10 @@ class EE_API cUIControl { bool IsType( const Uint32& Type ) const; + virtual bool InheritsFrom( const Uint32 Type ); + + bool IsTypeOrInheritsFrom( const Uint32 Type ); + virtual void MessagePost( const cUIMessage * Msg ); bool IsInside( const eeVector2i& Pos ) const; @@ -158,7 +162,7 @@ class EE_API cUIControl { void Blend( const EE_PRE_BLEND_FUNC& blend ); - EE_PRE_BLEND_FUNC& Blend(); + EE_PRE_BLEND_FUNC Blend(); void ToFront(); @@ -173,6 +177,10 @@ class EE_API cUIControl { Uint32 IsAnimated(); + Uint32 IsDragable(); + + Uint32 IsComplex(); + Uint32 IsClipped(); Uint32 AddEventListener( const Uint32& EventType, const UIEventCallback& Callback ); @@ -227,38 +235,41 @@ class EE_API cUIControl { cUIControl * NextComplexControl(); protected: + typedef std::map< Uint32, std::map > UIEventsMap; friend class cUIManager; - bool mVisible; - bool mEnabled; eeVector2i mPos; eeVector2i mScreenPos; eeSize mSize; - cUIControl * mParentCtrl; + Uint32 mFlags; Uint32 mType; Uint32 mData; + cUIControl * mParentCtrl; cUIControl * mChild; //! Pointer to the first child of the control cUIControl * mChildLast; //! Pointer to the last child added cUIControl * mNext; //! Pointer to the next child of the father cUIControl * mPrev; //! Pointer to the prev child of the father + cUISkinState * mSkinState; cUIBackground * mBackground; cUIBorder * mBorder; Uint32 mControlFlags; - EE_PRE_BLEND_FUNC mBlend; + Uint16 mBlend; + Uint16 mNumCallBacks; eePolygon2f mPoly; eeVector2f mCenter; - std::map< Uint32, std::map > mEvents; - Uint32 mNumCallBacks; + UIEventsMap mEvents; - cUISkinState * mSkinState; std::string mSkinForcedName; + bool mVisible; + bool mEnabled; + virtual Uint32 OnMessage( const cUIMessage * Msg ); virtual Uint32 OnKeyDown( const cUIEventKey& Event ); diff --git a/src/ui/cuicontrolanim.cpp b/src/ui/cuicontrolanim.cpp index ac300b7e2..3bbdc99c5 100644 --- a/src/ui/cuicontrolanim.cpp +++ b/src/ui/cuicontrolanim.cpp @@ -13,7 +13,7 @@ cUIControlAnim::cUIControlAnim( const CreateParams& Params ) : mAlphaAnim(NULL), mMoveAnim(NULL) { - mType |= UI_TYPE_GET(UI_TYPE_CONTROL_ANIM); + mType = UI_TYPE_CONTROL_ANIM; mControlFlags |= UI_CTRL_FLAG_ANIM; } @@ -38,7 +38,7 @@ void cUIControlAnim::Draw() { if ( cUIManager::instance()->HighlightFocus() && cUIManager::instance()->FocusControl() == this ) { cPrimitives P; P.SetColor( cUIManager::instance()->HighlightColor() ); - P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, mBlend, 1, 0 ); + P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, Blend(), 1, 0 ); } } } @@ -252,9 +252,9 @@ void cUIControlAnim::BorderDraw() { P.SetColor( GetColor( mBorder->Color() ) ); if ( mFlags & UI_CLIP_ENABLE ) - P.DrawRectangle( (eeFloat)mScreenPos.x + 0.1f, (eeFloat)mScreenPos.y + 0.1f, (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f, 0.f, 1.f, EE_DRAW_LINE, mBlend, (eeFloat)mBorder->Width(), mBackground->Corners() ); + P.DrawRectangle( (eeFloat)mScreenPos.x + 0.1f, (eeFloat)mScreenPos.y + 0.1f, (eeFloat)mSize.Width() - 0.1f, (eeFloat)mSize.Height() - 0.1f, 0.f, 1.f, EE_DRAW_LINE, Blend(), (eeFloat)mBorder->Width(), mBackground->Corners() ); else - P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, mBlend, (eeFloat)mBorder->Width(), mBackground->Corners() ); + P.DrawRectangle( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y, (eeFloat)mSize.Width(), (eeFloat)mSize.Height(), 0.f, 1.f, EE_DRAW_LINE, Blend(), (eeFloat)mBorder->Width(), mBackground->Corners() ); } eeColorA cUIControlAnim::GetColor( const eeColorA& Col ) { diff --git a/src/ui/cuidragable.cpp b/src/ui/cuidragable.cpp index 82eb95154..1efdab800 100644 --- a/src/ui/cuidragable.cpp +++ b/src/ui/cuidragable.cpp @@ -8,7 +8,8 @@ cUIDragable::cUIDragable( const cUIControl::CreateParams& Params ) : cUIControl( Params ), mDragButton( EE_BUTTON_LMASK ) { - mType |= UI_TYPE_GET(UI_TYPE_CONTROL_DRAGABLE); + mType = UI_TYPE_CONTROL_DRAGABLE; + mControlFlags |= UI_CTRL_FLAG_DRAGABLE; } cUIDragable::~cUIDragable() { diff --git a/src/ui/cuidropdownlist.cpp b/src/ui/cuidropdownlist.cpp index 003569063..60d65e1be 100644 --- a/src/ui/cuidropdownlist.cpp +++ b/src/ui/cuidropdownlist.cpp @@ -9,7 +9,7 @@ cUIDropDownList::cUIDropDownList( cUIDropDownList::CreateParams& Params ) : mMinNumVisibleItems( Params.MinNumVisibleItems ), mPopUpToMainControl( Params.PopUpToMainControl ) { - mType |= UI_TYPE_GET( UI_TYPE_DROPDOWNLIST ); + mType = UI_TYPE_DROPDOWNLIST; if ( NULL == mListBox ) { cUIListBox::CreateParams LBParams; diff --git a/src/ui/cuigenericgrid.cpp b/src/ui/cuigenericgrid.cpp index e478a8294..3ec70cb08 100644 --- a/src/ui/cuigenericgrid.cpp +++ b/src/ui/cuigenericgrid.cpp @@ -23,7 +23,7 @@ cUIGenericGrid::cUIGenericGrid( const cUIGenericGrid::CreateParams& Params ) : mSelected(-1), mCollWidthAssigned( false ) { - mType |= UI_TYPE_GENERICGRID; + mType = UI_TYPE_GENERICGRID; mCollumnsWidth.resize( mCollumnsCount, 0 ); mCollumnsPos.resize( mCollumnsCount, 0 ); diff --git a/src/ui/cuigfx.cpp b/src/ui/cuigfx.cpp index 115e265c3..17b69084d 100644 --- a/src/ui/cuigfx.cpp +++ b/src/ui/cuigfx.cpp @@ -9,7 +9,7 @@ cUIGfx::cUIGfx( const cUIGfx::CreateParams& Params ) : mRender( Params.ShapeRender ), mAlignOffset(0,0) { - mType |= UI_TYPE_GET(UI_TYPE_GFX); + mType = UI_TYPE_GFX; if ( NULL != mShape && ( ( Flags() & UI_AUTO_SIZE ) || ( Params.Size.x == -1 && Params.Size.y == -1 ) ) ) Size( mShape->Size() ); @@ -43,7 +43,7 @@ void cUIGfx::Draw() { if ( mVisible ) { if ( NULL != mShape && 0.f != mAlpha ) - mShape->Draw( (eeFloat)mScreenPos.x + mAlignOffset.x, (eeFloat)mScreenPos.y + mAlignOffset.y, mColor, 0.f, 1.f, mBlend, mRender ); + mShape->Draw( (eeFloat)mScreenPos.x + mAlignOffset.x, (eeFloat)mScreenPos.y + mAlignOffset.y, mColor, 0.f, 1.f, Blend(), mRender ); } } diff --git a/src/ui/cuigridcell.cpp b/src/ui/cuigridcell.cpp index dd8e68e2a..3c7cff496 100644 --- a/src/ui/cuigridcell.cpp +++ b/src/ui/cuigridcell.cpp @@ -71,7 +71,7 @@ void cUIGridCell::Update() { Alpha( MyParent->Alpha() ); for ( Uint32 i = 0; i < mCells.size(); i++ ) { - if ( NULL != mCells[i] && mCells[i]->IsType( UI_TYPE_CONTROL_ANIM ) ) { + if ( NULL != mCells[i] && mCells[i]->IsAnimated() ) { reinterpret_cast( mCells[i] )->Alpha( MyParent->Alpha() ); } } diff --git a/src/ui/cuilistbox.cpp b/src/ui/cuilistbox.cpp index 1ab480e52..4de8b7626 100644 --- a/src/ui/cuilistbox.cpp +++ b/src/ui/cuilistbox.cpp @@ -27,7 +27,7 @@ cUIListBox::cUIListBox( cUIListBox::CreateParams& Params ) : mVisibleFirst(0), mVisibleLast(0) { - mType |= UI_TYPE_GET( UI_TYPE_LISTBOX ); + mType = UI_TYPE_LISTBOX; if ( NULL == Params.Font && NULL != cUIThemeManager::instance()->DefaultFont() ) mFont = cUIThemeManager::instance()->DefaultFont(); diff --git a/src/ui/cuilistboxitem.cpp b/src/ui/cuilistboxitem.cpp index feed3701e..70f3e5f3b 100644 --- a/src/ui/cuilistboxitem.cpp +++ b/src/ui/cuilistboxitem.cpp @@ -7,7 +7,7 @@ namespace EE { namespace UI { cUIListBoxItem::cUIListBoxItem( const cUITextBox::CreateParams& Params ) : cUITextBox( Params ) { - mType |= UI_TYPE_GET( UI_TYPE_LISTBOXITEM ); + mType = UI_TYPE_LISTBOXITEM; ApplyDefaultTheme(); } diff --git a/src/ui/cuimenu.cpp b/src/ui/cuimenu.cpp index 963f7fe17..fc6a04841 100644 --- a/src/ui/cuimenu.cpp +++ b/src/ui/cuimenu.cpp @@ -23,7 +23,7 @@ cUIMenu::cUIMenu( cUIMenu::CreateParams& Params ) : mClickHide( false ), mLastTickMove( 0 ) { - mType |= UI_TYPE_GET( UI_TYPE_MENU ); + mType = UI_TYPE_MENU; OnSizeChange(); @@ -121,7 +121,7 @@ Uint32 cUIMenu::AddSubMenu( const String& Text, cShape * Icon, cUIMenu * SubMenu } bool cUIMenu::CheckControlSize( cUIControl * Control, const bool& Resize ) { - if ( Control->IsType( UI_TYPE_MENUITEM ) ) { + if ( Control->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) { cUIMenuItem * tItem = reinterpret_cast ( Control ); if ( NULL != tItem->Icon() && tItem->IconHorizontalMargin() + tItem->Icon()->Size().Width() > (Int32)mBiggestIcon ) { @@ -129,7 +129,7 @@ bool cUIMenu::CheckControlSize( cUIControl * Control, const bool& Resize ) { } if ( mFlags & UI_AUTO_SIZE ) { - if ( Control->IsType( UI_TYPE_MENUSUBMENU ) ) { + if ( Control->IsTypeOrInheritsFrom( UI_TYPE_MENUSUBMENU ) ) { cUIMenuSubMenu * tMenu = reinterpret_cast ( tItem ); if ( tMenu->TextBox()->GetTextWidth() + mBiggestIcon + tMenu->Arrow()->Size().Width() + mMinRightMargin > (Int32)mMaxWidth - mPadding.Left - mPadding.Right ) { @@ -179,7 +179,7 @@ Uint32 cUIMenu::Add( cUIControl * Control ) { } void cUIMenu::SetControlSize( cUIControl * Control, const Uint32& Pos ) { - if ( Control->IsType( UI_TYPE_MENUITEM ) ) { + if ( Control->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) { Control->Size( mSize.Width() - mPadding.Left - mPadding.Right, mRowHeight ); cUIMenuItem * tItem = reinterpret_cast (Control); @@ -221,7 +221,7 @@ cUIControl * cUIMenu::GetItem( const Uint32& Index ) { cUIControl * cUIMenu::GetItem( const String& Text ) { for ( Uint32 i = 0; i < mItems.size(); i++ ) { - if ( mItems[i]->IsType( UI_TYPE_MENUITEM ) ) { + if ( mItems[i]->IsTypeOrInheritsFrom( UI_TYPE_MENUITEM ) ) { cUIMenuItem * tMenuItem = reinterpret_cast( mItems[i] ); if ( tMenuItem->Text() == Text ) @@ -292,7 +292,7 @@ void cUIMenu::Insert( cUIControl * Control, const Uint32& Index ) { bool cUIMenu::IsSubMenu( cUIControl * Ctrl ) { for ( Uint32 i = 0; i < mItems.size(); i++ ) { - if ( mItems[i]->IsType( UI_TYPE_MENUSUBMENU ) ) { + if ( mItems[i]->IsTypeOrInheritsFrom( UI_TYPE_MENUSUBMENU ) ) { cUIMenuSubMenu * tMenu = reinterpret_cast ( mItems[i] ); if ( tMenu->SubMenu() == Ctrl ) @@ -404,7 +404,7 @@ bool cUIMenu::Hide() { void cUIMenu::SetItemSelected( cUIControl * Item ) { if ( NULL != mItemSelected ) { - if ( mItemSelected->IsType( UI_TYPE_MENUSUBMENU ) ) { + if ( mItemSelected->IsTypeOrInheritsFrom( UI_TYPE_MENUSUBMENU ) ) { cUIMenuSubMenu * tMenu = reinterpret_cast ( mItemSelected ); if ( NULL != tMenu->SubMenu() ) @@ -425,7 +425,7 @@ void cUIMenu::SetItemSelected( cUIControl * Item ) { void cUIMenu::TrySelect( cUIControl * Ctrl, bool Up ) { if ( mItems.size() ) { - if ( !Ctrl->IsType( UI_TYPE_SEPARATOR ) ) { + if ( !Ctrl->IsTypeOrInheritsFrom( UI_TYPE_SEPARATOR ) ) { SetItemSelected( Ctrl ); } else { Uint32 Index = GetItemIndex( Ctrl ); @@ -434,7 +434,7 @@ void cUIMenu::TrySelect( cUIControl * Ctrl, bool Up ) { if ( Up ) { if ( Index > 0 ) { for ( Uint32 i = Index - 1; i >= 0; i-- ) { - if ( !mItems[i]->IsType( UI_TYPE_SEPARATOR ) ) { + if ( !mItems[i]->IsTypeOrInheritsFrom( UI_TYPE_SEPARATOR ) ) { SetItemSelected( mItems[i] ); return; } @@ -444,7 +444,7 @@ void cUIMenu::TrySelect( cUIControl * 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]->IsTypeOrInheritsFrom( UI_TYPE_SEPARATOR ) ) { SetItemSelected( mItems[i] ); return; } @@ -499,7 +499,7 @@ Uint32 cUIMenu::OnKeyDown( const cUIEventKey& Event ) { break; case KEY_RIGHT: - if ( NULL != mItemSelected && mItemSelected->IsType( UI_TYPE_MENUSUBMENU ) ) { + if ( NULL != mItemSelected && ( mItemSelected->IsTypeOrInheritsFrom( UI_TYPE_MENUSUBMENU ) ) ) { cUIMenuSubMenu * tMenu = reinterpret_cast ( mItemSelected ); tMenu->ShowSubMenu(); diff --git a/src/ui/cuimenucheckbox.cpp b/src/ui/cuimenucheckbox.cpp index 57561fb7e..05bcc0b5e 100644 --- a/src/ui/cuimenucheckbox.cpp +++ b/src/ui/cuimenucheckbox.cpp @@ -9,7 +9,7 @@ cUIMenuCheckBox::cUIMenuCheckBox( cUIMenuCheckBox::CreateParams& Params ) : mSkinActive( NULL ), mSkinInactive( NULL ) { - mType |= UI_TYPE_GET( UI_TYPE_MENUCHECKBOX ); + mType = UI_TYPE_MENUCHECKBOX; ApplyDefaultTheme(); } @@ -90,4 +90,11 @@ void cUIMenuCheckBox::OnStateChange() { Active( mActive ); } +bool cUIMenuCheckBox::InheritsFrom( const Uint32 Type ) { + if ( Type == UI_TYPE_MENUITEM ) + return true; + + return false; +} + }} diff --git a/src/ui/cuimenucheckbox.hpp b/src/ui/cuimenucheckbox.hpp index 0542dd522..387ebd033 100644 --- a/src/ui/cuimenucheckbox.hpp +++ b/src/ui/cuimenucheckbox.hpp @@ -20,6 +20,8 @@ class cUIMenuCheckBox : public cUIMenuItem { void Active( const bool& active ); void SwitchActive(); + + virtual bool InheritsFrom( const Uint32 Type ); protected: bool mActive; cUISkin * mSkinActive; diff --git a/src/ui/cuimenuitem.cpp b/src/ui/cuimenuitem.cpp index 3bfbacc51..3bb821120 100644 --- a/src/ui/cuimenuitem.cpp +++ b/src/ui/cuimenuitem.cpp @@ -6,7 +6,7 @@ namespace EE { namespace UI { cUIMenuItem::cUIMenuItem( cUIPushButton::CreateParams& Params ) : cUIPushButton( Params ) { - mType |= UI_TYPE_GET( UI_TYPE_MENUITEM ); + mType = UI_TYPE_MENUITEM; ApplyDefaultTheme(); } diff --git a/src/ui/cuimenusubmenu.cpp b/src/ui/cuimenusubmenu.cpp index 4c9a09361..b04221186 100644 --- a/src/ui/cuimenusubmenu.cpp +++ b/src/ui/cuimenusubmenu.cpp @@ -14,7 +14,7 @@ cUIMenuSubMenu::cUIMenuSubMenu( cUIMenuSubMenu::CreateParams& Params ) : mCbId( 0 ), mCbId2( 0 ) { - mType |= UI_TYPE_GET( UI_TYPE_MENUSUBMENU ); + mType = UI_TYPE_MENUSUBMENU; cUIGfx::CreateParams GfxParams; GfxParams.Parent( this ); @@ -142,4 +142,11 @@ void cUIMenuSubMenu::OnHideByClick( const cUIEvent * Event ) { tMenu->Hide(); } +bool cUIMenuSubMenu::InheritsFrom( const Uint32 Type ) { + if ( Type == UI_TYPE_MENUITEM ) + return true; + + return false; +} + }} diff --git a/src/ui/cuimenusubmenu.hpp b/src/ui/cuimenusubmenu.hpp index 87b5783a7..3e89c5144 100644 --- a/src/ui/cuimenusubmenu.hpp +++ b/src/ui/cuimenusubmenu.hpp @@ -37,6 +37,8 @@ class cUIMenuSubMenu : public cUIMenuItem { cUIGfx * Arrow() const; void ShowSubMenu(); + + virtual bool InheritsFrom( const Uint32 Type ); protected: cUIMenu * mSubMenu; cUISkin * mSkinArrow; diff --git a/src/ui/cuipopupmenu.cpp b/src/ui/cuipopupmenu.cpp index 784ef6bb9..5dc85fb3b 100644 --- a/src/ui/cuipopupmenu.cpp +++ b/src/ui/cuipopupmenu.cpp @@ -6,7 +6,7 @@ namespace EE { namespace UI { cUIPopUpMenu::cUIPopUpMenu( cUIPopUpMenu::CreateParams Params ) : cUIMenu( Params ) { - mType |= UI_TYPE_GET(UI_TYPE_POPUPMENU); + mType = UI_TYPE_POPUPMENU; ApplyDefaultTheme(); } @@ -71,7 +71,7 @@ Uint32 cUIPopUpMenu::OnMessage( const cUIMessage * Msg ) { switch ( Msg->Msg() ) { case cUIMessage::MsgMouseUp: { - if ( !Msg->Sender()->IsType( UI_TYPE_MENUSUBMENU ) && ( Msg->Flags() & EE_BUTTONS_LRM ) ) { + if ( !Msg->Sender()->IsTypeOrInheritsFrom( UI_TYPE_MENUSUBMENU ) && ( Msg->Flags() & EE_BUTTONS_LRM ) ) { SendCommonEvent( cUIEvent::EventOnHideByClick ); cUIManager::instance()->MainControl()->SetFocus(); diff --git a/src/ui/cuiprogressbar.cpp b/src/ui/cuiprogressbar.cpp index 756a354f9..9dd9b6aa4 100644 --- a/src/ui/cuiprogressbar.cpp +++ b/src/ui/cuiprogressbar.cpp @@ -12,7 +12,7 @@ cUIProgressBar::cUIProgressBar( const cUIProgressBar::CreateParams& Params ) : mTotalSteps( 100.f ), mParallax( NULL ) { - mType |= UI_TYPE_GET(UI_TYPE_PROGRESSBAR); + mType = UI_TYPE_PROGRESSBAR; cUITextBox::CreateParams TxtBoxParams = Params; diff --git a/src/ui/cuipushbutton.cpp b/src/ui/cuipushbutton.cpp index e49cff5cd..8d1f10dcc 100644 --- a/src/ui/cuipushbutton.cpp +++ b/src/ui/cuipushbutton.cpp @@ -10,7 +10,7 @@ cUIPushButton::cUIPushButton( const cUIPushButton::CreateParams& Params ) : mTextBox( NULL ), mIconSpace( Params.IconHorizontalMargin ) { - mType |= UI_TYPE_GET(UI_TYPE_PUSHBUTTON); + mType = UI_TYPE_PUSHBUTTON; cUIGfx::CreateParams GfxParams; GfxParams.Parent( this ); diff --git a/src/ui/cuiradiobutton.cpp b/src/ui/cuiradiobutton.cpp index 385386981..d0730701b 100644 --- a/src/ui/cuiradiobutton.cpp +++ b/src/ui/cuiradiobutton.cpp @@ -8,7 +8,7 @@ cUIRadioButton::cUIRadioButton( const cUITextBox::CreateParams& Params ) : mInactiveButton(NULL), mActive( false ) { - mType |= UI_TYPE_GET(UI_TYPE_RADIOBUTTON); + mType = UI_TYPE_RADIOBUTTON; cUIControlAnim::CreateParams ButtonParams( Params ); @@ -113,7 +113,7 @@ void cUIRadioButton::Active( const bool& active ) { cUIControl * tChild = mParentCtrl->ChildGetFirst(); while ( NULL != tChild ) { - if ( tChild->IsType( UI_TYPE_RADIOBUTTON ) ) { + if ( tChild->IsType( UI_TYPE_RADIOBUTTON ) || tChild->InheritsFrom( UI_TYPE_RADIOBUTTON ) ) { if ( tChild != this ) { cUIRadioButton * tRB = reinterpret_cast ( tChild ); @@ -132,7 +132,7 @@ bool cUIRadioButton::CheckActives() { cUIControl * tChild = mParentCtrl->ChildGetFirst(); while ( NULL != tChild ) { - if ( tChild->IsType( UI_TYPE_RADIOBUTTON ) ) { + if ( tChild->IsTypeOrInheritsFrom( UI_TYPE_RADIOBUTTON ) ) { if ( tChild != this ) { cUIRadioButton * tRB = reinterpret_cast ( tChild ); @@ -155,7 +155,7 @@ void cUIRadioButton::AutoActivate() { cUIControl * tChild = mParentCtrl->ChildGetFirst(); while ( NULL != tChild ) { - if ( tChild->IsType( UI_TYPE_RADIOBUTTON ) ) { + if ( tChild->IsTypeOrInheritsFrom( UI_TYPE_RADIOBUTTON ) ) { if ( tChild != this ) { cUIRadioButton * tRB = reinterpret_cast ( tChild ); diff --git a/src/ui/cuiscrollbar.cpp b/src/ui/cuiscrollbar.cpp index 3870738fd..212a48817 100644 --- a/src/ui/cuiscrollbar.cpp +++ b/src/ui/cuiscrollbar.cpp @@ -6,7 +6,7 @@ namespace EE { namespace UI { cUIScrollBar::cUIScrollBar( const cUIScrollBar::CreateParams& Params ) : cUIComplexControl( Params ) { - mType |= UI_TYPE_GET( UI_TYPE_SCROLLBAR ); + mType = UI_TYPE_SCROLLBAR; cUIControlAnim::CreateParams CParams = Params; CParams.Size = eeSize( 16, 16 ); diff --git a/src/ui/cuiselectbutton.cpp b/src/ui/cuiselectbutton.cpp index 8f96f02bd..7dd31654c 100644 --- a/src/ui/cuiselectbutton.cpp +++ b/src/ui/cuiselectbutton.cpp @@ -6,7 +6,7 @@ namespace EE { namespace UI { cUISelectButton::cUISelectButton( const cUIPushButton::CreateParams& Params ) : cUIPushButton( Params ) { - mType |= UI_TYPE_GET(UI_TYPE_SELECTBUTTON); + mType = UI_TYPE_SELECTBUTTON; } cUISelectButton::~cUISelectButton() { diff --git a/src/ui/cuiseparator.cpp b/src/ui/cuiseparator.cpp index 5c167b144..8f26864a4 100644 --- a/src/ui/cuiseparator.cpp +++ b/src/ui/cuiseparator.cpp @@ -5,7 +5,7 @@ namespace EE { namespace UI { cUISeparator::cUISeparator( cUIControlAnim::CreateParams Params ) : cUIControlAnim( Params ) { - mType |= UI_TYPE_GET( UI_TYPE_SEPARATOR ); + mType = UI_TYPE_SEPARATOR; ApplyDefaultTheme(); } diff --git a/src/ui/cuislider.cpp b/src/ui/cuislider.cpp index 2b72777ff..678e4dd00 100644 --- a/src/ui/cuislider.cpp +++ b/src/ui/cuislider.cpp @@ -16,7 +16,7 @@ cUISlider::cUISlider( const cUISlider::CreateParams& Params ) : mClickStep( 0.1f ), mOnPosChange( false ) { - mType |= UI_TYPE_GET(UI_TYPE_SLIDER); + mType = UI_TYPE_SLIDER; cUIControl::CreateParams BgParams; BgParams.Parent( this ); diff --git a/src/ui/cuispinbox.cpp b/src/ui/cuispinbox.cpp index 5a41da5b9..a00938a06 100644 --- a/src/ui/cuispinbox.cpp +++ b/src/ui/cuispinbox.cpp @@ -9,7 +9,7 @@ cUISpinBox::cUISpinBox( const cUISpinBox::CreateParams& Params ) : mValue( Params.DefaultValue ), mClickStep( 1.f ) { - mType |= UI_TYPE_GET(UI_TYPE_SPINBOX); + mType = UI_TYPE_SPINBOX; cUITextInput::CreateParams InputParams( Params ); InputParams.PosSet( 0, 0 ); diff --git a/src/ui/cuisprite.cpp b/src/ui/cuisprite.cpp index 50bc7207c..e54137886 100644 --- a/src/ui/cuisprite.cpp +++ b/src/ui/cuisprite.cpp @@ -9,7 +9,7 @@ cUISprite::cUISprite( const cUISprite::CreateParams& Params ) : mAlignOffset(0,0), mShapeLast(NULL) { - mType |= UI_TYPE_GET(UI_TYPE_SPRITE); + mType = UI_TYPE_SPRITE; if ( ( Flags() & UI_AUTO_SIZE ) || ( Params.Size.x == -1 && Params.Size.y == -1 ) ) { if ( NULL != mSprite && NULL != mSprite->GetCurrentShape() ) { @@ -34,7 +34,7 @@ void cUISprite::Draw() { if ( NULL != mSprite && 0.f != mAlpha ) { CheckShapeUpdate(); mSprite->Position( (eeFloat)( mScreenPos.x + mAlignOffset.x ), (eeFloat)( mScreenPos.y + mAlignOffset.y ) ); - mSprite->Draw( mBlend, mRender ); + mSprite->Draw( Blend(), mRender ); } } } diff --git a/src/ui/cuitextbox.cpp b/src/ui/cuitextbox.cpp index 184935043..652986883 100644 --- a/src/ui/cuitextbox.cpp +++ b/src/ui/cuitextbox.cpp @@ -10,7 +10,7 @@ cUITextBox::cUITextBox( const cUITextBox::CreateParams& Params ) : mFontShadowColor( Params.FontShadowColor ), mAlignOffset( 0.f, 0.f ) { - mType |= UI_TYPE_GET(UI_TYPE_TEXTBOX); + mType = UI_TYPE_TEXTBOX; mTextCache = eeNew( cTextCache, () ); mTextCache->Font( Params.Font ); @@ -45,7 +45,7 @@ void cUITextBox::Draw() { ); } - mTextCache->Draw( (eeFloat)mScreenPos.x + mAlignOffset.x + (eeFloat)mPadding.Left, (eeFloat)mScreenPos.y + mAlignOffset.y + (eeFloat)mPadding.Top, Flags(), 1.f, 0.f, mBlend ); + mTextCache->Draw( (eeFloat)mScreenPos.x + mAlignOffset.x + (eeFloat)mPadding.Left, (eeFloat)mScreenPos.y + mAlignOffset.y + (eeFloat)mPadding.Top, Flags(), 1.f, 0.f, Blend() ); if ( mFlags & UI_CLIP_ENABLE ) { cUIManager::instance()->ClipDisable(); diff --git a/src/ui/cuitextedit.cpp b/src/ui/cuitextedit.cpp index ee57ebdd2..4ae7220be 100644 --- a/src/ui/cuitextedit.cpp +++ b/src/ui/cuitextedit.cpp @@ -12,7 +12,7 @@ cUITextEdit::cUITextEdit( cUITextEdit::CreateParams& Params ) : mVScrollBarMode( Params.VScrollBar ), mSkipValueChange( false ) { - mType |= UI_TYPE_GET( UI_TYPE_TEXTEDIT ); + mType = UI_TYPE_TEXTEDIT; Uint32 extraFlags = 0; diff --git a/src/ui/cuitextinput.cpp b/src/ui/cuitextinput.cpp index 9dc9e34b6..ea5e9af7d 100644 --- a/src/ui/cuitextinput.cpp +++ b/src/ui/cuitextinput.cpp @@ -10,7 +10,7 @@ cUITextInput::cUITextInput( const cUITextInput::CreateParams& Params ) : mAllowEditing( true ), mShowingWait( true ) { - mType |= UI_TYPE_GET(UI_TYPE_TEXTINPUT); + mType = UI_TYPE_TEXTINPUT; mTextBuffer.Start(); mTextBuffer.Active( false ); diff --git a/src/ui/cuitooltip.cpp b/src/ui/cuitooltip.cpp index 1862aa419..def94124e 100644 --- a/src/ui/cuitooltip.cpp +++ b/src/ui/cuitooltip.cpp @@ -37,7 +37,7 @@ cUITooltip::cUITooltip( cUITooltip::CreateParams& Params, cUIControl * TooltipOf cUITooltip::~cUITooltip() { eeSAFE_DELETE( mTextCache ); - if ( NULL != mTooltipOf && mTooltipOf->IsType( UI_TYPE_CONTROL_COMPLEX ) ) { + if ( NULL != mTooltipOf && mTooltipOf->IsComplex() ) { reinterpret_cast( mTooltipOf )->TooltipRemove(); } } @@ -59,7 +59,7 @@ void cUITooltip::AutoPadding() { } void cUITooltip::Show() { - if ( !Visible() ) { + if ( !Visible() || 0 == mAlpha ) { ToFront(); Visible( true ); @@ -88,7 +88,7 @@ void cUITooltip::Draw() { cUIControlAnim::Draw(); if ( mTextCache->GetTextWidth() ) { - mTextCache->Draw( (eeFloat)mScreenPos.x + mAlignOffset.x, (eeFloat)mScreenPos.y + mAlignOffset.y, Flags(), 1.f, 0.f, mBlend ); + mTextCache->Draw( (eeFloat)mScreenPos.x + mAlignOffset.x, (eeFloat)mScreenPos.y + mAlignOffset.y, Flags(), 1.f, 0.f, Blend() ); } } } diff --git a/src/ui/cuiwindow.cpp b/src/ui/cuiwindow.cpp index 65f70eb30..9f99eab13 100644 --- a/src/ui/cuiwindow.cpp +++ b/src/ui/cuiwindow.cpp @@ -23,7 +23,7 @@ cUIWindow::cUIWindow( const cUIWindow::CreateParams& Params ) : mDecoAutoSize( Params.DecorationAutoSize ), mBorderAutoSize( Params.BorderAutoSize ) { - mType |= UI_TYPE_GET( UI_TYPE_WINDOW ); + mType = UI_TYPE_WINDOW; cUIControlAnim::CreateParams tParams; tParams.Parent( this ); diff --git a/src/ui/cuiwinmenu.cpp b/src/ui/cuiwinmenu.cpp index 7c487dec1..644fe6cd2 100644 --- a/src/ui/cuiwinmenu.cpp +++ b/src/ui/cuiwinmenu.cpp @@ -16,7 +16,7 @@ cUIWinMenu::cUIWinMenu( const cUIWinMenu::CreateParams& Params ) : mFirstButtonMargin( Params.FirstButtonMargin ), mMenuHeight( Params.MenuHeight ) { - mType |= UI_TYPE_GET(UI_TYPE_WINMENU); + mType = UI_TYPE_WINMENU; if ( !(mFlags & UI_ANCHOR_RIGHT) ) mFlags |= UI_ANCHOR_RIGHT; @@ -162,7 +162,7 @@ Uint32 cUIWinMenu::OnMessage( const cUIMessage * Msg ) { case cUIMessage::MsgMouseUp: case cUIMessage::MsgMouseEnter: { - if ( Msg->Sender()->IsType( UI_TYPE_SELECTBUTTON ) ) { + if ( Msg->Sender()->IsTypeOrInheritsFrom( UI_TYPE_SELECTBUTTON ) ) { cUISelectButton * tbut = reinterpret_cast ( Msg->Sender() ); cUIPopUpMenu * tpop = GetMenuFromButton( tbut ); diff --git a/src/ui/tuiitemcontainer.hpp b/src/ui/tuiitemcontainer.hpp index a7f72b314..23fe1e5d8 100644 --- a/src/ui/tuiitemcontainer.hpp +++ b/src/ui/tuiitemcontainer.hpp @@ -60,7 +60,7 @@ cUIControl * tUIItemContainer::OverFind( const eeVector2f& Point ) { cUIControl * pOver = NULL; - if ( mVisible && mEnabled && LBParent->mItems.size() ) { + if ( mEnabled && mVisible && LBParent->mItems.size() ) { UpdateQuad(); if ( PointInsidePolygon2( mPoly, Point ) ) { diff --git a/src/ui/uihelper.hpp b/src/ui/uihelper.hpp index 163972bf5..97cc8f0c4 100644 --- a/src/ui/uihelper.hpp +++ b/src/ui/uihelper.hpp @@ -11,15 +11,17 @@ Uint32 EE_API VAlignGet( Uint32 Flags ); enum UI_CONTROL_FLAGS_POS { UI_CTRL_FLAG_CLOSE_POS = 0, - UI_CTRL_FLAG_CLOSE_FO_POS = 1, - UI_CTRL_FLAG_ANIM_POS = 2, - UI_CTRL_FLAG_MOUSEOVER_POS = 3, - UI_CTRL_FLAG_HAS_FOCUS_POS = 4, - UI_CTRL_FLAG_SELECTED_POS = 5, - UI_CTRL_FLAG_DISABLE_CHECK_CLOSE_CHILDS_POS = 6, - UI_CTRL_FLAG_DISABLE_FADE_OUT_POS = 7, - UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD_POS = 8, - UI_CTRL_FLAG_DRAGGING_POS = 9, + UI_CTRL_FLAG_CLOSE_FO_POS, + UI_CTRL_FLAG_ANIM_POS, + UI_CTRL_FLAG_MOUSEOVER_POS, + UI_CTRL_FLAG_HAS_FOCUS_POS, + UI_CTRL_FLAG_SELECTED_POS, + UI_CTRL_FLAG_DISABLE_CHECK_CLOSE_CHILDS_POS, + UI_CTRL_FLAG_DISABLE_FADE_OUT_POS, + UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD_POS, + UI_CTRL_FLAG_DRAGGING_POS, + UI_CTRL_FLAG_DRAGABLE_POS, + UI_CTRL_FLAG_COMPLEX_POS, UI_CTRL_FLAG_FREE_USE_POS = 31 }; @@ -34,6 +36,8 @@ enum UI_CONTROL_FLAGS_VALUES { UI_CTRL_FLAG_DISABLE_FADE_OUT = (1< OnPathEndCallback; + typedef cb::Callback0 OnStepCallback; + /** Add a new point */ void AddWaypoint( const eeFloat Pos, const eeFloat Time = 0 ); @@ -35,11 +37,17 @@ class EE_API cInterpolation { bool EraseWaypoint( const eeUint PointNum ); /** Start the animation */ - void Start( OnPathEndCallback PathEndCallback = OnPathEndCallback() ); + void Start( OnPathEndCallback PathEndCallback = OnPathEndCallback(), OnStepCallback StepCallback = OnStepCallback() ); /** Stop the animation */ void Stop(); + /** Sets a path end callback */ + void SetPathEndCallback( OnPathEndCallback PathEndCallback ); + + /** Sets a step callback */ + void SetStepCallback( OnStepCallback StepCallback ); + /** Update the movement interpolation */ void Update( const eeFloat& Elapsed ); @@ -118,6 +126,8 @@ class EE_API cInterpolation { cPoint1df* mNexP; OnPathEndCallback mOnPathEndCallback; + + OnStepCallback mOnStepCallback; }; }} diff --git a/src/utils/cwaypoints.cpp b/src/utils/cwaypoints.cpp index d10a41318..814eef747 100755 --- a/src/utils/cwaypoints.cpp +++ b/src/utils/cwaypoints.cpp @@ -14,15 +14,18 @@ cWaypoints::cWaypoints() : mCurPoint(0), mCurTime(0.0f), mSpeed(1.3f), - mOnPathEndCallback(NULL) { + mOnPathEndCallback(NULL), + mOnStepCallback(NULL) +{ } cWaypoints::~cWaypoints() { } -void cWaypoints::Start( OnPathEndCallback PathEndCallback ) { - mEnable = true; - mOnPathEndCallback = PathEndCallback; +void cWaypoints::Start( OnPathEndCallback PathEndCallback, OnStepCallback StepCallback ) { + mEnable = true; + mOnPathEndCallback = PathEndCallback; + mOnStepCallback = StepCallback; if ( mPoints.size() ) { mActP = &mPoints[ 0 ]; @@ -40,6 +43,14 @@ void cWaypoints::Stop() { mEnable = false; } +void cWaypoints::SetPathEndCallback( OnPathEndCallback PathEndCallback ) { + mOnPathEndCallback = PathEndCallback; +} + +void cWaypoints::SetStepCallback( OnStepCallback StepCallback ) { + mOnStepCallback = StepCallback; +} + void cWaypoints::Reset() { mTotDist = 0.f; mEnable = false; @@ -135,9 +146,15 @@ void cWaypoints::Update( const eeFloat& Elapsed ) { mCurTime = 0; mActP = &mPoints[ mCurPoint ]; - if ( mCurPoint + 1 < mPoints.size() ) + if ( mCurPoint + 1 < mPoints.size() ) { mNexP = &mPoints[ mCurPoint + 1 ]; - else { + + if ( mOnStepCallback.IsSet() ) + mOnStepCallback(); + } else { + if ( mOnStepCallback.IsSet() ) + mOnStepCallback(); + if ( mLoop ) { mNexP = &mPoints[ 0 ]; diff --git a/src/utils/cwaypoints.hpp b/src/utils/cwaypoints.hpp index b0e8111f4..07f259a70 100755 --- a/src/utils/cwaypoints.hpp +++ b/src/utils/cwaypoints.hpp @@ -25,6 +25,8 @@ class EE_API cWaypoints { typedef cb::Callback0 OnPathEndCallback; + typedef cb::Callback0 OnStepCallback; + /** Add a new waypoint */ void AddWaypoint( const eeVector2f& Pos, const eeFloat& Time = 0.f ); @@ -37,11 +39,17 @@ class EE_API cWaypoints { /** Start the animation ( will reset the current state, and start from the beginning ) @param PathEndCallback An optional callback fired when the animation ends. */ - void Start( OnPathEndCallback PathEndCallback = OnPathEndCallback() ); + void Start( OnPathEndCallback PathEndCallback = OnPathEndCallback(), OnStepCallback StepCallback = OnStepCallback() ); /** Stop the animation ( Enable = false ) */ void Stop(); + /** Sets a path end callback */ + void SetPathEndCallback( OnPathEndCallback PathEndCallback ); + + /** Sets a step callback */ + void SetStepCallback( OnStepCallback StepCallback ); + /** Update the movement interpolation */ void Update( const eeFloat& Elapsed ); @@ -113,6 +121,8 @@ class EE_API cWaypoints { std::vector mPoints; OnPathEndCallback mOnPathEndCallback; + + OnStepCallback mOnStepCallback; }; }}