controls/FUiCtrl_ListViewItem.cpp
controls/FUiCtrl_ListViewItemProviderAdaptor.cpp
controls/FUiCtrl_ListViewModel.cpp
- controls/FUiCtrl_ListViewTouchEventHandler.cpp
controls/FUiCtrl_SimpleItemImpl.cpp
controls/FUiCtrl_UiListViewItemEvent.cpp
controls/FUiCtrl_UiListViewItemEventArg.cpp
#include <FApp_AppInfo.h>
#include <FGrp_TextTextSimple.h>
#include "FUi_CoordinateSystemUtils.h"
+#include "FUi_ITouchLongPressGestureEventListener.h"
#include "FUi_Math.h"
#include "FUi_ResourceManager.h"
+#include "FUi_TouchEventArg.h"
+#include "FUi_TouchLongPressGestureDetector.h"
+#include "FUi_TouchManager.h"
#include "FUi_UiBuilder.h"
#include "FUiCtrl_FastScrollEvent.h"
#include "FUiCtrl_FastScrollEventArg.h"
#include "FUiCtrl_ScrollEventArg.h"
using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Utility;
using namespace Tizen::Graphics;
using namespace Tizen::Graphics::_Text;
namespace Tizen { namespace Ui { namespace Controls
{
+class _GroupedListViewImpl::_GroupedListViewPropagatedTouchEventListener
+ : public Tizen::Ui::_IPropagatedTouchEventListener
+ , public Tizen::Ui::_ITouchLongPressGestureEventListener
+{
+public:
+
+ _GroupedListViewPropagatedTouchEventListener(_GroupedListViewImpl& impl)
+ : __impl(impl)
+ , __core(impl.GetCore())
+ , __public(impl.GetPublic())
+ , __oldPreviousPressedTime(0)
+ , __previousPressedTime(0)
+ , __currentPressedTime(0)
+ , __previousPressedPoint(0.0f, 0.0f)
+ , __currentPressedPoint(0.0f, 0.0f)
+ , __pLongPressedGesture(null)
+ {
+ __pTouchManager = _TouchManager::GetInstance();
+ SysTryReturnVoidResult(NID_UI, (__pTouchManager != null), E_SYSTEM, "[E_SYSTEM] System error occurred.");
+
+ // Add _TouchLongPressGestureDetector
+ __pLongPressedGesture = new (std::nothrow) _TouchLongPressGestureDetector();
+ SysTryReturnVoidResult(NID_UI_CTRL, (__pLongPressedGesture != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ __core.AddGestureDetector(*__pLongPressedGesture);
+ __pLongPressedGesture->AddGestureListener(*this);
+ }
+
+ virtual ~_GroupedListViewPropagatedTouchEventListener(void)
+ {
+ if (__pLongPressedGesture != null)
+ {
+ __pLongPressedGesture->RemoveGestureListener(*this);
+ __core.RemoveGestureDetector(*__pLongPressedGesture);
+
+ delete __pLongPressedGesture;
+ __pLongPressedGesture = null;
+ }
+ }
+
+ virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ return __impl.CallOnTouchPressed(source, touchInfo);
+ }
+
+ virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ return __impl.CallOnTouchReleased(source, touchInfo);
+ }
+
+ virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ return __impl.CallOnTouchMoved(source, touchInfo);
+ }
+
+ virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ return __impl.CallOnTouchCanceled(source, touchInfo);
+ }
+
+ virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ _UiTouchEventDelivery isFiltered = _UI_TOUCH_EVENT_DELIVERY_NO;
+ IPropagatedTouchEventListener* pListener = __impl.GetPublicPropagatedTouchEventListener();
+
+ if (pListener != null)
+ {
+ Control& control = __impl.GetPublic();
+
+ TouchEventInfo publicTouchInfo;
+
+ _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
+ SysTryReturn(NID_UI, pEventArg, _UI_TOUCH_EVENT_DELIVERY_YES, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
+
+ publicTouchInfo.Construct(*pEventArg);
+
+ if (pEventArg)
+ {
+ delete pEventArg;
+ pEventArg = null;
+ }
+
+ if (pListener->OnTouchPressed(control, publicTouchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+ }
+
+ // public TouchEventListener
+ if (ProcessTouchEventListener(touchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ isFiltered = __impl.OnPreviewTouchPressed(__impl, touchInfo);
+ if (isFiltered == _UI_TOUCH_EVENT_DELIVERY_NO)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ isFiltered = __core.OnPreviewTouchPressed(source, touchInfo);
+
+ return isFiltered;
+ }
+
+ virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ _UiTouchEventDelivery isFiltered = _UI_TOUCH_EVENT_DELIVERY_NO;
+ IPropagatedTouchEventListener* pListener = __impl.GetPublicPropagatedTouchEventListener();
+
+ if (pListener != null)
+ {
+ Control& control = __impl.GetPublic();
+
+ TouchEventInfo publicTouchInfo;
+
+ _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
+ SysTryReturn(NID_UI, pEventArg, _UI_TOUCH_EVENT_DELIVERY_YES, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
+
+ publicTouchInfo.Construct(*pEventArg);
+
+ if (pEventArg)
+ {
+ delete pEventArg;
+ pEventArg = null;
+ }
+
+ if (pListener->OnTouchReleased(control, publicTouchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+ }
+
+ // public TouchEventListener
+ if (ProcessTouchEventListener(touchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ isFiltered = __impl.OnPreviewTouchReleased(__impl, touchInfo);
+ if (isFiltered == _UI_TOUCH_EVENT_DELIVERY_NO)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ isFiltered = __core.OnPreviewTouchReleased(source, touchInfo);
+
+ return isFiltered;
+ }
+
+ virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ _UiTouchEventDelivery isFiltered = _UI_TOUCH_EVENT_DELIVERY_NO;
+ IPropagatedTouchEventListener* pListener = __impl.GetPublicPropagatedTouchEventListener();
+
+ if (pListener != null)
+ {
+ Control& control = __impl.GetPublic();
+
+ TouchEventInfo publicTouchInfo;
+
+ _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
+ SysTryReturn(NID_UI, pEventArg, _UI_TOUCH_EVENT_DELIVERY_YES, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
+
+ publicTouchInfo.Construct(*pEventArg);
+
+ if (pEventArg)
+ {
+ delete pEventArg;
+ pEventArg = null;
+ }
+
+ if (pListener->OnTouchMoved(control, publicTouchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+ }
+
+ // public TouchEventListener
+ if (ProcessTouchEventListener(touchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ isFiltered = __impl.OnPreviewTouchMoved(__impl, touchInfo);
+ if (isFiltered == _UI_TOUCH_EVENT_DELIVERY_NO)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ isFiltered = __core.OnPreviewTouchMoved(source, touchInfo);
+
+ return isFiltered;
+ }
+
+ virtual _UiTouchEventDelivery OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ IPropagatedTouchEventListener* pListener = __impl.GetPublicPropagatedTouchEventListener();
+
+ if (pListener != null)
+ {
+ Control& control = __impl.GetPublic();
+
+ TouchEventInfo publicTouchInfo;
+
+ _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
+ SysTryReturn(NID_UI, pEventArg, _UI_TOUCH_EVENT_DELIVERY_YES, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
+
+ publicTouchInfo.Construct(*pEventArg);
+
+ if (pEventArg)
+ {
+ delete pEventArg;
+ pEventArg = null;
+ }
+
+ if (pListener->OnTouchCanceled(control, publicTouchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+ }
+
+ // public TouchEventListener
+ if (ProcessTouchEventListener(touchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ return _UI_TOUCH_EVENT_DELIVERY_YES;
+ }
+
+ virtual void OnTouchPressHandled(const _Control& source)
+ {
+ __impl.OnTouchPressHandled(source);
+ }
+
+ virtual void OnTouchReleaseHandled(const _Control& source)
+ {
+ __impl.OnTouchReleaseHandled(source);
+ }
+
+ virtual void OnTouchMoveHandled(const _Control& source)
+ {
+ __impl.OnTouchMoveHandled(source);
+ }
+
+ virtual void OnTouchCancelHandled(const _Control& source)
+ {
+ __impl.OnTouchCancelHandled(source);
+ }
+
+ bool OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
+ {
+ bool filtered = ProcessTouchEventListener();
+
+ if (!filtered)
+ {
+ __impl.FireListViewItemLongPressedEvent();
+ }
+
+ return filtered;
+ }
+
+ bool OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
+ {
+ return false;
+ }
+
+private:
+
+ bool ProcessTouchEventListener(const _TouchInfo& touchInfo)
+ {
+ bool filtered = false;
+
+ if (touchInfo.GetTouchStatus() == _TOUCH_PRESSED)
+ {
+ filtered = ProcessTouchDoublePressed(touchInfo);
+ }
+
+ if (!filtered)
+ {
+ ProcessTouchEvent(touchInfo);
+ }
+
+ filtered = __impl.IsInputEventConsumed();
+
+ if (filtered)
+ {
+ __impl.ResetInputEventConsumed();
+ }
+
+ return filtered;
+ }
+
+ bool ProcessTouchEventListener(void)
+ {
+ // for TouchLongPressed
+ _TouchInfo touchInfo(0, _TOUCH_LONG_PRESSED, __currentPressedPoint, false, 0);
+
+ return ProcessTouchEventListener(touchInfo);
+ }
+
+ void ProcessTouchEvent(const _TouchInfo& touchInfo)
+ {
+ TouchEventInfo publicTouchInfo;
+
+ _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
+ SysTryReturnVoidResult(NID_UI, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ publicTouchInfo.Construct(*pEventArg);
+
+ _Control* pDraggedControl = __pTouchManager->GetTouchControlSource();
+
+ IEnumeratorT<IEventListener*>* pEnumerator = __impl.GetTouchEventListener()->GetEnumeratorN();
+ if (pEnumerator)
+ {
+ while (pEnumerator->MoveNext() == E_SUCCESS)
+ {
+ IEventListener* pListener = null;
+ pEnumerator->GetCurrent(pListener);
+
+ ITouchEventListener* pTouchEventListener = dynamic_cast <ITouchEventListener*>(pListener);
+ if (pTouchEventListener != null)
+ {
+ FirePublicListener(*pTouchEventListener, publicTouchInfo);
+
+ if (touchInfo.GetTouchStatus() == _TOUCH_RELEASED)
+ {
+ if (pDraggedControl == null) //if exist dragged control, don't send focus event
+ {
+ FireFocusListener(*pTouchEventListener, publicTouchInfo);
+ }
+ }
+ else if (touchInfo.GetTouchStatus() == _TOUCH_MOVED)
+ {
+ FireFocusListener(*pTouchEventListener, publicTouchInfo);
+ }
+ }
+ }
+
+ delete pEnumerator;
+ }
+
+ delete pEventArg;
+ }
+
+ bool ProcessTouchDoublePressed(const _TouchInfo& touchinfo)
+ {
+ if (__pTouchManager->GetPointCount() == 1)
+ {
+ __oldPreviousPressedTime = __previousPressedTime;
+ __previousPressedTime = __currentPressedTime;
+ __currentPressedTime = touchinfo.GetTimeStamp();
+ __previousPressedPoint.x = __currentPressedPoint.x;
+ __previousPressedPoint.y = __currentPressedPoint.y;
+ __currentPressedPoint.x = touchinfo.GetCurrentPosition().x;
+ __currentPressedPoint.y = touchinfo.GetCurrentPosition().y;
+
+ if (Math::Abs(__previousPressedTime - __currentPressedTime) < DOUBLE_PRESS_TIME)
+ {
+ if (Math::Abs(__previousPressedTime - __oldPreviousPressedTime) > DOUBLE_PRESS_TIME)
+ {
+ if ((Math::Abs(__previousPressedPoint.x - __currentPressedPoint.x) < DOUBLE_PRESS_MOVE_ALLOWANCE)
+ && (Math::Abs(__previousPressedPoint.y - __currentPressedPoint.y) < DOUBLE_PRESS_MOVE_ALLOWANCE))
+ {
+ _TouchInfo touchInfo(0, _TOUCH_DOUBLE_PRESSED, __currentPressedPoint, false, 0);
+ ProcessTouchEvent(touchInfo);
+
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ void FirePublicListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo)
+ {
+ switch (touchEventInfo.GetTouchStatus())
+ {
+ case TOUCH_PRESSED:
+ listener.OnTouchPressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_LONG_PRESSED:
+ listener.OnTouchLongPressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_RELEASED:
+ listener.OnTouchReleased(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_MOVED:
+ listener.OnTouchMoved(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_DOUBLE_PRESSED:
+ listener.OnTouchDoublePressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_FOCUS_IN:
+ listener.OnTouchFocusIn(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_FOCUS_OUT:
+ listener.OnTouchFocusOut(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_CANCELED:
+ listener.OnTouchCanceled(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ default:
+ break;
+ }
+ }
+
+ void FireFocusListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo)
+ {
+ _ControlManager* pControlManager = _ControlManager::GetInstance();
+ SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] System error occurred.");
+
+ Point screenPoint(__pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).x,
+ __pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).y);
+
+ _Control* pTouchedControl = pControlManager->GetTopmostTouchedControl(screenPoint);
+ SysTryReturnVoidResult(NID_UI, pTouchedControl, E_INVALID_CONDITION, "[E_INVALID_CONDITION] pTouchedControl is null.");
+
+ if (__pTouchManager->GetFocusedControlSource() != pTouchedControl)
+ {
+ if (&(__core) != pTouchedControl)
+ {
+ if (__pTouchManager->GetFocusedControlSource() == &(__core))
+ {
+ listener.OnTouchFocusOut(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ }
+ }
+ else
+ {
+ listener.OnTouchFocusIn(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ }
+
+ __pTouchManager->SetFocusedControlSource(*pTouchedControl);
+ }
+ }
+
+ _TouchEventArg* GetTouchEventArgN(const _TouchInfo& touchInfo)
+ {
+ FloatPoint startPoint;
+
+ _TouchEventArg* pEventArg = new (std::nothrow) _TouchEventArg(__public, touchInfo.GetTouchStatus());
+ SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ startPoint.SetPosition(__pTouchManager->GetStartPoint(touchInfo.GetPointId()).x - __core.GetAbsoluteBoundsF().x,
+ __pTouchManager->GetStartPoint(touchInfo.GetPointId()).y - __core.GetAbsoluteBoundsF().y);
+
+ pEventArg->SetTouchPosition(touchInfo.GetPointId(), startPoint.x, startPoint.y,
+ touchInfo.GetCurrentPosition().x, touchInfo.GetCurrentPosition().y);
+
+ // need to flick distance setting
+
+ return pEventArg;
+ }
+
+private:
+ static const int DOUBLE_PRESS_TIME = 500;
+ static const int DOUBLE_PRESS_MOVE_ALLOWANCE = 10;
+
+ _GroupedListViewImpl& __impl;
+ _Control& __core;
+ Control& __public;
+ _TouchManager* __pTouchManager;
+
+ unsigned int __oldPreviousPressedTime;
+ unsigned int __previousPressedTime;
+ unsigned int __currentPressedTime;
+ Tizen::Graphics::FloatPoint __previousPressedPoint;
+ Tizen::Graphics::FloatPoint __currentPressedPoint;
+ _TouchLongPressGestureDetector* __pLongPressedGesture;
+};
+
_GroupedListViewImpl*
_GroupedListViewImpl::GetInstance(GroupedListView& groupedListView)
{
, __redrawListView(true)
, __isBoundsChanged(false)
, __pItemNeedsLazyDeletion(null)
- , __pTouchEventHandler(null)
- , __pLongPressedGesture(null)
+ , __pPropagatedTouchEventListener(null)
{
GET_COLOR_CONFIG(TABLEVIEW::EMPTY_CONTENTS_TEXT_NORMAL, __emptyTextColor);
-
- // Add _TouchLongPressGestureDetector
- __pLongPressedGesture = new (std::nothrow) _TouchLongPressGestureDetector();
- SysTryReturnVoidResult(NID_UI_CTRL, (__pLongPressedGesture != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
-
- pCore->AddGestureDetector(*__pLongPressedGesture);
- __pLongPressedGesture->AddGestureListener(*this);
}
_GroupedListViewImpl::~_GroupedListViewImpl()
__pEmptyText = null;
}
- delete __pTouchEventHandler;
- __pTouchEventHandler = null;
-
- if (__pLongPressedGesture != null)
- {
- __pLongPressedGesture->RemoveGestureListener(*this);
- GetCore().RemoveGestureDetector(*__pLongPressedGesture);
-
- delete __pLongPressedGesture;
- __pLongPressedGesture = null;
- }
+ delete __pPropagatedTouchEventListener;
+ __pPropagatedTouchEventListener = null;
}
const char*
r = CheckConstruction(pCore, pImpl);
SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ pImpl->__pPropagatedTouchEventListener = new (std::nothrow) _GroupedListViewPropagatedTouchEventListener(*pImpl);
+
+ if (pImpl->__pPropagatedTouchEventListener != null)
+ {
+ pCore->SetPropagatedTouchEventListener(pImpl->__pPropagatedTouchEventListener);
+ }
+
return pImpl;
}
// find touched item.
GetItemIndexFromPosition(GetCurrentTouchPosition(), touchedGroupIndex, touchedItemIndex);
- if ((touchedGroupIndex == groupIndex) && (touchedItemIndex == itemIndex) && (pTouchManager->GetTouchStatus(0) != TOUCH_RELEASED))
+ if (pListViewItem->IsItemSelected() && (touchedGroupIndex == groupIndex) && (touchedItemIndex == itemIndex)
+ && (pTouchManager->GetTouchStatus(0) != TOUCH_RELEASED))
{
needChangeEventTarget = true;
}
}
void
+_GroupedListViewImpl::FireListViewItemLongPressedEvent(void)
+{
+ if (__pListItemEvent != null)
+ {
+ int groupIndex = -1;
+ int itemIndex = -1;
+ int elementId = -1;
+
+ if ((GetItemIndexFromPosition(GetCurrentTouchPosition(), groupIndex, itemIndex, elementId) == E_SUCCESS) && (itemIndex != -1))
+ {
+ __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex));
+
+ if ((__pItemNeedsLazyDeletion != null) && (!__pItemNeedsLazyDeletion->IsContextItem()))
+ {
+ _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(groupIndex, itemIndex, elementId, 0, NOTIFY_TYPE_LONG_PRESSED_ITEM);
+ __pListItemEvent->Fire(*pArg);
+
+ __pItemNeedsLazyDeletion = null;
+ }
+ }
+ }
+}
+
+void
_GroupedListViewImpl::OnScrollEndReached(_Control& source, ScrollEndEvent type)
{
if (__pScrollEvent != null)
style = FONT_STYLE_PLAIN;
}
-bool
-_GroupedListViewImpl::OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo)
-{
- return (__pTouchEventHandler != null) ? __pTouchEventHandler->ProcessTouchEventListener(touchinfo) : false;
-}
-
-bool
-_GroupedListViewImpl::OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo)
-{
- return (__pTouchEventHandler != null) ? __pTouchEventHandler->ProcessTouchEventListener(touchinfo) : false;
-}
-
-bool
-_GroupedListViewImpl::OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo)
-{
- return (__pTouchEventHandler != null) ? __pTouchEventHandler->ProcessTouchEventListener(touchinfo) : false;
-}
-
-bool
-_GroupedListViewImpl::OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo)
-{
- return (__pTouchEventHandler != null) ? __pTouchEventHandler->ProcessTouchEventListener(touchinfo) : false;
-}
-
-bool
-_GroupedListViewImpl::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
+FloatPoint
+_GroupedListViewImpl::GetCurrentTouchPosition(void)
{
- bool filtered = false;
-
- if (__pTouchEventHandler != null)
- {
- filtered = __pTouchEventHandler->ProcessTouchEventListener();
- }
-
- if (!filtered && (__pListItemEvent != null))
- {
- int groupIndex = -1;
- int itemIndex = -1;
- int elementId = -1;
-
- if ((GetItemIndexFromPosition(GetCurrentTouchPosition(), groupIndex, itemIndex, elementId) == E_SUCCESS) && (itemIndex != -1))
- {
- __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex));
-
- if ((__pItemNeedsLazyDeletion != null) && (!__pItemNeedsLazyDeletion->IsContextItem()))
- {
- _ListItemEventArg* pArg = new (std::nothrow) _ListItemEventArg(groupIndex, itemIndex, elementId, 0, NOTIFY_TYPE_LONG_PRESSED_ITEM);
- __pListItemEvent->Fire(*pArg);
-
- __pItemNeedsLazyDeletion = null;
- }
- }
- }
+ FloatPoint currentTouchPos = _TouchManager::GetInstance()->GetScreenPoint(0);
+ FloatRectangle bounds = GetCore().GetAbsoluteBoundsF();
- return filtered;
-}
+ currentTouchPos.x -= bounds.x;
+ currentTouchPos.y -= bounds.y;
-bool
-_GroupedListViewImpl::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
-{
- return false;
+ return currentTouchPos;
}
result
_GroupedListViewImpl::OnTouchEventListenerAdded(void)
{
- // support ITouchEventListener
- if (GetTouchEventListener()->GetCount() == 1)
- {
- __pTouchEventHandler = new (std::nothrow) _ListViewTouchEventHandler(*this, LIST_VIEW_STYLE_GROUPED);
- }
-
return E_SUCCESS;
}
return E_SUCCESS;
}
-bool
-_GroupedListViewImpl::GetInputEventConsumeState(void)
-{
- bool filtered = IsInputEventConsumed();
-
- if (filtered)
- {
- ResetInputEventConsumed();
- }
-
- return filtered;
-}
-
-FloatPoint
-_GroupedListViewImpl::GetCurrentTouchPosition(void)
-{
- FloatPoint currentTouchPos = _TouchManager::GetInstance()->GetScreenPoint(0);
- FloatRectangle bounds = GetCore().GetAbsoluteBoundsF();
-
- currentTouchPos.x -= bounds.x;
- currentTouchPos.y -= bounds.y;
-
- return currentTouchPos;
-}
-
class _GroupedListViewMaker
: public _UiBuilderControlMaker
{
#include <FGrp_TextTextSimple.h>
#include "FUi_CoordinateSystemUtils.h"
#include "FUi_Math.h"
+#include "FUi_ITouchLongPressGestureEventListener.h"
#include "FUi_ResourceManager.h"
+#include "FUi_TouchEventArg.h"
+#include "FUi_TouchLongPressGestureDetector.h"
+#include "FUi_TouchManager.h"
#include "FUi_UiBuilder.h"
#include "FUiCtrl_FastScrollEvent.h"
#include "FUiCtrl_FastScrollEventArg.h"
#include "FUiCtrl_ScrollEventArg.h"
using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
using namespace Tizen::Base::Runtime;
+using namespace Tizen::Base::Utility;
using namespace Tizen::Graphics;
using namespace Tizen::Graphics::_Text;
namespace Tizen { namespace Ui { namespace Controls
{
+class _ListViewImpl::_ListViewPropagatedTouchEventListener
+ : public Tizen::Ui::_IPropagatedTouchEventListener
+ , public Tizen::Ui::_ITouchLongPressGestureEventListener
+{
+public:
+
+ _ListViewPropagatedTouchEventListener(_ListViewImpl& impl)
+ : __impl(impl)
+ , __core(impl.GetCore())
+ , __public(impl.GetPublic())
+ , __oldPreviousPressedTime(0)
+ , __previousPressedTime(0)
+ , __currentPressedTime(0)
+ , __previousPressedPoint(0.0f, 0.0f)
+ , __currentPressedPoint(0.0f, 0.0f)
+ , __pLongPressedGesture(null)
+ {
+ __pTouchManager = _TouchManager::GetInstance();
+ SysTryReturnVoidResult(NID_UI, (__pTouchManager != null), E_SYSTEM, "[E_SYSTEM] System error occurred.");
+
+ // Add _TouchLongPressGestureDetector
+ __pLongPressedGesture = new (std::nothrow) _TouchLongPressGestureDetector();
+ SysTryReturnVoidResult(NID_UI_CTRL, (__pLongPressedGesture != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ __core.AddGestureDetector(*__pLongPressedGesture);
+ __pLongPressedGesture->AddGestureListener(*this);
+ }
+
+ virtual ~_ListViewPropagatedTouchEventListener(void)
+ {
+ if (__pLongPressedGesture != null)
+ {
+ __pLongPressedGesture->RemoveGestureListener(*this);
+ __core.RemoveGestureDetector(*__pLongPressedGesture);
+
+ delete __pLongPressedGesture;
+ __pLongPressedGesture = null;
+ }
+ }
+
+ virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ return __impl.CallOnTouchPressed(source, touchInfo);
+ }
+
+ virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ return __impl.CallOnTouchReleased(source, touchInfo);
+ }
+
+ virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ return __impl.CallOnTouchMoved(source, touchInfo);
+ }
+
+ virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ return __impl.CallOnTouchCanceled(source, touchInfo);
+ }
+
+ virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ _UiTouchEventDelivery isFiltered = _UI_TOUCH_EVENT_DELIVERY_NO;
+ IPropagatedTouchEventListener* pListener = __impl.GetPublicPropagatedTouchEventListener();
+
+ if (pListener != null)
+ {
+ Control& control = __impl.GetPublic();
+
+ TouchEventInfo publicTouchInfo;
+
+ _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
+ SysTryReturn(NID_UI, pEventArg, _UI_TOUCH_EVENT_DELIVERY_YES, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
+
+ publicTouchInfo.Construct(*pEventArg);
+
+ if (pEventArg)
+ {
+ delete pEventArg;
+ pEventArg = null;
+ }
+
+ if (pListener->OnTouchPressed(control, publicTouchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+ }
+
+ // public TouchEventListener
+ if (ProcessTouchEventListener(touchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ isFiltered = __impl.OnPreviewTouchPressed(__impl, touchInfo);
+ if (isFiltered == _UI_TOUCH_EVENT_DELIVERY_NO)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ isFiltered = __core.OnPreviewTouchPressed(source, touchInfo);
+
+ return isFiltered;
+ }
+
+ virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ _UiTouchEventDelivery isFiltered = _UI_TOUCH_EVENT_DELIVERY_NO;
+ IPropagatedTouchEventListener* pListener = __impl.GetPublicPropagatedTouchEventListener();
+
+ if (pListener != null)
+ {
+ Control& control = __impl.GetPublic();
+
+ TouchEventInfo publicTouchInfo;
+
+ _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
+ SysTryReturn(NID_UI, pEventArg, _UI_TOUCH_EVENT_DELIVERY_YES, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
+
+ publicTouchInfo.Construct(*pEventArg);
+
+ if (pEventArg)
+ {
+ delete pEventArg;
+ pEventArg = null;
+ }
+
+ if (pListener->OnTouchReleased(control, publicTouchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+ }
+
+ // public TouchEventListener
+ if (ProcessTouchEventListener(touchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ isFiltered = __impl.OnPreviewTouchReleased(__impl, touchInfo);
+ if (isFiltered == _UI_TOUCH_EVENT_DELIVERY_NO)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ isFiltered = __core.OnPreviewTouchReleased(source, touchInfo);
+
+ return isFiltered;
+ }
+
+ virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ _UiTouchEventDelivery isFiltered = _UI_TOUCH_EVENT_DELIVERY_NO;
+ IPropagatedTouchEventListener* pListener = __impl.GetPublicPropagatedTouchEventListener();
+
+ if (pListener != null)
+ {
+ Control& control = __impl.GetPublic();
+
+ TouchEventInfo publicTouchInfo;
+
+ _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
+ SysTryReturn(NID_UI, pEventArg, _UI_TOUCH_EVENT_DELIVERY_YES, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
+
+ publicTouchInfo.Construct(*pEventArg);
+
+ if (pEventArg)
+ {
+ delete pEventArg;
+ pEventArg = null;
+ }
+
+ if (pListener->OnTouchMoved(control, publicTouchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+ }
+
+ // public TouchEventListener
+ if (ProcessTouchEventListener(touchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ isFiltered = __impl.OnPreviewTouchMoved(__impl, touchInfo);
+ if (isFiltered == _UI_TOUCH_EVENT_DELIVERY_NO)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ isFiltered = __core.OnPreviewTouchMoved(source, touchInfo);
+
+ return isFiltered;
+ }
+
+ virtual _UiTouchEventDelivery OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchInfo)
+ {
+ IPropagatedTouchEventListener* pListener = __impl.GetPublicPropagatedTouchEventListener();
+
+ if (pListener != null)
+ {
+ Control& control = __impl.GetPublic();
+
+ TouchEventInfo publicTouchInfo;
+
+ _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
+ SysTryReturn(NID_UI, pEventArg, _UI_TOUCH_EVENT_DELIVERY_YES, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
+
+ publicTouchInfo.Construct(*pEventArg);
+
+ if (pEventArg)
+ {
+ delete pEventArg;
+ pEventArg = null;
+ }
+
+ if (pListener->OnTouchCanceled(control, publicTouchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+ }
+
+ // public TouchEventListener
+ if (ProcessTouchEventListener(touchInfo) == true)
+ {
+ return _UI_TOUCH_EVENT_DELIVERY_NO;
+ }
+
+ return _UI_TOUCH_EVENT_DELIVERY_YES;
+ }
+
+ virtual void OnTouchPressHandled(const _Control& source)
+ {
+ __impl.OnTouchPressHandled(source);
+ }
+
+ virtual void OnTouchReleaseHandled(const _Control& source)
+ {
+ __impl.OnTouchReleaseHandled(source);
+ }
+
+ virtual void OnTouchMoveHandled(const _Control& source)
+ {
+ __impl.OnTouchMoveHandled(source);
+ }
+
+ virtual void OnTouchCancelHandled(const _Control& source)
+ {
+ __impl.OnTouchCancelHandled(source);
+ }
+
+ bool OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
+ {
+ bool filtered = ProcessTouchEventListener();
+
+ if (!filtered)
+ {
+ __impl.FireListViewItemLongPressedEvent();
+ }
+
+ return filtered;
+ }
+
+ bool OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
+ {
+ return false;
+ }
+
+private:
+
+ bool ProcessTouchEventListener(const _TouchInfo& touchInfo)
+ {
+ bool filtered = false;
+
+ if (touchInfo.GetTouchStatus() == _TOUCH_PRESSED)
+ {
+ filtered = ProcessTouchDoublePressed(touchInfo);
+ }
+
+ if (!filtered)
+ {
+ ProcessTouchEvent(touchInfo);
+ }
+
+ filtered = __impl.IsInputEventConsumed();
+
+ if (filtered)
+ {
+ __impl.ResetInputEventConsumed();
+ }
+
+ return filtered;
+ }
+
+ bool ProcessTouchEventListener(void)
+ {
+ // for TouchLongPressed
+ _TouchInfo touchInfo(0, _TOUCH_LONG_PRESSED, __currentPressedPoint, false, 0);
+
+ return ProcessTouchEventListener(touchInfo);
+ }
+
+ void ProcessTouchEvent(const _TouchInfo& touchInfo)
+ {
+ TouchEventInfo publicTouchInfo;
+
+ _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
+ SysTryReturnVoidResult(NID_UI, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ publicTouchInfo.Construct(*pEventArg);
+
+ _Control* pDraggedControl = __pTouchManager->GetTouchControlSource();
+
+ IEnumeratorT<IEventListener*>* pEnumerator = __impl.GetTouchEventListener()->GetEnumeratorN();
+ if (pEnumerator)
+ {
+ while (pEnumerator->MoveNext() == E_SUCCESS)
+ {
+ IEventListener* pListener = null;
+ pEnumerator->GetCurrent(pListener);
+
+ ITouchEventListener* pTouchEventListener = dynamic_cast <ITouchEventListener*>(pListener);
+ if (pTouchEventListener != null)
+ {
+ FirePublicListener(*pTouchEventListener, publicTouchInfo);
+
+ if (touchInfo.GetTouchStatus() == _TOUCH_RELEASED)
+ {
+ if (pDraggedControl == null) //if exist dragged control, don't send focus event
+ {
+ FireFocusListener(*pTouchEventListener, publicTouchInfo);
+ }
+ }
+ else if (touchInfo.GetTouchStatus() == _TOUCH_MOVED)
+ {
+ FireFocusListener(*pTouchEventListener, publicTouchInfo);
+ }
+ }
+ }
+
+ delete pEnumerator;
+ }
+
+ delete pEventArg;
+ }
+
+ bool ProcessTouchDoublePressed(const _TouchInfo& touchinfo)
+ {
+ if (__pTouchManager->GetPointCount() == 1)
+ {
+ __oldPreviousPressedTime = __previousPressedTime;
+ __previousPressedTime = __currentPressedTime;
+ __currentPressedTime = touchinfo.GetTimeStamp();
+ __previousPressedPoint.x = __currentPressedPoint.x;
+ __previousPressedPoint.y = __currentPressedPoint.y;
+ __currentPressedPoint.x = touchinfo.GetCurrentPosition().x;
+ __currentPressedPoint.y = touchinfo.GetCurrentPosition().y;
+
+ if (Math::Abs(__previousPressedTime - __currentPressedTime) < DOUBLE_PRESS_TIME)
+ {
+ if (Math::Abs(__previousPressedTime - __oldPreviousPressedTime) > DOUBLE_PRESS_TIME)
+ {
+ if ((Math::Abs(__previousPressedPoint.x - __currentPressedPoint.x) < DOUBLE_PRESS_MOVE_ALLOWANCE)
+ && (Math::Abs(__previousPressedPoint.y - __currentPressedPoint.y) < DOUBLE_PRESS_MOVE_ALLOWANCE))
+ {
+ _TouchInfo touchInfo(0, _TOUCH_DOUBLE_PRESSED, __currentPressedPoint, false, 0);
+ ProcessTouchEvent(touchInfo);
+
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ void FirePublicListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo)
+ {
+ switch (touchEventInfo.GetTouchStatus())
+ {
+ case TOUCH_PRESSED:
+ listener.OnTouchPressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_LONG_PRESSED:
+ listener.OnTouchLongPressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_RELEASED:
+ listener.OnTouchReleased(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_MOVED:
+ listener.OnTouchMoved(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_DOUBLE_PRESSED:
+ listener.OnTouchDoublePressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_FOCUS_IN:
+ listener.OnTouchFocusIn(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_FOCUS_OUT:
+ listener.OnTouchFocusOut(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ case TOUCH_CANCELED:
+ listener.OnTouchCanceled(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ break;
+ default:
+ break;
+ }
+ }
+
+ void FireFocusListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo)
+ {
+ _ControlManager* pControlManager = _ControlManager::GetInstance();
+ SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] System error occurred.");
+
+ Point screenPoint(__pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).x,
+ __pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).y);
+
+ _Control* pTouchedControl = pControlManager->GetTopmostTouchedControl(screenPoint);
+ SysTryReturnVoidResult(NID_UI, pTouchedControl, E_INVALID_CONDITION, "[E_INVALID_CONDITION] pTouchedControl is null.");
+
+ if (__pTouchManager->GetFocusedControlSource() != pTouchedControl)
+ {
+ if (&(__core) != pTouchedControl)
+ {
+ if (__pTouchManager->GetFocusedControlSource() == &(__core))
+ {
+ listener.OnTouchFocusOut(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ }
+ }
+ else
+ {
+ listener.OnTouchFocusIn(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
+ }
+
+ __pTouchManager->SetFocusedControlSource(*pTouchedControl);
+ }
+ }
+
+ _TouchEventArg* GetTouchEventArgN(const _TouchInfo& touchInfo)
+ {
+ FloatPoint startPoint;
+
+ _TouchEventArg* pEventArg = new (std::nothrow) _TouchEventArg(__public, touchInfo.GetTouchStatus());
+ SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ startPoint.SetPosition(__pTouchManager->GetStartPoint(touchInfo.GetPointId()).x - __core.GetAbsoluteBoundsF().x,
+ __pTouchManager->GetStartPoint(touchInfo.GetPointId()).y - __core.GetAbsoluteBoundsF().y);
+
+ pEventArg->SetTouchPosition(touchInfo.GetPointId(), startPoint.x, startPoint.y,
+ touchInfo.GetCurrentPosition().x, touchInfo.GetCurrentPosition().y);
+
+ // need to flick distance setting
+
+ return pEventArg;
+ }
+
+private:
+ static const int DOUBLE_PRESS_TIME = 500;
+ static const int DOUBLE_PRESS_MOVE_ALLOWANCE = 10;
+
+ _ListViewImpl& __impl;
+ _Control& __core;
+ Control& __public;
+ _TouchManager* __pTouchManager;
+
+ unsigned int __oldPreviousPressedTime;
+ unsigned int __previousPressedTime;
+ unsigned int __currentPressedTime;
+ Tizen::Graphics::FloatPoint __previousPressedPoint;
+ Tizen::Graphics::FloatPoint __currentPressedPoint;
+ _TouchLongPressGestureDetector* __pLongPressedGesture;
+};
+
_ListViewImpl*
_ListViewImpl::GetInstance(ListView& listView)
{
, __redrawListView(true)
, __isBoundsChanged(false)
, __pItemNeedsLazyDeletion(null)
- , __pTouchEventHandler(null)
- , __pLongPressedGesture(null)
+ , __pPropagatedTouchEventListener(null)
{
GET_COLOR_CONFIG(TABLEVIEW::EMPTY_CONTENTS_TEXT_NORMAL, __emptyTextColor);
-
- // Add _TouchLongPressGestureDetector
- __pLongPressedGesture = new (std::nothrow) _TouchLongPressGestureDetector();
- SysTryReturnVoidResult(NID_UI_CTRL, (__pLongPressedGesture != null), E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
-
- pCore->AddGestureDetector(*__pLongPressedGesture);
- __pLongPressedGesture->AddGestureListener(*this);
}
_ListViewImpl::~_ListViewImpl()
__pEmptyText = null;
}
- delete __pTouchEventHandler;
- __pTouchEventHandler = null;
-
- if (__pLongPressedGesture != null)
- {
- __pLongPressedGesture->RemoveGestureListener(*this);
- GetCore().RemoveGestureDetector(*__pLongPressedGesture);
-
- delete __pLongPressedGesture;
- __pLongPressedGesture = null;
- }
+ delete __pPropagatedTouchEventListener;
+ __pPropagatedTouchEventListener = null;
}
const char*
r = CheckConstruction(pCore, pImpl);
SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ pImpl->__pPropagatedTouchEventListener = new (std::nothrow) _ListViewPropagatedTouchEventListener(*pImpl);
+
+ if (pImpl->__pPropagatedTouchEventListener != null)
+ {
+ pCore->SetPropagatedTouchEventListener(pImpl->__pPropagatedTouchEventListener);
+ }
+
return pImpl;
}
_TouchManager* pTouchManager = _TouchManager::GetInstance();
bool needChangeEventTarget = false;
- if ((GetItemIndexFromPosition(GetCurrentTouchPosition()) == index) && (pTouchManager->GetTouchStatus(0) != TOUCH_RELEASED))
+ if (pListViewItem->IsItemSelected() && (GetItemIndexFromPosition(GetCurrentTouchPosition()) == index)
+ && (pTouchManager->GetTouchStatus(0) != TOUCH_RELEASED))
{
needChangeEventTarget = true;
}
style = FONT_STYLE_PLAIN;
}
-bool
-_ListViewImpl::OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo)
+FloatPoint
+_ListViewImpl::GetCurrentTouchPosition(void)
{
- return (__pTouchEventHandler != null) ? __pTouchEventHandler->ProcessTouchEventListener(touchinfo) : false;
-}
+ FloatPoint currentTouchPos = _TouchManager::GetInstance()->GetScreenPoint(0);
+ FloatRectangle bounds = GetCore().GetAbsoluteBoundsF();
-bool
-_ListViewImpl::OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo)
-{
- return (__pTouchEventHandler != null) ? __pTouchEventHandler->ProcessTouchEventListener(touchinfo) : false;
+ currentTouchPos.x -= bounds.x;
+ currentTouchPos.y -= bounds.y;
+
+ return currentTouchPos;
}
-bool
-_ListViewImpl::OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo)
+result
+_ListViewImpl::OnTouchEventListenerAdded(void)
{
- return (__pTouchEventHandler != null) ? __pTouchEventHandler->ProcessTouchEventListener(touchinfo) : false;
+ return E_SUCCESS;
}
-bool
-_ListViewImpl::OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo)
+result
+_ListViewImpl::OnTouchEventListenerRemoved(void)
{
- return (__pTouchEventHandler != null) ? __pTouchEventHandler->ProcessTouchEventListener(touchinfo) : false;
+ return E_SUCCESS;
}
-bool
-_ListViewImpl::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
+void
+_ListViewImpl::FireListViewItemLongPressedEvent(void)
{
- bool filtered = false;
-
- if (__pTouchEventHandler != null)
- {
- filtered = __pTouchEventHandler->ProcessTouchEventListener();
- }
-
- if (!filtered && (__pListItemEvent != null))
+ if (__pListItemEvent != null)
{
int itemIndex = -1;
int elementId = -1;
}
}
}
-
- return filtered;
-}
-
-bool
-_ListViewImpl::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
-{
- return false;
-}
-
-result
-_ListViewImpl::OnTouchEventListenerAdded(void)
-{
- // support ITouchEventListener
- if (GetTouchEventListener()->GetCount() == 1)
- {
- __pTouchEventHandler = new (std::nothrow) _ListViewTouchEventHandler(*this, LIST_VIEW_STYLE_SIMPLE);
- }
-
- return E_SUCCESS;
-}
-
-result
-_ListViewImpl::OnTouchEventListenerRemoved(void)
-{
- return E_SUCCESS;
-}
-
-bool
-_ListViewImpl::GetInputEventConsumeState(void)
-{
- bool filtered = IsInputEventConsumed();
-
- if (filtered)
- {
- ResetInputEventConsumed();
- }
-
- return filtered;
-}
-
-FloatPoint
-_ListViewImpl::GetCurrentTouchPosition(void)
-{
- FloatPoint currentTouchPos = _TouchManager::GetInstance()->GetScreenPoint(0);
- FloatRectangle bounds = GetCore().GetAbsoluteBoundsF();
-
- currentTouchPos.x -= bounds.x;
- currentTouchPos.y -= bounds.y;
-
- return currentTouchPos;
}
class _ListViewMaker
__prevTouchPos = currentStatus.currentTouchPosition;
__selectionEabled = currentStatus.elementSelectionEnabled;
__selectedElementId = currentStatus.selectedElementId;
+ __touchPressed = true;
if (__selectionEabled)
{
currentStatus.selectedElementId = __selectedElementId;
}
+bool
+_ListViewItem::IsItemSelected(void)
+{
+ return __touchPressed;
+}
+
int
_ListViewItem::GetElementIdFromPosition(const FloatPoint& position) const
{
+++ /dev/null
-//
-// Open Service Platform
-// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-/**
- * @file FUiCtrl_ListViewTouchEventHandler.cpp
- * @brief This is the implementation file for _ListViewTouchEventHandler class.
- *
- * This file contains the implementation of _ListViewTouchEventHandler class.
- */
-
-#include <FBaseSysLog.h>
-#include "FUiCtrl_GroupedListViewImpl.h"
-#include "FUiCtrl_ListViewImpl.h"
-#include "FUiCtrl_ListViewTouchEventHandler.h"
-
-#ifdef MEMORY_LEAK_CHECK
-#include "mem_leak_check.h"
-#endif
-
-using namespace Tizen::Base::Collection;
-using namespace Tizen::Base::Runtime;
-using namespace Tizen::Base::Utility;
-using namespace Tizen::Graphics;
-
-namespace Tizen { namespace Ui { namespace Controls
-{
-_ListViewTouchEventHandler::_ListViewTouchEventHandler(_ControlImpl& impl, ListViewStyle style)
- : __impl(impl)
- , __core(impl.GetCore())
- , __public(impl.GetPublic())
- , __style(style)
- , __oldPreviousPressedTime(0)
- , __previousPressedTime(0)
- , __currentPressedTime(0)
- , __previousPressedPoint(0.0f, 0.0f)
- , __currentPressedPoint(0.0f, 0.0f)
-{
- __pTouchManager = _TouchManager::GetInstance();
- SysTryReturnVoidResult(NID_UI, (__pTouchManager != null), E_SYSTEM, "[E_SYSTEM] System error occurred.");
-}
-
-_ListViewTouchEventHandler::~_ListViewTouchEventHandler(void)
-{
-}
-
-bool
-_ListViewTouchEventHandler::ProcessTouchEventListener(const _TouchInfo& touchInfo)
-{
- bool filtered = false;
-
- if (touchInfo.GetTouchStatus() == _TOUCH_PRESSED)
- {
- filtered = ProcessTouchDoublePressed(touchInfo);
- }
-
- if (!filtered)
- {
- ProcessTouchEvent(touchInfo);
- }
-
- if (__style == LIST_VIEW_STYLE_SIMPLE)
- {
- filtered = static_cast<_ListViewImpl*>(&__impl)->GetInputEventConsumeState();
- }
- else if (__style == LIST_VIEW_STYLE_GROUPED)
- {
- filtered = static_cast<_GroupedListViewImpl*>(&__impl)->GetInputEventConsumeState();
- }
-
- return filtered;
-}
-
-
-bool
-_ListViewTouchEventHandler::ProcessTouchEventListener(void)
-{
- // for TouchLongPressed
- _TouchInfo touchInfo(0, _TOUCH_LONG_PRESSED, __currentPressedPoint, false, 0);
-
- return ProcessTouchEventListener(touchInfo);
-}
-
-void
-_ListViewTouchEventHandler::ProcessTouchEvent(const _TouchInfo& touchInfo)
-{
- TouchEventInfo publicTouchInfo;
-
- _TouchEventArg* pEventArg = GetTouchEventArgN(touchInfo);
- SysTryReturnVoidResult(NID_UI, pEventArg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
-
- publicTouchInfo.Construct(*pEventArg);
-
- _Control* pDraggedControl = __pTouchManager->GetTouchControlSource();
-
- IEnumeratorT<IEventListener*>* pEnumerator = __impl.GetTouchEventListener()->GetEnumeratorN();
- if (pEnumerator)
- {
- while (pEnumerator->MoveNext() == E_SUCCESS)
- {
- IEventListener* pListener = null;
- pEnumerator->GetCurrent(pListener);
-
- ITouchEventListener* pTouchEventListener = dynamic_cast <ITouchEventListener*>(pListener);
- if (pTouchEventListener != null)
- {
- FirePublicListener(*pTouchEventListener, publicTouchInfo);
-
- if (touchInfo.GetTouchStatus() == _TOUCH_RELEASED)
- {
- if (pDraggedControl == null) //if exist dragged control, don't send focus event
- {
- FireFocusListener(*pTouchEventListener, publicTouchInfo);
- }
- }
- else if (touchInfo.GetTouchStatus() == _TOUCH_MOVED)
- {
- FireFocusListener(*pTouchEventListener, publicTouchInfo);
- }
- }
- }
-
- delete pEnumerator;
- }
-
- delete pEventArg;
-}
-
-bool
-_ListViewTouchEventHandler::ProcessTouchDoublePressed(const _TouchInfo& touchinfo)
-{
- if (__pTouchManager->GetPointCount() == 1)
- {
- __oldPreviousPressedTime = __previousPressedTime;
- __previousPressedTime = __currentPressedTime;
- __currentPressedTime = touchinfo.GetTimeStamp();
- __previousPressedPoint.x = __currentPressedPoint.x;
- __previousPressedPoint.y = __currentPressedPoint.y;
- __currentPressedPoint.x = touchinfo.GetCurrentPosition().x;
- __currentPressedPoint.y = touchinfo.GetCurrentPosition().y;
-
- if (Math::Abs(__previousPressedTime - __currentPressedTime) < DOUBLE_PRESS_TIME)
- {
- if (Math::Abs(__previousPressedTime - __oldPreviousPressedTime) > DOUBLE_PRESS_TIME)
- {
- if ((Math::Abs(__previousPressedPoint.x - __currentPressedPoint.x) < DOUBLE_PRESS_MOVE_ALLOWANCE)
- && (Math::Abs(__previousPressedPoint.y - __currentPressedPoint.y) < DOUBLE_PRESS_MOVE_ALLOWANCE))
- {
- _TouchInfo touchInfo(0, _TOUCH_DOUBLE_PRESSED, __currentPressedPoint, false, 0);
- ProcessTouchEvent(touchInfo);
-
- return true;
- }
- }
- }
- }
-
- return false;
-}
-
-void
-_ListViewTouchEventHandler::FirePublicListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo)
-{
- switch (touchEventInfo.GetTouchStatus())
- {
- case TOUCH_PRESSED:
- listener.OnTouchPressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
- break;
- case TOUCH_LONG_PRESSED:
- listener.OnTouchLongPressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
- break;
- case TOUCH_RELEASED:
- listener.OnTouchReleased(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
- break;
- case TOUCH_MOVED:
- listener.OnTouchMoved(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
- break;
- case TOUCH_DOUBLE_PRESSED:
- listener.OnTouchDoublePressed(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
- break;
- case TOUCH_FOCUS_IN:
- listener.OnTouchFocusIn(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
- break;
- case TOUCH_FOCUS_OUT:
- listener.OnTouchFocusOut(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
- break;
- case TOUCH_CANCELED:
- listener.OnTouchCanceled(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
- break;
- default:
- break;
- }
-}
-
-void
-_ListViewTouchEventHandler::FireFocusListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo)
-{
- _ControlManager* pControlManager = _ControlManager::GetInstance();
- SysTryReturnVoidResult(NID_UI, pControlManager, E_SYSTEM, "[E_SYSTEM] System error occurred.");
-
- Point screenPoint(__pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).x,
- __pTouchManager->GetScreenPoint(touchEventInfo.GetPointId()).y);
-
- _Control* pTouchedControl = pControlManager->GetTopmostTouchedControl(screenPoint);
- SysTryReturnVoidResult(NID_UI, pTouchedControl, E_INVALID_CONDITION, "[E_INVALID_CONDITION] pTouchedControl is null.");
-
- if (__pTouchManager->GetFocusedControlSource() != pTouchedControl)
- {
- if (&(__core) != pTouchedControl)
- {
- if (__pTouchManager->GetFocusedControlSource() == &(__core))
- {
- listener.OnTouchFocusOut(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
- }
- }
- else
- {
- listener.OnTouchFocusIn(__public, touchEventInfo.GetCurrentPosition(), touchEventInfo);
- }
-
- __pTouchManager->SetFocusedControlSource(*pTouchedControl);
- }
-}
-
-_TouchEventArg*
-_ListViewTouchEventHandler::GetTouchEventArgN(const _TouchInfo& touchInfo)
-{
- Point startPoint;
-
- _TouchEventArg* pEventArg = new (std::nothrow) _TouchEventArg(__public, touchInfo.GetTouchStatus());
- SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
-
- startPoint.SetPosition(__pTouchManager->GetStartPoint(touchInfo.GetPointId()).x - __core.GetAbsoluteBounds().x,
- __pTouchManager->GetStartPoint(touchInfo.GetPointId()).y - __core.GetAbsoluteBounds().y);
-
- pEventArg->SetTouchPosition(touchInfo.GetPointId(), startPoint.x, startPoint.y,
- touchInfo.GetCurrentPosition().x, touchInfo.GetCurrentPosition().y);
-
- // need to flick distance setting
-
- return pEventArg;
-}
-
-}}} // Tizen::Ui::Controls
#include <FUiCtrlGroupedListView.h>
#include "FUi_ControlImpl.h"
-#include "FUi_ITouchLongPressGestureEventListener.h"
-#include "FUi_TouchLongPressGestureDetector.h"
#include "FUiCtrl_IFastScrollListener.h"
#include "FUiCtrl_IScrollEventListener.h"
#include "FUiCtrl_IUiListViewItemEventListener.h"
-#include "FUiCtrl_ListViewTouchEventHandler.h"
#include "FUiCtrl_TableView.h"
namespace Tizen { namespace Ui { namespace Controls
class _GroupedListViewImpl
: public _ControlImpl
, public _ITableViewItemEventListener
- , public _ITouchLongPressGestureEventListener
, public _IScrollEventListener
, public _IUiFastScrollListener
, public _IUiListViewItemEventListener
virtual void OnFontInfoRequested(unsigned long& style, float& size);
- virtual bool OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo);
-
- virtual bool OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo);
-
- virtual bool OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo);
-
- virtual bool OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo);
-
- virtual bool OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture);
-
- virtual bool OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture);
-
- bool GetInputEventConsumeState(void);
-
public:
static _GroupedListViewImpl* GetInstance(GroupedListView& groupedListView);
void FireListViewItemEvent(int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem,
Tizen::Ui::Controls::TableViewItemStatus status);
+ void FireListViewItemLongPressedEvent(void);
+
+ void SetItemNeedsLazyDeletion(void);
+
virtual result OnTouchEventListenerAdded(void);
virtual result OnTouchEventListenerRemoved(void);
- void SetItemNeedsLazyDeletion(void);
-
private:
_ListItemEvent* __pListItemEvent;
_PublicLinkEvent* __pLinkEvent;
bool __isBoundsChanged;
_ListViewItem* __pItemNeedsLazyDeletion;
- _ListViewTouchEventHandler* __pTouchEventHandler;
- _TouchLongPressGestureDetector* __pLongPressedGesture;
+ class _GroupedListViewPropagatedTouchEventListener;
+ _GroupedListViewPropagatedTouchEventListener* __pPropagatedTouchEventListener;
+
+ friend class _GroupedListViewPropagatedTouchEventListener;
}; // _GroupedListViewImpl
}}} // Tizen::Ui::Controls
#include <FUiCtrlListView.h>
#include "FUi_ControlImpl.h"
-#include "FUi_ITouchLongPressGestureEventListener.h"
-#include "FUi_TouchLongPressGestureDetector.h"
#include "FUiCtrl_IFastScrollListener.h"
#include "FUiCtrl_IScrollEventListener.h"
#include "FUiCtrl_IUiListViewItemEventListener.h"
-#include "FUiCtrl_ListViewTouchEventHandler.h"
#include "FUiCtrl_TableView.h"
namespace Tizen { namespace Ui { namespace Controls
: public _ControlImpl
, public _IScrollEventListener
, public _ITableViewItemEventListener
- , public _ITouchLongPressGestureEventListener
, public _IUiFastScrollListener
, public _IUiListViewItemEventListener
, virtual public Tizen::Base::Runtime::IEventListener
virtual void OnFontInfoRequested(unsigned long& style, float& size);
- virtual bool OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo);
-
- virtual bool OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo);
-
- virtual bool OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo);
-
- virtual bool OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo);
-
- virtual bool OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture);
-
- virtual bool OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture);
-
- bool GetInputEventConsumeState(void);
-
public:
static _ListViewImpl* GetInstance(ListView& listView);
Tizen::Graphics::FloatPoint GetCurrentTouchPosition(void);
+ void SetItemNeedsLazyDeletion(void);
+
virtual result OnTouchEventListenerAdded(void);
virtual result OnTouchEventListenerRemoved(void);
- void SetItemNeedsLazyDeletion(void);
+ void FireListViewItemLongPressedEvent(void);
private:
_ListItemEvent* __pListItemEvent;
bool __isBoundsChanged;
_ListViewItem* __pItemNeedsLazyDeletion;
- _ListViewTouchEventHandler* __pTouchEventHandler;
- _TouchLongPressGestureDetector* __pLongPressedGesture;
+ class _ListViewPropagatedTouchEventListener;
+ _ListViewPropagatedTouchEventListener* __pPropagatedTouchEventListener;
+
+ friend class _ListViewPropagatedTouchEventListener;
}; // _ListViewImpl
}}} // Tizen::Ui::Controls
void GetCurrentStatus(_ListViewItemStatus& currentStatus);
+ bool IsItemSelected(void);
+
int GetElementIdFromPosition(const Tizen::Graphics::FloatPoint& position) const;
int GetElementIdFromCurrentTouchPosition(void) const;
+++ /dev/null
-//
-// Open Service Platform
-// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-/**
- * @file FUiCtrl_ListViewTouchEventHandler.h
- * @brief This is the header file for the _ListViewTouchEventHandler class.
- *
- * This header file contains the declarations of the _ListViewTouchEventHandler class.
- */
-
-#ifndef _FUI_CTRL_INTERNAL_LIST_VIEW_TOUCH_EVENT_HANDLER_H_
-#define _FUI_CTRL_INTERNAL_LIST_VIEW_TOUCH_EVENT_HANDLER_H_
-
-#include "FUi_Control.h"
-#include "FUi_ControlImpl.h"
-#include "FUi_ControlManager.h"
-#include "FUi_TouchManager.h"
-#include "FUi_TouchEventArg.h"
-
-namespace Tizen { namespace Ui { namespace Controls
-{
-enum ListViewStyle
-{
- LIST_VIEW_STYLE_SIMPLE,
- LIST_VIEW_STYLE_GROUPED
-};
-
-class _ListViewTouchEventHandler
- : virtual public Tizen::Base::Runtime::IEventListener
-{
-public:
- _ListViewTouchEventHandler(_ControlImpl& impl, ListViewStyle style);
-
- ~_ListViewTouchEventHandler(void);
-
- bool ProcessTouchEventListener(const _TouchInfo& touchinfo);
-
- bool ProcessTouchEventListener(void);
-
-private:
- _ListViewTouchEventHandler(const _ListViewTouchEventHandler& rhs);
-
- _ListViewTouchEventHandler& operator =(const _ListViewTouchEventHandler& rhs);
-
- void ProcessTouchEvent(const _TouchInfo& touchinfo);
-
- bool ProcessTouchDoublePressed(const _TouchInfo& touchinfo);
-
- void FirePublicListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo);
-
- void FireFocusListener(ITouchEventListener& listener, const TouchEventInfo& touchEventInfo);
-
- _TouchEventArg* GetTouchEventArgN(const _TouchInfo& touchInfo);
-
-private:
- static const int DOUBLE_PRESS_TIME = 500;
- static const int DOUBLE_PRESS_MOVE_ALLOWANCE = 10;
-
- _ControlImpl& __impl;
- _Control& __core;
- Control& __public;
- _TouchManager* __pTouchManager;
-
- ListViewStyle __style;
-
- unsigned int __oldPreviousPressedTime;
- unsigned int __previousPressedTime;
- unsigned int __currentPressedTime;
- Tizen::Graphics::FloatPoint __previousPressedPoint;
- Tizen::Graphics::FloatPoint __currentPressedPoint;
-}; // _ListViewTouchEventHandler
-
-}}} // Tizen::Ui::Controls
-
-#endif // _FUI_CTRL_INTERNAL_LIST_VIEW_TOUCH_EVENT_HANDLER_H_