Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Unified Diff: ui/app_list/views/apps_grid_view.cc

Issue 19382003: Make dragging outside the app list scroll back to its original position. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/apps_grid_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/apps_grid_view.cc
diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc
index a465cdc2e8b08e054a417c79a64ada69d437e87e..2f7c23650835bceaebe14378c307d75f5c086adc 100644
--- a/ui/app_list/views/apps_grid_view.cc
+++ b/ui/app_list/views/apps_grid_view.cc
@@ -183,10 +183,6 @@ class SynchronousDrag : public ui::DragSourceWin {
virtual void OnDragSourceMove() OVERRIDE {
grid_view_->UpdateDrag(app_list::AppsGridView::MOUSE,
GetCursorInGridViewCoords());
-
- // Don't turn pages if the cursor is dragged outside the view.
- if (!IsCursorWithinGridView())
- grid_view_->StopPageFlipTimer();
}
void SetupExchangeData(ui::OSExchangeData* data) {
@@ -244,6 +240,7 @@ AppsGridView::AppsGridView(AppsGridViewDelegate* delegate,
drag_pointer_(NONE),
drag_and_drop_host_(NULL),
forward_events_to_drag_and_drop_host_(false),
+ drag_start_page_(-1),
page_flip_target_(-1),
page_flip_delay_in_ms_(kPageFlipDelayInMs),
bounds_animator_(this) {
@@ -323,6 +320,7 @@ void AppsGridView::InitiateDrag(AppListItemView* view,
drag_view_ = view;
drag_view_offset_ = event.location();
+ drag_start_page_ = pagination_model_->selected_page();
ExtractDragLocation(event, &drag_start_grid_view_);
drag_view_start_ = gfx::Point(drag_view_->x(), drag_view_->y());
}
@@ -448,6 +446,9 @@ void AppsGridView::EndDrag(bool cancel) {
drag_pointer_ = NONE;
drop_target_ = Index();
drag_view_ = NULL;
+ drag_start_grid_view_ = gfx::Point();
+ drag_start_page_ = -1;
+ drag_view_offset_ = gfx::Point();
AnimateToIdealBounds();
StopPageFlipTimer();
@@ -898,11 +899,16 @@ void AppsGridView::ExtractDragLocation(const ui::LocatedEvent& event,
void AppsGridView::CalculateDropTarget(const gfx::Point& drag_point,
bool use_page_button_hovering) {
- const int current_page = pagination_model_->selected_page();
+ int current_page = pagination_model_->selected_page();
+ gfx::Point point(drag_point);
+ if (!HitTestPoint(drag_point)) {
+ point = drag_start_grid_view_;
+ current_page = drag_start_page_;
+ }
if (use_page_button_hovering &&
- page_switcher_view_->bounds().Contains(drag_point)) {
- gfx::Point page_switcher_point(drag_point);
+ page_switcher_view_->bounds().Contains(point)) {
+ gfx::Point page_switcher_point(point);
views::View::ConvertPointToTarget(this, page_switcher_view_,
&page_switcher_point);
int page = page_switcher_view_->GetPageForPoint(page_switcher_point);
@@ -911,9 +917,9 @@ void AppsGridView::CalculateDropTarget(const gfx::Point& drag_point,
drop_target_.slot = tiles_per_page() - 1;
}
} else {
- const int drop_row = drag_point.y() / kPreferredTileHeight;
+ const int drop_row = point.y() / kPreferredTileHeight;
const int drop_col = std::min(cols_ - 1,
- drag_point.x() / kPreferredTileWidth);
+ point.x() / kPreferredTileWidth);
drop_target_.page = current_page;
drop_target_.slot = std::max(0, std::min(
@@ -990,6 +996,8 @@ void AppsGridView::DispatchDragEventToDragAndDropHost(
}
void AppsGridView::MaybeStartPageFlipTimer(const gfx::Point& drag_point) {
+ if (!HitTestPoint(drag_point))
+ StopPageFlipTimer();
int new_page_flip_target = -1;
if (page_switcher_view_->bounds().Contains(drag_point)) {
@@ -1013,8 +1021,8 @@ void AppsGridView::MaybeStartPageFlipTimer(const gfx::Point& drag_point) {
return;
if (pagination_model_->is_valid_page(new_page_flip_target)) {
+ StopPageFlipTimer();
page_flip_target_ = new_page_flip_target;
- page_flip_timer_.Stop();
if (page_flip_target_ != pagination_model_->selected_page()) {
page_flip_timer_.Start(FROM_HERE,
@@ -1022,8 +1030,7 @@ void AppsGridView::MaybeStartPageFlipTimer(const gfx::Point& drag_point) {
this, &AppsGridView::OnPageFlipTimer);
}
} else {
- page_flip_target_ = -1;
- page_flip_timer_.Stop();
+ StopPageFlipTimer();
xiyuan 2013/07/19 04:36:46 nit: We probably could move this to be before the
koz (OOO until 15th September) 2013/07/19 08:00:32 Done.
}
}
« no previous file with comments | « ui/app_list/views/apps_grid_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698