| 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_controller.h" | 9 #include "ash/frame/frame_border_hit_test_controller.h" |
| 10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 : frame_(frame), | 24 : frame_(frame), |
| 25 caption_button_container_(NULL), | 25 caption_button_container_(NULL), |
| 26 window_icon_(NULL), | 26 window_icon_(NULL), |
| 27 frame_border_hit_test_controller_( | 27 frame_border_hit_test_controller_( |
| 28 new FrameBorderHitTestController(frame_)) { | 28 new FrameBorderHitTestController(frame_)) { |
| 29 DCHECK(!frame_->widget_delegate()->CanMaximize()); | 29 DCHECK(!frame_->widget_delegate()->CanMaximize()); |
| 30 if (frame_type != FRAME_NONE) | 30 if (frame_type != FRAME_NONE) |
| 31 InitHeaderPainter(); | 31 InitHeaderPainter(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 PanelFrameView::~PanelFrameView() { | 34 PanelFrameView::~PanelFrameView() {} |
| 35 } | |
| 36 | 35 |
| 37 void PanelFrameView::SetFrameColors(SkColor active_frame_color, | 36 void PanelFrameView::SetFrameColors(SkColor active_frame_color, |
| 38 SkColor inactive_frame_color) { | 37 SkColor inactive_frame_color) { |
| 39 header_painter_->SetFrameColors(active_frame_color, inactive_frame_color); | 38 header_painter_->SetFrameColors(active_frame_color, inactive_frame_color); |
| 40 } | 39 } |
| 41 | 40 |
| 42 const char* PanelFrameView::GetClassName() const { | 41 const char* PanelFrameView::GetClassName() const { |
| 43 return kViewClassName; | 42 return kViewClassName; |
| 44 } | 43 } |
| 45 | 44 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 61 int PanelFrameView::NonClientTopBorderHeight() const { | 60 int PanelFrameView::NonClientTopBorderHeight() const { |
| 62 if (!header_painter_) | 61 if (!header_painter_) |
| 63 return 0; | 62 return 0; |
| 64 return header_painter_->GetHeaderHeightForPainting(); | 63 return header_painter_->GetHeaderHeightForPainting(); |
| 65 } | 64 } |
| 66 | 65 |
| 67 gfx::Size PanelFrameView::GetMinimumSize() const { | 66 gfx::Size PanelFrameView::GetMinimumSize() const { |
| 68 if (!header_painter_) | 67 if (!header_painter_) |
| 69 return gfx::Size(); | 68 return gfx::Size(); |
| 70 gfx::Size min_client_view_size(frame_->client_view()->GetMinimumSize()); | 69 gfx::Size min_client_view_size(frame_->client_view()->GetMinimumSize()); |
| 71 return gfx::Size( | 70 return gfx::Size(std::max(header_painter_->GetMinimumHeaderWidth(), |
| 72 std::max(header_painter_->GetMinimumHeaderWidth(), | 71 min_client_view_size.width()), |
| 73 min_client_view_size.width()), | 72 NonClientTopBorderHeight() + min_client_view_size.height()); |
| 74 NonClientTopBorderHeight() + min_client_view_size.height()); | |
| 75 } | 73 } |
| 76 | 74 |
| 77 void PanelFrameView::Layout() { | 75 void PanelFrameView::Layout() { |
| 78 if (!header_painter_) | 76 if (!header_painter_) |
| 79 return; | 77 return; |
| 80 header_painter_->LayoutHeader(); | 78 header_painter_->LayoutHeader(); |
| 81 frame_->GetNativeWindow()->SetProperty(aura::client::kTopViewInset, | 79 frame_->GetNativeWindow()->SetProperty(aura::client::kTopViewInset, |
| 82 NonClientTopBorderHeight()); | 80 NonClientTopBorderHeight()); |
| 83 } | 81 } |
| 84 | 82 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 98 window_icon_->SetImage(delegate->GetWindowIcon()); | 96 window_icon_->SetImage(delegate->GetWindowIcon()); |
| 99 window_icon_->SchedulePaint(); | 97 window_icon_->SchedulePaint(); |
| 100 } | 98 } |
| 101 | 99 |
| 102 void PanelFrameView::UpdateWindowTitle() { | 100 void PanelFrameView::UpdateWindowTitle() { |
| 103 if (!header_painter_) | 101 if (!header_painter_) |
| 104 return; | 102 return; |
| 105 header_painter_->SchedulePaintForTitle(); | 103 header_painter_->SchedulePaintForTitle(); |
| 106 } | 104 } |
| 107 | 105 |
| 108 void PanelFrameView::SizeConstraintsChanged() { | 106 void PanelFrameView::SizeConstraintsChanged() {} |
| 109 } | |
| 110 | 107 |
| 111 int PanelFrameView::NonClientHitTest(const gfx::Point& point) { | 108 int PanelFrameView::NonClientHitTest(const gfx::Point& point) { |
| 112 if (!header_painter_) | 109 if (!header_painter_) |
| 113 return HTNOWHERE; | 110 return HTNOWHERE; |
| 114 return FrameBorderHitTestController::NonClientHitTest(this, | 111 return FrameBorderHitTestController::NonClientHitTest( |
| 115 caption_button_container_, point); | 112 this, caption_button_container_, point); |
| 116 } | 113 } |
| 117 | 114 |
| 118 void PanelFrameView::OnPaint(gfx::Canvas* canvas) { | 115 void PanelFrameView::OnPaint(gfx::Canvas* canvas) { |
| 119 if (!header_painter_) | 116 if (!header_painter_) |
| 120 return; | 117 return; |
| 121 bool paint_as_active = ShouldPaintAsActive(); | 118 bool paint_as_active = ShouldPaintAsActive(); |
| 122 caption_button_container_->SetPaintAsActive(paint_as_active); | 119 caption_button_container_->SetPaintAsActive(paint_as_active); |
| 123 | 120 |
| 124 HeaderPainter::Mode header_mode = paint_as_active ? | 121 HeaderPainter::Mode header_mode = paint_as_active |
| 125 HeaderPainter::MODE_ACTIVE : HeaderPainter::MODE_INACTIVE; | 122 ? HeaderPainter::MODE_ACTIVE |
| 123 : HeaderPainter::MODE_INACTIVE; |
| 126 header_painter_->PaintHeader(canvas, header_mode); | 124 header_painter_->PaintHeader(canvas, header_mode); |
| 127 } | 125 } |
| 128 | 126 |
| 129 gfx::Rect PanelFrameView::GetBoundsForClientView() const { | 127 gfx::Rect PanelFrameView::GetBoundsForClientView() const { |
| 130 gfx::Rect client_bounds = bounds(); | 128 gfx::Rect client_bounds = bounds(); |
| 131 client_bounds.Inset(0, NonClientTopBorderHeight(), 0, 0); | 129 client_bounds.Inset(0, NonClientTopBorderHeight(), 0, 0); |
| 132 return client_bounds; | 130 return client_bounds; |
| 133 } | 131 } |
| 134 | 132 |
| 135 gfx::Rect PanelFrameView::GetWindowBoundsForClientBounds( | 133 gfx::Rect PanelFrameView::GetWindowBoundsForClientBounds( |
| 136 const gfx::Rect& client_bounds) const { | 134 const gfx::Rect& client_bounds) const { |
| 137 gfx::Rect window_bounds = client_bounds; | 135 gfx::Rect window_bounds = client_bounds; |
| 138 window_bounds.Inset(0, -NonClientTopBorderHeight(), 0, 0); | 136 window_bounds.Inset(0, -NonClientTopBorderHeight(), 0, 0); |
| 139 return window_bounds; | 137 return window_bounds; |
| 140 } | 138 } |
| 141 | 139 |
| 142 } // namespace ash | 140 } // namespace ash |
| OLD | NEW |