diff --git a/Demo/Demo.vcxproj b/Demo/Demo.vcxproj index 98bd4630..b89fc721 100644 --- a/Demo/Demo.vcxproj +++ b/Demo/Demo.vcxproj @@ -1,156 +1,156 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {9D85A92F-BCCE-4EF0-BAD3-601C0086661C} - Win32Proj - Demo - 10.0.15063.0 - - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - Application - true - v141 - Unicode - - - Application - false - v141 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - $(MSBuildProjectDirectory)\..\Win32;$(LibraryPath) - - - true - - - false - - - false - - - - - - Level3 - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - - - Windows - true - - - - - - - Level3 - Disabled - _DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - - - Windows - true - - - - - - - Level3 - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - - - - - - - Level3 - MaxSpeed - true - true - NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {9D85A92F-BCCE-4EF0-BAD3-601C0086661C} + Win32Proj + Demo + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(MSBuildProjectDirectory)\..\Win32;$(LibraryPath) + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + + + Level3 + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + Level3 + MaxSpeed + true + true + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + \ No newline at end of file diff --git a/Easy2D/Easy2D.vcxproj b/Easy2D/Easy2D.vcxproj index 410a9fdb..f6173c2e 100644 --- a/Easy2D/Easy2D.vcxproj +++ b/Easy2D/Easy2D.vcxproj @@ -1,216 +1,216 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - 15.0 - {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF} - Win32Proj - Easy2D - 10.0.15063.0 - - - - StaticLibrary - true - v141 - Unicode - - - StaticLibrary - false - v141 - false - Unicode - - - StaticLibrary - true - v141 - Unicode - - - StaticLibrary - false - v141 - false - Unicode - - - - - - - - - - - - - - - - - - - - - true - Easy2Ddw - $(SolutionDir)$(Platform)\ - $(Platform)\$(Configuration)\ - - - true - Easy2Ddw - $(SolutionDir)$(Platform)\ - $(Platform)\$(Configuration)\ - - - false - Easy2Dw - $(SolutionDir)$(Platform)\ - $(Platform)\$(Configuration)\ - - - false - Easy2Dw - $(SolutionDir)$(Platform)\ - $(Platform)\$(Configuration)\ - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EditAndContinue - false - - - Console - true - - - - - - - - - - - false - - - - - NotUsing - Level3 - Disabled - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - None - false - - - Console - true - - - - - - - - - - - NotUsing - Level3 - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - None - - - Console - true - true - true - - - - - - - - - - - - - NotUsing - Level3 - MaxSpeed - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - None - - - Console - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 15.0 + {FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF} + Win32Proj + Easy2D + 8.1 + + + + StaticLibrary + true + v140 + Unicode + + + StaticLibrary + false + v141 + false + Unicode + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + false + v141 + false + Unicode + + + + + + + + + + + + + + + + + + + + + true + Easy2Ddw + $(SolutionDir)$(Platform)\ + $(Platform)\$(Configuration)\ + + + true + Easy2Ddw + $(SolutionDir)$(Platform)\ + $(Platform)\$(Configuration)\ + + + false + Easy2Dw + $(SolutionDir)$(Platform)\ + $(Platform)\$(Configuration)\ + + + false + Easy2Dw + $(SolutionDir)$(Platform)\ + $(Platform)\$(Configuration)\ + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EditAndContinue + false + + + Console + true + + + + + + + + + + + false + + + + + NotUsing + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + None + false + + + Console + true + + + + + + + + + + + NotUsing + Level3 + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + None + + + Console + true + true + true + + + + + + + + + + + + + NotUsing + Level3 + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + None + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Easy2D/Tool/EMouseListener.cpp b/Easy2D/Tool/EMouseListener.cpp index 08fb0b33..84e514a1 100644 --- a/Easy2D/Tool/EMouseListener.cpp +++ b/Easy2D/Tool/EMouseListener.cpp @@ -1 +1,69 @@ -#include "..\etools.h" \ No newline at end of file +#include "..\etools.h" + +e2d::EMouseListener::EMouseListener() + : m_bRunning(false) + , m_bWaiting(false) + , m_sName(L"") + , m_callback([] {}) + , m_pParentScene(nullptr) +{ +} + +e2d::EMouseListener::EMouseListener(EString name) + : EMouseListener() +{ + m_sName = name; +} + +e2d::EMouseListener::EMouseListener(const MOUSE_CALLBACK & callback) + : EMouseListener() +{ + m_callback = callback; +} + +e2d::EMouseListener::EMouseListener(EString name, const MOUSE_CALLBACK & callback) + : EMouseListener() +{ + m_sName = name; + m_callback = callback; +} + +bool e2d::EMouseListener::isRunnint() const +{ + return m_bRunning && !m_bWaiting; +} + +void e2d::EMouseListener::start() +{ + m_bRunning = true; +} + +void e2d::EMouseListener::stop() +{ + m_bRunning = false; +} + +void e2d::EMouseListener::wait() +{ + m_bWaiting = true; +} + +void e2d::EMouseListener::notify() +{ + m_bWaiting = false; +} + +void e2d::EMouseListener::runCallback() +{ + m_callback(); +} + +e2d::EString e2d::EMouseListener::getName() const +{ + return m_sName; +} + +e2d::EScene * e2d::EMouseListener::getParentScene() +{ + return m_pParentScene; +} \ No newline at end of file diff --git a/Easy2D/ebase.h b/Easy2D/ebase.h index 33208d5d..50837fb8 100644 --- a/Easy2D/ebase.h +++ b/Easy2D/ebase.h @@ -166,8 +166,9 @@ protected: class EScene { -public: + friend EApp; +public: EScene(); ~EScene(); @@ -200,7 +201,6 @@ public: void clearAllChildren(); protected: - friend EApp; std::vector m_vChildren; protected: @@ -213,6 +213,8 @@ protected: class EObject { + friend EObjectManager; + public: EObject(); @@ -228,7 +230,6 @@ public: void autoRelease(); private: - friend EObjectManager; int m_nRefCount; bool m_bManaged; bool m_bAutoRelease; diff --git a/Easy2D/ecommon.h b/Easy2D/ecommon.h index a8b59b26..dbbbbb9f 100644 --- a/Easy2D/ecommon.h +++ b/Easy2D/ecommon.h @@ -2,12 +2,16 @@ #include #include #include +#include namespace e2d { typedef std::wstring EString; +//typedef std::function KEY_CALLBACK; +typedef std::function MOUSE_CALLBACK; + typedef CSize ESize; typedef CPoint EPoint; diff --git a/Easy2D/etools.h b/Easy2D/etools.h index 280aa0aa..73911f72 100644 --- a/Easy2D/etools.h +++ b/Easy2D/etools.h @@ -4,8 +4,13 @@ namespace e2d { +class EMsgManager; + + class EObjectManager { + friend EApp; + public: // ½«Ò»¸ö½Úµã·ÅÈëÊÍ·Å³Ø static void add( @@ -16,8 +21,6 @@ public: static void clearAllObjects(); private: - friend EApp; - // Ë¢ÐÂÄÚ´æ³Ø static void __flush(); }; @@ -54,15 +57,67 @@ public: class EMouseListener : public EObject { -protected: friend EMsgManager; - e2d::EString name; +public: + EMouseListener(); + + EMouseListener( + EString name + ); + + EMouseListener( + const MOUSE_CALLBACK &callback + ); + + EMouseListener( + EString name, + const MOUSE_CALLBACK &callback + ); + + // »ñÈ¡¼àÌýÆ÷״̬ + bool isRunnint() const; + + // Æô¶¯¼àÌý + void start(); + + // Í£Ö¹¼àÌý + void stop(); + + // ½øÈëµÈ´ý״̬ + void wait(); + + // »½ÐÑ + void notify(); + + // Ö´ÐмàÌýÆ÷»Øµ÷º¯Êý + void runCallback(); + + // »ñÈ¡¼àÌýÆ÷Ãû³Æ + EString getName() const; + + // »ñÈ¡¼àÌýÆ÷ËùÔÚ³¡¾° + EScene * getParentScene(); + + // ÉèÖüàÌýÆ÷Ãû³Æ + void setName(EString name); + + // ÉèÖüàÌýÆ÷»Øµ÷º¯Êý + void setCallback(const MOUSE_CALLBACK &callback); + +protected: + EString m_sName; + bool m_bRunning; + bool m_bWaiting; + MOUSE_CALLBACK m_callback; + EScene * m_pParentScene; }; class EMsgManager { + friend EApp; + public: static void setMouseMsg( UINT message @@ -75,8 +130,7 @@ public: ); private: - friend EApp; - + static void __exec(); };