2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_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>
37 #include <FBaseSysLog.h>
38 #include "FGrp_BitmapImpl.h"
39 #include "FGrp_TextTextObject.h"
40 #include <FGrp_TextTextSimple.h>
41 #include "FUiAnim_VisualElement.h"
42 #include "FUi_Control.h"
43 #include "FUi_UiTouchEvent.h"
44 #include "FUi_ResourceManager.h"
45 #include "FUiCtrl_IFastScrollListener.h"
46 #include "FUiCtrl_UiFastScrollEvent.h"
47 #include "FUiCtrl_UiFastScrollEventArg.h"
48 #include "FUiCtrl_FastScroll.h"
49 #include "FUiCtrl_FastScrollPresenter.h"
50 #include "FUiCtrl_FastScrollModel.h"
51 #include "FUiCtrl_FastScrollIndex.h"
53 #include "FUiAnim_MatrixUtil.h"
55 using namespace Tizen::Base;
56 using namespace Tizen::Graphics;
57 using namespace Tizen::Ui;
58 using namespace Tizen::Ui::Animations;
59 using namespace Tizen::Graphics::_Text;
63 const float FASTSCROLL_OPACITY_ON = 1.0f;
64 const float FASTSCROLL_OPACITY_SELECTEDBG_DIM = 0.5f;
65 const float FASTSCROLL_OPACITY_LIGHT_DIM = 0.3f;
66 const float FASTSCROLL_OPACITY_OFF = 0.0f;
67 const int FASTSCROLL_POPUPINDEX_COUNT = 3;
70 namespace Tizen { namespace Ui { namespace Controls
74 #define MAX(a, b) ((a) > (b) ? (a) : (b))
75 #define MIN(a, b) ((a) < (b) ? (a) : (b))
79 _FastScrollViewConfig::_FastScrollViewConfig(void)
80 : __indexBgColor(Color::GetColor(COLOR_ID_BLACK))
81 , __indexHighlightColor(Color::GetColor(COLOR_ID_BLACK))
82 , __indexLeftLineColor(Color::GetColor(COLOR_ID_BLACK))
83 , __indexTextColor(Color::GetColor(COLOR_ID_BLACK))
84 , __indexSeparatorColor(Color::GetColor(COLOR_ID_BLACK))
85 , __selectedIndexBgColor(Color::GetColor(COLOR_ID_BLACK))
86 , __selectedIndexTextColor(Color::GetColor(COLOR_ID_BLACK))
87 , __selectedIndexOutlineColor(Color::GetColor(COLOR_ID_BLACK))
88 , __popupBgColor(Color::GetColor(COLOR_ID_BLACK))
89 , __popupTextColor(Color::GetColor(COLOR_ID_BLACK))
90 , __indexSizeMin(0, 0)
92 , __indexMarginRight(0)
95 , __indexLeftLineThickness(0)
97 , __indexSeparatorThickness(0)
98 , __selectedIndexMarginRight(0)
99 , __selectedIndexHeight(0)
100 , __popupWidthIncrement(0)
102 , __popupShadowRight(0)
103 , __popupShadowBottom(0)
104 , __pIndexBgBitmap(null)
105 , __pSelectedIndexBgBitmap(null)
106 , __pSelectedIndexOutlineBitmap(null)
107 , __pPopupBgBitmap(null)
108 , __pPopupBgEffectBitmap(null)
113 _FastScrollViewConfig::~_FastScrollViewConfig(void)
118 _FastScrollViewConfig*
119 _FastScrollViewConfig::CreateFastScrollViewConfigN(_ControlOrientation orientation)
121 _FastScrollViewConfig* pConfig = new (std::nothrow) _FastScrollViewConfig();
122 SysTryReturn(NID_UI_CTRL, pConfig, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
124 result r = pConfig->Construct(orientation);
125 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
127 SetLastResult(E_SUCCESS);
137 _FastScrollViewConfig::ReloadConfig(_ControlOrientation orientation)
139 result r = E_SUCCESS;
141 // release allocated resources.
144 // load bitmap resources
145 r = GET_BITMAP_CONFIG_N(FASTSCROLL::INDEX_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pIndexBgBitmap);
146 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
148 r = GET_BITMAP_CONFIG_N(FASTSCROLL::SELECTED_INDEX_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pSelectedIndexBgBitmap);
149 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
151 r = GET_BITMAP_CONFIG_N(FASTSCROLL::SELECTED_INDEX_OUTLINE, BITMAP_PIXEL_FORMAT_ARGB8888, __pSelectedIndexOutlineBitmap);
152 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
154 r = GET_BITMAP_CONFIG_N(FASTSCROLL::POPUP_BG, BITMAP_PIXEL_FORMAT_ARGB8888, __pPopupBgEffectBitmap);
155 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
157 r = GET_BITMAP_CONFIG_N(FASTSCROLL::POPUP_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pPopupBgBitmap);
158 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
161 // load shape configuration
162 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __indexSizeMin.width);
163 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
165 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __indexSizeMin.height);
166 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
168 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __indexMarginTop);
169 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
171 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_LEFT_LINE_THICKNESS, _CONTROL_ORIENTATION_PORTRAIT, __indexLeftLineThickness);
172 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
174 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __indexTextSize);
175 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
177 r = GET_FIXED_VALUE_CONFIG(FASTSCROLL::INDEX_SEPARATOR_THICKNESS, _CONTROL_ORIENTATION_PORTRAIT, __indexSeparatorThickness);
178 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
180 r = GET_SHAPE_CONFIG(FASTSCROLL::SELECTED_INDEX_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __selectedIndexMarginRight);
181 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
183 r = GET_SHAPE_CONFIG(FASTSCROLL::SELECTED_INDEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __selectedIndexHeight);
184 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
186 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __popupSize.width);
187 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
189 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __popupSize.height);
190 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
192 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_WIDTH_INCREMENT, _CONTROL_ORIENTATION_PORTRAIT, __popupWidthIncrement);
193 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
195 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __popupTextSize);
196 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
198 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_RIGHT_SHADOW, _CONTROL_ORIENTATION_PORTRAIT, __popupShadowRight);
199 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
201 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_BOTTOM_SHADOW, _CONTROL_ORIENTATION_PORTRAIT, __popupShadowBottom);
202 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
205 // load color configuration
206 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_BAR, __indexBgColor);
207 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
209 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_LEFT_LINE, __indexLeftLineColor);
210 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
212 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_BAR_TEXT, __indexTextColor);
213 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
215 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_SEPARATOR, __indexSeparatorColor);
216 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
218 r = GET_COLOR_CONFIG(FASTSCROLL::SELECTED_INDEX_BG, __selectedIndexBgColor);
219 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
221 r = GET_COLOR_CONFIG(FASTSCROLL::SELECTED_INDEX_TEXT, __selectedIndexTextColor);
222 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
224 r = GET_COLOR_CONFIG(FASTSCROLL::SELECTED_INDEX_OUTLINE, __selectedIndexOutlineColor);
225 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
227 r = GET_COLOR_CONFIG(FASTSCROLL::POPUP_BG, __popupBgColor);
228 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
230 r = GET_COLOR_CONFIG(FASTSCROLL::POPUP_TEXT, __popupTextColor);
231 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
236 __indexBgColor = Color::GetColor(COLOR_ID_BLACK);
237 __indexHighlightColor = Color::GetColor(COLOR_ID_BLACK);
238 __indexLeftLineColor = Color::GetColor(COLOR_ID_BLACK);
239 __indexTextColor = Color::GetColor(COLOR_ID_BLACK);
240 __indexSeparatorColor = Color::GetColor(COLOR_ID_BLACK);
241 __selectedIndexBgColor = Color::GetColor(COLOR_ID_BLACK);
242 __selectedIndexTextColor = Color::GetColor(COLOR_ID_BLACK);
243 __selectedIndexOutlineColor = Color::GetColor(COLOR_ID_BLACK);
244 __popupBgColor = Color::GetColor(COLOR_ID_BLACK);
245 __popupTextColor = Color::GetColor(COLOR_ID_BLACK);
247 __indexSizeMin.SetSize(0, 0);
248 __popupSize.SetSize(0, 0);
250 __indexMarginRight = 0;
251 __indexMarginTop = 0;
253 __indexLeftLineThickness = 0;
255 __indexSeparatorThickness = 0;
256 __selectedIndexMarginRight = 0;
257 __selectedIndexHeight = 0;
258 __popupWidthIncrement = 0;
267 _FastScrollViewConfig::ReleaseResources(void)
269 delete __pIndexBgBitmap;
270 delete __pSelectedIndexBgBitmap;
271 delete __pSelectedIndexOutlineBitmap;
272 delete __pPopupBgBitmap;
273 delete __pPopupBgEffectBitmap;
275 __pIndexBgBitmap = null;
276 __pSelectedIndexBgBitmap = null;
277 __pSelectedIndexOutlineBitmap = null;
278 __pPopupBgBitmap = null;
279 __pPopupBgEffectBitmap = null;
283 _FastScrollViewConfig::Construct(_ControlOrientation orientation)
285 return ReloadConfig(orientation);
289 _FastScrollIndexView::_FastScrollIndexView(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
290 : __parentVe(parentVe)
291 , __viewConfig(viewConfig)
293 , __pSelectedIndex(null)
294 , __pSelectedIndexInOmittedIndex(null)
295 , __pFormerIndex(null)
296 , __pBaseIndexVe(null)
297 , __pSelectedBgVe(null)
298 , __pSelectedIndexVe(null)
299 , __needUpdateBaseIndex(false)
300 , __needUpdateSelectedIndex(false)
301 , __needDestroySelf(false)
305 _FastScrollIndexView::~_FastScrollIndexView(void)
307 if (__pSelectedIndexVe)
309 __pSelectedIndexVe->RemoveAllAnimations();
310 __pSelectedIndexVe->SetAnimationProvider(null);
312 __pSelectedIndexVe->Destroy();
313 __pSelectedIndexVe = null;
318 __pSelectedBgVe->RemoveAllAnimations();
319 __pSelectedBgVe->SetAnimationProvider(null);
321 __pSelectedBgVe->Destroy();
322 __pSelectedBgVe = null;
327 __pBaseIndexVe->RemoveAllAnimations();
328 __pBaseIndexVe->SetAnimationProvider(null);
330 __pBaseIndexVe->Destroy();
331 __pBaseIndexVe = null;
335 _FastScrollIndexView*
336 _FastScrollIndexView::CreateFastScrollIndexViewN(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
338 _FastScrollIndexView* pIndexView = new (std::nothrow) _FastScrollIndexView(parentVe, viewConfig);
339 SysTryReturn(NID_UI_CTRL, pIndexView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
341 result r = pIndexView->Construct();
342 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
344 SetLastResult(E_SUCCESS);
354 _FastScrollIndexView::FadeOutAndDestroy(void)
356 __needDestroySelf = true;
357 if (__pSelectedIndexVe)
359 __pSelectedIndexVe->RemoveAllAnimations();
364 __pSelectedBgVe->RemoveAllAnimations();
367 return SetIndexVisibility(false);
371 _FastScrollIndexView::SetBaseIndex(_FastScrollIndex* pIndex)
373 __pBaseIndex = pIndex;
375 result r = UpdateIndex(false);
376 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view.");
382 _FastScrollIndexView::GetBaseIndex(void) const
388 _FastScrollIndexView::SetIndexBounds(const Rectangle& indexBounds)
390 SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null.");
392 FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height);
394 __pBaseIndexVe->SetBounds(veBounds);
396 __needUpdateBaseIndex = true;
400 __pSelectedIndexVe->SetBounds(veBounds);
402 __needUpdateSelectedIndex = true;
408 _FastScrollIndexView::GetIndexBounds(void) const
410 FloatRectangle veBounds = __pBaseIndexVe->GetBounds();
411 return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
415 _FastScrollIndexView::SetSelectedBgBounds(const Rectangle& indexBounds)
417 SysTryReturnResult(NID_UI_CTRL, __pSelectedBgVe, E_INVALID_STATE, "__pSelectedBgVe must not be null.");
419 FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height);
420 __pSelectedBgVe->SetBounds(veBounds);
426 _FastScrollIndexView::GetSelectedBgBounds(void) const
428 SysTryReturn(NID_UI_CTRL, __pSelectedBgVe, Rectangle(0, 0, 0, 0), E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedBgVe must not be null.");
430 FloatRectangle veBounds = __pSelectedBgVe->GetBounds();
431 return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
435 _FastScrollIndexView::SetSelectedIndexBounds(const Rectangle& indexBounds)
437 SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null.");
439 FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height);
440 __pSelectedIndexVe->SetBounds(veBounds);
446 _FastScrollIndexView::GetSelectedIndexBounds(void) const
448 SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, Rectangle(0, 0, 0, 0), E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndexVe must not be null.");
450 FloatRectangle veBounds = __pSelectedIndexVe->GetBounds();
451 return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
455 _FastScrollIndexView::GetIndexAtPoint(const Point& point) const
457 SysTryReturn(NID_UI_CTRL, __pBaseIndex, null, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
459 int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
460 SysTryReturn(NID_UI_CTRL, childCount > 0, null, E_INVALID_STATE, "[E_INVALID_STATE] The index have no children.");
462 _FastScrollIndex* pChildIndex = null;
464 Rectangle bounds = GetIndexBounds();
465 if (bounds.Contains(point) == true)
467 int touchY = point.y - bounds.y - __viewConfig.__indexMarginTop;
468 int indexHeight = GetIndexHeight();
471 if ((touchY != 0) && (indexHeight != 0))
473 indexOrder = touchY / indexHeight;
476 pChildIndex = __pBaseIndex->GetChildIndex(indexOrder, true);
477 SysTryReturn(NID_UI_CTRL, pChildIndex, null, GetLastResult(), "[%s] Failed to get the child index.",
478 GetErrorMessage(GetLastResult()));
481 SetLastResult(E_SUCCESS);
486 _FastScrollIndexView::GetOmissionIndexAtPoint(_FastScrollIndex* pIndex, const Point& point) const
488 Rectangle bounds = GetIndexBounds();
489 int touchY = point.y - bounds.y - __viewConfig.__indexMarginTop - (pIndex->GetIndexOrder(true) * GetIndexHeight());
490 int indexHeight = GetIndexHeight() / pIndex->GetChildCount();
491 int omissionIndexOrder = 0;
493 if ((touchY != 0) && (indexHeight != 0))
495 omissionIndexOrder = touchY / indexHeight;
498 _FastScrollIndex* pChildIndex = pIndex->GetChildIndex(omissionIndexOrder);
499 SysTryReturn(NID_UI_CTRL, pChildIndex, null, GetLastResult(), "[%s] Failed to get the child index.",
500 GetErrorMessage(GetLastResult()));
502 SetLastResult(E_SUCCESS);
507 _FastScrollIndexView::GetIndexHeight(void) const
509 Rectangle bounds = GetIndexBounds();
510 int indexHeight = __viewConfig.__indexSizeMin.height;
512 if (__pBaseIndex->GetParentIndex() == null)
514 indexHeight = MAX(indexHeight,
515 ((bounds.height - __viewConfig.__indexMarginTop * 2) / __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType())));
522 _FastScrollIndexView::SelectIndex(int indexOrder)
524 result r = E_SUCCESS;
526 SysTryReturnResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "__pBaseIndex must not be null.");
528 _FastScrollIndex* pIndex = __pBaseIndex->GetChildIndex(indexOrder, true);
529 SysTryReturnResult(NID_UI_CTRL, pIndex, GetLastResult(), "Failed to get the child index.");
531 r = SelectIndex(pIndex, false);
532 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the index.");
538 _FastScrollIndexView::SelectIndex(_FastScrollIndex* pIndex, bool animation)
540 result r = E_SUCCESS;
542 if (__pSelectedIndex == pIndex)
547 __pSelectedIndex = pIndex;
549 if (__pSelectedIndex)
551 r = SetSelectedBgBounds(CalculateSelectedBg());
552 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to get the canvas of the Selected Bg ve.");
554 if (GetSelectedIndexVisibility() == false)
556 r = SetSelectedIndexVisibility(true, animation);
557 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the Selected Bg ve.");
562 if (GetSelectedIndexVisibility() == true)
564 r = SetSelectedIndexVisibility(false, animation);
565 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the Selected Bg ve.");
567 SetSelectedIndexInOmittedIndex(null);
568 __pFormerIndex = null;
571 r = UpdateIndex(false);
572 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view.");
578 _FastScrollIndexView::GetSelectedIndexOrder(void) const
580 SysTryReturn(NID_UI_CTRL, __pBaseIndex, -1, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
581 SysTryReturn(NID_UI_CTRL, __pSelectedIndex, -1, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndex must not be null.");
583 return __pBaseIndex->GetChildOrder(__pSelectedIndex, true);
587 _FastScrollIndexView::GetSelectedIndex(void) const
589 return __pSelectedIndex;
593 _FastScrollIndexView::SetSelectedIndexInOmittedIndex(_FastScrollIndex* pIndex)
595 __pFormerIndex = __pSelectedIndexInOmittedIndex;
596 __pSelectedIndexInOmittedIndex = pIndex;
600 _FastScrollIndexView::GetSelectedIndexInOmittedIndex(void) const
602 return __pSelectedIndexInOmittedIndex;
606 _FastScrollIndexView::GetFormerIndex(void) const
608 return __pFormerIndex;
612 _FastScrollIndexView::IsOnAnimation(void) const
618 _FastScrollIndexView::RemoveAllAnimations(void)
620 __pBaseIndexVe->RemoveAllAnimations();
624 _FastScrollIndexView::SetIndexVisibility(bool visibility)
626 result r = E_SUCCESS;
628 __pBaseIndexVe->SetImplicitAnimationEnabled(true);
632 __pBaseIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON);
636 __pBaseIndexVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
638 // else keep up current visibility.
640 __pBaseIndexVe->SetImplicitAnimationEnabled(false);
646 _FastScrollIndexView::GetIndexVisibility(void) const
648 float opacity = __pBaseIndexVe->GetOpacity();
649 if (opacity > FASTSCROLL_OPACITY_OFF)
660 _FastScrollIndexView::SetSelectedIndexVisibility(bool visibility, bool animation)
662 SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null.");
663 SysTryReturnResult(NID_UI_CTRL, __pSelectedBgVe, E_INVALID_STATE, "__pSelectedBgVe must not be null.");
667 __pSelectedIndexVe->SetImplicitAnimationEnabled(true);
668 __pSelectedBgVe->SetImplicitAnimationEnabled(true);
673 __pSelectedIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON);
674 __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_SELECTEDBG_DIM);
678 __pSelectedIndexVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
679 __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
681 // else keep up current visibility.
683 __pSelectedIndexVe->SetImplicitAnimationEnabled(false);
684 __pSelectedBgVe->SetImplicitAnimationEnabled(false);
690 _FastScrollIndexView::GetSelectedIndexVisibility(void) const
692 SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, false, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndexVe must not be null.");
694 float opacity = __pSelectedIndexVe->GetOpacity();
695 if (opacity > FASTSCROLL_OPACITY_OFF)
705 _FastScrollIndexView::AddAccessibilityElement(const _AccessibilityContainer& control)
707 SysTryReturnResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
709 int omittedChildCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
710 SysTryReturnResult(NID_UI_CTRL, omittedChildCount > 0, E_INVALID_STATE, "The index have no children.");
712 Rectangle bounds = GetIndexBounds();
713 int indexHeight = GetIndexHeight();
714 Rectangle indexRect(bounds.x, __viewConfig.__indexMarginTop, bounds.width, indexHeight);
715 int nonOmittedIndex = 0;
717 _AccessibilityElement* pAccessibilityElement = null;
718 result r = E_SUCCESS;
719 for (int i = 0; i < omittedChildCount; )
721 _FastScrollIndex* pChildIndex = __pBaseIndex->GetChildIndex(i, true);
722 SysTryReturnResult(NID_UI_CTRL, pChildIndex, GetLastResult(), "Failed to get the child index.");
724 int omittedCount = 0;
725 if (pChildIndex->GetOmitted())
727 omittedCount = pChildIndex->GetChildCount();
728 pChildIndex = __pBaseIndex->GetChildIndex(nonOmittedIndex, false);
729 SysTryReturnResult(NID_UI_CTRL, pChildIndex, GetLastResult(), "Failed to get the child index.");
732 Bitmap* pChildIndexImage = pChildIndex->GetIndexImage();
733 if (pChildIndexImage == null)
735 String* pChildIndexText = pChildIndex->GetIndexText();
736 SysTryReturnResult(NID_UI_CTRL, pChildIndexText, E_INVALID_STATE, "pChildIndexText must not be null.");
738 _AccessibilityContainer* pAccessibilityContainer = const_cast <_AccessibilityContainer*>(&control);
739 pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
740 SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
741 pAccessibilityElement->SetBounds(indexRect);
742 pAccessibilityElement->SetLabel(*pChildIndexText);
743 pAccessibilityElement->SetName(L"FastScrollIndex");
744 pAccessibilityElement->SetHint(L"double tap to move ," + *pChildIndexText + L", list");
745 r = pAccessibilityContainer->AddElement(*pAccessibilityElement);
746 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add accessibility element.", GetErrorMessage(r));
749 if (omittedCount > 1)
755 indexRect.y += indexHeight;
765 delete pAccessibilityElement;
770 _FastScrollIndexView::UpdateIndex(bool bNeedUpdateBaseIndex)
772 result r = E_SUCCESS;
774 r = __parentVe.InvalidateRectangle(null);
775 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to invalidate the index Ve.");
777 if (__pSelectedIndex)
779 __needUpdateSelectedIndex = true;
782 if (bNeedUpdateBaseIndex)
784 __needUpdateBaseIndex = true;
791 _FastScrollIndexView::CalculateSelectedBg(void)
793 SysTryReturn(NID_UI_CTRL, __pBaseIndex, Rectangle(0, 0, 0, 0), E_INVALID_STATE,
794 "[E_INVALID_STATE] __pBaseIndex must not be null.");
795 SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, Rectangle(0, 0, 0, 0), E_INVALID_STATE,
796 "[E_INVALID_STATE] __pSelectedIndexVe must not be null.");
797 SysTryReturn(NID_UI_CTRL, __pSelectedIndex, Rectangle(0, 0, 0, 0), E_INVALID_STATE,
798 "[E_INVALID_STATE] __pSelectedIndex must not be null.");
800 int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
801 SysTryReturn(NID_UI_CTRL, childCount > 0, Rectangle(0, 0, 0, 0), E_INVALID_STATE, "[E_INVALID_STATE] The index have no children.");
803 Rectangle bounds = GetIndexBounds();
804 int indexHeight = GetIndexHeight();
805 int selectedIndexOrder = GetSelectedIndexOrder();
806 Rectangle selectedRect(0, 0, (bounds.width - __viewConfig.__selectedIndexMarginRight), __viewConfig.__selectedIndexHeight);
808 if (indexHeight > __viewConfig.__selectedIndexHeight)
810 selectedRect.y = (selectedIndexOrder * indexHeight) + __viewConfig.__indexMarginTop * 2;
811 selectedRect.height = indexHeight - (__viewConfig.__indexMarginTop * 2) ;
813 else if (bounds.height <= __viewConfig.__selectedIndexHeight)
815 selectedRect.height = bounds.height;
819 if (selectedIndexOrder == (childCount - 1))
821 selectedRect.y = bounds.height - __viewConfig.__selectedIndexHeight - __viewConfig.__indexMarginTop;
825 selectedRect.y = ((selectedIndexOrder * indexHeight) + __viewConfig.__indexMarginTop) - (__viewConfig.__selectedIndexHeight - indexHeight) / 2;
826 selectedRect.y = MAX (selectedRect.y, __viewConfig.__indexMarginTop);
834 _FastScrollIndexView::OnDraw(void)
837 if (__pSelectedIndex)
845 _FastScrollIndexView::DrawBaseIndex()
847 if (!__needUpdateBaseIndex)
852 SysTryReturnVoidResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
854 result r = E_SUCCESS;
856 int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
857 SysTryReturnVoidResult(NID_UI_CTRL, childCount > 0, E_INVALID_STATE, "[E_INVALID_STATE] The index have no children.");
859 Canvas* pCanvas = __pBaseIndexVe->GetCanvasN();
860 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the index ve.",
861 GetErrorMessage(GetLastResult()));
863 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
867 pCanvas->SetLineWidth(__viewConfig.__indexSeparatorThickness);
869 Rectangle bounds = GetIndexBounds();
870 int indexHeight = GetIndexHeight();
872 //Draw background ef, bitmap
873 Rectangle bgBounds(0, 0, bounds.width, bounds.height);
874 if (__viewConfig.__pIndexBgBitmap)
876 Bitmap* pReplacementColorBackgroundBitmap =
877 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pIndexBgBitmap,
878 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__indexBgColor);
879 DrawBitmap(*pCanvas, bgBounds, *pReplacementColorBackgroundBitmap);
881 delete pReplacementColorBackgroundBitmap;
884 Rectangle indexRect(0, __viewConfig.__indexMarginTop, bounds.width, indexHeight);
885 Bitmap* pReplacementColorBitmap = null;
887 TextObject* pTextObject = new (std::nothrow) TextObject();
888 SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
890 pTextObject->Construct();
892 for (int i = 0; i < childCount; i++)
894 TextSimple* pSimpleText = null;
896 _FastScrollIndex* pChildIndex = __pBaseIndex->GetChildIndex(i, true);
897 SysTryCatch(NID_UI_CTRL, pChildIndex, , GetLastResult(), "[%s] Failed to get the child index.",
898 GetErrorMessage(GetLastResult()));
900 Bitmap* pChildIndexImage = pChildIndex->GetIndexImage();
901 if (pChildIndexImage)
903 Rectangle imageRect = indexRect;
905 float scaleFactor = MIN(((float)indexRect.width / pChildIndexImage->GetWidth()), ((float)indexRect.height / pChildIndexImage->GetHeight()));
907 imageRect.width = pChildIndexImage->GetWidth() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
908 imageRect.height = pChildIndexImage->GetHeight() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
910 if (indexRect.width - imageRect.width > 0)
912 imageRect.x = indexRect.x + (indexRect.width - imageRect.width)/2;
915 if (indexRect.height - imageRect.height > 0)
917 imageRect.y = indexRect.y + (indexRect.height - imageRect.height)/2;
920 pReplacementColorBitmap =
921 _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage,
922 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__indexTextColor);
923 r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap,
924 Rectangle(0, 0, pChildIndexImage->GetWidth(), pChildIndexImage->GetHeight()));
925 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r));
927 delete pReplacementColorBitmap;
928 pReplacementColorBitmap = null;
932 String* pChildIndexText = pChildIndex->GetIndexText();
933 SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "pChildIndexText must not be null.");
935 pTextObject->RemoveAll();
937 pSimpleText = new (std::nothrow)TextSimple(const_cast<wchar_t*>(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
938 SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed");
940 r = pTextObject->AppendElement(*pSimpleText);
941 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simple text.", GetErrorMessage(r));
943 r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
944 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r));
946 r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength());
947 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
949 r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
950 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r));
952 r = pTextObject->SetBounds(indexRect);
953 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r));
955 r = pTextObject->SetForegroundColor(__viewConfig.__indexTextColor, 0, pTextObject->GetTextLength());
956 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r));
958 r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
959 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r));
963 indexRect.y += indexHeight;
964 if (i != (childCount - 1))
966 pCanvas->SetForegroundColor(__viewConfig.__indexSeparatorColor);
967 pCanvas->DrawLine(Point(indexRect.x, indexRect.y + __viewConfig.__indexSeparatorThickness),
968 Point(indexRect.x + indexRect.width, indexRect.y + __viewConfig.__indexSeparatorThickness));
972 __needUpdateBaseIndex = false;
977 delete pReplacementColorBitmap;
981 _FastScrollIndexView::DrawSelectedBg()
983 if (!__needUpdateSelectedIndex)
988 SysTryReturnVoidResult(NID_UI_CTRL, __pSelectedIndex, E_INVALID_STATE,
989 "[E_INVALID_STATE] __pSelectedIndex must not be null.");
991 Canvas* pCanvas = __pSelectedBgVe->GetCanvasN();
992 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the Selected Bg ve.",
993 GetErrorMessage(GetLastResult()));
995 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
998 Rectangle bounds = GetSelectedBgBounds();
1001 if (__viewConfig.__pSelectedIndexBgBitmap)
1003 Bitmap* pReplacementColorBackgroundBitmap = null;
1004 pReplacementColorBackgroundBitmap =
1005 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pSelectedIndexBgBitmap,
1006 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexBgColor);
1007 DrawBitmap(*pCanvas, bounds, *pReplacementColorBackgroundBitmap);
1009 delete pReplacementColorBackgroundBitmap;
1016 _FastScrollIndexView::DrawSelectedIndex()
1018 if (!__needUpdateSelectedIndex)
1023 SysTryReturnVoidResult(NID_UI_CTRL, __pSelectedIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndex must not be null.");
1025 Canvas* pCanvas = __pSelectedIndexVe->GetCanvasN();
1026 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the selected index ve.",
1027 GetErrorMessage(GetLastResult()));
1029 result r = E_SUCCESS;
1031 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1033 Rectangle bounds = GetSelectedIndexBounds();
1035 //draw selected outline
1036 Rectangle outlineBounds = GetSelectedBgBounds();
1037 if (__viewConfig.__pSelectedIndexOutlineBitmap)
1039 Bitmap* pReplacementColorBackgroundBitmap = null;
1040 pReplacementColorBackgroundBitmap =
1041 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pSelectedIndexOutlineBitmap,
1042 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexOutlineColor);
1043 DrawBitmap(*pCanvas, outlineBounds, *pReplacementColorBackgroundBitmap);
1045 delete pReplacementColorBackgroundBitmap;
1049 pCanvas->SetLineWidth(__viewConfig.__indexLeftLineThickness);
1050 pCanvas->SetForegroundColor(__viewConfig.__indexLeftLineColor);
1052 pCanvas->DrawLine(Point(0, 0), Point(0, outlineBounds.y));
1053 pCanvas->DrawLine(Point(0, (outlineBounds.y + 1 + outlineBounds.height)), Point(0, bounds.height));
1056 TextObject* pTextObject = null;
1057 TextSimple* pSimpleText = null;
1059 int indexHeight = GetIndexHeight();
1060 Rectangle indexRect(0, ((GetSelectedIndexOrder() * indexHeight) + __viewConfig.__indexMarginTop),
1061 bounds.width, indexHeight);
1063 Bitmap* pChildIndexImage = __pSelectedIndex->GetIndexImage();
1064 Bitmap* pReplacementColorBitmap = null;
1065 if (pChildIndexImage)
1067 Rectangle imageRect = indexRect;
1069 float scaleFactor = MIN(((float)indexRect.width / pChildIndexImage->GetWidth()), ((float)indexRect.height / pChildIndexImage->GetHeight()));
1071 imageRect.width = pChildIndexImage->GetWidth() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
1072 imageRect.height = pChildIndexImage->GetHeight() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
1074 if (indexRect.width - imageRect.width > 0)
1076 imageRect.x = indexRect.x + (indexRect.width - imageRect.width)/2;
1079 if (indexRect.height - imageRect.height > 0)
1081 imageRect.y = indexRect.y + (indexRect.height - imageRect.height)/2;
1084 pReplacementColorBitmap =
1085 _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage,
1086 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexTextColor);
1087 r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap,
1088 Rectangle(0, 0, pChildIndexImage->GetWidth(), pChildIndexImage->GetHeight()));
1089 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r));
1091 delete pReplacementColorBitmap;
1092 pReplacementColorBitmap = null;
1096 String* pChildIndexText = __pSelectedIndex->GetIndexText();
1097 SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "[E_INVALID_STATE] pChildIndexText must not be null.");
1099 pTextObject = new (std::nothrow) TextObject();
1100 SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1102 pTextObject->Construct();
1104 pSimpleText = new (std::nothrow)TextSimple(const_cast<wchar_t*>(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1105 SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1107 r = pTextObject->AppendElement(*pSimpleText);
1108 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simpletext.", GetErrorMessage(r));
1110 r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1111 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r));
1113 r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength());
1114 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
1116 r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1117 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r));
1119 r = pTextObject->SetBounds(indexRect);
1120 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r));
1122 r = pTextObject->SetForegroundColor(__viewConfig.__selectedIndexTextColor, 0, pTextObject->GetTextLength());
1123 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r));
1125 r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1126 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r));
1130 __needUpdateSelectedIndex = false;
1136 delete pReplacementColorBitmap;
1140 _FastScrollIndexView::DrawBitmap(Canvas& canvas, const Rectangle& bounds, const Bitmap& bitmap)
1142 result r = E_SUCCESS;
1143 if (bitmap.IsNinePatchedBitmap())
1145 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
1146 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1150 r = canvas.DrawBitmap(bounds, bitmap);
1151 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1158 _FastScrollIndexView::DrawBitmap(Canvas& canvas, const Rectangle& srcRect, const Bitmap& bitmap, const Rectangle& dstRect)
1160 result r = E_SUCCESS;
1161 if (bitmap.IsNinePatchedBitmap())
1163 r = canvas.DrawNinePatchedBitmap(srcRect, bitmap);
1164 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1168 r = canvas.DrawBitmap(srcRect, bitmap, dstRect);
1169 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1175 VisualElementAnimation*
1176 _FastScrollIndexView::CreateAnimationForProperty(VisualElement& target, const String& property)
1178 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
1182 const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
1183 if (pTimingFunction)
1185 pAnimation->SetTimingFunction(pTimingFunction);
1187 pAnimation->SetVisualElementAnimationStatusEventListener(this);
1193 _FastScrollIndexView::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
1198 _FastScrollIndexView::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
1203 _FastScrollIndexView::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
1205 if (__pBaseIndexVe == (static_cast <_VisualElement*>(&target)))
1207 if (__needDestroySelf && completedNormally)
1209 if (__pSelectedIndexVe)
1211 __pSelectedIndexVe->RemoveAllAnimations();
1212 __pSelectedIndexVe->SetAnimationProvider(null);
1215 if (__pSelectedBgVe)
1217 __pSelectedBgVe->RemoveAllAnimations();
1218 __pSelectedBgVe->SetAnimationProvider(null);
1221 __pBaseIndexVe->RemoveAllAnimations();
1222 __pBaseIndexVe->SetAnimationProvider(null);
1230 _FastScrollIndexView::Construct(void)
1232 result r = E_SUCCESS;
1234 // FormattedText for Title text
1235 __pBaseIndexVe = new (std::nothrow) _VisualElement();
1236 SysTryCatch(NID_UI_CTRL, __pBaseIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1238 r = __pBaseIndexVe->Construct();
1239 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the index Ve.", GetErrorMessage(r));
1241 __pBaseIndexVe->SetAnimationProvider(this);
1243 r = __pBaseIndexVe->SetSurfaceOpaque(false);
1244 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the base index ve.", GetErrorMessage(r));
1246 __pBaseIndexVe->SetImplicitAnimationEnabled(false);
1248 r = __parentVe.AttachChild(*__pBaseIndexVe);
1249 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the base index ve to the parent.", GetErrorMessage(r));
1251 __pBaseIndexVe->SetShowState(true);
1254 __pSelectedBgVe = new (std::nothrow) _VisualElement();
1255 SysTryCatch(NID_UI_CTRL, __pSelectedBgVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1257 r = __pSelectedBgVe->Construct();
1258 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the selected Bg ve.", GetErrorMessage(r));
1260 __pSelectedBgVe->SetAnimationProvider(this);
1262 r = __pSelectedBgVe->SetSurfaceOpaque(false);
1263 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the selected Bg ve.", GetErrorMessage(r));
1265 __pSelectedBgVe->SetImplicitAnimationEnabled(false);
1267 r = __pBaseIndexVe->AttachChild(*__pSelectedBgVe);
1268 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the selected Bg ve to the parent.", GetErrorMessage(r));
1270 __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_SELECTEDBG_DIM);
1272 __pSelectedBgVe->SetShowState(true);
1274 //__pSelectedIndexVe
1275 __pSelectedIndexVe = new (std::nothrow) _VisualElement();
1276 SysTryCatch(NID_UI_CTRL, __pSelectedIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1278 r = __pSelectedIndexVe->Construct();
1279 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the selected index ve.", GetErrorMessage(r));
1281 __pSelectedIndexVe->SetAnimationProvider(this);
1283 r = __pSelectedIndexVe->SetSurfaceOpaque(false);
1284 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the selected index ve.", GetErrorMessage(r));
1286 __pSelectedIndexVe->SetImplicitAnimationEnabled(false);
1288 r = __pBaseIndexVe->AttachChild(*__pSelectedIndexVe);
1289 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the selected index ve to the parent.", GetErrorMessage(r));
1291 __pSelectedIndexVe->SetShowState(true);
1296 if (__pSelectedIndexVe)
1298 __pSelectedIndexVe->Destroy();
1299 __pSelectedIndexVe = null;
1302 if (__pSelectedBgVe)
1304 __pSelectedBgVe->Destroy();
1305 __pSelectedBgVe = null;
1310 __pBaseIndexVe->Destroy();
1311 __pBaseIndexVe = null;
1317 _FastScrollPopupView::_FastScrollPopupView(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
1318 : __parentVe(parentVe)
1319 , __viewConfig(viewConfig)
1321 , __needUpdatePopupVe(false)
1322 , __needUpdatePopupIndexVe(false)
1323 , __needDestroySelf(false)
1327 _FastScrollPopupView::~_FastScrollPopupView(void)
1329 for (int i = 0; i < GetIndexVeCount(); i++)
1331 _VisualElement* pIndexVe = GetIndexVe(i);
1335 pIndexVe->RemoveAllAnimations();
1336 pIndexVe->SetAnimationProvider(null);
1337 pIndexVe->Destroy();
1340 __indexViews.RemoveAll(false);
1344 __pPopupVe->RemoveAllAnimations();
1345 __pPopupVe->SetAnimationProvider(null);
1347 __pPopupVe->Destroy();
1352 _FastScrollPopupView*
1353 _FastScrollPopupView::CreateFastScrollPopupViewN(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
1355 _FastScrollPopupView* pPopupView = new (std::nothrow) _FastScrollPopupView(parentVe, viewConfig);
1356 SysTryReturn(NID_UI_CTRL, pPopupView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1358 result r = pPopupView->Construct();
1359 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1361 SetLastResult(E_SUCCESS);
1371 _FastScrollPopupView::FadeOutAndDestroy(void)
1373 __needDestroySelf = true;
1375 for (int i = 0; i < GetIndexVeCount(); i++)
1377 _VisualElement* pIndexVe = GetIndexVe(i);
1378 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view.");
1380 pIndexVe->RemoveAllAnimations();
1383 return SetPopupVisibility(false);
1387 _FastScrollPopupView::SelectIndex(int indexLevel, _FastScrollIndex* pIndex, _FastScrollIndex* pFormerIndex)
1389 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1390 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view.");
1394 pIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON);
1395 FloatRectangle popupVeBounds = __pPopupVe->GetBounds();
1396 FloatMatrix4 popupVeMatrix;
1397 popupVeMatrix.SetAsIdentity();
1399 if (pFormerIndex && (pFormerIndex != pIndex))
1401 FloatRectangle popupIndexVeBounds = pIndexVe->GetBounds();
1403 int selectedOrder = pIndex->GetIndexOrder(false);
1404 int oldOrder = pFormerIndex->GetIndexOrder(false);
1406 if (selectedOrder > oldOrder)
1408 _MatrixUtilTranslate(popupVeMatrix, 0, 0, 0);
1412 _MatrixUtilTranslate(popupVeMatrix, 0, -(popupVeBounds.height * (FASTSCROLL_POPUPINDEX_COUNT - 1)), 0);
1414 pIndexVe->SetTransformMatrix(popupVeMatrix);
1415 pIndexVe->SetImplicitAnimationEnabled(true);
1417 popupVeMatrix.SetAsIdentity();
1418 _MatrixUtilTranslate(popupVeMatrix, 0, -popupVeBounds.height, 0);
1419 pIndexVe->SetTransformMatrix(popupVeMatrix);
1421 pIndexVe->SetImplicitAnimationEnabled(false);
1425 _MatrixUtilTranslate(popupVeMatrix, 0, -popupVeBounds.height, 0);
1426 pIndexVe->SetTransformMatrix(popupVeMatrix);
1431 pIndexVe->SetOpacity(FASTSCROLL_OPACITY_LIGHT_DIM);
1438 _FastScrollPopupView::AddPopupIndexVe(int indexLevel)
1440 result r = E_SUCCESS;
1441 _VisualElement* pPopupIndexVe = new (std::nothrow) _VisualElement();
1442 SysTryCatch(NID_UI_CTRL, pPopupIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1444 r = pPopupIndexVe->Construct();
1445 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the popup index ve.", GetErrorMessage(r));
1447 pPopupIndexVe->SetAnimationProvider(this);
1449 r = pPopupIndexVe->SetSurfaceOpaque(false);
1450 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the popup index ve.", GetErrorMessage(r));
1452 pPopupIndexVe->SetImplicitAnimationEnabled(false);
1454 r = __pPopupVe->AttachChild(*pPopupIndexVe);
1455 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the popup index ve to the popup ve.", GetErrorMessage(r));
1457 pPopupIndexVe->SetShowState(true);
1459 r = __indexViews.InsertAt(*pPopupIndexVe, indexLevel);
1460 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to change the last index view.", GetErrorMessage(r));
1467 pPopupIndexVe->RemoveAllAnimations();
1468 pPopupIndexVe->SetAnimationProvider(null);
1470 pPopupIndexVe->Destroy();
1477 _FastScrollPopupView::RemovePopupIndexVe(int indexLevel)
1479 result r = E_SUCCESS;
1481 if (indexLevel < GetIndexVeCount())
1483 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1484 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index ve.");
1486 r = __indexViews.Remove(*pIndexVe, false);
1487 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove the popup index ve.");
1489 pIndexVe->RemoveAllAnimations();
1490 pIndexVe->SetAnimationProvider(null);
1491 pIndexVe->Destroy();
1498 _FastScrollPopupView::SetPopupBounds(const Rectangle& indexBounds)
1500 SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null.");
1502 FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height);
1503 __pPopupVe->SetBounds(veBounds);
1509 _FastScrollPopupView::GetPopupBounds(void) const
1511 SysTryReturn(NID_UI_CTRL, __pPopupVe, Rectangle(0, 0, 0, 0), E_INVALID_STATE,
1512 "[E_INVALID_STATE] __pPopupVe must not be null.");
1514 FloatRectangle veBounds = __pPopupVe->GetBounds();
1515 return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
1519 _FastScrollPopupView::SetPopupIndexBounds(int indexLevel, const _FastScrollIndex* pBaseIndex)
1521 FloatRectangle veBounds = __pPopupVe->GetBounds();
1522 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1523 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view.");
1529 veBounds.height = veBounds.height * FASTSCROLL_POPUPINDEX_COUNT;
1532 int indexVeCount = GetIndexVeCount();
1533 int indexWidth = veBounds.width;
1534 if (indexVeCount > 0)
1536 indexWidth /= indexVeCount;
1539 veBounds.width = indexWidth;
1540 veBounds.x = veBounds.width * indexLevel;
1542 pIndexVe->SetBounds(veBounds);
1548 _FastScrollPopupView::GetPopupIndexBounds(int indexLevel) const
1550 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1551 SysTryReturn(NID_UI_CTRL, pIndexVe, Rectangle(0, 0, 0, 0), GetLastResult(), "[%s] Failed to get the popup index view.",
1552 GetErrorMessage(GetLastResult()));
1554 FloatRectangle veBounds = pIndexVe->GetBounds();
1555 return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
1559 _FastScrollPopupView::GetIndexVe(int indexLevel) const
1561 Object* pObj = const_cast<Object*>(__indexViews.GetAt(indexLevel));
1562 SysTryReturn(NID_UI_CTRL, pObj, null, GetLastResult(), "[%s] Failed to get the popup index ve.",
1563 GetErrorMessage(GetLastResult()));
1565 return dynamic_cast<_VisualElement*>(pObj);
1569 _FastScrollPopupView::GetIndexVeCount(void) const
1571 return __indexViews.GetCount();
1575 _FastScrollPopupView::IsOnAnimation(void) const
1581 _FastScrollPopupView::RemoveAllAnimations(void)
1583 SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null.");
1584 __pPopupVe->RemoveAllAnimations();
1588 _FastScrollPopupView::SetPopupVisibility(bool visibility)
1590 SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null.");
1594 __pPopupVe->SetTransformMatrix(__matrixFadeInStart);
1595 __pPopupVe->SetImplicitAnimationEnabled(true);
1596 __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_ON);
1597 __pPopupVe->SetTransformMatrix(__matrixOrigin);
1598 __pPopupVe->SetImplicitAnimationEnabled(false);
1602 __pPopupVe->SetImplicitAnimationEnabled(true);
1603 __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
1604 __pPopupVe->SetTransformMatrix(__matrixFadeOutEnd);
1605 __pPopupVe->SetImplicitAnimationEnabled(false);
1607 // else keep up current visibility.
1613 _FastScrollPopupView::GetPopupVisibility(void) const
1615 SysTryReturn(NID_UI_CTRL, __pPopupVe, false, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null.");
1617 float opacity = __pPopupVe->GetOpacity();
1618 if (opacity > FASTSCROLL_OPACITY_OFF)
1627 _FastScrollPopupView::SetPopupVeUpdateNeeded(bool needUpdate)
1629 __needUpdatePopupIndexVe = needUpdate;
1633 _FastScrollPopupView::UpdateIndex(void)
1635 SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null.");
1637 result r = E_SUCCESS;
1639 r = __parentVe.InvalidateRectangle(null);
1640 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to invaildate the popup Ve.");
1642 __needUpdatePopupIndexVe = true;
1648 _FastScrollPopupView::DrawPopupVe(void)
1650 if (!__needUpdatePopupVe)
1655 SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null.");
1657 Canvas* pCanvas = __pPopupVe->GetCanvasN();
1658 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the popup ve.",
1659 GetErrorMessage(GetLastResult()));
1661 Rectangle bounds = GetPopupBounds();
1662 bounds.SetPosition(0, 0);
1664 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1667 if (__viewConfig.__pPopupBgEffectBitmap)
1669 DrawBitmap(*pCanvas, bounds, *__viewConfig.__pPopupBgEffectBitmap);
1672 if (__viewConfig.__pPopupBgBitmap)
1674 Bitmap* pReplacementColorBackgroundBitmap = null;
1675 pReplacementColorBackgroundBitmap =
1676 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pPopupBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__popupBgColor);
1677 DrawBitmap(*pCanvas, bounds, *pReplacementColorBackgroundBitmap);
1679 delete pReplacementColorBackgroundBitmap;
1684 __needUpdatePopupVe = false;
1689 _FastScrollPopupView::DrawPopupIndexVe(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex)
1691 if (__needUpdatePopupIndexVe != true)
1696 SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] pBaseIndex must not be null.");
1697 SysTryReturnVoidResult(NID_UI_CTRL, pSelectedIndex, E_INVALID_STATE, "[E_INVALID_STATE] pBaseIndex must not be null.");
1699 result r = E_SUCCESS;
1701 int childCount = pBaseIndex->GetChildCount();
1702 SysTryReturnVoidResult(NID_UI_CTRL, childCount > 0, E_INVALID_STATE, "[E_INVALID_STATE] The index have no children.");
1704 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1705 SysTryReturnVoidResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "[%s] Failed to get the popup index ve.",
1706 GetErrorMessage(GetLastResult()));
1708 Canvas* pCanvas = pIndexVe->GetCanvasN();
1709 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the popup index ve.",
1710 GetErrorMessage(GetLastResult()));
1712 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1715 FloatRectangle veBounds = pIndexVe->GetBounds();
1716 Rectangle bounds(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
1718 int indexHeight = bounds.height / FASTSCROLL_POPUPINDEX_COUNT;
1719 indexHeight = MAX(__viewConfig.__popupTextSize, indexHeight);
1721 Rectangle indexRect(0, 0, bounds.width, indexHeight);
1722 int selectedOrder = pSelectedIndex->GetIndexOrder(false);
1723 Bitmap* pReplacementColorBitmap = null;
1725 TextObject* pTextObject = new (std::nothrow) TextObject();
1726 SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1728 pTextObject->Construct();
1730 for (int i = -1; i < 2; i++)
1732 TextSimple* pSimpleText = null;
1734 _FastScrollIndex* pChildIndex = pBaseIndex->GetChildIndex(selectedOrder + i);
1737 Bitmap* pChildIndexImage = pChildIndex->GetIndexImage();
1738 if (pChildIndexImage)
1740 Rectangle imageRect = indexRect;
1741 float widthScale = (float)indexRect.width / pChildIndexImage->GetWidth();
1742 int rectHeight = MIN(indexRect.height, __viewConfig.__popupTextSize);
1743 float heightScale = (float)rectHeight / pChildIndexImage->GetHeight();
1744 float scaleFactor = MIN(widthScale, heightScale);
1746 imageRect.width = pChildIndexImage->GetWidth() * scaleFactor;
1747 imageRect.height = pChildIndexImage->GetHeight() * scaleFactor;
1749 if (indexRect.width - imageRect.width > 0)
1751 imageRect.x = indexRect.x + (indexRect.width - imageRect.width)/2;
1754 if (indexRect.height - imageRect.height > 0)
1756 imageRect.y = indexRect.y + (indexRect.height - imageRect.height)/2;
1759 pReplacementColorBitmap =
1760 _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage,
1761 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__popupTextColor);
1762 r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap,
1763 Rectangle(0, 0, pChildIndexImage->GetWidth(), pChildIndexImage->GetHeight()));
1764 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r));
1766 delete pReplacementColorBitmap;
1767 pReplacementColorBitmap = null;
1771 String* pChildIndexText = pChildIndex->GetIndexText();
1772 SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "[E_INVALID_STATE] pChildIndexText must not be null.");
1774 pTextObject->RemoveAll();
1776 pSimpleText = new (std::nothrow)TextSimple(const_cast<wchar_t*>(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1777 SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1779 r = pTextObject->AppendElement(*pSimpleText);
1780 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simple text.", GetErrorMessage(r));
1782 r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1783 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r));
1785 r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength());
1786 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
1788 r = pTextObject->SetForegroundColor(__viewConfig.__popupTextColor, 0, pTextObject->GetTextLength());
1789 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r));
1791 r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1792 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r));
1794 r = pTextObject->SetBounds(indexRect);
1795 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r));
1797 r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1798 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r));
1802 indexRect.y += indexHeight;
1809 delete pReplacementColorBitmap;
1813 _FastScrollPopupView::OnDraw(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex)
1816 DrawPopupIndexVe(indexLevel, pBaseIndex, pSelectedIndex);
1820 _FastScrollPopupView::DrawBitmap(Canvas& canvas, const Rectangle& bounds, const Bitmap& bitmap)
1822 result r = E_SUCCESS;
1823 if (bitmap.IsNinePatchedBitmap())
1825 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
1826 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1830 r = canvas.DrawBitmap(bounds, bitmap);
1831 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1838 _FastScrollPopupView::DrawBitmap(Canvas& canvas, const Rectangle& srcRect, const Bitmap& bitmap, const Rectangle& dstRect)
1840 result r = E_SUCCESS;
1841 if (bitmap.IsNinePatchedBitmap())
1843 r = canvas.DrawNinePatchedBitmap(srcRect, bitmap);
1844 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1848 r = canvas.DrawBitmap(srcRect, bitmap, dstRect);
1849 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1855 VisualElementAnimation*
1856 _FastScrollPopupView::CreateAnimationForProperty(VisualElement& target, const String& property)
1858 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
1862 const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
1863 if (pTimingFunction)
1865 pAnimation->SetTimingFunction(pTimingFunction);
1867 pAnimation->SetVisualElementAnimationStatusEventListener(this);
1873 _FastScrollPopupView::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
1878 _FastScrollPopupView::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
1883 _FastScrollPopupView::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
1885 SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] The popup Ve must not be null.");
1886 if (__pPopupVe == (static_cast <_VisualElement*>(&target)))
1888 if (__needDestroySelf && completedNormally)
1890 for (int i = 0; i < GetIndexVeCount(); i++)
1892 _VisualElement* pIndexVe = GetIndexVe(i);
1895 pIndexVe->RemoveAllAnimations();
1896 pIndexVe->SetAnimationProvider(null);
1900 __pPopupVe->RemoveAllAnimations();
1901 __pPopupVe->SetAnimationProvider(null);
1909 _FastScrollPopupView::Construct(void)
1911 result r = E_SUCCESS;
1913 __pPopupVe = new (std::nothrow) _VisualElement();
1914 SysTryCatch(NID_UI_CTRL, __pPopupVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1916 r = __pPopupVe->Construct();
1917 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the popup ve.", GetErrorMessage(r));
1919 __pPopupVe->SetAnimationProvider(this);
1921 r = __pPopupVe->SetSurfaceOpaque(false);
1922 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the popup ve.", GetErrorMessage(r));
1924 __pPopupVe->SetImplicitAnimationEnabled(false);
1926 r = __parentVe.AttachChild(*__pPopupVe);
1927 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the popup ve to the parent.", GetErrorMessage(r));
1929 __pPopupVe->SetShowState(true);
1930 __pPopupVe->SetClipChildrenEnabled(true);
1931 __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
1933 __needUpdatePopupVe = true;
1935 __matrixOrigin.SetAsIdentity();
1936 __matrixFadeInStart.SetAsIdentity();
1937 __matrixFadeOutEnd.SetAsIdentity();
1939 _MatrixUtilScale(__matrixFadeInStart, 0.8, 0.8, 1);
1940 _MatrixUtilScale(__matrixFadeOutEnd, 0.1, 0.1, 1);
1947 __pPopupVe->Destroy();
1954 _FastScrollPresenter::_FastScrollPresenter(_Control& parentCtrl, _FastScroll& fastScroll, bool visibility)
1955 : __parentCtrl(parentCtrl)
1956 , __fastScroll(fastScroll)
1958 , __pViewConfig(null)
1959 , __pFastScrollEvent(null)
1960 , __pFastScrollModel(null)
1963 , __pPopupView(null)
1964 , __focusedIndexLevel(0)
1965 , __pSelectedIndex(null)
1966 , __enableFadeEffect(true)
1967 , __indexCountMax(0)
1970 , __scrollVisibility(visibility)
1971 , __fadeEffectDuration_ms(500)
1975 _FastScrollPresenter::~_FastScrollPresenter(void)
1977 delete __pFastScrollEvent;
1978 __pFastScrollEvent = null;
1980 delete __pFastScrollModel;
1981 __pFastScrollModel = null;
1983 delete __pPopupView;
1984 __pPopupView = null;
1986 RemoveAllIndexViews(false);
1988 delete __pViewConfig;
1989 __pViewConfig = null;
1993 __pCtrlVe->RemoveAllAnimations();
1994 __pCtrlVe->SetAnimationProvider(null);
1998 _FastScrollPresenter*
1999 _FastScrollPresenter::CreateFastScrollPresenterN(_Control& parentCtrl, _FastScroll& fastScroll, bool visibility)
2001 _FastScrollPresenter* pPresenter = new (std::nothrow) _FastScrollPresenter(parentCtrl, fastScroll, visibility);
2002 SysTryReturn(NID_UI_CTRL, pPresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2004 result r = pPresenter->Construct();
2005 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2016 _FastScrollPresenter::SetRootIndex(_FastScrollIndex* pIndex)
2018 result r = E_SUCCESS;
2020 // initialize index views
2021 RemoveAllIndexViews(false);
2023 // initialize the popup view
2026 r = __pPopupView->SetPopupVisibility(false);
2027 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear visibility of the popup view.");
2030 r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__indexTextSize);
2031 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set font.");
2033 // set the root index into _FastScrollModel
2034 r = __pFastScrollModel->SetRootIndex(pIndex);
2035 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the root index into _FastScrollModel");
2037 // add new root index view.
2040 r = AddIndexView(0, *pIndex);
2041 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add the root index view.");
2048 _FastScrollPresenter::GetRootIndex(void) const
2050 return __pFastScrollModel->GetRootIndex();
2054 _FastScrollPresenter::UpdateIndex(void)
2056 result r = E_SUCCESS;
2058 // update the base index of index views
2059 int indexViewCount = GetIndexViewCount();
2060 for (int i = 0; i < indexViewCount; i++)
2062 _FastScrollIndexView* pIndexView = GetIndexView(i);
2063 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
2065 _FastScrollIndex* pIndex = pIndexView->GetBaseIndex();
2067 if ((pIndex->GetChildCount() > __indexCountMax) && (pIndex->GetIndexType() != FAST_SCROLL_INDEX_TYPE_OMISSION))
2069 r = pIndex->SetOmissionIndex(__indexCountMax);
2070 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set omiited index.");
2073 r = pIndexView->UpdateIndex(true);
2074 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view.");
2077 // update the base index of the popup view
2080 r = __pPopupView->UpdateIndex();
2081 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the popup view.");
2088 _FastScrollPresenter::EnableFadeEffect(bool enable)
2090 __enableFadeEffect = enable;
2094 _FastScrollPresenter::IsEnabledFadeEffect(void) const
2096 return __enableFadeEffect;
2100 _FastScrollPresenter::IsOnFadeEffect(void) const
2102 return (__fadeIn || __fadeOut);
2106 _FastScrollPresenter::IsScrollVisible(void) const
2108 return (__fadeIn || __fadeOut || __scrollVisibility);
2112 _FastScrollPresenter::SetScrollVisibility(bool visibility)
2114 result r = E_SUCCESS;
2116 if (GetScrollVisibility() == visibility)
2118 // keep up current visibility.
2122 __pCtrlVe->RemoveAllAnimations();
2125 if (__enableFadeEffect)
2130 __pCtrlVe->SetImplicitAnimationEnabled(true);
2133 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON);
2135 if (__enableFadeEffect)
2137 __pCtrlVe->SetImplicitAnimationEnabled(false);
2147 if (__enableFadeEffect)
2152 __pCtrlVe->SetImplicitAnimationEnabled(true);
2155 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
2157 if (__enableFadeEffect)
2159 __pCtrlVe->SetImplicitAnimationEnabled(false);
2168 __scrollVisibility = visibility;
2174 _FastScrollPresenter::GetScrollVisibility(void) const
2176 float opacity = __pCtrlVe->GetOpacity();
2178 if (__enableFadeEffect)
2180 if (__scrollVisibility)
2185 else if (opacity > FASTSCROLL_OPACITY_OFF)
2194 _FastScrollPresenter::CancelFadeEffect(void)
2199 __scrollVisibility = false;
2200 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
2205 __scrollVisibility = true;
2206 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON);
2211 _FastScrollPresenter::AddFastScrollEventListener(const Controls::_IUiFastScrollListener& listener)
2213 result r = E_SUCCESS;
2215 if (__pFastScrollEvent == null)
2217 __pFastScrollEvent = new (std::nothrow) _UiFastScrollEvent();
2218 SysTryReturnVoidResult(NID_UI_CTRL, __pFastScrollEvent, E_OUT_OF_MEMORY,
2219 "[E_OUT_OF_MEMORY] Memory allocation failed.");
2221 r = __pFastScrollEvent->Construct(__fastScroll);
2222 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2225 r = __pFastScrollEvent->AddListener(listener);
2226 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2230 _FastScrollPresenter::RemoveFastScrollEventListener(const Controls::_IUiFastScrollListener& listener)
2232 result r = E_SUCCESS;
2234 SysTryReturnVoidResult(NID_UI_CTRL, __pFastScrollEvent, E_INVALID_STATE, "[E_INVALID_STATE] __pFastScrollEvent must not be null.");
2236 r = __pFastScrollEvent->RemoveListener(listener);
2237 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2241 _FastScrollPresenter::AddAccessibilityElement(const _AccessibilityContainer& control, bool onAccessibility)
2243 _FastScrollIndexView* pIndexView = GetIndexView(0);
2244 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get fastscroll indexview.",
2245 GetErrorMessage(GetLastResult()));
2247 _AccessibilityContainer* pAccessibilityContainer = const_cast <_AccessibilityContainer*>(&control);
2248 result r = pAccessibilityContainer->RemoveAllElement();
2249 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove accessibility elements.");
2250 _AccessibilityElement* pAccessibilityElement = null;
2252 if (onAccessibility)
2254 r = pIndexView->AddAccessibilityElement(control);
2255 SysTryReturnResult(NID_UI_CTRL, r = E_SUCCESS, r, "Failed to Add accessibility element.");
2259 pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
2260 SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
2262 pAccessibilityElement->SetBounds(pIndexView->GetIndexBounds());
2263 pAccessibilityElement->SetTrait(L"Fast scroll bar");
2264 pAccessibilityElement->SetName(L"FastScroll");
2265 pAccessibilityElement->SetHint(L"double tap to enter fast scroll mode");
2266 r = pAccessibilityContainer->AddElement(*pAccessibilityElement);
2267 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Add accessibility element.", GetErrorMessage(r));
2272 delete pAccessibilityElement;
2277 _FastScrollPresenter::OnParentBoundsChanged(void)
2279 RelayoutFastScrollChildren();
2283 _FastScrollPresenter::OnDraw(void)
2286 int indexViewCount = GetIndexViewCount();
2287 for (int i = 0; i < indexViewCount; i++)
2289 _FastScrollIndexView* pIndexView = GetIndexView(i);
2290 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2291 GetErrorMessage(GetLastResult()));
2293 result r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__indexTextSize);
2294 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r));
2295 pIndexView->OnDraw();
2297 // draw the popup view
2298 if (__pPopupView && i <= __focusedIndexLevel)
2300 r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__popupTextSize);
2301 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r));
2302 __pPopupView->OnDraw(i, pIndexView->GetBaseIndex(), pIndexView->GetSelectedIndexInOmittedIndex());
2308 __pPopupView->SetPopupVeUpdateNeeded(false);
2313 _FastScrollPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
2315 return OnTouchPressedAndMoved(touchinfo.GetCurrentPosition(), true);
2319 _FastScrollPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
2321 return OnTouchReleasedAndCanceled();
2325 _FastScrollPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
2327 return OnTouchPressedAndMoved(touchinfo.GetCurrentPosition(), false);
2331 _FastScrollPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
2333 return OnTouchReleasedAndCanceled();
2337 _FastScrollPresenter::OnFontChanged(Font* pFont)
2339 __pViewConfig->__pFont = pFont;
2343 _FastScrollPresenter::OnFontInfoRequested(unsigned long& style, int& size)
2345 style = __fontStyle;
2350 _FastScrollPresenter::SetFontInfo(unsigned long style, int size)
2352 __fontStyle = style;
2355 __pViewConfig->__pFont = __fastScroll.GetFallbackFont();
2356 SysTryReturnResult(NID_UI_CTRL, __pViewConfig->__pFont, GetLastResult(), "Failed to get a font.");
2361 VisualElementAnimation*
2362 _FastScrollPresenter::CreateAnimationForProperty(VisualElement& target, const String& property)
2364 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
2368 const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
2369 if (pTimingFunction)
2371 pAnimation->SetTimingFunction(pTimingFunction);
2373 pAnimation->SetVisualElementAnimationStatusEventListener(this);
2379 _FastScrollPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
2384 _FastScrollPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
2389 _FastScrollPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
2391 if (__pCtrlVe == (static_cast <_VisualElement*>(&target)))
2399 _FastScrollPresenter::HitTest(const Tizen::Graphics::FloatPoint& point)
2401 if (IsScrollVisible() == false)
2403 return HIT_TEST_NOWHERE;
2406 int indexViewCount = GetIndexViewCount();
2407 for (int i = 0; i < indexViewCount; i++)
2409 _FastScrollIndexView* pIndexView = GetIndexView(i);
2410 SysTryReturn(NID_UI_CTRL, pIndexView, HIT_TEST_NOWHERE, GetLastResult(), "[%s] Failed to get the index view.",
2411 GetErrorMessage(GetLastResult()));
2413 Rectangle indexBounds = pIndexView->GetIndexBounds();
2414 if (indexBounds.Contains(Point(point.x, point.y)) == true)
2416 return HIT_TEST_MATCH;
2420 return HIT_TEST_NOWHERE;
2424 _FastScrollPresenter::OnIndexDataUpdated(_FastScrollIndex& updatedIndex)
2426 result r = E_SUCCESS;
2428 int indexViewCount = GetIndexViewCount();
2429 for (int i = 0; i < indexViewCount; i++)
2431 _FastScrollIndexView* pIndexView = GetIndexView(i);
2432 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2433 GetErrorMessage(GetLastResult()));
2435 if (pIndexView->GetBaseIndex() == &updatedIndex)
2437 r = pIndexView->UpdateIndex(false);
2438 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2442 r = __pPopupView->UpdateIndex();
2443 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update the popup view.", GetErrorMessage(r));
2451 _FastScrollPresenter::OnIndexDeleted(_FastScrollIndex& deletedIndex)
2453 result r = E_SUCCESS;
2455 int indexViewCount = GetIndexViewCount();
2456 for (int i = 0; i < indexViewCount; i++)
2458 _FastScrollIndexView* pIndexView = GetIndexView(i);
2459 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2460 GetErrorMessage(GetLastResult()));
2462 if (pIndexView->GetBaseIndex() == &deletedIndex)
2464 // first of all, update the base index view
2467 _FastScrollIndexView* pBaseIndexView = GetIndexView(i - 1);
2468 SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2469 GetErrorMessage(GetLastResult()));
2471 r = pBaseIndexView->UpdateIndex(false);
2472 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2475 // then remove the index view for detached index.
2476 RemoveIndexView(i, true);
2478 delete __pPopupView;
2479 __pPopupView = null;
2483 else if (pIndexView->GetBaseIndex() == deletedIndex.GetParentIndex())
2485 r = pIndexView->UpdateIndex(false);
2486 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2488 r = __pPopupView->UpdateIndex();
2489 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r));
2495 _FastScrollPresenter::OnChildIndexAttached(_FastScrollIndex& parentIndex, int attachedOrder, _FastScrollIndex& attachedIndex)
2497 result r = E_SUCCESS;
2499 int indexViewCount = GetIndexViewCount();
2500 for (int i = 0; i < indexViewCount; i++)
2502 _FastScrollIndexView* pIndexView = GetIndexView(i);
2503 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2504 GetErrorMessage(GetLastResult()));
2506 if (pIndexView->GetBaseIndex() == &parentIndex)
2508 r = pIndexView->UpdateIndex(false);
2509 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2511 r = __pPopupView->UpdateIndex();
2512 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r));
2519 _FastScrollPresenter::OnChildIndexDetached(_FastScrollIndex& parentIndex, int detachedOrder, _FastScrollIndex& detachedIndex)
2521 result r = E_SUCCESS;
2523 int indexViewCount = GetIndexViewCount();
2524 for (int i = 0; i < indexViewCount; i++)
2526 _FastScrollIndexView* pIndexView = GetIndexView(i);
2527 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2528 GetErrorMessage(GetLastResult()));
2530 if (pIndexView->GetBaseIndex() == &detachedIndex)
2532 // first of all, update the base index view
2535 _FastScrollIndexView* pBaseIndexView = GetIndexView(i - 1);
2536 SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2537 GetErrorMessage(GetLastResult()));
2539 r = pBaseIndexView->UpdateIndex(false);
2540 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2543 // then remove the index view for detached index.
2544 RemoveIndexView(i, true);
2546 delete __pPopupView;
2547 __pPopupView = null;
2550 else if (pIndexView->GetBaseIndex() == &parentIndex)
2552 r = pIndexView->UpdateIndex(false);
2553 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2555 r = __pPopupView->UpdateIndex();
2556 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r));
2563 _FastScrollPresenter::Construct(void)
2565 result r = E_SUCCESS;
2567 // load color/shape configuration and bitmap resources
2568 __pViewConfig = _FastScrollViewConfig::CreateFastScrollViewConfigN(_CONTROL_ORIENTATION_PORTRAIT);
2569 SysTryReturnResult(NID_UI_CTRL, __pViewConfig, GetLastResult(), "Failed to create _FastScrollViewConfig.");
2571 // create _FastScrollModel
2572 __pFastScrollModel = _FastScrollModel::CreateFastScrollModelN();
2573 SysTryCatch(NID_UI_CTRL, __pFastScrollModel, , GetLastResult(), "[%s] Failed to create _FastScrollModel.",
2574 GetErrorMessage(GetLastResult()));
2576 // initialize visual elements
2577 __pCtrlVe = __fastScroll.GetVisualElement();
2578 SysTryCatch(NID_UI_CTRL, __pCtrlVe, , GetLastResult(), "[%s] Failed to get VisualElement of the _FastScroll",
2579 GetErrorMessage(GetLastResult()));
2581 __pCtrlVe->SetAnimationProvider(this);
2582 __pCtrlVe->SetClipChildrenEnabled(false);
2584 if (__scrollVisibility)
2586 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON);
2590 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
2593 // initialize the fastscroll control
2594 r = __fastScroll.SetBounds(CalculateFastScrollBounds(0));
2595 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the bounds of _FastScroll", GetErrorMessage(r));
2597 __fastScroll.SetBackgroundColor(Tizen::Graphics::Color(0, 0, 0, 0));
2599 __indexCountMax = (__fastScroll.GetBounds().height - (__pViewConfig->__indexMarginTop * 2)) / __pViewConfig->__indexSizeMin.height;
2604 delete __pFastScrollModel;
2605 __pFastScrollModel = null;
2607 delete __pViewConfig;
2608 __pViewConfig = null;
2610 return GetLastResult();
2614 _FastScrollPresenter::CalculateFastScrollBounds(int indexCount)
2616 Rectangle fastScrollBounds(0, 0, 0, 0);
2617 Rectangle parentBounds = __parentCtrl.GetBounds();
2618 fastScrollBounds.width = parentBounds.width;
2619 fastScrollBounds.height = parentBounds.height;
2620 return fastScrollBounds;
2624 _FastScrollPresenter::CalculateIndexBounds(int indexLevel, _FastScrollIndex& pIndex)
2626 Rectangle indexBounds(0, 0, 0, 0);
2627 Rectangle fastScrollBounds = __fastScroll.GetBounds();
2629 indexBounds.x = fastScrollBounds.width;
2630 for (int i = 0; i <= indexLevel; i++)
2634 indexBounds.x -= __pViewConfig->__indexGap;
2637 indexBounds.x -= __pViewConfig->__indexSizeMin.width;
2639 indexBounds.x = MAX(indexBounds.x, 0);
2642 indexBounds.width = __pViewConfig->__indexSizeMin.width;
2643 indexBounds.height = fastScrollBounds.height;
2645 if (indexLevel != 0)
2647 int childCount = pIndex.GetChildCount();
2648 indexBounds.height = (childCount * __pViewConfig->__indexSizeMin.height) + (__pViewConfig->__indexMarginTop * 2);
2650 if (indexBounds.height < fastScrollBounds.height)
2652 _FastScrollIndexView* pParentIndexView = GetIndexView(indexLevel - 1);
2653 if (pParentIndexView)
2655 int parentIndexHeight = pParentIndexView->GetIndexHeight();
2656 Rectangle parentBounds = pParentIndexView->GetIndexBounds();
2658 indexBounds.y = parentBounds.y + (pIndex.GetIndexOrder() * parentIndexHeight) - __pViewConfig->__indexMarginTop;
2659 indexBounds.y = MAX(indexBounds.y, fastScrollBounds.y);
2661 if (indexBounds.y + indexBounds.height >= fastScrollBounds.height)
2663 indexBounds.y = fastScrollBounds.height - indexBounds.height;
2669 indexBounds.height = fastScrollBounds.height;
2677 _FastScrollPresenter::CalculatePopupBounds(void)
2679 Rectangle popupBounds(0, 0, 0, 0);
2680 Rectangle parentBounds = __parentCtrl.GetBounds();
2681 Rectangle fastScrollBounds = __fastScroll.GetBounds();
2682 int popupWidth = __pViewConfig->__popupSize.width + (__pViewConfig->__popupWidthIncrement * __focusedIndexLevel);
2684 popupBounds.width = MIN(popupWidth, parentBounds.width);
2685 popupBounds.height = MIN(__pViewConfig->__popupSize.height, parentBounds.height);
2687 popupBounds.x = (parentBounds.width - popupBounds.width) ? ((parentBounds.width - popupBounds.width)/2) : 0;
2688 popupBounds.y = (parentBounds.height - popupBounds.height) ? ((parentBounds.height - popupBounds.height)/2) : 0;
2690 popupBounds.x -= fastScrollBounds.x;
2691 popupBounds.y -= fastScrollBounds.y;
2697 _FastScrollPresenter::RelayoutFastScrollChildren(void)
2699 result r = E_SUCCESS;
2701 int indexViewCount = GetIndexViewCount();
2703 // initialize the fastscroll control
2704 r = __fastScroll.SetBounds(CalculateFastScrollBounds(indexViewCount));
2705 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set the bounds of _FastScroll", GetErrorMessage(r));
2707 __indexCountMax = (__fastScroll.GetBounds().height - (__pViewConfig->__indexMarginTop * 2)) / __pViewConfig->__indexSizeMin.height;
2709 for (int i = 0; i < indexViewCount; i++)
2711 _FastScrollIndexView* pIndexView = GetIndexView(i);
2712 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2713 GetErrorMessage(GetLastResult()));
2715 r = pIndexView->SetIndexBounds(CalculateIndexBounds(i, *(pIndexView->GetBaseIndex())));
2716 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set bounds of the index.", GetErrorMessage(r));
2718 _FastScrollIndex* pIndex = pIndexView->GetBaseIndex();
2719 if (pIndex->GetIndexType() == FAST_SCROLL_INDEX_TYPE_OMISSION)
2721 r = pIndex->RemoveOmissionChildren(false);
2722 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to remove omission index view", GetErrorMessage(r));
2725 if (pIndex->GetChildCount() > __indexCountMax)
2727 r = pIndex->SetOmissionIndex(__indexCountMax);
2728 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set omission index.", GetErrorMessage(r));
2731 r = pIndexView->UpdateIndex(false);
2732 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2737 r = __pPopupView->SetPopupBounds(CalculatePopupBounds());
2738 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set bounds of the popup view.", GetErrorMessage(r));
2743 _FastScrollPresenter::SelectOnIndexViews(const Point& point, bool animation)
2745 result r = E_SUCCESS;
2747 _FastScrollIndex* pSelectedIndex = null;
2748 int selectedIndexLevel = 0;
2749 int indexViewCount = GetIndexViewCount();
2750 SysTryReturn(NID_UI_CTRL, indexViewCount > 0, null, E_INVALID_STATE, "[E_INVALID_STATE] The root index view is invalid state.");
2752 // search the hit index on index views, then fade out other index views
2753 for (int i = 0; i < indexViewCount; i++)
2755 _FastScrollIndexView* pIndexView = GetIndexView(i);
2756 SysTryReturn(NID_UI_CTRL, pIndexView, null, GetLastResult(), "[%s] Failed to get the index view.",
2757 GetErrorMessage(GetLastResult()));
2759 _FastScrollIndex* pIndex = pIndexView->GetIndexAtPoint(point);
2762 // select the index of the index view.
2763 r = pIndexView->SelectIndex(pIndex, animation);
2764 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r));
2765 pSelectedIndex = pIndex;
2766 if (pIndex->GetOmitted() == true)
2768 pSelectedIndex = pIndexView->GetOmissionIndexAtPoint(pIndex, point);
2770 pIndexView->SetSelectedIndexInOmittedIndex(pSelectedIndex);
2772 selectedIndexLevel = i;
2777 // if can no find the index on views, select index of the last index view
2778 if ((pSelectedIndex == null) && (__focusedIndexLevel != -1))
2780 _FastScrollIndexView* pFocusedIndexView = GetIndexView(__focusedIndexLevel);
2781 SysTryReturn(NID_UI_CTRL, pFocusedIndexView, null, GetLastResult(), "[%s] Failed to get the index view.",
2782 GetErrorMessage(GetLastResult()));
2784 _FastScrollIndex* pIndex = pFocusedIndexView->GetIndexAtPoint(Point(pFocusedIndexView->GetIndexBounds().x, point.y));
2787 // select the index of the focused index view.
2788 r = pFocusedIndexView->SelectIndex(pIndex, animation);
2789 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r));
2790 pSelectedIndex = pIndex;
2792 if (pIndex->GetOmitted() == true)
2794 pSelectedIndex = pFocusedIndexView->GetOmissionIndexAtPoint(pIndex,
2795 Point(pFocusedIndexView->GetIndexBounds().x, point.y));
2797 pFocusedIndexView->SetSelectedIndexInOmittedIndex(pSelectedIndex);
2799 selectedIndexLevel = __focusedIndexLevel;
2803 pSelectedIndex = pFocusedIndexView->GetSelectedIndex();
2804 selectedIndexLevel = __focusedIndexLevel;
2810 int childCount = pSelectedIndex->GetChildCount();
2813 _FastScrollIndexView* pSelectedIndexView = GetIndexView(selectedIndexLevel + 1);
2814 if (pSelectedIndexView)
2816 r = pSelectedIndexView->SelectIndex((_FastScrollIndex*)null, false);
2817 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r));
2819 r = pSelectedIndexView->SetBaseIndex(pSelectedIndex);
2820 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set the base index of the index view.", GetErrorMessage(r));
2822 r = pSelectedIndexView->SetIndexBounds(CalculateIndexBounds(selectedIndexLevel + 1, *pSelectedIndex));
2823 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set bounds of the index.", GetErrorMessage(r));
2825 r = pSelectedIndexView->SetIndexVisibility(true);
2826 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set the visibility of the index view.", GetErrorMessage(r));
2828 indexViewCount = GetIndexViewCount();
2829 while (indexViewCount > selectedIndexLevel + 2)
2831 r = RemoveIndexView(indexViewCount - 1, true);
2832 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r));
2833 indexViewCount = GetIndexViewCount();
2838 r = AddIndexView(*pSelectedIndex);
2839 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to add new child index.", GetErrorMessage(r));
2842 if ((childCount > __indexCountMax) && (pSelectedIndex->GetIndexType() != FAST_SCROLL_INDEX_TYPE_OMISSION))
2844 r = pSelectedIndex->SetOmissionIndex(__indexCountMax);
2845 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set omission index.", GetErrorMessage(r));
2850 indexViewCount = GetIndexViewCount();
2851 while (indexViewCount > selectedIndexLevel + 1)
2853 r = RemoveIndexView(indexViewCount - 1, true);
2854 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r));
2855 indexViewCount = GetIndexViewCount();
2861 indexViewCount = GetIndexViewCount();
2862 while (indexViewCount > 1)
2864 r = RemoveIndexView(indexViewCount - 1, true);
2865 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r));
2866 indexViewCount = GetIndexViewCount();
2870 __focusedIndexLevel = selectedIndexLevel;
2871 return pSelectedIndex;
2875 _FastScrollPresenter::DeselectIndexViews(void)
2877 result r = E_SUCCESS;
2879 while (GetIndexViewCount() > 1)
2881 RemoveIndexView(GetIndexViewCount() - 1, true);
2884 _FastScrollIndexView* pIndexView = GetIndexView(0);
2885 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
2887 r = pIndexView->SelectIndex((_FastScrollIndex*)null, true);
2888 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear the index selection.");
2889 pIndexView->SetSelectedIndexInOmittedIndex(null);
2891 __fastScroll.Invalidate();
2897 _FastScrollPresenter::SetPopupIndex(_FastScrollIndex& popupIndex, const Point& point)
2899 result r = E_SUCCESS;
2901 // set the selected node into the popup views.
2902 if (__pPopupView == null)
2904 __pPopupView = _FastScrollPopupView::CreateFastScrollPopupViewN(*__pCtrlVe, *__pViewConfig);
2905 SysTryReturnResult(NID_UI_CTRL, __pPopupView, GetLastResult(), "Propagating.");
2907 r = __pPopupView->SetPopupBounds(CalculatePopupBounds());
2908 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup view.");
2910 r = __pPopupView->SetPopupVisibility(true);
2911 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the popup view.");
2914 int indexViewCount = __focusedIndexLevel + 1;
2915 int popupIndexViewCount = __pPopupView->GetIndexVeCount();
2917 if (indexViewCount != popupIndexViewCount)
2919 r = __pPopupView->SetPopupBounds(CalculatePopupBounds());
2920 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup view.");
2922 if (indexViewCount > popupIndexViewCount)
2924 for (int i = popupIndexViewCount; i < indexViewCount; i++)
2926 r = __pPopupView->AddPopupIndexVe(i);
2927 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add popup index ve.");
2930 else if (indexViewCount < popupIndexViewCount)
2932 for (int i = indexViewCount; i < popupIndexViewCount; i++)
2934 r = __pPopupView->RemovePopupIndexVe(i);
2935 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove popup index ve.");
2940 r = __pPopupView->UpdateIndex();
2941 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the popup view.");
2943 for (int i = 0; i < indexViewCount; i++)
2945 _FastScrollIndexView* pIndexView = GetIndexView(i);
2946 SysTryReturnResult(NID_UI_CTRL, pIndexView, r, "Failed to index view.");
2948 r = __pPopupView->SetPopupIndexBounds(i, pIndexView->GetBaseIndex());
2949 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup index ve.");
2951 _FastScrollIndex* pFormerIndex = null;
2952 if ( i == __focusedIndexLevel )
2954 pFormerIndex = pIndexView->GetFormerIndex();
2955 r = __pPopupView->SelectIndex(i, &popupIndex, pFormerIndex);
2956 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the popup index.");
2960 r = __pPopupView->SelectIndex(i, null, null);
2961 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the popup index.");
2969 _FastScrollPresenter::ClearPopupIndex(void)
2971 result r = E_SUCCESS;
2973 // clear the node data of the popup view
2976 r = __pPopupView->FadeOutAndDestroy();
2977 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear visibility of the popup view.");
2979 __pPopupView = null;
2986 _FastScrollPresenter::FireFastScrollEvent(_FastScrollIndex& selectedIndex)
2988 // fire the fast scroll event
2989 if (__pFastScrollEvent)
2991 String* pIndexNodeText = selectedIndex.GetIndexText();
2994 _UiFastScrollEventArg* pEventArg = new (std::nothrow) _UiFastScrollEventArg(*__pFastScrollEvent->GetSource(), selectedIndex);
2995 SysTryReturnResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "Memory allocation failed.");
2997 __pFastScrollEvent->Fire(*pEventArg);
3005 _FastScrollPresenter::OnTouchPressedAndMoved(const Point& point, bool animation)
3007 result r = E_SUCCESS;
3008 if (__scrollVisibility == false)
3010 r = SetScrollVisibility(true);
3011 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to fade out fastscroll.", GetErrorMessage(r));
3014 _FastScrollIndex* pSelectedIndex = SelectOnIndexViews(point, animation);
3015 if (pSelectedIndex && (__pSelectedIndex != pSelectedIndex))
3017 r = SetPopupIndex(*pSelectedIndex, point);
3018 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to set the poup index.", GetErrorMessage(r));
3020 r = FireFastScrollEvent(*pSelectedIndex);
3021 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to send the fast scroll event.", GetErrorMessage(r));
3024 __pSelectedIndex = pSelectedIndex;
3030 _FastScrollPresenter::OnTouchReleasedAndCanceled(void)
3032 result r = E_SUCCESS;
3034 r = DeselectIndexViews();
3035 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to deselect index views.", GetErrorMessage(r));
3037 r = ClearPopupIndex();
3038 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to clear the popup index.", GetErrorMessage(r));
3040 if (__scrollVisibility == false)
3042 r = SetScrollVisibility(false);
3043 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to fade out fastscroll.", GetErrorMessage(r));
3046 __pSelectedIndex = null;
3052 _FastScrollPresenter::AddIndexView(_FastScrollIndex& baseIndex)
3054 return AddIndexView(GetIndexViewCount(), baseIndex);
3058 _FastScrollPresenter::AddIndexView(int indexLevel, _FastScrollIndex& baseIndex)
3060 result r = E_SUCCESS;
3062 _FastScrollIndexView* pNewIndexView = _FastScrollIndexView::CreateFastScrollIndexViewN( *__pCtrlVe, *__pViewConfig);
3063 SysTryReturnResult(NID_UI_CTRL, pNewIndexView, GetLastResult(), "Propagating.");
3065 r = __fastScroll.SetBounds(CalculateFastScrollBounds(GetIndexViewCount() + 1));
3066 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll.");
3068 r = pNewIndexView->SetIndexBounds(CalculateIndexBounds(indexLevel, baseIndex));
3069 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the index view.");
3071 r = pNewIndexView->SetBaseIndex(&baseIndex);
3072 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the index data for the index view.");
3074 r = pNewIndexView->SetIndexVisibility(true);
3075 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the index view.");
3077 r = __indexViews.InsertAt(*pNewIndexView, indexLevel);
3078 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to change the last index view.");
3084 _FastScrollPresenter::RemoveIndexView(int indexLevel, bool fadeout)
3086 result r = E_SUCCESS;
3088 int indexViewCount = GetIndexViewCount();
3089 if (indexLevel < indexViewCount)
3091 _FastScrollIndexView* pIndexView = GetIndexView(indexLevel);
3092 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
3096 r = pIndexView->FadeOutAndDestroy();
3097 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to request to fade out of the index view.");
3100 r = __indexViews.Remove(*pIndexView, false);
3101 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove the index views.");
3103 // initialize the fastscroll control
3104 r = __fastScroll.SetBounds(CalculateFastScrollBounds(GetIndexViewCount()));
3105 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll");
3112 _FastScrollPresenter::RemoveAllIndexViews(bool fadeout)
3114 result r = E_SUCCESS;
3118 int indexViewCount = GetIndexViewCount();
3119 for (int i = 0; i < indexViewCount; i++)
3121 _FastScrollIndexView* pIndexView = GetIndexView(i);
3122 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
3124 r = pIndexView->FadeOutAndDestroy();
3125 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to request to fade out of the index view.");
3129 __indexViews.RemoveAll(true);
3131 // initialize the fastscroll control
3132 r = __fastScroll.SetBounds(CalculateFastScrollBounds(0));
3133 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll.");
3138 _FastScrollIndexView*
3139 _FastScrollPresenter::GetIndexView(int indexLevel) const
3141 Object* pIndexView = const_cast<Object*>(__indexViews.GetAt(indexLevel));
3142 SysTryReturn(NID_UI_CTRL, pIndexView, null, GetLastResult(), "[%s] Failed to get the index view.",
3143 GetErrorMessage(GetLastResult()));
3145 return dynamic_cast<_FastScrollIndexView*>(pIndexView);
3149 _FastScrollPresenter::GetIndexViewCount(void) const
3151 return __indexViews.GetCount();
3154 } } } // Tizen::Ui::Controls