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/wm/frame_painter.h" | 7 #include "ash/wm/frame_painter.h" |
8 #include "grit/ash_resources.h" | 8 #include "grit/ash_resources.h" |
9 #include "grit/ui_strings.h" // Accessibility names | 9 #include "grit/ui_strings.h" // Accessibility names |
10 #include "third_party/skia/include/core/SkPaint.h" | 10 #include "third_party/skia/include/core/SkPaint.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 if (frame_->widget_delegate()->ShouldShowWindowIcon()) { | 52 if (frame_->widget_delegate()->ShouldShowWindowIcon()) { |
53 window_icon_ = new views::ImageButton(this); | 53 window_icon_ = new views::ImageButton(this); |
54 AddChildView(window_icon_); | 54 AddChildView(window_icon_); |
55 } | 55 } |
56 | 56 |
57 frame_painter_->Init(frame_, window_icon_, minimize_button_, close_button_, | 57 frame_painter_->Init(frame_, window_icon_, minimize_button_, close_button_, |
58 FramePainter::SIZE_BUTTON_MINIMIZES); | 58 FramePainter::SIZE_BUTTON_MINIMIZES); |
59 } | 59 } |
60 | 60 |
61 void PanelFrameView::Layout() { | 61 void PanelFrameView::Layout() { |
62 if (!frame_painter_.get()) | 62 if (!frame_painter_) |
63 return; | 63 return; |
64 frame_painter_->LayoutHeader(this, true); | 64 frame_painter_->LayoutHeader(this, true); |
65 } | 65 } |
66 | 66 |
67 void PanelFrameView::ResetWindowControls() { | 67 void PanelFrameView::ResetWindowControls() { |
68 NOTIMPLEMENTED(); | 68 NOTIMPLEMENTED(); |
69 } | 69 } |
70 | 70 |
71 void PanelFrameView::UpdateWindowIcon() { | 71 void PanelFrameView::UpdateWindowIcon() { |
72 if (!window_icon_) | 72 if (!window_icon_) |
73 return; | 73 return; |
74 views::WidgetDelegate* delegate = frame_->widget_delegate(); | 74 views::WidgetDelegate* delegate = frame_->widget_delegate(); |
75 if (delegate) { | 75 if (delegate) { |
76 gfx::ImageSkia image = delegate->GetWindowIcon(); | 76 gfx::ImageSkia image = delegate->GetWindowIcon(); |
77 window_icon_->SetImage(views::CustomButton::STATE_NORMAL, &image); | 77 window_icon_->SetImage(views::CustomButton::STATE_NORMAL, &image); |
78 } | 78 } |
79 window_icon_->SchedulePaint(); | 79 window_icon_->SchedulePaint(); |
80 } | 80 } |
81 | 81 |
82 void PanelFrameView::UpdateWindowTitle() { | 82 void PanelFrameView::UpdateWindowTitle() { |
83 if (!frame_painter_.get()) | 83 if (!frame_painter_) |
84 return; | 84 return; |
85 frame_painter_->SchedulePaintForTitle(this, title_font_); | 85 frame_painter_->SchedulePaintForTitle(this, title_font_); |
86 } | 86 } |
87 | 87 |
88 void PanelFrameView::GetWindowMask(const gfx::Size&, gfx::Path*) { | 88 void PanelFrameView::GetWindowMask(const gfx::Size&, gfx::Path*) { |
89 // Nothing. | 89 // Nothing. |
90 } | 90 } |
91 | 91 |
92 int PanelFrameView::NonClientHitTest(const gfx::Point& point) { | 92 int PanelFrameView::NonClientHitTest(const gfx::Point& point) { |
93 if (!frame_painter_.get()) | 93 if (!frame_painter_) |
94 return HTNOWHERE; | 94 return HTNOWHERE; |
95 return frame_painter_->NonClientHitTest(this, point); | 95 return frame_painter_->NonClientHitTest(this, point); |
96 } | 96 } |
97 | 97 |
98 void PanelFrameView::OnPaint(gfx::Canvas* canvas) { | 98 void PanelFrameView::OnPaint(gfx::Canvas* canvas) { |
99 if (!frame_painter_.get()) | 99 if (!frame_painter_) |
100 return; | 100 return; |
101 bool paint_as_active = ShouldPaintAsActive(); | 101 bool paint_as_active = ShouldPaintAsActive(); |
102 int theme_image_id = paint_as_active ? IDR_AURA_WINDOW_HEADER_BASE_ACTIVE : | 102 int theme_image_id = paint_as_active ? IDR_AURA_WINDOW_HEADER_BASE_ACTIVE : |
103 IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; | 103 IDR_AURA_WINDOW_HEADER_BASE_INACTIVE; |
104 frame_painter_->PaintHeader( | 104 frame_painter_->PaintHeader( |
105 this, | 105 this, |
106 canvas, | 106 canvas, |
107 paint_as_active ? FramePainter::ACTIVE : FramePainter::INACTIVE, | 107 paint_as_active ? FramePainter::ACTIVE : FramePainter::INACTIVE, |
108 theme_image_id, | 108 theme_image_id, |
109 NULL); | 109 NULL); |
110 frame_painter_->PaintTitleBar(this, canvas, title_font_); | 110 frame_painter_->PaintTitleBar(this, canvas, title_font_); |
111 frame_painter_->PaintHeaderContentSeparator(this, canvas); | 111 frame_painter_->PaintHeaderContentSeparator(this, canvas); |
112 } | 112 } |
113 | 113 |
114 gfx::Rect PanelFrameView::GetBoundsForClientView() const { | 114 gfx::Rect PanelFrameView::GetBoundsForClientView() const { |
115 if (!frame_painter_.get()) | 115 if (!frame_painter_) |
116 return bounds(); | 116 return bounds(); |
117 return frame_painter_->GetBoundsForClientView( | 117 return frame_painter_->GetBoundsForClientView( |
118 close_button_->bounds().bottom(), | 118 close_button_->bounds().bottom(), |
119 bounds()); | 119 bounds()); |
120 } | 120 } |
121 | 121 |
122 gfx::Rect PanelFrameView::GetWindowBoundsForClientBounds( | 122 gfx::Rect PanelFrameView::GetWindowBoundsForClientBounds( |
123 const gfx::Rect& client_bounds) const { | 123 const gfx::Rect& client_bounds) const { |
124 if (!frame_painter_.get()) | 124 if (!frame_painter_) |
125 return client_bounds; | 125 return client_bounds; |
126 return frame_painter_->GetWindowBoundsForClientBounds( | 126 return frame_painter_->GetWindowBoundsForClientBounds( |
127 close_button_->bounds().bottom(), client_bounds); | 127 close_button_->bounds().bottom(), client_bounds); |
128 } | 128 } |
129 | 129 |
130 void PanelFrameView::ButtonPressed(views::Button* sender, | 130 void PanelFrameView::ButtonPressed(views::Button* sender, |
131 const ui::Event& event) { | 131 const ui::Event& event) { |
132 if (sender == close_button_) | 132 if (sender == close_button_) |
133 GetWidget()->Close(); | 133 GetWidget()->Close(); |
134 if (sender == minimize_button_) | 134 if (sender == minimize_button_) |
135 GetWidget()->Minimize(); | 135 GetWidget()->Minimize(); |
136 } | 136 } |
137 | 137 |
138 } // namespace ash | 138 } // namespace ash |
OLD | NEW |