Chromium Code Reviews| 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" |
| 11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
| 13 #include "grit/theme_resources.h" | 13 #include "grit/theme_resources.h" |
| 14 #include "grit/ui_resources.h" | 14 #include "grit/ui_resources.h" |
| 15 #include "ui/base/hit_test.h" | 15 #include "ui/base/hit_test.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
| 19 #include "ui/gfx/font_list.h" | 19 #include "ui/gfx/font_list.h" |
| 20 #include "ui/gfx/path.h" | 20 #include "ui/gfx/path.h" |
| 21 #include "ui/views/controls/button/image_button.h" | 21 #include "ui/views/controls/button/image_button.h" |
| 22 #include "ui/views/controls/label.h" | 22 #include "ui/views/controls/label.h" |
| 23 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 24 #include "ui/views/widget/widget_delegate.h" | 24 #include "ui/views/widget/widget_delegate.h" |
| 25 | 25 |
| 26 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 27 #include <X11/extensions/XInput2.h> | |
| 28 #include <X11/Xlib.h> | |
| 29 #endif | |
| 30 | |
| 26 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 27 #include "base/win/scoped_gdi_object.h" | 32 #include "base/win/scoped_gdi_object.h" |
| 28 #include "ui/base/win/shell.h" | 33 #include "ui/base/win/shell.h" |
| 29 #include "ui/gfx/path_win.h" | 34 #include "ui/gfx/path_win.h" |
| 30 #include "ui/views/win/hwnd_util.h" | 35 #include "ui/views/win/hwnd_util.h" |
| 31 #endif | 36 #endif |
| 32 | 37 |
| 33 #if defined(USE_AURA) | 38 #if defined(USE_AURA) |
| 34 #include "ui/aura/window.h" | 39 #include "ui/aura/window.h" |
| 35 #endif | 40 #endif |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 52 const SkColor kInactiveBackgroundDefaultColor = SkColorSetRGB(0x7a, 0x7c, 0x7c); | 57 const SkColor kInactiveBackgroundDefaultColor = SkColorSetRGB(0x7a, 0x7c, 0x7c); |
| 53 const SkColor kAttentionBackgroundDefaultColor = | 58 const SkColor kAttentionBackgroundDefaultColor = |
| 54 SkColorSetRGB(0x53, 0xa9, 0x3f); | 59 SkColorSetRGB(0x53, 0xa9, 0x3f); |
| 55 | 60 |
| 56 // Color used to draw the minimized panel. | 61 // Color used to draw the minimized panel. |
| 57 const SkColor kMinimizeBackgroundDefaultColor = SkColorSetRGB(0xf5, 0xf4, 0xf0); | 62 const SkColor kMinimizeBackgroundDefaultColor = SkColorSetRGB(0xf5, 0xf4, 0xf0); |
| 58 | 63 |
| 59 // Color used to draw the title text under default theme. | 64 // Color used to draw the title text under default theme. |
| 60 const SkColor kTitleTextDefaultColor = SkColorSetRGB(0xf9, 0xf9, 0xf9); | 65 const SkColor kTitleTextDefaultColor = SkColorSetRGB(0xf9, 0xf9, 0xf9); |
| 61 | 66 |
| 67 #if defined(USE_X11) && !defined(OS_CHROMEOS) | |
|
pkotwicz
2014/03/18 02:48:26
I did not put this method in events_x.cc because I
| |
| 68 // Extracts the position in screen coordinates from |native_event|. | |
| 69 gfx::Point GetEventLocationInScreenFromNative( | |
| 70 const base::NativeEvent& native_event) { | |
| 71 switch (native_event->type) { | |
| 72 case MotionNotify: | |
| 73 return gfx::Point(native_event->xmotion.x_root, | |
| 74 native_event->xmotion.y_root); | |
| 75 case GenericEvent: { | |
| 76 XIDeviceEvent* xievent = | |
| 77 static_cast<XIDeviceEvent*>(native_event->xcookie.data); | |
| 78 return gfx::Point(static_cast<int>(xievent->root_x), | |
| 79 static_cast<int>(xievent->root_y)); | |
| 80 } | |
| 81 } | |
| 82 NOTREACHED(); | |
| 83 return gfx::Point(); | |
| 84 } | |
| 85 #endif | |
| 86 | |
| 62 gfx::ImageSkia* CreateImageForColor(SkColor color) { | 87 gfx::ImageSkia* CreateImageForColor(SkColor color) { |
| 63 gfx::Canvas canvas(gfx::Size(1, 1), 1.0f, true); | 88 gfx::Canvas canvas(gfx::Size(1, 1), 1.0f, true); |
| 64 canvas.DrawColor(color); | 89 canvas.DrawColor(color); |
| 65 return new gfx::ImageSkia(canvas.ExtractImageRep()); | 90 return new gfx::ImageSkia(canvas.ExtractImageRep()); |
| 66 } | 91 } |
| 67 | 92 |
| 68 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
| 69 const gfx::ImageSkia& GetTopLeftCornerImage(panel::CornerStyle corner_style) { | 94 const gfx::ImageSkia& GetTopLeftCornerImage(panel::CornerStyle corner_style) { |
| 70 static gfx::ImageSkia* rounded_image = NULL; | 95 static gfx::ImageSkia* rounded_image = NULL; |
| 71 static gfx::ImageSkia* non_rounded_image = NULL; | 96 static gfx::ImageSkia* non_rounded_image = NULL; |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 // If the mouse location falls within the resizing area of the titlebar, | 596 // If the mouse location falls within the resizing area of the titlebar, |
| 572 // do not handle the event so that the system resizing logic could kick in. | 597 // do not handle the event so that the system resizing logic could kick in. |
| 573 if (!panel_view_->IsWithinResizingArea(mouse_location) && | 598 if (!panel_view_->IsWithinResizingArea(mouse_location) && |
| 574 panel_view_->OnTitlebarMousePressed(mouse_location)) | 599 panel_view_->OnTitlebarMousePressed(mouse_location)) |
| 575 return true; | 600 return true; |
| 576 } | 601 } |
| 577 return NonClientFrameView::OnMousePressed(event); | 602 return NonClientFrameView::OnMousePressed(event); |
| 578 } | 603 } |
| 579 | 604 |
| 580 bool PanelFrameView::OnMouseDragged(const ui::MouseEvent& event) { | 605 bool PanelFrameView::OnMouseDragged(const ui::MouseEvent& event) { |
| 606 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 607 // Converting the mouse location to screen coordinates returns an incorrect | |
| 608 // location while the panel is moving. See crbug.com/353393 for more details. | |
| 609 // Get the mouse location in screen coordinates from the base::NativeEvent | |
| 610 // instead. | |
| 611 // TODO(pkotwicz): Fix conversion to screen coordinates | |
| 612 if (event.type() != ui::ET_MOUSE_DRAGGED) | |
| 613 return false; | |
| 614 gfx::Point mouse_location = | |
| 615 GetEventLocationInScreenFromNative(event.native_event()); | |
| 616 #else | |
| 581 // |event.location| is in the view's coordinate system. Convert it to the | 617 // |event.location| is in the view's coordinate system. Convert it to the |
| 582 // screen coordinate system. | 618 // screen coordinate system. |
| 583 gfx::Point mouse_location = event.location(); | 619 gfx::Point mouse_location = event.location(); |
| 584 views::View::ConvertPointToScreen(this, &mouse_location); | 620 views::View::ConvertPointToScreen(this, &mouse_location); |
| 621 #endif | |
| 585 | 622 |
| 586 if (panel_view_->OnTitlebarMouseDragged(mouse_location)) | 623 if (panel_view_->OnTitlebarMouseDragged(mouse_location)) |
| 587 return true; | 624 return true; |
| 588 return NonClientFrameView::OnMouseDragged(event); | 625 return NonClientFrameView::OnMouseDragged(event); |
| 589 } | 626 } |
| 590 | 627 |
| 591 void PanelFrameView::OnMouseReleased(const ui::MouseEvent& event) { | 628 void PanelFrameView::OnMouseReleased(const ui::MouseEvent& event) { |
| 592 if (panel_view_->OnTitlebarMouseReleased( | 629 if (panel_view_->OnTitlebarMouseReleased( |
| 593 event.IsControlDown() ? panel::APPLY_TO_ALL : panel::NO_MODIFIER)) | 630 event.IsControlDown() ? panel::APPLY_TO_ALL : panel::NO_MODIFIER)) |
| 594 return; | 631 return; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 | 792 |
| 756 // Draw the left border. | 793 // Draw the left border. |
| 757 canvas->TileImageInt(left_image, | 794 canvas->TileImageInt(left_image, |
| 758 0, | 795 0, |
| 759 top_left_image.height(), | 796 top_left_image.height(), |
| 760 left_image.width(), | 797 left_image.width(), |
| 761 height() - top_left_image.height() - | 798 height() - top_left_image.height() - |
| 762 bottom_left_image.height()); | 799 bottom_left_image.height()); |
| 763 #endif | 800 #endif |
| 764 } | 801 } |
| OLD | NEW |