libaurum: Fix indentation and clean code up
[platform/core/uifw/aurum.git] / libaurum / src / UiScrollable.cc
1 #include "Aurum.h"
2
3 UiScrollable::UiScrollable(std::shared_ptr<UiSelector> selector)
4 : mSelector{selector}, mMaxSearchSwipe{100}, mScrollStep{50}
5 {
6 }
7
8 UiScrollable::UiScrollable()
9 : mSelector{nullptr}, mMaxSearchSwipe{1}, mScrollStep{1}
10 {
11     // todo : find the top most scrollable object
12 }
13
14 bool UiScrollable::scrollToObject(UiObject *obj)
15 {
16     auto sel = obj->getSelector();
17
18     if (exists(obj)) return true;
19
20     for (int i = 0 ; i < mMaxSearchSwipe ; ++i) {
21         bool scrolled = scrollForward();
22         if (exists(obj)) return true;
23         if (!scrolled) return false;
24     }
25 }
26
27
28 bool UiScrollable::exists(UiObject *obj)
29 {
30     return (obj->isShowing() && obj->isVisible());
31 }
32
33 bool UiScrollable::scrollForward()
34 {
35     return scrollForward(mScrollStep);
36 }
37
38 bool UiScrollable::scrollForward(int steps)
39 {
40
41     //TODO Check Scree Size here
42     return true;
43
44 }
45
46 bool UiScrollable::scrollBackward()
47 {
48 return true;
49 }
50 bool UiScrollable::scrollBackward(int steps)
51 {
52 return true;
53 }
54
55 bool UiScrollable::scrollToBegin()
56 {
57 return true;
58 }