| 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/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/wm_shell.h" |
| 7 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 9 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
| 8 #include "ash/frame/default_header_painter.h" | 10 #include "ash/frame/default_header_painter.h" |
| 9 #include "ash/frame/frame_border_hit_test_controller.h" | 11 #include "ash/frame/frame_border_hit_test_controller.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 12 #include "ui/aura/client/aura_constants.h" |
| 11 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 12 #include "ui/base/hit_test.h" | 14 #include "ui/base/hit_test.h" |
| 13 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 14 #include "ui/views/controls/image_view.h" | 16 #include "ui/views/controls/image_view.h" |
| 15 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 16 #include "ui/views/widget/widget_delegate.h" | 18 #include "ui/views/widget/widget_delegate.h" |
| 17 | 19 |
| 18 namespace ash { | 20 namespace ash { |
| 19 | 21 |
| 20 // static | 22 // static |
| 21 const char PanelFrameView::kViewClassName[] = "PanelFrameView"; | 23 const char PanelFrameView::kViewClassName[] = "PanelFrameView"; |
| 22 | 24 |
| 23 PanelFrameView::PanelFrameView(views::Widget* frame, FrameType frame_type) | 25 PanelFrameView::PanelFrameView(views::Widget* frame, FrameType frame_type) |
| 24 : frame_(frame), | 26 : frame_(frame), |
| 25 caption_button_container_(NULL), | 27 caption_button_container_(NULL), |
| 26 window_icon_(NULL), | 28 window_icon_(NULL), |
| 27 frame_border_hit_test_controller_( | 29 frame_border_hit_test_controller_( |
| 28 new FrameBorderHitTestController(frame_)) { | 30 new FrameBorderHitTestController(frame_)) { |
| 29 DCHECK(!frame_->widget_delegate()->CanMaximize()); | 31 DCHECK(!frame_->widget_delegate()->CanMaximize()); |
| 30 if (frame_type != FRAME_NONE) | 32 if (frame_type != FRAME_NONE) |
| 31 InitHeaderPainter(); | 33 InitHeaderPainter(); |
| 34 WmShell::Get()->AddShellObserver(this); |
| 32 } | 35 } |
| 33 | 36 |
| 34 PanelFrameView::~PanelFrameView() {} | 37 PanelFrameView::~PanelFrameView() { |
| 38 WmShell::Get()->RemoveShellObserver(this); |
| 39 } |
| 35 | 40 |
| 36 void PanelFrameView::SetFrameColors(SkColor active_frame_color, | 41 void PanelFrameView::SetFrameColors(SkColor active_frame_color, |
| 37 SkColor inactive_frame_color) { | 42 SkColor inactive_frame_color) { |
| 38 header_painter_->SetFrameColors(active_frame_color, inactive_frame_color); | 43 header_painter_->SetFrameColors(active_frame_color, inactive_frame_color); |
| 39 } | 44 } |
| 40 | 45 |
| 41 const char* PanelFrameView::GetClassName() const { | 46 const char* PanelFrameView::GetClassName() const { |
| 42 return kViewClassName; | 47 return kViewClassName; |
| 43 } | 48 } |
| 44 | 49 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 103 } |
| 99 | 104 |
| 100 void PanelFrameView::UpdateWindowTitle() { | 105 void PanelFrameView::UpdateWindowTitle() { |
| 101 if (!header_painter_) | 106 if (!header_painter_) |
| 102 return; | 107 return; |
| 103 header_painter_->SchedulePaintForTitle(); | 108 header_painter_->SchedulePaintForTitle(); |
| 104 } | 109 } |
| 105 | 110 |
| 106 void PanelFrameView::SizeConstraintsChanged() {} | 111 void PanelFrameView::SizeConstraintsChanged() {} |
| 107 | 112 |
| 113 gfx::Rect PanelFrameView::GetBoundsForClientView() const { |
| 114 gfx::Rect client_bounds = bounds(); |
| 115 client_bounds.Inset(0, NonClientTopBorderHeight(), 0, 0); |
| 116 return client_bounds; |
| 117 } |
| 118 |
| 119 gfx::Rect PanelFrameView::GetWindowBoundsForClientBounds( |
| 120 const gfx::Rect& client_bounds) const { |
| 121 gfx::Rect window_bounds = client_bounds; |
| 122 window_bounds.Inset(0, -NonClientTopBorderHeight(), 0, 0); |
| 123 return window_bounds; |
| 124 } |
| 125 |
| 108 int PanelFrameView::NonClientHitTest(const gfx::Point& point) { | 126 int PanelFrameView::NonClientHitTest(const gfx::Point& point) { |
| 109 if (!header_painter_) | 127 if (!header_painter_) |
| 110 return HTNOWHERE; | 128 return HTNOWHERE; |
| 111 return FrameBorderHitTestController::NonClientHitTest( | 129 return FrameBorderHitTestController::NonClientHitTest( |
| 112 this, caption_button_container_, point); | 130 this, caption_button_container_, point); |
| 113 } | 131 } |
| 114 | 132 |
| 115 void PanelFrameView::OnPaint(gfx::Canvas* canvas) { | 133 void PanelFrameView::OnPaint(gfx::Canvas* canvas) { |
| 116 if (!header_painter_) | 134 if (!header_painter_) |
| 117 return; | 135 return; |
| 118 bool paint_as_active = ShouldPaintAsActive(); | 136 bool paint_as_active = ShouldPaintAsActive(); |
| 119 caption_button_container_->SetPaintAsActive(paint_as_active); | 137 caption_button_container_->SetPaintAsActive(paint_as_active); |
| 120 | 138 |
| 121 HeaderPainter::Mode header_mode = paint_as_active | 139 HeaderPainter::Mode header_mode = paint_as_active |
| 122 ? HeaderPainter::MODE_ACTIVE | 140 ? HeaderPainter::MODE_ACTIVE |
| 123 : HeaderPainter::MODE_INACTIVE; | 141 : HeaderPainter::MODE_INACTIVE; |
| 124 header_painter_->PaintHeader(canvas, header_mode); | 142 header_painter_->PaintHeader(canvas, header_mode); |
| 125 } | 143 } |
| 126 | 144 |
| 127 gfx::Rect PanelFrameView::GetBoundsForClientView() const { | 145 /////////////////////////////////////////////////////////////////////////////// |
| 128 gfx::Rect client_bounds = bounds(); | 146 // PanelFrameView, ShellObserver overrides: |
| 129 client_bounds.Inset(0, NonClientTopBorderHeight(), 0, 0); | 147 |
| 130 return client_bounds; | 148 void PanelFrameView::OnOverviewModeStarting() { |
| 149 if (ash::MaterialDesignController::IsOverviewMaterial()) |
| 150 caption_button_container_->SetVisible(false); |
| 131 } | 151 } |
| 132 | 152 |
| 133 gfx::Rect PanelFrameView::GetWindowBoundsForClientBounds( | 153 void PanelFrameView::OnOverviewModeEnded() { |
| 134 const gfx::Rect& client_bounds) const { | 154 if (ash::MaterialDesignController::IsOverviewMaterial()) |
| 135 gfx::Rect window_bounds = client_bounds; | 155 caption_button_container_->SetVisible(true); |
| 136 window_bounds.Inset(0, -NonClientTopBorderHeight(), 0, 0); | |
| 137 return window_bounds; | |
| 138 } | 156 } |
| 139 | 157 |
| 140 } // namespace ash | 158 } // namespace ash |
| OLD | NEW |