Update Event
This commit is contained in:
parent
56dea4c055
commit
1e530411ae
|
|
@ -12,7 +12,11 @@
|
|||
<ClInclude Include="..\..\src\kiwano\2d\Frame.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\2d\GifSprite.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\common.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\Event.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\event\Event.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\event\EventType.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\event\KeyEvent.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\event\MouseEvent.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\event\WindowEvent.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\Library.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\kiwano.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\config.h" />
|
||||
|
|
@ -107,9 +111,12 @@
|
|||
<ClCompile Include="..\..\src\kiwano\2d\Transition.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\AsyncTask.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\Component.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\Event.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\EventDispatcher.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\EventListener.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\event\Event.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\event\KeyEvent.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\event\MouseEvent.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\event\WindowEvent.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\Library.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\Logger.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\ObjectBase.cpp" />
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@
|
|||
<Filter Include="platform\win32">
|
||||
<UniqueIdentifier>{e84dcf9a-e650-473e-8c9c-193804ab9e76}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="core\event">
|
||||
<UniqueIdentifier>{c629aedd-ffb9-4bc1-82c3-f50e77c82e77}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\kiwano\ui\Button.h">
|
||||
|
|
@ -228,9 +231,6 @@
|
|||
<ClInclude Include="..\..\src\kiwano\core\Library.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\core\Event.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\platform\FileSystem.h">
|
||||
<Filter>platform</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -273,6 +273,21 @@
|
|||
<ClInclude Include="..\..\src\kiwano\platform\win32\helper.h">
|
||||
<Filter>platform\win32</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\core\event\Event.h">
|
||||
<Filter>core\event</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\core\event\EventType.h">
|
||||
<Filter>core\event</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\core\event\KeyEvent.h">
|
||||
<Filter>core\event</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\core\event\MouseEvent.h">
|
||||
<Filter>core\event</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\core\event\WindowEvent.h">
|
||||
<Filter>core\event</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\kiwano\ui\Button.cpp">
|
||||
|
|
@ -431,9 +446,6 @@
|
|||
<ClCompile Include="..\..\src\kiwano\core\Library.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\core\Event.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\platform\FileSystem.cpp">
|
||||
<Filter>platform</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -461,5 +473,17 @@
|
|||
<ClCompile Include="..\..\src\kiwano\platform\win32\StackWalker.cpp">
|
||||
<Filter>platform\win32</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\core\event\Event.cpp">
|
||||
<Filter>core\event</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\core\event\KeyEvent.cpp">
|
||||
<Filter>core\event</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\core\event\MouseEvent.cpp">
|
||||
<Filter>core\event</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\core\event\WindowEvent.cpp">
|
||||
<Filter>core\event</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
#include <kiwano/core/Event.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
Event::Event(EventType const& type)
|
||||
: type_(type)
|
||||
{
|
||||
}
|
||||
|
||||
Event::~Event()
|
||||
{
|
||||
}
|
||||
|
||||
MouseEvent::MouseEvent(EventType const& type)
|
||||
: Event(type)
|
||||
, pos()
|
||||
, left_btn_down(false)
|
||||
, right_btn_down(false)
|
||||
, target(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
MouseMoveEvent::MouseMoveEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseMoveEvent))
|
||||
{
|
||||
}
|
||||
|
||||
MouseDownEvent::MouseDownEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseDownEvent))
|
||||
, button(0)
|
||||
{
|
||||
}
|
||||
|
||||
MouseUpEvent::MouseUpEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseUpEvent))
|
||||
, button(0)
|
||||
{
|
||||
}
|
||||
|
||||
MouseClickEvent::MouseClickEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseClickEvent))
|
||||
, button(0)
|
||||
{
|
||||
}
|
||||
|
||||
MouseHoverEvent::MouseHoverEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseHoverEvent))
|
||||
{
|
||||
}
|
||||
|
||||
MouseOutEvent::MouseOutEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseOutEvent))
|
||||
{
|
||||
}
|
||||
|
||||
MouseWheelEvent::MouseWheelEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseWheelEvent))
|
||||
, wheel(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
KeyDownEvent::KeyDownEvent()
|
||||
: Event(KGE_EVENT(KeyDownEvent))
|
||||
, code(0)
|
||||
{
|
||||
}
|
||||
|
||||
KeyUpEvent::KeyUpEvent()
|
||||
: Event(KGE_EVENT(KeyUpEvent))
|
||||
, code(0)
|
||||
{
|
||||
}
|
||||
|
||||
KeyCharEvent::KeyCharEvent()
|
||||
: Event(KGE_EVENT(KeyCharEvent))
|
||||
, value()
|
||||
{
|
||||
}
|
||||
|
||||
WindowMovedEvent::WindowMovedEvent()
|
||||
: Event(KGE_EVENT(WindowMovedEvent))
|
||||
, x(0)
|
||||
, y(0)
|
||||
{
|
||||
}
|
||||
|
||||
WindowResizedEvent::WindowResizedEvent()
|
||||
: Event(KGE_EVENT(WindowResizedEvent))
|
||||
, width(0)
|
||||
, height(0)
|
||||
{
|
||||
}
|
||||
|
||||
WindowFocusChangedEvent::WindowFocusChangedEvent()
|
||||
: Event(KGE_EVENT(WindowFocusChangedEvent))
|
||||
, focus(false)
|
||||
{
|
||||
}
|
||||
|
||||
WindowTitleChangedEvent::WindowTitleChangedEvent()
|
||||
: Event(KGE_EVENT(WindowTitleChangedEvent))
|
||||
, title()
|
||||
{
|
||||
}
|
||||
|
||||
WindowClosedEvent::WindowClosedEvent()
|
||||
: Event(KGE_EVENT(WindowClosedEvent))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,333 +0,0 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <typeinfo>
|
||||
#include <typeindex>
|
||||
#include <kiwano/core/common.h>
|
||||
#include <kiwano/math/math.h>
|
||||
#include <kiwano/core/keys.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
class Actor;
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 事件类型
|
||||
class EventType
|
||||
: public std::type_index
|
||||
{
|
||||
class Dummy { };
|
||||
|
||||
public:
|
||||
/// \~chinese
|
||||
/// @brief 构建事件类型
|
||||
EventType() : std::type_index(typeid(EventType::Dummy)) {}
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构建事件类型
|
||||
/// @param info 事件标识符
|
||||
EventType(const type_info& info) : std::type_index(info) {}
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 构建事件类型
|
||||
/// @param index 事件标识符
|
||||
EventType(const std::type_index& index) : std::type_index(index) {}
|
||||
};
|
||||
|
||||
#define KGE_EVENT(EVENT_TYPE) ::kiwano::EventType(typeid(EVENT_TYPE))
|
||||
|
||||
|
||||
/**
|
||||
* \~chinese
|
||||
* \defgroup Events 事件
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup Events
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 事件
|
||||
class KGE_API Event
|
||||
{
|
||||
public:
|
||||
/// \~chinese
|
||||
/// @brief 构造事件
|
||||
Event(EventType const& type);
|
||||
|
||||
virtual ~Event();
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 获取类型事件
|
||||
inline const EventType& GetType() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 判断事件类型
|
||||
/// @return 是否是指定事件类型
|
||||
template <
|
||||
typename _Ty,
|
||||
typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type
|
||||
>
|
||||
inline bool IsType() const
|
||||
{
|
||||
return type_ == KGE_EVENT(_Ty);
|
||||
}
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 转换为其他类型事件
|
||||
/// @throw std::bad_cast 类型无法转换时抛出
|
||||
template <
|
||||
typename _Ty,
|
||||
typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type
|
||||
>
|
||||
inline const _Ty& Cast() const
|
||||
{
|
||||
return dynamic_cast<const _Ty&>(*this);
|
||||
}
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 转换为其他类型事件
|
||||
/// @throw std::bad_cast 类型无法转换时抛出
|
||||
template <
|
||||
typename _Ty,
|
||||
typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type
|
||||
>
|
||||
inline _Ty& Cast()
|
||||
{
|
||||
return dynamic_cast<_Ty&>(*this);
|
||||
}
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 安全转换为其他类型事件
|
||||
/// @throw std::bad_cast 类型无法转换时抛出
|
||||
template <
|
||||
typename _Ty,
|
||||
typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type
|
||||
>
|
||||
inline const _Ty& SafeCast() const
|
||||
{
|
||||
if (!IsType<_Ty>())
|
||||
throw std::bad_cast();
|
||||
return Cast<_Ty>();
|
||||
}
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 安全转换为其他类型事件
|
||||
/// @throw std::bad_cast 类型无法转换时抛出
|
||||
template <
|
||||
typename _Ty,
|
||||
typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type
|
||||
>
|
||||
inline _Ty& SafeCast()
|
||||
{
|
||||
return const_cast<_Ty&>(const_cast<const Event*>(this)->SafeCast<_Ty>());
|
||||
}
|
||||
|
||||
private:
|
||||
const EventType type_;
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 事件特性:判断是否是事件类型
|
||||
template <typename _Ty>
|
||||
class IsEvent : public std::bool_constant<std::is_base_of<Event, _Ty>::value || std::is_same<Event, _Ty>::value> {};
|
||||
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标事件
|
||||
class KGE_API MouseEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
Point pos; ///< 鼠标位置
|
||||
bool left_btn_down; ///< 鼠标左键是否按下
|
||||
bool right_btn_down; ///< 鼠标右键是否按下
|
||||
Actor* target; ///< 目标
|
||||
|
||||
MouseEvent(EventType const& type);
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标移动事件
|
||||
class KGE_API MouseMoveEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
MouseMoveEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标按键按下事件
|
||||
class KGE_API MouseDownEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
MouseButton::Value button; ///< 鼠标键值
|
||||
|
||||
MouseDownEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标按键抬起事件
|
||||
class KGE_API MouseUpEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
MouseButton::Value button; ///< 鼠标键值
|
||||
|
||||
MouseUpEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标点击事件
|
||||
class KGE_API MouseClickEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
MouseButton::Value button; ///< 鼠标键值
|
||||
|
||||
MouseClickEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标移入事件
|
||||
class KGE_API MouseHoverEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
MouseHoverEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标移出事件
|
||||
class KGE_API MouseOutEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
MouseOutEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标滚轮事件
|
||||
class KGE_API MouseWheelEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
float wheel; ///< 滚轮值
|
||||
|
||||
MouseWheelEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 键盘按下事件
|
||||
class KGE_API KeyDownEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
KeyCode::Value code; ///< 键值
|
||||
|
||||
KeyDownEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 键盘抬起事件
|
||||
class KGE_API KeyUpEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
KeyCode::Value code; ///< 键值
|
||||
|
||||
KeyUpEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 键盘字符事件
|
||||
class KGE_API KeyCharEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
char value; ///< 字符
|
||||
|
||||
KeyCharEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 窗口移动事件
|
||||
class KGE_API WindowMovedEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
int x; ///< 窗口左上角 x 坐标
|
||||
int y; ///< 窗口左上角 y 坐标
|
||||
|
||||
WindowMovedEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 窗口大小变化事件
|
||||
class KGE_API WindowResizedEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
int width; ///< 窗口宽度
|
||||
int height; ///< 窗口高度
|
||||
|
||||
WindowResizedEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 窗口焦点变化事件
|
||||
class KGE_API WindowFocusChangedEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
bool focus; ///< 是否获取到焦点
|
||||
|
||||
WindowFocusChangedEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 窗口标题更改事件
|
||||
class KGE_API WindowTitleChangedEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
String title; ///< 标题
|
||||
|
||||
WindowTitleChangedEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 窗口关闭事件
|
||||
class KGE_API WindowClosedEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
WindowClosedEvent();
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
}
|
||||
|
|
@ -22,7 +22,10 @@
|
|||
#include <kiwano/core/common.h>
|
||||
#include <kiwano/core/SmartPtr.hpp>
|
||||
#include <kiwano/core/ObjectBase.h>
|
||||
#include <kiwano/core/Event.h>
|
||||
#include <kiwano/core/event/Event.h>
|
||||
#include <kiwano/core/event/MouseEvent.h>
|
||||
#include <kiwano/core/event/KeyEvent.h>
|
||||
#include <kiwano/core/event/WindowEvent.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
#include <kiwano/core/event/Event.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
Event::Event(EventType const& type)
|
||||
: type_(type)
|
||||
{
|
||||
}
|
||||
|
||||
Event::~Event()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <kiwano/core/event/EventType.h>
|
||||
#include <kiwano/math/math.h>
|
||||
#include <kiwano/core/keys.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
/**
|
||||
* \~chinese
|
||||
* \defgroup Events 事件
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup Events
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 事件
|
||||
class KGE_API Event
|
||||
{
|
||||
public:
|
||||
/// \~chinese
|
||||
/// @brief 构造事件
|
||||
Event(EventType const& type);
|
||||
|
||||
virtual ~Event();
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 获取类型事件
|
||||
const EventType& GetType() const;
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 判断事件类型
|
||||
/// @return 是否是指定事件类型
|
||||
template <
|
||||
typename _Ty,
|
||||
typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type
|
||||
>
|
||||
bool IsType() const;
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 安全转换为其他类型事件
|
||||
/// @throw std::bad_cast 类型无法转换时抛出
|
||||
template <
|
||||
typename _Ty,
|
||||
typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type
|
||||
>
|
||||
const _Ty& SafeCast() const;
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 安全转换为其他类型事件
|
||||
/// @throw std::bad_cast 类型无法转换时抛出
|
||||
template <
|
||||
typename _Ty,
|
||||
typename = typename std::enable_if<std::is_base_of<Event, _Ty>::value, int>::type
|
||||
>
|
||||
_Ty& SafeCast();
|
||||
|
||||
private:
|
||||
const EventType type_;
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 事件特性:判断是否是事件类型
|
||||
template <typename _Ty>
|
||||
struct IsEvent : public std::bool_constant<std::is_base_of<Event, _Ty>::value || std::is_same<Event, _Ty>::value>
|
||||
{
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 事件特性:判断是否是事件类型
|
||||
template <typename _Ty, typename = typename std::enable_if<IsEvent<_Ty>::value, int>::type>
|
||||
struct IsEventType
|
||||
{
|
||||
inline bool operator()(const Event& evt) const
|
||||
{
|
||||
return evt.GetType() == KGE_EVENT(_Ty);
|
||||
}
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
inline const EventType& Event::GetType() const
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
template <typename _Ty, typename>
|
||||
inline bool Event::IsType() const
|
||||
{
|
||||
return kiwano::IsEventType<_Ty>()(*this);
|
||||
}
|
||||
|
||||
template <typename _Ty, typename>
|
||||
inline const _Ty& Event::SafeCast() const
|
||||
{
|
||||
if (!IsType<_Ty>())
|
||||
throw std::bad_cast();
|
||||
return dynamic_cast<const _Ty&>(*this);
|
||||
}
|
||||
|
||||
template <typename _Ty, typename>
|
||||
inline _Ty& Event::SafeCast()
|
||||
{
|
||||
return const_cast<_Ty&>(const_cast<const Event*>(this)->SafeCast<_Ty>());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <typeinfo>
|
||||
#include <typeindex>
|
||||
#include <kiwano/core/common.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
/**
|
||||
* \addtogroup Events
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// \~chinese
|
||||
/// @brief ʼþÀàÐÍ
|
||||
class EventType
|
||||
: public std::type_index
|
||||
{
|
||||
class Dummy { };
|
||||
|
||||
public:
|
||||
/// \~chinese
|
||||
/// @brief ¹¹½¨Ê¼þÀàÐÍ
|
||||
EventType();
|
||||
|
||||
using std::type_index::type_index;
|
||||
using std::type_index::operator==;
|
||||
using std::type_index::operator!=;
|
||||
using std::type_index::operator<;
|
||||
using std::type_index::operator>=;
|
||||
using std::type_index::operator>;
|
||||
using std::type_index::operator<=;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
#define KGE_EVENT(EVENT_TYPE) ::kiwano::EventType(typeid(EVENT_TYPE))
|
||||
|
||||
|
||||
inline EventType::EventType()
|
||||
: std::type_index(typeid(EventType::Dummy))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#include <kiwano/core/event/KeyEvent.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
KeyDownEvent::KeyDownEvent()
|
||||
: Event(KGE_EVENT(KeyDownEvent))
|
||||
, code(0)
|
||||
{
|
||||
}
|
||||
|
||||
KeyUpEvent::KeyUpEvent()
|
||||
: Event(KGE_EVENT(KeyUpEvent))
|
||||
, code(0)
|
||||
{
|
||||
}
|
||||
|
||||
KeyCharEvent::KeyCharEvent()
|
||||
: Event(KGE_EVENT(KeyCharEvent))
|
||||
, value()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <kiwano/core/event/Event.h>
|
||||
#include <kiwano/core/keys.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
/**
|
||||
* \addtogroup Events
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 键盘事件
|
||||
class KGE_API KeyEvent
|
||||
: public Event
|
||||
{
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 键盘按下事件
|
||||
class KGE_API KeyDownEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
KeyCode::Value code; ///< 键值
|
||||
|
||||
KeyDownEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 键盘抬起事件
|
||||
class KGE_API KeyUpEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
KeyCode::Value code; ///< 键值
|
||||
|
||||
KeyUpEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 键盘字符事件
|
||||
class KGE_API KeyCharEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
char value; ///< 字符
|
||||
|
||||
KeyCharEvent();
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
template <>
|
||||
struct IsEventType<KeyEvent>
|
||||
{
|
||||
inline bool operator()(const Event& evt) const
|
||||
{
|
||||
return evt.GetType() == KGE_EVENT(KeyDownEvent)
|
||||
|| evt.GetType() == KGE_EVENT(KeyUpEvent)
|
||||
|| evt.GetType() == KGE_EVENT(KeyCharEvent);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
#include <kiwano/core/event/MouseEvent.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
MouseEvent::MouseEvent(EventType const& type)
|
||||
: Event(type)
|
||||
, pos()
|
||||
, left_btn_down(false)
|
||||
, right_btn_down(false)
|
||||
, target(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
MouseMoveEvent::MouseMoveEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseMoveEvent))
|
||||
{
|
||||
}
|
||||
|
||||
MouseDownEvent::MouseDownEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseDownEvent))
|
||||
, button(0)
|
||||
{
|
||||
}
|
||||
|
||||
MouseUpEvent::MouseUpEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseUpEvent))
|
||||
, button(0)
|
||||
{
|
||||
}
|
||||
|
||||
MouseClickEvent::MouseClickEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseClickEvent))
|
||||
, button(0)
|
||||
{
|
||||
}
|
||||
|
||||
MouseHoverEvent::MouseHoverEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseHoverEvent))
|
||||
{
|
||||
}
|
||||
|
||||
MouseOutEvent::MouseOutEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseOutEvent))
|
||||
{
|
||||
}
|
||||
|
||||
MouseWheelEvent::MouseWheelEvent()
|
||||
: MouseEvent(KGE_EVENT(MouseWheelEvent))
|
||||
, wheel(0.f)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <kiwano/core/event/Event.h>
|
||||
#include <kiwano/math/math.h>
|
||||
#include <kiwano/core/keys.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
class Actor;
|
||||
|
||||
/**
|
||||
* \addtogroup Events
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标事件
|
||||
class KGE_API MouseEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
Point pos; ///< 鼠标位置
|
||||
bool left_btn_down; ///< 鼠标左键是否按下
|
||||
bool right_btn_down; ///< 鼠标右键是否按下
|
||||
Actor* target; ///< 目标
|
||||
|
||||
MouseEvent(EventType const& type);
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标移动事件
|
||||
class KGE_API MouseMoveEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
MouseMoveEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标按键按下事件
|
||||
class KGE_API MouseDownEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
MouseButton::Value button; ///< 鼠标键值
|
||||
|
||||
MouseDownEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标按键抬起事件
|
||||
class KGE_API MouseUpEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
MouseButton::Value button; ///< 鼠标键值
|
||||
|
||||
MouseUpEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标点击事件
|
||||
class KGE_API MouseClickEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
MouseButton::Value button; ///< 鼠标键值
|
||||
|
||||
MouseClickEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标移入事件
|
||||
class KGE_API MouseHoverEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
MouseHoverEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标移出事件
|
||||
class KGE_API MouseOutEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
MouseOutEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 鼠标滚轮事件
|
||||
class KGE_API MouseWheelEvent
|
||||
: public MouseEvent
|
||||
{
|
||||
public:
|
||||
float wheel; ///< 滚轮值
|
||||
|
||||
MouseWheelEvent();
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
template <>
|
||||
struct IsEventType<MouseEvent>
|
||||
{
|
||||
inline bool operator()(const Event& evt) const
|
||||
{
|
||||
return evt.GetType() == KGE_EVENT(MouseMoveEvent)
|
||||
|| evt.GetType() == KGE_EVENT(MouseDownEvent)
|
||||
|| evt.GetType() == KGE_EVENT(MouseUpEvent)
|
||||
|| evt.GetType() == KGE_EVENT(MouseClickEvent)
|
||||
|| evt.GetType() == KGE_EVENT(MouseHoverEvent)
|
||||
|| evt.GetType() == KGE_EVENT(MouseOutEvent)
|
||||
|| evt.GetType() == KGE_EVENT(MouseWheelEvent);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#include <kiwano/core/event/WindowEvent.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
WindowMovedEvent::WindowMovedEvent()
|
||||
: Event(KGE_EVENT(WindowMovedEvent))
|
||||
, x(0)
|
||||
, y(0)
|
||||
{
|
||||
}
|
||||
|
||||
WindowResizedEvent::WindowResizedEvent()
|
||||
: Event(KGE_EVENT(WindowResizedEvent))
|
||||
, width(0)
|
||||
, height(0)
|
||||
{
|
||||
}
|
||||
|
||||
WindowFocusChangedEvent::WindowFocusChangedEvent()
|
||||
: Event(KGE_EVENT(WindowFocusChangedEvent))
|
||||
, focus(false)
|
||||
{
|
||||
}
|
||||
|
||||
WindowTitleChangedEvent::WindowTitleChangedEvent()
|
||||
: Event(KGE_EVENT(WindowTitleChangedEvent))
|
||||
, title()
|
||||
{
|
||||
}
|
||||
|
||||
WindowClosedEvent::WindowClosedEvent()
|
||||
: Event(KGE_EVENT(WindowClosedEvent))
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <kiwano/core/event/Event.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
/**
|
||||
* \addtogroup Events
|
||||
* @{
|
||||
*/
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 窗口事件
|
||||
class KGE_API WindowEvent
|
||||
: public Event
|
||||
{
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 窗口移动事件
|
||||
class KGE_API WindowMovedEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
int x; ///< 窗口左上角 x 坐标
|
||||
int y; ///< 窗口左上角 y 坐标
|
||||
|
||||
WindowMovedEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 窗口大小变化事件
|
||||
class KGE_API WindowResizedEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
int width; ///< 窗口宽度
|
||||
int height; ///< 窗口高度
|
||||
|
||||
WindowResizedEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 窗口焦点变化事件
|
||||
class KGE_API WindowFocusChangedEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
bool focus; ///< 是否获取到焦点
|
||||
|
||||
WindowFocusChangedEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 窗口标题更改事件
|
||||
class KGE_API WindowTitleChangedEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
String title; ///< 标题
|
||||
|
||||
WindowTitleChangedEvent();
|
||||
};
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 窗口关闭事件
|
||||
class KGE_API WindowClosedEvent
|
||||
: public Event
|
||||
{
|
||||
public:
|
||||
WindowClosedEvent();
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
template <>
|
||||
struct IsEventType<WindowEvent>
|
||||
{
|
||||
inline bool operator()(const Event& evt) const
|
||||
{
|
||||
return evt.GetType() == KGE_EVENT(WindowMovedEvent)
|
||||
|| evt.GetType() == KGE_EVENT(WindowResizedEvent)
|
||||
|| evt.GetType() == KGE_EVENT(WindowFocusChangedEvent)
|
||||
|| evt.GetType() == KGE_EVENT(WindowTitleChangedEvent)
|
||||
|| evt.GetType() == KGE_EVENT(WindowClosedEvent);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -49,7 +49,10 @@
|
|||
#include <kiwano/core/Logger.h>
|
||||
#include <kiwano/core/SmartPtr.hpp>
|
||||
#include <kiwano/core/ObjectBase.h>
|
||||
#include <kiwano/core/Event.h>
|
||||
#include <kiwano/core/event/Event.h>
|
||||
#include <kiwano/core/event/MouseEvent.h>
|
||||
#include <kiwano/core/event/KeyEvent.h>
|
||||
#include <kiwano/core/event/WindowEvent.h>
|
||||
#include <kiwano/core/EventListener.h>
|
||||
#include <kiwano/core/EventDispatcher.h>
|
||||
#include <kiwano/core/Timer.h>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,10 @@
|
|||
#include <kiwano/core/common.h>
|
||||
#include <kiwano/core/time.h>
|
||||
#include <kiwano/core/Component.h>
|
||||
#include <kiwano/core/Event.h>
|
||||
#include <kiwano/core/event/Event.h>
|
||||
#include <kiwano/core/event/MouseEvent.h>
|
||||
#include <kiwano/core/event/KeyEvent.h>
|
||||
#include <kiwano/core/event/WindowEvent.h>
|
||||
#include <kiwano/platform/Window.h>
|
||||
#include <kiwano/renderer/Renderer.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,9 @@ namespace kiwano
|
|||
|
||||
void Button::UpdateStatus(Event& evt)
|
||||
{
|
||||
if (enabled_ && (evt.Cast<MouseEvent>().target == this))
|
||||
KGE_ASSERT(evt.IsType<MouseEvent>());
|
||||
|
||||
if (enabled_ && (evt.SafeCast<MouseEvent>().target == this))
|
||||
{
|
||||
if (evt.IsType<MouseHoverEvent>())
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue