YSTest: Hover.cpp 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

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

- 文件列表
- 文件成员

Hover.cpp
浏览该文件的文档.
1 /*
2 © 2013-2015 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 #include "YSLib/UI/YModules.h"
29 #include YFM_YSLib_UI_Hover
30 #include YFM_YSLib_UI_YControl
31 #include YFM_YSLib_UI_YUIContainer
32
33 namespace YSLib
34 {
35
36 namespace UI
37 {
38
39 HoverUpdater::HoverUpdater(IWidget& wgt)
40 : Widget(wgt)
41 {
42 yunseq(
43 FetchEvent<Enter>(wgt) += [this]{
44 entered = true,
45 Invalidate(Widget);
46 },
47 FetchEvent<Leave>(wgt) += [this]{
48 entered = false,
49 Invalidate(Widget);
50 }
51 );
52 }
53
54
55 yconstexpr const Timers::Duration TimedHoverState::DefaultDuration;
56
57 bool
58 TimedHoverState::Check() ynothrow
59 {
60 if(state == Outside)
61 {
62 Activate(tmr),
63 state = Over;
64 }
65 if(state == Over && tmr.Refresh())
66 {
67 state = Left;
68 return true;
69 }
70 return {};
71 }
72
73 Point
74 TimedHoverState::DefaultLocate(const CursorEventArgs& e) ynothrow
75 {
76 return e.Position;
77 }
78
79 void
80 TimedHoverState::Leave() ynothrow
81 {
82 if(state == Left)
83 Reset();
84 }
85
86 Point
87 TimedHoverState::LocateForOffset(const CursorEventArgs& e, const Point& pt)
88 {
89 return LocateForTopOffset(e.Position, e.GetSender(), pt);
90 }
91
92 bool
93 TimedHoverState::Update(const Point& pt) ynothrow
94 {
95 if(Position != pt)
96 {
97 Position = pt;
98 Leave();
99 return true;
100 }
101 return {};
102 }
103
104 } // namespace UI;
105
106 } // namespace YSLib;
107
YSLib::UI::ynothrow
AView &y ynothrow
Definition: YWidgetView.cpp:47
YSLib::UI::LocateForTopOffset
Point LocateForTopOffset(const Point &origin, IWidget &wgt, const Point &pt)
Definition: YUIContainer.cpp:91
YSLib::UI::Leave
控件离开。
Definition: YWidgetEvent.h:424
YSLib::UI::HoverUpdater::entered
bool entered
Definition: Hover.h:51
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
UI
YSLib::UI::wgt
IWidget & wgt
Definition: YControl.h:112
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:679
YSLib::Drawing::Point
GBinaryGroup< SPos > Point
屏幕二维点（直角坐标表示）。
Definition: YGDIBase.h:278
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:1022
YSLib::UI::Invalidate
YF_API void Invalidate(IWidget &, const Rect &)
无效化：使相对部件的指定区域在直接和间接的窗口缓冲区中无效。
Definition: YWidget.cpp:108
YSLib::UI::Widget
部件。
Definition: YWidget.h:369
YSLib::UI::HoverUpdater::HoverUpdater
HoverUpdater(IWidget &)
Definition: Hover.cpp:39
YSLib::UI::Activate
void Activate(Console &, Drawing::Color, Drawing::Color)
Definition: Console.cpp:45
YSLib::UI::e
void e
Definition: YWidget.h:352
YModules.h
platform_ex::Reset
unsigned long Reset(COMPtr< _iCOM > &ptr) ynothrow
Definition: COM.h:406
YSLib::Timers::Duration
HighResolutionClock::duration Duration
高精度时间间隔。
Definition: YClock.h:68
YSLib::UI::CursorState::Over