YSTest: Viewer.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

Viewer.h
浏览该文件的文档.
1 /*
2 © 2011-2015, 2020 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_viewer_hpp_
29 #define YSL_INC_UI_viewer_hpp_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_UI_YComponent
33
34 namespace YSLib
35 {
36
37 namespace UI
38 {
39
45 class YF_API SequenceViewer
46 {
47 private:
52 size_t head = 0;
54 size_t selected = 0;
59 bool is_selected = {};
60
61 public:
63 size_t Length = 1;
64
70 SequenceViewer() = default;
71
76 DefPred(const ynothrow, Selected, is_selected)
77
78
82 YB_ATTR_nodiscard YB_PURE bool
83 Contains(size_t) const ynothrow;
84
85 DefGetter(const ynothrow, size_t, HeadIndex, head)
86 DefGetter(const ynothrow, size_t, SelectedIndex, selected)
91 DefGetter(const ynothrow, ptrdiff_t, Offset, IsSelected()
92 ? ptrdiff_t(GetSelectedIndex()) - ptrdiff_t(GetHeadIndex()) : -1) \
98 YB_ATTR_nodiscard YB_PURE size_t
99 GetValid(size_t total) const ynothrow;
100
106 bool
107 SetHeadIndex(size_t t, size_t total);
113 bool
114 SetSelectedIndex(size_t t, size_t total);
115
123 bool
124 AdjustForContent(size_t total);
125
127 PDefH(bool, CheckSelected, size_t idx) const
128 ImplRet(IsSelected() && GetSelectedIndex() == idx)
129
134 PDefH(void, ClearSelected, )
135 ImplExpr(is_selected = {})
136
141 SequenceViewer&
142 IncreaseHead(ptrdiff_t d, size_t total);
143
149 SequenceViewer&
150 IncreaseSelected(ptrdiff_t d, size_t total);
151
156 bool
157 MoveViewerToBegin();
158
163 bool
164 MoveViewerToEnd(size_t total);
165
170 PDefH(void, Reset, )
171 ImplUnseq(head = 0, selected = 0, Length = 1, is_selected = {})
172
180 bool
181 RestrictSelected();
182
190 bool
191 RestrictView();
192 };
193
194
200 class YF_API AMUnitList
201 {
202 protected:
204 SequenceViewer vwList{};
209 SDst uTopOffset = 0;
211 size_t idxShared = size_t(-1);
212
213 public:
214 virtual DefDeDtor(AMUnitList)
215
216
220 bool CyclicTraverse = {};
221
227 YB_ATTR_nodiscard SDst
228 GetFullViewHeight() const;
235 YB_ATTR_nodiscard SDst
236 GetItemHeight() const;
237
238 protected:
244 YB_ATTR_nodiscard virtual SDst
245 GetItemHeightCore() const;
246
247 public:
249 YB_ATTR_nodiscard size_t
250 GetLastLabelIndexClipped(SPos, SDst) const;
252 DefGetter(const ynothrow, size_t, SharedIndex, idxShared)
254 DefGetter(const ynothrow, SDst, TopOffset, uTopOffset)
259 DeclIEntry(size_t GetTotal() const)
261 DeclIEntry(IWidget& GetUnitRef() const)
267 YB_ATTR_nodiscard Point
268 GetUnitLocation(size_t) const;
274 YB_ATTR_nodiscard SDst
275 GetViewPosition() const;
276
286 SDst
287 AdjustBottomForHeight(SDst, SDst);
288
290
291
301 SDst
302 AdjustOffsetForHeight(SDst, bool);
303
309 void
310 AdjustViewForContent(SDst);
311
318 void
319 AdjustViewLengthForHeight(SDst, SDst);
320
326 YB_ATTR_nodiscard size_t
327 CheckPoint(const Size&, const Point&);
328
333 void
334 ResetView();
336 };
337
338 } // namespace UI;
339
340 } // namespace YSLib;
341
342 #endif
343
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
YSLib::UI::ynothrow
AView &y ynothrow
Definition: YWidgetView.cpp:47
YSLib::UI::SequenceViewer::DefGetter
DefGetter(const ynothrow, size_t, HeadIndex, head) DefGetter(const ynothrow
YSLib::Drawing::Size
屏幕区域大小。
Definition: YGDIBase.h:536
YSLib::UI::AMUnitList
单元部件列表模块。
Definition: Viewer.h:201
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:919
YSLib::UI::PDefH
PDefH(void, DisplayFor, IWidget &wgt, Timers::TimeSpan delay) ImplExpr(Show(wgt)
在一定时间内显示部件。
CHRLib::d
_tDst * d
Definition: CharacterProcessing.h:142
YF_API
#define YF_API
Definition: Platform.h:56
YSLib::UI::SequenceViewer
序列视图。
Definition: Viewer.h:46
YSLib::UI::AMUnitList::DefDeDtor
virtual DefDeDtor(AMUnitList) bool CyclicTraverse
循环选择遍历。
ImplUnseq
#define ImplUnseq(...)
Definition: YBaseMacro.h:110
YSLib::UI::SequenceViewer::SequenceViewer
SequenceViewer()=default
构造：使用指定容器。
YSLib::UI::SequenceViewer::PDefH
PDefH(void, Reset,) ImplUnseq(head=0
复位视图。
YSLib::Drawing::GBinaryGroup< SPos >
ytest::timing::total
auto total(size_t n, _fNow now, _func &&f, _tParams &&... args) -> decltype(now() - now())
测试指定函数执行若干次的总时间。
Definition: timing.hpp:91
platform::SDst
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:44
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:46
head
link_ptr head
Definition: memory_resource.cpp:232
YSLib::UI::AMUnitList::DefGetter
DefGetter(const ynothrow, size_t, SharedIndex, idxShared) DefGetter(const ynothrow
YModules.h
YSLib 用户界面模块配置文件。
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::UI::SequenceViewer::DefPred
DefPred(const ynothrow, Selected, is_selected) YB_ATTR_nodiscard YB_PURE bool Contains(size_t) const ynothrow
判断是否为选中状态。
YSLib::DeclIEntry
YB_ATTR_nodiscard DeclIEntry(any Create(Creation, const any &) const) YB_ATTR_nodiscard YB_PURE DeclIEntry(bool Equals(const void *) const) YB_ATTR_nodiscard YB_PURE DeclIEntry(size_t OwnsCount() const ynothrow) YB_ATTR_nodiscard YB_PURE DeclIEntry(any Query(uintmax_t) const) template< typename _type > YB_ATTR_nodiscard static any CreateHolder(Creation
创建新的持有者。
YSLib::size_t
YF_API const char size_t
Definition: YException.h:149
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
platform::SPos
std::int16_t SPos
屏幕坐标度量。
Definition: Video.h:43
YSLib::UI::ImplRet
const IWidget &wgt ImplRet(wgt.GetView().IsVisible()) YB_ATTR_nodiscard YB_PURE bool YF_API Contains(const IWidget &
判断点是否在部件的可视区域内。
platform_ex::Reset
unsigned long Reset(COMPtr< _iCOM > &ptr) ynothrow
Definition: Win32/include/YCLib/COM.h:406