| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/panels/panel_browser_view.h" | 5 #include "chrome/browser/ui/panels/panel_browser_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/ui/panels/panel.h" | 8 #include "chrome/browser/ui/panels/panel.h" |
| 9 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" | 9 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
| 10 #include "chrome/browser/ui/panels/panel_manager.h" | 10 #include "chrome/browser/ui/panels/panel_manager.h" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 mouse_pressed_ = true; | 325 mouse_pressed_ = true; |
| 326 mouse_pressed_point_ = location; | 326 mouse_pressed_point_ = location; |
| 327 mouse_dragging_ = false; | 327 mouse_dragging_ = false; |
| 328 return true; | 328 return true; |
| 329 } | 329 } |
| 330 | 330 |
| 331 bool PanelBrowserView::OnTitlebarMouseDragged(const gfx::Point& location) { | 331 bool PanelBrowserView::OnTitlebarMouseDragged(const gfx::Point& location) { |
| 332 if (!mouse_pressed_) | 332 if (!mouse_pressed_) |
| 333 return false; | 333 return false; |
| 334 | 334 |
| 335 // We do not allow dragging vertically. | |
| 336 int delta_x = location.x() - mouse_pressed_point_.x(); | 335 int delta_x = location.x() - mouse_pressed_point_.x(); |
| 337 if (!mouse_dragging_ && ExceededDragThreshold(delta_x, 0)) { | 336 int delta_y = location.y() - mouse_pressed_point_.y(); |
| 337 if (!mouse_dragging_ && ExceededDragThreshold(delta_x, delta_y)) { |
| 338 panel_->manager()->StartDragging(panel_.get()); | 338 panel_->manager()->StartDragging(panel_.get()); |
| 339 mouse_dragging_ = true; | 339 mouse_dragging_ = true; |
| 340 } | 340 } |
| 341 if (mouse_dragging_) | 341 if (mouse_dragging_) |
| 342 panel_->manager()->Drag(delta_x); | 342 panel_->manager()->Drag(delta_x); |
| 343 return true; | 343 return true; |
| 344 } | 344 } |
| 345 | 345 |
| 346 bool PanelBrowserView::OnTitlebarMouseReleased() { | 346 bool PanelBrowserView::OnTitlebarMouseReleased() { |
| 347 if (mouse_dragging_) | 347 if (mouse_dragging_) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 void NativePanelTestingWin::PressLeftMouseButtonTitlebar( | 412 void NativePanelTestingWin::PressLeftMouseButtonTitlebar( |
| 413 const gfx::Point& point) { | 413 const gfx::Point& point) { |
| 414 panel_browser_view_->OnTitlebarMousePressed(point); | 414 panel_browser_view_->OnTitlebarMousePressed(point); |
| 415 } | 415 } |
| 416 | 416 |
| 417 void NativePanelTestingWin::ReleaseMouseButtonTitlebar() { | 417 void NativePanelTestingWin::ReleaseMouseButtonTitlebar() { |
| 418 panel_browser_view_->OnTitlebarMouseReleased(); | 418 panel_browser_view_->OnTitlebarMouseReleased(); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void NativePanelTestingWin::DragTitlebar(int delta_x, int delta_y) { | 421 void NativePanelTestingWin::DragTitlebar(int delta_x, int delta_y) { |
| 422 gfx::Rect current_bounds = panel_browser_view_->panel()->GetRestoredBounds(); | 422 // TODO(jianli): Need a comment here that explains why we use |
| 423 // mouse_pressed_point_ and not current bounds as obtained by |
| 424 // GetRestoredBounds(). |
| 423 panel_browser_view_->OnTitlebarMouseDragged(gfx::Point( | 425 panel_browser_view_->OnTitlebarMouseDragged(gfx::Point( |
| 424 current_bounds.x() + delta_x, current_bounds.y() + delta_y)); | 426 panel_browser_view_->mouse_pressed_point_.x() + delta_x, |
| 427 panel_browser_view_->mouse_pressed_point_.y() + delta_y)); |
| 425 } | 428 } |
| 426 | 429 |
| 427 void NativePanelTestingWin::CancelDragTitlebar() { | 430 void NativePanelTestingWin::CancelDragTitlebar() { |
| 428 panel_browser_view_->OnTitlebarMouseCaptureLost(); | 431 panel_browser_view_->OnTitlebarMouseCaptureLost(); |
| 429 } | 432 } |
| 430 | 433 |
| 431 void NativePanelTestingWin::FinishDragTitlebar() { | 434 void NativePanelTestingWin::FinishDragTitlebar() { |
| 432 panel_browser_view_->OnTitlebarMouseReleased(); | 435 panel_browser_view_->OnTitlebarMouseReleased(); |
| 433 } | 436 } |
| OLD | NEW |