28 #ifndef YSL_INC_UI_viewer_hpp_
29 #define YSL_INC_UI_viewer_hpp_ 1
42 template<class _tContainer>
51 typedef typename _tContainer::size_type
SizeType;
56 static_assert(std::is_unsigned<SizeType>::value,
57 "Invalid size type found!");
59 static_assert(std::is_signed<DifferenceType>::value,
60 "Invalid difference type found!");
81 GSequenceViewer(ContainerType& con)
82 : pContainer(&con), head(0), selected(0), length(1), is_selected(false)
89 inline
PDefHOp(GSequenceViewer&, ++,
int) \
92 inline
PDefHOp(GSequenceViewer&, --,
int) \
107 return GetTotal() != 0 && GetLength() != 0
108 && IsInInterval<SizeType>(i - GetHeadIndex(), GetLength());
116 DefGetter(const ynothrow, DifferenceType, Offset, IsSelected()
117 ? GetSelectedIndex() - GetHeadIndex() : -1) \
119 DefGetter(const ynothrow, SizeType, Valid, min(GetTotal() - GetHeadIndex(),
128 SetContainer(ContainerType& con)
131 yunseq(pContainer = &con, selected = 0, head = 0, length = 1);
137 SetHeadIndex(SizeType t)
139 if(t < GetTotal() && t != head)
143 else if(length + t > GetTotal())
155 SetLength(SizeType l)
168 SetSelectedIndex(SizeType t)
170 if(t < GetTotal() && !(t == selected && is_selected))
190 const auto total(GetTotal());
194 if(!(selected <
total))
195 selected =
total - 1;
196 return RestrictView();
212 inline PDefH(GSequenceViewer&, DecreaseHead, DifferenceType d) \
216 inline
PDefH(GSequenceViewer&, DecreaseSelected, DifferenceType d) \
225 IncreaseHead(DifferenceType d)
239 IncreaseSelected(DifferenceType d)
268 if(GetTotal() < length)
270 head = GetTotal() - length;
281 yunseq(head = 0, selected = 0, length = 1, is_selected =
false);
297 else if(selected < head + length)
300 selected = head + length - 1;
317 else if(selected < head + length)
320 head = selected + 1 - length;