diff --git a/Makefile b/Makefile index 520a089a9..569b6e20c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,3 @@ -export DEBUGBUILD = yes -export STATIC = yes - ifeq ($(DEBUGBUILD), yes) DEBUGFLAGS = -g -DDEBUG else diff --git a/ee.linux.cbp b/ee.linux.cbp index 9673421de..13b42b57c 100644 --- a/ee.linux.cbp +++ b/ee.linux.cbp @@ -175,6 +175,10 @@ + + + + @@ -185,6 +189,8 @@ + + diff --git a/src/audio/csound.hpp b/src/audio/csound.hpp index d2fb9b0ae..5bb8b4422 100755 --- a/src/audio/csound.hpp +++ b/src/audio/csound.hpp @@ -8,106 +8,106 @@ namespace EE { namespace Audio { /** @enum EE_SOUND_STATE The state of the sound */ -typedef enum { +enum EE_SOUND_STATE { SOUND_STOPPED, SOUND_PAUSED, SOUND_PLAYING -} EE_SOUND_STATE; +}; class EE_API cSound : public cAudioResource { public : cSound(); ~cSound(); - + /** Construct the sound from its parameters */ cSound( const cSoundBuffer& Buffer, const bool& Loop = false, const eeFloat& Pitch = 1.f, const eeFloat& Volume = 100.f, const Vector3AL& Position = Vector3AL(0, 0, 0) ); - + /** Copy constructor */ cSound(const cSound& Copy); - + /** Play the Sound */ void Play(); - + /** Pause the Sound */ void Pause(); - + /** Stop the Sound */ void Stop(); - + /** Set the Sound Source Buffer */ void Buffer( const cSoundBuffer& Buffer ); - + /** Set the Sound Loop State */ void Loop( const bool& Loop ); - + /** Set the Sound Pitch */ void Pitch( const eeFloat& Pitch ); - + /** Set the Sound Volume */ void Volume( const eeFloat& Volume ); - + /** Set the Sound Position. The default position is (0, 0, 0) */ void Position( const eeFloat& X, const eeFloat& Y, const eeFloat& Z ); - + /** Set the Sound Position from a 3D Vector. The default position is (0, 0, 0) */ void Position( const Vector3AL& Position ); - + /** Set the minimum distance - closer than this distance, \n the listener will hear the sound at its maximum volume. \n The default minimum distance is 1.0. */ void MinDistance( const eeFloat& MinDistance ); - + /** Set the attenuation factor. \n The higher the attenuation, the more the sound will be attenuated with distance from listener. \n The default attenuation factor 1.0. */ void Attenuation( const eeFloat& Attenuation ); - + /** Get the Sound Source Buffer */ const cSoundBuffer* Buffer() const; - + /** Get the Sound Loop State */ bool Loop() const; - + /** Get the Sound Pitch */ eeFloat Pitch() const; - + /** Get the Sound Volume */ eeFloat Volume() const; - + /** Get the Sound Position */ Vector3AL Position() const; - + /** Get the Minimun Distance */ eeFloat MinDistance() const; - + /** Get the Sound Attenuation */ eeFloat Attenuation() const; - + /** Get the Sound State */ EE_SOUND_STATE GetState() const; - + /** Get the Sound State */ EE_SOUND_STATE State() const { return GetState(); }; - + /** Get the current playing position of the sound */ virtual eeFloat PlayingOffset() const; - + /** Set the current playing position of the sound * @param TimeOffset : New playing position, expressed in seconds */ virtual void PlayingOffset( const eeFloat& TimeOffset ); - + /** Assignment operator */ cSound& operator =(const cSound& Other); - + /** Make the sound's position relative to the listener's position, or absolute. The default value is false (absolute) * @param Relative : True to set the position relative, false to set it absolute */ void SetRelativeToListener( const bool& Relative ); - + /** Tell if the sound's position is relative to the listener's position, or if it's absolute * @return True if the position is relative, false if it's absolute */ bool IsRelativeToListener() const; private : friend class cSoundStream; - + unsigned int mySource; ///< OpenAL source identifier const cSoundBuffer* myBuffer; ///< Sound buffer bound to the source }; diff --git a/src/ee.h b/src/ee.h index b083c7272..7395f2367 100755 --- a/src/ee.h +++ b/src/ee.h @@ -35,11 +35,11 @@ #include "utils/easing.hpp" using namespace EE::Utils; using namespace EE::Utils::easing; - + // Math #include "math/math.hpp" using namespace EE::Math; - + // System #include "system/singleton.hpp" #include "system/cthread.hpp" @@ -67,13 +67,13 @@ #include "audio/cmusic.hpp" #include "audio/tsoundmanager.hpp" using namespace EE::Audio; - + // Window #include "window/cinput.hpp" #include "window/cinputtextbuffer.hpp" #include "window/cview.hpp" #include "window/cengine.hpp" - + // Graphics #include "graphics/renders.hpp" #include "graphics/ctexture.hpp" @@ -93,7 +93,7 @@ #include "graphics/cglobalbatchrenderer.hpp" #include "graphics/ctextcache.hpp" #include "graphics/pixelperfect.hpp" - + #ifdef EE_SHADERS #include "graphics/cshader.hpp" #include "graphics/cshaderprogram.hpp" @@ -107,6 +107,12 @@ using namespace EE::Gaming; // UI + #include "ui/cuibackground.hpp" + #include "ui/cuiborder.hpp" + #include "ui/cuievent.hpp" + #include "ui/cuieventkey.hpp" + #include "ui/cuieventmouse.hpp" + #include "ui/cuimessage.hpp" #include "ui/cuicontrol.hpp" #include "ui/cuidragable.hpp" #include "ui/cuicontrolanim.hpp" diff --git a/src/gaming/clight.hpp b/src/gaming/clight.hpp index adfa819ca..cc5748c77 100644 --- a/src/gaming/clight.hpp +++ b/src/gaming/clight.hpp @@ -6,10 +6,10 @@ namespace EE { namespace Gaming { /** @enum LIGHT_TYPE Define the light spot type */ -typedef enum { +enum LIGHT_TYPE { LIGHT_NORMAL = 0, LIGHT_ISOMETRIC = 1 -} LIGHT_TYPE; +}; class EE_API cLight { public: diff --git a/src/graphics/cparticlesystem.hpp b/src/graphics/cparticlesystem.hpp index 99f5e201f..eebec7824 100755 --- a/src/graphics/cparticlesystem.hpp +++ b/src/graphics/cparticlesystem.hpp @@ -11,7 +11,7 @@ using namespace EE::Window; namespace EE { namespace Graphics { /** @enum EE_PARTICLE_EFFECT Predefined effects for the particle system. Use Callback when wan't to create a new effect, o set the parameters using NoFx, but it's much more limited. */ -typedef enum { +enum EE_PARTICLE_EFFECT { Nofx = 0, //!< User defined effect BlueBall = 1, Fire = 2, @@ -32,13 +32,13 @@ typedef enum { BT = 17, Atomic = 18, Callback = 19 //!< Callback defined effect. Set the callback before creating the effect. -} EE_PARTICLE_EFFECT; +}; /** @brief Basic but powerfull Particle System */ class EE_API cParticleSystem { public: typedef boost::function2 ParticleCallback; - + cParticleSystem(); ~cParticleSystem(); @@ -65,7 +65,7 @@ class EE_API cParticleSystem { /** Draw the particles effect */ void Draw(); - /** Update the particles effect + /** Update the particles effect * @param Time The time transcurred between the last update. If -1 will take the cEngine::Elapsed() */ void Update( const eeFloat& Time = -99999.f ); @@ -126,20 +126,20 @@ class EE_API cParticleSystem { private: cEngine* EE; cTextureFactory* TF; - + std::vector mParticle; EE_PARTICLE_EFFECT mEffect; eeColorAf mColor; - + Uint32 mTexId, mPCount, mPLeft, mLoops; int mProgression, mDirection; bool mLoop, mUsed, mPointsSup; - + eeFloat mX, mY, mXAcc, mYAcc, mXSpeed, mYSpeed, mAlphaDecay, mSize, mHSize, mTime, mX2, mY2; - + void Begin(); void Reset( cParticle* P ); - + bool mIsCallback; ParticleCallback mPC; }; diff --git a/src/graphics/renders.hpp b/src/graphics/renders.hpp index 85d5d9364..51d61608e 100755 --- a/src/graphics/renders.hpp +++ b/src/graphics/renders.hpp @@ -4,63 +4,63 @@ namespace EE { namespace Graphics { /** @enum EE_FILLMODE Defines the fill mode for the primitives. */ -typedef enum { +enum EE_FILLMODE { DRAW_LINE, //!< Draw only lines DRAW_FILL //!< Draw filled objects -} EE_FILLMODE; +}; /** @enum EE_TEX_FILTER Defines the texture filter used. */ -typedef enum { +enum EE_TEX_FILTER { TEX_LINEAR, //!< Linear filtering (Smoothed Zoom) TEX_NEAREST //!< No filtering (Pixeled Zoom) -} EE_TEX_FILTER; +}; /** @enum EE_RENDERALPHAS Defines the Blend Function to use */ -typedef enum { +enum EE_RENDERALPHAS { ALPHA_NONE, //!< Disable the GL_BLEND ALPHA_NORMAL, //!< glBlendFunc(GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA); ALPHA_BLENDONE, //!< glBlendFunc(GL_SRC_ALPHA , GL_ONE); ALPHA_BLENDTWO, //!< glBlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA); \n glBlendFunc(GL_DST_ALPHA , GL_ONE); ALPHA_BLENDTHREE, //!< glBlendFunc(GL_SRC_ALPHA , GL_ONE); \n glBlendFunc(GL_DST_ALPHA , GL_SRC_ALPHA); - ALPHA_ALPHACHANNELS, //!< glBlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA); + ALPHA_ALPHACHANNELS, //!< glBlendFunc(GL_SRC_ALPHA , GL_SRC_ALPHA); ALPHA_DESTALPHA, //!< glBlendFunc(GL_SRC_ALPHA , GL_DST_ALPHA); ALPHA_MULTIPLY //!< glBlendFunc(GL_DST_COLOR,GL_ZERO); -} EE_RENDERALPHAS; +}; /** @enum EE_RENDERTYPE Defines the method to use to render a texture. */ -typedef enum { +enum EE_RENDERTYPE { RN_NORMAL = 0, //!< Render the texture without any change RN_MIRROR = 1, //!< Render the texture mirrored RN_FLIP = 2, //!< Render the texture fliped RN_FLIPMIRROR = 3, //!< Render the texture fliped and mirrored - RN_ISOMETRIC = 4, //!< Render the texture as an isometric tile + RN_ISOMETRIC = 4, //!< Render the texture as an isometric tile RN_ISOMETRICVERTICAL = 5, //!< Render the texture as an isometric vertical tile RN_ISOMETRICVERTICALNEGATIVE = 6 //!< Render the texture as an isometric vectical tile mirrored -} EE_RENDERTYPE; +}; /** @enum EE_SAVEFORMAT Defines the format to save a texture. */ -typedef enum { +enum EE_SAVETYPE { EE_SAVE_TYPE_TGA = 0, EE_SAVE_TYPE_BMP = 1, EE_SAVE_TYPE_DDS = 2 -} EE_SAVETYPE; +}; /** @enum EE_TTF_FONTSTYLE Set the TTF Font style. */ -typedef enum { +enum EE_TTF_FONTSTYLE { EE_TTF_STYLE_NORMAL = 0, EE_TTF_STYLE_BOLD = 1, EE_TTF_STYLE_ITALIC = 2, EE_TTF_STYLE_UNDERLINE = 4 -} EE_TTF_FONTSTYLE; +}; /** @enum EE_CLAMP_MODE Set the clamp mode of the texture. */ -typedef enum { +enum EE_CLAMP_MODE { EE_CLAMP_TO_EDGE, EE_CLAMP_REPEAT -} EE_CLAMP_MODE; +}; /** @enum EE_BATCH_RENDERER_METHOD The batch renderer, rendering methods */ -typedef enum { +enum EE_BATCH_RENDER_METHOD { EE_GL_POINTS = 0x0000, EE_GL_LINES = 0x0001, EE_GL_LINE_LOOP = 0x0002, @@ -71,7 +71,7 @@ typedef enum { EE_GL_QUADS = 0x0007, EE_GL_QUAD_STRIP = 0x0008, EE_GL_POLYGON = 0x0009 -} EE_BATCH_RENDER_METHOD; +}; } diff --git a/src/test/ee.cpp b/src/test/ee.cpp index efa2b9e34..345bf6a77 100644 --- a/src/test/ee.cpp +++ b/src/test/ee.cpp @@ -12,8 +12,9 @@ class cUITest : public cUIControlAnim { public: cUITest( cUIControlAnim::CreateParams& Params ) : cUIControlAnim( Params ) { mOldColor = mBackground.Color(); } + virtual Uint32 OnMouseEnter( const eeVector2i& Pos, const Uint32 Flags ) { mBackground.Color( eeColorA( mOldColor.R(), mOldColor.G(), mOldColor.B(), 200 ) ); return 1; } - virtual Uint32 OnMouseExit( const eeVector2i& Pos, const Uint32 Flags ) { mBackground.Color( mOldColor ); return 1; } + virtual Uint32 OnMouseExit( const eeVector2i& Pos, const Uint32 Flags ) { mBackground.Color( mOldColor ); return 1; } virtual Uint32 OnMouseUp( const eeVector2i& Pos, const Uint32 Flags ) { cUIDragable::OnMouseUp( Pos, Flags ); @@ -25,15 +26,8 @@ class cUITest : public cUIControlAnim { return 1; } - protected: - eeColorA mOldColor; -}; -class cUITest2 : public cUIControl { - public: - cUITest2( cUIControl::CreateParams& Params ) : cUIControl( Params ) { mOldColor = mBackground.Color(); } - virtual Uint32 OnMouseEnter( const eeVector2i& Pos, const Uint32 Flags ) { mBackground.Color( eeColorA( mOldColor.R(), mOldColor.G(), mOldColor.B(), 200 ) ); return 1; } - virtual Uint32 OnMouseExit( const eeVector2i& Pos, const Uint32 Flags ) { mBackground.Color( mOldColor ); return 1; } + const eeColorA& OldColor() { return mOldColor; } protected: eeColorA mOldColor; }; @@ -148,6 +142,7 @@ class cEETest : private cThread { std::wstring mBuda; }; + void cEETest::Init() { EE = cEngine::instance(); @@ -926,12 +921,6 @@ void cEETest::End() { MySong.clear(); cLog::instance()->Save(); - - #ifdef EE_SHADERS - if ( mShaderProgram != NULL ) - delete mShaderProgram; - #endif - cEngine::DestroySingleton(); cUIManager::DestroySingleton(); } diff --git a/src/ui/cuibackground.cpp b/src/ui/cuibackground.cpp new file mode 100644 index 000000000..462edaf54 --- /dev/null +++ b/src/ui/cuibackground.cpp @@ -0,0 +1,33 @@ +#include "cuibackground.hpp" + +namespace EE { namespace UI { + +cUIBackground::cUIBackground() : + mColor( 0xFF404040 ), + mBlendMode( ALPHA_NORMAL ) +{ +} + +cUIBackground::cUIBackground( const cUIBackground& Back ) : + mColor( Back.Color() ), + mBlendMode( ALPHA_NORMAL ) +{ +} + +const eeColorA& cUIBackground::Color() const { + return mColor; +} + +void cUIBackground::Color( const eeColorA& Col ) { + mColor = Col; +} + +const EE_RENDERALPHAS& cUIBackground::Blend() const { + return mBlendMode; +} + +void cUIBackground::Blend( const EE_RENDERALPHAS& blend ) { + mBlendMode = blend; +} + +}} diff --git a/src/ui/cuibackground.hpp b/src/ui/cuibackground.hpp new file mode 100644 index 000000000..71fe1443f --- /dev/null +++ b/src/ui/cuibackground.hpp @@ -0,0 +1,25 @@ +#ifndef EE_UICUIBACKGROUND_HPP +#define EE_UICUIBACKGROUND_HPP + +#include "base.hpp" + +namespace EE { namespace UI { + +class cUIBackground { + public: + cUIBackground(); + cUIBackground( const cUIBackground& Back ); + + const eeColorA& Color() const; + void Color( const eeColorA& Col ); + + const EE_RENDERALPHAS& Blend() const; + void Blend( const EE_RENDERALPHAS& blend ); + protected: + eeColorA mColor; + EE_RENDERALPHAS mBlendMode; +}; + +}} + +#endif diff --git a/src/ui/cuiborder.cpp b/src/ui/cuiborder.cpp new file mode 100644 index 000000000..356ce0df8 --- /dev/null +++ b/src/ui/cuiborder.cpp @@ -0,0 +1,24 @@ +#include "cuiborder.hpp" + +namespace EE { namespace UI { + +cUIBorder::cUIBorder() : mColor( 0xFF404040 ), mWidth( 1 ) {} +cUIBorder::cUIBorder( const cUIBorder& border ) : mColor( border.Color() ), mWidth( border.Width() ) {} + +const eeColorA& cUIBorder::Color() const { + return mColor; +} + +void cUIBorder::Color( const eeColorA& Col ) { + mColor = Col; +} + +const eeUint& cUIBorder::Width() const { + return mWidth; +} + +void cUIBorder::Width( const eeUint& width ) { + mWidth = width; +} + +}} \ No newline at end of file diff --git a/src/ui/cuiborder.hpp b/src/ui/cuiborder.hpp new file mode 100644 index 000000000..477725f16 --- /dev/null +++ b/src/ui/cuiborder.hpp @@ -0,0 +1,25 @@ +#ifndef EE_UICUIBORDER_HPP +#define EE_UICUIBORDER_HPP + +#include "base.hpp" + +namespace EE { namespace UI { + +class cUIBorder { + public: + cUIBorder(); + cUIBorder( const cUIBorder& border ); + + const eeColorA& Color() const; + void Color( const eeColorA& Col ); + + const eeUint& Width() const; + void Width( const eeUint& width ); + protected: + eeColorA mColor; + eeUint mWidth; +}; + +}} + +#endif diff --git a/src/ui/cuicontrol.cpp b/src/ui/cuicontrol.cpp index ec916e5ca..56636e24d 100644 --- a/src/ui/cuicontrol.cpp +++ b/src/ui/cuicontrol.cpp @@ -16,7 +16,8 @@ cUIControl::cUIControl( const CreateParams& Params ) : mBackground( Params.Background ), mBorder( Params.Border ), mControlFlags( 0 ), - mBlend( Params.Blend ) + mBlend( Params.Blend ), + mNumCallBacks(0) { mType |= UI_TYPE_GET(UI_TYPE_CONTROL); @@ -210,47 +211,68 @@ void cUIControl::Update() { } } -Uint32 cUIControl::OnKeyDown( const cUIEventKey& _Event ) { +void cUIControl::SendMouseEvent( const Uint32& Event, const eeVector2i& Pos, const Uint32& Flags ) { + cUIEventMouse MouseEvent( this, Event, Pos, Flags ); + SendEvent( &MouseEvent ); +} + +void cUIControl::SendCommonEvent( const Uint32& Event ) { + cUIEvent CommonEvent( this, Event ); + SendEvent( &CommonEvent ); +} + +Uint32 cUIControl::OnKeyDown( const cUIEventKey& Event ) { + SendEvent( &Event ); return 0; } -Uint32 cUIControl::OnKeyUp( const cUIEventKey& _Event ) { +Uint32 cUIControl::OnKeyUp( const cUIEventKey& Event ) { + SendEvent( &Event ); return 0; } Uint32 cUIControl::OnMouseMove( const eeVector2i& Pos, const Uint32 Flags ) { + SendMouseEvent( cUIEvent::EventMouseMove, Pos, Flags ); return 0; } Uint32 cUIControl::OnMouseDown( const eeVector2i& Pos, const Uint32 Flags ) { + SendMouseEvent( cUIEvent::EventMouseDown, Pos, Flags ); return 0; } Uint32 cUIControl::OnMouseUp( const eeVector2i& Pos, const Uint32 Flags ) { + SendMouseEvent( cUIEvent::EventMouseUp, Pos, Flags ); return 0; } Uint32 cUIControl::OnMouseClick( const eeVector2i& Pos, const Uint32 Flags ) { + SendMouseEvent( cUIEvent::EventMouseClick, Pos, Flags ); return 0; } Uint32 cUIControl::OnMouseDoubleClick( const eeVector2i& Pos, const Uint32 Flags ) { + SendMouseEvent( cUIEvent::EventMouseDoubleClick, Pos, Flags ); return 0; } Uint32 cUIControl::OnMouseEnter( const eeVector2i& Pos, const Uint32 Flags ) { + SendMouseEvent( cUIEvent::EventMouseEnter, Pos, Flags ); return 1; } Uint32 cUIControl::OnMouseExit( const eeVector2i& Pos, const Uint32 Flags ) { + SendMouseEvent( cUIEvent::EventMouseExit, Pos, Flags ); return 1; } Uint32 cUIControl::OnFocus() { + SendCommonEvent( cUIEvent::EventOnFocus ); return 0; } Uint32 cUIControl::OnFocusLoss() { + SendCommonEvent( cUIEvent::EventOnFocusLoss ); return 0; } @@ -356,6 +378,7 @@ void cUIControl::ToPos( const Uint32& Pos ) { } void cUIControl::OnVisibleChange() { + SendCommonEvent( cUIEvent::EventOnVisibleChange ); } void cUIControl::OnEnabledChange() { @@ -364,12 +387,16 @@ void cUIControl::OnEnabledChange() { cUIManager::instance()->FocusControl( NULL ); } } + + SendCommonEvent( cUIEvent::EventOnEnabledChange ); } void cUIControl::OnPosChange() { + SendCommonEvent( cUIEvent::EventOnPosChange ); } void cUIControl::OnSizeChange() { + SendCommonEvent( cUIEvent::EventOnSizeChange ); } void cUIControl::BackgroundDraw() { @@ -670,4 +697,47 @@ void cUIControl::UpdateQuad() { }; } +eeFloat cUIControl::Elapsed() { + return cUIManager::instance()->Elapsed(); +} + +Uint32 cUIControl::AddEventListener( const Uint32& EventType, const UIEventCallback& Callback ) { + mNumCallBacks++; + + mEvents[ EventType ][ mNumCallBacks ] = Callback; + + return mNumCallBacks; +} + +void cUIControl::RemoveEventListener( const Uint32& CallbackId ) { + std::map< Uint32, std::map >::iterator it; + + for ( it = mEvents.begin(); it != mEvents.end(); ++it ) { + std::map event = it->second; + + if ( event.erase( CallbackId ) ) + break; + } +} + +void cUIControl::SendEvent( const cUIEvent * Event ) { + if ( 0 != mEvents.count( Event->EventType() ) ) { + std::map event = mEvents[ Event->EventType() ]; + std::map::iterator it; + + if ( event.begin() != event.end() ) { + for ( it = event.begin(); it != event.end(); ++it ) + it->second( Event ); + } + } +} + +cUIBackground * cUIControl::Background() { + return &mBackground; +} + +cUIBorder * cUIControl::Border() { + return &mBorder; +} + }} diff --git a/src/ui/cuicontrol.hpp b/src/ui/cuicontrol.hpp index cfd3efbaa..827c45b22 100644 --- a/src/ui/cuicontrol.hpp +++ b/src/ui/cuicontrol.hpp @@ -3,9 +3,12 @@ #include "base.hpp" #include "uihelper.hpp" +#include "cuibackground.hpp" +#include "cuiborder.hpp" #include "cuimessage.hpp" #include "cuievent.hpp" #include "cuieventkey.hpp" +#include "cuieventmouse.hpp" namespace EE { namespace UI { @@ -13,35 +16,7 @@ class cUIManager; class EE_API cUIControl { public: - class cUIBackground { - public: - cUIBackground() : mColor( 0xFF404040 ), mBlendMode( ALPHA_NORMAL ) {} - cUIBackground( const cUIBackground& Back ) : mColor( Back.Color() ), mBlendMode( ALPHA_NORMAL ) {} - - const eeColorA& Color() const { return mColor; } - void Color( const eeColorA& Col ) { mColor = Col; } - - const EE_RENDERALPHAS& Blend() const { return mBlendMode; } - void Blend( const EE_RENDERALPHAS& blend ) { mBlendMode = blend; } - protected: - eeColorA mColor; - EE_RENDERALPHAS mBlendMode; - }; - - class cUIBorder { - public: - cUIBorder() : mColor( 0xFF404040 ), mWidth( 1 ) {} - cUIBorder( const cUIBorder& border ) : mColor( border.Color() ), mWidth( border.Width() ) {} - - const eeColorA& Color() const { return mColor; } - void Color( const eeColorA& Col ) { mColor = Col; } - - const eeUint& Width() const { return mWidth; } - void Width( const eeUint& width ) { mWidth = width; } - protected: - eeColorA mColor; - eeUint mWidth; - }; + typedef boost::function1 UIEventCallback; class CreateParams { public: @@ -142,9 +117,9 @@ class EE_API cUIControl { virtual void Update(); - virtual Uint32 OnKeyDown( const cUIEventKey& _Event ); + virtual Uint32 OnKeyDown( const cUIEventKey& Event ); - virtual Uint32 OnKeyUp( const cUIEventKey& _Event ); + virtual Uint32 OnKeyUp( const cUIEventKey& Event ); virtual Uint32 OnMouseMove( const eeVector2i& Pos, const Uint32 Flags ); @@ -205,6 +180,14 @@ class EE_API cUIControl { Uint32 IsAnimated(); Uint32 IsClipped(); + + Uint32 AddEventListener( const Uint32& EventType, const UIEventCallback& Callback ); + + void RemoveEventListener( const Uint32& CallbackId ); + + cUIBackground * Background(); + + cUIBorder * Border(); protected: friend class cUIManager; friend class cUIDragable; @@ -232,6 +215,9 @@ class EE_API cUIControl { eeQuad2f mQuad; eeVector2f mCenter; + std::map< Uint32, std::map > mEvents; + Uint32 mNumCallBacks; + virtual ~cUIControl(); virtual void OnVisibleChange(); @@ -283,6 +269,14 @@ class EE_API cUIControl { virtual void ClipTo(); virtual void DrawChilds(); + + virtual eeFloat Elapsed(); + + virtual void SendEvent( const cUIEvent * Event ); + + void SendMouseEvent( const Uint32& Event, const eeVector2i& Pos, const Uint32& Flags ); + + void SendCommonEvent( const Uint32& Event ); }; }} diff --git a/src/ui/cuicontrolanim.cpp b/src/ui/cuicontrolanim.cpp index 338b13f25..9af83702f 100644 --- a/src/ui/cuicontrolanim.cpp +++ b/src/ui/cuicontrolanim.cpp @@ -111,22 +111,22 @@ void cUIControlAnim::Update() { cUIDragable::Update(); if ( NULL != mMoveAnim && mMoveAnim->Enabled() ) { - mMoveAnim->Update( cUIManager::instance()->Elapsed() ); + mMoveAnim->Update( Elapsed() ); Pos( (eeInt)mMoveAnim->GetPos().x, (eeInt)mMoveAnim->GetPos().y ); } if ( NULL != mAlphaAnim && mAlphaAnim->Enabled() ) { - mAlphaAnim->Update( cUIManager::instance()->Elapsed() ); + mAlphaAnim->Update( Elapsed() ); Alpha( mAlphaAnim->GetRealPos() ); } if ( NULL != mScaleAnim && mScaleAnim->Enabled() ) { - mScaleAnim->Update( cUIManager::instance()->Elapsed() ); + mScaleAnim->Update( Elapsed() ); Scale( mScaleAnim->GetRealPos() ); } if ( NULL != mAngleAnim && mAngleAnim->Enabled() ) { - mAngleAnim->Update( cUIManager::instance()->Elapsed() ); + mAngleAnim->Update( Elapsed() ); Angle( mAngleAnim->GetRealPos() ); } @@ -286,12 +286,15 @@ cWaypoints * cUIControlAnim::MovementInterpolation() { } void cUIControlAnim::OnAngleChange() { + SendCommonEvent( cUIEvent::EventOnAngleChange ); } void cUIControlAnim::OnScaleChange() { + SendCommonEvent( cUIEvent::EventOnScaleChange ); } void cUIControlAnim::OnAlphaChange() { + SendCommonEvent( cUIEvent::EventOnAlphaChange ); } }} diff --git a/src/ui/cuicontrolanim.hpp b/src/ui/cuicontrolanim.hpp index ea6d06a33..e61bb21fb 100644 --- a/src/ui/cuicontrolanim.hpp +++ b/src/ui/cuicontrolanim.hpp @@ -82,9 +82,9 @@ class EE_API cUIControlAnim : public cUIDragable { virtual void OnAlphaChange(); - void MatrixSet(); + virtual void MatrixSet(); - void MatrixUnset(); + virtual void MatrixUnset(); }; }} diff --git a/src/ui/cuidragable.cpp b/src/ui/cuidragable.cpp index 552b44511..c7c25dbf8 100644 --- a/src/ui/cuidragable.cpp +++ b/src/ui/cuidragable.cpp @@ -19,6 +19,7 @@ Uint32 cUIDragable::OnMouseDown( const eeVector2i& Pos, const Uint32 Flags ) { mDragPoint = mDraggingPoint = Pos; } + cUIControl::OnMouseDown( Pos, Flags ); return 1; } @@ -26,6 +27,7 @@ Uint32 cUIDragable::OnMouseUp( const eeVector2i& Pos, const Uint32 Flags ) { if ( mDragEnable && mDragging && ( Flags & mDragButton ) ) mDragging = false; + cUIControl::OnMouseUp( Pos, Flags ); return 1; } @@ -55,18 +57,18 @@ void cUIDragable::DraggingPoint( const eeVector2i& Point ) { void cUIDragable::Update() { cUIControl::Update(); - + if ( !mDragEnable ) return; - + if ( mDragging ) { if ( !( cInput::instance()->PressTrigger() & mDragButton ) ) { mDragging = false; return; } - + eeVector2i Pos( cInput::instance()->GetMousePos() ); - + if ( mDraggingPoint.x != Pos.x || mDraggingPoint.y != Pos.y ) { mDragPoint = mDraggingPoint; mDraggingPoint = Pos; @@ -77,7 +79,7 @@ void cUIDragable::Update() { } } -const bool& cUIDragable::DragEnable() const { +const bool& cUIDragable::DragEnable() const { return mDragEnable; } diff --git a/src/ui/cuidragable.hpp b/src/ui/cuidragable.hpp index 7e18cefd5..e8533a69e 100644 --- a/src/ui/cuidragable.hpp +++ b/src/ui/cuidragable.hpp @@ -8,9 +8,9 @@ namespace EE { namespace UI { class EE_API cUIDragable : public cUIControl { public: cUIDragable( const cUIControl::CreateParams& Params ); - + virtual Uint32 OnMouseDown( const eeVector2i& Pos, const Uint32 Flags ); - virtual Uint32 OnMouseUp( const eeVector2i& Pos, const Uint32 Flags ); + virtual Uint32 OnMouseUp( const eeVector2i& Pos, const Uint32 Flags ); bool Dragging() const; void Dragging( const bool& dragging ); @@ -22,15 +22,15 @@ class EE_API cUIDragable : public cUIControl { void DraggingPoint( const eeVector2i& Point ); virtual void Update(); - - const bool& DragEnable() const; + + const bool& DragEnable() const; void DragEnable( const bool& enable ); - + void DragButton( const Uint32& Button ); const Uint32& DragButton() const; protected: virtual ~cUIDragable(); - + bool mDragEnable; bool mDragging; eeVector2i mDragPoint; diff --git a/src/ui/cuievent.cpp b/src/ui/cuievent.cpp index 6d80b5545..4c9d85c62 100644 --- a/src/ui/cuievent.cpp +++ b/src/ui/cuievent.cpp @@ -1,10 +1,12 @@ #include "cuievent.hpp" #include "cuicontrol.hpp" -namespace EE { namespace UI { +namespace EE { namespace UI { -cUIEvent::cUIEvent( cUIControl * Ctrl ) { - mCtrl = Ctrl; +cUIEvent::cUIEvent( cUIControl * Ctrl, const Uint32& EventType ) : + mCtrl( Ctrl ), + mEventType( EventType ) +{ } cUIEvent::~cUIEvent() @@ -15,4 +17,8 @@ cUIControl * cUIEvent::Ctrl() const { return mCtrl; } -}} \ No newline at end of file +const Uint32& cUIEvent::EventType() const { + return mEventType; +} + +}} diff --git a/src/ui/cuievent.hpp b/src/ui/cuievent.hpp index 2ffa96e01..f43b26e89 100644 --- a/src/ui/cuievent.hpp +++ b/src/ui/cuievent.hpp @@ -9,15 +9,44 @@ class cUIControl; class EE_API cUIEvent { public: - cUIEvent( cUIControl * Ctrl ); - + enum UIEvent { + EventKeyDown = 0, + EventKeyUp, + EventMouseMove, + EventMouseDown, + EventMouseClick, + EventMouseDoubleClick, + EventMouseUp, + EventMouseEnter, + EventMouseExit, + EventOnFocus, + EventOnFocusLoss, + EventOnVisibleChange, + EventOnEnabledChange, + EventOnPosChange, + EventOnSizeChange, + EventOnAngleChange, + EventOnScaleChange, + EventOnAlphaChange, + EventOnTextChanged, + EventOnFontChanged, + EventOnPressEnter, + EventUser, + EventForceDWord = 0xFFFFFFFF + }; + + cUIEvent( cUIControl * Ctrl, const Uint32& EventType = EventForceDWord ); + ~cUIEvent(); - + cUIControl * Ctrl() const; + + const Uint32& EventType() const; protected: - cUIControl * mCtrl; + cUIControl * mCtrl; + Uint32 mEventType; }; }} -#endif +#endif diff --git a/src/ui/cuieventkey.cpp b/src/ui/cuieventkey.cpp index 6f6445da8..3e5c2d5c8 100644 --- a/src/ui/cuieventkey.cpp +++ b/src/ui/cuieventkey.cpp @@ -3,9 +3,9 @@ namespace EE { namespace UI { -cUIEventKey::cUIEventKey( cUIControl * Ctrl, const Uint32& KeyCode, const Uint16& Char ) : - cUIEvent( Ctrl ), - mKeyCode( KeyCode ), +cUIEventKey::cUIEventKey( cUIControl * Ctrl, const Uint32& EventNum, const Uint32& KeyCode, const Uint16& Char ) : + cUIEvent( Ctrl, EventNum ), + mKeyCode( KeyCode ), mChar( Char ) { } @@ -14,12 +14,12 @@ cUIEventKey::~cUIEventKey() { } -Uint32 cUIEventKey::KeyCode() const { +const Uint32& cUIEventKey::KeyCode() const { return mKeyCode; } -Uint16 cUIEventKey::Char() const { +const Uint16& cUIEventKey::Char() const { return mChar; } - -}} \ No newline at end of file + +}} diff --git a/src/ui/cuieventkey.hpp b/src/ui/cuieventkey.hpp index 1f5617c5e..9c2007e7e 100644 --- a/src/ui/cuieventkey.hpp +++ b/src/ui/cuieventkey.hpp @@ -10,13 +10,13 @@ class cUIControl; class EE_API cUIEventKey : public cUIEvent { public: - cUIEventKey( cUIControl * Ctrl, const Uint32& KeyCode, const Uint16& Char ); + cUIEventKey( cUIControl * Ctrl, const Uint32& EventNum, const Uint32& KeyCode, const Uint16& Char ); ~cUIEventKey(); - Uint32 KeyCode() const; + const Uint32& KeyCode() const; - Uint16 Char() const; + const Uint16& Char() const; protected: Uint32 mKeyCode; Uint16 mChar; @@ -24,4 +24,4 @@ class EE_API cUIEventKey : public cUIEvent { }} -#endif +#endif diff --git a/src/ui/cuieventmouse.cpp b/src/ui/cuieventmouse.cpp new file mode 100644 index 000000000..798262087 --- /dev/null +++ b/src/ui/cuieventmouse.cpp @@ -0,0 +1,26 @@ +#include "cuieventmouse.hpp" +#include "cuicontrol.hpp" + +namespace EE { namespace UI { + +cUIEventMouse::cUIEventMouse( cUIControl * Ctrl, const Uint32& EventNum, const eeVector2i& Pos, const Uint32& Flags ) : + cUIEvent( Ctrl, EventNum ), + mPos( Pos ), + mFlags( Flags ) +{ +} + +cUIEventMouse::~cUIEventMouse() +{ +} + +const eeVector2i& cUIEventMouse::Pos() const { + return mPos; +} + +const Uint32& cUIEventMouse::Flags() const { + return mFlags; +} + +}} + diff --git a/src/ui/cuieventmouse.hpp b/src/ui/cuieventmouse.hpp new file mode 100644 index 000000000..37bd9a685 --- /dev/null +++ b/src/ui/cuieventmouse.hpp @@ -0,0 +1,28 @@ +#ifndef EE_UICUIEVENTMOUSE_HPP +#define EE_UICUIEVENTMOUSE_HPP + +#include "base.hpp" +#include "cuievent.hpp" + +namespace EE { namespace UI { + +class cUIControl; + +class EE_API cUIEventMouse : public cUIEvent { + public: + cUIEventMouse( cUIControl * Ctrl, const Uint32& EventNum, const eeVector2i& Pos, const Uint32& Flags ); + + ~cUIEventMouse(); + + const eeVector2i& Pos() const; + + const Uint32& Flags() const; + protected: + eeVector2i mPos; + Uint32 mFlags; +}; + +}} + +#endif + diff --git a/src/ui/cuigfx.cpp b/src/ui/cuigfx.cpp index 1601623fd..f11fb12d8 100644 --- a/src/ui/cuigfx.cpp +++ b/src/ui/cuigfx.cpp @@ -2,17 +2,17 @@ namespace EE { namespace UI { -cUIGfx::cUIGfx( const cUIGfx::CreateParams& Params ) : +cUIGfx::cUIGfx( const cUIGfx::CreateParams& Params ) : cUIControlAnim( Params ), mShape( Params.Shape ), mColor( Params.ShapeColor ), mRender( Params.ShapeRender ) { mType |= UI_TYPE_GET(UI_TYPE_GFX); - + if ( Flags() & UI_AUTO_SIZE || ( Params.Size.x == -1 && Params.Size.y == -1 ) ) Size( mShape->Size() ); - + if ( mColor.voidRGB ) { mColor.Alpha = (Uint8)mAlpha; mColor.voidRGB = false; @@ -24,11 +24,11 @@ cUIGfx::~cUIGfx() { void cUIGfx::Draw() { cUIControlAnim::Draw(); - + if ( mVisible ) { eeVector2i Pos = mPos; ControlToScreen( Pos ); - + mShape->Draw( (eeFloat)Pos.x, (eeFloat)Pos.y, mColor, 0.f, 1.f, mBlend, mRender ); } } @@ -64,6 +64,8 @@ void cUIGfx::OnSizeChange() { mShape->DestWidth( (eeFloat)mSize.x ); mShape->DestHeight( (eeFloat)mSize.y ); } + + cUIControlAnim::OnSizeChange(); } }} diff --git a/src/ui/cuimanager.cpp b/src/ui/cuimanager.cpp index dcb5051b8..72ef4b17a 100644 --- a/src/ui/cuimanager.cpp +++ b/src/ui/cuimanager.cpp @@ -60,12 +60,11 @@ void cUIManager::InputCallback( EE_Event * Event ) { void cUIManager::ResizeControl() { mControl->Size( mEE->GetWidth(), mEE->GetHeight() ); - cUIMessage Msg( mControl, cUIMessage::WindowResize ); - mControl->MessagePost( &Msg ); + SendMsg( mControl, cUIMessage::MsgWindowResize ); } void cUIManager::SendKeyUp( EE_Event * Event ) { - cUIEventKey KeyEvent = cUIEventKey( mFocusControl, Event->key.keysym.sym, Event->key.keysym.unicode ); + cUIEventKey KeyEvent = cUIEventKey( mFocusControl, cUIEvent::EventKeyUp, Event->key.keysym.sym, Event->key.keysym.unicode ); cUIControl * CtrlLoop = mFocusControl; while( NULL != CtrlLoop ) { @@ -77,7 +76,7 @@ void cUIManager::SendKeyUp( EE_Event * Event ) { } void cUIManager::SendKeyDown( EE_Event * Event ) { - cUIEventKey KeyEvent = cUIEventKey( mFocusControl, Event->key.keysym.sym, Event->key.keysym.unicode ); + cUIEventKey KeyEvent = cUIEventKey( mFocusControl, cUIEvent::EventKeyDown, Event->key.keysym.sym, Event->key.keysym.unicode ); cUIControl * CtrlLoop = mFocusControl; while( NULL != CtrlLoop ) { @@ -104,6 +103,12 @@ void cUIManager::OverControl( cUIControl * Ctrl ) { mOverControl = Ctrl; } +void cUIManager::SendMsg( cUIControl * Ctrl, const Uint32& Msg ) { + cUIMessage tMsg( Ctrl, Msg ); + + Ctrl->MessagePost( &tMsg ); +} + void cUIManager::Update() { mElapsed = mEE->Elapsed(); @@ -114,8 +119,13 @@ void cUIManager::Update() { if ( mKM->ClickTrigger() ) { mFocusControl->OnMouseClick( mKM->GetMousePos(), mKM->ClickTrigger() ); - if ( mKM->DoubleClickTrigger() ) + SendMsg( mFocusControl, cUIMessage::MsgClick ); + + if ( mKM->DoubleClickTrigger() ) { mFocusControl->OnMouseDoubleClick( mKM->GetMousePos(), mKM->DoubleClickTrigger() ); + + SendMsg( mFocusControl, cUIMessage::MsgDoubleClick ); + } } } } @@ -125,16 +135,14 @@ void cUIManager::Update() { if ( pOver != mOverControl ) { if ( NULL != mOverControl ) { mOverControl->OnMouseExit( mKM->GetMousePos(), 0 ); - cUIMessage Msg( mOverControl, cUIMessage::MouseExit ); - mOverControl->MessagePost( &Msg ); + SendMsg( mOverControl, cUIMessage::MsgMouseExit ); } mOverControl = pOver; if ( NULL != mOverControl ) { mOverControl->OnMouseEnter( mKM->GetMousePos(), 0 ); - cUIMessage Msg( mOverControl, cUIMessage::MouseEnter ); - mOverControl->MessagePost( &Msg ); + SendMsg( mOverControl, cUIMessage::MsgMouseEnter ); } } else { if ( NULL != mOverControl ) diff --git a/src/ui/cuimanager.hpp b/src/ui/cuimanager.hpp index d39fb7066..a44e7d3db 100644 --- a/src/ui/cuimanager.hpp +++ b/src/ui/cuimanager.hpp @@ -39,6 +39,8 @@ class EE_API cUIManager : public cSingleton { void ClipDisable(); void ResizeControl(); + + void SendMsg( cUIControl * Ctrl, const Uint32& Msg ); protected: cEngine * mEE; cInput * mKM; diff --git a/src/ui/cuimessage.hpp b/src/ui/cuimessage.hpp index d480706cf..e5af4e559 100644 --- a/src/ui/cuimessage.hpp +++ b/src/ui/cuimessage.hpp @@ -9,14 +9,15 @@ class cUIControl; class EE_API cUIMessage { public: - enum + enum UIMessage { - ClickMsg = 0, - MouseEnter, - MouseExit, - WindowResize, - UserMsg, - ForceDWord = 0xFFFFFFFF, + MsgClick = 0, + MsgDoubleClick, + MsgMouseEnter, + MsgMouseExit, + MsgWindowResize, + MsgUser, + MsgForceDWord = 0xFFFFFFFF, }; cUIMessage( cUIControl * Ctrl, const Uint32& Msg ); diff --git a/src/ui/cuitextbox.cpp b/src/ui/cuitextbox.cpp index 2228bda95..03a9420bb 100644 --- a/src/ui/cuitextbox.cpp +++ b/src/ui/cuitextbox.cpp @@ -125,12 +125,16 @@ void cUITextBox::OnSizeChange() { AutoShrink(); AutoSize(); AutoAlign(); + + cUIControlAnim::OnSizeChange(); } void cUITextBox::OnTextChanged() { + SendCommonEvent( cUIEvent::EventOnTextChanged ); } void cUITextBox::OnFontChanged() { + SendCommonEvent( cUIEvent::EventOnFontChanged ); } }} diff --git a/src/ui/cuitextinput.cpp b/src/ui/cuitextinput.cpp index d6fb98151..c4a8baed8 100644 --- a/src/ui/cuitextinput.cpp +++ b/src/ui/cuitextinput.cpp @@ -20,57 +20,57 @@ cUITextInput::~cUITextInput() { void cUITextInput::Update() { cUITextBox::Update(); - + if ( mTextBuffer.ChangedSinceLastUpdate() ) { eeVector2f offSet = mAlignOffset; - + Text( mTextBuffer.Buffer() ); - + mAlignOffset = offSet; - + ResetWaitCursor(); - + AlignFix(); - + return; } - + if ( mCursorPos != mTextBuffer.CurPos() ) { AlignFix(); mCursorPos = mTextBuffer.CurPos(); } } -void cUITextInput::Draw() { +void cUITextInput::Draw() { cUITextBox::Draw(); - + if ( Visible() && mTextBuffer.Active() && mTextBuffer.SupportFreeEditing() ) { mWaitCursorTime += cUIManager::instance()->Elapsed(); - + if ( mShowingWait ) { bool disableSmooth = mShowingWait && cEngine::instance()->GetVideoInfo()->LineSmooth; - + if ( disableSmooth ) cEngine::instance()->SetLineSmooth( false ); - + cPrimitives P; P.SetColor( mFontColor ); - + eeVector2i Pos = mPos; ControlToScreen( Pos ); - + eeFloat CurPosX = Pos.x + mAlignOffset.x + mCurPos.x + 1; eeFloat CurPosY = Pos.y + mAlignOffset.y + mCurPos.y; - + if ( CurPosX > (eeFloat)Pos.x + (eeFloat)mSize.x ) CurPosX = (eeFloat)Pos.x + (eeFloat)mSize.x; - + P.DrawLine( CurPosX, CurPosY, CurPosX, CurPosY + mTextCache.Font()->GetFontHeight(), 1.f ); - + if ( disableSmooth ) cEngine::instance()->SetLineSmooth( true ); } - + if ( mWaitCursorTime >= 500.f ) { mShowingWait = !mShowingWait; mWaitCursorTime = 0.f; @@ -81,15 +81,20 @@ void cUITextInput::Draw() { Uint32 cUITextInput::OnFocus() { mTextBuffer.Active( true ); ResetWaitCursor(); + + cUITextBox::OnFocus(); return 1; } Uint32 cUITextInput::OnFocusLoss() { mTextBuffer.Active( false ); + + cUITextBox::OnFocusLoss(); return 1; } Uint32 cUITextInput::OnPressEnter() { + SendCommonEvent( cUIEvent::EventOnPressEnter ); return 0; } @@ -105,23 +110,23 @@ void cUITextInput::ResetWaitCursor() { void cUITextInput::AlignFix() { if ( !( FontHAlignGet( Flags() ) == UI_HALIGN_LEFT && !mTextBuffer.SupportNewLine() ) ) return; - + Uint32 NLPos = 0; Uint32 LineNum = mTextBuffer.GetCurPosLinePos( NLPos ); - + mTextCache.Font()->SetText( mTextBuffer.Buffer().substr( NLPos, mTextBuffer.CurPos() - NLPos ) ); - + eeFloat tW = mTextCache.Font()->GetTextWidth(); eeFloat tX = mAlignOffset.x + tW; - + mCurPos.x = tW; mCurPos.y = (eeFloat)LineNum * (eeFloat)mTextCache.GetTextHeight(); - + if ( tX < 0.f ) mAlignOffset.x = -( mAlignOffset.x + ( tW - mAlignOffset.x ) ); else if ( tX > mSize.Width() ) mAlignOffset.x = mSize.Width() - ( mAlignOffset.x + ( tW - mAlignOffset.x ) ); - + } }} diff --git a/src/utils/helper.hpp b/src/utils/helper.hpp index f3e09909f..8bf8aa931 100644 --- a/src/utils/helper.hpp +++ b/src/utils/helper.hpp @@ -4,7 +4,7 @@ namespace EE { namespace Utils { /** @enum EE_INTERPOLATION Define the type of interpolation used. */ -typedef enum { +enum EE_INTERPOLATION { LINEAR, QUADRATICIN, QUADRATICOUT, @@ -37,8 +37,8 @@ typedef enum { ELASTICOUT, ELASTICINOUT, COUNT -} EE_INTERPOLATION; +}; }} -#endif +#endif diff --git a/src/window/cinput.hpp b/src/window/cinput.hpp index e2ce3c1f2..86eb0dbe8 100755 --- a/src/window/cinput.hpp +++ b/src/window/cinput.hpp @@ -34,7 +34,7 @@ typedef SDL_Event EE_Event; int EE_API convertKeyCharacter(EE_Event* event); /** @enum EE_KEY Enum of keyboard keys. */ -typedef enum { +enum EE_KEY { KEY_UNKNOWN= SDLK_UNKNOWN, KEY_FIRST= SDLK_FIRST, KEY_BACKSPACE= SDLK_BACKSPACE, @@ -286,14 +286,14 @@ typedef enum { KEY_WORLD_93= SDLK_WORLD_93, KEY_WORLD_94= SDLK_WORLD_94, KEY_WORLD_95= SDLK_WORLD_95 -} EE_KEY; +}; /** @enum EE_KEY_STATE Differents States of a Key */ -typedef enum { +enum EE_KEY_STATE { EE_KEYOFF = 0, EE_KEYDOWN = 1, EE_KEYUP = 2 -} EE_KEY_STATE; +}; /** @brief The basic input class. For mouse and keyboard. */ class EE_API cInput : public cSingleton { @@ -402,25 +402,25 @@ class EE_API cInput : public cSingleton { /** @return The Mouse Speed */ const eeFloat& MouseSpeed() const; - + /** @return The bitflags of the last pressed trigger (before the current state of press trigger) */ const Uint32& LastPressTrigger() const; - + /** @return The current state as flags of the mouse press trigger */ const Uint32& PressTrigger() const; - + /** @return The current state as flags of the mouse release trigger */ const Uint32& ReleaseTrigger() const; - + /** @return The current state as flags of the mouse click trigger */ const Uint32& ClickTrigger() const; - + /** @return The current state as flags of the mouse double click trigger */ const Uint32& DoubleClickTrigger() const; - + /** @return The double click interval in milliseconds ( default 500 ms ) */ const Uint32& DoubleClickInterval() const; - + /** Set the double click interval in milliseconds */ void DoubleClickInterval( const Uint32& Interval ); protected: @@ -431,7 +431,7 @@ class EE_API cInput : public cSingleton { EE_Event mEvent; std::map mKeystates; std::map mCallbacks; - + Uint32 mPressTrigger; Uint32 mReleaseTrigger; Uint32 mLastPressTrigger; @@ -441,10 +441,10 @@ class EE_API cInput : public cSingleton { Uint32 mDoubleClickInterval; //!< Determine the double click inverval in milliseconds ( default 500 ms ) Uint32 mLastButtonLeftClicked, mLastButtonRightClicked, mLastButtonMiddleClicked; Uint32 mLastButtonLeftClick, mLastButtonRightClick, mLastButtonMiddleClick; - + Uint32 mTClick; eeVector2i mMousePos; - + VideoResizeCallback mVRCall; Uint32 mNumCallBacks;