Magic_Game/src/kiwano/core/event/WindowEvent.h

111 lines
3.0 KiB
C
Raw Normal View History

2019-12-31 11:22:23 +08:00
// Copyright (c) 2016-2018 Kiwano - Nomango
2020-01-21 10:09:55 +08:00
//
2019-12-31 11:22:23 +08:00
// 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:
2020-01-21 10:09:55 +08:00
//
2019-12-31 11:22:23 +08:00
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
2020-01-21 10:09:55 +08:00
//
2019-12-31 11:22:23 +08:00
// 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
{
2020-01-21 10:09:55 +08:00
KGE_DECLARE_SMART_PTR(WindowEvent);
KGE_DECLARE_SMART_PTR(WindowMovedEvent);
KGE_DECLARE_SMART_PTR(WindowResizedEvent);
KGE_DECLARE_SMART_PTR(WindowFocusChangedEvent);
KGE_DECLARE_SMART_PTR(WindowTitleChangedEvent);
KGE_DECLARE_SMART_PTR(WindowClosedEvent);
/**
* \addtogroup Events
* @{
*/
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 窗口事件
2020-01-21 10:09:55 +08:00
class KGE_API WindowEvent : public Event
{
public:
WindowEvent(const EventType& type);
};
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 窗口移动事件
2020-01-21 10:09:55 +08:00
class KGE_API WindowMovedEvent : public WindowEvent
{
public:
2020-02-10 17:32:04 +08:00
int x; ///< 窗口左上角 x 坐标
int y; ///< 窗口左上角 y 坐标
2020-01-21 10:09:55 +08:00
WindowMovedEvent();
};
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 窗口大小变化事件
2020-01-21 10:09:55 +08:00
class KGE_API WindowResizedEvent : public WindowEvent
{
public:
2020-02-10 17:32:04 +08:00
uint32_t width; ///< 窗口宽度
uint32_t height; ///< 窗口高度
2020-01-21 10:09:55 +08:00
WindowResizedEvent();
};
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 窗口焦点变化事件
2020-01-21 10:09:55 +08:00
class KGE_API WindowFocusChangedEvent : public WindowEvent
{
public:
2020-02-10 17:32:04 +08:00
bool focus; ///< 是否获取到焦点
2020-01-21 10:09:55 +08:00
WindowFocusChangedEvent();
};
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 窗口标题更改事件
2020-01-21 10:09:55 +08:00
class KGE_API WindowTitleChangedEvent : public WindowEvent
{
public:
2020-02-10 17:32:04 +08:00
String title; ///< 标题
2020-01-21 10:09:55 +08:00
WindowTitleChangedEvent();
};
/// \~chinese
2020-02-10 17:32:04 +08:00
/// @brief 窗口关闭事件
2020-01-21 10:09:55 +08:00
class KGE_API WindowClosedEvent : public WindowEvent
{
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);
}
};
} // namespace kiwano