From: youseong.ji Date: Wed, 3 Apr 2013 08:34:23 +0000 (+0900) Subject: Modified to work properly for item background highlight X-Git-Tag: accepted/tizen_2.1/20130425.033138~467^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7151b51fe4e9c7a05111ed90cfade82653825ac6;p=platform%2Fframework%2Fnative%2Fuifw.git Modified to work properly for item background highlight Change-Id: Ic8d71cb2b64ffc62f5491d7a21aae9dbe050ccc1 Signed-off-by: youseong.ji --- diff --git a/src/ui/controls/FUiCtrl_TableViewItem.cpp b/src/ui/controls/FUiCtrl_TableViewItem.cpp index e1235ad..1b247df 100644 --- a/src/ui/controls/FUiCtrl_TableViewItem.cpp +++ b/src/ui/controls/FUiCtrl_TableViewItem.cpp @@ -49,9 +49,11 @@ _TableViewItemControl::_TableViewItemControl(void) _TableViewItemControl::~_TableViewItemControl(void) { - delete __pBackgroundBitmap; - __pBackgroundBitmap = null; - + if(__pBackgroundBitmap) + { + delete __pBackgroundBitmap; + __pBackgroundBitmap = null; + } ClearLastResult(); } @@ -268,18 +270,34 @@ _TableViewItem::~_TableViewItem() { __isAnimationCallbackBlocked = true; + StopTouchPressedTimer(); + delete __pPressedTimer; + __pPressedTimer = null; + + StopTouchReleasedTimer(); + delete __pReleasedTimer; + __pReleasedTimer = null; + _VisualElement* pVisualElement = GetVisualElement(); if (pVisualElement != null) { - __pMoveItemAnimation->SetVisualElementAnimationTickEventListener(null); - __pMoveItemAnimation->SetVisualElementAnimationStatusEventListener(null); - - __pZoomInOutItemAnimation->SetVisualElementAnimationTickEventListener(null); - __pZoomInOutItemAnimation->SetVisualElementAnimationStatusEventListener(null); + if(__pMoveItemAnimation != null) + { + __pMoveItemAnimation->SetVisualElementAnimationTickEventListener(null); + __pMoveItemAnimation->SetVisualElementAnimationStatusEventListener(null); + } - __pFadeInOutItemtAnimation->SetVisualElementAnimationTickEventListener(null); - __pFadeInOutItemtAnimation->SetVisualElementAnimationStatusEventListener(null); + if(__pZoomInOutItemAnimation != null) + { + __pZoomInOutItemAnimation->SetVisualElementAnimationTickEventListener(null); + __pZoomInOutItemAnimation->SetVisualElementAnimationStatusEventListener(null); + } + if(__pFadeInOutItemtAnimation != null) + { + __pFadeInOutItemtAnimation->SetVisualElementAnimationTickEventListener(null); + __pFadeInOutItemtAnimation->SetVisualElementAnimationStatusEventListener(null); + } pVisualElement->RemoveAllAnimations(); } @@ -345,22 +363,6 @@ _TableViewItem::~_TableViewItem() delete __pFadeInOutItemtAnimation; __pFadeInOutItemtAnimation = null; - if (__isPressedTimerEnabled && __pPressedTimer != null) - { - __pPressedTimer->Cancel(); - } - - delete __pPressedTimer; - __pPressedTimer = null; - - if (__isReleasedTimerEnabled && __pReleasedTimer != null) - { - __pReleasedTimer->Cancel(); - } - - delete __pReleasedTimer; - __pReleasedTimer = null; - if (__isCheckedTimerEnabled) { __pCheckedTimer->Cancel(); @@ -629,6 +631,127 @@ _TableViewItem::CreateItemCover(void) return r; } +result +_TableViewItem::CreateCheckBox(void) +{ + result r = E_SUCCESS; + + if (__pItemAnnex == null) + { + float annexWidth = 0.0f; + float annexHeight = 0.0f; + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight); + + __pItemAnnex = _Label::CreateLabelN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pItemAnnex != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + float leftMargin = 0.0f; + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + + float itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height); + __pItemAnnex->SetBounds(FloatRectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); + __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); + + AttachSystemChild(*__pItemAnnex); + } + + return r; +} + + +result +_TableViewItem::CreateRadioBox(void) +{ + result r = E_SUCCESS; + + if (__pItemAnnex == null) + { + float annexWidth = 0.0f; + float annexHeight = 0.0f; + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight); + + __pItemAnnex = _Label::CreateLabelN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pItemAnnex != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + float leftMargin = 0.0f; + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + + float itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height); + __pItemAnnex->SetBounds(FloatRectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); + __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); + + AttachSystemChild(*__pItemAnnex); + } + + return r; +} + +result +_TableViewItem::CreateOnOffButton(void) +{ + result r = E_SUCCESS; + + if (__pItemAnnex == null) + { + float annexWidth = 0.0f; + float annexHeight = 0.0f; + + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_ONOFF_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight); + + __pItemAnnex = _Label::CreateLabelN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pItemAnnex != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + float leftMargin = 0.0f; + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + + leftMargin += __pDrawingProperty->scrollMargin; + + float itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height); + __pItemAnnex->SetBounds(FloatRectangle((GetBoundsF().width - annexWidth - leftMargin), ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); + __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); + + AttachSystemChild(*__pItemAnnex); + } + + return r; +} + +result +_TableViewItem::CreateDetailButton(void) +{ + result r = E_SUCCESS; + + if (__pItemAnnex == null) + { + float annexWidth = 0.0f; + float annexHeight = 0.0f; + + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, annexWidth); + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_ANNEX_MORE_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, annexHeight); + __pItemAnnex = _Label::CreateLabelN(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pItemAnnex != null, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + float leftMargin = 0.0f; + GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); + + leftMargin += __pDrawingProperty->scrollMargin; + float itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height); + __pItemAnnex->SetBounds(FloatRectangle((GetBoundsF().width - annexWidth - leftMargin), ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); + __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); + + AttachSystemChild(*__pItemAnnex); + } + + return r; +} + void _TableViewItem::ExposeContextItem(FloatRectangle itemBounds, float targetWidth) { @@ -1088,12 +1211,6 @@ _TableViewItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchin return true; } - if(__isReleasedTimerEnabled) - { - StopTouchReleasedTimer(); - FireItemTouchReleased(); - } - __annexOnOffHandlerMoved = false; __touchStartPosition = touchinfo.GetCurrentPosition(); // +++ check floating @@ -1120,9 +1237,25 @@ _TableViewItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchin __pressedControl = TABLE_VIEW_ITEM_PRESSED_NONE; } - if (!IsIndividualSelectionEnabled(source)) + if(__isReleasedTimerEnabled) + { + StopTouchReleasedTimer(); + + if (!IsIndividualSelectionEnabled(source)) + { + __itemSelected = true; + FireItemTouchPressed(); + } + + FireItemTouchReleased(); + } + else { - StartTouchPressedTimer(source, touchinfo); + if (!IsIndividualSelectionEnabled(source)) + { + __itemSelected = true; + StartTouchPressedTimer(source, touchinfo); + } } return true; @@ -1178,8 +1311,6 @@ _TableViewItem::OnTouchReleased(const _Control& source, const _TouchInfo& touchi void _TableViewItem::FireItemTouchPressed() { - __itemSelected = true; - if(__pressedControl == TABLE_VIEW_ITEM_PRESSED_ITEM) { __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED; @@ -1194,10 +1325,14 @@ _TableViewItem::FireItemTouchPressed() __isSelectedDetailButton = true; DrawAnnexStyle(); } - else if (__annexStyle != TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING && - __annexStyle != TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER) + else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || + __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER) { __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + } + else + { + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED; SetItemChanged(true); Invalidate(); } @@ -1211,7 +1346,6 @@ _TableViewItem::FireItemTouchPressed() Invalidate(); } } - } void @@ -1229,11 +1363,14 @@ _TableViewItem::FireItemTouchReleased() if (__releasedControl == TABLE_VIEW_ITEM_PRESSED_ITEM) { - if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) - || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) + if ((__annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO) || (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)) { SetChecked(!checked); + } + else if(__annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK) + { + SetChecked(!checked); SetCheckedAnimationEnabled(!checked); } } @@ -1586,21 +1723,20 @@ _TableViewItem::StartTouchReleasedTimer() { result r = E_SUCCESS; - if(__pReleasedTimer != null) + if(__pReleasedTimer == null) { - delete __pReleasedTimer; - __pReleasedTimer = null; - } + __pReleasedTimer = new (std::nothrow) Timer(); + SysTryCatch(NID_UI_CTRL, __pReleasedTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - __pReleasedTimer = new (std::nothrow) Timer(); - SysTryCatch(NID_UI_CTRL, __pReleasedTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - - r = __pReleasedTimer->Construct(*this); - SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage); - - r = __pReleasedTimer->Start(TOUCH_RELEASED_DURATION); - SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage); + r = __pReleasedTimer->Construct(*this); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage); + } + if(!__isReleasedTimerEnabled) + { + r = __pReleasedTimer->Start(TOUCH_RELEASED_DURATION); + SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage); + } __isReleasedTimerEnabled = true; return r; @@ -1845,6 +1981,8 @@ void _TableViewItem::SetDrawingProperty(_ItemDrawingProperty* pDrawingProperty) { __pDrawingProperty = pDrawingProperty; + + CreateAnnexStyle(); } _ItemDrawingProperty* @@ -2153,6 +2291,31 @@ CATCH: } void +_TableViewItem::CreateAnnexStyle(void) +{ + switch (__annexStyle) + { + case TABLE_VIEW_ANNEX_STYLE_MARK: + CreateCheckBox(); + break; + case TABLE_VIEW_ANNEX_STYLE_RADIO: + CreateRadioBox(); + break; + case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING: + CreateOnOffButton(); + break; + case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER: + CreateOnOffButton(); + break; + case TABLE_VIEW_ANNEX_STYLE_DETAILED: + CreateDetailButton(); + break; + default: + break; + } +} + +void _TableViewItem::DrawAnnexStyle(void) { switch (__annexStyle) @@ -2206,6 +2369,7 @@ _TableViewItem::DrawCheckBox(void) r = GET_BITMAP_CONFIG_N(TABLEVIEW::CHECKBOX_CHECK_MARK_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pCheckBox); SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS) && (pCheckBox != null), , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r)); + } else { @@ -2257,23 +2421,6 @@ _TableViewItem::DrawCheckBox(void) pMergeBitmap->Construct(*pCanvas, bounds); } - if (__pItemAnnex == null) - { - __pItemAnnex = _Label::CreateLabelN(); - - r = GetLastResult(); - SysTryCatch(NID_UI_CTRL, __pItemAnnex != null, , r, "[%s] Propagating.", GetErrorMessage(r)); - - float leftMargin = 0.0f; - GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); - - float itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height); - __pItemAnnex->SetBounds(FloatRectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); - __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); - - AttachSystemChild(*__pItemAnnex); - } - __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap); __pItemAnnex->Invalidate(); @@ -2354,21 +2501,6 @@ _TableViewItem::DrawRadioBox(void) pMergeBitmap->Construct(*pCanvas, bounds); } - if (__pItemAnnex == null) - { - __pItemAnnex = _Label::CreateLabelN(); - SysTryReturnVoidResult(NID_UI_CTRL, __pItemAnnex, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - float leftMargin = 0.0f; - GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); - - float itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height); - __pItemAnnex->SetBounds(FloatRectangle(leftMargin, ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); - __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); - - AttachSystemChild(*__pItemAnnex); - } - __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap); __pItemAnnex->Invalidate(); @@ -2460,23 +2592,6 @@ _TableViewItem::DrawOnOffButton(void) pMergeBitmap->Construct(*pCanvas, bounds); - if (__pItemAnnex == null) - { - __pItemAnnex = _Label::CreateLabelN(); - SysTryReturnVoidResult(NID_UI_CTRL, __pItemAnnex, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - float leftMargin = 0.0f; - GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); - - leftMargin += __pDrawingProperty->scrollMargin; - - float itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height); - __pItemAnnex->SetBounds(FloatRectangle((GetBoundsF().width - annexWidth - leftMargin), ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); - __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); - - AttachSystemChild(*__pItemAnnex); - } - __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap); __pItemAnnex->Invalidate(); @@ -2772,22 +2887,6 @@ _TableViewItem::DrawDetailButton(void) pMergeBitmap->Construct(*pCanvas, bounds); - if (__pItemAnnex == null) - { - __pItemAnnex = _Label::CreateLabelN(); - SysTryReturnVoidResult(NID_UI_CTRL, __pItemAnnex, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - float leftMargin = 0.0f; - GET_SHAPE_CONFIG(TABLEVIEW::ITEM_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, leftMargin); - - leftMargin += __pDrawingProperty->scrollMargin; - float itemHeight = ((__customHeight > 0) ? __customHeight : GetBoundsF().height); - __pItemAnnex->SetBounds(FloatRectangle((GetBoundsF().width - annexWidth - leftMargin), ((itemHeight - annexHeight) / 2), annexWidth, annexHeight)); - __pItemAnnex->SetBackgroundColor(Color(0, 0, 0, 0)); - - AttachSystemChild(*__pItemAnnex); - } - __pItemAnnex->SetBackgroundBitmap(*pMergeBitmap); __pItemAnnex->Invalidate(); @@ -3395,6 +3494,47 @@ _TableViewItem::GetDrawingStatus(void) } void +_TableViewItem::SetPressedControl(TableViewItemPressedControl pressedControl) +{ + __pressedControl = pressedControl; + + if(__pressedControl == TABLE_VIEW_ITEM_PRESSED_ITEM) + { + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED; + } + else if(__pressedControl == TABLE_VIEW_ITEM_PRESSED_ANNEX) + { + if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_DETAILED) + { + __isSelectedDetailButton = true; + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + } + else if (__annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || + __annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING_WITH_DIVIDER) + { + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL; + } + else + { + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED; + } + } + else + { + if(__pressedControl != TABLE_VIEW_ITEM_PRESSED_INDIVIDUAL) + { + __drawingStatus = TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED; + } + } +} + +TableViewItemPressedControl +_TableViewItem::GetPressedControl(void) +{ + return __pressedControl; +} + +void _TableViewItem::AdjustChildControlMargin(void) { if (__childMarginState) diff --git a/src/ui/inc/FUiCtrl_TableViewItem.h b/src/ui/inc/FUiCtrl_TableViewItem.h index 033548d..8b7400c 100644 --- a/src/ui/inc/FUiCtrl_TableViewItem.h +++ b/src/ui/inc/FUiCtrl_TableViewItem.h @@ -296,6 +296,9 @@ protected: bool SetItemTapSoundEnabled(bool tapSoundEnabled); bool GetItemTapSoundEnabled(void); + void SetPressedControl(TableViewItemPressedControl pressedControl); + TableViewItemPressedControl GetPressedControl(void); + result StartTouchPressedTimer(const _Control& source, const _TouchInfo& touchinfo); void StopTouchPressedTimer(void); result StartTouchReleasedTimer(void); @@ -333,9 +336,16 @@ private: void DrawSimpleItem(void); result CreateSimpleItemContents(bool textOnly); - result CreateItemCover(void); result CreateItemDivider(void); result CreateItemAnnexDivider(void); + result CreateItemCover(void); + + void CreateAnnexStyle(void); + result CreateCheckBox(void); + result CreateRadioBox(void); + result CreateOnOffButton(void); + result CreateDetailButton(void); + void FireItemTouchReleased(void); void FireItemTouchPressed(void); @@ -440,7 +450,7 @@ private: static const int DEFAULT_CAPTURED_CONTROL_COUNT = 10; static const int CHECKED_ANIMATION_DURATION = 30; static const int TOUCH_PRESSED_DURATION = 100; - static const int TOUCH_RELEASED_DURATION = 50; + static const int TOUCH_RELEASED_DURATION = 30; static const int MAX_CHECKED_COUNT = 10; static const float INSENSITIVE = 0.16f; static const float SENSITIVE = 0.08f;