YSTest: ygui.h 源文件

YSTest PreAlpha_b500_20140530 The YSLib Test Project

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

- 文件列表
- 文件成员

全部 类 命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 组 页
ygui.h
浏览该文件的文档.
1 /*
2 © 2009-2014 FrankHB.
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 "YModules.h"
32 #include YFM_YSLib_UI_YWidgetEvent
33 #include YFM_YSLib_Service_YTimer
34 #include YFM_YSLib_UI_YStyle
35
36 namespace YSLib
37 {
38
39 namespace UI
40 {
41
48 class YF_API InputTimer : public Timers::Timer
49 {
50 public:
51 using Duration = Timers::Duration;
56 enum HeldStateType
57 {
58 Free = 0,
59 Pressed = 1,
60 Held = 2
61 };
62
63 InputTimer(const Duration& = Timers::TimeSpan(1000U));
64
69 bool
70 RefreshHeld(HeldStateType&, const Duration& = Timers::TimeSpan(240),
71 const Duration& = Timers::TimeSpan(120));
72
78 size_t
79 RefreshClick(size_t, const Duration& = Timers::TimeSpan(400));
80
85 void
86 ResetInput();
87 };
88
89
95 YF_API bool
96 RepeatHeld(InputTimer&, InputTimer::HeldStateType&,
97 const Timers::Duration&, const Timers::Duration&);
98
99
105 class YF_API GUIState : private noncopyable, private nonmovable
106 {
107 public:
112 InputTimer::HeldStateType KeyHeldState, TouchHeldState;
113 Drawing::Vec DraggingOffset;
114
118 InputTimer HeldTimer;
123 Drawing::Point CursorLocation;
124 Styles::Palette Colors;
125
129 Styles::StyleMap Styles;
130
131 private:
136 IWidget* p_CursorOver = {};
141 IWidget* p_indp_focus = {};
146 IWidget* p_cascade_focus = {};
151 bool entered = {};
152
158 KeyInput checked_held{};
159
165 size_t master_key = 0;
166
167 public:
168 GUIState() ynothrow;
169
171 DefPred(const ynothrow, Entered, entered)
172
174 DefGetter(const ynothrow, const KeyInput&, CheckedHeldKeys, checked_held)
176 DefGetter(const ynothrow, IWidget*, CursorOverPtr, p_CursorOver)
178 DefGetter(const ynothrow, IWidget*, IndependentFocusPtr, p_indp_focus) \
179 //独立焦点指针。
180
192 PDefH(bool, CheckHeldState, const KeyInput& keys)
193 ImplRet(CheckHeldState(keys, KeyHeldState))
194 bool
195 CheckHeldState(const KeyInput&, InputTimer::HeldStateType&);
197
204 bool
205 CheckDraggingOffset(IWidget* = {});
206
213 void
214 CleanupReferences(IWidget&);
215
216 private:
221 void
222 HandleCascade(RoutedEventArgs&, IWidget&);
223
224 public:
230 void
231 Reset();
232
238 void
239 ResetHeldState(InputTimer::HeldStateType&, const KeyInput&);
240
242
243
247 void
248 ResponseCursor(CursorEventArgs&, VisualEvent);
249
257 void
258 ResponseCursorBase(CursorEventArgs&, VisualEvent);
260
265 void
266 ResponseKey(KeyEventArgs&, VisualEvent);
267
274 void
275 ResponseKeyBase(KeyEventArgs&, VisualEvent);
277
278 private:
280
281 void
282 TryEntering(CursorEventArgs&&);
283
284 void
285 TryLeaving(CursorEventArgs&&);
286
287 public:
295 char
296 UpdateChar(KeyInput&);
297
299 void
300 Wrap(IWidget&);
302 };
303
304
309 YF_API GUIState&
310 FetchGUIState();
311
312
317 inline bool
318 IsFocusedByShell(const IWidget& wgt, const GUIState& st = FetchGUIState())
319 {
320 return st.GetIndependentFocusPtr() == &wgt;
321 }
322
323 } // namespace UI;
324
325 } // namespace YSLib;
326
327 #endif
328
YSLib::UI::GUIState::DraggingOffset
Drawing::Vec DraggingOffset
拖放偏移量。
Definition: ygui.h:113
ystdex::nonmovable
Definition: utility.hpp:109
YModules.h
DefPred
#define DefPred(_q, _n,...)
Definition: YBaseMacro.h:172
YSLib::UI::FetchGUIState
YF_API GUIState & FetchGUIState()
取默认图形用户界面公共状态。
Definition: ygui.cpp:442
YSLib::UI::GUIState::CursorLocation
Drawing::Point CursorLocation
最近的指针设备操作时的控件全局位置（相对于顶层部件的坐标）。
Definition: ygui.h:123
YSLib::UI::KeyEventArgs
按键输入事件参数类。
Definition: ywgtevt.h:167
YF_API
#define YF_API
Definition: Platform.h:64
YSLib::UI::InputTimer::Duration
Timers::Duration Duration
Definition: ygui.h:51
YSLib::UI::IsFocusedByShell
bool IsFocusedByShell(const IWidget &wgt, const GUIState &st=FetchGUIState())
判断指定部件是否被句柄指定的图形用户界面状态锁定为独立焦点。
Definition: ygui.h:318
YSLib::UI::GUIState::TouchHeldState
InputTimer::HeldStateType TouchHeldState
Definition: ygui.h:112
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:180
YSLib::UI::InputTimer
输入计时器。
Definition: ygui.h:48
YSLib::UI::PDefH
PDefH(void, Activate, Console &console, Drawing::Color fc=Drawing::ColorSpace::White) ImplExpr(Activate(console
激活：使用指定屏幕、有效性、前景色和默认背景色。
YSLib::UI::Styles::StyleMap
样式映射。
Definition: ystyle.h:355
ystdex::noncopyable
不可复制对象：禁止派生类调用默认原型的复制构造函数和复制赋值操作符。
Definition: utility.hpp:75
YSLib::UI::CursorState::Pressed
YSLib::UI::wgt
_tWidget & wgt
Definition: ywgtevt.h:596
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
YSLib::Drawing::GBinaryGroup< SPos >
YSLib::UI::GUIState::Colors
Styles::Palette Colors
调色板。
Definition: ygui.h:124
YSLib::UI::Styles::Palette
默认调色板。
Definition: ystyle.h:214
platform_ex::Reset
unsigned long Reset(COMPtr< _iCOM > &ptr) ynothrow
Definition: include/YCLib/COM.h:406
YSLib::UI::ImplRet
const IWidget &wgt ImplRet(wgt.GetView().IsVisible()) bool YF_API Contains(const IWidget &
判断点是否在部件的可视区域内。
YSLib::UI::RoutedEventArgs
路由事件参数基类。
Definition: ywgtevt.h:93
YSLib::UI::GUIState::HeldTimer
InputTimer HeldTimer
输入接触保持计时器。
Definition: ygui.h:118
YSLib::Timers::Duration
HighResolutionClock::duration Duration
高精度时间间隔。
Definition: ytimer.h:72
YSLib::UI::InputTimer::HeldStateType
HeldStateType
输入保持状态。
Definition: ygui.h:56
YSLib::UI::GUIState
图形用户界面公共状态。
Definition: ygui.h:105
YSLib::Timers::TimeSpan
std::chrono::milliseconds TimeSpan
低精度时间间隔。
Definition: ytimer.h:85
YSLib::UI::CursorEventArgs
指针设备输入事件参数类。
Definition: ywgtevt.h:183
platform::KeyInput
std::bitset< KeyBitsetWidth > KeyInput
按键并行位宽。
Definition: Keys.h:68
YSLib::UI::GUIState::Styles
Styles::StyleMap Styles
样式映射。
Definition: ygui.h:129
YSLib::Timers::Timer
计时器。
Definition: ytimer.h:100
YSLib::UI::RepeatHeld
YF_API bool RepeatHeld(InputTimer &, InputTimer::HeldStateType &, const Timers::Duration &, const Timers::Duration &)
向指定计时器传递参数，根据状态重复按键。
Definition: ygui.cpp:117