2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_TableViewItem.h
20 * @brief This is the header file for the _TableViewItem class.
22 * This header file contains the declarations of the _TableViewItem class.
26 #ifndef _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_H_
27 #define _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_H_
29 #include <FUiCtrlTableViewTypes.h>
30 #include <FUiAnimIVisualElementAnimationStatusEventListener.h>
31 #include <FUiAnimIVisualElementAnimationTickEventListener.h>
32 #include <FBaseColArrayList.h>
33 #include <FBaseRtITimerEventListener.h>
34 #include "FUi_Control.h"
35 #include "FUi_IAccessibilityListener.h"
36 #include "FUiCtrl_IListItemCommon.h"
37 #include "FUiCtrl_Label.h"
39 namespace Tizen { namespace Ui
41 class _TouchLongPressGestureDetector;
44 namespace Tizen { namespace Ui { namespace Controls
47 enum TableViewItemSelectionStyle
49 TABLE_VIEW_ITEM_SELECTION_STYLE_NONE = 0,
50 TABLE_VIEW_ITEM_SELECTION_STYLE_WHOLE
53 enum TableViewItemType
55 TABLE_VIEW_ITEM_TYPE_TOP,
56 TABLE_VIEW_ITEM_TYPE_MIDDLE,
57 TABLE_VIEW_ITEM_TYPE_BOTTOM,
58 TABLE_VIEW_ITEM_TYPE_ONE,
59 TABLE_VIEW_ITEM_TYPE_TITLE,
60 TABLE_VIEW_ITEM_TYPE_HEADER,
61 TABLE_VIEW_ITEM_TYPE_FOOTER,
62 TABLE_VIEW_ITEM_TYPE_NONE
65 enum TableViewGroupItemDrawingStatus
67 TABLE_VIEW_GROUPITEM_DRAWING_STATUS_NORMAL = 3,
68 TABLE_VIEW_GROUPITEM_DRAWING_STATUS_PRESSED
71 enum TableViewSimpleItemDrawingStatus
73 TABLE_VIEW_SIMPLEITEM_DRAWING_STATUS_DISABLED = 5,
76 enum TableViewItemPressedControl
78 TABLE_VIEW_ITEM_PRESSED_NONE = 0,
79 TABLE_VIEW_ITEM_PRESSED_ITEM,
80 TABLE_VIEW_ITEM_PRESSED_ANNEX,
81 TABLE_VIEW_ITEM_PRESSED_INDIVIDUAL
84 struct _ItemDrawingProperty
86 bool itemDividerEnabled;
87 Tizen::Graphics::Color dividerColor;
88 bool sectionStyleEnabled;
89 Tizen::Graphics::Color sectionStyleBgColor;
90 bool groupedLookEnabled;
98 // TableViewItemControl
99 class _TableViewItemControl
100 : public Tizen::Ui::_Control
103 virtual ~_TableViewItemControl(void);
104 virtual void OnDraw(void);
105 virtual Tizen::Ui::Animations::HitTestResult HitTest(const Tizen::Graphics::FloatPoint& point);
108 static _TableViewItemControl* CreateTableViewItemControlN(void);
109 result SetBackgroundBitmap(const Tizen::Graphics::Bitmap& bitmap);
110 Tizen::Graphics::Bitmap* GetBackgroundBitmap(void) const;
113 Tizen::Graphics::Bitmap* __pBackgroundBitmap;
116 _TableViewItemControl(void);
117 _TableViewItemControl(const _TableViewItemControl& rhs);
118 _TableViewItemControl& operator =(const _TableViewItemControl rhs);
122 class _OSP_EXPORT_ _TableViewItem
123 : public Tizen::Ui::_Control
124 , public _IListItemCommon
125 , public _IAccessibilityListener
126 , public Tizen::Base::Runtime::ITimerEventListener
127 , public Tizen::Ui::Animations::IVisualElementAnimationTickEventListener
128 , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener
129 , virtual public Tizen::Base::Runtime::IEventListener
130 , virtual public Tizen::Ui::_IUiEventListener
131 , virtual public Tizen::Ui::_IUiEventPreviewer
135 virtual ~_TableViewItem();
137 static _TableViewItem* CreateTableViewItemN(float itemHeight);
139 virtual bool DrawItem(Tizen::Graphics::FloatRectangle& rcItem, ListItemState isFocused, bool itemDivider = false);
141 virtual float GetItemHeight(void) const;
142 virtual void SetItemHeight(int itemHeight); // +++ check floating
143 virtual void SetItemHeight(float itemHeight);
145 virtual void SetChecked(bool checked);
146 virtual bool IsChecked(void) const;
147 virtual void SetCheckedAnimationEnabled(bool enabled);
149 virtual void SetItemEnabled(bool enabled);
150 virtual bool IsItemEnabled(void) const;
152 void SetItemType(const TableViewItemType itemType);
153 TableViewItemType GetItemType(void) const;
155 virtual bool IsReorderMode(void) const;
156 virtual void SetReorderMode(bool enabled);
158 virtual void SetItemChanged(bool changed);
159 virtual bool IsItemChanged(void) const;
161 virtual void SetItemIndex(int groupIndex, int itemIndex);
162 virtual void GetItemIndex(int& groupIndex, int& itemIndex) const;
164 _TableViewItem* GetContextItem(void) const;
165 void SetContextItem(_TableViewItem* pContextItem);
167 bool IsContextItem(void) const;
168 void SetContextItemActivation(bool activated);
169 bool IsContextItemActivated(void) const;
171 result CreateItemDimLayer(void);
172 void ExposeContextItem(Tizen::Graphics::FloatRectangle itemBounds, float targetWidth);
173 void DrawItemDimLayer(bool visible);
175 void SetItemStyle(TableViewAnnexStyle style);
176 TableViewAnnexStyle GetItemStyle(void) const;
178 void SetItemWidth(float width);
180 bool SetItemBackgroundBitmap(ListItemState itemState, const Tizen::Graphics::Bitmap* pBitmap);
181 Tizen::Graphics::Bitmap* GetItemBackgroundBitmap(ListItemState itemState) const;
183 void SetItemBackgroundColor(ListItemState itemState, const Tizen::Graphics::Color bgColor);
184 Tizen::Graphics::Color GetItemBackgroundColor(ListItemState itemState) const;
186 result SetSelectionStyle(TableViewItemSelectionStyle style);
187 TableViewItemSelectionStyle GetSelectionStyle(void) const;
189 virtual void SetAppInfo(const void* pAppInfo);
190 virtual void* GetAppInfo(void) const;
195 void FireItemEvent(bool selectedItem = true);
196 void FireItemSweepEvent(TableViewSweepDirection direction);
198 void SetDrawingProperty(_ItemDrawingProperty* pDrawingProperty);
199 _ItemDrawingProperty* GetDrawingProperty(void);
201 void SetDrawingStatus(TableViewItemDrawingStatus status);
202 TableViewItemDrawingStatus GetDrawingStatus(void);
204 void AdjustChildControlMargin(void);
206 void AdjustContextItemBounds(void);
207 void AdjustChildControlCenterAlign(void);
208 void SetChildControlCenterAlign(bool centerAlign);
209 void SetItemCustomHeight(float height);
210 void AdjustAnnexBounds(void);
213 result SetSimpleItemContents(const Tizen::Base::String& text, const Tizen::Graphics::Bitmap* pBitmap, bool groupType);
214 result SetSimpleTextColor(const Tizen::Graphics::Color& color, TableViewItemDrawingStatus status);
215 Tizen::Graphics::Color GetSimpleItemTextColor(TableViewItemDrawingStatus status) const;
216 result SetSimpleItemTextSize(int size);
217 int GetSimpleItemTextSize(void) const;
219 result SetSectionHeaderFooterContents(const Tizen::Base::String& text, HorizontalAlignment alignment, bool isHeader);
220 result SetSectionHeaderFooterAlignment(HorizontalAlignment alignment);
222 bool MoveItem(Tizen::Graphics::FloatPoint position, int duration, int delay);
223 bool FadeInOutItem(bool fadeOut, int duration, int delay);
224 bool ZoomInOutItem(bool zoomOut, int duration, int delay);
226 Tizen::Graphics::Point GetLastTouchPressedPosition(void);
227 Tizen::Graphics::FloatPoint GetLastTouchPressedPositionF(void);
228 void SetLastTouchPressedPosition(Tizen::Graphics::Point position);
229 void SetLastTouchPressedPosition(Tizen::Graphics::FloatPoint position);
231 bool GetSelectionState(void);
232 void SetSelectionState(bool selected);
234 result SetIndividualSelectionEnabled(const _Control& control, bool enable);
235 bool IsIndividualSelectionEnabled(const _Control& control);
237 bool IsAnimationPlaying(void);
238 void StopAllAnimation(void);
240 void SetItemDividerEnabled(bool enable);
242 result PlayCheckBoxAnimation(void);
243 result StartCheckBoxAnimation(void);
244 void StopCheckBoxAnimation(void);
246 void SetItemLayoutEnabled(bool enabled);
247 bool GetItemLayoutEnabled(void);
248 bool IsAnnexOnOffSliding(void);
249 static float GetAnnexWidth(TableViewAnnexStyle style);
251 void FireItemTouchReleased(void);
252 void FireItemTouchPressed(void);
255 virtual void SetAccessibilityElement(void);
256 Tizen::Ui::_AccessibilityElement* GetAccessibilityElement(void);
258 virtual result OnAttachedToMainTree(void);
260 // event handler for ITouchEventListener
261 virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
262 virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
263 virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
264 virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
266 virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
267 virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
268 virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
269 virtual _UiTouchEventDelivery OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
271 virtual void OnDraw(void);
272 virtual void OnChildAttached(const _Control& child);
273 virtual void OnChildDetached(const _Control& child);
274 virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
275 virtual void OnBoundsChanged(void);
277 // VisualElement Animation
278 virtual void OnTickOccurred(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, const Tizen::Ui::Variant& currentValue);
279 virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target);
280 virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount);
281 virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally);
283 // accessibility listener
284 virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element);
285 virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element);
286 virtual bool OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element);
287 virtual bool OnAccessibilityReadedElement(const _AccessibilityContainer& control, const _AccessibilityElement& element);
288 virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element);
289 virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element);
290 virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element);
291 virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element);
292 virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element);
295 _TableViewItem(float nItemHeight);
296 result Initialize(void);
298 virtual void SetAccessibilityElementLabel(void);
300 bool SetItemTapSoundEnabled(bool tapSoundEnabled);
301 bool GetItemTapSoundEnabled(void);
303 void SetPressedControl(TableViewItemPressedControl pressedControl);
304 TableViewItemPressedControl GetPressedControl(void);
306 result StartTouchPressedTimer(const _Control& source, const _TouchInfo& touchinfo);
307 void StopTouchPressedTimer(void);
308 result StartTouchReleasedTimer(void);
309 void StopTouchReleasedTimer(void);
311 void OnAncestorInputEnableStateChanged(const _Control& control);
314 _TableViewItem(const _TableViewItem&);
315 _TableViewItem& operator =(const _TableViewItem&);
318 void DrawItemBackground(void);
319 void DrawSectionStyleBackground(void);
320 void DrawSectionStyleBackgroundCover(void);
321 void DrawAnnexStyle(void);
322 void DrawCheckBox(void);
323 void DrawRadioBox(void);
324 void DrawOnOffButton(void);
325 void DrawAnnexOnOffHandler(float position);
326 void AdjustAnnexOnOffHandlerPosition();
327 void DrawDetailButton(void);
328 void DrawItemDivider(void);
329 void DrawItemAnnexDivider(void);
330 void DrawGroupedLook(void);
332 result DrawBitmap (Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, const Tizen::Graphics::Bitmap& bitmap);
334 result SetItemHighlightBounds(Tizen::Ui::Animations::_VisualElement& highlightVisualElement, const Tizen::Graphics::FloatRectangle& bounds);
335 Tizen::Graphics::FloatRectangle CalculateItemHighlightBounds(void);
336 Tizen::Graphics::FloatRectangle CalculateAnnexBitmapBounds(float annexWidth, float annexHeight, const Tizen::Graphics::Bitmap& bitmap);
338 bool IsTitleStyleItem(void) const;
339 bool IsValidSelectionState(void);
342 void DrawSimpleItem(void);
343 result CreateSimpleItemContents(bool textOnly);
345 result CreateItemDivider(void);
346 result CreateItemAnnexDivider(void);
347 result CreateItemCover(void);
349 void CreateAnnexStyle(void);
350 result CreateCheckBox(void);
351 result CreateRadioBox(void);
352 result CreateOnOffButton(void);
353 result CreateDetailButton(void);
359 int __itemGroupIndex;
367 bool __itemTouchMoved;
368 bool __childMarginState;
370 TableViewAnnexStyle __annexStyle;
371 TableViewItemDrawingStatus __drawingStatus;
372 TableViewItemSelectionStyle __selectionStyle;
373 TableViewItemType __itemType;
375 _TableViewItem* __pContextItem;
376 bool __isContextItem;
377 bool __isContextItemActivated;
378 bool __checkItemHeightNeeded;
380 _TableViewItemControl* __pItemDivider;
381 _TableViewItemControl* __pItemTopDivider;
382 _Label* __pItemAnnex;
383 _TableViewItemControl* __pItemCover;
384 _TableViewItemControl* __pItemAnnexLeftDivider;
385 _TableViewItemControl* __pItemAnnexRightDivider;
389 Tizen::Graphics::Bitmap* __pItemBgBitmap[3];
390 Tizen::Graphics::Color __colorItemBg[3];
392 _ItemDrawingProperty* __pDrawingProperty;
394 bool __itemDividerEnabled;
397 _Label* __pSimpleItemText;
398 _Label* __pSimpleItemBitmap;
399 Tizen::Graphics::Color __simpleItemTextColor[6];
400 int __simpleItemTextSize;
402 // Section header, footer
403 _Label* __pHeaderFooterItemText;
407 Tizen::Graphics::FloatPoint __touchStartPosition;
408 float __annexOnOffTouchPosition;
409 bool __annexOnOffHandlerMoved;
410 float __annexOnOffHandlerLastPosition;
411 bool __childControlCenterAlign;
412 float __customHeight;
413 int __animationCount;
415 Tizen::Base::Collection::ArrayList __individualSelectionControls;
417 Tizen::Ui::_AccessibilityElement* __pAccessibilityElement;
419 Tizen::Base::Runtime::Timer* __pPressedTimer;
420 Tizen::Base::Runtime::Timer* __pReleasedTimer;
421 bool __isPressedTimerEnabled;
422 bool __isReleasedTimerEnabled;
423 TableViewItemPressedControl __pressedControl;
424 TableViewItemPressedControl __releasedControl;
426 Tizen::Base::Runtime::Timer* __pCheckedTimer;
427 bool __isCheckedTimerEnabled;
428 bool __isCheckedAnimationEnabled;
430 Tizen::Graphics::FloatRectangle __checkedBounds;
432 bool __isItemLayoutEnabled;
434 bool __isMoveItemAnimationEnabled;
435 bool __isZoomInOutItemAnimationEnabled;
436 bool __isFadeInOutItemAnimationEnabled;
437 bool __isAnimationCallbackBlocked;
439 bool __isItemTapSoundEnabled;
440 bool __isTabSoundPlayed;
441 bool __isSelectedDetailButton;
443 Tizen::Ui::Animations::_VisualElement* __pHighlightVisualElement;
444 Tizen::Ui::Animations::_VisualElement* __pBitmapVisualElement;
446 Tizen::Ui::Animations::VisualElementValueAnimation* __pMoveItemAnimation;
447 Tizen::Ui::Animations::VisualElementValueAnimation* __pZoomInOutItemAnimation;
448 Tizen::Ui::Animations::VisualElementValueAnimation* __pFadeInOutItemtAnimation;
450 static const float SIMPLE_ITEM_ELEMENT_BITMAP_SIZE_RATIO = 0.6f;
451 static const float BACKGROUND_DIMMED_OPACITY = 0.7f;
452 static const float BACKGROUND_DISABLED_OPACITY = 0.3f;
453 static const int DEFAULT_CAPTURED_CONTROL_COUNT = 10;
454 static const int CHECKED_ANIMATION_DURATION = 30;
455 static const int TOUCH_PRESSED_DURATION = 100;
456 static const int TOUCH_RELEASED_DURATION = 30;
457 static const int MAX_CHECKED_COUNT = 10;
458 static const float INSENSITIVE = 0.16f;
459 static const float SENSITIVE = 0.08f;
462 }}} // Tizen::Ui::Controls
464 #endif // _FUI_CTRL_INTERNAL_TABLE_VIEW_ITEM_H_