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