2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file HmCustomPageControl.h
19 * @brief Keeps declaration of the HmCustomPageControl
20 * declares HmCustomPageControl class, it overrides default scrolling functionality of IconListView
23 #ifndef _HM_CUSTOM_PAGE_CONTROL_H_
24 #define _HM_CUSTOM_PAGE_CONTROL_H_
30 class ICustomPageControlEventListener;
31 class IPageControlItemProvider;
34 * @class CustomPageControl
35 * @brief This is the control which handles page by page scrolling of the application icons.
36 * It contains a custom IconListView and Provider for it.
38 class CustomPageControl
39 : public Tizen::Ui::Controls::Panel
40 , public Tizen::Ui::Controls::IIconListViewItemEventListener
41 , public Tizen::Base::Runtime::ITimerEventListener
42 , public Tizen::Ui::ITouchEventListener
43 , public Tizen::Ui::ITouchLongPressGestureEventListener
47 * The object is not fully constructed after this constructor is called.
48 * For full construction, the Construct() method must be called right after calling this constructor.
50 CustomPageControl(void);
53 * Destructor, this destructor overrides ~Tizen::Ui::Controls::Panel
55 virtual ~CustomPageControl(void);
58 * This function constructs the control properly
60 result Construct(const Tizen::Graphics::Rectangle& controlRect, int noOfPages, int pageWidth);
63 * Adds a new page in the page control
68 * Returns currently selected page number
70 int GetCurrentSelectedPage(void);
73 * Returns currently selected page number
75 Tizen::Base::Collection::ArrayList* GetIconLists(void);
78 * returns the total no. of pages in the control
80 const int GetPageCount(void);
83 * Marks a page to be deleted
85 void MarkPageToDelete(int pageNumber);
88 * Scrolls to the next or previous page on crossing the bounds while moving icons in edit mode
93 * Sets the maximum number of icons in one page
95 void SetMaxNumberOfIcons(int iconsCount);
98 * Sets the listener to intercept events on the page control.
100 void SetPageControlEventListener(ICustomPageControlEventListener* pListener);
103 * Sets item provider for the Page control
105 void SetPageControlItemProvider(IPageControlItemProvider* pItemProvider);
108 * Scrolls to the specified page number
110 void SetPageSelected(int pageNumber);
113 * Enables/Disables edit mode
115 void ToggleEditMode(void);
117 // from IIconListViewItemEventListener
118 virtual void OnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView& iconListView, int index, Tizen::Ui::Controls::IconListViewItemStatus status);
119 virtual void OnIconListViewOverlayBitmapSelected(Tizen::Ui::Controls::IconListView& iconListView, int index, int overlayBitmapId);
121 // From ITimerEventListener
122 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
124 //from ITouchEventListener
125 virtual void OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {}
126 virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {}
127 virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo) {}
128 virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
129 virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
130 virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
132 // From ITouchLongPressGestureEventListener
133 virtual void OnLongPressGestureCanceled(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector) {}
134 virtual void OnLongPressGestureDetected(Tizen::Ui::TouchLongPressGestureDetector& gestureDetector);
138 * Removes a page from the Page control
140 result RemovePage(int pageNumber);
143 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
145 CustomPageControl(const CustomPageControl&);
148 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
150 CustomPageControl& operator =(const CustomPageControl&);
153 bool __hasPageMoved; // keeps info if the page transition completed or not
154 bool __isDragging; // tell if an icon is being dragged
155 bool __isInEditMode; // tells if the control is in edit mode or not
156 bool __needAnimation; //indicates, if scroll animation needs to be played.
157 HomeItemInfo* __pDraggingAppInfo; // the app info of moving item
158 ICustomPageControlEventListener* __pEventListener; // the listener object to notify about the events
159 int __currentIndex; //the index in which the moving item is projected at the moment
160 int __currentPageNumber; //Currently shown page number
161 int __iconsCount; //max number of icons per page
162 int __pageNumber; // current page number
163 int __pageToBeDeleted; // page number to be deleted
164 int __pageWidth; // width of one page
165 int __startIndex; // start index of the dragged icon
166 int __sweepTraveled; // the distance the touch has traveled,
167 int __totalPages; // total number of pages in this control
168 IPageControlItemProvider* __pPageItemProvider; // the provider for the PageItem
169 Tizen::Base::Collection::ArrayList* __pIconListProviders; // list of provider objects
170 Tizen::Base::Collection::ArrayList* __pIconLists; //keeps the list of IconListViews
171 Tizen::Base::Runtime::Timer* __pPageMovementTimer; // Time to be created for the duration for Page Movement
172 Tizen::Graphics::Bitmap* __pMovingItemBitmap; //The item bitmap of the moving item
173 Tizen::Graphics::Point __animationEndPoint; // starting position of touch from where the animation to be started
174 Tizen::Graphics::Point __animationStartPoint; // starting position control to be animated to.
175 Tizen::Graphics::Point __dragStartPosition; // starting position of touch dragging an item started
176 Tizen::Graphics::Point __iconListCurrentPos; // current position of the current page
177 Tizen::Graphics::Point __iconListRestPosition; // current position of the current page
178 Tizen::Graphics::Point __touchStartPoint; // starting position of touch from where the scrolling started
179 Tizen::Ui::Controls::IconListViewItem* __pMovementItem; //The Moving item
180 Tizen::Ui::Controls::Label* __pMovementLabel; // The label to show current position of touch location, to guide while repositioning
181 Tizen::Ui::TouchLongPressGestureDetector* __pGetureDetector; //LongTouchGesture detector
184 #endif // _HM_CUSTOM_PAGE_CONTROL_H_