YAPOG  0.0.1
Yet Another Pokemon Online Game
PartialLayoutManager.cpp
Go to the documentation of this file.
4 
5 namespace yap
6 {
7 
9  : cursorCurSel_ (0)
10  , itemCount_ (0)
11  , size_ (0)
12  , layout_ (&layout)
13  , stock_ ()
14  , itemz_ ()
15  , isEnable_ (true)
16  , widthItem_ (0)
17  {
18  }
19 
21  {
22  }
23 
25  {
26  isEnable_ = state;
27  }
29  {
30  if (isEnable_)
31  {
32  uint countItem = 0;
33 
34  layout_->Clear ();
35  uint itemBeforeCount = (itemCount_ - 1) / 2;
36  uint itemAfterCount = itemCount_ - itemBeforeCount - 1;
37  int endListHandle = itemAfterCount - (itemz_.Count () - 1 - cursorCurSel_) +1;
38  endListHandle = (endListHandle >= 0) ? endListHandle : 0;
39  uint it = MathHelper::Clamp<int>(cursorCurSel_ - itemBeforeCount - endListHandle, 0, cursorCurSel_);
40 
41  while (it < itemz_.Count () && it < cursorCurSel_)
42  {
43  layout_->AddChild (*itemz_[it], yap::LayoutBox::Align::LEFT);
44  it++;
45  countItem++;
46  }
47 
48  it = cursorCurSel_;
49 
50  while (it < itemz_.Count () && countItem <= itemCount_)
51  {
52  layout_->AddChild (*itemz_[it], yap::LayoutBox::Align::LEFT);
53  it++;
54  countItem++;
55  }
56  }
57  }
58 
60  {
61  itemz_.Add (items);
62  }
63 
65  {
66  cursorCurSel_ = curr;
67  Refresh ();
68  }
70  {
72  size_ = size;
73  itemCount_ = size / widthItem_;
74  Refresh ();
75  }
77  {
78  return size_;
79  }
80 
82  {
83  itemz_.Clear ();
84  }
85 
86 } //namespace yap