commit
						c9f4fd87f4
					
				|  | @ -11,7 +11,6 @@ | ||||||
|     <ClInclude Include="..\..\src\kiwano\2d\action\Animation.h" /> |     <ClInclude Include="..\..\src\kiwano\2d\action\Animation.h" /> | ||||||
|     <ClInclude Include="..\..\src\kiwano\2d\Frame.h" /> |     <ClInclude Include="..\..\src\kiwano\2d\Frame.h" /> | ||||||
|     <ClInclude Include="..\..\src\kiwano\2d\GifSprite.h" /> |     <ClInclude Include="..\..\src\kiwano\2d\GifSprite.h" /> | ||||||
|     <ClInclude Include="..\..\src\kiwano\core\Director.h" /> |  | ||||||
|     <ClInclude Include="..\..\src\kiwano\core\Event.h" /> |     <ClInclude Include="..\..\src\kiwano\core\Event.h" /> | ||||||
|     <ClInclude Include="..\..\src\kiwano\core\Library.h" /> |     <ClInclude Include="..\..\src\kiwano\core\Library.h" /> | ||||||
|     <ClInclude Include="..\..\src\kiwano\core\win32\ComPtr.hpp" /> |     <ClInclude Include="..\..\src\kiwano\core\win32\ComPtr.hpp" /> | ||||||
|  | @ -64,6 +63,7 @@ | ||||||
|     <ClInclude Include="..\..\src\kiwano\math\scalar.h" /> |     <ClInclude Include="..\..\src\kiwano\math\scalar.h" /> | ||||||
|     <ClInclude Include="..\..\src\kiwano\math\Vec2.hpp" /> |     <ClInclude Include="..\..\src\kiwano\math\Vec2.hpp" /> | ||||||
|     <ClInclude Include="..\..\src\kiwano\platform\Application.h" /> |     <ClInclude Include="..\..\src\kiwano\platform\Application.h" /> | ||||||
|  |     <ClInclude Include="..\..\src\kiwano\platform\Director.h" /> | ||||||
|     <ClInclude Include="..\..\src\kiwano\platform\FileSystem.h" /> |     <ClInclude Include="..\..\src\kiwano\platform\FileSystem.h" /> | ||||||
|     <ClInclude Include="..\..\src\kiwano\platform\Input.h" /> |     <ClInclude Include="..\..\src\kiwano\platform\Input.h" /> | ||||||
|     <ClInclude Include="..\..\src\kiwano\platform\modules.h" /> |     <ClInclude Include="..\..\src\kiwano\platform\modules.h" /> | ||||||
|  | @ -123,11 +123,11 @@ | ||||||
|     <ClCompile Include="..\..\src\kiwano\core\Logger.cpp" /> |     <ClCompile Include="..\..\src\kiwano\core\Logger.cpp" /> | ||||||
|     <ClCompile Include="..\..\src\kiwano\core\ObjectBase.cpp" /> |     <ClCompile Include="..\..\src\kiwano\core\ObjectBase.cpp" /> | ||||||
|     <ClCompile Include="..\..\src\kiwano\core\Resource.cpp" /> |     <ClCompile Include="..\..\src\kiwano\core\Resource.cpp" /> | ||||||
|     <ClCompile Include="..\..\src\kiwano\core\Director.cpp" /> |  | ||||||
|     <ClCompile Include="..\..\src\kiwano\core\Timer.cpp" /> |     <ClCompile Include="..\..\src\kiwano\core\Timer.cpp" /> | ||||||
|     <ClCompile Include="..\..\src\kiwano\core\TimerManager.cpp" /> |     <ClCompile Include="..\..\src\kiwano\core\TimerManager.cpp" /> | ||||||
|     <ClCompile Include="..\..\src\kiwano\core\time.cpp" /> |     <ClCompile Include="..\..\src\kiwano\core\time.cpp" /> | ||||||
|     <ClCompile Include="..\..\src\kiwano\platform\Application.cpp" /> |     <ClCompile Include="..\..\src\kiwano\platform\Application.cpp" /> | ||||||
|  |     <ClCompile Include="..\..\src\kiwano\platform\Director.cpp" /> | ||||||
|     <ClCompile Include="..\..\src\kiwano\platform\FileSystem.cpp" /> |     <ClCompile Include="..\..\src\kiwano\platform\FileSystem.cpp" /> | ||||||
|     <ClCompile Include="..\..\src\kiwano\platform\Input.cpp" /> |     <ClCompile Include="..\..\src\kiwano\platform\Input.cpp" /> | ||||||
|     <ClCompile Include="..\..\src\kiwano\platform\modules.cpp" /> |     <ClCompile Include="..\..\src\kiwano\platform\modules.cpp" /> | ||||||
|  |  | ||||||
|  | @ -117,9 +117,6 @@ | ||||||
|     <ClInclude Include="..\..\src\kiwano\2d\GifSprite.h"> |     <ClInclude Include="..\..\src\kiwano\2d\GifSprite.h"> | ||||||
|       <Filter>2d</Filter> |       <Filter>2d</Filter> | ||||||
|     </ClInclude> |     </ClInclude> | ||||||
|     <ClInclude Include="..\..\src\kiwano\core\Director.h"> |  | ||||||
|       <Filter>core</Filter> |  | ||||||
|     </ClInclude> |  | ||||||
|     <ClInclude Include="..\..\src\kiwano\2d\Actor.h"> |     <ClInclude Include="..\..\src\kiwano\2d\Actor.h"> | ||||||
|       <Filter>2d</Filter> |       <Filter>2d</Filter> | ||||||
|     </ClInclude> |     </ClInclude> | ||||||
|  | @ -303,6 +300,9 @@ | ||||||
|     <ClInclude Include="..\..\src\kiwano\platform\Window.h"> |     <ClInclude Include="..\..\src\kiwano\platform\Window.h"> | ||||||
|       <Filter>platform</Filter> |       <Filter>platform</Filter> | ||||||
|     </ClInclude> |     </ClInclude> | ||||||
|  |     <ClInclude Include="..\..\src\kiwano\platform\Director.h"> | ||||||
|  |       <Filter>platform</Filter> | ||||||
|  |     </ClInclude> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClCompile Include="..\..\src\kiwano\ui\Button.cpp"> |     <ClCompile Include="..\..\src\kiwano\ui\Button.cpp"> | ||||||
|  | @ -356,9 +356,6 @@ | ||||||
|     <ClCompile Include="..\..\src\kiwano\2d\GifSprite.cpp"> |     <ClCompile Include="..\..\src\kiwano\2d\GifSprite.cpp"> | ||||||
|       <Filter>2d</Filter> |       <Filter>2d</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|     <ClCompile Include="..\..\src\kiwano\core\Director.cpp"> |  | ||||||
|       <Filter>core</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\src\kiwano\2d\Actor.cpp"> |     <ClCompile Include="..\..\src\kiwano\2d\Actor.cpp"> | ||||||
|       <Filter>2d</Filter> |       <Filter>2d</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|  | @ -485,5 +482,8 @@ | ||||||
|     <ClCompile Include="..\..\src\kiwano\platform\Window.cpp"> |     <ClCompile Include="..\..\src\kiwano\platform\Window.cpp"> | ||||||
|       <Filter>platform</Filter> |       <Filter>platform</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\src\kiwano\platform\Director.cpp"> | ||||||
|  |       <Filter>platform</Filter> | ||||||
|  |     </ClCompile> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
| </Project> | </Project> | ||||||
|  | @ -68,13 +68,13 @@ namespace kiwano | ||||||
| 			void BeginContact(b2Contact* contact) override | 			void BeginContact(b2Contact* contact) override | ||||||
| 			{ | 			{ | ||||||
| 				ContactBeginEvent evt(contact); | 				ContactBeginEvent evt(contact); | ||||||
| 				world_->Dispatch(&evt); | 				world_->Dispatch(evt); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			void EndContact(b2Contact* contact) override | 			void EndContact(b2Contact* contact) override | ||||||
| 			{ | 			{ | ||||||
| 				ContactEndEvent evt(contact); | 				ContactEndEvent evt(contact); | ||||||
| 				world_->Dispatch(&evt); | 				world_->Dispatch(evt); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) override		{ KGE_NOT_USED(contact); KGE_NOT_USED(oldManifold); } | 			void PreSolve(b2Contact* contact, const b2Manifold* oldManifold) override		{ KGE_NOT_USED(contact); KGE_NOT_USED(oldManifold); } | ||||||
|  | @ -227,8 +227,7 @@ namespace kiwano | ||||||
| 
 | 
 | ||||||
| 		void World::Update(Duration dt) | 		void World::Update(Duration dt) | ||||||
| 		{ | 		{ | ||||||
| 			Stage::Update(dt); | 			{ | ||||||
| 
 |  | ||||||
| 				b2Body* b2body = world_.GetBodyList(); | 				b2Body* b2body = world_.GetBodyList(); | ||||||
| 				while (b2body) | 				while (b2body) | ||||||
| 				{ | 				{ | ||||||
|  | @ -240,10 +239,12 @@ namespace kiwano | ||||||
| 
 | 
 | ||||||
| 					b2body = b2body->GetNext(); | 					b2body = b2body->GetNext(); | ||||||
| 				} | 				} | ||||||
|  | 			} | ||||||
| 
 | 
 | ||||||
| 			world_.Step(dt.Seconds(), vel_iter_, pos_iter_); | 			world_.Step(dt.Seconds(), vel_iter_, pos_iter_); | ||||||
| 
 | 
 | ||||||
| 			b2body = world_.GetBodyList(); | 			{ | ||||||
|  | 				b2Body* b2body = world_.GetBodyList(); | ||||||
| 				while (b2body) | 				while (b2body) | ||||||
| 				{ | 				{ | ||||||
| 					Body* body = static_cast<Body*>(b2body->GetUserData()); | 					Body* body = static_cast<Body*>(b2body->GetUserData()); | ||||||
|  | @ -256,5 +257,8 @@ namespace kiwano | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
|  | 			Stage::Update(dt); | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -61,12 +61,12 @@ namespace kiwano | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Actor::Update(Duration dt) | 	void Actor::Update(Duration dt) | ||||||
| 	{ |  | ||||||
| 		if (!update_pausing_) |  | ||||||
| 	{ | 	{ | ||||||
| 		UpdateActions(this, dt); | 		UpdateActions(this, dt); | ||||||
| 		UpdateTimers(dt); | 		UpdateTimers(dt); | ||||||
| 
 | 
 | ||||||
|  | 		if (!update_pausing_) | ||||||
|  | 		{ | ||||||
| 			if (cb_update_) | 			if (cb_update_) | ||||||
| 				cb_update_(dt); | 				cb_update_(dt); | ||||||
| 
 | 
 | ||||||
|  | @ -155,7 +155,7 @@ namespace kiwano | ||||||
| 		return visible_in_rt_; | 		return visible_in_rt_; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Actor::Dispatch(Event* evt) | 	void Actor::Dispatch(Event& evt) | ||||||
| 	{ | 	{ | ||||||
| 		if (!visible_) | 		if (!visible_) | ||||||
| 			return; | 			return; | ||||||
|  | @ -169,9 +169,9 @@ namespace kiwano | ||||||
| 
 | 
 | ||||||
| 		if (responsible_) | 		if (responsible_) | ||||||
| 		{ | 		{ | ||||||
| 			if (evt->type == event::MouseMove) | 			if (evt.type == event::MouseMove) | ||||||
| 			{ | 			{ | ||||||
| 				auto mouse_evt = evt->SafeCast<MouseMoveEvent>(); | 				auto mouse_evt = evt.SafeCast<MouseMoveEvent>(); | ||||||
| 				if (!mouse_evt->target && ContainsPoint(mouse_evt->pos)) | 				if (!mouse_evt->target && ContainsPoint(mouse_evt->pos)) | ||||||
| 				{ | 				{ | ||||||
| 					mouse_evt->target = this; | 					mouse_evt->target = this; | ||||||
|  | @ -185,7 +185,7 @@ namespace kiwano | ||||||
| 						hover.left_btn_down = mouse_evt->left_btn_down; | 						hover.left_btn_down = mouse_evt->left_btn_down; | ||||||
| 						hover.right_btn_down = mouse_evt->right_btn_down; | 						hover.right_btn_down = mouse_evt->right_btn_down; | ||||||
| 						hover.target = this; | 						hover.target = this; | ||||||
| 						EventDispatcher::Dispatch(&hover); | 						EventDispatcher::Dispatch(hover); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
| 				else if (hover_) | 				else if (hover_) | ||||||
|  | @ -198,29 +198,30 @@ namespace kiwano | ||||||
| 					out.left_btn_down = mouse_evt->left_btn_down; | 					out.left_btn_down = mouse_evt->left_btn_down; | ||||||
| 					out.right_btn_down = mouse_evt->right_btn_down; | 					out.right_btn_down = mouse_evt->right_btn_down; | ||||||
| 					out.target = this; | 					out.target = this; | ||||||
| 					EventDispatcher::Dispatch(&out); | 					EventDispatcher::Dispatch(out); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			if (evt->type == event::MouseDown && hover_) | 			if (evt.type == event::MouseDown && hover_) | ||||||
| 			{ | 			{ | ||||||
| 				pressed_ = true; | 				pressed_ = true; | ||||||
| 				evt->SafeCast<MouseDownEvent>()->target = this; | 				evt.SafeCast<MouseDownEvent>()->target = this; | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			if (evt->type == event::MouseUp && pressed_) | 			if (evt.type == event::MouseUp && pressed_) | ||||||
| 			{ | 			{ | ||||||
| 				pressed_ = false; | 				pressed_ = false; | ||||||
| 
 | 
 | ||||||
| 				auto mouse_up_evt = evt->SafeCast<MouseUpEvent>(); | 				auto mouse_up_evt = evt.SafeCast<MouseUpEvent>(); | ||||||
| 				mouse_up_evt->target = this; | 				mouse_up_evt->target = this; | ||||||
| 
 | 
 | ||||||
| 				MouseOutEvent click; | 				MouseClickEvent click; | ||||||
| 				click.pos = mouse_up_evt->pos; | 				click.pos = mouse_up_evt->pos; | ||||||
| 				click.left_btn_down = mouse_up_evt->left_btn_down; | 				click.left_btn_down = mouse_up_evt->left_btn_down; | ||||||
| 				click.right_btn_down = mouse_up_evt->right_btn_down; | 				click.right_btn_down = mouse_up_evt->right_btn_down; | ||||||
| 				click.target = this; | 				click.target = this; | ||||||
| 				EventDispatcher::Dispatch(&click); | 				click.button = mouse_up_evt->button; | ||||||
|  | 				EventDispatcher::Dispatch(click); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -365,7 +365,7 @@ namespace kiwano | ||||||
| 		void ShowBorder(bool show); | 		void ShowBorder(bool show); | ||||||
| 
 | 
 | ||||||
| 		// 事件分发
 | 		// 事件分发
 | ||||||
| 		void Dispatch(Event* evt) override; | 		void Dispatch(Event& evt) override; | ||||||
| 
 | 
 | ||||||
| 		// 设置默认锚点
 | 		// 设置默认锚点
 | ||||||
| 		static void SetDefaultAnchor( | 		static void SetDefaultAnchor( | ||||||
|  |  | ||||||
|  | @ -66,8 +66,8 @@ namespace kiwano | ||||||
| 		style.line_spacing = 20.f; | 		style.line_spacing = 20.f; | ||||||
| 		debug_text_->SetStyle(style); | 		debug_text_->SetStyle(style); | ||||||
| 
 | 
 | ||||||
| 		AddListener(event::MouseHover, [=](Event*) { SetOpacity(0.4f); }); | 		AddListener(event::MouseHover, [=](Event&) { SetOpacity(0.4f); }); | ||||||
| 		AddListener(event::MouseOut, [=](Event*) { SetOpacity(1.f); }); | 		AddListener(event::MouseOut, [=](Event&) { SetOpacity(1.f); }); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	DebugActor::~DebugActor() | 	DebugActor::~DebugActor() | ||||||
|  |  | ||||||
|  | @ -64,7 +64,7 @@ namespace kiwano | ||||||
| 		area_.SetMaskTransform(transform); | 		area_.SetMaskTransform(transform); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Layer::Dispatch(Event* evt) | 	void Layer::Dispatch(Event& evt) | ||||||
| 	{ | 	{ | ||||||
| 		if (!IsVisible()) | 		if (!IsVisible()) | ||||||
| 			return; | 			return; | ||||||
|  | @ -91,41 +91,41 @@ namespace kiwano | ||||||
| 		rt->PopLayer(); | 		rt->PopLayer(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Layer::HandleMessages(Event* evt) | 	void Layer::HandleMessages(Event& evt) | ||||||
| 	{ | 	{ | ||||||
| 		if (evt->type == event::MouseDown) | 		if (evt.type == event::MouseDown) | ||||||
| 		{ | 		{ | ||||||
| 			auto real_evt = evt->SafeCast<MouseDownEvent>(); | 			auto real_evt = evt.SafeCast<MouseDownEvent>(); | ||||||
| 			OnMouseButtonDown(real_evt->button, real_evt->pos); | 			OnMouseButtonDown(real_evt->button, real_evt->pos); | ||||||
| 		} | 		} | ||||||
| 		else if (evt->type == event::MouseUp) | 		else if (evt.type == event::MouseUp) | ||||||
| 		{ | 		{ | ||||||
| 			auto real_evt = evt->SafeCast<MouseUpEvent>(); | 			auto real_evt = evt.SafeCast<MouseUpEvent>(); | ||||||
| 			OnMouseButtonUp(real_evt->button, real_evt->pos); | 			OnMouseButtonUp(real_evt->button, real_evt->pos); | ||||||
| 		} | 		} | ||||||
| 		else if (evt->type == event::MouseMove) | 		else if (evt.type == event::MouseMove) | ||||||
| 		{ | 		{ | ||||||
| 			auto real_evt = evt->SafeCast<MouseMoveEvent>(); | 			auto real_evt = evt.SafeCast<MouseMoveEvent>(); | ||||||
| 			OnMouseMoved(real_evt->pos); | 			OnMouseMoved(real_evt->pos); | ||||||
| 		} | 		} | ||||||
| 		else if (evt->type == event::MouseWheel) | 		else if (evt.type == event::MouseWheel) | ||||||
| 		{ | 		{ | ||||||
| 			auto real_evt = evt->SafeCast<MouseWheelEvent>(); | 			auto real_evt = evt.SafeCast<MouseWheelEvent>(); | ||||||
| 			OnMouseWheel(real_evt->wheel); | 			OnMouseWheel(real_evt->wheel); | ||||||
| 		} | 		} | ||||||
| 		else if (evt->type == event::KeyDown) | 		else if (evt.type == event::KeyDown) | ||||||
| 		{ | 		{ | ||||||
| 			auto real_evt = evt->SafeCast<KeyDownEvent>(); | 			auto real_evt = evt.SafeCast<KeyDownEvent>(); | ||||||
| 			OnKeyDown(real_evt->code); | 			OnKeyDown(real_evt->code); | ||||||
| 		} | 		} | ||||||
| 		else if (evt->type == event::KeyUp) | 		else if (evt.type == event::KeyUp) | ||||||
| 		{ | 		{ | ||||||
| 			auto real_evt = evt->SafeCast<KeyUpEvent>(); | 			auto real_evt = evt.SafeCast<KeyUpEvent>(); | ||||||
| 			OnKeyUp(real_evt->code); | 			OnKeyUp(real_evt->code); | ||||||
| 		} | 		} | ||||||
| 		else if (evt->type == event::KeyChar) | 		else if (evt.type == event::KeyChar) | ||||||
| 		{ | 		{ | ||||||
| 			auto real_evt = evt->SafeCast<KeyCharEvent>(); | 			auto real_evt = evt.SafeCast<KeyCharEvent>(); | ||||||
| 			OnChar(real_evt->value); | 			OnChar(real_evt->value); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -67,12 +67,12 @@ namespace kiwano | ||||||
| 		inline LayerArea const& GetArea() const		{ return area_; } | 		inline LayerArea const& GetArea() const		{ return area_; } | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		void Dispatch(Event* evt) override; | 		void Dispatch(Event& evt) override; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		void Render(RenderTarget* rt) override; | 		void Render(RenderTarget* rt) override; | ||||||
| 
 | 
 | ||||||
| 		void HandleMessages(Event* evt); | 		void HandleMessages(Event& evt); | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		bool		swallow_; | 		bool		swallow_; | ||||||
|  |  | ||||||
|  | @ -85,7 +85,7 @@ namespace kiwano | ||||||
| 		: public virtual ComponentBase | 		: public virtual ComponentBase | ||||||
| 	{ | 	{ | ||||||
| 	public: | 	public: | ||||||
| 		virtual void HandleEvent(Event*) {} | 		virtual void HandleEvent(Event&) {} | ||||||
| 
 | 
 | ||||||
| 		virtual void HandleMessage(HWND, UINT32, WPARAM, LPARAM) {} | 		virtual void HandleMessage(HWND, UINT32, WPARAM, LPARAM) {} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -3,8 +3,8 @@ | ||||||
| namespace kiwano | namespace kiwano | ||||||
| { | { | ||||||
| 	EventType event::MouseMove			= EventType(L"MouseMove"); | 	EventType event::MouseMove			= EventType(L"MouseMove"); | ||||||
| 	EventType event::MouseDown			= EventType(L"MouseBtnDown"); | 	EventType event::MouseDown			= EventType(L"MouseDown"); | ||||||
| 	EventType event::MouseUp			= EventType(L"MouseBtnUp"); | 	EventType event::MouseUp			= EventType(L"MouseUp"); | ||||||
| 	EventType event::MouseWheel			= EventType(L"MouseWheel"); | 	EventType event::MouseWheel			= EventType(L"MouseWheel"); | ||||||
| 	EventType event::MouseHover			= EventType(L"MouseHover"); | 	EventType event::MouseHover			= EventType(L"MouseHover"); | ||||||
| 	EventType event::MouseOut			= EventType(L"MouseOut"); | 	EventType event::MouseOut			= EventType(L"MouseOut"); | ||||||
|  | @ -82,21 +82,18 @@ namespace kiwano | ||||||
| 	KeyDownEvent::KeyDownEvent() | 	KeyDownEvent::KeyDownEvent() | ||||||
| 		: Event(event::KeyDown) | 		: Event(event::KeyDown) | ||||||
| 		, code(0) | 		, code(0) | ||||||
| 		, count(0) |  | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	KeyUpEvent::KeyUpEvent() | 	KeyUpEvent::KeyUpEvent() | ||||||
| 		: Event(event::KeyUp) | 		: Event(event::KeyUp) | ||||||
| 		, code(0) | 		, code(0) | ||||||
| 		, count(0) |  | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	KeyCharEvent::KeyCharEvent() | 	KeyCharEvent::KeyCharEvent() | ||||||
| 		: Event(event::KeyChar) | 		: Event(event::KeyChar) | ||||||
| 		, value() | 		, value() | ||||||
| 		, count(0) |  | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -192,7 +192,6 @@ namespace kiwano | ||||||
| 	{ | 	{ | ||||||
| 	public: | 	public: | ||||||
| 		KeyCode::Value code; | 		KeyCode::Value code; | ||||||
| 		int count; |  | ||||||
| 
 | 
 | ||||||
| 		KeyDownEvent(); | 		KeyDownEvent(); | ||||||
| 	}; | 	}; | ||||||
|  | @ -203,7 +202,6 @@ namespace kiwano | ||||||
| 	{ | 	{ | ||||||
| 	public: | 	public: | ||||||
| 		KeyCode::Value code; | 		KeyCode::Value code; | ||||||
| 		int count; |  | ||||||
| 
 | 
 | ||||||
| 		KeyUpEvent(); | 		KeyUpEvent(); | ||||||
| 	}; | 	}; | ||||||
|  | @ -214,7 +212,6 @@ namespace kiwano | ||||||
| 	{ | 	{ | ||||||
| 	public: | 	public: | ||||||
| 		char value; | 		char value; | ||||||
| 		int count; |  | ||||||
| 
 | 
 | ||||||
| 		KeyCharEvent(); | 		KeyCharEvent(); | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
|  | @ -23,7 +23,7 @@ | ||||||
| 
 | 
 | ||||||
| namespace kiwano | namespace kiwano | ||||||
| { | { | ||||||
| 	void EventDispatcher::Dispatch(Event* evt) | 	void EventDispatcher::Dispatch(Event& evt) | ||||||
| 	{ | 	{ | ||||||
| 		if (listeners_.empty()) | 		if (listeners_.empty()) | ||||||
| 			return; | 			return; | ||||||
|  | @ -33,7 +33,7 @@ namespace kiwano | ||||||
| 		{ | 		{ | ||||||
| 			next = listener->next_item(); | 			next = listener->next_item(); | ||||||
| 
 | 
 | ||||||
| 			if (listener->IsRunning() && listener->type_ == evt->type) | 			if (listener->IsRunning() && listener->type_ == evt.type) | ||||||
| 			{ | 			{ | ||||||
| 				listener->callback_(evt); | 				listener->callback_(evt); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -81,7 +81,7 @@ namespace kiwano | ||||||
| 			const EventType& type | 			const EventType& type | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		virtual void Dispatch(Event* evt); | 		virtual void Dispatch(Event& evt); | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		Listeners listeners_; | 		Listeners listeners_; | ||||||
|  |  | ||||||
|  | @ -39,7 +39,7 @@ namespace kiwano | ||||||
| 		friend IntrusiveList<EventListenerPtr>; | 		friend IntrusiveList<EventListenerPtr>; | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		using Callback = Function<void(Event*)>; | 		using Callback = Function<void(Event&)>; | ||||||
| 
 | 
 | ||||||
| 		EventListener(); | 		EventListener(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -76,7 +76,6 @@ | ||||||
| //
 | //
 | ||||||
| 
 | 
 | ||||||
| #include <kiwano/core/time.h> | #include <kiwano/core/time.h> | ||||||
| #include <kiwano/core/Director.h> |  | ||||||
| #include <kiwano/core/Logger.h> | #include <kiwano/core/Logger.h> | ||||||
| #include <kiwano/core/SmartPtr.hpp> | #include <kiwano/core/SmartPtr.hpp> | ||||||
| #include <kiwano/core/ObjectBase.h> | #include <kiwano/core/ObjectBase.h> | ||||||
|  | @ -130,6 +129,7 @@ | ||||||
| #include <kiwano/platform/FileSystem.h> | #include <kiwano/platform/FileSystem.h> | ||||||
| #include <kiwano/platform/Input.h> | #include <kiwano/platform/Input.h> | ||||||
| #include <kiwano/platform/Window.h> | #include <kiwano/platform/Window.h> | ||||||
|  | #include <kiwano/platform/Director.h> | ||||||
| #include <kiwano/platform/Application.h> | #include <kiwano/platform/Application.h> | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ | ||||||
| #include <kiwano/platform/modules.h> | #include <kiwano/platform/modules.h> | ||||||
| #include <kiwano/core/win32/helper.h> | #include <kiwano/core/win32/helper.h> | ||||||
| #include <kiwano/platform/Input.h> | #include <kiwano/platform/Input.h> | ||||||
| #include <kiwano/core/Director.h> | #include <kiwano/platform/Director.h> | ||||||
| #include <kiwano/renderer/TextureCache.h> | #include <kiwano/renderer/TextureCache.h> | ||||||
| #include <kiwano/utils/ResourceCache.h> | #include <kiwano/utils/ResourceCache.h> | ||||||
| 
 | 
 | ||||||
|  | @ -261,7 +261,7 @@ namespace kiwano | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Application::DispatchEvent(Event* evt) | 	void Application::DispatchEvent(Event& evt) | ||||||
| 	{ | 	{ | ||||||
| 		for (auto c : event_comps_) | 		for (auto c : event_comps_) | ||||||
| 		{ | 		{ | ||||||
|  | @ -311,15 +311,15 @@ namespace kiwano | ||||||
| 			{ | 			{ | ||||||
| 				KeyDownEvent evt; | 				KeyDownEvent evt; | ||||||
| 				evt.code = static_cast<int>(wparam); | 				evt.code = static_cast<int>(wparam); | ||||||
| 				evt.count = static_cast<int>(lparam & 0xFF); | 				// evt.count = static_cast<int>(lparam & 0xFF);
 | ||||||
| 				app->DispatchEvent(&evt); | 				app->DispatchEvent(evt); | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 			{ | 			{ | ||||||
| 				KeyUpEvent evt; | 				KeyUpEvent evt; | ||||||
| 				evt.code = static_cast<int>(wparam); | 				evt.code = static_cast<int>(wparam); | ||||||
| 				evt.count = static_cast<int>(lparam & 0xFF); | 				// evt.count = static_cast<int>(lparam & 0xFF);
 | ||||||
| 				app->DispatchEvent(&evt); | 				app->DispatchEvent(evt); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		break; | 		break; | ||||||
|  | @ -328,8 +328,8 @@ namespace kiwano | ||||||
| 		{ | 		{ | ||||||
| 			KeyCharEvent evt; | 			KeyCharEvent evt; | ||||||
| 			evt.value = static_cast<char>(wparam); | 			evt.value = static_cast<char>(wparam); | ||||||
| 			evt.count = static_cast<int>(lparam & 0xFF); | 			// evt.count = static_cast<int>(lparam & 0xFF);
 | ||||||
| 			app->DispatchEvent(&evt); | 			app->DispatchEvent(evt); | ||||||
| 		} | 		} | ||||||
| 		break; | 		break; | ||||||
| 
 | 
 | ||||||
|  | @ -345,43 +345,43 @@ namespace kiwano | ||||||
| 		case WM_MOUSEMOVE: | 		case WM_MOUSEMOVE: | ||||||
| 		case WM_MOUSEWHEEL: | 		case WM_MOUSEWHEEL: | ||||||
| 		{ | 		{ | ||||||
| 			auto UpdateMouseData = [&](MouseEvent* evt) | 			auto UpdateMouseData = [&](MouseEvent& evt) | ||||||
| 			{ | 			{ | ||||||
| 				evt->pos = Point(static_cast<float>(GET_X_LPARAM(lparam)), static_cast<float>(GET_Y_LPARAM(lparam))); | 				evt.pos = Point(static_cast<float>(GET_X_LPARAM(lparam)), static_cast<float>(GET_Y_LPARAM(lparam))); | ||||||
| 				evt->left_btn_down = !!(wparam & MK_LBUTTON); | 				evt.left_btn_down = !!(wparam & MK_LBUTTON); | ||||||
| 				evt->left_btn_down = !!(wparam & MK_RBUTTON); | 				evt.left_btn_down = !!(wparam & MK_RBUTTON); | ||||||
| 			}; | 			}; | ||||||
| 
 | 
 | ||||||
| 			if (msg == WM_MOUSEMOVE) | 			if (msg == WM_MOUSEMOVE) | ||||||
| 			{ | 			{ | ||||||
| 				MouseMoveEvent evt; | 				MouseMoveEvent evt; | ||||||
| 				UpdateMouseData(&evt); | 				UpdateMouseData(evt); | ||||||
| 				app->DispatchEvent(&evt); | 				app->DispatchEvent(evt); | ||||||
| 			} | 			} | ||||||
| 			else if	(msg == WM_LBUTTONDOWN || msg == WM_RBUTTONDOWN || msg == WM_MBUTTONDOWN) | 			else if	(msg == WM_LBUTTONDOWN || msg == WM_RBUTTONDOWN || msg == WM_MBUTTONDOWN) | ||||||
| 			{ | 			{ | ||||||
| 				MouseDownEvent evt; | 				MouseDownEvent evt; | ||||||
| 				UpdateMouseData(&evt); | 				UpdateMouseData(evt); | ||||||
| 				if		(msg == WM_LBUTTONDOWN)	{ evt.button = MouseButton::Left; } | 				if		(msg == WM_LBUTTONDOWN)	{ evt.button = MouseButton::Left; } | ||||||
| 				else if	(msg == WM_RBUTTONDOWN)	{ evt.button = MouseButton::Right; } | 				else if	(msg == WM_RBUTTONDOWN)	{ evt.button = MouseButton::Right; } | ||||||
| 				else if	(msg == WM_MBUTTONDOWN)	{ evt.button = MouseButton::Middle; } | 				else if	(msg == WM_MBUTTONDOWN)	{ evt.button = MouseButton::Middle; } | ||||||
| 				app->DispatchEvent(&evt); | 				app->DispatchEvent(evt); | ||||||
| 			} | 			} | ||||||
| 			else if (msg == WM_LBUTTONUP || msg == WM_RBUTTONUP || msg == WM_MBUTTONUP) | 			else if (msg == WM_LBUTTONUP || msg == WM_RBUTTONUP || msg == WM_MBUTTONUP) | ||||||
| 			{ | 			{ | ||||||
| 				MouseDownEvent evt; | 				MouseUpEvent evt; | ||||||
| 				UpdateMouseData(&evt); | 				UpdateMouseData(evt); | ||||||
| 				if		(msg == WM_LBUTTONUP)	{ evt.button = MouseButton::Left; } | 				if		(msg == WM_LBUTTONUP)	{ evt.button = MouseButton::Left; } | ||||||
| 				else if	(msg == WM_RBUTTONUP)	{ evt.button = MouseButton::Right; } | 				else if	(msg == WM_RBUTTONUP)	{ evt.button = MouseButton::Right; } | ||||||
| 				else if	(msg == WM_MBUTTONUP)	{ evt.button = MouseButton::Middle; } | 				else if	(msg == WM_MBUTTONUP)	{ evt.button = MouseButton::Middle; } | ||||||
| 				app->DispatchEvent(&evt); | 				app->DispatchEvent(evt); | ||||||
| 			} | 			} | ||||||
| 			else if	(msg == WM_MOUSEWHEEL) | 			else if	(msg == WM_MOUSEWHEEL) | ||||||
| 			{ | 			{ | ||||||
| 				MouseWheelEvent evt; | 				MouseWheelEvent evt; | ||||||
| 				UpdateMouseData(&evt); | 				UpdateMouseData(evt); | ||||||
| 				evt.wheel = GET_WHEEL_DELTA_WPARAM(wparam) / (float)WHEEL_DELTA; | 				evt.wheel = GET_WHEEL_DELTA_WPARAM(wparam) / (float)WHEEL_DELTA; | ||||||
| 				app->DispatchEvent(&evt); | 				app->DispatchEvent(evt); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		break; | 		break; | ||||||
|  | @ -401,7 +401,7 @@ namespace kiwano | ||||||
| 				WindowResizedEvent evt; | 				WindowResizedEvent evt; | ||||||
| 				evt.width = LOWORD(lparam); | 				evt.width = LOWORD(lparam); | ||||||
| 				evt.height = HIWORD(lparam); | 				evt.height = HIWORD(lparam); | ||||||
| 				app->DispatchEvent(&evt); | 				app->DispatchEvent(evt); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		break; | 		break; | ||||||
|  | @ -414,7 +414,7 @@ namespace kiwano | ||||||
| 			WindowMovedEvent evt; | 			WindowMovedEvent evt; | ||||||
| 			evt.x = x; | 			evt.x = x; | ||||||
| 			evt.y = y; | 			evt.y = y; | ||||||
| 			app->DispatchEvent(&evt); | 			app->DispatchEvent(evt); | ||||||
| 		} | 		} | ||||||
| 		break; | 		break; | ||||||
| 
 | 
 | ||||||
|  | @ -426,7 +426,7 @@ namespace kiwano | ||||||
| 
 | 
 | ||||||
| 			WindowFocusChangedEvent evt; | 			WindowFocusChangedEvent evt; | ||||||
| 			evt.focus = active; | 			evt.focus = active; | ||||||
| 			app->DispatchEvent(&evt); | 			app->DispatchEvent(evt); | ||||||
| 		} | 		} | ||||||
| 		break; | 		break; | ||||||
| 
 | 
 | ||||||
|  | @ -436,7 +436,7 @@ namespace kiwano | ||||||
| 
 | 
 | ||||||
| 			WindowTitleChangedEvent evt; | 			WindowTitleChangedEvent evt; | ||||||
| 			evt.title = reinterpret_cast<const wchar_t*>(lparam); | 			evt.title = reinterpret_cast<const wchar_t*>(lparam); | ||||||
| 			app->DispatchEvent(&evt); | 			app->DispatchEvent(evt); | ||||||
| 		} | 		} | ||||||
| 		break; | 		break; | ||||||
| 
 | 
 | ||||||
|  | @ -467,7 +467,7 @@ namespace kiwano | ||||||
| 			if (!app->OnClosing()) | 			if (!app->OnClosing()) | ||||||
| 			{ | 			{ | ||||||
| 				WindowClosedEvent evt; | 				WindowClosedEvent evt; | ||||||
| 				app->DispatchEvent(&evt); | 				app->DispatchEvent(evt); | ||||||
| 				return 0; | 				return 0; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -91,7 +91,7 @@ namespace kiwano | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 分发事件
 | 		// 分发事件
 | ||||||
| 		void DispatchEvent(Event* evt); | 		void DispatchEvent(Event& evt); | ||||||
| 
 | 
 | ||||||
| 		// 在 Kiwano 主线程中执行函数
 | 		// 在 Kiwano 主线程中执行函数
 | ||||||
| 		// 当在其他线程调用 Kiwano 函数时使用
 | 		// 当在其他线程调用 Kiwano 函数时使用
 | ||||||
|  |  | ||||||
|  | @ -18,7 +18,7 @@ | ||||||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | ||||||
| // THE SOFTWARE.
 | // THE SOFTWARE.
 | ||||||
| 
 | 
 | ||||||
| #include <kiwano/core/Director.h> | #include <kiwano/platform/Director.h> | ||||||
| #include <kiwano/2d/Actor.h> | #include <kiwano/2d/Actor.h> | ||||||
| #include <kiwano/2d/Stage.h> | #include <kiwano/2d/Stage.h> | ||||||
| #include <kiwano/2d/Transition.h> | #include <kiwano/2d/Transition.h> | ||||||
|  | @ -180,7 +180,7 @@ namespace kiwano | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Director::HandleEvent(Event* evt) | 	void Director::HandleEvent(Event& evt) | ||||||
| 	{ | 	{ | ||||||
| 		if (debug_actor_) | 		if (debug_actor_) | ||||||
| 			debug_actor_->Dispatch(evt); | 			debug_actor_->Dispatch(evt); | ||||||
|  | @ -72,7 +72,7 @@ namespace kiwano | ||||||
| 
 | 
 | ||||||
| 		void OnRender(RenderTarget* rt) override; | 		void OnRender(RenderTarget* rt) override; | ||||||
| 
 | 
 | ||||||
| 		void HandleEvent(Event* evt) override; | 		void HandleEvent(Event& evt) override; | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		Director(); | 		Director(); | ||||||
|  | @ -103,14 +103,14 @@ namespace kiwano | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	void Button::UpdateStatus(Event* evt) | 	void Button::UpdateStatus(Event& evt) | ||||||
| 	{ | 	{ | ||||||
| 		auto mouse_evt = evt->SafeCast<MouseEvent>(); | 		auto mouse_evt = evt.SafeCast<MouseEvent>(); | ||||||
| 		KGE_ASSERT(mouse_evt); | 		KGE_ASSERT(mouse_evt); | ||||||
| 
 | 
 | ||||||
| 		if (enabled_ && (mouse_evt->target == this)) | 		if (enabled_ && (mouse_evt->target == this)) | ||||||
| 		{ | 		{ | ||||||
| 			if (evt->type == event::MouseHover) | 			if (evt.type == event::MouseHover) | ||||||
| 			{ | 			{ | ||||||
| 				SetStatus(Status::Hover); | 				SetStatus(Status::Hover); | ||||||
| 				Window::GetInstance()->SetCursor(CursorType::Hand); | 				Window::GetInstance()->SetCursor(CursorType::Hand); | ||||||
|  | @ -118,7 +118,7 @@ namespace kiwano | ||||||
| 				if (mouse_over_callback_) | 				if (mouse_over_callback_) | ||||||
| 					mouse_over_callback_(); | 					mouse_over_callback_(); | ||||||
| 			} | 			} | ||||||
| 			else if (evt->type == event::MouseOut) | 			else if (evt.type == event::MouseOut) | ||||||
| 			{ | 			{ | ||||||
| 				SetStatus(Status::Normal); | 				SetStatus(Status::Normal); | ||||||
| 				Window::GetInstance()->SetCursor(CursorType::Arrow); | 				Window::GetInstance()->SetCursor(CursorType::Arrow); | ||||||
|  | @ -126,14 +126,14 @@ namespace kiwano | ||||||
| 				if (mouse_out_callback_) | 				if (mouse_out_callback_) | ||||||
| 					mouse_out_callback_(); | 					mouse_out_callback_(); | ||||||
| 			} | 			} | ||||||
| 			else if (evt->type == event::MouseDown && status_ == Status::Hover) | 			else if (evt.type == event::MouseDown && status_ == Status::Hover) | ||||||
| 			{ | 			{ | ||||||
| 				SetStatus(Status::Pressed); | 				SetStatus(Status::Pressed); | ||||||
| 
 | 
 | ||||||
| 				if (pressed_callback_) | 				if (pressed_callback_) | ||||||
| 					pressed_callback_(); | 					pressed_callback_(); | ||||||
| 			} | 			} | ||||||
| 			else if (evt->type == event::MouseUp && status_ == Status::Pressed) | 			else if (evt.type == event::MouseUp && status_ == Status::Pressed) | ||||||
| 			{ | 			{ | ||||||
| 				SetStatus(Status::Hover); | 				SetStatus(Status::Hover); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -84,7 +84,7 @@ namespace kiwano | ||||||
| 			Status status | 			Status status | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		void UpdateStatus(Event* evt); | 		void UpdateStatus(Event& evt); | ||||||
| 
 | 
 | ||||||
| 	private: | 	private: | ||||||
| 		bool		enabled_; | 		bool		enabled_; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue