| 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_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 "ash/common/wm_window_property.h" | 13 #include "ui/aura/client/aura_constants.h" |
| 14 #include "ui/aura/window.h" |
| 14 #include "ui/base/hit_test.h" | 15 #include "ui/base/hit_test.h" |
| 15 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 16 #include "ui/views/controls/image_view.h" | 17 #include "ui/views/controls/image_view.h" |
| 17 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 18 #include "ui/views/widget/widget_delegate.h" | 19 #include "ui/views/widget/widget_delegate.h" |
| 19 | 20 |
| 20 namespace ash { | 21 namespace ash { |
| 21 | 22 |
| 22 // static | 23 // static |
| 23 const char PanelFrameView::kViewClassName[] = "PanelFrameView"; | 24 const char PanelFrameView::kViewClassName[] = "PanelFrameView"; |
| 24 | 25 |
| 25 PanelFrameView::PanelFrameView(views::Widget* frame, FrameType frame_type) | 26 PanelFrameView::PanelFrameView(views::Widget* frame, FrameType frame_type) |
| 26 : frame_(frame), caption_button_container_(nullptr), window_icon_(nullptr) { | 27 : frame_(frame), caption_button_container_(nullptr), window_icon_(nullptr) { |
| 27 GetWidgetWindow()->InstallResizeHandleWindowTargeter(nullptr); | 28 GetWidgetWindow()->InstallResizeHandleWindowTargeter(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 WmShell::Get()->AddShellObserver(this); | 32 WmShell::Get()->AddShellObserver(this); |
| 32 } | 33 } |
| 33 | 34 |
| 34 PanelFrameView::~PanelFrameView() { | 35 PanelFrameView::~PanelFrameView() { |
| 35 WmShell::Get()->RemoveShellObserver(this); | 36 WmShell::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()->SetColorProperty(WmWindowProperty::TOP_VIEW_COLOR, | 42 GetWidgetWindow()->aura_window()->SetProperty( |
| 42 header_painter_->GetInactiveFrameColor()); | 43 aura::client::kTopViewColor, 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()->SetColorProperty(WmWindowProperty::TOP_VIEW_COLOR, | 52 GetWidgetWindow()->aura_window()->SetProperty( |
| 52 header_painter_->GetInactiveFrameColor()); | 53 aura::client::kTopViewColor, 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_); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 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()->SetIntProperty(WmWindowProperty::TOP_VIEW_INSET, | 90 GetWidgetWindow()->aura_window()->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 |