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_FastScroll.cpp
20 * @brief This is the implementation file for the _FastScroll class.
23 #include <FBaseSysLog.h>
24 #include "FUiCtrl_FastScroll.h"
26 using namespace Tizen::Base;
27 using namespace Tizen::Graphics;
28 using namespace Tizen::Ui::Animations;
30 namespace Tizen { namespace Ui { namespace Controls
34 class _FastScrollAccessibilityListener
35 : public _IAccessibilityListener
38 _FastScrollAccessibilityListener(_FastScroll* pFastScroll)
39 : __pFastScroll(pFastScroll)
40 , __onAccessibility(false)
44 virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;}
45 virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;}
46 virtual bool OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;}
47 virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;}
48 virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;}
49 virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;}
50 virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;}
51 virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element){return true;}
52 virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
54 if (__onAccessibility)
56 __onAccessibility = false;
57 __pFastScroll->ReleaseTouchCapture();
61 __onAccessibility = true;
62 __pFastScroll->SetTouchCapture(true, false);
65 _AccessibilityContainer* pAccessibilityContainer = __pFastScroll->GetAccessibilityContainer();
66 __pFastScroll->AddAccessibilityElement(*pAccessibilityContainer, __onAccessibility);
71 _FastScroll* __pFastScroll;
72 bool __onAccessibility;
75 _FastScroll::_FastScroll(void)
77 , __pAccessibilityListener(null)
81 _FastScroll::~_FastScroll(void)
83 _AccessibilityContainer* pAccessibilityContainer = GetAccessibilityContainer();
84 if (pAccessibilityContainer && pAccessibilityContainer->IsActivated())
86 pAccessibilityContainer->RemoveAllElement();
92 delete __pAccessibilityListener;
93 __pAccessibilityListener = null;
97 _FastScroll::CreateFastScrollN(Tizen::Ui::_Control& parentCtrl)
102 _FastScroll* pFastScroll = new (std::nothrow) _FastScroll();
103 SysTryReturn(NID_UI_CTRL, pFastScroll, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
105 r = pFastScroll->Construct(parentCtrl);
106 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
116 _FastScroll::SetIndex(_FastScrollIndex* pIndex)
118 return GetPresenter().SetRootIndex(pIndex);
122 _FastScroll::GetIndex(void) const
124 return GetPresenter().GetRootIndex();
128 _FastScroll::UpdateIndex(void)
130 _AccessibilityContainer* pAccessibilityContainer = GetAccessibilityContainer();
131 if (pAccessibilityContainer && pAccessibilityContainer->IsActivated())
133 GetPresenter().AddAccessibilityElement(*pAccessibilityContainer, false);
135 return GetPresenter().UpdateIndex();
139 _FastScroll::EnableFadeEffect(bool enable)
141 GetPresenter().EnableFadeEffect(enable);
145 _FastScroll::IsEnabledFadeEffect(void) const
147 return GetPresenter().IsEnabledFadeEffect();
151 _FastScroll::IsOnFadeEffect(void) const
153 return GetPresenter().IsOnFadeEffect();
157 _FastScroll::SetScrollVisibility(bool visibility)
159 return GetPresenter().SetScrollVisibility(visibility);
163 _FastScroll::GetScrollVisibility(void) const
165 return GetPresenter().GetScrollVisibility();
169 _FastScroll::CancelFadeEffect(void)
171 GetPresenter().CancelFadeEffect();
175 _FastScroll::InitializeAccessibility(void)
177 if (unlikely(!(_AccessibilityManager::IsActivated())))
182 _AccessibilityContainer* pAccessibilityContainer = GetAccessibilityContainer();
183 if (pAccessibilityContainer)
185 pAccessibilityContainer->Activate(true);
186 __pAccessibilityListener = new (std::nothrow) _FastScrollAccessibilityListener(this);
187 SysTryReturnResult(NID_UI_CTRL, __pAccessibilityListener, E_OUT_OF_MEMORY, "Memory allocation failed.");
189 pAccessibilityContainer->AddListener(*__pAccessibilityListener);
195 _FastScroll::AddAccessibilityElement(const _AccessibilityContainer& control, bool onAccessibility)
197 return GetPresenter().AddAccessibilityElement(control, onAccessibility);
201 _FastScroll::AddFastScrollEventListener(const Tizen::Ui::Controls::_IUiFastScrollListener& listener)
203 GetPresenter().AddFastScrollEventListener(listener);
207 _FastScroll::RemoveFastScrollEventListener(const Tizen::Ui::Controls::_IUiFastScrollListener& listener)
209 GetPresenter().RemoveFastScrollEventListener(listener);
213 _FastScroll::OnAttachedToMainTree(void)
215 return InitializeAccessibility();
219 _FastScroll::OnParentBoundsChanged(void)
221 GetPresenter().OnParentBoundsChanged();
225 _FastScroll::OnDraw(void)
227 GetPresenter().OnDraw();
231 _FastScroll::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
233 return GetPresenter().OnTouchPressed(source, touchinfo);
237 _FastScroll::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
239 return GetPresenter().OnTouchReleased(source, touchinfo);
243 _FastScroll::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
245 return GetPresenter().OnTouchMoved(source, touchinfo);
249 _FastScroll::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
251 return GetPresenter().OnTouchCanceled(source, touchinfo);
255 _FastScroll::OnAncestorVisibleStateChanged(const _Control& control)
257 GetPresenter().OnAncestorVisibleStateChanged(control);
261 _FastScroll::OnAncestorEnableStateChanged(const _Control& control)
263 GetPresenter().OnAncestorEnableStateChanged(control);
267 _FastScroll::OnAncestorInputEnableStateChanged(const _Control& control)
269 GetPresenter().OnAncestorInputEnableStateChanged(control);
273 _FastScroll::OnFontChanged(Font* pFont)
275 GetPresenter().OnFontChanged(pFont);
279 _FastScroll::OnFontInfoRequested(unsigned long& style, float& size)
281 GetPresenter().OnFontInfoRequested(style, size);
285 _FastScroll::HitTest(const Tizen::Graphics::FloatPoint& point)
287 return GetPresenter().HitTest(point);
291 _FastScroll::Construct(Tizen::Ui::_Control& parentCtrl)
293 _FastScrollPresenter* pPresenter = _FastScrollPresenter::CreateFastScrollPresenterN(parentCtrl, *this);
294 SysTryReturnResult(NID_UI_CTRL, pPresenter, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
296 SetPresenter(*pPresenter);
304 _FastScroll::SetPresenter(_FastScrollPresenter& fastScrollPresenter)
306 __pPresenter = &fastScrollPresenter;
309 _FastScrollPresenter&
310 _FastScroll::GetPresenter(void) const
312 return *__pPresenter;
315 } } } // Tizen::Ui::Controls