2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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_FastScrollPresenter.cpp
20 * @brief This is the implementation file for the _FastScrollPresenter class.
23 #include <FBaseErrors.h>
24 #include <FBaseString.h>
26 #include <FGrpColor.h>
27 #include <FGrpRectangle.h>
28 #include <FGrpCanvas.h>
29 #include <FGrpBitmap.h>
30 #include <FUiAnimVisualElementAnimation.h>
31 #include <FUiAnimVisualElementAnimationProvider.h>
32 #include <FUiAnimIVisualElementAnimationStatusEventListener.h>
33 #include <FUiAnimVisualElementContentProvider.h>
34 #include <FUiAnimIVisualElementContentProvider.h>
35 #include <FUiAnimVisualElement.h>
36 #include <FBaseSysLog.h>
37 #include <FGrp_BitmapImpl.h>
38 #include "FGrp_TextTextObject.h"
39 #include <FGrp_TextTextSimple.h>
40 #include "FUiAnim_VisualElement.h"
41 #include "FUi_Control.h"
42 #include "FUi_UiTouchEvent.h"
43 #include "FUi_ResourceManager.h"
44 #include "FUi_CoordinateSystemUtils.h"
46 #include "FUiCtrl_IFastScrollListener.h"
47 #include "FUiCtrl_UiFastScrollEvent.h"
48 #include "FUiCtrl_UiFastScrollEventArg.h"
49 #include "FUiCtrl_FastScroll.h"
50 #include "FUiCtrl_FastScrollPresenter.h"
51 #include "FUiCtrl_FastScrollModel.h"
52 #include "FUiCtrl_FastScrollIndex.h"
54 #include "FUiAnim_MatrixUtil.h"
56 using namespace Tizen::Base;
57 using namespace Tizen::Graphics;
58 using namespace Tizen::Ui;
59 using namespace Tizen::Ui::Animations;
60 using namespace Tizen::Graphics::_Text;
64 const float FASTSCROLL_OPACITY_ON = 1.0f;
65 const float FASTSCROLL_OPACITY_SELECTEDBG_DIM = 0.5f;
66 const float FASTSCROLL_OPACITY_LIGHT_DIM = 0.3f;
67 const float FASTSCROLL_OPACITY_OFF = 0.0f;
68 const int FASTSCROLL_POPUPINDEX_COUNT = 3;
71 namespace Tizen { namespace Ui { namespace Controls
74 _FastScrollViewConfig::_FastScrollViewConfig(void)
75 : __indexBgColor(Color::GetColor(COLOR_ID_BLACK))
76 , __indexHighlightColor(Color::GetColor(COLOR_ID_BLACK))
77 , __indexSelectedLineColor(Color::GetColor(COLOR_ID_BLACK))
78 , __indexTextColor(Color::GetColor(COLOR_ID_BLACK))
79 , __indexDividerColor(Color::GetColor(COLOR_ID_BLACK))
80 , __selectedIndexBgColor(Color::GetColor(COLOR_ID_BLACK))
81 , __selectedIndexTextColor(Color::GetColor(COLOR_ID_BLACK))
82 , __popupBgColor(Color::GetColor(COLOR_ID_BLACK))
83 , __popupTextColor(Color::GetColor(COLOR_ID_BLACK))
84 , __indexSizeMin(0.0f, 0.0f)
85 , __popupSize(0.0f, 0.0f)
86 , __indexMarginTop(0.0f)
88 , __indexLeftLineThickness(0.0f)
89 , __indexTextSize(0.0f)
90 , __indexSeparatorThickness(0.0f)
91 , __selectedIndexMarginRight(0.0f)
92 , __selectedIndexHeight(0.0f)
93 , __popupWidthIncrement(0.0f)
94 , __popupTextSize(0.0f)
95 , __popupShadowRight(0.0f)
96 , __popupShadowBottom(0.0f)
97 , __pIndexBgBitmap(null)
98 , __pSelectedIndexBgBitmap(null)
99 , __pSelectedIndexlineBitmap(null)
100 , __pPopupBgBitmap(null)
101 , __pPopupBgEffectBitmap(null)
106 _FastScrollViewConfig::~_FastScrollViewConfig(void)
111 _FastScrollViewConfig*
112 _FastScrollViewConfig::CreateFastScrollViewConfigN(_ControlOrientation orientation)
114 _FastScrollViewConfig* pConfig = new (std::nothrow) _FastScrollViewConfig();
115 SysTryReturn(NID_UI_CTRL, pConfig, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
117 result r = pConfig->Construct(orientation);
118 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
120 SetLastResult(E_SUCCESS);
130 _FastScrollViewConfig::ReloadConfig(_ControlOrientation orientation)
132 result r = E_SUCCESS;
134 // release allocated resources.
137 // load bitmap resources
138 r = GET_BITMAP_CONFIG_N(FASTSCROLL::INDEX_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pIndexBgBitmap);
139 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
141 r = GET_BITMAP_CONFIG_N(FASTSCROLL::INDEX_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pSelectedIndexBgBitmap);
142 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
144 r = GET_BITMAP_CONFIG_N(FASTSCROLL::INDEX_LINE_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pSelectedIndexlineBitmap);
145 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
147 r = GET_BITMAP_CONFIG_N(FASTSCROLL::POPUP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pPopupBgBitmap);
148 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
150 r = GET_BITMAP_CONFIG_N(FASTSCROLL::POPUP_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pPopupBgEffectBitmap);
151 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
154 // load shape configuration
155 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __indexSizeMin.width);
156 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
158 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __indexSizeMin.height);
159 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
161 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __indexMarginTop);
162 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
164 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_LEFT_LINE_THICKNESS, _CONTROL_ORIENTATION_PORTRAIT, __indexLeftLineThickness);
165 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
167 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __indexTextSize);
168 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
170 r = GET_FIXED_VALUE_CONFIG(FASTSCROLL::INDEX_SEPARATOR_THICKNESS, _CONTROL_ORIENTATION_PORTRAIT, __indexSeparatorThickness);
171 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
173 r = GET_SHAPE_CONFIG(FASTSCROLL::SELECTED_INDEX_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __selectedIndexMarginRight);
174 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
176 r = GET_SHAPE_CONFIG(FASTSCROLL::SELECTED_INDEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __selectedIndexHeight);
177 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
179 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __popupSize.width);
180 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
182 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __popupSize.height);
183 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
185 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_WIDTH_INCREMENT, _CONTROL_ORIENTATION_PORTRAIT, __popupWidthIncrement);
186 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
188 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __popupTextSize);
189 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
191 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_RIGHT_SHADOW, _CONTROL_ORIENTATION_PORTRAIT, __popupShadowRight);
192 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
194 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_BOTTOM_SHADOW, _CONTROL_ORIENTATION_PORTRAIT, __popupShadowBottom);
195 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
198 // load color configuration
199 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_BG_NORMAL, __indexBgColor);
200 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
202 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_LINE_PRESSED, __indexSelectedLineColor);
203 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
205 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_TEXT_NORMAL, __indexTextColor);
206 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
208 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_DIVIDER_NORMAL, __indexDividerColor);
209 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
211 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_BG_PRESSED, __selectedIndexBgColor);
212 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
214 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_TEXT_PRESSED, __selectedIndexTextColor);
215 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
217 r = GET_COLOR_CONFIG(FASTSCROLL::POPUP_BG_NORMAL, __popupBgColor);
218 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
220 r = GET_COLOR_CONFIG(FASTSCROLL::POPUP_TEXT_NORMAL, __popupTextColor);
221 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
226 __indexBgColor = Color::GetColor(COLOR_ID_BLACK);
227 __indexHighlightColor = Color::GetColor(COLOR_ID_BLACK);
228 __indexSelectedLineColor= Color::GetColor(COLOR_ID_BLACK);
229 __indexTextColor = Color::GetColor(COLOR_ID_BLACK);
230 __indexDividerColor= Color::GetColor(COLOR_ID_BLACK);
231 __selectedIndexBgColor = Color::GetColor(COLOR_ID_BLACK);
232 __selectedIndexTextColor = Color::GetColor(COLOR_ID_BLACK);
233 __popupBgColor = Color::GetColor(COLOR_ID_BLACK);
234 __popupTextColor = Color::GetColor(COLOR_ID_BLACK);
236 __indexSizeMin.SetSize(0.0f, 0.0f);
237 __popupSize.SetSize(0.0f, 0.0f);
239 __indexMarginTop = 0.0f;
241 __indexLeftLineThickness = 0.0f;
242 __indexTextSize = 0.0f;
243 __indexSeparatorThickness = 0.0f;
244 __selectedIndexMarginRight = 0.0f;
245 __selectedIndexHeight = 0.0f;
246 __popupWidthIncrement = 0.0f;
247 __popupTextSize = 0.0f;
248 __popupShadowRight = 0.0f;
249 __popupShadowBottom = 0.0f;
257 _FastScrollViewConfig::ReleaseResources(void)
259 delete __pIndexBgBitmap;
260 delete __pSelectedIndexBgBitmap;
261 delete __pSelectedIndexlineBitmap;
262 delete __pPopupBgBitmap;
263 delete __pPopupBgEffectBitmap;
265 __pIndexBgBitmap = null;
266 __pSelectedIndexBgBitmap = null;
267 __pSelectedIndexlineBitmap = null;
268 __pPopupBgBitmap = null;
269 __pPopupBgEffectBitmap = null;
273 _FastScrollViewConfig::Construct(_ControlOrientation orientation)
275 return ReloadConfig(orientation);
279 _FastScrollIndexView::_FastScrollIndexView(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
280 : __parentVe(parentVe)
281 , __viewConfig(viewConfig)
283 , __pSelectedIndex(null)
284 , __pSelectedIndexInOmittedIndex(null)
285 , __pFormerIndex(null)
286 , __pBaseIndexVe(null)
287 , __pSelectedBgVe(null)
288 , __pSelectedIndexVe(null)
289 , __needUpdateBaseIndex(false)
290 , __needUpdateSelectedIndex(false)
291 , __needDestroySelf(false)
295 _FastScrollIndexView::~_FastScrollIndexView(void)
297 if (__pSelectedIndexVe)
299 __pSelectedIndexVe->RemoveAllAnimations();
300 __pSelectedIndexVe->SetAnimationProvider(null);
302 __pSelectedIndexVe->Destroy();
303 __pSelectedIndexVe = null;
308 __pSelectedBgVe->RemoveAllAnimations();
309 __pSelectedBgVe->SetAnimationProvider(null);
311 __pSelectedBgVe->Destroy();
312 __pSelectedBgVe = null;
317 __pBaseIndexVe->RemoveAllAnimations();
318 __pBaseIndexVe->SetAnimationProvider(null);
320 __pBaseIndexVe->Destroy();
321 __pBaseIndexVe = null;
325 _FastScrollIndexView*
326 _FastScrollIndexView::CreateFastScrollIndexViewN(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
328 _FastScrollIndexView* pIndexView = new (std::nothrow) _FastScrollIndexView(parentVe, viewConfig);
329 SysTryReturn(NID_UI_CTRL, pIndexView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
331 result r = pIndexView->Construct();
332 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
334 SetLastResult(E_SUCCESS);
344 _FastScrollIndexView::FadeOutAndDestroy(void)
346 __needDestroySelf = true;
347 if (__pSelectedIndexVe)
349 __pSelectedIndexVe->RemoveAllAnimations();
354 __pSelectedBgVe->RemoveAllAnimations();
357 return SetIndexVisibility(false);
361 _FastScrollIndexView::SetBaseIndex(_FastScrollIndex* pIndex)
363 __pBaseIndex = pIndex;
365 result r = UpdateIndex(false);
366 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view.");
372 _FastScrollIndexView::GetBaseIndex(void) const
378 _FastScrollIndexView::SetIndexBounds(const FloatRectangle& indexBounds)
380 SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null.");
382 FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height);
383 __pBaseIndexVe->SetBounds(veBounds);
385 __needUpdateBaseIndex = true;
389 __pSelectedIndexVe->SetBounds(veBounds);
391 __needUpdateSelectedIndex = true;
397 _FastScrollIndexView::GetIndexBounds(void) const
399 FloatRectangle veBounds = __pBaseIndexVe->GetBounds();
400 return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
404 _FastScrollIndexView::GetIndexBoundsF(void) const
406 return __pBaseIndexVe->GetBounds();
410 _FastScrollIndexView::GetIndexAtPoint(const FloatPoint& point) const
412 SysTryReturn(NID_UI_CTRL, __pBaseIndex, null, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
414 int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
415 SysTryReturn(NID_UI_CTRL, childCount > 0, null, E_INVALID_STATE, "[E_INVALID_STATE] The index have no children.");
417 _FastScrollIndex* pChildIndex = null;
419 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
420 if (bounds.Contains(point) == true)
422 float touchY = point.y - bounds.y - __viewConfig.__indexMarginTop;
423 float indexHeight = GetIndexHeight();
426 if (!(_FloatCompare(touchY, 0.0f) || _FloatCompare(indexHeight, 0.0f)))
428 indexOrder = _CoordinateSystemUtils::ConvertToInteger(touchY / indexHeight);
431 pChildIndex = __pBaseIndex->GetChildIndex(indexOrder, true);
432 SysTryReturn(NID_UI_CTRL, pChildIndex, null, GetLastResult(), "[%s] Failed to get the child index.",
433 GetErrorMessage(GetLastResult()));
436 SetLastResult(E_SUCCESS);
441 _FastScrollIndexView::GetOmissionIndexAtPoint(_FastScrollIndex* pIndex, const FloatPoint& point) const
443 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
444 float touchY = point.y - bounds.y - __viewConfig.__indexMarginTop - (pIndex->GetIndexOrder(true) * GetIndexHeight());
445 float indexHeight = GetIndexHeight() / pIndex->GetChildCount();
446 int omissionIndexOrder = 0;
448 if ((touchY > 0.0f) && !_FloatCompare(indexHeight, 0.0f))
450 omissionIndexOrder = _CoordinateSystemUtils::ConvertToInteger(touchY / indexHeight);
453 _FastScrollIndex* pChildIndex = pIndex->GetChildIndex(omissionIndexOrder);
454 SysTryReturn(NID_UI_CTRL, pChildIndex, null, GetLastResult(), "[%s] Failed to get the child index.",
455 GetErrorMessage(GetLastResult()));
457 SetLastResult(E_SUCCESS);
462 _FastScrollIndexView::GetIndexHeight(void) const
464 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
465 float indexHeight = __viewConfig.__indexSizeMin.height;
467 if (__pBaseIndex->GetParentIndex() == null)
469 float indexHeightPerChild = (bounds.height - __viewConfig.__indexMarginTop * 2.0f) / (__pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType()));
470 if (indexHeight < indexHeightPerChild)
472 indexHeight = indexHeightPerChild;
480 _FastScrollIndexView::SelectIndex(int indexOrder)
482 result r = E_SUCCESS;
484 SysTryReturnResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "__pBaseIndex must not be null.");
486 _FastScrollIndex* pIndex = __pBaseIndex->GetChildIndex(indexOrder, true);
487 SysTryReturnResult(NID_UI_CTRL, pIndex, GetLastResult(), "Failed to get the child index.");
489 r = SelectIndex(pIndex, false);
490 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the index.");
496 _FastScrollIndexView::SelectIndex(_FastScrollIndex* pIndex, bool animation)
498 result r = E_SUCCESS;
500 if (__pSelectedIndex == pIndex)
505 __pSelectedIndex = pIndex;
507 if (__pSelectedIndex)
509 __pSelectedBgVe->SetBounds(CalculateSelectedBg());
510 if (GetSelectedIndexVisibility() == false)
512 r = SetSelectedIndexVisibility(true, animation);
513 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the Selected Bg ve.");
518 if (GetSelectedIndexVisibility() == true)
520 r = SetSelectedIndexVisibility(false, animation);
521 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the Selected Bg ve.");
523 SetSelectedIndexInOmittedIndex(null);
524 __pFormerIndex = null;
527 r = UpdateIndex(false);
528 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view.");
534 _FastScrollIndexView::GetSelectedIndexOrder(void) const
536 SysTryReturn(NID_UI_CTRL, __pBaseIndex, -1, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
537 SysTryReturn(NID_UI_CTRL, __pSelectedIndex, -1, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndex must not be null.");
539 return __pBaseIndex->GetChildOrder(__pSelectedIndex, true);
543 _FastScrollIndexView::SetSelectedIndex(_FastScrollIndex* pIndex)
545 __pSelectedIndex = pIndex;
549 _FastScrollIndexView::GetSelectedIndex(void) const
551 return __pSelectedIndex;
555 _FastScrollIndexView::SetSelectedIndexInOmittedIndex(_FastScrollIndex* pIndex)
557 if (pIndex == __pSelectedIndexInOmittedIndex)
562 __pFormerIndex = __pSelectedIndexInOmittedIndex;
563 __pSelectedIndexInOmittedIndex = pIndex;
567 _FastScrollIndexView::GetSelectedIndexInOmittedIndex(void) const
569 return __pSelectedIndexInOmittedIndex;
573 _FastScrollIndexView::GetFormerIndex(void) const
575 return __pFormerIndex;
579 _FastScrollIndexView::IsOnAnimation(void) const
585 _FastScrollIndexView::RemoveAllAnimations(void)
587 __pBaseIndexVe->RemoveAllAnimations();
591 _FastScrollIndexView::SetIndexVisibility(bool visibility)
593 result r = E_SUCCESS;
595 __pBaseIndexVe->SetImplicitAnimationEnabled(true);
599 __pBaseIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON);
603 __pBaseIndexVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
605 // else keep up current visibility.
607 __pBaseIndexVe->SetImplicitAnimationEnabled(false);
613 _FastScrollIndexView::GetIndexVisibility(void) const
615 float opacity = __pBaseIndexVe->GetOpacity();
616 if (opacity > FASTSCROLL_OPACITY_OFF)
627 _FastScrollIndexView::SetSelectedIndexVisibility(bool visibility, bool animation)
629 SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null.");
630 SysTryReturnResult(NID_UI_CTRL, __pSelectedBgVe, E_INVALID_STATE, "__pSelectedBgVe must not be null.");
634 __pSelectedIndexVe->SetImplicitAnimationEnabled(true);
635 __pSelectedBgVe->SetImplicitAnimationEnabled(true);
640 __pSelectedIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON);
641 __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_SELECTEDBG_DIM);
645 __pSelectedIndexVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
646 __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
648 // else keep up current visibility.
650 __pSelectedIndexVe->SetImplicitAnimationEnabled(false);
651 __pSelectedBgVe->SetImplicitAnimationEnabled(false);
657 _FastScrollIndexView::GetSelectedIndexVisibility(void) const
659 SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, false, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndexVe must not be null.");
661 float opacity = __pSelectedIndexVe->GetOpacity();
662 if (opacity > FASTSCROLL_OPACITY_OFF)
672 _FastScrollIndexView::AddAccessibilityElement(const _AccessibilityContainer& control)
674 SysTryReturnResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
676 int omittedChildCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
677 SysTryReturnResult(NID_UI_CTRL, omittedChildCount > 0, E_INVALID_STATE, "The index have no children.");
679 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
680 float indexHeight = GetIndexHeight();
681 FloatRectangle indexRect(bounds.x, __viewConfig.__indexMarginTop, bounds.width, indexHeight);
683 _AccessibilityElement* pAccessibilityElement = null;
684 result r = E_SUCCESS;
685 for (int i = 0; i < omittedChildCount; )
687 _FastScrollIndex* pChildIndex = __pBaseIndex->GetChildIndex(i, true);
688 SysTryReturnResult(NID_UI_CTRL, pChildIndex, GetLastResult(), "Failed to get the child index.");
690 if (pChildIndex->GetOmitted())
692 FloatPoint point((indexRect.x + indexRect.width/2), (indexRect.y + indexHeight/2));
693 pChildIndex = GetOmissionIndexAtPoint(pChildIndex, point);
694 SysTryReturnResult(NID_UI_CTRL, pChildIndex, GetLastResult(), "Failed to get the child index.");
697 Bitmap* pChildIndexImage = pChildIndex->GetIndexImage();
698 if (pChildIndexImage == null)
700 String* pChildIndexText = pChildIndex->GetIndexText();
701 SysTryReturnResult(NID_UI_CTRL, pChildIndexText, E_INVALID_STATE, "pChildIndexText must not be null.");
703 _AccessibilityContainer* pAccessibilityContainer = const_cast <_AccessibilityContainer*>(&control);
704 pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
705 SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
706 pAccessibilityElement->SetBounds(indexRect);
707 pAccessibilityElement->SetLabel(*pChildIndexText);
708 pAccessibilityElement->SetName(L"FastScrollIndex");
709 pAccessibilityElement->SetHint(L"double tap to move ," + *pChildIndexText + L", list");
710 r = pAccessibilityContainer->AddElement(*pAccessibilityElement);
711 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add accessibility element.", GetErrorMessage(r));
714 indexRect.y += indexHeight;
721 delete pAccessibilityElement;
726 _FastScrollIndexView::UpdateIndex(bool bNeedUpdateBaseIndex)
728 result r = E_SUCCESS;
730 r = __parentVe.InvalidateRectangle(null);
731 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to invalidate the index Ve.");
733 if (__pSelectedIndex)
735 __needUpdateSelectedIndex = true;
738 if (bNeedUpdateBaseIndex)
740 __needUpdateBaseIndex = true;
747 _FastScrollIndexView::OnDraw(void)
750 if (__pSelectedIndex)
757 VisualElementAnimation*
758 _FastScrollIndexView::CreateAnimationForProperty(VisualElement& target, const String& property)
760 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
764 const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
767 pAnimation->SetTimingFunction(pTimingFunction);
769 pAnimation->SetVisualElementAnimationStatusEventListener(this);
775 _FastScrollIndexView::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
780 _FastScrollIndexView::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
785 _FastScrollIndexView::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
787 if (__pBaseIndexVe == (static_cast <_VisualElement*>(&target)))
789 if (__needDestroySelf && completedNormally)
791 if (__pSelectedIndexVe)
793 __pSelectedIndexVe->RemoveAllAnimations();
794 __pSelectedIndexVe->SetAnimationProvider(null);
799 __pSelectedBgVe->RemoveAllAnimations();
800 __pSelectedBgVe->SetAnimationProvider(null);
803 __pBaseIndexVe->RemoveAllAnimations();
804 __pBaseIndexVe->SetAnimationProvider(null);
812 _FastScrollIndexView::CalculateSelectedBg(void)
814 SysTryReturn(NID_UI_CTRL, __pBaseIndex, FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), E_INVALID_STATE,
815 "[E_INVALID_STATE] __pBaseIndex must not be null.");
816 SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), E_INVALID_STATE,
817 "[E_INVALID_STATE] __pSelectedIndexVe must not be null.");
818 SysTryReturn(NID_UI_CTRL, __pSelectedIndex, FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), E_INVALID_STATE,
819 "[E_INVALID_STATE] __pSelectedIndex must not be null.");
821 int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
822 SysTryReturn(NID_UI_CTRL, childCount > 0, FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), E_INVALID_STATE, "[E_INVALID_STATE] The index have no children.");
824 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
825 float indexHeight = GetIndexHeight();
826 int selectedIndexOrder = GetSelectedIndexOrder();
827 FloatRectangle selectedRect(0.0f, 0.0f, (bounds.width - __viewConfig.__selectedIndexMarginRight), __viewConfig.__selectedIndexHeight);
829 if (_FloatCompare(bounds.height, __viewConfig.__selectedIndexHeight) || (bounds.height < __viewConfig.__selectedIndexHeight))
831 selectedRect.height = bounds.height;
835 selectedRect.y = ((selectedIndexOrder * indexHeight) + __viewConfig.__indexMarginTop);
836 if (indexHeight < __viewConfig.__selectedIndexHeight)
838 selectedRect.y -= ((__viewConfig.__selectedIndexHeight - indexHeight) / 2.0f);
842 selectedRect.height = indexHeight;
845 if (selectedRect.y < 0.0f)
847 selectedRect.y = 0.0f;
855 _FastScrollIndexView::DrawBaseIndex()
857 if (!__needUpdateBaseIndex)
861 SysTryReturnVoidResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
863 result r = E_SUCCESS;
864 int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
865 SysTryReturnVoidResult(NID_UI_CTRL, childCount > 0, E_INVALID_STATE, "[E_INVALID_STATE] The index have no children.");
867 Canvas* pCanvas = __pBaseIndexVe->GetCanvasN();
868 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the index ve.",
869 GetErrorMessage(GetLastResult()));
871 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
874 pCanvas->SetLineWidth(__viewConfig.__indexSeparatorThickness);
876 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
877 float indexHeight = GetIndexHeight();
879 FloatRectangle bgBounds(0.0f, 0.0f, bounds.width, bounds.height);
880 if (__viewConfig.__pIndexBgBitmap)
882 Bitmap* pReplacementColorBackgroundBitmap =
883 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pIndexBgBitmap,
884 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__indexBgColor);
885 DrawBitmap(*pCanvas, bgBounds, *pReplacementColorBackgroundBitmap);
887 delete pReplacementColorBackgroundBitmap;
890 FloatRectangle indexRect(0.0f, __viewConfig.__indexMarginTop, bounds.width, indexHeight);
891 Bitmap* pReplacementColorBitmap = null;
893 TextObject* pTextObject = new (std::nothrow) TextObject();
894 SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
896 pTextObject->Construct();
898 for (int i = 0; i < childCount; i++)
900 TextSimple* pSimpleText = null;
902 _FastScrollIndex* pChildIndex = __pBaseIndex->GetChildIndex(i, true);
903 SysTryCatch(NID_UI_CTRL, pChildIndex, , GetLastResult(), "[%s] Failed to get the child index.",
904 GetErrorMessage(GetLastResult()));
906 Bitmap* pChildIndexImage = pChildIndex->GetIndexImage();
907 if (pChildIndexImage)
909 FloatRectangle imageRect = indexRect;
910 float scaleFactor = indexRect.width / pChildIndexImage->GetWidthF();
911 float heightScaleFactor = indexRect.height / pChildIndexImage->GetHeightF();
912 if (scaleFactor > heightScaleFactor)
914 scaleFactor = heightScaleFactor;
917 imageRect.width = pChildIndexImage->GetWidthF() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
918 imageRect.height = pChildIndexImage->GetHeightF() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
920 if (indexRect.width - imageRect.width > 0.0f)
922 imageRect.x = indexRect.x + (indexRect.width - imageRect.width) / 2.0f;
925 if (indexRect.height - imageRect.height > 0.0f)
927 imageRect.y = indexRect.y + (indexRect.height - imageRect.height) / 2.0f;
930 pReplacementColorBitmap =
931 _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage,
932 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__indexTextColor);
933 r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap,
934 FloatRectangle(0.0f, 0.0f, pChildIndexImage->GetWidthF(), pChildIndexImage->GetHeightF()));
935 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r));
937 delete pReplacementColorBitmap;
938 pReplacementColorBitmap = null;
942 String* pChildIndexText = pChildIndex->GetIndexText();
943 SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "pChildIndexText must not be null.");
945 pTextObject->RemoveAll();
947 pSimpleText = new (std::nothrow)TextSimple(const_cast<wchar_t*>(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
948 SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed");
950 r = pTextObject->AppendElement(*pSimpleText);
951 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simple text.", GetErrorMessage(r));
953 r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
954 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r));
956 r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength());
957 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
959 r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
960 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r));
962 r = pTextObject->SetBounds(indexRect);
963 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r));
965 r = pTextObject->SetForegroundColor(__viewConfig.__indexTextColor, 0, pTextObject->GetTextLength());
966 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r));
968 r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
969 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r));
973 indexRect.y += indexHeight;
974 if (i != (childCount - 1))
976 pCanvas->SetForegroundColor(__viewConfig.__indexDividerColor);
977 pCanvas->DrawLine(FloatPoint(indexRect.x, indexRect.y + __viewConfig.__indexSeparatorThickness),
978 FloatPoint(indexRect.x + indexRect.width, indexRect.y + __viewConfig.__indexSeparatorThickness));
982 __needUpdateBaseIndex = false;
987 delete pReplacementColorBitmap;
991 _FastScrollIndexView::DrawSelectedBg()
993 if (!__needUpdateSelectedIndex)
998 SysTryReturnVoidResult(NID_UI_CTRL, __pSelectedIndex, E_INVALID_STATE,
999 "[E_INVALID_STATE] __pSelectedIndex must not be null.");
1001 Canvas* pCanvas = __pSelectedBgVe->GetCanvasN();
1002 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the Selected Bg ve.",
1003 GetErrorMessage(GetLastResult()));
1005 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1008 FloatRectangle bounds = __pSelectedBgVe->GetBounds();
1011 if (__viewConfig.__pSelectedIndexBgBitmap)
1013 Bitmap* pReplacementColorBackgroundBitmap = null;
1014 pReplacementColorBackgroundBitmap =
1015 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pSelectedIndexBgBitmap,
1016 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexBgColor);
1017 DrawBitmap(*pCanvas, bounds, *pReplacementColorBackgroundBitmap);
1019 delete pReplacementColorBackgroundBitmap;
1026 _FastScrollIndexView::DrawSelectedIndex()
1028 if (!__needUpdateSelectedIndex)
1033 SysTryReturnVoidResult(NID_UI_CTRL, __pSelectedIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndex must not be null.");
1035 Canvas* pCanvas = __pSelectedIndexVe->GetCanvasN();
1036 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the selected index ve.",
1037 GetErrorMessage(GetLastResult()));
1039 result r = E_SUCCESS;
1040 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1042 FloatRectangle bounds = __pSelectedIndexVe->GetBounds();
1043 FloatRectangle outlineBounds = __pSelectedBgVe->GetBounds();
1045 pCanvas->SetLineWidth(__viewConfig.__indexLeftLineThickness);
1046 pCanvas->SetForegroundColor(__viewConfig.__indexSelectedLineColor);
1048 if (__viewConfig.__pSelectedIndexlineBitmap)
1050 Bitmap* pReplacementColorBackgroundBitmap = null;
1051 pReplacementColorBackgroundBitmap =
1052 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pSelectedIndexlineBitmap,
1053 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__indexSelectedLineColor);
1054 DrawBitmap(*pCanvas, outlineBounds, *pReplacementColorBackgroundBitmap);
1056 delete pReplacementColorBackgroundBitmap;
1058 pCanvas->DrawLine(FloatPoint(1.0f, 0.0f), FloatPoint(1.0f, outlineBounds.y));
1059 pCanvas->DrawLine(FloatPoint(1.0f, (outlineBounds.y + outlineBounds.height)), FloatPoint(1.0f, bounds.height));
1063 TextObject* pTextObject = null;
1064 TextSimple* pSimpleText = null;
1066 float indexHeight = GetIndexHeight();
1067 FloatRectangle indexRect(0.0f, ((GetSelectedIndexOrder() * indexHeight) + __viewConfig.__indexMarginTop),
1068 bounds.width, indexHeight);
1070 Bitmap* pChildIndexImage = __pSelectedIndex->GetIndexImage();
1071 Bitmap* pReplacementColorBitmap = null;
1072 if (pChildIndexImage)
1074 FloatRectangle imageRect = indexRect;
1075 float scaleFactor = indexRect.width / pChildIndexImage->GetWidthF();
1076 float heightScaleFactor = indexRect.height / pChildIndexImage->GetHeightF();
1077 if (scaleFactor > heightScaleFactor)
1079 scaleFactor = heightScaleFactor;
1082 imageRect.width = pChildIndexImage->GetWidthF() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
1083 imageRect.height = pChildIndexImage->GetHeightF() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
1085 if (indexRect.width - imageRect.width > 0.0f)
1087 imageRect.x = indexRect.x + (indexRect.width - imageRect.width) / 2.0f;
1090 if (indexRect.height - imageRect.height > 0.0f)
1092 imageRect.y = indexRect.y + (indexRect.height - imageRect.height) / 2.0f;
1095 pReplacementColorBitmap =
1096 _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage,
1097 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexTextColor);
1098 r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap,
1099 FloatRectangle(0.0f, 0.0f, pChildIndexImage->GetWidthF(), pChildIndexImage->GetHeightF()));
1100 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r));
1102 delete pReplacementColorBitmap;
1103 pReplacementColorBitmap = null;
1107 String* pChildIndexText = __pSelectedIndex->GetIndexText();
1108 SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "[E_INVALID_STATE] pChildIndexText must not be null.");
1110 pTextObject = new (std::nothrow) TextObject();
1111 SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1113 pTextObject->Construct();
1115 pSimpleText = new (std::nothrow)TextSimple(const_cast<wchar_t*>(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1116 SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1118 r = pTextObject->AppendElement(*pSimpleText);
1119 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simpletext.", GetErrorMessage(r));
1121 r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1122 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r));
1124 r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength());
1125 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
1127 r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1128 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r));
1130 r = pTextObject->SetBounds(indexRect);
1131 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r));
1133 r = pTextObject->SetForegroundColor(__viewConfig.__selectedIndexTextColor, 0, pTextObject->GetTextLength());
1134 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r));
1136 r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1137 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r));
1140 __needUpdateSelectedIndex = false;
1146 delete pReplacementColorBitmap;
1150 _FastScrollIndexView::DrawBitmap(Canvas& canvas, const FloatRectangle& bounds, const Bitmap& bitmap)
1152 result r = E_SUCCESS;
1153 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))
1155 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
1156 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1160 r = canvas.DrawBitmap(bounds, bitmap);
1161 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1168 _FastScrollIndexView::DrawBitmap(Canvas& canvas, const FloatRectangle& srcRect, const Bitmap& bitmap, const FloatRectangle& dstRect)
1170 result r = E_SUCCESS;
1171 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))
1173 r = canvas.DrawNinePatchedBitmap(srcRect, bitmap);
1174 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1178 r = canvas.DrawBitmap(srcRect, bitmap, dstRect);
1179 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1186 _FastScrollIndexView::Construct(void)
1188 result r = E_SUCCESS;
1190 // FormattedText for Title text
1191 __pBaseIndexVe = new (std::nothrow) _VisualElement();
1192 SysTryCatch(NID_UI_CTRL, __pBaseIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1194 r = __pBaseIndexVe->Construct();
1195 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the index Ve.", GetErrorMessage(r));
1197 __pBaseIndexVe->SetAnimationProvider(this);
1199 r = __pBaseIndexVe->SetSurfaceOpaque(false);
1200 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the base index ve.", GetErrorMessage(r));
1202 __pBaseIndexVe->SetImplicitAnimationEnabled(false);
1204 r = __parentVe.AttachChild(*__pBaseIndexVe);
1205 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the base index ve to the parent.", GetErrorMessage(r));
1207 __pBaseIndexVe->SetShowState(true);
1210 __pSelectedBgVe = new (std::nothrow) _VisualElement();
1211 SysTryCatch(NID_UI_CTRL, __pSelectedBgVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1213 r = __pSelectedBgVe->Construct();
1214 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the selected Bg ve.", GetErrorMessage(r));
1216 __pSelectedBgVe->SetAnimationProvider(this);
1218 r = __pSelectedBgVe->SetSurfaceOpaque(false);
1219 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the selected Bg ve.", GetErrorMessage(r));
1221 __pSelectedBgVe->SetImplicitAnimationEnabled(false);
1223 r = __pBaseIndexVe->AttachChild(*__pSelectedBgVe);
1224 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the selected Bg ve to the parent.", GetErrorMessage(r));
1226 __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_SELECTEDBG_DIM);
1228 __pSelectedBgVe->SetShowState(true);
1230 //__pSelectedIndexVe
1231 __pSelectedIndexVe = new (std::nothrow) _VisualElement();
1232 SysTryCatch(NID_UI_CTRL, __pSelectedIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1234 r = __pSelectedIndexVe->Construct();
1235 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the selected index ve.", GetErrorMessage(r));
1237 __pSelectedIndexVe->SetAnimationProvider(this);
1239 r = __pSelectedIndexVe->SetSurfaceOpaque(false);
1240 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the selected index ve.", GetErrorMessage(r));
1242 __pSelectedIndexVe->SetImplicitAnimationEnabled(false);
1244 r = __pBaseIndexVe->AttachChild(*__pSelectedIndexVe);
1245 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the selected index ve to the parent.", GetErrorMessage(r));
1247 __pSelectedIndexVe->SetShowState(true);
1252 if (__pSelectedIndexVe)
1254 __pSelectedIndexVe->Destroy();
1255 __pSelectedIndexVe = null;
1258 if (__pSelectedBgVe)
1260 __pSelectedBgVe->Destroy();
1261 __pSelectedBgVe = null;
1266 __pBaseIndexVe->Destroy();
1267 __pBaseIndexVe = null;
1273 _FastScrollPopupView::_FastScrollPopupView(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
1274 : __parentVe(parentVe)
1275 , __viewConfig(viewConfig)
1277 , __needUpdatePopupVe(false)
1278 , __needUpdatePopupIndexVe(false)
1279 , __needDestroySelf(false)
1283 _FastScrollPopupView::~_FastScrollPopupView(void)
1285 for (int i = 0; i < GetIndexVeCount(); i++)
1287 _VisualElement* pIndexVe = GetIndexVe(i);
1291 pIndexVe->RemoveAllAnimations();
1292 pIndexVe->SetAnimationProvider(null);
1293 pIndexVe->Destroy();
1296 __indexViews.RemoveAll(false);
1300 __pPopupVe->RemoveAllAnimations();
1301 __pPopupVe->SetAnimationProvider(null);
1303 __pPopupVe->Destroy();
1308 _FastScrollPopupView*
1309 _FastScrollPopupView::CreateFastScrollPopupViewN(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
1311 _FastScrollPopupView* pPopupView = new (std::nothrow) _FastScrollPopupView(parentVe, viewConfig);
1312 SysTryReturn(NID_UI_CTRL, pPopupView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1314 result r = pPopupView->Construct();
1315 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1317 SetLastResult(E_SUCCESS);
1327 _FastScrollPopupView::FadeOutAndDestroy(void)
1329 __needDestroySelf = true;
1331 for (int i = 0; i < GetIndexVeCount(); i++)
1333 _VisualElement* pIndexVe = GetIndexVe(i);
1334 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view.");
1336 pIndexVe->RemoveAllAnimations();
1339 return SetPopupVisibility(false);
1343 _FastScrollPopupView::SelectIndex(int indexLevel, _FastScrollIndex* pIndex, _FastScrollIndex* pFormerIndex)
1345 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1346 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view.");
1350 pIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON);
1351 FloatRectangle popupVeBounds = __pPopupVe->GetBounds();
1352 FloatMatrix4 popupVeMatrix;
1353 popupVeMatrix.SetAsIdentity();
1355 if (pFormerIndex && (pFormerIndex != pIndex))
1357 FloatRectangle popupIndexVeBounds = pIndexVe->GetBounds();
1359 int selectedOrder = pIndex->GetIndexOrder(false);
1360 int oldOrder = pFormerIndex->GetIndexOrder(false);
1362 if (selectedOrder > oldOrder)
1364 _MatrixUtilTranslate(popupVeMatrix, 0.0f, 0.0f, 0.0f);
1368 _MatrixUtilTranslate(popupVeMatrix, 0.0f, -(popupVeBounds.height * (FASTSCROLL_POPUPINDEX_COUNT - 1)), 0.0f);
1370 pIndexVe->SetTransformMatrix(popupVeMatrix);
1371 pIndexVe->SetImplicitAnimationEnabled(true);
1373 popupVeMatrix.SetAsIdentity();
1374 _MatrixUtilTranslate(popupVeMatrix, 0.0f, -popupVeBounds.height, 0.0f);
1375 pIndexVe->SetTransformMatrix(popupVeMatrix);
1377 pIndexVe->SetImplicitAnimationEnabled(false);
1381 _MatrixUtilTranslate(popupVeMatrix, 0.0f, -popupVeBounds.height, 0.0f);
1382 pIndexVe->SetTransformMatrix(popupVeMatrix);
1387 pIndexVe->SetOpacity(FASTSCROLL_OPACITY_LIGHT_DIM);
1394 _FastScrollPopupView::AddPopupIndexVe(int indexLevel)
1396 result r = E_SUCCESS;
1397 _VisualElement* pPopupIndexVe = new (std::nothrow) _VisualElement();
1398 SysTryCatch(NID_UI_CTRL, pPopupIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1400 r = pPopupIndexVe->Construct();
1401 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the popup index ve.", GetErrorMessage(r));
1403 pPopupIndexVe->SetAnimationProvider(this);
1405 r = pPopupIndexVe->SetSurfaceOpaque(false);
1406 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the popup index ve.", GetErrorMessage(r));
1408 pPopupIndexVe->SetImplicitAnimationEnabled(false);
1410 r = __pPopupVe->AttachChild(*pPopupIndexVe);
1411 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the popup index ve to the popup ve.", GetErrorMessage(r));
1413 pPopupIndexVe->SetShowState(true);
1415 r = __indexViews.InsertAt(*pPopupIndexVe, indexLevel);
1416 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to change the last index view.", GetErrorMessage(r));
1423 pPopupIndexVe->RemoveAllAnimations();
1424 pPopupIndexVe->SetAnimationProvider(null);
1426 pPopupIndexVe->Destroy();
1433 _FastScrollPopupView::RemovePopupIndexVe(int indexLevel)
1435 result r = E_SUCCESS;
1437 if (indexLevel < GetIndexVeCount())
1439 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1440 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index ve.");
1442 r = __indexViews.Remove(*pIndexVe, false);
1443 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove the popup index ve.");
1445 pIndexVe->RemoveAllAnimations();
1446 pIndexVe->SetAnimationProvider(null);
1447 pIndexVe->Destroy();
1454 _FastScrollPopupView::SetPopupBounds(const FloatRectangle& indexBounds)
1456 SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null.");
1458 __pPopupVe->SetBounds(indexBounds);
1464 _FastScrollPopupView::SetPopupIndexBounds(int indexLevel, const _FastScrollIndex* pBaseIndex)
1466 FloatRectangle veBounds = __pPopupVe->GetBounds();
1467 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1468 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view.");
1474 veBounds.height = veBounds.height * FASTSCROLL_POPUPINDEX_COUNT;
1477 int indexVeCount = GetIndexVeCount();
1478 float indexWidth = veBounds.width;
1479 if (indexVeCount > 0)
1481 indexWidth /= indexVeCount;
1484 veBounds.width = indexWidth;
1485 veBounds.x = veBounds.width * indexLevel;
1487 pIndexVe->SetBounds(veBounds);
1493 _FastScrollPopupView::GetIndexVe(int indexLevel) const
1495 Object* pObj = const_cast<Object*>(__indexViews.GetAt(indexLevel));
1496 SysTryReturn(NID_UI_CTRL, pObj, null, GetLastResult(), "[%s] Failed to get the popup index ve.",
1497 GetErrorMessage(GetLastResult()));
1499 return dynamic_cast<_VisualElement*>(pObj);
1503 _FastScrollPopupView::GetIndexVeCount(void) const
1505 return __indexViews.GetCount();
1509 _FastScrollPopupView::IsOnAnimation(void) const
1515 _FastScrollPopupView::RemoveAllAnimations(void)
1517 SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null.");
1518 __pPopupVe->RemoveAllAnimations();
1522 _FastScrollPopupView::SetPopupVisibility(bool visibility)
1524 SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null.");
1528 __pPopupVe->SetTransformMatrix(__matrixFadeInStart);
1529 __pPopupVe->SetImplicitAnimationEnabled(true);
1530 __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_ON);
1531 __pPopupVe->SetTransformMatrix(__matrixOrigin);
1532 __pPopupVe->SetImplicitAnimationEnabled(false);
1536 __pPopupVe->SetImplicitAnimationEnabled(true);
1537 __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
1538 __pPopupVe->SetTransformMatrix(__matrixFadeOutEnd);
1539 __pPopupVe->SetImplicitAnimationEnabled(false);
1541 // else keep up current visibility.
1547 _FastScrollPopupView::GetPopupVisibility(void) const
1549 SysTryReturn(NID_UI_CTRL, __pPopupVe, false, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null.");
1551 float opacity = __pPopupVe->GetOpacity();
1552 if (opacity > FASTSCROLL_OPACITY_OFF)
1561 _FastScrollPopupView::SetPopupVeUpdateNeeded(bool needUpdate)
1563 __needUpdatePopupIndexVe = needUpdate;
1567 _FastScrollPopupView::UpdateIndex(void)
1569 SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null.");
1571 result r = E_SUCCESS;
1573 r = __parentVe.InvalidateRectangle(null);
1574 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to invalidate the popup Ve.");
1576 __needUpdatePopupIndexVe = true;
1582 _FastScrollPopupView::OnDraw(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex)
1585 DrawPopupIndexVe(indexLevel, pBaseIndex, pSelectedIndex);
1588 VisualElementAnimation*
1589 _FastScrollPopupView::CreateAnimationForProperty(VisualElement& target, const String& property)
1591 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
1595 const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
1596 if (pTimingFunction)
1598 pAnimation->SetTimingFunction(pTimingFunction);
1600 pAnimation->SetVisualElementAnimationStatusEventListener(this);
1606 _FastScrollPopupView::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
1611 _FastScrollPopupView::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
1616 _FastScrollPopupView::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
1618 SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] The popup Ve must not be null.");
1619 if (__pPopupVe == (static_cast <_VisualElement*>(&target)))
1621 if (__needDestroySelf && completedNormally)
1623 for (int i = 0; i < GetIndexVeCount(); i++)
1625 _VisualElement* pIndexVe = GetIndexVe(i);
1628 pIndexVe->RemoveAllAnimations();
1629 pIndexVe->SetAnimationProvider(null);
1633 __pPopupVe->RemoveAllAnimations();
1634 __pPopupVe->SetAnimationProvider(null);
1642 _FastScrollPopupView::DrawPopupVe(void)
1644 if (!__needUpdatePopupVe)
1649 SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null.");
1651 Canvas* pCanvas = __pPopupVe->GetCanvasN();
1652 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the popup ve.",
1653 GetErrorMessage(GetLastResult()));
1655 FloatRectangle bounds = __pPopupVe->GetBounds();
1656 bounds.SetPosition(0.0f, 0.0f);
1658 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1660 bool isCustomBitmap = IS_CUSTOM_BITMAP(FASTSCROLL::POPUP_BG_NORMAL);
1662 if (__viewConfig.__pPopupBgEffectBitmap && isCustomBitmap == false)
1664 DrawBitmap(*pCanvas, bounds, *__viewConfig.__pPopupBgEffectBitmap);
1667 if (__viewConfig.__pPopupBgBitmap)
1669 Bitmap* pReplacementColorBackgroundBitmap = null;
1670 pReplacementColorBackgroundBitmap =
1671 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pPopupBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__popupBgColor);
1672 DrawBitmap(*pCanvas, bounds, *pReplacementColorBackgroundBitmap);
1674 delete pReplacementColorBackgroundBitmap;
1679 __needUpdatePopupVe = false;
1684 _FastScrollPopupView::DrawPopupIndexVe(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex)
1686 if (__needUpdatePopupIndexVe != true)
1691 SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] pBaseIndex must not be null.");
1692 SysTryReturnVoidResult(NID_UI_CTRL, pSelectedIndex, E_INVALID_STATE, "[E_INVALID_STATE] pBaseIndex must not be null.");
1694 result r = E_SUCCESS;
1696 int childCount = pBaseIndex->GetChildCount();
1697 SysTryReturnVoidResult(NID_UI_CTRL, childCount > 0, E_INVALID_STATE, "[E_INVALID_STATE] The index have no children.");
1699 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1700 SysTryReturnVoidResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "[%s] Failed to get the popup index ve.",
1701 GetErrorMessage(GetLastResult()));
1703 Canvas* pCanvas = pIndexVe->GetCanvasN();
1704 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the popup index ve.",
1705 GetErrorMessage(GetLastResult()));
1707 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1710 FloatRectangle veBounds = pIndexVe->GetBounds();
1711 FloatRectangle bounds(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
1713 float indexHeight = bounds.height / FASTSCROLL_POPUPINDEX_COUNT;
1714 if (indexHeight < __viewConfig.__indexTextSize)
1716 indexHeight = __viewConfig.__indexTextSize;
1719 FloatRectangle indexRect(0.0f, 0.0f, bounds.width, indexHeight);
1720 int selectedOrder = pSelectedIndex->GetIndexOrder(false);
1721 Bitmap* pReplacementColorBitmap = null;
1723 TextObject* pTextObject = new (std::nothrow) TextObject();
1724 SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1726 pTextObject->Construct();
1728 for (int i = -1; i < 2; i++)
1730 TextSimple* pSimpleText = null;
1732 _FastScrollIndex* pChildIndex = pBaseIndex->GetChildIndex(selectedOrder + i);
1735 Bitmap* pChildIndexImage = pChildIndex->GetIndexImage();
1736 if (pChildIndexImage)
1738 FloatRectangle imageRect = indexRect;
1739 float scaleFactor = indexRect.width / pChildIndexImage->GetWidthF();
1740 float heightScale = indexRect.height / pChildIndexImage->GetHeightF();
1741 float rectHeight = indexRect.height;
1742 if (rectHeight > __viewConfig.__popupTextSize)
1744 rectHeight = __viewConfig.__popupTextSize;
1747 if (scaleFactor > heightScale)
1749 scaleFactor = heightScale;
1751 imageRect.width = pChildIndexImage->GetWidthF() * scaleFactor;
1752 imageRect.height = pChildIndexImage->GetHeightF() * scaleFactor;
1754 if (indexRect.width - imageRect.width > 0.0f)
1756 imageRect.x = indexRect.x + (indexRect.width - imageRect.width) / 2.0f;
1759 if (indexRect.height - imageRect.height > 0.0f)
1761 imageRect.y = indexRect.y + (indexRect.height - imageRect.height) / 2.0f;
1764 pReplacementColorBitmap =
1765 _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage,
1766 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__popupTextColor);
1767 r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap,
1768 FloatRectangle(0.0f, 0.0f, pChildIndexImage->GetWidthF(), pChildIndexImage->GetHeightF()));
1769 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r));
1771 delete pReplacementColorBitmap;
1772 pReplacementColorBitmap = null;
1776 String* pChildIndexText = pChildIndex->GetIndexText();
1777 SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "[E_INVALID_STATE] pChildIndexText must not be null.");
1779 pTextObject->RemoveAll();
1781 pSimpleText = new (std::nothrow)TextSimple(const_cast<wchar_t*>(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1782 SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1784 r = pTextObject->AppendElement(*pSimpleText);
1785 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simple text.", GetErrorMessage(r));
1787 r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1788 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r));
1790 r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength());
1791 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
1793 r = pTextObject->SetForegroundColor(__viewConfig.__popupTextColor, 0, pTextObject->GetTextLength());
1794 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r));
1796 r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1797 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r));
1799 r = pTextObject->SetBounds(indexRect);
1800 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r));
1802 r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1803 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r));
1807 indexRect.y += indexHeight;
1814 delete pReplacementColorBitmap;
1818 _FastScrollPopupView::DrawBitmap(Canvas& canvas, const FloatRectangle& bounds, const Bitmap& bitmap)
1820 result r = E_SUCCESS;
1821 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))
1823 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
1824 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1828 r = canvas.DrawBitmap(bounds, bitmap);
1829 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1836 _FastScrollPopupView::DrawBitmap(Canvas& canvas, const FloatRectangle& srcRect, const Bitmap& bitmap, const FloatRectangle& dstRect)
1838 result r = E_SUCCESS;
1839 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))
1841 r = canvas.DrawNinePatchedBitmap(srcRect, bitmap);
1842 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1846 r = canvas.DrawBitmap(srcRect, bitmap, dstRect);
1847 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1854 _FastScrollPopupView::Construct(void)
1856 result r = E_SUCCESS;
1858 __pPopupVe = new (std::nothrow) _VisualElement();
1859 SysTryCatch(NID_UI_CTRL, __pPopupVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1861 r = __pPopupVe->Construct();
1862 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the popup ve.", GetErrorMessage(r));
1864 __pPopupVe->SetAnimationProvider(this);
1866 r = __pPopupVe->SetSurfaceOpaque(false);
1867 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the popup ve.", GetErrorMessage(r));
1869 __pPopupVe->SetImplicitAnimationEnabled(false);
1871 r = __parentVe.AttachChild(*__pPopupVe);
1872 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the popup ve to the parent.", GetErrorMessage(r));
1874 __pPopupVe->SetShowState(true);
1875 __pPopupVe->SetClipChildrenEnabled(true);
1876 __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
1878 __needUpdatePopupVe = true;
1880 __matrixOrigin.SetAsIdentity();
1881 __matrixFadeInStart.SetAsIdentity();
1882 __matrixFadeOutEnd.SetAsIdentity();
1884 _MatrixUtilScale(__matrixFadeInStart, 0.8f, 0.8f, 1.0f);
1885 _MatrixUtilScale(__matrixFadeOutEnd, 0.1f, 0.1f, 1.0f);
1892 __pPopupVe->Destroy();
1899 _FastScrollPresenter::_FastScrollPresenter(_Control& parentCtrl, _FastScroll& fastScroll, bool visibility)
1900 : __parentCtrl(parentCtrl)
1901 , __fastScroll(fastScroll)
1903 , __pViewConfig(null)
1904 , __pFastScrollEvent(null)
1905 , __pFastScrollModel(null)
1908 , __pPopupView(null)
1909 , __focusedIndexLevel(0)
1910 , __pSelectedIndex(null)
1911 , __enableFadeEffect(true)
1912 , __indexCountMax(0)
1915 , __scrollVisibility(visibility)
1916 , __fadeEffectDuration_ms(500)
1920 _FastScrollPresenter::~_FastScrollPresenter(void)
1922 delete __pFastScrollEvent;
1923 __pFastScrollEvent = null;
1925 delete __pFastScrollModel;
1926 __pFastScrollModel = null;
1928 delete __pPopupView;
1929 __pPopupView = null;
1931 RemoveAllIndexViews(false);
1933 delete __pViewConfig;
1934 __pViewConfig = null;
1938 __pCtrlVe->RemoveAllAnimations();
1939 __pCtrlVe->SetAnimationProvider(null);
1943 _FastScrollPresenter*
1944 _FastScrollPresenter::CreateFastScrollPresenterN(_Control& parentCtrl, _FastScroll& fastScroll, bool visibility)
1946 _FastScrollPresenter* pPresenter = new (std::nothrow) _FastScrollPresenter(parentCtrl, fastScroll, visibility);
1947 SysTryReturn(NID_UI_CTRL, pPresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1949 result r = pPresenter->Construct();
1950 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1961 _FastScrollPresenter::SetRootIndex(_FastScrollIndex* pIndex)
1963 result r = E_SUCCESS;
1965 // initialize index views
1966 RemoveAllIndexViews(false);
1968 // initialize the popup view
1971 r = __pPopupView->SetPopupVisibility(false);
1972 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear visibility of the popup view.");
1975 r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__indexTextSize);
1976 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set font.");
1978 // set the root index into _FastScrollModel
1979 r = __pFastScrollModel->SetRootIndex(pIndex);
1980 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the root index into _FastScrollModel");
1982 // add new root index view.
1985 r = AddIndexView(0, *pIndex);
1986 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add the root index view.");
1993 _FastScrollPresenter::GetRootIndex(void) const
1995 return __pFastScrollModel->GetRootIndex();
1999 _FastScrollPresenter::UpdateIndex(void)
2001 result r = E_SUCCESS;
2003 // update the base index of index views
2004 int indexViewCount = GetIndexViewCount();
2005 for (int i = 0; i < indexViewCount; i++)
2007 _FastScrollIndexView* pIndexView = GetIndexView(i);
2008 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
2010 _FastScrollIndex* pIndex = pIndexView->GetBaseIndex();
2012 if ((pIndex->GetChildCount() > __indexCountMax) && (pIndex->GetIndexType() != FAST_SCROLL_INDEX_TYPE_OMISSION))
2014 r = pIndex->SetOmissionIndex(__indexCountMax);
2015 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set omiited index.");
2018 r = pIndexView->UpdateIndex(true);
2019 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view.");
2022 // update the base index of the popup view
2025 r = __pPopupView->UpdateIndex();
2026 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the popup view.");
2033 _FastScrollPresenter::EnableFadeEffect(bool enable)
2035 __enableFadeEffect = enable;
2039 _FastScrollPresenter::IsEnabledFadeEffect(void) const
2041 return __enableFadeEffect;
2045 _FastScrollPresenter::IsOnFadeEffect(void) const
2047 return (__fadeIn || __fadeOut);
2051 _FastScrollPresenter::IsScrollVisible(void) const
2053 return (__fadeIn || __fadeOut || __scrollVisibility);
2057 _FastScrollPresenter::SetScrollVisibility(bool visibility)
2059 result r = E_SUCCESS;
2061 if (GetScrollVisibility() == visibility)
2063 // keep up current visibility.
2067 if (visibility == false && __pSelectedIndex != null)
2072 __pCtrlVe->RemoveAllAnimations();
2075 if (__enableFadeEffect)
2080 __pCtrlVe->SetImplicitAnimationEnabled(true);
2083 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON);
2085 if (__enableFadeEffect)
2087 __pCtrlVe->SetImplicitAnimationEnabled(false);
2097 if (__enableFadeEffect)
2102 __pCtrlVe->SetImplicitAnimationEnabled(true);
2105 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
2107 if (__enableFadeEffect)
2109 __pCtrlVe->SetImplicitAnimationEnabled(false);
2118 __scrollVisibility = visibility;
2124 _FastScrollPresenter::GetScrollVisibility(void) const
2126 float opacity = __pCtrlVe->GetOpacity();
2128 if (__enableFadeEffect)
2130 if (__scrollVisibility)
2135 else if (opacity > FASTSCROLL_OPACITY_OFF)
2144 _FastScrollPresenter::CancelFadeEffect(void)
2149 __scrollVisibility = false;
2150 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
2155 __scrollVisibility = true;
2156 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON);
2161 _FastScrollPresenter::AddFastScrollEventListener(const Controls::_IUiFastScrollListener& listener)
2163 result r = E_SUCCESS;
2165 if (__pFastScrollEvent == null)
2167 __pFastScrollEvent = new (std::nothrow) _UiFastScrollEvent();
2168 SysTryReturnVoidResult(NID_UI_CTRL, __pFastScrollEvent, E_OUT_OF_MEMORY,
2169 "[E_OUT_OF_MEMORY] Memory allocation failed.");
2171 r = __pFastScrollEvent->Construct(__fastScroll);
2172 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2175 r = __pFastScrollEvent->AddListener(listener);
2176 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2180 _FastScrollPresenter::RemoveFastScrollEventListener(const Controls::_IUiFastScrollListener& listener)
2182 result r = E_SUCCESS;
2184 SysTryReturnVoidResult(NID_UI_CTRL, __pFastScrollEvent, E_INVALID_STATE, "[E_INVALID_STATE] __pFastScrollEvent must not be null.");
2186 r = __pFastScrollEvent->RemoveListener(listener);
2187 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2191 _FastScrollPresenter::AddAccessibilityElement(const _AccessibilityContainer& control, bool onAccessibility)
2193 _FastScrollIndexView* pIndexView = GetIndexView(0);
2194 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get fastscroll indexview.",
2195 GetErrorMessage(GetLastResult()));
2197 _AccessibilityContainer* pAccessibilityContainer = const_cast <_AccessibilityContainer*>(&control);
2198 result r = pAccessibilityContainer->RemoveAllElement();
2199 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove accessibility elements.");
2200 _AccessibilityElement* pAccessibilityElement = null;
2202 if (onAccessibility)
2204 r = pIndexView->AddAccessibilityElement(control);
2205 SysTryReturnResult(NID_UI_CTRL, r = E_SUCCESS, r, "Failed to Add accessibility element.");
2209 pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
2210 SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
2212 pAccessibilityElement->SetBounds(pIndexView->GetIndexBounds());
2213 pAccessibilityElement->SetTrait(L"Fast scroll bar");
2214 pAccessibilityElement->SetName(L"FastScroll");
2215 pAccessibilityElement->SetHint(L"double tap to enter fast scroll mode");
2216 r = pAccessibilityContainer->AddElement(*pAccessibilityElement);
2217 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Add accessibility element.", GetErrorMessage(r));
2222 delete pAccessibilityElement;
2227 _FastScrollPresenter::OnParentBoundsChanged(void)
2229 RelayoutFastScrollChildren();
2233 _FastScrollPresenter::OnDraw(void)
2236 bool availableTextSize = (__fastScroll.GetBoundsF().height >= __pViewConfig->__popupTextSize);
2237 int indexViewCount = GetIndexViewCount();
2238 for (int i = 0; i < indexViewCount; i++)
2240 _FastScrollIndexView* pIndexView = GetIndexView(i);
2241 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2242 GetErrorMessage(GetLastResult()));
2244 result r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__indexTextSize);
2245 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r));
2246 pIndexView->OnDraw();
2248 // draw the popup view
2249 if (__pPopupView && i <= __focusedIndexLevel)
2251 if (availableTextSize)
2253 r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__popupTextSize);
2255 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r));
2256 __pPopupView->OnDraw(i, pIndexView->GetBaseIndex(), pIndexView->GetSelectedIndexInOmittedIndex());
2262 __pPopupView->SetPopupVeUpdateNeeded(false);
2267 _FastScrollPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
2269 FloatPoint touchedPosition = touchinfo.GetCurrentPosition();
2270 return OnTouchPressedAndMoved(touchedPosition, true);
2274 _FastScrollPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
2276 return OnTouchReleasedAndCanceled();
2280 _FastScrollPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
2282 FloatPoint touchedPosition = touchinfo.GetCurrentPosition();
2283 return OnTouchPressedAndMoved(touchedPosition, false);
2287 _FastScrollPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
2289 return OnTouchReleasedAndCanceled();
2293 _FastScrollPresenter::OnAncestorVisibleStateChanged(const _Control& control)
2295 OnTouchReleasedAndCanceled();
2299 _FastScrollPresenter::OnAncestorEnableStateChanged(const _Control& control)
2301 OnTouchReleasedAndCanceled();
2305 _FastScrollPresenter::OnAncestorInputEnableStateChanged(const _Control& control)
2307 OnTouchReleasedAndCanceled();
2311 _FastScrollPresenter::OnFontChanged(Font* pFont)
2313 __pViewConfig->__pFont = pFont;
2317 _FastScrollPresenter::OnFontInfoRequested(unsigned long& style, float& size)
2319 style = __fontStyle;
2324 _FastScrollPresenter::SetFontInfo(unsigned long style, float size)
2326 __fontStyle = style;
2329 __pViewConfig->__pFont = __fastScroll.GetFallbackFont();
2330 SysTryReturnResult(NID_UI_CTRL, __pViewConfig->__pFont, GetLastResult(), "Failed to get a font.");
2335 VisualElementAnimation*
2336 _FastScrollPresenter::CreateAnimationForProperty(VisualElement& target, const String& property)
2338 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
2342 const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
2343 if (pTimingFunction)
2345 pAnimation->SetTimingFunction(pTimingFunction);
2347 pAnimation->SetVisualElementAnimationStatusEventListener(this);
2353 _FastScrollPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
2358 _FastScrollPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
2363 _FastScrollPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
2365 if (__pCtrlVe == (static_cast <_VisualElement*>(&target)))
2373 _FastScrollPresenter::HitTest(const Tizen::Graphics::FloatPoint& point)
2375 if (IsScrollVisible() == false)
2377 return HIT_TEST_NOWHERE;
2380 int indexViewCount = GetIndexViewCount();
2381 for (int i = 0; i < indexViewCount; i++)
2383 _FastScrollIndexView* pIndexView = GetIndexView(i);
2384 SysTryReturn(NID_UI_CTRL, pIndexView, HIT_TEST_NOWHERE, GetLastResult(), "[%s] Failed to get the index view.",
2385 GetErrorMessage(GetLastResult()));
2387 FloatRectangle indexBounds = pIndexView->GetIndexBoundsF();
2388 if (indexBounds.Contains(point) == true)
2390 return HIT_TEST_MATCH;
2394 return HIT_TEST_NOWHERE;
2398 _FastScrollPresenter::OnIndexDataUpdated(_FastScrollIndex& updatedIndex)
2400 result r = E_SUCCESS;
2402 int indexViewCount = GetIndexViewCount();
2403 for (int i = 0; i < indexViewCount; i++)
2405 _FastScrollIndexView* pIndexView = GetIndexView(i);
2406 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2407 GetErrorMessage(GetLastResult()));
2409 if (pIndexView->GetBaseIndex() == &updatedIndex)
2411 r = pIndexView->UpdateIndex(false);
2412 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2416 r = __pPopupView->UpdateIndex();
2417 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update the popup view.", GetErrorMessage(r));
2425 _FastScrollPresenter::OnIndexDeleted(_FastScrollIndex& deletedIndex)
2427 result r = E_SUCCESS;
2429 int indexViewCount = GetIndexViewCount();
2430 for (int i = 0; i < indexViewCount; i++)
2432 _FastScrollIndexView* pIndexView = GetIndexView(i);
2433 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2434 GetErrorMessage(GetLastResult()));
2436 if (pIndexView->GetBaseIndex() == &deletedIndex)
2438 // first of all, update the base index view
2441 _FastScrollIndexView* pBaseIndexView = GetIndexView(i - 1);
2442 SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2443 GetErrorMessage(GetLastResult()));
2445 r = pBaseIndexView->UpdateIndex(false);
2446 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2449 // then remove the index view for detached index.
2450 RemoveIndexView(i, true);
2452 delete __pPopupView;
2453 __pPopupView = null;
2457 else if (pIndexView->GetBaseIndex() == deletedIndex.GetParentIndex())
2459 r = pIndexView->UpdateIndex(false);
2460 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2462 r = __pPopupView->UpdateIndex();
2463 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r));
2469 _FastScrollPresenter::OnChildIndexAttached(_FastScrollIndex& parentIndex, int attachedOrder, _FastScrollIndex& attachedIndex)
2471 result r = E_SUCCESS;
2473 int indexViewCount = GetIndexViewCount();
2474 for (int i = 0; i < indexViewCount; i++)
2476 _FastScrollIndexView* pIndexView = GetIndexView(i);
2477 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2478 GetErrorMessage(GetLastResult()));
2480 if (pIndexView->GetBaseIndex() == &parentIndex)
2482 r = pIndexView->UpdateIndex(false);
2483 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2485 r = __pPopupView->UpdateIndex();
2486 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r));
2493 _FastScrollPresenter::OnChildIndexDetached(_FastScrollIndex& parentIndex, int detachedOrder, _FastScrollIndex& detachedIndex)
2495 result r = E_SUCCESS;
2497 int indexViewCount = GetIndexViewCount();
2498 for (int i = 0; i < indexViewCount; i++)
2500 _FastScrollIndexView* pIndexView = GetIndexView(i);
2501 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2502 GetErrorMessage(GetLastResult()));
2504 if (pIndexView->GetBaseIndex() == &detachedIndex)
2506 // first of all, update the base index view
2509 _FastScrollIndexView* pBaseIndexView = GetIndexView(i - 1);
2510 SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2511 GetErrorMessage(GetLastResult()));
2513 r = pBaseIndexView->UpdateIndex(false);
2514 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2517 // then remove the index view for detached index.
2518 RemoveIndexView(i, true);
2520 delete __pPopupView;
2521 __pPopupView = null;
2524 else if (pIndexView->GetBaseIndex() == &parentIndex)
2526 r = pIndexView->UpdateIndex(false);
2527 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2529 r = __pPopupView->UpdateIndex();
2530 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r));
2537 _FastScrollPresenter::Construct(void)
2539 result r = E_SUCCESS;
2541 // load color/shape configuration and bitmap resources
2542 __pViewConfig = _FastScrollViewConfig::CreateFastScrollViewConfigN(_CONTROL_ORIENTATION_PORTRAIT);
2543 SysTryReturnResult(NID_UI_CTRL, __pViewConfig, GetLastResult(), "Failed to create _FastScrollViewConfig.");
2545 // create _FastScrollModel
2546 __pFastScrollModel = _FastScrollModel::CreateFastScrollModelN();
2547 SysTryCatch(NID_UI_CTRL, __pFastScrollModel, , GetLastResult(), "[%s] Failed to create _FastScrollModel.",
2548 GetErrorMessage(GetLastResult()));
2550 // initialize visual elements
2551 __pCtrlVe = __fastScroll.GetVisualElement();
2552 SysTryCatch(NID_UI_CTRL, __pCtrlVe, , GetLastResult(), "[%s] Failed to get VisualElement of the _FastScroll",
2553 GetErrorMessage(GetLastResult()));
2555 __pCtrlVe->SetAnimationProvider(this);
2556 __pCtrlVe->SetClipChildrenEnabled(false);
2558 if (__scrollVisibility)
2560 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON);
2564 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
2567 // initialize the fastscroll control
2568 r = __fastScroll.SetBounds(CalculateFastScrollBounds(0));
2569 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the bounds of _FastScroll", GetErrorMessage(r));
2571 __fastScroll.SetBackgroundColor(Tizen::Graphics::Color(0, 0, 0, 0));
2573 __indexCountMax = _CoordinateSystemUtils::ConvertToInteger((__fastScroll.GetBoundsF().height -
2574 (__pViewConfig->__indexMarginTop * 2.0f)) / __pViewConfig->__indexSizeMin.height);
2579 delete __pFastScrollModel;
2580 __pFastScrollModel = null;
2582 delete __pViewConfig;
2583 __pViewConfig = null;
2585 return GetLastResult();
2589 _FastScrollPresenter::CalculateFastScrollBounds(int indexCount)
2591 FloatRectangle fastScrollBounds(0.0f, 0.0f, 0.0f, 0.0f);
2592 FloatRectangle parentBounds = __parentCtrl.GetBoundsF();
2593 fastScrollBounds.width = parentBounds.width;
2594 fastScrollBounds.height = parentBounds.height;
2595 return fastScrollBounds;
2599 _FastScrollPresenter::CalculateIndexBounds(int indexLevel, _FastScrollIndex& pIndex)
2601 FloatRectangle fastScrollBounds = __fastScroll.GetBoundsF();
2602 FloatRectangle indexBounds(0.0f, 0.0f, __pViewConfig->__indexSizeMin.width, fastScrollBounds.height);
2604 indexBounds.x = fastScrollBounds.width - __pViewConfig->__indexSizeMin.width;
2605 for (int i = 1; i <= indexLevel; i++)
2607 indexBounds.x -= __pViewConfig->__indexGap + __pViewConfig->__indexSizeMin.width;
2610 if (indexBounds.x < 0.0f)
2612 indexBounds.x = 0.0f;
2615 if (indexLevel != 0)
2617 int childCount = pIndex.GetChildCount();
2618 indexBounds.height = (childCount * __pViewConfig->__indexSizeMin.height) + (__pViewConfig->__indexMarginTop * 2.0f);
2620 if (indexBounds.height < fastScrollBounds.height)
2622 _FastScrollIndexView* pParentIndexView = GetIndexView(indexLevel - 1);
2623 if (pParentIndexView)
2625 FloatRectangle parentBounds = pParentIndexView->GetIndexBoundsF();
2627 indexBounds.y = parentBounds.y + (pIndex.GetIndexOrder() * pParentIndexView->GetIndexHeight()) - __pViewConfig->__indexMarginTop;
2628 if (indexBounds.y < fastScrollBounds.y)
2630 indexBounds.y = fastScrollBounds.y;
2633 float totalHeight = indexBounds.y + indexBounds.height;
2634 if (_FloatCompare(totalHeight, fastScrollBounds.height) || (totalHeight > fastScrollBounds.height))
2636 indexBounds.y = fastScrollBounds.height - indexBounds.height;
2642 indexBounds.height = fastScrollBounds.height;
2650 _FastScrollPresenter::CalculatePopupBounds(void)
2652 FloatRectangle popupBounds(0.0f, 0.0f, 0.0f, 0.0f);
2653 FloatRectangle parentBounds = __parentCtrl.GetBoundsF();
2654 FloatRectangle fastScrollBounds = __fastScroll.GetBoundsF();
2656 popupBounds.width = __pViewConfig->__popupSize.width + (__pViewConfig->__popupWidthIncrement * __focusedIndexLevel);
2657 if (popupBounds.width > parentBounds.width)
2659 popupBounds.width = parentBounds.width;
2662 popupBounds.height = __pViewConfig->__popupSize.height;
2663 if (popupBounds.height > parentBounds.height)
2665 popupBounds.height = parentBounds.height;
2668 popupBounds.x = ((parentBounds.width - popupBounds.width) / 2.0f) - fastScrollBounds.x;
2669 if (popupBounds.x < 0.0f)
2671 popupBounds.x = 0.0f;
2674 popupBounds.y = ((parentBounds.height - popupBounds.height) / 2.0f) - fastScrollBounds.y;
2675 if (popupBounds.y < 0.0f)
2677 popupBounds.y = 0.0f;
2684 _FastScrollPresenter::RelayoutFastScrollChildren(void)
2686 result r = E_SUCCESS;
2688 int indexViewCount = GetIndexViewCount();
2690 // initialize the fastscroll control
2691 r = __fastScroll.SetBounds(CalculateFastScrollBounds(indexViewCount));
2692 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set the bounds of _FastScroll", GetErrorMessage(r));
2694 __indexCountMax = _CoordinateSystemUtils::ConvertToInteger((__fastScroll.GetBoundsF().height -
2695 (__pViewConfig->__indexMarginTop * 2.0f)) / __pViewConfig->__indexSizeMin.height);
2697 for (int i = 0; i < indexViewCount; i++)
2699 _FastScrollIndexView* pIndexView = GetIndexView(i);
2700 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2701 GetErrorMessage(GetLastResult()));
2703 r = pIndexView->SetIndexBounds(CalculateIndexBounds(i, *(pIndexView->GetBaseIndex())));
2704 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set bounds of the index.", GetErrorMessage(r));
2706 _FastScrollIndex* pIndex = pIndexView->GetBaseIndex();
2707 if (pIndex->GetIndexType() == FAST_SCROLL_INDEX_TYPE_OMISSION)
2709 _FastScrollIndex* pSelectedIndex = pIndexView->GetSelectedIndex();
2710 if (pSelectedIndex && pSelectedIndex->GetOmitted())
2712 pIndexView->SetSelectedIndex(null);
2714 r = pIndex->RemoveOmissionChildren(false);
2715 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to remove omission index view", GetErrorMessage(r));
2718 if (pIndex->GetChildCount() > __indexCountMax)
2720 r = pIndex->SetOmissionIndex(__indexCountMax);
2721 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set omission index.", GetErrorMessage(r));
2724 r = pIndexView->UpdateIndex(false);
2725 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2730 r = __pPopupView->SetPopupBounds(CalculatePopupBounds());
2731 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set bounds of the popup view.", GetErrorMessage(r));
2736 _FastScrollPresenter::SelectOnIndexViews(const FloatPoint& point, bool animation)
2738 result r = E_SUCCESS;
2740 _FastScrollIndex* pSelectedIndex = null;
2741 int selectedIndexLevel = 0;
2742 int indexViewCount = GetIndexViewCount();
2743 SysTryReturn(NID_UI_CTRL, indexViewCount > 0, null, E_INVALID_STATE, "[E_INVALID_STATE] The root index view is invalid state.");
2745 // search the hit index on index views, then fade out other index views
2746 for (int i = 0; i < indexViewCount; i++)
2748 _FastScrollIndexView* pIndexView = GetIndexView(i);
2749 SysTryReturn(NID_UI_CTRL, pIndexView, null, GetLastResult(), "[%s] Failed to get the index view.",
2750 GetErrorMessage(GetLastResult()));
2752 _FastScrollIndex* pIndex = pIndexView->GetIndexAtPoint(point);
2755 // select the index of the index view.
2756 r = pIndexView->SelectIndex(pIndex, animation);
2757 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r));
2758 pSelectedIndex = pIndex;
2759 if (pIndex->GetOmitted() == true)
2761 pSelectedIndex = pIndexView->GetOmissionIndexAtPoint(pIndex, point);
2763 pIndexView->SetSelectedIndexInOmittedIndex(pSelectedIndex);
2765 selectedIndexLevel = i;
2770 // if can no find the index on views, select index of the last index view
2771 if ((pSelectedIndex == null) && (__focusedIndexLevel != -1))
2773 _FastScrollIndexView* pFocusedIndexView = GetIndexView(__focusedIndexLevel);
2774 SysTryReturn(NID_UI_CTRL, pFocusedIndexView, null, GetLastResult(), "[%s] Failed to get the index view.",
2775 GetErrorMessage(GetLastResult()));
2777 _FastScrollIndex* pIndex = pFocusedIndexView->GetIndexAtPoint(FloatPoint(pFocusedIndexView->GetIndexBoundsF().x, point.y));
2780 // select the index of the focused index view.
2781 r = pFocusedIndexView->SelectIndex(pIndex, animation);
2782 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r));
2783 pSelectedIndex = pIndex;
2785 if (pIndex->GetOmitted() == true)
2787 pSelectedIndex = pFocusedIndexView->GetOmissionIndexAtPoint(pIndex,
2788 FloatPoint(pFocusedIndexView->GetIndexBoundsF().x, point.y));
2789 if (pSelectedIndex == null)
2791 pSelectedIndex = pFocusedIndexView->GetSelectedIndexInOmittedIndex();
2794 pFocusedIndexView->SetSelectedIndexInOmittedIndex(pSelectedIndex);
2796 selectedIndexLevel = __focusedIndexLevel;
2800 pSelectedIndex = pFocusedIndexView->GetSelectedIndex();
2801 if (pSelectedIndex && pSelectedIndex->GetOmitted() == true)
2803 pSelectedIndex = pFocusedIndexView->GetSelectedIndexInOmittedIndex();
2805 selectedIndexLevel = __focusedIndexLevel;
2811 int childCount = pSelectedIndex->GetChildCount();
2812 if (childCount > 0 && (pSelectedIndex->GetOmitted() == false))
2814 _FastScrollIndexView* pSelectedIndexView = GetIndexView(selectedIndexLevel + 1);
2815 if (pSelectedIndexView)
2817 r = pSelectedIndexView->SelectIndex((_FastScrollIndex*)null, false);
2818 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r));
2820 r = pSelectedIndexView->SetBaseIndex(pSelectedIndex);
2821 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set the base index of the index view.", GetErrorMessage(r));
2823 r = pSelectedIndexView->SetIndexBounds(CalculateIndexBounds(selectedIndexLevel + 1, *pSelectedIndex));
2824 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set bounds of the index.", GetErrorMessage(r));
2826 r = pSelectedIndexView->SetIndexVisibility(true);
2827 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set the visibility of the index view.", GetErrorMessage(r));
2829 indexViewCount = GetIndexViewCount();
2830 while (indexViewCount > selectedIndexLevel + 2)
2832 r = RemoveIndexView(indexViewCount - 1, true);
2833 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r));
2834 indexViewCount = GetIndexViewCount();
2839 r = AddIndexView(*pSelectedIndex);
2840 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to add new child index.", GetErrorMessage(r));
2843 if ((childCount > __indexCountMax) && (pSelectedIndex->GetIndexType() != FAST_SCROLL_INDEX_TYPE_OMISSION))
2845 r = pSelectedIndex->SetOmissionIndex(__indexCountMax);
2846 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set omission index.", GetErrorMessage(r));
2851 indexViewCount = GetIndexViewCount();
2852 while (indexViewCount > selectedIndexLevel + 1)
2854 r = RemoveIndexView(indexViewCount - 1, true);
2855 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r));
2856 indexViewCount = GetIndexViewCount();
2862 indexViewCount = GetIndexViewCount();
2863 while (indexViewCount > 1)
2865 r = RemoveIndexView(indexViewCount - 1, true);
2866 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r));
2867 indexViewCount = GetIndexViewCount();
2871 __focusedIndexLevel = selectedIndexLevel;
2872 return pSelectedIndex;
2876 _FastScrollPresenter::DeselectIndexViews(void)
2878 result r = E_SUCCESS;
2880 while (GetIndexViewCount() > 1)
2882 RemoveIndexView(GetIndexViewCount() - 1, true);
2885 _FastScrollIndexView* pIndexView = GetIndexView(0);
2886 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
2888 r = pIndexView->SelectIndex((_FastScrollIndex*)null, true);
2889 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear the index selection.");
2890 pIndexView->SetSelectedIndexInOmittedIndex(null);
2892 __fastScroll.Invalidate();
2898 _FastScrollPresenter::SetPopupIndex(_FastScrollIndex& popupIndex, const FloatPoint& point)
2900 result r = E_SUCCESS;
2902 // set the selected node into the popup views.
2903 if (__pPopupView == null)
2905 __pPopupView = _FastScrollPopupView::CreateFastScrollPopupViewN(*__pCtrlVe, *__pViewConfig);
2906 SysTryReturnResult(NID_UI_CTRL, __pPopupView, GetLastResult(), "Propagating.");
2908 r = __pPopupView->SetPopupBounds(CalculatePopupBounds());
2909 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup view.");
2911 r = __pPopupView->SetPopupVisibility(true);
2912 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the popup view.");
2915 int indexViewCount = __focusedIndexLevel + 1;
2916 int popupIndexViewCount = __pPopupView->GetIndexVeCount();
2918 if (indexViewCount != popupIndexViewCount)
2920 r = __pPopupView->SetPopupBounds(CalculatePopupBounds());
2921 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup view.");
2923 if (indexViewCount > popupIndexViewCount)
2925 for (int i = popupIndexViewCount; i < indexViewCount; i++)
2927 r = __pPopupView->AddPopupIndexVe(i);
2928 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add popup index ve.");
2931 else if (indexViewCount < popupIndexViewCount)
2933 for (int i = indexViewCount; i < popupIndexViewCount; i++)
2935 r = __pPopupView->RemovePopupIndexVe(i);
2936 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove popup index ve.");
2941 r = __pPopupView->UpdateIndex();
2942 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the popup view.");
2944 for (int i = 0; i < indexViewCount; i++)
2946 _FastScrollIndexView* pIndexView = GetIndexView(i);
2947 SysTryReturnResult(NID_UI_CTRL, pIndexView, r, "Failed to index view.");
2949 r = __pPopupView->SetPopupIndexBounds(i, pIndexView->GetBaseIndex());
2950 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup index ve.");
2952 _FastScrollIndex* pFormerIndex = null;
2953 if ( i == __focusedIndexLevel )
2955 pFormerIndex = pIndexView->GetFormerIndex();
2956 r = __pPopupView->SelectIndex(i, &popupIndex, pFormerIndex);
2957 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the popup index.");
2961 r = __pPopupView->SelectIndex(i, null, null);
2962 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the popup index.");
2970 _FastScrollPresenter::ClearPopupIndex(void)
2972 result r = E_SUCCESS;
2974 // clear the node data of the popup view
2977 r = __pPopupView->FadeOutAndDestroy();
2978 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear visibility of the popup view.");
2980 __pPopupView = null;
2987 _FastScrollPresenter::FireFastScrollEvent(_FastScrollIndex& selectedIndex)
2989 // fire the fast scroll event
2990 if (__pFastScrollEvent)
2992 String* pIndexNodeText = selectedIndex.GetIndexText();
2995 _UiFastScrollEventArg* pEventArg = new (std::nothrow) _UiFastScrollEventArg(*__pFastScrollEvent->GetSource(), selectedIndex);
2996 SysTryReturnResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "Memory allocation failed.");
2998 __pFastScrollEvent->Fire(*pEventArg);
3006 _FastScrollPresenter::OnTouchPressedAndMoved(const FloatPoint& point, bool animation)
3008 result r = E_SUCCESS;
3010 _FastScrollIndex* pSelectedIndex = SelectOnIndexViews(point, animation);
3011 if (pSelectedIndex && (__pSelectedIndex != pSelectedIndex))
3013 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
3014 r = SetPopupIndex(*pSelectedIndex, point);
3015 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to set the poup index.", GetErrorMessage(r));
3017 r = FireFastScrollEvent(*pSelectedIndex);
3018 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to send the fast scroll event.", GetErrorMessage(r));
3021 __pSelectedIndex = pSelectedIndex;
3027 _FastScrollPresenter::OnTouchReleasedAndCanceled(void)
3029 result r = E_SUCCESS;
3031 r = DeselectIndexViews();
3032 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to deselect index views.", GetErrorMessage(r));
3034 r = ClearPopupIndex();
3035 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to clear the popup index.", GetErrorMessage(r));
3037 __pSelectedIndex = null;
3043 _FastScrollPresenter::AddIndexView(_FastScrollIndex& baseIndex)
3045 return AddIndexView(GetIndexViewCount(), baseIndex);
3049 _FastScrollPresenter::AddIndexView(int indexLevel, _FastScrollIndex& baseIndex)
3051 result r = E_SUCCESS;
3053 _FastScrollIndexView* pNewIndexView = _FastScrollIndexView::CreateFastScrollIndexViewN( *__pCtrlVe, *__pViewConfig);
3054 SysTryReturnResult(NID_UI_CTRL, pNewIndexView, GetLastResult(), "Propagating.");
3056 r = __fastScroll.SetBounds(CalculateFastScrollBounds(GetIndexViewCount() + 1));
3057 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll.");
3059 r = pNewIndexView->SetIndexBounds(CalculateIndexBounds(indexLevel, baseIndex));
3060 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the index view.");
3062 r = pNewIndexView->SetBaseIndex(&baseIndex);
3063 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the index data for the index view.");
3065 r = pNewIndexView->SetIndexVisibility(true);
3066 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the index view.");
3068 r = __indexViews.InsertAt(*pNewIndexView, indexLevel);
3069 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to change the last index view.");
3075 _FastScrollPresenter::RemoveIndexView(int indexLevel, bool fadeout)
3077 result r = E_SUCCESS;
3079 int indexViewCount = GetIndexViewCount();
3080 if (indexLevel < indexViewCount)
3082 _FastScrollIndexView* pIndexView = GetIndexView(indexLevel);
3083 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
3087 r = pIndexView->FadeOutAndDestroy();
3088 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to request to fade out of the index view.");
3091 r = __indexViews.Remove(*pIndexView, false);
3092 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove the index views.");
3094 // initialize the fastscroll control
3095 r = __fastScroll.SetBounds(CalculateFastScrollBounds(GetIndexViewCount()));
3096 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll");
3103 _FastScrollPresenter::RemoveAllIndexViews(bool fadeout)
3105 result r = E_SUCCESS;
3109 int indexViewCount = GetIndexViewCount();
3110 for (int i = 0; i < indexViewCount; i++)
3112 _FastScrollIndexView* pIndexView = GetIndexView(i);
3113 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
3115 r = pIndexView->FadeOutAndDestroy();
3116 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to request to fade out of the index view.");
3120 __indexViews.RemoveAll(true);
3122 // initialize the fastscroll control
3123 r = __fastScroll.SetBounds(CalculateFastScrollBounds(0));
3124 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll.");
3129 _FastScrollIndexView*
3130 _FastScrollPresenter::GetIndexView(int indexLevel) const
3132 Object* pIndexView = const_cast<Object*>(__indexViews.GetAt(indexLevel));
3133 SysTryReturn(NID_UI_CTRL, pIndexView, null, GetLastResult(), "[%s] Failed to get the index view.",
3134 GetErrorMessage(GetLastResult()));
3136 return dynamic_cast<_FastScrollIndexView*>(pIndexView);
3140 _FastScrollPresenter::GetIndexViewCount(void) const
3142 return __indexViews.GetCount();
3145 } } } // Tizen::Ui::Controls