Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_browser_view.cc |
| diff --git a/chrome/browser/ui/panels/panel_browser_view.cc b/chrome/browser/ui/panels/panel_browser_view.cc |
| index 748a4897c69915fe2417fe32322c4a6d91cc37f4..fc2b33042470d77c8e03d659c48faf1703d30b28 100644 |
| --- a/chrome/browser/ui/panels/panel_browser_view.cc |
| +++ b/chrome/browser/ui/panels/panel_browser_view.cc |
| @@ -309,29 +309,23 @@ void PanelBrowserView::DestroyPanelBrowser() { |
| DestroyBrowser(); |
| } |
| -NativePanelTesting* PanelBrowserView::GetNativePanelTesting() { |
| - return this; |
| -} |
| - |
| PanelBrowserFrameView* PanelBrowserView::GetFrameView() const { |
| return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView()); |
| } |
| -bool PanelBrowserView::OnTitleBarMousePressed(const views::MouseEvent& event) { |
| - if (!event.IsOnlyLeftMouseButton()) |
| - return false; |
| +bool PanelBrowserView::OnTitleBarMousePressed(const gfx::Point& location) { |
| mouse_pressed_ = true; |
| - mouse_pressed_point_ = event.location(); |
| + mouse_pressed_point_ = location; |
| mouse_dragging_ = false; |
| return true; |
| } |
| -bool PanelBrowserView::OnTitleBarMouseDragged(const views::MouseEvent& event) { |
| +bool PanelBrowserView::OnTitleBarMouseDragged(const gfx::Point& location) { |
| if (!mouse_pressed_) |
| return false; |
| // We do not allow dragging vertically. |
| - int delta_x = event.location().x() - mouse_pressed_point_.x(); |
| + int delta_x = location.x() - mouse_pressed_point_.x(); |
| if (!mouse_dragging_ && ExceededDragThreshold(delta_x, 0)) { |
| panel_->manager()->StartDragging(panel_.get()); |
| mouse_dragging_ = true; |
| @@ -341,7 +335,7 @@ bool PanelBrowserView::OnTitleBarMouseDragged(const views::MouseEvent& event) { |
| return true; |
| } |
| -bool PanelBrowserView::OnTitleBarMouseReleased(const views::MouseEvent& event) { |
| +bool PanelBrowserView::OnTitleBarMouseReleased() { |
| if (mouse_dragging_) |
| return EndDragging(false); |
| @@ -377,3 +371,52 @@ bool PanelBrowserView::EndDragging(bool cancelled) { |
| panel_->manager()->EndDragging(cancelled); |
| return true; |
| } |
| + |
| +// NativePanelTesting implementation. |
| +class NativePanelTestingWin : public NativePanelTesting { |
|
jianli
2011/08/11 20:52:09
Please move this subclass to the anonymous namespa
prasadt
2011/08/11 21:07:56
Need this class in header file.
|
| + public: |
| + explicit NativePanelTestingWin(PanelBrowserView* panel_browser_view); |
| + |
| + private: |
| + virtual void PressLeftMouseButtonTitlebar( |
| + const gfx::Point& point) OVERRIDE; |
| + virtual void ReleaseMouseButtonTitlebar() OVERRIDE; |
| + virtual void DragTitlebar(int delta_x, int delta_y) OVERRIDE; |
| + virtual void CancelDragTitlebar() OVERRIDE; |
| + virtual void FinishDragTitlebar() OVERRIDE; |
| + |
| + PanelBrowserView* panel_browser_view_; |
| +}; |
| + |
| +NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { |
|
jianli
2011/08/11 20:52:09
Please add the comment like the following:
// st
prasadt
2011/08/11 21:07:56
Done.
|
| + return new NativePanelTestingWin(static_cast<PanelBrowserView*>( |
| + native_panel)); |
| +} |
| + |
| +NativePanelTestingWin::NativePanelTestingWin( |
| + PanelBrowserView* panel_browser_view) : |
| + panel_browser_view_(panel_browser_view) { |
| +} |
| + |
| +void NativePanelTestingWin::PressLeftMouseButtonTitlebar( |
| + const gfx::Point& point) { |
| + panel_browser_view_->OnTitleBarMousePressed(point); |
| +} |
| + |
| +void NativePanelTestingWin::ReleaseMouseButtonTitlebar() { |
| + panel_browser_view_->OnTitleBarMouseReleased(); |
| +} |
| + |
| +void NativePanelTestingWin::DragTitlebar(int delta_x, int delta_y) { |
| + gfx::Rect current_bounds = panel_browser_view_->panel()->GetRestoredBounds(); |
| + panel_browser_view_->OnTitleBarMouseDragged(gfx::Point( |
| + current_bounds.x() + delta_x, current_bounds.y() + delta_y)); |
| +} |
| + |
| +void NativePanelTestingWin::CancelDragTitlebar() { |
| + panel_browser_view_->OnTitleBarMouseCaptureLost(); |
| +} |
| + |
| +void NativePanelTestingWin::FinishDragTitlebar() { |
| + panel_browser_view_->OnTitleBarMouseReleased(); |
| +} |