libaurum: apply smart pointer wider and extract impl out
[platform/core/uifw/aurum.git] / libaurum / src / UiScrollable.cc
1 #include "UiScrollable.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 /*
42     화면 크기 확인 
43     scroll to 
44
45 */
46     return true;
47
48 }
49
50 bool UiScrollable::scrollBackward()
51 {
52 return true;
53 }
54 bool UiScrollable::scrollBackward(int steps)
55 {
56 return true;
57 }
58
59 bool UiScrollable::scrollToBegin()
60 {
61 return true;
62 }