From: Suhwan_Park Date: Sun, 24 Mar 2013 08:24:56 +0000 (+0900) Subject: Apply that tap sound is not played when element selection enabled. X-Git-Tag: accepted/tizen_2.1/20130425.033138~746^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c540408d06e780b676f25277c1344a5adf40e138;p=platform%2Fframework%2Fnative%2Fuifw.git Apply that tap sound is not played when element selection enabled. Apply that item is not checked when element selection enabled. Apply that item is drawn normal state BG when touch released during RefreshList. Change-Id: I2c3a79f4a4421650cf106244fb824550cb04704d Signed-off-by: Suhwan_Park --- diff --git a/src/ui/controls/FUiCtrl_GroupedListViewImpl.cpp b/src/ui/controls/FUiCtrl_GroupedListViewImpl.cpp index b46b724..ee506a3 100644 --- a/src/ui/controls/FUiCtrl_GroupedListViewImpl.cpp +++ b/src/ui/controls/FUiCtrl_GroupedListViewImpl.cpp @@ -642,49 +642,52 @@ _GroupedListViewImpl::RefreshList(int groupIndex, int itemIndex, ListRefreshType } else { - TableViewItemDrawingStatus itemDrawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; - bool itemSelected = false; - FloatPoint touchPosition(-1.0f, -1.0f); + _ListViewItemStatus itemStatus; + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + bool needChangeEventTarget = false; + int touchedGroupIndex = -1; + int touchedItemIndex = -1; - if (pListViewItem != null) + // find touched item. + GetItemIndexFromPosition(GetCurrentTouchPosition(), touchedGroupIndex, touchedItemIndex); + + if ((touchedGroupIndex == groupIndex) && (touchedItemIndex == itemIndex) && (pTouchManager->GetTouchStatus(0) != TOUCH_RELEASED)) + { + needChangeEventTarget = true; + } + + if (needChangeEventTarget && (pListViewItem != null)) { - itemDrawingStatus = pListViewItem->GetDrawingStatus(); - itemSelected = pListViewItem->GetSelectionState(); - touchPosition = pListViewItem->GetLastTouchPressedPositionF(); + pListViewItem->GetCurrentStatus(itemStatus); + pListViewItem = null; } + // item unload GetCore().UnloadItem(groupIndex, itemIndex); + // item load pListViewItem = static_cast<_ListViewItem*>(GetCore().LoadItem(groupIndex, itemIndex)); - if ((pListViewItem != null) && (itemDrawingStatus != TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)) + if (needChangeEventTarget && (pListViewItem != null)) { - pListViewItem->SetDrawingStatus(itemDrawingStatus); - pListViewItem->SetSelectionState(itemSelected); - pListViewItem->SetLastTouchPressedPosition(touchPosition); + pListViewItem->SetCurrentStatus(itemStatus); // for create Annex pListViewItem->Draw(); pListViewItem->Show(); - _Control* target = static_cast<_Control*>(pListViewItem); + _Control* pTarget = static_cast<_Control*>(pListViewItem); for (int i = 0; i < pListViewItem->GetChildCount(); i++) { - if (pListViewItem->GetChild(i)->GetBoundsF().Contains(touchPosition)) + if (pListViewItem->GetChild(i)->GetBoundsF().Contains(itemStatus.currentTouchPosition)) { - target = pListViewItem->GetChild(i); + pTarget = pListViewItem->GetChild(i); } } - if (target != null) - { - target->SetChangingEventTarget(true); - } - else - { - pListViewItem->SetDrawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); - pListViewItem->SetSelectionState(false); - } + // change touch event target + pTarget->SetChangingEventTarget(true); + pTouchManager->SetChangedTouchableTarget(pTarget); } } } @@ -1504,17 +1507,11 @@ _GroupedListViewImpl::OnLongPressGestureDetected(_TouchLongPressGestureDetector& if (!filtered && (__pListItemEvent != null)) { - _TouchManager* pTouchManager = _TouchManager::GetInstance(); - FloatPoint currentTouchPos = pTouchManager->GetScreenPoint(0); - FloatRectangle bounds = GetCore().GetAbsoluteBoundsF(); int groupIndex = -1; int itemIndex = -1; int elementId = -1; - currentTouchPos.x -= bounds.x; - currentTouchPos.y -= bounds.y; - - if ((GetItemIndexFromPosition(currentTouchPos, groupIndex, itemIndex, elementId) == E_SUCCESS) && (itemIndex != -1)) + if ((GetItemIndexFromPosition(GetCurrentTouchPosition(), groupIndex, itemIndex, elementId) == E_SUCCESS) && (itemIndex != -1)) { __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(groupIndex, itemIndex)); @@ -1568,6 +1565,18 @@ _GroupedListViewImpl::GetInputEventConsumeState(void) 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 { diff --git a/src/ui/controls/FUiCtrl_ListViewImpl.cpp b/src/ui/controls/FUiCtrl_ListViewImpl.cpp index cda210f..89f6303 100644 --- a/src/ui/controls/FUiCtrl_ListViewImpl.cpp +++ b/src/ui/controls/FUiCtrl_ListViewImpl.cpp @@ -614,49 +614,47 @@ _ListViewImpl::RefreshList(int index, ListRefreshType type, bool needFlush) if ((topItemIndex <= index) && (bottomItemIndex >= index)) { - TableViewItemDrawingStatus itemDrawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; - bool itemSelected = false; - FloatPoint touchPosition(-1.0f, -1.0f); + _ListViewItemStatus itemStatus; + _TouchManager* pTouchManager = _TouchManager::GetInstance(); + bool needChangeEventTarget = false; - if (pListViewItem != null) + if ((GetItemIndexFromPosition(GetCurrentTouchPosition()) == index) && (pTouchManager->GetTouchStatus(0) != TOUCH_RELEASED)) + { + needChangeEventTarget = true; + } + + if (needChangeEventTarget && (pListViewItem != null)) { - itemDrawingStatus = pListViewItem->GetDrawingStatus(); - itemSelected = pListViewItem->GetSelectionState(); - touchPosition = pListViewItem->GetLastTouchPressedPositionF(); + pListViewItem->GetCurrentStatus(itemStatus); + pListViewItem = null; } + // item unload GetCore().UnloadItem(0, index); + // item load pListViewItem = static_cast<_ListViewItem*>(GetCore().LoadItem(0, index)); - if ((pListViewItem != null) && (itemDrawingStatus != TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL)) + if (needChangeEventTarget && (pListViewItem != null)) { - pListViewItem->SetDrawingStatus(itemDrawingStatus); - pListViewItem->SetSelectionState(itemSelected); - pListViewItem->SetLastTouchPressedPosition(touchPosition); + pListViewItem->SetCurrentStatus(itemStatus); // for create Annex pListViewItem->Draw(); pListViewItem->Show(); - _Control* target = static_cast<_Control*>(pListViewItem); + _Control* pTarget = static_cast<_Control*>(pListViewItem); for (int i = 0; i < pListViewItem->GetChildCount(); i++) { - if (pListViewItem->GetChild(i)->GetBoundsF().Contains(touchPosition)) + if (pListViewItem->GetChild(i)->GetBoundsF().Contains(itemStatus.currentTouchPosition)) { - target = pListViewItem->GetChild(i); + pTarget = pListViewItem->GetChild(i); } } - if (target != null) - { - target->SetChangingEventTarget(true); - } - else - { - pListViewItem->SetDrawingStatus(TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL); - pListViewItem->SetSelectionState(false); - } + // change touch event target + pTarget->SetChangingEventTarget(true); + pTouchManager->SetChangedTouchableTarget(pTarget); } } else @@ -1385,16 +1383,10 @@ _ListViewImpl::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gestur if (!filtered && (__pListItemEvent != null)) { - _TouchManager* pTouchManager = _TouchManager::GetInstance(); - FloatPoint currentTouchPos = pTouchManager->GetScreenPoint(0); - FloatRectangle bounds = GetCore().GetAbsoluteBoundsF(); int itemIndex = -1; int elementId = -1; - currentTouchPos.x -= bounds.x; - currentTouchPos.y -= bounds.y; - - if (GetItemIndexFromPosition(currentTouchPos, itemIndex, elementId) == E_SUCCESS) + if (GetItemIndexFromPosition(GetCurrentTouchPosition(), itemIndex, elementId) == E_SUCCESS) { __pItemNeedsLazyDeletion = static_cast<_ListViewItem*>(GetCore().FindItem(0, itemIndex)); @@ -1448,6 +1440,18 @@ _ListViewImpl::GetInputEventConsumeState(void) 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 : public _UiBuilderControlMaker { diff --git a/src/ui/controls/FUiCtrl_ListViewItem.cpp b/src/ui/controls/FUiCtrl_ListViewItem.cpp index ecc4fe0..0eb12ea 100755 --- a/src/ui/controls/FUiCtrl_ListViewItem.cpp +++ b/src/ui/controls/FUiCtrl_ListViewItem.cpp @@ -39,7 +39,6 @@ #include "FUiCtrl_Label.h" #include "FUiCtrl_ListViewContextItem.h" #include "FUiCtrl_ListViewItem.h" -#include "FUiCtrl_Progress.h" #include "FUiCtrl_UiListViewItemEvent.h" #include "FUiCtrl_UiListViewItemEventArg.h" @@ -63,9 +62,6 @@ _ListViewItem::_ListViewItem(float itemHeight) , __needAlignContextItem(false) , __touchPressed(false) , __selectedElementId(-1) - , __progressLeftMargin(0.0f) - , __progressRightMargin(0.0f) - , __pProgress(null) , __descriptionTextShowState(false) , __pDescriptionText(null) , __pDivider(null) @@ -94,14 +90,6 @@ _ListViewItem::~_ListViewItem(void) delete __pTextSlideTimer; __pTextSlideTimer = null; - if (__pProgress != null) - { - DetachChild(*__pProgress); - - delete __pProgress; - __pProgress = null; - } - if (__pDescriptionText != null) { DetachChild(*__pDescriptionText); @@ -538,6 +526,72 @@ _ListViewItem::ClearLastStateChangedInfo(void) ___stateChangedInfo.pUiLinkInfo = null; } +void +_ListViewItem::SetCurrentStatus(_ListViewItemStatus& currentStatus) +{ + // This function was made to modify of ListView::RefreshList(). + // This function could adversely affect touch event handling. So, you should be used with caution. + + ListViewItemDrawingStatus drawingStatus = (currentStatus.itemSelected ? LISTVIEW_ITEM_STATUS_PRESSED + : currentStatus.currentStatus); + + SetItemDrawingStatus(drawingStatus); + SetSelectionState(currentStatus.itemSelected); + SetLastTouchPressedPosition(currentStatus.currentTouchPosition); + + __prevTouchPos = currentStatus.currentTouchPosition; + __selectionEabled = currentStatus.elementSelectionEnabled; + __selectedElementId = currentStatus.selectedElementId; + + // set item state changed info + SetLastStateChangedInfo(); + + if (__selectionEabled) + { + __selectionEabledBgColor = GetItemBackgroundColor(LIST_ITEM_STATE_PRESSED); + SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, GetItemBackgroundColor(LIST_ITEM_STATE_NORMAL)); + } + + _ListViewItemElement* pElement = GetElement(__selectedElementId); + + // text sliding check and invoke + if (pElement != null) + { + if (pElement->elementType == LISTVIEW_ITEM_ELEMENT_TEXT) + { + RefreshElement(__selectedElementId); + + SetCutlinkTextFocus(currentStatus.currentTouchPosition); + + if (pElement->pTextElement->textSlidingEnabled) + { + pElement->pTextElement->pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_SLIDE_LEFT); + pElement->pTextElement->pTextObject->Compose(); + + if (pElement->pTextElement->pTextObject->IsActionOn()) + { + StartTextSlideTimer(); + } + } + } + } +} + +void +_ListViewItem::GetCurrentStatus(_ListViewItemStatus& currentStatus) +{ + // for _TableViewItem + currentStatus.currentStatus = GetItemDrawingStatus(); + currentStatus.itemSelected = GetSelectionState(); + currentStatus.currentTouchPosition = GetLastTouchPressedPositionF(); + + // for _ListViewItem + currentStatus.elementSelectionEnabled = __selectionEabled; + currentStatus.selectedElementId = __selectedElementId; + // for event fire + GetLastStateChangedInfo(currentStatus.stateChangedInfo); +} + int _ListViewItem::GetElementIdFromPosition(const FloatPoint& position) const { @@ -784,31 +838,6 @@ _ListViewItem::GetTextColor(int elementId, Color& textColor, ListViewItemDrawing return true; } -void -_ListViewItem::AdjustProgressBounds(void) -{ - if (__pProgress != null) - { - FloatRectangle progressRect = GetBoundsF(); - float progressHeight = 0.0f; - float bottomMargin = 0.0f; - - // Calculate progress position - GET_SHAPE_CONFIG(SLIDER::BAR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, progressHeight); - GET_SHAPE_CONFIG(SLIDER::BAR_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, bottomMargin); - - progressHeight = progressHeight + (bottomMargin * 2.0f); - progressRect.x = __progressLeftMargin; - progressRect.y = progressRect.height - progressHeight; - progressRect.height = progressHeight; - progressRect.width = progressRect.width - __progressLeftMargin - __progressRightMargin; - - progressRect.y -= ((__descriptionTextShowState) ? GetDescriptionTextHeight() : 0.0f); - - __pProgress->SetBounds(progressRect); - } -} - bool _ListViewItem::SetDescriptionText(const String& text) { @@ -1009,6 +1038,15 @@ _ListViewItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchinf _TableViewItem::OnTouchPressed(source, touchinfo); + // for do not occur annex selection. + if (__selectionEabled) + { + StopTouchPressedTimer(); + SetSelectionState(false); + + RefreshElement(__selectedElementId); + } + return false; } @@ -1023,17 +1061,24 @@ _ListViewItem::OnTouchReleased(const _Control& source, const _TouchInfo& touchin ResetTextSlide(); ResetCutlinkFocus(); + _TableViewItem::OnTouchReleased(source, touchinfo); + if (__selectionEabled) { SetItemBackgroundColor(LIST_ITEM_STATE_PRESSED, __selectionEabledBgColor); __selectionEabled = false; + + //Invalidate(); + RefreshElement(__selectedElementId); + + bool enabled = SetItemTapSoundEnabled(false); + FireItemEvent(); + SetItemTapSoundEnabled(enabled); } __selectedElementId = -1; __touchPressed = false; - _TableViewItem::OnTouchReleased(source, touchinfo); - return false; } @@ -1074,10 +1119,15 @@ _ListViewItem::OnTouchCanceled(const _Control& source, const _TouchInfo& touchin void _ListViewItem::OnDraw(void) { + bool needDraw = IsItemChanged(); + _TableViewItem::OnDraw(); - DrawElements(); - DrawDivider(); + if (needDraw) + { + DrawElements(); + DrawDivider(); + } } result @@ -1112,28 +1162,45 @@ _ListViewItem::OnBoundsChanged(void) } } +void +_ListViewItem::SetItemDrawingStatus(ListViewItemDrawingStatus status) +{ + TableViewItemDrawingStatus parentStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + + switch (status) + { + case LISTVIEW_ITEM_STATUS_PRESSED: + parentStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED; + break; + + case LISTVIEW_ITEM_STATUS_HIGHLIGHTED: + parentStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED; + break; + + default: + parentStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + break; + } + + SetDrawingStatus(parentStatus); +} + ListViewItemDrawingStatus _ListViewItem::GetItemDrawingStatus(void) { TableViewItemDrawingStatus parentStatus = GetDrawingStatus(); - ListViewItemDrawingStatus status; switch (parentStatus) { case TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED: - status = LISTVIEW_ITEM_STATUS_PRESSED; - break; + return LISTVIEW_ITEM_STATUS_PRESSED; case TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED: - status = LISTVIEW_ITEM_STATUS_HIGHLIGHTED; - break; + return LISTVIEW_ITEM_STATUS_HIGHLIGHTED; default: - status = LISTVIEW_ITEM_STATUS_NORMAL; - break; + return LISTVIEW_ITEM_STATUS_NORMAL; } - - return status; } void @@ -1166,6 +1233,13 @@ _ListViewItem::DrawElement(_ListViewItemElement* pElement) } } } + else + { + if ((__selectedElementId == pElement->elementId) && __selectionEabled) + { + status = LISTVIEW_ITEM_STATUS_PRESSED; + } + } Canvas* pCanvas = null; diff --git a/src/ui/inc/FUiCtrl_GroupedListViewImpl.h b/src/ui/inc/FUiCtrl_GroupedListViewImpl.h index 2d3997e..15993df 100644 --- a/src/ui/inc/FUiCtrl_GroupedListViewImpl.h +++ b/src/ui/inc/FUiCtrl_GroupedListViewImpl.h @@ -269,6 +269,8 @@ private: void CheckEmptyListShowState(void); + Tizen::Graphics::FloatPoint GetCurrentTouchPosition(void); + void FireListViewItemEvent(int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status); diff --git a/src/ui/inc/FUiCtrl_ListViewImpl.h b/src/ui/inc/FUiCtrl_ListViewImpl.h index 2ce39d9..ecae93d 100644 --- a/src/ui/inc/FUiCtrl_ListViewImpl.h +++ b/src/ui/inc/FUiCtrl_ListViewImpl.h @@ -251,6 +251,8 @@ private: void CheckEmptyListShowState(void); + Tizen::Graphics::FloatPoint GetCurrentTouchPosition(void); + virtual result OnTouchEventListenerAdded(void); virtual result OnTouchEventListenerRemoved(void); diff --git a/src/ui/inc/FUiCtrl_ListViewItem.h b/src/ui/inc/FUiCtrl_ListViewItem.h index b1dec6e..f67470b 100644 --- a/src/ui/inc/FUiCtrl_ListViewItem.h +++ b/src/ui/inc/FUiCtrl_ListViewItem.h @@ -42,7 +42,6 @@ namespace Tizen { namespace Ui { namespace Controls class _Label; class _ListViewContextItem; -class _Progress; enum ListViewItemElementType { @@ -110,6 +109,16 @@ struct _ListViewItemElement Tizen::Graphics::FloatRectangle bounds; }; +struct _ListViewItemStatus +{ + ListViewItemDrawingStatus currentStatus; + bool itemSelected; + bool elementSelectionEnabled; + int selectedElementId; + Tizen::Graphics::FloatPoint currentTouchPosition; + _ListViewItemStateChangedInfo stateChangedInfo; +}; + class _ListViewItemHitTestVEDelegator : public Tizen::Ui::Animations::VisualElementContentProvider { @@ -156,6 +165,10 @@ public: void ClearLastStateChangedInfo(void); + void SetCurrentStatus(_ListViewItemStatus& currentStatus); + + void GetCurrentStatus(_ListViewItemStatus& currentStatus); + int GetElementIdFromPosition(const Tizen::Graphics::FloatPoint& position) const; int GetElementIdFromCurrentTouchPosition(void) const; @@ -234,6 +247,8 @@ private: _ListViewItemElementBitmap* GetElementBitmap(int elementId) const; + void SetItemDrawingStatus(ListViewItemDrawingStatus status); + ListViewItemDrawingStatus GetItemDrawingStatus(void); void DrawElement(_ListViewItemElement* pElement); @@ -248,8 +263,6 @@ private: float GetDescriptionTextHeight(void); - void AdjustProgressBounds(void); - Tizen::Graphics::Font* GetFont(unsigned long fontStyle, float fontSize); // TextSlide @@ -289,12 +302,6 @@ private: int __selectedElementId; - float __progressLeftMargin; - - float __progressRightMargin; - - _Progress* __pProgress; - bool __descriptionTextShowState; Tizen::Graphics::Color __descriptionTextColor;