Chromium Code Reviews| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 } | 302 } |
| 303 | 303 |
| 304 Browser* PanelBrowserView::GetPanelBrowser() const { | 304 Browser* PanelBrowserView::GetPanelBrowser() const { |
| 305 return browser(); | 305 return browser(); |
| 306 } | 306 } |
| 307 | 307 |
| 308 void PanelBrowserView::DestroyPanelBrowser() { | 308 void PanelBrowserView::DestroyPanelBrowser() { |
| 309 DestroyBrowser(); | 309 DestroyBrowser(); |
| 310 } | 310 } |
| 311 | 311 |
| 312 NativePanelTesting* PanelBrowserView::GetNativePanelTesting() { | |
| 313 return this; | |
| 314 } | |
| 315 | |
| 316 PanelBrowserFrameView* PanelBrowserView::GetFrameView() const { | 312 PanelBrowserFrameView* PanelBrowserView::GetFrameView() const { |
| 317 return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView()); | 313 return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView()); |
| 318 } | 314 } |
| 319 | 315 |
| 320 bool PanelBrowserView::OnTitleBarMousePressed(const views::MouseEvent& event) { | 316 bool PanelBrowserView::OnTitleBarMousePressed(const views::MouseEvent& event) { |
| 321 if (!event.IsOnlyLeftMouseButton()) | 317 if (!event.IsOnlyLeftMouseButton()) |
| 322 return false; | 318 return false; |
| 323 mouse_pressed_ = true; | 319 mouse_pressed_ = true; |
| 324 mouse_pressed_point_ = event.location(); | 320 mouse_pressed_point_ = event.location(); |
| 325 mouse_dragging_ = false; | 321 mouse_dragging_ = false; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 if (!mouse_pressed_) | 366 if (!mouse_pressed_) |
| 371 return false; | 367 return false; |
| 372 mouse_pressed_ = false; | 368 mouse_pressed_ = false; |
| 373 | 369 |
| 374 if (!mouse_dragging_) | 370 if (!mouse_dragging_) |
| 375 cancelled = true; | 371 cancelled = true; |
| 376 mouse_dragging_ = false; | 372 mouse_dragging_ = false; |
| 377 panel_->manager()->EndDragging(cancelled); | 373 panel_->manager()->EndDragging(cancelled); |
| 378 return true; | 374 return true; |
| 379 } | 375 } |
| 376 | |
| 377 // NativePanelTesting implementation. | |
| 378 class NativePanelTestingWin : public NativePanelTesting { | |
| 379 public: | |
| 380 explicit NativePanelTestingWin(PanelBrowserView* panel_browser_view); | |
| 381 | |
| 382 private: | |
| 383 virtual void TitlebarLeftButtonPress(gfx::Point point) OVERRIDE; | |
| 384 virtual void TitlebarLeftButtonRelease() OVERRIDE; | |
| 385 virtual void TitlebarDrag(int delta_x, int delta_y) OVERRIDE; | |
| 386 virtual void TitlebarCancelDrag() OVERRIDE; | |
| 387 virtual void TitlebarFinishDrag() OVERRIDE; | |
| 388 | |
| 389 PanelBrowserView* panel_browser_view_; | |
| 390 }; | |
| 391 | |
| 392 NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { | |
| 393 return new NativePanelTestingWin(static_cast<PanelBrowserView*>( | |
| 394 native_panel)); | |
| 395 } | |
| 396 | |
| 397 NativePanelTestingWin::NativePanelTestingWin( | |
| 398 PanelBrowserView* panel_browser_view) : | |
| 399 panel_browser_view_(panel_browser_view) { | |
| 400 } | |
| 401 | |
| 402 void NativePanelTestingWin::TitlebarLeftButtonPress(gfx::Point point) { | |
| 403 views::MouseEvent pressed(ui::ET_MOUSE_PRESSED, point.x(), point.y(), | |
| 404 ui::EF_LEFT_BUTTON_DOWN); | |
| 405 panel_browser_view_->OnTitleBarMousePressed(pressed); | |
|
jianli
2011/08/09 21:10:23
It seems to me that we can refactor PanelBrowserVi
prasadt
2011/08/09 23:05:04
Wouldn't it be better to leave it the way it is in
jianli
2011/08/09 23:24:16
I rather worry about it later since it is more imp
prasadt
2011/08/09 23:49:41
I started making the change and then saw that you'
prasadt
2011/08/11 00:26:41
Made the changes following our offline chat. Plea
| |
| 406 } | |
| 407 | |
| 408 void NativePanelTestingWin::TitlebarLeftButtonRelease() { | |
| 409 views::MouseEvent released(ui::ET_MOUSE_RELEASED, 0, 0, 0); | |
| 410 panel_browser_view_->OnTitleBarMouseReleased(released); | |
| 411 } | |
| 412 | |
| 413 void NativePanelTestingWin::TitlebarDrag(int delta_x, int delta_y) { | |
| 414 gfx::Rect current_bounds = panel_browser_view_->GetRestoredBounds(); | |
| 415 views::MouseEvent dragged(ui::ET_MOUSE_DRAGGED, | |
| 416 current_bounds.x() + delta_x, | |
| 417 current_bounds.y() + delta_y, | |
| 418 ui::EF_LEFT_BUTTON_DOWN); | |
| 419 panel_browser_view_->OnTitleBarMouseDragged(dragged); | |
| 420 } | |
| 421 | |
| 422 void NativePanelTestingWin::TitlebarCancelDrag() { | |
| 423 panel_browser_view_->OnTitleBarMouseCaptureLost(); | |
| 424 } | |
| 425 | |
| 426 void NativePanelTestingWin::TitlebarFinishDrag() { | |
| 427 views::MouseEvent released(ui::ET_MOUSE_RELEASED, 0, 0, 0); | |
| 428 panel_browser_view_->OnTitleBarMouseReleased(released); | |
| 429 } | |
| OLD | NEW |