apply touch press threshold to ContextMenu
authorPark Kyoung Hee <kh1979.park@samsung.com>
Tue, 16 Apr 2013 07:17:22 +0000 (16:17 +0900)
committerPark Kyoung Hee <kh1979.park@samsung.com>
Tue, 16 Apr 2013 08:40:33 +0000 (17:40 +0900)
Change-Id: I86b20847bb0074391589777b96f1adf0941e332d
Signed-off-by: Park Kyoung Hee <kh1979.park@samsung.com>
src/ui/controls/FUiCtrl_ContextMenu.cpp
src/ui/controls/FUiCtrl_ContextMenuListPresenter.cpp

index 6a3eeb4..bfe1336 100644 (file)
@@ -37,6 +37,10 @@ using namespace Tizen::Graphics;
 using namespace Tizen::Media;
 using namespace Tizen::Ui::Animations;
 
+namespace {
+static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f;
+}
+
 namespace Tizen { namespace Ui { namespace Controls
 {
 
@@ -155,7 +159,7 @@ _ContextMenu::CreateContextMenuN(const FloatPoint& point, enum ContextMenuCoreSt
        SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Install.", GetErrorMessage(r));
 
        pContextMenu->AcquireHandle();
-       pContextMenu->SetTouchPressThreshold(0.08f);
+       pContextMenu->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
 
        if (pContextMenu->GetAccessibilityContainer() != null)
        {
@@ -168,6 +172,7 @@ _ContextMenu::CreateContextMenuN(const FloatPoint& point, enum ContextMenuCoreSt
                GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MIN_WIDTH,   _CONTROL_ORIENTATION_PORTRAIT, minWidth);
                GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, minHeight);
                pContextMenu->__pScrollPanel = _ScrollPanel::CreateScrollPanelN(FloatRectangle(0.0f, 0.0f, minWidth, minHeight), SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, false, false);
+               pContextMenu->__pScrollPanel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
                pContextMenu->AttachChild(*(pContextMenu->__pScrollPanel));
        }
 
index da576f5..2ed9c11 100755 (executable)
@@ -40,8 +40,11 @@ using namespace Tizen::Base;
 using namespace Tizen::Base::Runtime;
 using namespace Tizen::Graphics::_Text;
 
+namespace {
+static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f;
 static const int CONTEXT_MENU_LIST_ELEMENT_TEXT = 0;
 static const int CONTEXT_MENU_LIST_ELEMENT_BITMAP = 1;
+}
 
 namespace Tizen { namespace Ui { namespace Controls
 {
@@ -182,6 +185,7 @@ _ContextMenuListPresenter::CreateItem(const Base::String& text, int actionId, co
 
                int bitmapY = (__itemHeight - __itemBitmapHeight ) / 2;
                pLabel->SetBounds(FloatRectangle(__leftMargin, bitmapY,  __itemBitmapWidth, __itemBitmapHeight));
+               pLabel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
                pItem->AttachChild(*pLabel);
                _AccessibilityContainer* pContainer = pLabel->GetAccessibilityContainer();
                if (pContainer)
@@ -226,7 +230,7 @@ _ContextMenuListPresenter::CreateItem(const Base::String& text, int actionId, co
        GET_SHAPE_CONFIG(LABEL::TOP_MARGIN,  _CONTROL_ORIENTATION_PORTRAIT, labelTopMargin);
        textArea.width  += 2.0f * labelLeftMargin;
        textArea.height += 2.0f * labelTopMargin;
-       itemSize.height = __itemHeight + __dividerHeight;
+       itemSize.height = __itemHeight + (__dividerHeight * 2.0f);
        itemSize.width =  __leftMargin + textArea.width + __rightMargin + bitmapWidth;
 
        itemSize.width = itemSize.width < __itemMinWidth ? __itemMinWidth : itemSize.width;
@@ -254,6 +258,7 @@ _ContextMenuListPresenter::CreateItem(const Base::String& text, int actionId, co
        pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
        pLabel->SetTextConfig(__itemFontSize, LABEL_TEXT_STYLE_NORMAL);
 
+       pLabel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
        pItem->AttachChild(*pLabel);
        _AccessibilityContainer* pContainer = pLabel->GetAccessibilityContainer();
        if (pContainer)
@@ -264,6 +269,7 @@ _ContextMenuListPresenter::CreateItem(const Base::String& text, int actionId, co
 
        __itemWidth = __itemWidth < itemSize.width ? itemSize.width : __itemWidth;
 
+       pItem->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
        return pItem;
 }
 
@@ -699,8 +705,8 @@ _ContextMenuListPresenter::CalculateRect(void)
        {
                __pContextMenu->GetScrollPanel()->SetBounds(FloatRectangle(bodyRect.x + bodyLeftMargin, bodyRect.y + bodyTopMargin, __layoutSize.width, __layoutSize.height));
                int itemCount = __pModel->GetItemCount();
-               float itemHeight = __itemHeight + __dividerHeight;
-               float layoutClientHeight = itemCount * itemHeight - __dividerHeight;
+               float itemHeight = __itemHeight + (__dividerHeight * 2.0f);
+               float layoutClientHeight = itemCount * itemHeight - (__dividerHeight * 2.0f);
                __pContextMenu->GetScrollPanel()->SetClientAreaHeight(layoutClientHeight);
        }
 
@@ -754,12 +760,12 @@ _ContextMenuListPresenter::AdjustItemLayoutStyle(void)
        int itemMaxCount = CalculateShowItemCount();
 
        int itemCount = __pModel->GetItemCount();
-       float itemHeight = __itemHeight + __dividerHeight;
+       float itemHeight = __itemHeight + (__dividerHeight * 2.0f);
 
        FloatDimension layoutSize(__itemWidth, 0.0f);
 
-       float layoutClientHeight = itemCount * itemHeight - __dividerHeight;
-       float layoutMaxHeight = itemMaxCount * itemHeight - __dividerHeight;
+       float layoutClientHeight = itemCount * itemHeight - (__dividerHeight * 2.0f);
+       float layoutMaxHeight = itemMaxCount * itemHeight - (__dividerHeight * 2.0f);
        if (layoutClientHeight > layoutMaxHeight)
        {
                __scrollEnable = true;
@@ -783,7 +789,7 @@ _ContextMenuListPresenter::AdjustItemPosition(void)
                return;
        }
 
-       float itemHeight = __itemHeight + __dividerHeight;
+       float itemHeight = __itemHeight + (__dividerHeight * 2.0f);
        float drawItemY = 0.0f;
 
        float x = __pContextMenu->GetBodyRect().x + __leftMargin;