YSTest: YGUI.h 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

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

- 文件列表
- 文件成员

YGUI.h
浏览该文件的文档.
1 /*
2 © 2009-2016 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
64 static yconstexpr const Duration DefaultDuration{Timers::TimeSpan(1000U)};
65
67 InputTimer(Duration = DefaultDuration) ynothrow;
69 DefDeCopyCtor(InputTimer)
74 virtual ~InputTimer();
75
80 bool
81 RefreshHeld(HeldStateType&, Duration = Timers::TimeSpan(240),
82 Duration = Timers::TimeSpan(120));
83
89 size_t
90 RefreshTap(size_t, Duration = Timers::TimeSpan(400));
91
96 PDefH(void, ResetInput, Duration d = DefaultDuration)
97 ImplExpr(Interval = d)
98 };
99
100
106 YF_API bool
107 RepeatHeld(InputTimer&, InputTimer::HeldStateType&,
108 const Timers::Duration&, const Timers::Duration&);
109
110
117 YF_API void
118 CallInputEvent(IWidget&, const String&, const KeyInput&);
120 inline PDefH(bool, CallInputEvent, char16_t c, const KeyInput& k, IWidget& wgt)
121 ImplRet(c != char16_t() ? (CallInputEvent(wgt, {c}, k), true) : false)
123
124
130 class YF_API GUIState : private noncopyable, private nonmovable
131 {
132 public:
138 Point CaretLocation{Point::Invalid};
143 Drawing::Point CursorLocation{Point::Invalid};
148 Drawing::Point CursorOverLocation{Point::Invalid};
149 Drawing::Vec DraggingOffset{Vec::Invalid};
150
155 observer_ptr<IWidget> ExternalTextInputFocusPtr = {};
164 InputTimer HeldTimer{};
165 InputTimer::HeldStateType KeyHeldState = InputTimer::Free,
166 TouchHeldState = InputTimer::Free;
172 InputTimer TapTimer{};
177 Size TapArea{4, 4};
184 size_t WidgetIdentity = size_t(-1);
185
186 private:
192 KeyInput checked_held{};
197 bool entered = {};
202 Point entered_top_location{};
208 size_t master_key = 0;
215 size_t shared_wgt_id = size_t(-1);
217
218 observer_ptr<IWidget> p_CursorOver = {};
221 observer_ptr<IWidget> p_cascade_focus = {};
223 observer_ptr<IWidget> p_entered_toplevel = {};
225 observer_ptr<IWidget> p_indp_focus = {};
232 size_t tap_count = 0;
240 Point tap_location{Point::Invalid};
241
242 public:
244 DefPred(const ynothrow, Entered, entered)
246 DefPred(const ynothrow, CursorMoved, CursorLocation != CursorOverLocation)
247
249 DefGetter(const ynothrow, const KeyInput&, CheckedHeldKeys, checked_held)
251 DefGetter(const ynothrow, observer_ptr<IWidget>, CursorOverPtr, p_CursorOver)
253 DefGetter(const ynothrow, observer_ptr<IWidget>, IndependentFocusPtr,
254 p_indp_focus)
256 DefGetter(const ynothrow, size_t, SharedWidgetIdentity, shared_wgt_id)
258 DefGetter(const ynothrow, size_t, TapCount, tap_count)
260 DefGetter(const ynothrow, const Point&, TapLocation, tap_location)
261
273 PDefH(bool, CheckHeldState, const KeyInput& keys)
274 ImplRet(CheckHeldState(keys, KeyHeldState))
275 bool
276 CheckHeldState(const KeyInput&, InputTimer::HeldStateType&);
278
285 bool
286 CheckDraggingOffset(observer_ptr<IWidget> = {});
287
294 void
295 CleanupReferences(IWidget&);
296
297 private:
302 void
303 HandleCascade(RoutedEventArgs&, IWidget&);
304
305 public:
320 size_t
321 RefreshTap(const Point& pt = Point::Invalid,
322 size_t n = 2, const Timers::Duration& delay = Timers::TimeSpan(400));
323
329 void
330 Reset();
331
337 void
338 ResetHeldState(InputTimer::HeldStateType&, const KeyInput&);
339
341
342
346 void
347 ResponseCursor(CursorEventArgs&, VisualEvent);
348
356 void
357 ResponseCursorBase(CursorEventArgs&, VisualEvent);
359
364 void
365 ResponseKey(KeyEventArgs&, VisualEvent);
366
373 void
374 ResponseKeyBase(KeyEventArgs&, VisualEvent);
375
385 PDefH(bool, SendInput, KeyInput& k)
386 ImplRet(SendInput(char16_t(UpdateChar(k)), k))
387 PDefH(bool, SendInput, char16_t c, const KeyInput& k)
388 ImplRet(c != char16_t() ? SendInput(k, {c}) : false)
389 bool
390 SendInput(const KeyInput&, const String&);
392
393 private:
395
396 void
397 TryEntering(CursorEventArgs&&);
398
399 void
400 TryLeaving(CursorEventArgs&&);
401
402 public:
410 char
411 UpdateChar(const KeyInput&);
412
414 void
415 Wrap(IWidget&);
417 };
418
424 YF_API GUIState&
425 FetchGUIState() ynothrow;
426
432 inline PDefH(bool, IsFocusedByShell, const IWidget& wgt,
433 const GUIState& st = FetchGUIState()) ynothrow
434 ImplRet(st.GetIndependentFocusPtr().get() == &wgt)
435
436
441 class YF_API GUIConfiguration
442 {
443 public:
445 Styles::Palette Colors{};
447 Styles::StyleMap Styles{};
448 };
449
455 YF_API GUIConfiguration&
456 FetchGUIConfiguration();
457
458 } // namespace UI;
459
460 } // namespace YSLib;
461
462 #endif
463
YSLib::Timers::Timer
计时器。
Definition: YTimer.h:77
YSLib::UI::InputTimer::Duration
Timers::Duration Duration
Definition: YGUI.h:51
YSLib::UI::PDefH
PDefH(void, DisplayFor, IWidget &wgt, Timers::TimeSpan delay) ImplExpr(Show(wgt)
在一定时间内显示部件。
YSLib::UI::ynothrow
AView &y ynothrow
Definition: YWidgetView.cpp:47
DefPred
#define DefPred(_q, _n,...)
Definition: YBaseMacro.h:232
YSLib::UI::FetchGUIConfiguration
GUIConfiguration & FetchGUIConfiguration()
Definition: YGUI.cpp:519
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
UI
platform::size_t
YF_API size_t
Definition: FileIO.h:1353
NPL::A1::Forms::Wrap
YF_API ContextHandler Wrap(const ContextHandler &)
包装合并子为应用子。
Definition: NPLA1.cpp:1447
YSLib::UI::RepeatHeld
YF_API bool RepeatHeld(InputTimer &, InputTimer::HeldStateType &, const Timers::Duration &, const Timers::Duration &)
向指定计时器传递参数，根据状态重复按键。
Definition: YGUI.cpp:109
YSLib::UI::wgt
IWidget & wgt
Definition: YControl.h:112
YSLib::UI::ImplRet
const IWidget &wgt ImplRet(wgt.GetView().IsVisible()) bool YF_API Contains(const IWidget &
判断点是否在部件的可视区域内。
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:679
YSLib::Drawing::Point
GBinaryGroup< SPos > Point
屏幕二维点（直角坐标表示）。
Definition: YGDIBase.h:278
YSLib::UI::FetchGUIState
GUIState & FetchGUIState() ynothrow
Definition: YGUI.cpp:508
YSLib::UI::VisualEvent
VisualEvent
标准控件事件空间。
Definition: YWidgetEvent.h:370
YSLib::Drawing::GBinaryGroup< SPos >::Invalid
static const GBinaryGroup Invalid
无效（不在屏幕坐标系中）对象。
Definition: YGDIBase.h:58
YSLib::UI::CallInputEvent
YF_API void CallInputEvent(IWidget &, const String &, const KeyInput &)
调用指定部件的 TextInput 事件处理指定的输入。
Definition: YGUI.cpp:120
YF_API
#define YF_API
Definition: Platform.h:56
YSLib::UI::InputTimer::HeldStateType
HeldStateType
输入保持状态。
Definition: YGUI.h:56
platform::KeyInput
std::bitset< KeyBitsetWidth > KeyInput
按键并行位宽。
Definition: Keys.h:67
Timers
YSLib::UI::InputTimer
输入计时器。
Definition: YGUI.h:48
YSLib::Drawing::GBinaryGroup< SPos >
YModules.h
platform_ex::Reset
unsigned long Reset(COMPtr< _iCOM > &ptr) ynothrow
Definition: COM.h:406
ystdex::nonmovable
Definition: base.h:81
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
YSLib::UI::ImplExpr
IWidget bool b ImplExpr(wgt.GetController().SetEnabled(b)) YF_API bool Enable(IWidget &
设置部件可用性，且当可用性改变时无效化部件区域。
YSLib::Timers::Duration
HighResolutionClock::duration Duration
高精度时间间隔。
Definition: YClock.h:68
DefDeCopyCtor
#define DefDeCopyCtor(_t)
Definition: YBaseMacro.h:162
ystdex::noncopyable
不可复制对象：禁止派生类调用默认原型的复制构造函数和复制赋值操作符。
Definition: base.h:41
CHRLib::c
c
Definition: CharacterProcessing.h:81
YSLib::UI::InputTimer::Free
Definition: YGUI.h:58
CHRLib::char16_t
char16_t((*c_ptr<< CHAR_BIT)|c_ptr[1])) inline PDefH(char16_t
取 c_ptr 指向的小端序双字节字符。
CHRLib::d
_tDst * d
Definition: CharacterProcessing.h:139
YSLib::UI::bool
IWidget bool b bool
Definition: YControl.h:121
YSLib::Timers::TimeSpan
std::chrono::duration< Duration::rep, std::milli > TimeSpan
低精度时间间隔。
Definition: YClock.h:81
YSLib::Drawing::Vec
GBinaryGroup< SPos > Vec
屏幕二维向量（直角坐标表示）。
Definition: YGDIBase.h:285
YSLib::UI::CursorState::Pressed
YSLib::Text::String
YSLib 标准字符串（使用 UCS-2 作为内部编码）。
Definition: YString.h:46
ystdex::details::get
get())
Definition: cast.hpp:102