| OLD | NEW |
| 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/panels/panel_frame_view.h" | 5 #include "chrome/browser/ui/views/panels/panel_frame_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/panels/panel.h" | 7 #include "chrome/browser/ui/panels/panel.h" |
| 8 #include "chrome/browser/ui/panels/panel_constants.h" | 8 #include "chrome/browser/ui/panels/panel_constants.h" |
| 9 #include "chrome/browser/ui/views/panels/panel_view.h" | 9 #include "chrome/browser/ui/views/panels/panel_view.h" |
| 10 #include "chrome/browser/ui/views/tab_icon_view.h" | 10 #include "chrome/browser/ui/views/tab_icon_view.h" |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 void PanelFrameView::OnPaint(gfx::Canvas* canvas) { | 554 void PanelFrameView::OnPaint(gfx::Canvas* canvas) { |
| 555 UpdateControlStyles(GetPaintState()); | 555 UpdateControlStyles(GetPaintState()); |
| 556 PaintFrameBackground(canvas); | 556 PaintFrameBackground(canvas); |
| 557 PaintFrameEdge(canvas); | 557 PaintFrameEdge(canvas); |
| 558 } | 558 } |
| 559 | 559 |
| 560 bool PanelFrameView::OnMousePressed(const ui::MouseEvent& event) { | 560 bool PanelFrameView::OnMousePressed(const ui::MouseEvent& event) { |
| 561 if (event.IsOnlyLeftMouseButton()) { | 561 if (event.IsOnlyLeftMouseButton()) { |
| 562 // |event.location| is in the view's coordinate system. Convert it to the | 562 // |event.location| is in the view's coordinate system. Convert it to the |
| 563 // screen coordinate system. | 563 // screen coordinate system. |
| 564 gfx::Point mouse_location = event.location(); | 564 gfx::Point mouse_location = gfx::ToFlooredPoint(event.location()); |
| 565 views::View::ConvertPointToScreen(this, &mouse_location); | 565 views::View::ConvertPointToScreen(this, &mouse_location); |
| 566 | 566 |
| 567 // If the mouse location falls within the resizing area of the titlebar, | 567 // If the mouse location falls within the resizing area of the titlebar, |
| 568 // do not handle the event so that the system resizing logic could kick in. | 568 // do not handle the event so that the system resizing logic could kick in. |
| 569 if (!panel_view_->IsWithinResizingArea(mouse_location) && | 569 if (!panel_view_->IsWithinResizingArea(mouse_location) && |
| 570 panel_view_->OnTitlebarMousePressed(mouse_location)) | 570 panel_view_->OnTitlebarMousePressed(mouse_location)) |
| 571 return true; | 571 return true; |
| 572 } | 572 } |
| 573 return NonClientFrameView::OnMousePressed(event); | 573 return NonClientFrameView::OnMousePressed(event); |
| 574 } | 574 } |
| 575 | 575 |
| 576 bool PanelFrameView::OnMouseDragged(const ui::MouseEvent& event) { | 576 bool PanelFrameView::OnMouseDragged(const ui::MouseEvent& event) { |
| 577 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 577 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 578 // Converting the mouse location to screen coordinates returns an incorrect | 578 // Converting the mouse location to screen coordinates returns an incorrect |
| 579 // location while the panel is moving. See crbug.com/353393 for more details. | 579 // location while the panel is moving. See crbug.com/353393 for more details. |
| 580 // TODO(pkotwicz): Fix conversion to screen coordinates | 580 // TODO(pkotwicz): Fix conversion to screen coordinates |
| 581 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); | 581 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); |
| 582 gfx::Point mouse_location = screen->GetCursorScreenPoint(); | 582 gfx::Point mouse_location = screen->GetCursorScreenPoint(); |
| 583 #else | 583 #else |
| 584 // |event.location| is in the view's coordinate system. Convert it to the | 584 // |event.location| is in the view's coordinate system. Convert it to the |
| 585 // screen coordinate system. | 585 // screen coordinate system. |
| 586 gfx::Point mouse_location = event.location(); | 586 gfx::Point mouse_location = gfx::ToFlooredPoint(event.location()); |
| 587 views::View::ConvertPointToScreen(this, &mouse_location); | 587 views::View::ConvertPointToScreen(this, &mouse_location); |
| 588 #endif | 588 #endif |
| 589 | 589 |
| 590 if (panel_view_->OnTitlebarMouseDragged(mouse_location)) | 590 if (panel_view_->OnTitlebarMouseDragged(mouse_location)) |
| 591 return true; | 591 return true; |
| 592 return NonClientFrameView::OnMouseDragged(event); | 592 return NonClientFrameView::OnMouseDragged(event); |
| 593 } | 593 } |
| 594 | 594 |
| 595 void PanelFrameView::OnMouseReleased(const ui::MouseEvent& event) { | 595 void PanelFrameView::OnMouseReleased(const ui::MouseEvent& event) { |
| 596 if (panel_view_->OnTitlebarMouseReleased( | 596 if (panel_view_->OnTitlebarMouseReleased( |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 | 759 |
| 760 // Draw the left border. | 760 // Draw the left border. |
| 761 canvas->TileImageInt(left_image, | 761 canvas->TileImageInt(left_image, |
| 762 0, | 762 0, |
| 763 top_left_image.height(), | 763 top_left_image.height(), |
| 764 left_image.width(), | 764 left_image.width(), |
| 765 height() - top_left_image.height() - | 765 height() - top_left_image.height() - |
| 766 bottom_left_image.height()); | 766 bottom_left_image.height()); |
| 767 #endif | 767 #endif |
| 768 } | 768 } |
| OLD | NEW |