From ae8c75d97d3cfa1bb7d49d81d535249e00f3c83a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Mon, 21 Jan 2013 03:17:45 -0300 Subject: [PATCH] Added OnDrag event to be able to intercept the drag event. Added dragging the map in the map editor with the mouse middle press. --- include/eepp/ui/cuidragable.hpp | 2 ++ projects/linux/ee.creator.user | 2 +- src/eepp/gaming/mapeditor/cuimap.cpp | 21 +++++++++++++++++++++ src/eepp/gaming/mapeditor/cuimap.hpp | 2 ++ src/eepp/ui/cuidefaulttheme.cpp | 2 +- src/eepp/ui/cuidragable.cpp | 12 +++++++++--- 6 files changed, 36 insertions(+), 5 deletions(-) diff --git a/include/eepp/ui/cuidragable.hpp b/include/eepp/ui/cuidragable.hpp index 556e5be37..da3263d5c 100644 --- a/include/eepp/ui/cuidragable.hpp +++ b/include/eepp/ui/cuidragable.hpp @@ -35,6 +35,8 @@ class EE_API cUIDragable : public cUIControl { virtual Uint32 OnMouseDown( const eeVector2i& Pos, const Uint32 Flags ); virtual Uint32 OnMouseUp( const eeVector2i& Pos, const Uint32 Flags ); + + virtual Uint32 OnDrag( const eeVector2i& Pos ); }; }} diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 709eb17b9..b438b58e8 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/src/eepp/gaming/mapeditor/cuimap.cpp b/src/eepp/gaming/mapeditor/cuimap.cpp index c5835477f..49ac0ebef 100644 --- a/src/eepp/gaming/mapeditor/cuimap.cpp +++ b/src/eepp/gaming/mapeditor/cuimap.cpp @@ -34,6 +34,9 @@ cUIMap::cUIMap( const cUIComplexControl::CreateParams& Params, cUITheme * Theme, mMap->SetDrawCallback( cb::Make0( this, &cUIMap::MapDraw ) ); + mDragButton = EE_BUTTON_MMASK; + DragEnable( true ); + UpdateScreenPos(); } @@ -41,6 +44,24 @@ cUIMap::~cUIMap() { eeSAFE_DELETE( mMap ); } +Uint32 cUIMap::OnDrag( const eeVector2i& Pos ) { + + if ( ( EDITING_OBJECT == mEditingMode && NULL != mSelObj ) || + ( EDITING_LIGHT == mEditingMode && NULL != mSelLight ) ) { + mDragPoint = Pos; + return 0; + } + + eeVector2i nPos( -( mDragPoint - Pos ) ); + eeVector2f nPosf( nPos.x, nPos.y ); + + mMap->Move( nPosf ); + + mDragPoint = Pos; + + return 0; +} + void cUIMap::ReplaceMap( cMap * newMap ) { eeSAFE_DELETE( mMap ); mMap = newMap; diff --git a/src/eepp/gaming/mapeditor/cuimap.hpp b/src/eepp/gaming/mapeditor/cuimap.hpp index e59d371a5..002e721d6 100644 --- a/src/eepp/gaming/mapeditor/cuimap.hpp +++ b/src/eepp/gaming/mapeditor/cuimap.hpp @@ -135,6 +135,8 @@ class EE_API cUIMap : public cUIComplexControl { virtual void OnAlphaChange(); + virtual Uint32 OnDrag( const eeVector2i& Pos ); + void ObjItemClick( const cUIEvent * Event ); void MapDraw(); diff --git a/src/eepp/ui/cuidefaulttheme.cpp b/src/eepp/ui/cuidefaulttheme.cpp index 9d4cfa92e..4cb9cd328 100644 --- a/src/eepp/ui/cuidefaulttheme.cpp +++ b/src/eepp/ui/cuidefaulttheme.cpp @@ -143,7 +143,7 @@ cUIMessageBox * cUIDefaultTheme::CreateMessageBox( UI_MSGBOX_TYPE Type, const St MsgBoxParams.Flags |= UI_DRAW_SHADOW; MsgBoxParams.WinFlags |= UI_WIN_DRAW_SHADOW; MsgBoxParams.ButtonsPositionFixer.x = -2; - MsgBoxParams.TitleFontColor = eeColorA( 0, 0, 0, 255 ); + MsgBoxParams.TitleFontColor = eeColorA( 230, 230, 230, 255 ); } return eeNew( cUIMessageBox, ( MsgBoxParams ) ); diff --git a/src/eepp/ui/cuidragable.cpp b/src/eepp/ui/cuidragable.cpp index ee55009a3..49ad8580f 100644 --- a/src/eepp/ui/cuidragable.cpp +++ b/src/eepp/ui/cuidragable.cpp @@ -64,15 +64,21 @@ void cUIDragable::Update() { eeVector2i Pos( cUIManager::instance()->GetMousePos() ); if ( mDragPoint != Pos ) { - mPos += -( mDragPoint - Pos ); + if ( OnDrag( Pos ) ) { + mPos += -( mDragPoint - Pos ); - mDragPoint = Pos; + mDragPoint = Pos; - OnPosChange(); + OnPosChange(); + } } } } +Uint32 cUIDragable::OnDrag( const eeVector2i& Pos ) { + return 1; +} + bool cUIDragable::DragEnable() const { return 0 != ( mFlags & UI_DRAG_ENABLE ); }