diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-23 21:27:12 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-23 21:27:12 +0000 |
commit | f879188e71ae17348b4174c09f59bfbdfdb2f26b (patch) | |
tree | 658e28b958145dd952bc4bb180f052dd0c15d4d3 /ui/app_list | |
parent | ee21c370e8c74630f65bfb946c0588a2e386aa75 (diff) | |
download | chromium_src-f879188e71ae17348b4174c09f59bfbdfdb2f26b.zip chromium_src-f879188e71ae17348b4174c09f59bfbdfdb2f26b.tar.gz chromium_src-f879188e71ae17348b4174c09f59bfbdfdb2f26b.tar.bz2 |
app_list: Starts touch drag via long press.
Touch drag starts on long press event and context menu shows up if no drag
actually happens.
BUG=117090
TEST=Manual per description above.
R=sadrul@chromium.org,sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11232052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163685 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/app_list')
-rw-r--r-- | ui/app_list/app_list_item_view.cc | 38 | ||||
-rw-r--r-- | ui/app_list/app_list_item_view.h | 9 |
2 files changed, 15 insertions, 32 deletions
diff --git a/ui/app_list/app_list_item_view.cc b/ui/app_list/app_list_item_view.cc index 0a14059..2e54825 100644 --- a/ui/app_list/app_list_item_view.cc +++ b/ui/app_list/app_list_item_view.cc @@ -42,11 +42,8 @@ const SkColor kHighlightedColor = kHoverAndPushedColor; const int kTitleFontSize = 11; const int kLeftRightPaddingChars = 1; -// Delay in milliseconds of when a touch drag should start after tap down. -const int kTouchDragStartDelayInMs = 200; - -// Scale to transform when touch drag starts. -const float kTouchDraggingScale = 1.5f; +// Scale to transform the icon when a drag starts. +const float kDraggingIconScale = 1.5f; // Delay in milliseconds of when the dragging UI should be shown for mouse drag. const int kMouseDragUIDelayInMs = 100; @@ -143,7 +140,7 @@ void AppListItemView::SetUIState(UIState state) { #if !defined(OS_WIN) ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator()); - switch(ui_state_) { + switch (ui_state_) { case UI_STATE_NORMAL: title_->SetVisible(true); layer()->SetTransform(gfx::Transform()); @@ -153,16 +150,12 @@ void AppListItemView::SetUIState(UIState state) { const gfx::Rect bounds(layer()->bounds().size()); layer()->SetTransform(gfx::GetScaleTransform( bounds.CenterPoint(), - kTouchDraggingScale)); + kDraggingIconScale)); break; } #endif } -void AppListItemView::OnTouchDragTimer() { - SetTouchDragging(true); -} - void AppListItemView::SetTouchDragging(bool touch_dragging) { if (touch_dragging_ == touch_dragging) return; @@ -317,19 +310,10 @@ bool AppListItemView::OnMouseDragged(const ui::MouseEvent& event) { ui::EventResult AppListItemView::OnGestureEvent( const ui::GestureEvent& event) { switch (event.type()) { - case ui::ET_GESTURE_TAP_DOWN: - if (!apps_grid_view_->has_dragged_view()) { - touch_drag_timer_.Start(FROM_HERE, - base::TimeDelta::FromMilliseconds(kTouchDragStartDelayInMs), - this, &AppListItemView::OnTouchDragTimer); - } - break; case ui::ET_GESTURE_SCROLL_BEGIN: if (touch_dragging_) { apps_grid_view_->InitiateDrag(this, AppsGridView::TOUCH, event); return ui::ER_CONSUMED; - } else { - touch_drag_timer_.Stop(); } break; case ui::ET_GESTURE_SCROLL_UPDATE: @@ -346,10 +330,18 @@ ui::EventResult AppListItemView::OnGestureEvent( return ui::ER_CONSUMED; } break; - case ui::ET_GESTURE_END: case ui::ET_GESTURE_LONG_PRESS: - touch_drag_timer_.Stop(); - SetTouchDragging(false); + if (!apps_grid_view_->has_dragged_view()) + SetTouchDragging(true); + return ui::ER_CONSUMED; + case ui::ET_GESTURE_END: + if (touch_dragging_) { + SetTouchDragging(false); + + gfx::Point location(event.location()); + ConvertPointToScreen(this, &location); + ShowContextMenu(location, true); + } break; default: break; diff --git a/ui/app_list/app_list_item_view.h b/ui/app_list/app_list_item_view.h index 40198ad..42f2493 100644 --- a/ui/app_list/app_list_item_view.h +++ b/ui/app_list/app_list_item_view.h @@ -54,10 +54,6 @@ class APP_LIST_EXPORT AppListItemView : public views::CustomButton, void SetUIState(UIState state); - // Invoked when |touch_drag_timer_| fires. It sets touch dragging flag so - // that further touch scroll gestures contribute to drag. - void OnTouchDragTimer(); - // Sets |touch_dragging_| flag and updates UI. void SetTouchDragging(bool touch_dragging); @@ -104,11 +100,6 @@ class APP_LIST_EXPORT AppListItemView : public views::CustomButton, UIState ui_state_; - // A timer to track whether user has pressed on the item long enough. When it - // fires, subsequent scroll gesture events will contribute to drag instead - // scrolling. - base::OneShotTimer<AppListItemView> touch_drag_timer_; - // True if scroll gestures should contribute to dragging. bool touch_dragging_; |