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

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

Issue 10446090: Changes the tabstrip dragging code to use coordinates from the events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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_strip.h ('k') | chrome/browser/ui/views/tabs/tab_unittest.cc » ('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_strip.h" 5 #include "chrome/browser/ui/views/tabs/tab_strip.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 // It doesn't make sense to drag tabs out on metro. 978 // It doesn't make sense to drag tabs out on metro.
979 if (base::win::GetMetroModule()) 979 if (base::win::GetMetroModule())
980 detach_behavior = TabDragController::NOT_DETACHABLE; 980 detach_behavior = TabDragController::NOT_DETACHABLE;
981 #endif 981 #endif
982 drag_controller_.reset(new TabDragController); 982 drag_controller_.reset(new TabDragController);
983 drag_controller_->Init( 983 drag_controller_->Init(
984 this, tab, tabs, gfx::Point(x, y), tab->GetMirroredXInView(event.x()), 984 this, tab, tabs, gfx::Point(x, y), tab->GetMirroredXInView(event.x()),
985 selection_model, detach_behavior, move_behavior); 985 selection_model, detach_behavior, move_behavior);
986 } 986 }
987 987
988 void TabStrip::ContinueDrag(const views::MouseEvent& event) { 988 void TabStrip::ContinueDrag(views::View* view, const gfx::Point& location) {
989 if (drag_controller_.get()) 989 if (drag_controller_.get()) {
990 drag_controller_->Drag(); 990 gfx::Point screen_location(location);
991 views::View::ConvertPointToScreen(view, &screen_location);
992 drag_controller_->Drag(screen_location);
993 }
991 } 994 }
992 995
993 bool TabStrip::EndDrag(bool canceled) { 996 bool TabStrip::EndDrag(bool canceled) {
994 if (!drag_controller_.get()) 997 if (!drag_controller_.get())
995 return false; 998 return false;
996 bool started_drag = drag_controller_->started_drag(); 999 bool started_drag = drag_controller_->started_drag();
997 drag_controller_->EndDrag(canceled); 1000 drag_controller_->EndDrag(canceled);
998 return started_drag; 1001 return started_drag;
999 } 1002 }
1000 1003
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 return View::GetViewByID(view_id); 1306 return View::GetViewByID(view_id);
1304 } 1307 }
1305 1308
1306 bool TabStrip::OnMousePressed(const views::MouseEvent& event) { 1309 bool TabStrip::OnMousePressed(const views::MouseEvent& event) {
1307 UpdateLayoutTypeFromMouseEvent(this, event); 1310 UpdateLayoutTypeFromMouseEvent(this, event);
1308 // We can't return true here, else clicking in an empty area won't drag the 1311 // We can't return true here, else clicking in an empty area won't drag the
1309 // window. 1312 // window.
1310 return false; 1313 return false;
1311 } 1314 }
1312 1315
1313 bool TabStrip::OnMouseDragged(const views::MouseEvent& event) { 1316 bool TabStrip::OnMouseDragged(const views::MouseEvent& event) {
1314 if (drag_controller_.get()) 1317 ContinueDrag(this, event.location());
1315 drag_controller_->Drag();
1316 return true; 1318 return true;
1317 } 1319 }
1318 1320
1319 void TabStrip::OnMouseReleased(const views::MouseEvent& event) { 1321 void TabStrip::OnMouseReleased(const views::MouseEvent& event) {
1320 EndDrag(false); 1322 EndDrag(false);
1321 UpdateLayoutTypeFromMouseEvent(this, event); 1323 UpdateLayoutTypeFromMouseEvent(this, event);
1322 } 1324 }
1323 1325
1324 void TabStrip::OnMouseCaptureLost() { 1326 void TabStrip::OnMouseCaptureLost() {
1325 EndDrag(true); 1327 EndDrag(true);
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
2205 } 2207 }
2206 return NULL; 2208 return NULL;
2207 } 2209 }
2208 2210
2209 std::vector<int> TabStrip::GetTabXCoordinates() { 2211 std::vector<int> TabStrip::GetTabXCoordinates() {
2210 std::vector<int> results; 2212 std::vector<int> results;
2211 for (int i = 0; i < tab_count(); ++i) 2213 for (int i = 0; i < tab_count(); ++i)
2212 results.push_back(ideal_bounds(i).x()); 2214 results.push_back(ideal_bounds(i).x());
2213 return results; 2215 return results;
2214 } 2216 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.h ('k') | chrome/browser/ui/views/tabs/tab_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698