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 
49 {
50 public:
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
97  const Timers::Duration&, const Timers::Duration&);
98 
99 
105 class YF_API GUIState : private noncopyable, private nonmovable
106 {
107 public:
114 
125 
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 
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 
Drawing::Vec DraggingOffset
拖放偏移量。
Definition: ygui.h:113
#define DefPred(_q, _n,...)
Definition: YBaseMacro.h:172
YF_API GUIState & FetchGUIState()
取默认图形用户界面公共状态。
Definition: ygui.cpp:442
Drawing::Point CursorLocation
最近的指针设备操作时的控件全局位置(相对于顶层部件的坐标)。
Definition: ygui.h:123
按键输入事件参数类。
Definition: ywgtevt.h:167
#define YF_API
Definition: Platform.h:64
Timers::Duration Duration
Definition: ygui.h:51
bool IsFocusedByShell(const IWidget &wgt, const GUIState &st=FetchGUIState())
判断指定部件是否被句柄指定的图形用户界面状态锁定为独立焦点。
Definition: ygui.h:318
InputTimer::HeldStateType TouchHeldState
Definition: ygui.h:112
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:180
输入计时器。
Definition: ygui.h:48
PDefH(void, Activate, Console &console, Drawing::Color fc=Drawing::ColorSpace::White) ImplExpr(Activate(console
激活:使用指定屏幕、有效性、前景色和默认背景色。
样式映射。
Definition: ystyle.h:355
不可复制对象:禁止派生类调用默认原型的复制构造函数和复制赋值操作符。
Definition: utility.hpp:75
_tWidget & wgt
Definition: ywgtevt.h:596
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
Styles::Palette Colors
调色板。
Definition: ygui.h:124
默认调色板。
Definition: ystyle.h:214
unsigned long Reset(COMPtr< _iCOM > &ptr) ynothrow
const IWidget &wgt ImplRet(wgt.GetView().IsVisible()) bool YF_API Contains(const IWidget &
判断点是否在部件的可视区域内。
路由事件参数基类。
Definition: ywgtevt.h:93
InputTimer HeldTimer
输入接触保持计时器。
Definition: ygui.h:118
HighResolutionClock::duration Duration
高精度时间间隔。
Definition: ytimer.h:72
HeldStateType
输入保持状态。
Definition: ygui.h:56
图形用户界面公共状态。
Definition: ygui.h:105
std::chrono::milliseconds TimeSpan
低精度时间间隔。
Definition: ytimer.h:85
指针设备输入事件参数类。
Definition: ywgtevt.h:183
std::bitset< KeyBitsetWidth > KeyInput
按键并行位宽。
Definition: Keys.h:68
Styles::StyleMap Styles
样式映射。
Definition: ygui.h:129
计时器。
Definition: ytimer.h:100
YF_API bool RepeatHeld(InputTimer &, InputTimer::HeldStateType &, const Timers::Duration &, const Timers::Duration &)
向指定计时器传递参数,根据状态重复按键。
Definition: ygui.cpp:117