YSTest: ygui.h 源文件

YSTest PreAlpha_b400_20130424 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
ygui.h
浏览该文件的文档.
1 ﻿/*
2 Copyright by FrankHB 2009 - 2013.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YSL_INC_UI_ygui_h_
29 #define YSL_INC_UI_ygui_h_ 1
30
31 #include "ywgtevt.h"
32 #include "../Service/ytimer.h"
33 #include "ystyle.h"
34
35 YSL_BEGIN
36
37 YSL_BEGIN_NAMESPACE(UI)
38
39
46 class YF_API InputTimer
47 {
48 public:
49 typedef Timers::Duration Duration;
53 typedef enum
54 {
55 Free = 0,
56 Pressed = 1,
57 Held = 2
58 } HeldStateType;
59
60 private:
61 Timers::Timer timer;
62
63 public:
64 InputTimer(const Duration& = Timers::TimeSpan(1000U));
65
70 PDefH(void, Delay, const Duration& d)
71 ImplBodyMem(timer, Delay, d)
72
73
76 bool
77 Refresh(HeldStateType&, const Duration& = Timers::TimeSpan(240),
78 const Duration& = Timers::TimeSpan(120));
79
83 void
84 Reset();
85 };
86
87
93 YF_API bool
94 RepeatHeld(InputTimer&, InputTimer::HeldStateType&,
95 const Timers::Duration&, const Timers::Duration&);
96
97
103 class YF_API GUIState : private noncopyable, private nonmovable
104 {
105 public:
110 InputTimer::HeldStateType KeyHeldState, TouchHeldState;
111 Drawing::Vec DraggingOffset;
112
116 InputTimer HeldTimer;
117 Drawing::Point ControlLocation, LastControlLocation; \
119 Styles::Palette Colors;
120
121 private:
122 //独立焦点指针：自由状态时即时输入（按下）状态捕获的控件指针。
123 IWidget* p_KeyDown;
124 IWidget* p_TouchDown;
125 bool control_entered;
126
127 public:
128 GUIState() ynothrow;
129
130 DefPred(const ynothrow, ControlEntered, control_entered)
131
132 DefGetter(const ynothrow, IWidget*, KeyDownPtr, p_KeyDown) \
133 //独立键焦点指针。
134 DefGetter(const ynothrow, IWidget*, TouchDownPtr, p_TouchDown) \
135 //独立屏幕焦点指针。
136
142 void
143 Reset();
144
148 void
149 ResetHeldState(InputTimer::HeldStateType&);
150
151 private:
152 void
153 TryEntering(TouchEventArgs&&);
154
155 void
156 TryLeaving(TouchEventArgs&&);
157
158 public:
163 bool
164 ResponseKeyBase(KeyEventArgs&, VisualEvent);
165
170 bool
171 ResponseTouchBase(TouchEventArgs&, VisualEvent);
172
177 bool
178 ResponseKey(KeyEventArgs&, VisualEvent);
179
184 bool
185 ResponseTouch(TouchEventArgs&, VisualEvent);
186 };
187
188
194 YF_API GUIState&
195 FetchGUIState();
196
197
198 /*
199 \brief 判断指定部件是否被句柄指定的图形用户界面状态锁定为独立焦点。
200 \since build 287
201 */
202 inline bool
203 IsFocusedByShell(const IWidget& wgt, const GUIState& st = FetchGUIState())
204 {
205 return st.GetTouchDownPtr() == &wgt;
206 }
207
208 YSL_END_NAMESPACE(UI)
209
210 YSL_END
211
212 #endif
213