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

Side by Side Diff: ui/app_list/apps_grid_view.cc

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RenderText fixup Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/app_list/apps_grid_view.h" 5 #include "ui/app_list/apps_grid_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/app_list/app_list_item_model.h" 9 #include "ui/app_list/app_list_item_model.h"
10 #include "ui/app_list/app_list_item_view.h" 10 #include "ui/app_list/app_list_item_view.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 pagination_model_->SelectPage(index.page, false); 162 pagination_model_->SelectPage(index.page, false);
163 } 163 }
164 164
165 void AppsGridView::InitiateDrag(views::View* view, 165 void AppsGridView::InitiateDrag(views::View* view,
166 Pointer pointer, 166 Pointer pointer,
167 const ui::LocatedEvent& event) { 167 const ui::LocatedEvent& event) {
168 if (drag_view_) 168 if (drag_view_)
169 return; 169 return;
170 170
171 drag_view_ = view; 171 drag_view_ = view;
172 drag_offset_ = event.location(); 172 drag_start_ = event.location();
173 } 173 }
174 174
175 void AppsGridView::UpdateDrag(views::View* view, 175 void AppsGridView::UpdateDrag(views::View* view,
176 Pointer pointer, 176 Pointer pointer,
177 const ui::LocatedEvent& event) { 177 const ui::LocatedEvent& event) {
178 if (!dragging() && drag_view_ && 178 if (!dragging() && drag_view_ &&
179 ExceededDragThreshold(event.x() - drag_offset_.x(), 179 ExceededDragThreshold(event.location() - drag_start_)) {
180 event.y() - drag_offset_.y())) {
181 drag_pointer_ = pointer; 180 drag_pointer_ = pointer;
182 // Move the view to the front so that it appears on top of other views. 181 // Move the view to the front so that it appears on top of other views.
183 ReorderChildView(drag_view_, -1); 182 ReorderChildView(drag_view_, -1);
184 bounds_animator_.StopAnimatingView(drag_view_); 183 bounds_animator_.StopAnimatingView(drag_view_);
185 } 184 }
186 if (drag_pointer_ == pointer) { 185 if (drag_pointer_ == pointer) {
187 last_drag_point_ = event.location(); 186 last_drag_point_ = event.location();
188 views::View::ConvertPointToTarget(drag_view_, this, &last_drag_point_); 187 views::View::ConvertPointToTarget(drag_view_, this, &last_drag_point_);
189 188
190 const Index last_drop_target = drop_target_; 189 const Index last_drop_target = drop_target_;
191 CalculateDropTarget(last_drag_point_); 190 CalculateDropTarget(last_drag_point_);
192 MaybeStartPageFlipTimer(last_drag_point_); 191 MaybeStartPageFlipTimer(last_drag_point_);
193 192
194 gfx::Point page_switcher_point(last_drag_point_); 193 gfx::Point page_switcher_point(last_drag_point_);
195 views::View::ConvertPointToTarget(this, page_switcher_view_, 194 views::View::ConvertPointToTarget(this, page_switcher_view_,
196 &page_switcher_point); 195 &page_switcher_point);
197 page_switcher_view_->UpdateUIForDragPoint(page_switcher_point); 196 page_switcher_view_->UpdateUIForDragPoint(page_switcher_point);
198 197
199 if (last_drop_target != drop_target_) 198 if (last_drop_target != drop_target_)
200 AnimateToIdealBounds(); 199 AnimateToIdealBounds();
201 drag_view_->SetPosition(last_drag_point_.Subtract(drag_offset_)); 200 drag_view_->SetPosition(
201 gfx::PointAtOffsetFromOrigin(last_drag_point_ - drag_start_));
202 } 202 }
203 } 203 }
204 204
205 void AppsGridView::EndDrag(bool cancel) { 205 void AppsGridView::EndDrag(bool cancel) {
206 if (!cancel && dragging() && drag_view_ && IsValidIndex(drop_target_)) 206 if (!cancel && dragging() && drag_view_ && IsValidIndex(drop_target_))
207 MoveItemInModel(drag_view_, drop_target_); 207 MoveItemInModel(drag_view_, drop_target_);
208 208
209 drag_pointer_ = NONE; 209 drag_pointer_ = NONE;
210 drop_target_ = Index(); 210 drop_target_ = Index();
211 if (drag_view_) { 211 if (drag_view_) {
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 void AppsGridView::TransitionChanged() { 698 void AppsGridView::TransitionChanged() {
699 // Update layout for valid page transition only since over-scroll no longer 699 // Update layout for valid page transition only since over-scroll no longer
700 // animates app icons. 700 // animates app icons.
701 const PaginationModel::Transition& transition = 701 const PaginationModel::Transition& transition =
702 pagination_model_->transition(); 702 pagination_model_->transition();
703 if (pagination_model_->is_valid_page(transition.target_page)) 703 if (pagination_model_->is_valid_page(transition.target_page))
704 Layout(); 704 Layout();
705 } 705 }
706 706
707 } // namespace app_list 707 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698