Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(996)

Side by Side Diff: ash/common/wm/panels/panel_frame_view.cc

Issue 2410633002: Moves PanelFrameView to common (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/wm/panels/panel_frame_view.h ('k') | ash/mus/non_client_frame_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/wm/panels/panel_frame_view.h"
6 6
7 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h " 7 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h "
8 #include "ash/common/frame/default_header_painter.h" 8 #include "ash/common/frame/default_header_painter.h"
9 #include "ash/common/frame/frame_border_hit_test.h" 9 #include "ash/common/frame/frame_border_hit_test.h"
10 #include "ash/common/wm_lookup.h" 10 #include "ash/common/wm_lookup.h"
11 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
12 #include "ash/common/wm_window.h" 12 #include "ash/common/wm_window.h"
13 #include "ui/aura/client/aura_constants.h" 13 #include "ash/common/wm_window_property.h"
14 #include "ui/aura/window.h"
15 #include "ui/base/hit_test.h" 14 #include "ui/base/hit_test.h"
16 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
17 #include "ui/views/controls/image_view.h" 16 #include "ui/views/controls/image_view.h"
18 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
19 #include "ui/views/widget/widget_delegate.h" 18 #include "ui/views/widget/widget_delegate.h"
20 19
21 namespace ash { 20 namespace ash {
22 21
23 // static 22 // static
24 const char PanelFrameView::kViewClassName[] = "PanelFrameView"; 23 const char PanelFrameView::kViewClassName[] = "PanelFrameView";
25 24
26 PanelFrameView::PanelFrameView(views::Widget* frame, FrameType frame_type) 25 PanelFrameView::PanelFrameView(views::Widget* frame, FrameType frame_type)
27 : frame_(frame), caption_button_container_(nullptr), window_icon_(nullptr) { 26 : frame_(frame), caption_button_container_(nullptr), window_icon_(nullptr) {
28 WmLookup::Get()->GetWindowForWidget(frame)->InstallResizeHandleWindowTargeter( 27 GetWidgetWindow()->InstallResizeHandleWindowTargeter(nullptr);
29 nullptr);
30 DCHECK(!frame_->widget_delegate()->CanMaximize()); 28 DCHECK(!frame_->widget_delegate()->CanMaximize());
31 if (frame_type != FRAME_NONE) 29 if (frame_type != FRAME_NONE)
32 InitHeaderPainter(); 30 InitHeaderPainter();
33 WmShell::Get()->AddShellObserver(this); 31 WmShell::Get()->AddShellObserver(this);
34 } 32 }
35 33
36 PanelFrameView::~PanelFrameView() { 34 PanelFrameView::~PanelFrameView() {
37 WmShell::Get()->RemoveShellObserver(this); 35 WmShell::Get()->RemoveShellObserver(this);
38 } 36 }
39 37
40 void PanelFrameView::SetFrameColors(SkColor active_frame_color, 38 void PanelFrameView::SetFrameColors(SkColor active_frame_color,
41 SkColor inactive_frame_color) { 39 SkColor inactive_frame_color) {
42 header_painter_->SetFrameColors(active_frame_color, inactive_frame_color); 40 header_painter_->SetFrameColors(active_frame_color, inactive_frame_color);
43 frame_->GetNativeWindow()->SetProperty( 41 GetWidgetWindow()->SetColorProperty(WmWindowProperty::TOP_VIEW_COLOR,
44 aura::client::kTopViewColor, header_painter_->GetInactiveFrameColor()); 42 header_painter_->GetInactiveFrameColor());
45 } 43 }
46 44
47 const char* PanelFrameView::GetClassName() const { 45 const char* PanelFrameView::GetClassName() const {
48 return kViewClassName; 46 return kViewClassName;
49 } 47 }
50 48
51 void PanelFrameView::InitHeaderPainter() { 49 void PanelFrameView::InitHeaderPainter() {
52 header_painter_.reset(new DefaultHeaderPainter); 50 header_painter_.reset(new DefaultHeaderPainter);
53 frame_->GetNativeWindow()->SetProperty( 51 GetWidgetWindow()->SetColorProperty(WmWindowProperty::TOP_VIEW_COLOR,
54 aura::client::kTopViewColor, header_painter_->GetInactiveFrameColor()); 52 header_painter_->GetInactiveFrameColor());
55 53
56 caption_button_container_ = new FrameCaptionButtonContainerView(frame_); 54 caption_button_container_ = new FrameCaptionButtonContainerView(frame_);
57 AddChildView(caption_button_container_); 55 AddChildView(caption_button_container_);
58 56
59 header_painter_->Init(frame_, this, caption_button_container_); 57 header_painter_->Init(frame_, this, caption_button_container_);
60 58
61 if (frame_->widget_delegate()->ShouldShowWindowIcon()) { 59 if (frame_->widget_delegate()->ShouldShowWindowIcon()) {
62 window_icon_ = new views::ImageView(); 60 window_icon_ = new views::ImageView();
63 AddChildView(window_icon_); 61 AddChildView(window_icon_);
64 header_painter_->UpdateLeftHeaderView(window_icon_); 62 header_painter_->UpdateLeftHeaderView(window_icon_);
65 } 63 }
66 } 64 }
67 65
66 WmWindow* PanelFrameView::GetWidgetWindow() {
67 return WmLookup::Get()->GetWindowForWidget(frame_);
68 }
69
68 int PanelFrameView::NonClientTopBorderHeight() const { 70 int PanelFrameView::NonClientTopBorderHeight() const {
69 if (!header_painter_) 71 if (!header_painter_)
70 return 0; 72 return 0;
71 return header_painter_->GetHeaderHeightForPainting(); 73 return header_painter_->GetHeaderHeightForPainting();
72 } 74 }
73 75
74 gfx::Size PanelFrameView::GetMinimumSize() const { 76 gfx::Size PanelFrameView::GetMinimumSize() const {
75 if (!header_painter_) 77 if (!header_painter_)
76 return gfx::Size(); 78 return gfx::Size();
77 gfx::Size min_client_view_size(frame_->client_view()->GetMinimumSize()); 79 gfx::Size min_client_view_size(frame_->client_view()->GetMinimumSize());
78 return gfx::Size(std::max(header_painter_->GetMinimumHeaderWidth(), 80 return gfx::Size(std::max(header_painter_->GetMinimumHeaderWidth(),
79 min_client_view_size.width()), 81 min_client_view_size.width()),
80 NonClientTopBorderHeight() + min_client_view_size.height()); 82 NonClientTopBorderHeight() + min_client_view_size.height());
81 } 83 }
82 84
83 void PanelFrameView::Layout() { 85 void PanelFrameView::Layout() {
84 if (!header_painter_) 86 if (!header_painter_)
85 return; 87 return;
86 header_painter_->LayoutHeader(); 88 header_painter_->LayoutHeader();
87 frame_->GetNativeWindow()->SetProperty(aura::client::kTopViewInset, 89 GetWidgetWindow()->SetIntProperty(WmWindowProperty::TOP_VIEW_INSET,
88 NonClientTopBorderHeight()); 90 NonClientTopBorderHeight());
89 } 91 }
90 92
91 void PanelFrameView::GetWindowMask(const gfx::Size&, gfx::Path*) { 93 void PanelFrameView::GetWindowMask(const gfx::Size&, gfx::Path*) {
92 // Nothing. 94 // Nothing.
93 } 95 }
94 96
95 void PanelFrameView::ResetWindowControls() { 97 void PanelFrameView::ResetWindowControls() {
96 NOTIMPLEMENTED(); 98 NOTIMPLEMENTED();
97 } 99 }
98 100
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 151
150 void PanelFrameView::OnOverviewModeStarting() { 152 void PanelFrameView::OnOverviewModeStarting() {
151 caption_button_container_->SetVisible(false); 153 caption_button_container_->SetVisible(false);
152 } 154 }
153 155
154 void PanelFrameView::OnOverviewModeEnded() { 156 void PanelFrameView::OnOverviewModeEnded() {
155 caption_button_container_->SetVisible(true); 157 caption_button_container_->SetVisible(true);
156 } 158 }
157 159
158 } // namespace ash 160 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/panels/panel_frame_view.h ('k') | ash/mus/non_client_frame_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698