Kiwano Engine v1.3.x
WindowEvent.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/event/Event.h>
23
24namespace kiwano
25{
26
27class Window;
28
36class KGE_API WindowEvent : public Event
37{
38public:
40
41 WindowEvent(const EventType& type);
42};
43
46class KGE_API WindowMovedEvent : public WindowEvent
47{
48public:
49 int x;
50 int y;
51
53};
54
57class KGE_API WindowResizedEvent : public WindowEvent
58{
59public:
60 uint32_t width;
61 uint32_t height;
62
64};
65
69{
70public:
71 bool focus;
72
74};
75
79{
80public:
81 String title;
82
84};
85
88class KGE_API WindowClosedEvent : public WindowEvent
89{
90public:
92};
93
94template <>
96{
97 inline bool operator()(const Event* evt) const
98 {
99 return evt->GetType() == KGE_EVENT(WindowMovedEvent) || evt->GetType() == KGE_EVENT(WindowResizedEvent)
100 || evt->GetType() == KGE_EVENT(WindowFocusChangedEvent)
101 || evt->GetType() == KGE_EVENT(WindowTitleChangedEvent)
102 || evt->GetType() == KGE_EVENT(WindowClosedEvent);
103 }
104};
105
108} // namespace kiwano
事件类型
Definition: EventType.h:36
事件
Definition: Event.h:43
const EventType & GetType() const
获取类型事件
Definition: Event.h:91
窗口关闭事件
Definition: WindowEvent.h:89
窗口事件
Definition: WindowEvent.h:37
Window * window
窗口
Definition: WindowEvent.h:39
窗口焦点变化事件
Definition: WindowEvent.h:69
bool focus
是否获取到焦点
Definition: WindowEvent.h:71
窗口移动事件
Definition: WindowEvent.h:47
int y
窗口左上角 y 坐标
Definition: WindowEvent.h:50
int x
窗口左上角 x 坐标
Definition: WindowEvent.h:49
窗口大小变化事件
Definition: WindowEvent.h:58
uint32_t width
窗口宽度
Definition: WindowEvent.h:60
uint32_t height
窗口高度
Definition: WindowEvent.h:61
窗口标题更改事件
Definition: WindowEvent.h:79
String title
标题
Definition: WindowEvent.h:81
窗口类,控制窗口标题、大小、图标等
Definition: Window.h:115
事件特性:判断事件类型是否相同
Definition: Event.h:81