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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller.cc

Issue 10828265: Replace views::LocatedEvent with ui::LocatedEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_controller.h ('k') | chrome/browser/ui/views/tabs/tab_strip.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/ui/views/tabs/tab_drag_controller.h" 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 base::TimeDelta::FromMilliseconds(delay_ms), 985 base::TimeDelta::FromMilliseconds(delay_ms),
986 base::Bind(&TabDragController::MoveAttachedToPreviousStackedIndex, 986 base::Bind(&TabDragController::MoveAttachedToPreviousStackedIndex,
987 base::Unretained(this), point_in_screen)); 987 base::Unretained(this), point_in_screen));
988 } 988 }
989 } 989 }
990 990
991 TabDragController::DetachPosition TabDragController::GetDetachPosition( 991 TabDragController::DetachPosition TabDragController::GetDetachPosition(
992 const gfx::Point& point_in_screen) { 992 const gfx::Point& point_in_screen) {
993 DCHECK(attached_tabstrip_); 993 DCHECK(attached_tabstrip_);
994 gfx::Point attached_point(point_in_screen); 994 gfx::Point attached_point(point_in_screen);
995 views::View::ConvertPointToView(NULL, attached_tabstrip_, &attached_point); 995 views::View::ConvertPointToTarget(NULL, attached_tabstrip_, &attached_point);
996 if (attached_point.x() < 0) 996 if (attached_point.x() < 0)
997 return DETACH_BEFORE; 997 return DETACH_BEFORE;
998 if (attached_point.x() >= attached_tabstrip_->width()) 998 if (attached_point.x() >= attached_tabstrip_->width())
999 return DETACH_AFTER; 999 return DETACH_AFTER;
1000 return DETACH_ABOVE_OR_BELOW; 1000 return DETACH_ABOVE_OR_BELOW;
1001 } 1001 }
1002 1002
1003 DockInfo TabDragController::GetDockInfoAtPoint( 1003 DockInfo TabDragController::GetDockInfoAtPoint(
1004 const gfx::Point& point_in_screen) { 1004 const gfx::Point& point_in_screen) {
1005 // TODO: add support for dock info when |detach_into_browser_| is true. 1005 // TODO: add support for dock info when |detach_into_browser_| is true.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 1117
1118 // Inserting counts as a move. We don't want the tabs to jitter when the 1118 // Inserting counts as a move. We don't want the tabs to jitter when the
1119 // user moves the tab immediately after attaching it. 1119 // user moves the tab immediately after attaching it.
1120 last_move_screen_loc_ = point_in_screen.x(); 1120 last_move_screen_loc_ = point_in_screen.x();
1121 1121
1122 // Figure out where to insert the tab based on the bounds of the dragged 1122 // Figure out where to insert the tab based on the bounds of the dragged
1123 // representation and the ideal bounds of the other Tabs already in the 1123 // representation and the ideal bounds of the other Tabs already in the
1124 // strip. ("ideal bounds" are stable even if the Tabs' actual bounds are 1124 // strip. ("ideal bounds" are stable even if the Tabs' actual bounds are
1125 // changing due to animation). 1125 // changing due to animation).
1126 gfx::Point tab_strip_point(point_in_screen); 1126 gfx::Point tab_strip_point(point_in_screen);
1127 views::View::ConvertPointToView(NULL, attached_tabstrip_, &tab_strip_point); 1127 views::View::ConvertPointToTarget(NULL, attached_tabstrip_,
1128 &tab_strip_point);
1128 tab_strip_point.set_x( 1129 tab_strip_point.set_x(
1129 attached_tabstrip_->GetMirroredXInView(tab_strip_point.x())); 1130 attached_tabstrip_->GetMirroredXInView(tab_strip_point.x()));
1130 tab_strip_point.Offset(-mouse_offset_.x(), -mouse_offset_.y()); 1131 tab_strip_point.Offset(-mouse_offset_.x(), -mouse_offset_.y());
1131 gfx::Rect bounds = GetDraggedViewTabStripBounds(tab_strip_point); 1132 gfx::Rect bounds = GetDraggedViewTabStripBounds(tab_strip_point);
1132 int index = GetInsertionIndexForDraggedBounds(bounds); 1133 int index = GetInsertionIndexForDraggedBounds(bounds);
1133 for (size_t i = 0; i < drag_data_.size(); ++i) { 1134 for (size_t i = 0; i < drag_data_.size(); ++i) {
1134 int add_types = TabStripModel::ADD_NONE; 1135 int add_types = TabStripModel::ADD_NONE;
1135 if (attached_tabstrip_->touch_layout_.get()) { 1136 if (attached_tabstrip_->touch_layout_.get()) {
1136 // TouchTabStripLayout positions relative to the active tab, if we don't 1137 // TouchTabStripLayout positions relative to the active tab, if we don't
1137 // add the tab as active things bounce around. 1138 // add the tab as active things bounce around.
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 return gfx::Rect(tab_strip_point.x(), tab_strip_point.y(), 1485 return gfx::Rect(tab_strip_point.x(), tab_strip_point.y(),
1485 static_cast<int>(sel_width), 1486 static_cast<int>(sel_width),
1486 Tab::GetStandardSize().height()); 1487 Tab::GetStandardSize().height());
1487 } 1488 }
1488 1489
1489 gfx::Point TabDragController::GetAttachedDragPoint( 1490 gfx::Point TabDragController::GetAttachedDragPoint(
1490 const gfx::Point& point_in_screen) { 1491 const gfx::Point& point_in_screen) {
1491 DCHECK(attached_tabstrip_); // The tab must be attached. 1492 DCHECK(attached_tabstrip_); // The tab must be attached.
1492 1493
1493 gfx::Point tab_loc(point_in_screen); 1494 gfx::Point tab_loc(point_in_screen);
1494 views::View::ConvertPointToView(NULL, attached_tabstrip_, &tab_loc); 1495 views::View::ConvertPointToTarget(NULL, attached_tabstrip_, &tab_loc);
1495 int x = 1496 int x =
1496 attached_tabstrip_->GetMirroredXInView(tab_loc.x()) - mouse_offset_.x(); 1497 attached_tabstrip_->GetMirroredXInView(tab_loc.x()) - mouse_offset_.x();
1497 1498
1498 // TODO: consider caching this. 1499 // TODO: consider caching this.
1499 std::vector<BaseTab*> attached_tabs; 1500 std::vector<BaseTab*> attached_tabs;
1500 for (size_t i = 0; i < drag_data_.size(); ++i) 1501 for (size_t i = 0; i < drag_data_.size(); ++i)
1501 attached_tabs.push_back(drag_data_[i].attached_tab); 1502 attached_tabs.push_back(drag_data_[i].attached_tab);
1502 int size = attached_tabstrip_->GetSizeNeededForTabs(attached_tabs); 1503 int size = attached_tabstrip_->GetSizeNeededForTabs(attached_tabs);
1503 int max_x = attached_tabstrip_->width() - size; 1504 int max_x = attached_tabstrip_->width() - size;
1504 return gfx::Point(std::min(std::max(x, 0), max_x), 0); 1505 return gfx::Point(std::min(std::max(x, 0), max_x), 0);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 gfx::Point touch_point; 1958 gfx::Point touch_point;
1958 bool got_touch_point = widget_window->GetRootWindow()-> 1959 bool got_touch_point = widget_window->GetRootWindow()->
1959 gesture_recognizer()->GetLastTouchPointForTarget(widget_window, 1960 gesture_recognizer()->GetLastTouchPointForTarget(widget_window,
1960 &touch_point); 1961 &touch_point);
1961 DCHECK(got_touch_point); 1962 DCHECK(got_touch_point);
1962 return touch_point; 1963 return touch_point;
1963 } 1964 }
1964 #endif 1965 #endif
1965 return gfx::Screen::GetCursorScreenPoint(); 1966 return gfx::Screen::GetCursorScreenPoint();
1966 } 1967 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_controller.h ('k') | chrome/browser/ui/views/tabs/tab_strip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698