2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_FastScrollPresenter.cpp
20 * @brief This is the implementation file for the _FastScrollPresenter class.
23 #include <FBaseErrors.h>
24 #include <FBaseString.h>
26 #include <FGrpColor.h>
27 #include <FGrpRectangle.h>
28 #include <FGrpCanvas.h>
29 #include <FGrpBitmap.h>
30 #include <FUiAnimVisualElementAnimation.h>
31 #include <FUiAnimVisualElementAnimationProvider.h>
32 #include <FUiAnimIVisualElementAnimationStatusEventListener.h>
33 #include <FUiAnimVisualElementContentProvider.h>
34 #include <FUiAnimIVisualElementContentProvider.h>
35 #include <FUiAnimVisualElement.h>
36 #include <FBaseSysLog.h>
37 #include <FGrp_BitmapImpl.h>
38 #include "FGrp_TextTextObject.h"
39 #include <FGrp_TextTextSimple.h>
40 #include "FUiAnim_VisualElement.h"
41 #include "FUi_Control.h"
42 #include "FUi_UiTouchEvent.h"
43 #include "FUi_ResourceManager.h"
44 #include "FUi_CoordinateSystemUtils.h"
46 #include "FUiCtrl_IFastScrollListener.h"
47 #include "FUiCtrl_UiFastScrollEvent.h"
48 #include "FUiCtrl_UiFastScrollEventArg.h"
49 #include "FUiCtrl_FastScroll.h"
50 #include "FUiCtrl_FastScrollPresenter.h"
51 #include "FUiCtrl_FastScrollModel.h"
52 #include "FUiCtrl_FastScrollIndex.h"
54 #include "FUiAnim_MatrixUtil.h"
56 using namespace Tizen::Base;
57 using namespace Tizen::Graphics;
58 using namespace Tizen::Ui;
59 using namespace Tizen::Ui::Animations;
60 using namespace Tizen::Graphics::_Text;
64 const float FASTSCROLL_OPACITY_ON = 1.0f;
65 const float FASTSCROLL_OPACITY_SELECTEDBG_DIM = 0.5f;
66 const float FASTSCROLL_OPACITY_LIGHT_DIM = 0.3f;
67 const float FASTSCROLL_OPACITY_OFF = 0.0f;
68 const int FASTSCROLL_POPUPINDEX_COUNT = 3;
71 namespace Tizen { namespace Ui { namespace Controls
74 _FastScrollViewConfig::_FastScrollViewConfig(void)
75 : __indexBgColor(Color::GetColor(COLOR_ID_BLACK))
76 , __indexHighlightColor(Color::GetColor(COLOR_ID_BLACK))
77 , __indexLineColor(Color::GetColor(COLOR_ID_BLACK))
78 , __indexSelectedLineColor(Color::GetColor(COLOR_ID_BLACK))
79 , __indexTextColor(Color::GetColor(COLOR_ID_BLACK))
80 , __indexDividerColor(Color::GetColor(COLOR_ID_BLACK))
81 , __selectedIndexBgColor(Color::GetColor(COLOR_ID_BLACK))
82 , __selectedIndexTextColor(Color::GetColor(COLOR_ID_BLACK))
83 , __popupBgColor(Color::GetColor(COLOR_ID_BLACK))
84 , __popupTextColor(Color::GetColor(COLOR_ID_BLACK))
85 , __indexSizeMin(0.0f, 0.0f)
86 , __popupSize(0.0f, 0.0f)
87 , __indexMarginTop(0.0f)
89 , __indexLeftLineThickness(0.0f)
90 , __indexTextSize(0.0f)
91 , __indexSeparatorThickness(0.0f)
92 , __indexSeparatorWidth(0.0f)
93 , __selectedIndexMarginRight(0.0f)
94 , __selectedIndexHeight(0.0f)
95 , __popupWidthIncrement(0.0f)
96 , __popupTextSize(0.0f)
97 , __popupShadowRight(0.0f)
98 , __popupShadowBottom(0.0f)
99 , __pIndexBgBitmap(null)
100 , __pSelectedIndexBgBitmap(null)
101 , __pSelectedIndexlineBitmap(null)
102 , __pPopupBgBitmap(null)
103 , __pPopupBgEffectBitmap(null)
105 , __ignoreTouchEvent(false)
109 _FastScrollViewConfig::~_FastScrollViewConfig(void)
114 _FastScrollViewConfig*
115 _FastScrollViewConfig::CreateFastScrollViewConfigN(_ControlOrientation orientation)
117 _FastScrollViewConfig* pConfig = new (std::nothrow) _FastScrollViewConfig();
118 SysTryReturn(NID_UI_CTRL, pConfig, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
120 result r = pConfig->Construct(orientation);
121 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
123 SetLastResult(E_SUCCESS);
133 _FastScrollViewConfig::ReloadConfig(_ControlOrientation orientation)
135 result r = E_SUCCESS;
137 // release allocated resources.
140 // load bitmap resources
141 r = GET_BITMAP_CONFIG_N(FASTSCROLL::INDEX_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pIndexBgBitmap);
142 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
144 r = GET_BITMAP_CONFIG_N(FASTSCROLL::INDEX_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pSelectedIndexBgBitmap);
145 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
147 r = GET_BITMAP_CONFIG_N(FASTSCROLL::INDEX_LINE_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pSelectedIndexlineBitmap);
148 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
150 r = GET_BITMAP_CONFIG_N(FASTSCROLL::POPUP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pPopupBgBitmap);
151 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
153 r = GET_BITMAP_CONFIG_N(FASTSCROLL::POPUP_BG_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pPopupBgEffectBitmap);
154 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to load image.");
157 // load shape configuration
158 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __indexSizeMin.width);
159 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
161 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __indexSizeMin.height);
162 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
164 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __indexMarginTop);
165 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
167 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_LEFT_LINE_THICKNESS, _CONTROL_ORIENTATION_PORTRAIT, __indexLeftLineThickness);
168 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
170 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __indexTextSize);
171 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
173 r = GET_FIXED_VALUE_CONFIG(FASTSCROLL::INDEX_SEPARATOR_THICKNESS, _CONTROL_ORIENTATION_PORTRAIT, __indexSeparatorThickness);
174 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
176 r = GET_SHAPE_CONFIG(FASTSCROLL::INDEX_SEPARATOR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __indexSeparatorWidth);
177 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
179 r = GET_SHAPE_CONFIG(FASTSCROLL::SELECTED_INDEX_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __selectedIndexMarginRight);
180 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
182 r = GET_SHAPE_CONFIG(FASTSCROLL::SELECTED_INDEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __selectedIndexHeight);
183 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
185 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __popupSize.width);
186 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
188 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __popupSize.height);
189 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
191 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_WIDTH_INCREMENT, _CONTROL_ORIENTATION_PORTRAIT, __popupWidthIncrement);
192 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
194 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_TEXT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __popupTextSize);
195 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
197 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_RIGHT_SHADOW, _CONTROL_ORIENTATION_PORTRAIT, __popupShadowRight);
198 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
200 r = GET_SHAPE_CONFIG(FASTSCROLL::POPUP_BOTTOM_SHADOW, _CONTROL_ORIENTATION_PORTRAIT, __popupShadowBottom);
201 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
204 // load color configuration
205 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_BG_NORMAL, __indexBgColor);
206 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
208 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_LINE_NORMAL, __indexLineColor);
209 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
211 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_LINE_PRESSED, __indexSelectedLineColor);
212 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
214 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_TEXT_NORMAL, __indexTextColor);
215 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
217 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_DIVIDER_NORMAL, __indexDividerColor);
218 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
220 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_BG_PRESSED, __selectedIndexBgColor);
221 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
223 r = GET_COLOR_CONFIG(FASTSCROLL::INDEX_TEXT_PRESSED, __selectedIndexTextColor);
224 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
226 r = GET_COLOR_CONFIG(FASTSCROLL::POPUP_BG_NORMAL, __popupBgColor);
227 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
229 r = GET_COLOR_CONFIG(FASTSCROLL::POPUP_TEXT_NORMAL, __popupTextColor);
230 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to get resource.");
235 __indexBgColor = Color::GetColor(COLOR_ID_BLACK);
236 __indexHighlightColor = Color::GetColor(COLOR_ID_BLACK);
237 __indexLineColor= Color::GetColor(COLOR_ID_BLACK);
238 __indexSelectedLineColor= Color::GetColor(COLOR_ID_BLACK);
239 __indexTextColor = Color::GetColor(COLOR_ID_BLACK);
240 __indexDividerColor= Color::GetColor(COLOR_ID_BLACK);
241 __selectedIndexBgColor = Color::GetColor(COLOR_ID_BLACK);
242 __selectedIndexTextColor = Color::GetColor(COLOR_ID_BLACK);
243 __popupBgColor = Color::GetColor(COLOR_ID_BLACK);
244 __popupTextColor = Color::GetColor(COLOR_ID_BLACK);
246 __indexSizeMin.SetSize(0.0f, 0.0f);
247 __popupSize.SetSize(0.0f, 0.0f);
249 __indexMarginTop = 0.0f;
251 __indexLeftLineThickness = 0.0f;
252 __indexTextSize = 0.0f;
253 __indexSeparatorThickness = 0.0f;
254 __indexSeparatorWidth = 0.0f;
255 __selectedIndexMarginRight = 0.0f;
256 __selectedIndexHeight = 0.0f;
257 __popupWidthIncrement = 0.0f;
258 __popupTextSize = 0.0f;
259 __popupShadowRight = 0.0f;
260 __popupShadowBottom = 0.0f;
261 __ignoreTouchEvent = false;
268 _FastScrollViewConfig::ReleaseResources(void)
270 delete __pIndexBgBitmap;
271 delete __pSelectedIndexBgBitmap;
272 delete __pSelectedIndexlineBitmap;
273 delete __pPopupBgBitmap;
274 delete __pPopupBgEffectBitmap;
276 __pIndexBgBitmap = null;
277 __pSelectedIndexBgBitmap = null;
278 __pSelectedIndexlineBitmap = null;
279 __pPopupBgBitmap = null;
280 __pPopupBgEffectBitmap = null;
284 _FastScrollViewConfig::Construct(_ControlOrientation orientation)
286 return ReloadConfig(orientation);
290 _FastScrollIndexView::_FastScrollIndexView(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
291 : __parentVe(parentVe)
292 , __viewConfig(viewConfig)
294 , __pSelectedIndex(null)
295 , __pSelectedIndexInOmittedIndex(null)
296 , __pFormerIndex(null)
297 , __pBaseIndexVe(null)
298 , __pSelectedBgVe(null)
299 , __pSelectedIndexVe(null)
300 , __needUpdateBaseIndex(false)
301 , __needUpdateSelectedIndex(false)
302 , __needDestroySelf(false)
306 _FastScrollIndexView::~_FastScrollIndexView(void)
308 if (__pSelectedIndexVe)
310 __pSelectedIndexVe->RemoveAllAnimations();
311 __pSelectedIndexVe->SetAnimationProvider(null);
313 __pSelectedIndexVe->Destroy();
314 __pSelectedIndexVe = null;
319 __pSelectedBgVe->RemoveAllAnimations();
320 __pSelectedBgVe->SetAnimationProvider(null);
322 __pSelectedBgVe->Destroy();
323 __pSelectedBgVe = null;
328 __pBaseIndexVe->RemoveAllAnimations();
329 __pBaseIndexVe->SetAnimationProvider(null);
331 __pBaseIndexVe->Destroy();
332 __pBaseIndexVe = null;
336 _FastScrollIndexView*
337 _FastScrollIndexView::CreateFastScrollIndexViewN(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
339 _FastScrollIndexView* pIndexView = new (std::nothrow) _FastScrollIndexView(parentVe, viewConfig);
340 SysTryReturn(NID_UI_CTRL, pIndexView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
342 result r = pIndexView->Construct();
343 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
345 SetLastResult(E_SUCCESS);
355 _FastScrollIndexView::FadeOutAndDestroy(void)
357 __needDestroySelf = true;
358 if (__pSelectedIndexVe)
360 __pSelectedIndexVe->RemoveAllAnimations();
365 __pSelectedBgVe->RemoveAllAnimations();
368 return SetIndexVisibility(false);
372 _FastScrollIndexView::SetBaseIndex(_FastScrollIndex* pIndex)
374 if (__pBaseIndex == pIndex)
379 __pBaseIndex = pIndex;
381 result r = UpdateIndex(false);
382 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view.");
388 _FastScrollIndexView::GetBaseIndex(void) const
394 _FastScrollIndexView::SetIndexBounds(const FloatRectangle& indexBounds)
396 SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null.");
398 FloatRectangle veBounds(indexBounds.x, indexBounds.y, indexBounds.width, indexBounds.height);
399 __pBaseIndexVe->SetBounds(veBounds);
401 __needUpdateBaseIndex = true;
405 __pSelectedIndexVe->SetBounds(veBounds);
407 __needUpdateSelectedIndex = true;
413 _FastScrollIndexView::GetIndexBounds(void) const
415 FloatRectangle veBounds = __pBaseIndexVe->GetBounds();
416 return Rectangle(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
420 _FastScrollIndexView::GetIndexBoundsF(void) const
422 return __pBaseIndexVe->GetBounds();
426 _FastScrollIndexView::GetIndexAtPoint(const FloatPoint& point) const
428 SysTryReturn(NID_UI_CTRL, __pBaseIndex, null, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
430 int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
431 SysTryReturn(NID_UI_CTRL, childCount > 0, null, E_INVALID_STATE, "[E_INVALID_STATE] The index has no children.");
433 _FastScrollIndex* pChildIndex = null;
435 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
436 if (bounds.Contains(point) == true)
438 float touchY = point.y - bounds.y - __viewConfig.__indexMarginTop;
439 float indexHeight = GetIndexHeight();
442 if (!(_FloatCompare(touchY, 0.0f) || _FloatCompare(indexHeight, 0.0f)))
444 indexOrder = _CoordinateSystemUtils::ConvertToInteger(touchY / indexHeight);
447 pChildIndex = __pBaseIndex->GetChildIndex(indexOrder, true);
448 SysTryReturn(NID_UI_CTRL, pChildIndex, null, GetLastResult(), "[%s] Failed to get the child index.",
449 GetErrorMessage(GetLastResult()));
452 SetLastResult(E_SUCCESS);
457 _FastScrollIndexView::GetOmissionIndexAtPoint(_FastScrollIndex* pIndex, const FloatPoint& point) const
459 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
460 float touchY = point.y - bounds.y - __viewConfig.__indexMarginTop - (pIndex->GetIndexOrder(true) * GetIndexHeight());
461 int hiddenChildCount = pIndex->GetChildCount();
462 SysTryReturn(NID_UI_CTRL, hiddenChildCount > 0, null, E_INVALID_STATE, "[E_INVALID_STATE] Failed to get the hidden index");
463 float indexHeight = GetIndexHeight() /hiddenChildCount;
464 int omissionIndexOrder = 0;
466 if ((touchY > 0.0f) && !_FloatCompare(indexHeight, 0.0f))
468 omissionIndexOrder = _CoordinateSystemUtils::ConvertToInteger(touchY / indexHeight);
471 _FastScrollIndex* pChildIndex = pIndex->GetChildIndex(omissionIndexOrder);
472 SysTryReturn(NID_UI_CTRL, pChildIndex, null, GetLastResult(), "[%s] Failed to get the child index.",
473 GetErrorMessage(GetLastResult()));
475 SetLastResult(E_SUCCESS);
480 _FastScrollIndexView::GetIndexHeight(void) const
482 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
483 float indexHeight = __viewConfig.__indexSizeMin.height;
485 if (__pBaseIndex->GetParentIndex() == null)
487 float indexHeightPerChild = (bounds.height - __viewConfig.__indexMarginTop * 2.0f) / (__pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType()));
488 if (indexHeight < indexHeightPerChild)
490 indexHeight = indexHeightPerChild;
498 _FastScrollIndexView::SelectIndex(int indexOrder)
500 result r = E_SUCCESS;
502 SysTryReturnResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "__pBaseIndex must not be null.");
504 _FastScrollIndex* pIndex = __pBaseIndex->GetChildIndex(indexOrder, true);
505 SysTryReturnResult(NID_UI_CTRL, pIndex, GetLastResult(), "Failed to get the child index.");
507 r = SelectIndex(pIndex, false);
508 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the index.");
514 _FastScrollIndexView::SelectIndex(_FastScrollIndex* pIndex, bool animation)
516 result r = E_SUCCESS;
518 if (__pSelectedIndex == pIndex)
523 __pSelectedIndex = pIndex;
525 if (__pSelectedIndex)
527 __pSelectedBgVe->SetBounds(CalculateSelectedBg());
528 if (GetSelectedIndexVisibility() == false)
530 r = SetSelectedIndexVisibility(true, animation);
531 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the Selected Bg ve.");
536 if (GetSelectedIndexVisibility() == true)
538 r = SetSelectedIndexVisibility(false, animation);
539 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the Selected Bg ve.");
541 SetSelectedIndexInOmittedIndex(null);
542 __pFormerIndex = null;
545 r = UpdateIndex(false);
546 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view.");
552 _FastScrollIndexView::SelectIndexList(bool isNext)
554 FloatMatrix4 baseVeMatrix;
555 baseVeMatrix.SetAsIdentity();
556 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
560 _MatrixUtilTranslate(baseVeMatrix, 0.0f, bounds.height, 0.0f);
564 _MatrixUtilTranslate(baseVeMatrix, 0.0f, -bounds.height, 0.0f);
566 __pBaseIndexVe->SetTransformMatrix(baseVeMatrix);
567 __pBaseIndexVe->SetImplicitAnimationEnabled(true);
569 baseVeMatrix.SetAsIdentity();
570 _MatrixUtilTranslate(baseVeMatrix, 0.0f, 0.0f, 0.0f);
571 __pBaseIndexVe->SetTransformMatrix(baseVeMatrix);
573 __pBaseIndexVe->SetImplicitAnimationEnabled(false);
574 __needUpdateBaseIndex = true;
579 _FastScrollIndexView::GetSelectedIndexOrder(void) const
581 SysTryReturn(NID_UI_CTRL, __pBaseIndex, -1, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
582 SysTryReturn(NID_UI_CTRL, __pSelectedIndex, -1, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndex must not be null.");
584 return __pBaseIndex->GetChildOrder(__pSelectedIndex, true);
588 _FastScrollIndexView::SetSelectedIndex(_FastScrollIndex* pIndex)
590 __pSelectedIndex = pIndex;
594 _FastScrollIndexView::GetSelectedIndex(void) const
596 return __pSelectedIndex;
600 _FastScrollIndexView::SetSelectedIndexInOmittedIndex(_FastScrollIndex* pIndex)
602 if (pIndex == __pSelectedIndexInOmittedIndex)
607 __pFormerIndex = __pSelectedIndexInOmittedIndex;
608 __pSelectedIndexInOmittedIndex = pIndex;
612 _FastScrollIndexView::GetSelectedIndexInOmittedIndex(void) const
614 return __pSelectedIndexInOmittedIndex;
618 _FastScrollIndexView::GetFormerIndex(void) const
620 return __pFormerIndex;
624 _FastScrollIndexView::IsOnAnimation(void) const
630 _FastScrollIndexView::RemoveAllAnimations(void)
632 __pBaseIndexVe->RemoveAllAnimations();
636 _FastScrollIndexView::SetIndexVisibility(bool visibility)
638 result r = E_SUCCESS;
640 __pBaseIndexVe->SetImplicitAnimationEnabled(true);
644 __pBaseIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON);
648 __pBaseIndexVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
650 // else keep up current visibility.
652 __pBaseIndexVe->SetImplicitAnimationEnabled(false);
658 _FastScrollIndexView::GetIndexVisibility(void) const
660 float opacity = __pBaseIndexVe->GetOpacity();
661 if (opacity > FASTSCROLL_OPACITY_OFF)
672 _FastScrollIndexView::SetSelectedIndexVisibility(bool visibility, bool animation)
674 SysTryReturnResult(NID_UI_CTRL, __pSelectedIndexVe, E_INVALID_STATE, "__pSelectedIndexVe must not be null.");
675 SysTryReturnResult(NID_UI_CTRL, __pSelectedBgVe, E_INVALID_STATE, "__pSelectedBgVe must not be null.");
679 __pSelectedIndexVe->SetImplicitAnimationEnabled(true);
680 __pSelectedBgVe->SetImplicitAnimationEnabled(true);
685 __pSelectedIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON);
686 __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_SELECTEDBG_DIM);
690 __pSelectedIndexVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
691 __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
693 // else keep up current visibility.
695 __pSelectedIndexVe->SetImplicitAnimationEnabled(false);
696 __pSelectedBgVe->SetImplicitAnimationEnabled(false);
702 _FastScrollIndexView::GetSelectedIndexVisibility(void) const
704 SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, false, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndexVe must not be null.");
706 float opacity = __pSelectedIndexVe->GetOpacity();
707 if (opacity > FASTSCROLL_OPACITY_OFF)
717 _FastScrollIndexView::AddAccessibilityElement(const _AccessibilityContainer& control)
719 SysTryReturnResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
721 int omittedChildCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
722 SysTryReturnResult(NID_UI_CTRL, omittedChildCount > 0, E_INVALID_STATE, "The index has no children.");
724 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
725 float indexHeight = GetIndexHeight();
726 FloatRectangle indexRect(bounds.x, __viewConfig.__indexMarginTop, bounds.width, indexHeight);
727 int nonOmittedIndex = 0;
729 _AccessibilityElement* pAccessibilityElement = null;
730 result r = E_SUCCESS;
731 for (int i = 0; i < omittedChildCount; )
733 _FastScrollIndex* pChildIndex = __pBaseIndex->GetChildIndex(i, true);
734 SysTryReturnResult(NID_UI_CTRL, pChildIndex, GetLastResult(), "Failed to get the child index.");
736 int omittedCount = 0;
737 if (pChildIndex->GetOmitted())
739 omittedCount = pChildIndex->GetChildCount();
740 pChildIndex = __pBaseIndex->GetChildIndex(nonOmittedIndex, false);
741 SysTryReturnResult(NID_UI_CTRL, pChildIndex, GetLastResult(), "Failed to get the child index.");
744 Bitmap* pChildIndexImage = pChildIndex->GetIndexImage();
745 if (pChildIndexImage == null)
747 String* pChildIndexText = pChildIndex->GetIndexText();
748 SysTryReturnResult(NID_UI_CTRL, pChildIndexText, E_INVALID_STATE, "pChildIndexText must not be null.");
750 _AccessibilityContainer* pAccessibilityContainer = const_cast <_AccessibilityContainer*>(&control);
751 pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
752 SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
753 pAccessibilityElement->SetBounds(indexRect);
754 pAccessibilityElement->SetLabel(*pChildIndexText);
755 pAccessibilityElement->SetName(L"FastScrollIndex");
756 pAccessibilityElement->SetHint(L"double tap to move ," + *pChildIndexText + L", list");
757 r = pAccessibilityContainer->AddElement(*pAccessibilityElement);
758 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to add accessibility element.", GetErrorMessage(r));
761 if (omittedCount > 1)
767 indexRect.y += indexHeight;
777 delete pAccessibilityElement;
782 _FastScrollIndexView::UpdateIndex(bool bNeedUpdateBaseIndex)
784 result r = E_SUCCESS;
786 r = __parentVe.InvalidateRectangle(null);
787 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to invalidate the index Ve.");
789 if (__pSelectedIndex)
791 __needUpdateSelectedIndex = true;
794 if (bNeedUpdateBaseIndex)
796 __needUpdateBaseIndex = true;
803 _FastScrollIndexView::OnDraw(void)
806 if (__pSelectedIndex)
813 VisualElementAnimation*
814 _FastScrollIndexView::CreateAnimationForProperty(VisualElement& target, const String& property)
816 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
820 const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
823 pAnimation->SetTimingFunction(pTimingFunction);
825 pAnimation->SetVisualElementAnimationStatusEventListener(this);
831 _FastScrollIndexView::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
836 _FastScrollIndexView::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
841 _FastScrollIndexView::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
843 if (__pBaseIndexVe == (static_cast <_VisualElement*>(&target)))
845 if (__needDestroySelf && completedNormally)
847 if (__pSelectedIndexVe)
849 __pSelectedIndexVe->RemoveAllAnimations();
850 __pSelectedIndexVe->SetAnimationProvider(null);
855 __pSelectedBgVe->RemoveAllAnimations();
856 __pSelectedBgVe->SetAnimationProvider(null);
859 __pBaseIndexVe->RemoveAllAnimations();
860 __pBaseIndexVe->SetAnimationProvider(null);
864 else if (__viewConfig.__ignoreTouchEvent)
866 __viewConfig.__ignoreTouchEvent = false;
872 _FastScrollIndexView::CalculateSelectedBg(void)
874 SysTryReturn(NID_UI_CTRL, __pBaseIndex, FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), E_INVALID_STATE,
875 "[E_INVALID_STATE] __pBaseIndex must not be null.");
876 SysTryReturn(NID_UI_CTRL, __pSelectedIndexVe, FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), E_INVALID_STATE,
877 "[E_INVALID_STATE] __pSelectedIndexVe must not be null.");
878 SysTryReturn(NID_UI_CTRL, __pSelectedIndex, FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), E_INVALID_STATE,
879 "[E_INVALID_STATE] __pSelectedIndex must not be null.");
881 int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
882 SysTryReturn(NID_UI_CTRL, childCount > 0, FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), E_INVALID_STATE, "[E_INVALID_STATE] The index has no children.");
884 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
885 float indexHeight = GetIndexHeight();
886 int selectedIndexOrder = GetSelectedIndexOrder();
887 FloatRectangle selectedRect(0.0f, 0.0f, (bounds.width - __viewConfig.__selectedIndexMarginRight), __viewConfig.__selectedIndexHeight);
889 if (_FloatCompare(bounds.height, __viewConfig.__selectedIndexHeight) || (bounds.height < __viewConfig.__selectedIndexHeight))
891 selectedRect.height = bounds.height;
895 selectedRect.y = ((selectedIndexOrder * indexHeight) + __viewConfig.__indexMarginTop);
896 if (indexHeight < __viewConfig.__selectedIndexHeight)
898 selectedRect.y -= ((__viewConfig.__selectedIndexHeight - indexHeight) / 2.0f);
902 selectedRect.height = indexHeight;
905 if (selectedRect.y < 0.0f)
907 selectedRect.y = 0.0f;
915 _FastScrollIndexView::DrawBaseIndex()
917 if (!__needUpdateBaseIndex)
921 SysTryReturnVoidResult(NID_UI_CTRL, __pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pBaseIndex must not be null.");
923 result r = E_SUCCESS;
924 int childCount = __pBaseIndex->GetChildCount(__pBaseIndex->GetIndexType());
925 SysTryReturnVoidResult(NID_UI_CTRL, childCount > 0, E_INVALID_STATE, "[E_INVALID_STATE] The index has no children.");
927 Canvas* pCanvas = __pBaseIndexVe->GetCanvasN();
928 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the index ve.",
929 GetErrorMessage(GetLastResult()));
931 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
934 pCanvas->SetLineWidth(__viewConfig.__indexSeparatorThickness);
935 pCanvas->SetForegroundColor(__viewConfig.__indexLineColor);
938 FloatRectangle bounds = __pBaseIndexVe->GetBounds();
939 float indexHeight = GetIndexHeight();
941 FloatRectangle bgBounds(0.0f, 0.0f, bounds.width, bounds.height);
942 if (__viewConfig.__pIndexBgBitmap)
944 Bitmap* pReplacementColorBackgroundBitmap =
945 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pIndexBgBitmap,
946 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__indexBgColor);
947 DrawBitmap(*pCanvas, bgBounds, *pReplacementColorBackgroundBitmap);
949 delete pReplacementColorBackgroundBitmap;
951 pCanvas->DrawLine(FloatPoint(1.0f, 0.0f), FloatPoint(1.0f, bounds.height));
953 FloatRectangle indexRect(0.0f, __viewConfig.__indexMarginTop, bounds.width, indexHeight);
954 Bitmap* pReplacementColorBitmap = null;
955 float separatorX = indexRect.x + ((indexRect.width - __viewConfig.__indexSeparatorWidth)/2.0f);
957 TextObject* pTextObject = new (std::nothrow) TextObject();
958 SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
960 pTextObject->Construct();
962 for (int i = 0; i < childCount; i++)
964 TextSimple* pSimpleText = null;
966 _FastScrollIndex* pChildIndex = __pBaseIndex->GetChildIndex(i, true);
967 SysTryCatch(NID_UI_CTRL, pChildIndex, , GetLastResult(), "[%s] Failed to get the child index.",
968 GetErrorMessage(GetLastResult()));
970 Bitmap* pChildIndexImage = pChildIndex->GetIndexImage();
971 if (pChildIndexImage)
973 FloatRectangle imageRect = indexRect;
974 float scaleFactor = indexRect.width / pChildIndexImage->GetWidthF();
975 float heightScaleFactor = indexRect.height / pChildIndexImage->GetHeightF();
976 if (scaleFactor > heightScaleFactor)
978 scaleFactor = heightScaleFactor;
981 imageRect.width = pChildIndexImage->GetWidthF() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
982 imageRect.height = pChildIndexImage->GetHeightF() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
984 if (indexRect.width - imageRect.width > 0.0f)
986 imageRect.x = indexRect.x + (indexRect.width - imageRect.width) / 2.0f;
989 if (indexRect.height - imageRect.height > 0.0f)
991 imageRect.y = indexRect.y + (indexRect.height - imageRect.height) / 2.0f;
994 pReplacementColorBitmap =
995 _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage,
996 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__indexTextColor);
997 r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap,
998 FloatRectangle(0.0f, 0.0f, pChildIndexImage->GetWidthF(), pChildIndexImage->GetHeightF()));
999 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r));
1001 delete pReplacementColorBitmap;
1002 pReplacementColorBitmap = null;
1006 String* pChildIndexText = pChildIndex->GetIndexText();
1007 SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "pChildIndexText must not be null.");
1009 pTextObject->RemoveAll();
1011 pSimpleText = new (std::nothrow)TextSimple(const_cast<wchar_t*>(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1012 SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed");
1014 r = pTextObject->AppendElement(*pSimpleText);
1015 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simple text.", GetErrorMessage(r));
1017 r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1018 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r));
1020 r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength());
1021 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
1023 r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1024 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r));
1026 r = pTextObject->SetBounds(indexRect);
1027 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r));
1029 r = pTextObject->SetForegroundColor(__viewConfig.__indexTextColor, 0, pTextObject->GetTextLength());
1030 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r));
1032 r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1033 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r));
1037 indexRect.y += indexHeight;
1038 if (i != (childCount - 1))
1040 pCanvas->SetForegroundColor(__viewConfig.__indexDividerColor);
1041 pCanvas->DrawLine(FloatPoint(separatorX, indexRect.y + __viewConfig.__indexSeparatorThickness),
1042 FloatPoint(__viewConfig.__indexSeparatorWidth, indexRect.y + __viewConfig.__indexSeparatorThickness));
1046 __needUpdateBaseIndex = false;
1051 delete pReplacementColorBitmap;
1055 _FastScrollIndexView::DrawSelectedBg()
1057 if (!__needUpdateSelectedIndex)
1062 SysTryReturnVoidResult(NID_UI_CTRL, __pSelectedIndex, E_INVALID_STATE,
1063 "[E_INVALID_STATE] __pSelectedIndex must not be null.");
1065 Canvas* pCanvas = __pSelectedBgVe->GetCanvasN();
1066 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the Selected Bg ve.",
1067 GetErrorMessage(GetLastResult()));
1069 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1072 FloatRectangle bounds = __pSelectedBgVe->GetBounds();
1075 if (__viewConfig.__pSelectedIndexBgBitmap)
1077 Bitmap* pReplacementColorBackgroundBitmap = null;
1078 pReplacementColorBackgroundBitmap =
1079 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pSelectedIndexBgBitmap,
1080 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexBgColor);
1081 DrawBitmap(*pCanvas, bounds, *pReplacementColorBackgroundBitmap);
1083 delete pReplacementColorBackgroundBitmap;
1090 _FastScrollIndexView::DrawSelectedIndex()
1092 if (!__needUpdateSelectedIndex)
1097 SysTryReturnVoidResult(NID_UI_CTRL, __pSelectedIndex, E_INVALID_STATE, "[E_INVALID_STATE] __pSelectedIndex must not be null.");
1099 Canvas* pCanvas = __pSelectedIndexVe->GetCanvasN();
1100 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the selected index ve.",
1101 GetErrorMessage(GetLastResult()));
1103 result r = E_SUCCESS;
1104 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1106 FloatRectangle bounds = __pSelectedIndexVe->GetBounds();
1107 FloatRectangle outlineBounds = __pSelectedBgVe->GetBounds();
1109 pCanvas->SetLineWidth(__viewConfig.__indexLeftLineThickness);
1110 pCanvas->SetForegroundColor(__viewConfig.__indexSelectedLineColor);
1112 if (__viewConfig.__pSelectedIndexlineBitmap)
1114 Bitmap* pReplacementColorBackgroundBitmap = null;
1115 pReplacementColorBackgroundBitmap =
1116 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pSelectedIndexlineBitmap,
1117 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__indexSelectedLineColor);
1118 DrawBitmap(*pCanvas, outlineBounds, *pReplacementColorBackgroundBitmap);
1120 delete pReplacementColorBackgroundBitmap;
1122 pCanvas->DrawLine(FloatPoint(1.0f, 0.0f), FloatPoint(1.0f, outlineBounds.y));
1123 pCanvas->DrawLine(FloatPoint(1.0f, (outlineBounds.y + outlineBounds.height)), FloatPoint(1.0f, bounds.height));
1127 TextObject* pTextObject = null;
1128 TextSimple* pSimpleText = null;
1130 float indexHeight = GetIndexHeight();
1131 FloatRectangle indexRect(0.0f, ((GetSelectedIndexOrder() * indexHeight) + __viewConfig.__indexMarginTop),
1132 bounds.width, indexHeight);
1134 Bitmap* pChildIndexImage = __pSelectedIndex->GetIndexImage();
1135 Bitmap* pReplacementColorBitmap = null;
1136 if (pChildIndexImage)
1138 FloatRectangle imageRect = indexRect;
1139 float scaleFactor = indexRect.width / pChildIndexImage->GetWidthF();
1140 float heightScaleFactor = indexRect.height / pChildIndexImage->GetHeightF();
1141 if (scaleFactor > heightScaleFactor)
1143 scaleFactor = heightScaleFactor;
1146 imageRect.width = pChildIndexImage->GetWidthF() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
1147 imageRect.height = pChildIndexImage->GetHeightF() * scaleFactor + FASTSCROLL_OPACITY_SELECTEDBG_DIM;
1149 if (indexRect.width - imageRect.width > 0.0f)
1151 imageRect.x = indexRect.x + (indexRect.width - imageRect.width) / 2.0f;
1154 if (indexRect.height - imageRect.height > 0.0f)
1156 imageRect.y = indexRect.y + (indexRect.height - imageRect.height) / 2.0f;
1159 pReplacementColorBitmap =
1160 _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage,
1161 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__selectedIndexTextColor);
1162 r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap,
1163 FloatRectangle(0.0f, 0.0f, pChildIndexImage->GetWidthF(), pChildIndexImage->GetHeightF()));
1164 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r));
1166 delete pReplacementColorBitmap;
1167 pReplacementColorBitmap = null;
1171 String* pChildIndexText = __pSelectedIndex->GetIndexText();
1172 SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "[E_INVALID_STATE] pChildIndexText must not be null.");
1174 pTextObject = new (std::nothrow) TextObject();
1175 SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1177 pTextObject->Construct();
1179 pSimpleText = new (std::nothrow)TextSimple(const_cast<wchar_t*>(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1180 SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1182 r = pTextObject->AppendElement(*pSimpleText);
1183 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simpletext.", GetErrorMessage(r));
1185 r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1186 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r));
1188 r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength());
1189 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
1191 r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1192 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r));
1194 r = pTextObject->SetBounds(indexRect);
1195 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r));
1197 r = pTextObject->SetForegroundColor(__viewConfig.__selectedIndexTextColor, 0, pTextObject->GetTextLength());
1198 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r));
1200 r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1201 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r));
1204 __needUpdateSelectedIndex = false;
1210 delete pReplacementColorBitmap;
1214 _FastScrollIndexView::DrawBitmap(Canvas& canvas, const FloatRectangle& bounds, const Bitmap& bitmap)
1216 result r = E_SUCCESS;
1217 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))
1219 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
1220 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1224 r = canvas.DrawBitmap(bounds, bitmap);
1225 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1232 _FastScrollIndexView::DrawBitmap(Canvas& canvas, const FloatRectangle& srcRect, const Bitmap& bitmap, const FloatRectangle& dstRect)
1234 result r = E_SUCCESS;
1235 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))
1237 r = canvas.DrawNinePatchedBitmap(srcRect, bitmap);
1238 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1242 r = canvas.DrawBitmap(srcRect, bitmap, dstRect);
1243 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1250 _FastScrollIndexView::Construct(void)
1252 result r = E_SUCCESS;
1254 // FormattedText for Title text
1255 __pBaseIndexVe = new (std::nothrow) _VisualElement();
1256 SysTryCatch(NID_UI_CTRL, __pBaseIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1258 r = __pBaseIndexVe->Construct();
1259 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the index Ve.", GetErrorMessage(r));
1261 __pBaseIndexVe->SetAnimationProvider(this);
1263 r = __pBaseIndexVe->SetSurfaceOpaque(false);
1264 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the base index ve.", GetErrorMessage(r));
1266 __pBaseIndexVe->SetImplicitAnimationEnabled(false);
1268 r = __parentVe.AttachChild(*__pBaseIndexVe);
1269 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the base index ve to the parent.", GetErrorMessage(r));
1271 __pBaseIndexVe->SetShowState(true);
1274 __pSelectedBgVe = new (std::nothrow) _VisualElement();
1275 SysTryCatch(NID_UI_CTRL, __pSelectedBgVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1277 r = __pSelectedBgVe->Construct();
1278 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the selected Bg ve.", GetErrorMessage(r));
1280 __pSelectedBgVe->SetAnimationProvider(this);
1282 r = __pSelectedBgVe->SetSurfaceOpaque(false);
1283 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the selected Bg ve.", GetErrorMessage(r));
1285 __pSelectedBgVe->SetImplicitAnimationEnabled(false);
1287 r = __pBaseIndexVe->AttachChild(*__pSelectedBgVe);
1288 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the selected Bg ve to the parent.", GetErrorMessage(r));
1290 __pSelectedBgVe->SetOpacity(FASTSCROLL_OPACITY_SELECTEDBG_DIM);
1292 __pSelectedBgVe->SetShowState(true);
1294 //__pSelectedIndexVe
1295 __pSelectedIndexVe = new (std::nothrow) _VisualElement();
1296 SysTryCatch(NID_UI_CTRL, __pSelectedIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1298 r = __pSelectedIndexVe->Construct();
1299 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the selected index ve.", GetErrorMessage(r));
1301 __pSelectedIndexVe->SetAnimationProvider(this);
1303 r = __pSelectedIndexVe->SetSurfaceOpaque(false);
1304 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the selected index ve.", GetErrorMessage(r));
1306 __pSelectedIndexVe->SetImplicitAnimationEnabled(false);
1308 r = __pBaseIndexVe->AttachChild(*__pSelectedIndexVe);
1309 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the selected index ve to the parent.", GetErrorMessage(r));
1311 __pSelectedIndexVe->SetShowState(true);
1316 if (__pSelectedIndexVe)
1318 __pSelectedIndexVe->Destroy();
1319 __pSelectedIndexVe = null;
1322 if (__pSelectedBgVe)
1324 __pSelectedBgVe->Destroy();
1325 __pSelectedBgVe = null;
1330 __pBaseIndexVe->Destroy();
1331 __pBaseIndexVe = null;
1337 _FastScrollPopupView::_FastScrollPopupView(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
1338 : __parentVe(parentVe)
1339 , __viewConfig(viewConfig)
1341 , __needUpdatePopupVe(false)
1342 , __needUpdatePopupIndexVe(false)
1343 , __needDestroySelf(false)
1347 _FastScrollPopupView::~_FastScrollPopupView(void)
1349 for (int i = 0; i < GetIndexVeCount(); i++)
1351 _VisualElement* pIndexVe = GetIndexVe(i);
1355 pIndexVe->RemoveAllAnimations();
1356 pIndexVe->SetAnimationProvider(null);
1357 pIndexVe->Destroy();
1360 __indexViews.RemoveAll(false);
1364 __pPopupVe->RemoveAllAnimations();
1365 __pPopupVe->SetAnimationProvider(null);
1367 __pPopupVe->Destroy();
1372 _FastScrollPopupView*
1373 _FastScrollPopupView::CreateFastScrollPopupViewN(_VisualElement& parentVe, _FastScrollViewConfig& viewConfig)
1375 _FastScrollPopupView* pPopupView = new (std::nothrow) _FastScrollPopupView(parentVe, viewConfig);
1376 SysTryReturn(NID_UI_CTRL, pPopupView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1378 result r = pPopupView->Construct();
1379 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1381 SetLastResult(E_SUCCESS);
1391 _FastScrollPopupView::FadeOutAndDestroy(void)
1393 __needDestroySelf = true;
1395 for (int i = 0; i < GetIndexVeCount(); i++)
1397 _VisualElement* pIndexVe = GetIndexVe(i);
1398 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view.");
1400 pIndexVe->RemoveAllAnimations();
1403 return SetPopupVisibility(false);
1407 _FastScrollPopupView::SelectIndex(int indexLevel, _FastScrollIndex* pIndex, _FastScrollIndex* pFormerIndex)
1409 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1410 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view.");
1414 pIndexVe->SetOpacity(FASTSCROLL_OPACITY_ON);
1415 FloatRectangle popupVeBounds = __pPopupVe->GetBounds();
1416 FloatMatrix4 popupVeMatrix;
1417 popupVeMatrix.SetAsIdentity();
1419 if (pFormerIndex && (pFormerIndex != pIndex))
1421 FloatRectangle popupIndexVeBounds = pIndexVe->GetBounds();
1423 int selectedOrder = pIndex->GetIndexOrder(false);
1424 int oldOrder = pFormerIndex->GetIndexOrder(false);
1426 if (selectedOrder > oldOrder)
1428 _MatrixUtilTranslate(popupVeMatrix, 0.0f, 0.0f, 0.0f);
1432 _MatrixUtilTranslate(popupVeMatrix, 0.0f, -(popupVeBounds.height * (FASTSCROLL_POPUPINDEX_COUNT - 1)), 0.0f);
1434 pIndexVe->SetTransformMatrix(popupVeMatrix);
1435 pIndexVe->SetImplicitAnimationEnabled(true);
1437 popupVeMatrix.SetAsIdentity();
1438 _MatrixUtilTranslate(popupVeMatrix, 0.0f, -popupVeBounds.height, 0.0f);
1439 pIndexVe->SetTransformMatrix(popupVeMatrix);
1441 pIndexVe->SetImplicitAnimationEnabled(false);
1445 _MatrixUtilTranslate(popupVeMatrix, 0.0f, -popupVeBounds.height, 0.0f);
1446 pIndexVe->SetTransformMatrix(popupVeMatrix);
1451 pIndexVe->SetOpacity(FASTSCROLL_OPACITY_LIGHT_DIM);
1458 _FastScrollPopupView::AddPopupIndexVe(int indexLevel)
1460 result r = E_SUCCESS;
1461 _VisualElement* pPopupIndexVe = new (std::nothrow) _VisualElement();
1462 SysTryCatch(NID_UI_CTRL, pPopupIndexVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1464 r = pPopupIndexVe->Construct();
1465 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the popup index ve.", GetErrorMessage(r));
1467 pPopupIndexVe->SetAnimationProvider(this);
1469 r = pPopupIndexVe->SetSurfaceOpaque(false);
1470 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the popup index ve.", GetErrorMessage(r));
1472 pPopupIndexVe->SetImplicitAnimationEnabled(false);
1474 r = __pPopupVe->AttachChild(*pPopupIndexVe);
1475 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the popup index ve to the popup ve.", GetErrorMessage(r));
1477 pPopupIndexVe->SetShowState(true);
1479 r = __indexViews.InsertAt(*pPopupIndexVe, indexLevel);
1480 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to change the last index view.", GetErrorMessage(r));
1487 pPopupIndexVe->RemoveAllAnimations();
1488 pPopupIndexVe->SetAnimationProvider(null);
1490 pPopupIndexVe->Destroy();
1497 _FastScrollPopupView::RemovePopupIndexVe(int indexLevel)
1499 result r = E_SUCCESS;
1501 if (indexLevel < GetIndexVeCount())
1503 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1504 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index ve.");
1506 r = __indexViews.Remove(*pIndexVe, false);
1507 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove the popup index ve.");
1509 pIndexVe->RemoveAllAnimations();
1510 pIndexVe->SetAnimationProvider(null);
1511 pIndexVe->Destroy();
1518 _FastScrollPopupView::SetPopupBounds(const FloatRectangle& indexBounds)
1520 SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null.");
1522 __pPopupVe->SetBounds(indexBounds);
1528 _FastScrollPopupView::SetPopupIndexBounds(int indexLevel, const _FastScrollIndex* pBaseIndex)
1530 FloatRectangle veBounds = __pPopupVe->GetBounds();
1531 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1532 SysTryReturnResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "Failed to get the popup index view.");
1538 veBounds.height = veBounds.height * FASTSCROLL_POPUPINDEX_COUNT;
1541 int indexVeCount = GetIndexVeCount();
1542 float indexWidth = veBounds.width;
1543 if (indexVeCount > 0)
1545 indexWidth /= indexVeCount;
1548 veBounds.width = indexWidth;
1549 veBounds.x = veBounds.width * indexLevel;
1551 pIndexVe->SetBounds(veBounds);
1557 _FastScrollPopupView::GetIndexVe(int indexLevel) const
1559 Object* pObj = const_cast<Object*>(__indexViews.GetAt(indexLevel));
1560 SysTryReturn(NID_UI_CTRL, pObj, null, GetLastResult(), "[%s] Failed to get the popup index ve.",
1561 GetErrorMessage(GetLastResult()));
1563 return dynamic_cast<_VisualElement*>(pObj);
1567 _FastScrollPopupView::GetIndexVeCount(void) const
1569 return __indexViews.GetCount();
1573 _FastScrollPopupView::IsOnAnimation(void) const
1579 _FastScrollPopupView::RemoveAllAnimations(void)
1581 SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null.");
1582 __pPopupVe->RemoveAllAnimations();
1586 _FastScrollPopupView::SetPopupVisibility(bool visibility)
1588 SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null.");
1592 __pPopupVe->SetTransformMatrix(__matrixFadeInStart);
1593 __pPopupVe->SetImplicitAnimationEnabled(true);
1594 __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_ON);
1595 __pPopupVe->SetTransformMatrix(__matrixOrigin);
1596 __pPopupVe->SetImplicitAnimationEnabled(false);
1600 __pPopupVe->SetImplicitAnimationEnabled(true);
1601 __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
1602 __pPopupVe->SetTransformMatrix(__matrixFadeOutEnd);
1603 __pPopupVe->SetImplicitAnimationEnabled(false);
1605 // else keep up current visibility.
1611 _FastScrollPopupView::GetPopupVisibility(void) const
1613 SysTryReturn(NID_UI_CTRL, __pPopupVe, false, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null.");
1615 float opacity = __pPopupVe->GetOpacity();
1616 if (opacity > FASTSCROLL_OPACITY_OFF)
1625 _FastScrollPopupView::SetPopupVeUpdateNeeded(bool needUpdate)
1627 __needUpdatePopupIndexVe = needUpdate;
1631 _FastScrollPopupView::UpdateIndex(void)
1633 SysTryReturnResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "__pPopupVe must not be null.");
1635 result r = E_SUCCESS;
1637 r = __parentVe.InvalidateRectangle(null);
1638 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to invalidate the popup Ve.");
1640 __needUpdatePopupIndexVe = true;
1646 _FastScrollPopupView::OnDraw(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex)
1649 DrawPopupIndexVe(indexLevel, pBaseIndex, pSelectedIndex);
1652 VisualElementAnimation*
1653 _FastScrollPopupView::CreateAnimationForProperty(VisualElement& target, const String& property)
1655 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
1659 const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
1660 if (pTimingFunction)
1662 pAnimation->SetTimingFunction(pTimingFunction);
1664 pAnimation->SetVisualElementAnimationStatusEventListener(this);
1670 _FastScrollPopupView::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
1675 _FastScrollPopupView::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
1680 _FastScrollPopupView::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
1682 SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] The popup Ve must not be null.");
1683 if (__pPopupVe == (static_cast <_VisualElement*>(&target)))
1685 if (__needDestroySelf && completedNormally)
1687 for (int i = 0; i < GetIndexVeCount(); i++)
1689 _VisualElement* pIndexVe = GetIndexVe(i);
1692 pIndexVe->RemoveAllAnimations();
1693 pIndexVe->SetAnimationProvider(null);
1697 __pPopupVe->RemoveAllAnimations();
1698 __pPopupVe->SetAnimationProvider(null);
1706 _FastScrollPopupView::DrawPopupVe(void)
1708 if (!__needUpdatePopupVe)
1713 SysTryReturnVoidResult(NID_UI_CTRL, __pPopupVe, E_INVALID_STATE, "[E_INVALID_STATE] __pPopupVe must not be null.");
1715 Canvas* pCanvas = __pPopupVe->GetCanvasN();
1716 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the popup ve.",
1717 GetErrorMessage(GetLastResult()));
1719 FloatRectangle bounds = __pPopupVe->GetBounds();
1720 bounds.SetPosition(0.0f, 0.0f);
1722 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1724 bool isCustomBitmap = IS_CUSTOM_BITMAP(FASTSCROLL::POPUP_BG_NORMAL);
1726 if (__viewConfig.__pPopupBgEffectBitmap && isCustomBitmap == false)
1728 DrawBitmap(*pCanvas, bounds, *__viewConfig.__pPopupBgEffectBitmap);
1731 if (__viewConfig.__pPopupBgBitmap)
1733 Bitmap* pReplacementColorBackgroundBitmap = null;
1734 pReplacementColorBackgroundBitmap =
1735 _BitmapImpl::GetColorReplacedBitmapN(*__viewConfig.__pPopupBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__popupBgColor);
1736 DrawBitmap(*pCanvas, bounds, *pReplacementColorBackgroundBitmap);
1738 delete pReplacementColorBackgroundBitmap;
1743 __needUpdatePopupVe = false;
1748 _FastScrollPopupView::DrawPopupIndexVe(int indexLevel, const _FastScrollIndex* pBaseIndex, const _FastScrollIndex* pSelectedIndex)
1750 if (__needUpdatePopupIndexVe != true)
1755 SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndex, E_INVALID_STATE, "[E_INVALID_STATE] pBaseIndex must not be null.");
1756 SysTryReturnVoidResult(NID_UI_CTRL, pSelectedIndex, E_INVALID_STATE, "[E_INVALID_STATE] pBaseIndex must not be null.");
1758 result r = E_SUCCESS;
1760 int childCount = pBaseIndex->GetChildCount();
1761 SysTryReturnVoidResult(NID_UI_CTRL, childCount > 0, E_INVALID_STATE, "[E_INVALID_STATE] The index has no children.");
1763 _VisualElement* pIndexVe = GetIndexVe(indexLevel);
1764 SysTryReturnVoidResult(NID_UI_CTRL, pIndexVe, GetLastResult(), "[%s] Failed to get the popup index ve.",
1765 GetErrorMessage(GetLastResult()));
1767 Canvas* pCanvas = pIndexVe->GetCanvasN();
1768 SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, GetLastResult(), "[%s] Failed to get the canvas of the popup index ve.",
1769 GetErrorMessage(GetLastResult()));
1771 pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
1774 FloatRectangle veBounds = pIndexVe->GetBounds();
1775 FloatRectangle bounds(veBounds.x, veBounds.y, veBounds.width, veBounds.height);
1777 float indexHeight = bounds.height / FASTSCROLL_POPUPINDEX_COUNT;
1778 if (indexHeight < __viewConfig.__indexTextSize)
1780 indexHeight = __viewConfig.__indexTextSize;
1783 FloatRectangle indexRect(0.0f, 0.0f, bounds.width, indexHeight);
1784 int selectedOrder = pSelectedIndex->GetIndexOrder(false);
1785 Bitmap* pReplacementColorBitmap = null;
1787 TextObject* pTextObject = new (std::nothrow) TextObject();
1788 SysTryCatch(NID_UI_CTRL, pTextObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1790 pTextObject->Construct();
1792 for (int i = -1; i < 2; i++)
1794 TextSimple* pSimpleText = null;
1796 _FastScrollIndex* pChildIndex = pBaseIndex->GetChildIndex(selectedOrder + i);
1799 Bitmap* pChildIndexImage = pChildIndex->GetIndexImage();
1800 if (pChildIndexImage)
1802 FloatRectangle imageRect = indexRect;
1803 float scaleFactor = indexRect.width / pChildIndexImage->GetWidthF();
1804 float heightScale = indexRect.height / pChildIndexImage->GetHeightF();
1805 float rectHeight = indexRect.height;
1806 if (rectHeight > __viewConfig.__popupTextSize)
1808 rectHeight = __viewConfig.__popupTextSize;
1811 if (scaleFactor > heightScale)
1813 scaleFactor = heightScale;
1815 imageRect.width = pChildIndexImage->GetWidthF() * scaleFactor;
1816 imageRect.height = pChildIndexImage->GetHeightF() * scaleFactor;
1818 if (indexRect.width - imageRect.width > 0.0f)
1820 imageRect.x = indexRect.x + (indexRect.width - imageRect.width) / 2.0f;
1823 if (indexRect.height - imageRect.height > 0.0f)
1825 imageRect.y = indexRect.y + (indexRect.height - imageRect.height) / 2.0f;
1828 pReplacementColorBitmap =
1829 _BitmapImpl::GetColorReplacedBitmapN(*pChildIndexImage,
1830 Color::GetColor(COLOR_ID_MAGENTA), __viewConfig.__popupTextColor);
1831 r = DrawBitmap(*pCanvas, imageRect, *pReplacementColorBitmap,
1832 FloatRectangle(0.0f, 0.0f, pChildIndexImage->GetWidthF(), pChildIndexImage->GetHeightF()));
1833 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw a bitmap.", GetErrorMessage(r));
1835 delete pReplacementColorBitmap;
1836 pReplacementColorBitmap = null;
1840 String* pChildIndexText = pChildIndex->GetIndexText();
1841 SysTryCatch(NID_UI_CTRL, pChildIndexText, , E_INVALID_STATE, "[E_INVALID_STATE] pChildIndexText must not be null.");
1843 pTextObject->RemoveAll();
1845 pSimpleText = new (std::nothrow)TextSimple(const_cast<wchar_t*>(pChildIndexText->GetPointer()), pChildIndexText->GetLength(), TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
1846 SysTryCatch(NID_UI_CTRL, pSimpleText, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1848 r = pTextObject->AppendElement(*pSimpleText);
1849 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to append simple text.", GetErrorMessage(r));
1851 r = pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1852 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set wrap.", GetErrorMessage(r));
1854 r = pTextObject->SetFont(__viewConfig.__pFont, 0, pTextObject->GetTextLength());
1855 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set font.", GetErrorMessage(r));
1857 r = pTextObject->SetForegroundColor(__viewConfig.__popupTextColor, 0, pTextObject->GetTextLength());
1858 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set foreground color.", GetErrorMessage(r));
1860 r = pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
1861 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set alignment.", GetErrorMessage(r));
1863 r = pTextObject->SetBounds(indexRect);
1864 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set bounds of pTextObject.", GetErrorMessage(r));
1866 r = pTextObject->Draw(*_CanvasImpl::GetInstance(*pCanvas));
1867 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to draw text.", GetErrorMessage(r));
1871 indexRect.y += indexHeight;
1878 delete pReplacementColorBitmap;
1882 _FastScrollPopupView::DrawBitmap(Canvas& canvas, const FloatRectangle& bounds, const Bitmap& bitmap)
1884 result r = E_SUCCESS;
1885 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))
1887 r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
1888 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1892 r = canvas.DrawBitmap(bounds, bitmap);
1893 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1900 _FastScrollPopupView::DrawBitmap(Canvas& canvas, const FloatRectangle& srcRect, const Bitmap& bitmap, const FloatRectangle& dstRect)
1902 result r = E_SUCCESS;
1903 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))
1905 r = canvas.DrawNinePatchedBitmap(srcRect, bitmap);
1906 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw ninepathced bitmap");
1910 r = canvas.DrawBitmap(srcRect, bitmap, dstRect);
1911 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to draw bitmap");
1918 _FastScrollPopupView::Construct(void)
1920 result r = E_SUCCESS;
1922 __pPopupVe = new (std::nothrow) _VisualElement();
1923 SysTryCatch(NID_UI_CTRL, __pPopupVe, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1925 r = __pPopupVe->Construct();
1926 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to construct the popup ve.", GetErrorMessage(r));
1928 __pPopupVe->SetAnimationProvider(this);
1930 r = __pPopupVe->SetSurfaceOpaque(false);
1931 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the opaque of the popup ve.", GetErrorMessage(r));
1933 __pPopupVe->SetImplicitAnimationEnabled(false);
1935 r = __parentVe.AttachChild(*__pPopupVe);
1936 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to attach the popup ve to the parent.", GetErrorMessage(r));
1938 __pPopupVe->SetShowState(true);
1939 __pPopupVe->SetClipChildrenEnabled(true);
1940 __pPopupVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
1942 __needUpdatePopupVe = true;
1944 __matrixOrigin.SetAsIdentity();
1945 __matrixFadeInStart.SetAsIdentity();
1946 __matrixFadeOutEnd.SetAsIdentity();
1948 _MatrixUtilScale(__matrixFadeInStart, 0.8f, 0.8f, 1.0f);
1949 _MatrixUtilScale(__matrixFadeOutEnd, 0.1f, 0.1f, 1.0f);
1956 __pPopupVe->Destroy();
1963 _FastScrollPresenter::_FastScrollPresenter(_Control& parentCtrl, _FastScroll& fastScroll, bool enableFadeEffect, bool visibility)
1964 : __parentCtrl(parentCtrl)
1965 , __fastScroll(fastScroll)
1967 , __pViewConfig(null)
1968 , __pFastScrollEvent(null)
1969 , __pFastScrollModel(null)
1972 , __pPopupView(null)
1973 , __focusedIndexLevel(0)
1974 , __pSelectedIndex(null)
1975 , __enableFadeEffect(enableFadeEffect)
1976 , __indexCountMax(0)
1979 , __scrollVisibility(visibility)
1980 , __fadeEffectDuration_ms(500)
1984 _FastScrollPresenter::~_FastScrollPresenter(void)
1986 delete __pFastScrollEvent;
1987 __pFastScrollEvent = null;
1989 delete __pFastScrollModel;
1990 __pFastScrollModel = null;
1992 delete __pPopupView;
1993 __pPopupView = null;
1995 RemoveAllIndexViews(false);
1997 delete __pViewConfig;
1998 __pViewConfig = null;
2002 __pCtrlVe->RemoveAllAnimations();
2003 __pCtrlVe->SetAnimationProvider(null);
2007 _FastScrollPresenter*
2008 _FastScrollPresenter::CreateFastScrollPresenterN(_Control& parentCtrl, _FastScroll& fastScroll, bool enableFadeEffect, bool visibility)
2010 _FastScrollPresenter* pPresenter = new (std::nothrow) _FastScrollPresenter(parentCtrl, fastScroll, enableFadeEffect, visibility);
2011 SysTryReturn(NID_UI_CTRL, pPresenter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2013 result r = pPresenter->Construct();
2014 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
2025 _FastScrollPresenter::SetRootIndex(_FastScrollIndex* pIndex)
2027 result r = E_SUCCESS;
2029 // initialize index views
2030 RemoveAllIndexViews(false);
2032 // initialize the popup view
2035 r = __pPopupView->SetPopupVisibility(false);
2036 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear visibility of the popup view.");
2039 r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__indexTextSize);
2040 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set font.");
2042 // set the root index into _FastScrollModel
2043 r = __pFastScrollModel->SetRootIndex(pIndex);
2044 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the root index into _FastScrollModel");
2046 // add new root index view.
2049 r = AddIndexView(0, *pIndex);
2050 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add the root index view.");
2057 _FastScrollPresenter::GetRootIndex(void) const
2059 return __pFastScrollModel->GetRootIndex();
2063 _FastScrollPresenter::UpdateIndex(void)
2065 result r = E_SUCCESS;
2067 // update the base index of index views
2068 int indexViewCount = GetIndexViewCount();
2069 for (int i = 0; i < indexViewCount; i++)
2071 _FastScrollIndexView* pIndexView = GetIndexView(i);
2072 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
2074 _FastScrollIndex* pIndex = pIndexView->GetBaseIndex();
2076 if ((pIndex->GetChildCount() > __indexCountMax) && (pIndex->GetIndexType() != FAST_SCROLL_INDEX_TYPE_OMISSION))
2078 r = pIndex->SetOmissionIndex(__indexCountMax);
2079 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set omiited index.");
2082 r = pIndexView->UpdateIndex(true);
2083 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the index view.");
2086 // update the base index of the popup view
2089 r = __pPopupView->UpdateIndex();
2090 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the popup view.");
2097 _FastScrollPresenter::EnableFadeEffect(bool enable)
2099 __enableFadeEffect = enable;
2103 _FastScrollPresenter::IsEnabledFadeEffect(void) const
2105 return __enableFadeEffect;
2109 _FastScrollPresenter::IsOnFadeEffect(void) const
2111 return (__fadeIn || __fadeOut);
2115 _FastScrollPresenter::IsScrollVisible(void) const
2117 return (__fadeIn || __fadeOut || __scrollVisibility);
2121 _FastScrollPresenter::SetScrollVisibility(bool visibility)
2123 result r = E_SUCCESS;
2125 if (GetScrollVisibility() == visibility)
2127 // keep up current visibility.
2131 if (__pViewConfig->__ignoreTouchEvent && visibility == false)
2136 if (visibility == false && __pSelectedIndex != null)
2141 __pCtrlVe->RemoveAllAnimations();
2144 if (__enableFadeEffect)
2149 __pCtrlVe->SetImplicitAnimationEnabled(true);
2152 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON);
2154 if (__enableFadeEffect)
2156 __pCtrlVe->SetImplicitAnimationEnabled(false);
2166 if (__enableFadeEffect)
2171 __pCtrlVe->SetImplicitAnimationEnabled(true);
2174 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
2176 if (__enableFadeEffect)
2178 __pCtrlVe->SetImplicitAnimationEnabled(false);
2187 __scrollVisibility = visibility;
2193 _FastScrollPresenter::GetScrollVisibility(void) const
2195 float opacity = __pCtrlVe->GetOpacity();
2197 if (__enableFadeEffect)
2199 if (__scrollVisibility)
2204 else if (opacity > FASTSCROLL_OPACITY_OFF)
2213 _FastScrollPresenter::CancelFadeEffect(void)
2218 __scrollVisibility = false;
2219 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
2224 __scrollVisibility = true;
2225 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON);
2230 _FastScrollPresenter::AddFastScrollEventListener(const Controls::_IUiFastScrollListener& listener)
2232 result r = E_SUCCESS;
2234 if (__pFastScrollEvent == null)
2236 __pFastScrollEvent = new (std::nothrow) _UiFastScrollEvent();
2237 SysTryReturnVoidResult(NID_UI_CTRL, __pFastScrollEvent, E_OUT_OF_MEMORY,
2238 "[E_OUT_OF_MEMORY] Memory allocation failed.");
2240 r = __pFastScrollEvent->Construct(__fastScroll);
2241 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2244 r = __pFastScrollEvent->AddListener(listener);
2245 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2249 _FastScrollPresenter::RemoveFastScrollEventListener(const Controls::_IUiFastScrollListener& listener)
2251 result r = E_SUCCESS;
2253 SysTryReturnVoidResult(NID_UI_CTRL, __pFastScrollEvent, E_INVALID_STATE, "[E_INVALID_STATE] __pFastScrollEvent must not be null.");
2255 r = __pFastScrollEvent->RemoveListener(listener);
2256 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2260 _FastScrollPresenter::AddAccessibilityElement(const _AccessibilityContainer& control, bool onAccessibility)
2262 _FastScrollIndexView* pIndexView = GetIndexView(0);
2263 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get fastscroll indexview.",
2264 GetErrorMessage(GetLastResult()));
2266 _AccessibilityContainer* pAccessibilityContainer = const_cast <_AccessibilityContainer*>(&control);
2267 result r = pAccessibilityContainer->RemoveAllElement();
2268 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove accessibility elements.");
2269 _AccessibilityElement* pAccessibilityElement = null;
2271 if (onAccessibility)
2273 r = pIndexView->AddAccessibilityElement(control);
2274 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to Add accessibility element.");
2278 pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
2279 SysTryReturnResult(NID_UI_CTRL, pAccessibilityElement, E_OUT_OF_MEMORY, "Memory allocation failed.");
2281 pAccessibilityElement->SetBounds(pIndexView->GetIndexBounds());
2282 pAccessibilityElement->SetTrait(L"Fast scroll bar");
2283 pAccessibilityElement->SetName(L"FastScroll");
2284 pAccessibilityElement->SetHint(L"double tap to enter fast scroll mode");
2285 r = pAccessibilityContainer->AddElement(*pAccessibilityElement);
2286 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Add accessibility element.", GetErrorMessage(r));
2291 delete pAccessibilityElement;
2296 _FastScrollPresenter::OnParentBoundsChanged(void)
2298 RelayoutFastScrollChildren();
2302 _FastScrollPresenter::OnDraw(void)
2305 bool availableTextSize = (__fastScroll.GetBoundsF().height >= __pViewConfig->__popupTextSize);
2306 int indexViewCount = GetIndexViewCount();
2307 for (int i = 0; i < indexViewCount; i++)
2309 _FastScrollIndexView* pIndexView = GetIndexView(i);
2310 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2311 GetErrorMessage(GetLastResult()));
2313 result r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__indexTextSize);
2314 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r));
2315 pIndexView->OnDraw();
2317 // draw the popup view
2318 if (__pPopupView && i <= __focusedIndexLevel)
2320 if (availableTextSize)
2322 r = SetFontInfo(FONT_STYLE_PLAIN, __pViewConfig->__popupTextSize);
2324 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set font.", GetErrorMessage(r));
2325 __pPopupView->OnDraw(i, pIndexView->GetBaseIndex(), pIndexView->GetSelectedIndexInOmittedIndex());
2331 __pPopupView->SetPopupVeUpdateNeeded(false);
2336 _FastScrollPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
2338 FloatPoint touchedPosition = touchinfo.GetCurrentPosition();
2339 __pViewConfig->__ignoreTouchEvent = false;
2340 return OnTouchPressedAndMoved(touchedPosition, true);
2344 _FastScrollPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
2346 return OnTouchReleasedAndCanceled();
2350 _FastScrollPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
2352 FloatPoint touchedPosition = touchinfo.GetCurrentPosition();
2353 return OnTouchPressedAndMoved(touchedPosition, false);
2357 _FastScrollPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
2359 return OnTouchReleasedAndCanceled();
2363 _FastScrollPresenter::OnAncestorVisibleStateChanged(const _Control& control)
2365 OnTouchReleasedAndCanceled();
2369 _FastScrollPresenter::OnAncestorEnableStateChanged(const _Control& control)
2371 OnTouchReleasedAndCanceled();
2375 _FastScrollPresenter::OnAncestorInputEnableStateChanged(const _Control& control)
2377 OnTouchReleasedAndCanceled();
2381 _FastScrollPresenter::OnFontChanged(Font* pFont)
2383 __pViewConfig->__pFont = pFont;
2387 _FastScrollPresenter::OnFontInfoRequested(unsigned long& style, float& size)
2389 style = __fontStyle;
2394 _FastScrollPresenter::SetFontInfo(unsigned long style, float size)
2396 __fontStyle = style;
2399 __pViewConfig->__pFont = __fastScroll.GetFallbackFont();
2400 SysTryReturnResult(NID_UI_CTRL, __pViewConfig->__pFont, GetLastResult(), "Failed to get a font.");
2405 VisualElementAnimation*
2406 _FastScrollPresenter::CreateAnimationForProperty(VisualElement& target, const String& property)
2408 VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
2412 const IVisualElementAnimationTimingFunction* pTimingFunction = VisualElementAnimation::GetTimingFunctionByName("EaseInOut");
2413 if (pTimingFunction)
2415 pAnimation->SetTimingFunction(pTimingFunction);
2417 pAnimation->SetVisualElementAnimationStatusEventListener(this);
2423 _FastScrollPresenter::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
2428 _FastScrollPresenter::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
2433 _FastScrollPresenter::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
2435 if (__pCtrlVe == (static_cast <_VisualElement*>(&target)))
2443 _FastScrollPresenter::HitTest(const Tizen::Graphics::FloatPoint& point)
2445 if (IsScrollVisible() == false)
2447 return HIT_TEST_NOWHERE;
2450 int indexViewCount = GetIndexViewCount();
2451 for (int i = 0; i < indexViewCount; i++)
2453 _FastScrollIndexView* pIndexView = GetIndexView(i);
2454 SysTryReturn(NID_UI_CTRL, pIndexView, HIT_TEST_NOWHERE, GetLastResult(), "[%s] Failed to get the index view.",
2455 GetErrorMessage(GetLastResult()));
2457 FloatRectangle indexBounds = pIndexView->GetIndexBoundsF();
2458 if (indexBounds.Contains(point) == true)
2460 return HIT_TEST_MATCH;
2464 return HIT_TEST_NOWHERE;
2468 _FastScrollPresenter::OnIndexDataUpdated(_FastScrollIndex& updatedIndex)
2470 result r = E_SUCCESS;
2472 int indexViewCount = GetIndexViewCount();
2473 for (int i = 0; i < indexViewCount; i++)
2475 _FastScrollIndexView* pIndexView = GetIndexView(i);
2476 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2477 GetErrorMessage(GetLastResult()));
2479 if (pIndexView->GetBaseIndex() == &updatedIndex)
2481 r = pIndexView->UpdateIndex(false);
2482 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2486 r = __pPopupView->UpdateIndex();
2487 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update the popup view.", GetErrorMessage(r));
2495 _FastScrollPresenter::OnIndexDeleted(_FastScrollIndex& deletedIndex)
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() == &deletedIndex)
2508 // first of all, update the base index view
2511 _FastScrollIndexView* pBaseIndexView = GetIndexView(i - 1);
2512 SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2513 GetErrorMessage(GetLastResult()));
2515 r = pBaseIndexView->UpdateIndex(false);
2516 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2519 // then remove the index view for detached index.
2520 RemoveIndexView(i, true);
2522 delete __pPopupView;
2523 __pPopupView = null;
2527 else if (pIndexView->GetBaseIndex() == deletedIndex.GetParentIndex())
2529 r = pIndexView->UpdateIndex(false);
2530 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2532 r = __pPopupView->UpdateIndex();
2533 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r));
2539 _FastScrollPresenter::OnChildIndexAttached(_FastScrollIndex& parentIndex, int attachedOrder, _FastScrollIndex& attachedIndex)
2541 result r = E_SUCCESS;
2543 int indexViewCount = GetIndexViewCount();
2544 for (int i = 0; i < indexViewCount; i++)
2546 _FastScrollIndexView* pIndexView = GetIndexView(i);
2547 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2548 GetErrorMessage(GetLastResult()));
2550 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::OnChildIndexDetached(_FastScrollIndex& parentIndex, int detachedOrder, _FastScrollIndex& detachedIndex)
2565 result r = E_SUCCESS;
2567 int indexViewCount = GetIndexViewCount();
2568 for (int i = 0; i < indexViewCount; i++)
2570 _FastScrollIndexView* pIndexView = GetIndexView(i);
2571 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2572 GetErrorMessage(GetLastResult()));
2574 if (pIndexView->GetBaseIndex() == &detachedIndex)
2576 // first of all, update the base index view
2579 _FastScrollIndexView* pBaseIndexView = GetIndexView(i - 1);
2580 SysTryReturnVoidResult(NID_UI_CTRL, pBaseIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2581 GetErrorMessage(GetLastResult()));
2583 r = pBaseIndexView->UpdateIndex(false);
2584 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2587 // then remove the index view for detached index.
2588 RemoveIndexView(i, true);
2590 delete __pPopupView;
2591 __pPopupView = null;
2594 else if (pIndexView->GetBaseIndex() == &parentIndex)
2596 r = pIndexView->UpdateIndex(false);
2597 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2599 r = __pPopupView->UpdateIndex();
2600 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update popup view.", GetErrorMessage(r));
2607 _FastScrollPresenter::Construct(void)
2609 result r = E_SUCCESS;
2611 // load color/shape configuration and bitmap resources
2612 __pViewConfig = _FastScrollViewConfig::CreateFastScrollViewConfigN(_CONTROL_ORIENTATION_PORTRAIT);
2613 SysTryReturnResult(NID_UI_CTRL, __pViewConfig, GetLastResult(), "Failed to create _FastScrollViewConfig.");
2615 // create _FastScrollModel
2616 __pFastScrollModel = _FastScrollModel::CreateFastScrollModelN();
2617 SysTryCatch(NID_UI_CTRL, __pFastScrollModel, , GetLastResult(), "[%s] Failed to create _FastScrollModel.",
2618 GetErrorMessage(GetLastResult()));
2620 // initialize visual elements
2621 __pCtrlVe = __fastScroll.GetVisualElement();
2622 SysTryCatch(NID_UI_CTRL, __pCtrlVe, , GetLastResult(), "[%s] Failed to get VisualElement of the _FastScroll",
2623 GetErrorMessage(GetLastResult()));
2625 __pCtrlVe->SetAnimationProvider(this);
2626 __pCtrlVe->SetClipChildrenEnabled(false);
2628 if (__scrollVisibility)
2630 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_ON);
2634 __pCtrlVe->SetOpacity(FASTSCROLL_OPACITY_OFF);
2637 // initialize the fastscroll control
2638 r = __fastScroll.SetBounds(CalculateFastScrollBounds(0));
2639 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to set the bounds of _FastScroll", GetErrorMessage(r));
2641 __fastScroll.SetBackgroundColor(Tizen::Graphics::Color(0, 0, 0, 0));
2643 __indexCountMax = _CoordinateSystemUtils::ConvertToInteger((__fastScroll.GetBoundsF().height -
2644 (__pViewConfig->__indexMarginTop * 2.0f)) / __pViewConfig->__indexSizeMin.height);
2649 delete __pFastScrollModel;
2650 __pFastScrollModel = null;
2652 delete __pViewConfig;
2653 __pViewConfig = null;
2655 return GetLastResult();
2659 _FastScrollPresenter::CalculateFastScrollBounds(int indexCount)
2661 FloatRectangle fastScrollBounds(0.0f, 0.0f, 0.0f, 0.0f);
2662 FloatRectangle parentBounds = __parentCtrl.GetBoundsF();
2663 fastScrollBounds.width = parentBounds.width;
2664 fastScrollBounds.height = parentBounds.height;
2665 return fastScrollBounds;
2669 _FastScrollPresenter::CalculateIndexBounds(int indexLevel, _FastScrollIndex& pIndex)
2671 FloatRectangle fastScrollBounds = __fastScroll.GetBoundsF();
2672 FloatRectangle indexBounds(0.0f, 0.0f, __pViewConfig->__indexSizeMin.width, fastScrollBounds.height);
2674 indexBounds.x = fastScrollBounds.width - __pViewConfig->__indexSizeMin.width;
2675 for (int i = 1; i <= indexLevel; i++)
2677 indexBounds.x -= __pViewConfig->__indexGap + __pViewConfig->__indexSizeMin.width;
2680 if (indexBounds.x < 0.0f)
2682 indexBounds.x = 0.0f;
2685 if (indexLevel != 0)
2687 int childCount = pIndex.GetChildCount();
2688 indexBounds.height = (childCount * __pViewConfig->__indexSizeMin.height) + (__pViewConfig->__indexMarginTop * 2.0f);
2690 if (indexBounds.height < fastScrollBounds.height)
2692 _FastScrollIndexView* pParentIndexView = GetIndexView(indexLevel - 1);
2693 if (pParentIndexView)
2695 FloatRectangle parentBounds = pParentIndexView->GetIndexBoundsF();
2697 indexBounds.y = parentBounds.y + (pIndex.GetIndexOrder() * pParentIndexView->GetIndexHeight()) - __pViewConfig->__indexMarginTop;
2698 if (indexBounds.y < fastScrollBounds.y)
2700 indexBounds.y = fastScrollBounds.y;
2703 float totalHeight = indexBounds.y + indexBounds.height;
2704 if (_FloatCompare(totalHeight, fastScrollBounds.height) || (totalHeight > fastScrollBounds.height))
2706 indexBounds.y = fastScrollBounds.height - indexBounds.height;
2712 indexBounds.height = fastScrollBounds.height;
2720 _FastScrollPresenter::CalculatePopupBounds(void)
2722 FloatRectangle popupBounds(0.0f, 0.0f, 0.0f, 0.0f);
2723 FloatRectangle parentBounds = __parentCtrl.GetBoundsF();
2724 FloatRectangle fastScrollBounds = __fastScroll.GetBoundsF();
2726 popupBounds.width = __pViewConfig->__popupSize.width + (__pViewConfig->__popupWidthIncrement * __focusedIndexLevel);
2727 if (popupBounds.width > parentBounds.width)
2729 popupBounds.width = parentBounds.width;
2732 popupBounds.height = __pViewConfig->__popupSize.height;
2733 if (popupBounds.height > parentBounds.height)
2735 popupBounds.height = parentBounds.height;
2738 popupBounds.x = ((parentBounds.width - popupBounds.width) / 2.0f) - fastScrollBounds.x;
2739 if (popupBounds.x < 0.0f)
2741 popupBounds.x = 0.0f;
2744 popupBounds.y = ((parentBounds.height - popupBounds.height) / 2.0f) - fastScrollBounds.y;
2745 if (popupBounds.y < 0.0f)
2747 popupBounds.y = 0.0f;
2754 _FastScrollPresenter::RelayoutFastScrollChildren(void)
2756 result r = E_SUCCESS;
2758 int indexViewCount = GetIndexViewCount();
2760 // initialize the fastscroll control
2761 r = __fastScroll.SetBounds(CalculateFastScrollBounds(indexViewCount));
2762 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set the bounds of _FastScroll", GetErrorMessage(r));
2764 __indexCountMax = _CoordinateSystemUtils::ConvertToInteger((__fastScroll.GetBoundsF().height -
2765 (__pViewConfig->__indexMarginTop * 2.0f)) / __pViewConfig->__indexSizeMin.height);
2767 for (int i = 0; i < indexViewCount; i++)
2769 _FastScrollIndexView* pIndexView = GetIndexView(i);
2770 SysTryReturnVoidResult(NID_UI_CTRL, pIndexView, GetLastResult(), "[%s] Failed to get the index view.",
2771 GetErrorMessage(GetLastResult()));
2773 r = pIndexView->SetIndexBounds(CalculateIndexBounds(i, *(pIndexView->GetBaseIndex())));
2774 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set bounds of the index.", GetErrorMessage(r));
2776 _FastScrollIndex* pIndex = pIndexView->GetBaseIndex();
2777 if (pIndex->GetIndexType() == FAST_SCROLL_INDEX_TYPE_OMISSION)
2779 _FastScrollIndex* pSelectedIndex = pIndexView->GetSelectedIndex();
2780 if (pSelectedIndex && pSelectedIndex->GetOmitted())
2782 pIndexView->SetSelectedIndex(null);
2784 r = pIndex->RemoveOmissionChildren(false);
2785 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to remove omission index view", GetErrorMessage(r));
2788 if (pIndex->GetChildCount() > __indexCountMax)
2790 r = pIndex->SetOmissionIndex(__indexCountMax);
2791 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set omission index.", GetErrorMessage(r));
2794 r = pIndexView->UpdateIndex(false);
2795 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to update index view.", GetErrorMessage(r));
2800 r = __pPopupView->SetPopupBounds(CalculatePopupBounds());
2801 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Failed to set bounds of the popup view.", GetErrorMessage(r));
2806 _FastScrollPresenter::SelectOnIndexViews(const FloatPoint& point, bool isPressed)
2808 result r = E_SUCCESS;
2810 _FastScrollIndex* pSelectedIndex = null;
2811 int selectedIndexLevel = 0;
2812 int indexViewCount = GetIndexViewCount();
2813 SysTryReturn(NID_UI_CTRL, indexViewCount > 0, null, E_INVALID_STATE, "[E_INVALID_STATE] The root index view is invalid state.");
2815 // search the hit index on index views, then fade out other index views
2816 for (int i = 0; i < indexViewCount; i++)
2818 _FastScrollIndexView* pIndexView = GetIndexView(i);
2819 SysTryReturn(NID_UI_CTRL, pIndexView, null, GetLastResult(), "[%s] Failed to get the index view.",
2820 GetErrorMessage(GetLastResult()));
2822 _FastScrollIndex* pIndex = pIndexView->GetIndexAtPoint(point);
2825 // select the index of the index view.
2826 r = pIndexView->SelectIndex(pIndex, isPressed);
2827 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r));
2828 pSelectedIndex = pIndex;
2829 if (pIndex->GetOmitted() == true)
2831 pSelectedIndex = pIndexView->GetOmissionIndexAtPoint(pIndex, point);
2834 pIndexView->SetSelectedIndexInOmittedIndex(pSelectedIndex);
2836 selectedIndexLevel = i;
2841 // if can no find the index on views, select index of the last index view
2842 if ((pSelectedIndex == null) && (__focusedIndexLevel != -1))
2844 _FastScrollIndexView* pFocusedIndexView = GetIndexView(__focusedIndexLevel);
2845 SysTryReturn(NID_UI_CTRL, pFocusedIndexView, null, GetLastResult(), "[%s] Failed to get the index view.",
2846 GetErrorMessage(GetLastResult()));
2848 _FastScrollIndex* pIndex = pFocusedIndexView->GetIndexAtPoint(FloatPoint(pFocusedIndexView->GetIndexBoundsF().x, point.y));
2851 // select the index of the focused index view.
2852 r = pFocusedIndexView->SelectIndex(pIndex, isPressed);
2853 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r));
2854 pSelectedIndex = pIndex;
2856 if (pIndex->GetOmitted() == true)
2858 pSelectedIndex = pFocusedIndexView->GetOmissionIndexAtPoint(pIndex,
2859 FloatPoint(pFocusedIndexView->GetIndexBoundsF().x, point.y));
2860 if (pSelectedIndex == null)
2862 pSelectedIndex = pFocusedIndexView->GetSelectedIndexInOmittedIndex();
2865 pFocusedIndexView->SetSelectedIndexInOmittedIndex(pSelectedIndex);
2867 selectedIndexLevel = __focusedIndexLevel;
2871 pSelectedIndex = pFocusedIndexView->GetSelectedIndex();
2872 if (pSelectedIndex && pSelectedIndex->GetOmitted() == true)
2874 pSelectedIndex = pFocusedIndexView->GetSelectedIndexInOmittedIndex();
2876 selectedIndexLevel = __focusedIndexLevel;
2882 int childCount = pSelectedIndex->GetChildCount();
2883 if (childCount > 0 && (pSelectedIndex->GetOmitted() == false))
2885 _FastScrollIndexView* pSelectedIndexView = GetIndexView(selectedIndexLevel + 1);
2886 if (pSelectedIndexView)
2888 r = pSelectedIndexView->SelectIndex((_FastScrollIndex*)null, false);
2889 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to select the index.", GetErrorMessage(r));
2891 r = pSelectedIndexView->SetBaseIndex(pSelectedIndex);
2892 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set the base index of the index view.", GetErrorMessage(r));
2894 r = pSelectedIndexView->SetIndexBounds(CalculateIndexBounds(selectedIndexLevel + 1, *pSelectedIndex));
2895 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set bounds of the index.", GetErrorMessage(r));
2897 r = pSelectedIndexView->SetIndexVisibility(true);
2898 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set the visibility of the index view.", GetErrorMessage(r));
2900 indexViewCount = GetIndexViewCount();
2901 while (indexViewCount > selectedIndexLevel + 2)
2903 r = RemoveIndexView(indexViewCount - 1, true);
2904 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r));
2905 indexViewCount = GetIndexViewCount();
2910 r = AddIndexView(*pSelectedIndex);
2911 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to add new child index.", GetErrorMessage(r));
2914 if ((childCount > __indexCountMax) && (pSelectedIndex->GetIndexType() != FAST_SCROLL_INDEX_TYPE_OMISSION))
2916 r = pSelectedIndex->SetOmissionIndex(__indexCountMax);
2917 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to set omission index.", GetErrorMessage(r));
2922 indexViewCount = GetIndexViewCount();
2923 while (indexViewCount > selectedIndexLevel + 1)
2925 r = RemoveIndexView(indexViewCount - 1, true);
2926 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r));
2927 indexViewCount = GetIndexViewCount();
2933 indexViewCount = GetIndexViewCount();
2934 while (indexViewCount > 1)
2936 r = RemoveIndexView(indexViewCount - 1, true);
2937 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Failed to remove the index view.", GetErrorMessage(r));
2938 indexViewCount = GetIndexViewCount();
2942 __focusedIndexLevel = selectedIndexLevel;
2943 return pSelectedIndex;
2947 _FastScrollPresenter::DeselectIndexViews(void)
2949 result r = E_SUCCESS;
2951 while (GetIndexViewCount() > 1)
2953 RemoveIndexView(GetIndexViewCount() - 1, true);
2956 _FastScrollIndexView* pIndexView = GetIndexView(0);
2957 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
2959 r = pIndexView->SelectIndex((_FastScrollIndex*)null, true);
2960 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear the index selection.");
2961 pIndexView->SetSelectedIndexInOmittedIndex(null);
2963 __fastScroll.Invalidate();
2969 _FastScrollPresenter::SetPopupIndex(_FastScrollIndex& popupIndex, const FloatPoint& point)
2971 result r = E_SUCCESS;
2973 // set the selected node into the popup views.
2974 if (__pPopupView == null)
2976 __pPopupView = _FastScrollPopupView::CreateFastScrollPopupViewN(*__pCtrlVe, *__pViewConfig);
2977 SysTryReturnResult(NID_UI_CTRL, __pPopupView, GetLastResult(), "Propagating.");
2979 r = __pPopupView->SetPopupBounds(CalculatePopupBounds());
2980 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup view.");
2982 r = __pPopupView->SetPopupVisibility(true);
2983 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the popup view.");
2986 int indexViewCount = __focusedIndexLevel + 1;
2987 int popupIndexViewCount = __pPopupView->GetIndexVeCount();
2989 if (indexViewCount != popupIndexViewCount)
2991 r = __pPopupView->SetPopupBounds(CalculatePopupBounds());
2992 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup view.");
2994 if (indexViewCount > popupIndexViewCount)
2996 for (int i = popupIndexViewCount; i < indexViewCount; i++)
2998 r = __pPopupView->AddPopupIndexVe(i);
2999 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to add popup index ve.");
3002 else if (indexViewCount < popupIndexViewCount)
3004 for (int i = indexViewCount; i < popupIndexViewCount; i++)
3006 r = __pPopupView->RemovePopupIndexVe(i);
3007 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove popup index ve.");
3012 r = __pPopupView->UpdateIndex();
3013 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to update the popup view.");
3015 for (int i = 0; i < indexViewCount; i++)
3017 _FastScrollIndexView* pIndexView = GetIndexView(i);
3018 SysTryReturnResult(NID_UI_CTRL, pIndexView, r, "Failed to index view.");
3020 r = __pPopupView->SetPopupIndexBounds(i, pIndexView->GetBaseIndex());
3021 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the popup index ve.");
3023 _FastScrollIndex* pFormerIndex = null;
3024 if ( i == __focusedIndexLevel )
3026 pFormerIndex = pIndexView->GetFormerIndex();
3027 r = __pPopupView->SelectIndex(i, &popupIndex, pFormerIndex);
3028 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the popup index.");
3032 r = __pPopupView->SelectIndex(i, null, null);
3033 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to select the popup index.");
3041 _FastScrollPresenter::ClearPopupIndex(void)
3043 result r = E_SUCCESS;
3045 // clear the node data of the popup view
3048 r = __pPopupView->FadeOutAndDestroy();
3049 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to clear visibility of the popup view.");
3051 __pPopupView = null;
3058 _FastScrollPresenter::FireFastScrollEvent(_FastScrollIndex& selectedIndex)
3060 // fire the fast scroll event
3061 if (__pFastScrollEvent)
3063 String* pIndexNodeText = selectedIndex.GetIndexText();
3066 _UiFastScrollEventArg* pEventArg = new (std::nothrow) _UiFastScrollEventArg(*__pFastScrollEvent->GetSource(), selectedIndex);
3067 SysTryReturnResult(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, "Memory allocation failed.");
3069 __pFastScrollEvent->Fire(*pEventArg);
3077 _FastScrollPresenter::OnTouchPressedAndMoved(const FloatPoint& point, bool isPressed)
3079 result r = E_SUCCESS;
3080 if (__pViewConfig->__ignoreTouchEvent)
3085 if (__enableFadeEffect && __scrollVisibility == false)
3087 r = SetScrollVisibility(true);
3088 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to fade out fastscroll.", GetErrorMessage(r));
3091 _FastScrollIndex* pSelectedIndex = SelectOnIndexViews(point, isPressed);
3094 if (pSelectedIndex->GetNextIndexList() || pSelectedIndex->GetPreviousIndexList())
3096 _FastScrollIndexView* pIndexView = GetIndexView(__focusedIndexLevel);
3097 SysTryReturn(NID_UI_CTRL, pIndexView != null, true, r, "[%s] Propagating.", GetErrorMessage(r));
3099 _FastScrollIndex* pBaseIndex = pIndexView->GetBaseIndex();
3100 SysTryReturn(NID_UI_CTRL, pBaseIndex != null, true, r, "[%s] Propagating.", GetErrorMessage(r));
3103 if (pSelectedIndex->GetNextIndexList())
3105 pBaseIndex->SetCurrentIndexList(pSelectedIndex->GetNextIndexList());
3109 pBaseIndex->SetCurrentIndexList(pSelectedIndex->GetPreviousIndexList());
3113 if (pBaseIndex->GetIndexType() == FAST_SCROLL_INDEX_TYPE_OMISSION)
3115 r = pBaseIndex->RemoveOmissionChildren(false);
3116 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to remove omission index view", GetErrorMessage(r));
3119 __pViewConfig->__ignoreTouchEvent = true;
3120 OnTouchReleasedAndCanceled();
3122 pIndexView->SelectIndexList(isNext);
3124 if (__pSelectedIndex != pSelectedIndex)
3126 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, &__fastScroll);
3130 else if (__pSelectedIndex != pSelectedIndex)
3132 PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP, &__fastScroll);
3133 r = SetPopupIndex(*pSelectedIndex, point);
3134 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to set the popup index.", GetErrorMessage(r));
3136 r = FireFastScrollEvent(*pSelectedIndex);
3137 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to send the fast scroll event.", GetErrorMessage(r));
3138 __pSelectedIndex = pSelectedIndex;
3146 _FastScrollPresenter::OnTouchReleasedAndCanceled(void)
3148 result r = E_SUCCESS;
3150 r = DeselectIndexViews();
3151 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to deselect index views.", GetErrorMessage(r));
3153 r = ClearPopupIndex();
3154 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to clear the popup index.", GetErrorMessage(r));
3156 __pSelectedIndex = null;
3158 if (__enableFadeEffect && __pViewConfig->__ignoreTouchEvent == false && __scrollVisibility == true)
3160 r = SetScrollVisibility(false);
3161 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, true, r, "[%s] Failed to fade out fastscroll.", GetErrorMessage(r));
3168 _FastScrollPresenter::AddIndexView(_FastScrollIndex& baseIndex)
3170 return AddIndexView(GetIndexViewCount(), baseIndex);
3174 _FastScrollPresenter::AddIndexView(int indexLevel, _FastScrollIndex& baseIndex)
3176 result r = E_SUCCESS;
3178 _FastScrollIndexView* pNewIndexView = _FastScrollIndexView::CreateFastScrollIndexViewN( *__pCtrlVe, *__pViewConfig);
3179 SysTryReturnResult(NID_UI_CTRL, pNewIndexView, GetLastResult(), "Propagating.");
3181 r = __fastScroll.SetBounds(CalculateFastScrollBounds(GetIndexViewCount() + 1));
3182 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll.");
3184 r = pNewIndexView->SetIndexBounds(CalculateIndexBounds(indexLevel, baseIndex));
3185 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set bounds of the index view.");
3187 r = pNewIndexView->SetBaseIndex(&baseIndex);
3188 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the index data for the index view.");
3190 r = pNewIndexView->SetIndexVisibility(true);
3191 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set visibility of the index view.");
3193 r = __indexViews.InsertAt(*pNewIndexView, indexLevel);
3194 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to change the last index view.");
3200 _FastScrollPresenter::RemoveIndexView(int indexLevel, bool fadeout)
3202 result r = E_SUCCESS;
3204 int indexViewCount = GetIndexViewCount();
3205 if (indexLevel < indexViewCount)
3207 _FastScrollIndexView* pIndexView = GetIndexView(indexLevel);
3208 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
3212 r = pIndexView->FadeOutAndDestroy();
3213 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to request to fade out of the index view.");
3216 r = __indexViews.Remove(*pIndexView, false);
3217 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to remove the index views.");
3219 // initialize the fastscroll control
3220 r = __fastScroll.SetBounds(CalculateFastScrollBounds(GetIndexViewCount()));
3221 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll");
3228 _FastScrollPresenter::RemoveAllIndexViews(bool fadeout)
3230 result r = E_SUCCESS;
3234 int indexViewCount = GetIndexViewCount();
3235 for (int i = 0; i < indexViewCount; i++)
3237 _FastScrollIndexView* pIndexView = GetIndexView(i);
3238 SysTryReturnResult(NID_UI_CTRL, pIndexView, GetLastResult(), "Failed to get the index view.");
3240 r = pIndexView->FadeOutAndDestroy();
3241 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to request to fade out of the index view.");
3245 __indexViews.RemoveAll(true);
3247 // initialize the fastscroll control
3248 r = __fastScroll.SetBounds(CalculateFastScrollBounds(0));
3249 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to set the bounds of _FastScroll.");
3254 _FastScrollIndexView*
3255 _FastScrollPresenter::GetIndexView(int indexLevel) const
3257 Object* pIndexView = const_cast<Object*>(__indexViews.GetAt(indexLevel));
3258 SysTryReturn(NID_UI_CTRL, pIndexView, null, GetLastResult(), "[%s] Failed to get the index view.",
3259 GetErrorMessage(GetLastResult()));
3261 return dynamic_cast<_FastScrollIndexView*>(pIndexView);
3265 _FastScrollPresenter::GetIndexViewCount(void) const
3267 return __indexViews.GetCount();
3270 } } } // Tizen::Ui::Controls