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 "ash/wm/panels/panel_frame_view.h" | 5 #include "ash/wm/panels/panel_frame_view.h" |
6 | 6 |
7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
8 #include "ash/frame/default_header_painter.h" | 8 #include "ash/frame/default_header_painter.h" |
9 #include "ash/frame/frame_border_hit_test.h" | 9 #include "ash/frame/frame_border_hit_test.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/wm_window.h" | 11 #include "ash/wm/resize_handle_window_targeter.h" |
12 #include "ui/aura/client/aura_constants.h" | 12 #include "ui/aura/client/aura_constants.h" |
13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/base/hit_test.h" | 14 #include "ui/base/hit_test.h" |
15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
16 #include "ui/views/controls/image_view.h" | 16 #include "ui/views/controls/image_view.h" |
17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
18 #include "ui/views/widget/widget_delegate.h" | 18 #include "ui/views/widget/widget_delegate.h" |
19 | 19 |
20 namespace ash { | 20 namespace ash { |
21 | 21 |
22 // static | 22 // static |
23 const char PanelFrameView::kViewClassName[] = "PanelFrameView"; | 23 const char PanelFrameView::kViewClassName[] = "PanelFrameView"; |
24 | 24 |
25 PanelFrameView::PanelFrameView(views::Widget* frame, FrameType frame_type) | 25 PanelFrameView::PanelFrameView(views::Widget* frame, FrameType frame_type) |
26 : frame_(frame), caption_button_container_(nullptr), window_icon_(nullptr) { | 26 : frame_(frame), caption_button_container_(nullptr), window_icon_(nullptr) { |
27 GetWidgetWindow()->InstallResizeHandleWindowTargeter(nullptr); | 27 GetWidgetWindow()->SetEventTargeter( |
| 28 base::MakeUnique<ResizeHandleWindowTargeter>(GetWidgetWindow(), nullptr)); |
28 DCHECK(!frame_->widget_delegate()->CanMaximize()); | 29 DCHECK(!frame_->widget_delegate()->CanMaximize()); |
29 if (frame_type != FRAME_NONE) | 30 if (frame_type != FRAME_NONE) |
30 InitHeaderPainter(); | 31 InitHeaderPainter(); |
31 Shell::Get()->AddShellObserver(this); | 32 Shell::Get()->AddShellObserver(this); |
32 } | 33 } |
33 | 34 |
34 PanelFrameView::~PanelFrameView() { | 35 PanelFrameView::~PanelFrameView() { |
35 Shell::Get()->RemoveShellObserver(this); | 36 Shell::Get()->RemoveShellObserver(this); |
36 } | 37 } |
37 | 38 |
38 void PanelFrameView::SetFrameColors(SkColor active_frame_color, | 39 void PanelFrameView::SetFrameColors(SkColor active_frame_color, |
39 SkColor inactive_frame_color) { | 40 SkColor inactive_frame_color) { |
40 header_painter_->SetFrameColors(active_frame_color, inactive_frame_color); | 41 header_painter_->SetFrameColors(active_frame_color, inactive_frame_color); |
41 GetWidgetWindow()->aura_window()->SetProperty( | 42 GetWidgetWindow()->SetProperty(aura::client::kTopViewColor, |
42 aura::client::kTopViewColor, header_painter_->GetInactiveFrameColor()); | 43 header_painter_->GetInactiveFrameColor()); |
43 } | 44 } |
44 | 45 |
45 const char* PanelFrameView::GetClassName() const { | 46 const char* PanelFrameView::GetClassName() const { |
46 return kViewClassName; | 47 return kViewClassName; |
47 } | 48 } |
48 | 49 |
49 void PanelFrameView::InitHeaderPainter() { | 50 void PanelFrameView::InitHeaderPainter() { |
50 header_painter_.reset(new DefaultHeaderPainter); | 51 header_painter_.reset(new DefaultHeaderPainter); |
51 GetWidgetWindow()->aura_window()->SetProperty( | 52 GetWidgetWindow()->SetProperty(aura::client::kTopViewColor, |
52 aura::client::kTopViewColor, header_painter_->GetInactiveFrameColor()); | 53 header_painter_->GetInactiveFrameColor()); |
53 | 54 |
54 caption_button_container_ = new FrameCaptionButtonContainerView(frame_); | 55 caption_button_container_ = new FrameCaptionButtonContainerView(frame_); |
55 AddChildView(caption_button_container_); | 56 AddChildView(caption_button_container_); |
56 | 57 |
57 header_painter_->Init(frame_, this, caption_button_container_); | 58 header_painter_->Init(frame_, this, caption_button_container_); |
58 | 59 |
59 if (frame_->widget_delegate()->ShouldShowWindowIcon()) { | 60 if (frame_->widget_delegate()->ShouldShowWindowIcon()) { |
60 window_icon_ = new views::ImageView(); | 61 window_icon_ = new views::ImageView(); |
61 AddChildView(window_icon_); | 62 AddChildView(window_icon_); |
62 header_painter_->UpdateLeftHeaderView(window_icon_); | 63 header_painter_->UpdateLeftHeaderView(window_icon_); |
63 } | 64 } |
64 } | 65 } |
65 | 66 |
66 WmWindow* PanelFrameView::GetWidgetWindow() { | 67 aura::Window* PanelFrameView::GetWidgetWindow() { |
67 return WmWindow::Get(frame_->GetNativeWindow()); | 68 return frame_->GetNativeWindow(); |
68 } | 69 } |
69 | 70 |
70 int PanelFrameView::NonClientTopBorderHeight() const { | 71 int PanelFrameView::NonClientTopBorderHeight() const { |
71 if (!header_painter_) | 72 if (!header_painter_) |
72 return 0; | 73 return 0; |
73 return header_painter_->GetHeaderHeightForPainting(); | 74 return header_painter_->GetHeaderHeightForPainting(); |
74 } | 75 } |
75 | 76 |
76 gfx::Size PanelFrameView::GetMinimumSize() const { | 77 gfx::Size PanelFrameView::GetMinimumSize() const { |
77 if (!header_painter_) | 78 if (!header_painter_) |
78 return gfx::Size(); | 79 return gfx::Size(); |
79 gfx::Size min_client_view_size(frame_->client_view()->GetMinimumSize()); | 80 gfx::Size min_client_view_size(frame_->client_view()->GetMinimumSize()); |
80 return gfx::Size(std::max(header_painter_->GetMinimumHeaderWidth(), | 81 return gfx::Size(std::max(header_painter_->GetMinimumHeaderWidth(), |
81 min_client_view_size.width()), | 82 min_client_view_size.width()), |
82 NonClientTopBorderHeight() + min_client_view_size.height()); | 83 NonClientTopBorderHeight() + min_client_view_size.height()); |
83 } | 84 } |
84 | 85 |
85 void PanelFrameView::Layout() { | 86 void PanelFrameView::Layout() { |
86 if (!header_painter_) | 87 if (!header_painter_) |
87 return; | 88 return; |
88 header_painter_->LayoutHeader(); | 89 header_painter_->LayoutHeader(); |
89 GetWidgetWindow()->aura_window()->SetProperty(aura::client::kTopViewInset, | 90 GetWidgetWindow()->SetProperty(aura::client::kTopViewInset, |
90 NonClientTopBorderHeight()); | 91 NonClientTopBorderHeight()); |
91 } | 92 } |
92 | 93 |
93 void PanelFrameView::GetWindowMask(const gfx::Size&, gfx::Path*) { | 94 void PanelFrameView::GetWindowMask(const gfx::Size&, gfx::Path*) { |
94 // Nothing. | 95 // Nothing. |
95 } | 96 } |
96 | 97 |
97 void PanelFrameView::ResetWindowControls() { | 98 void PanelFrameView::ResetWindowControls() { |
98 NOTIMPLEMENTED(); | 99 NOTIMPLEMENTED(); |
99 } | 100 } |
100 | 101 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 152 |
152 void PanelFrameView::OnOverviewModeStarting() { | 153 void PanelFrameView::OnOverviewModeStarting() { |
153 caption_button_container_->SetVisible(false); | 154 caption_button_container_->SetVisible(false); |
154 } | 155 } |
155 | 156 |
156 void PanelFrameView::OnOverviewModeEnded() { | 157 void PanelFrameView::OnOverviewModeEnded() { |
157 caption_button_container_->SetVisible(true); | 158 caption_button_container_->SetVisible(true); |
158 } | 159 } |
159 | 160 |
160 } // namespace ash | 161 } // namespace ash |
OLD | NEW |