OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/frame/default_header_painter.h" | 5 #include "ash/frame/default_header_painter.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/header_painter_util.h" | 8 #include "ash/frame/header_painter_util.h" |
9 #include "base/debug/leak_annotations.h" | 9 #include "base/debug/leak_annotations.h" |
10 #include "base/logging.h" // DCHECK | 10 #include "base/logging.h" // DCHECK |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // Color for the window title text. | 31 // Color for the window title text. |
32 const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40); | 32 const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40); |
33 // Color of the active window header/content separator line. | 33 // Color of the active window header/content separator line. |
34 const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(150, 150, 152); | 34 const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(150, 150, 152); |
35 // Color of the inactive window header/content separator line. | 35 // Color of the inactive window header/content separator line. |
36 const SkColor kHeaderContentSeparatorInactiveColor = | 36 const SkColor kHeaderContentSeparatorInactiveColor = |
37 SkColorSetRGB(180, 180, 182); | 37 SkColorSetRGB(180, 180, 182); |
38 // The color of the frame. | 38 // The default color of the frame. |
39 const SkColor kFrameColor = SkColorSetRGB(242, 242, 242); | 39 const SkColor kDefaultFrameColor = SkColorSetRGB(242, 242, 242); |
40 // The alpha of the inactive frame. | 40 // The alpha of the inactive frame. |
41 const SkAlpha kInactiveFrameAlpha = 204; | 41 const SkAlpha kInactiveFrameAlpha = 204; |
42 // Duration of crossfade animation for activating and deactivating frame. | 42 // Duration of crossfade animation for activating and deactivating frame. |
43 const int kActivationCrossfadeDurationMs = 200; | 43 const int kActivationCrossfadeDurationMs = 200; |
44 | 44 |
45 // Tiles an image into an area, rounding the top corners. | 45 // Tiles an image into an area, rounding the top corners. |
46 void TileRoundRect(gfx::Canvas* canvas, | 46 void TileRoundRect(gfx::Canvas* canvas, |
47 const SkPaint& paint, | 47 const SkPaint& paint, |
48 const gfx::Rect& bounds, | 48 const gfx::Rect& bounds, |
49 int corner_radius) { | 49 int corner_radius) { |
(...skipping 22 matching lines...) Expand all Loading... |
72 namespace ash { | 72 namespace ash { |
73 | 73 |
74 /////////////////////////////////////////////////////////////////////////////// | 74 /////////////////////////////////////////////////////////////////////////////// |
75 // DefaultHeaderPainter, public: | 75 // DefaultHeaderPainter, public: |
76 | 76 |
77 DefaultHeaderPainter::DefaultHeaderPainter() | 77 DefaultHeaderPainter::DefaultHeaderPainter() |
78 : frame_(NULL), | 78 : frame_(NULL), |
79 view_(NULL), | 79 view_(NULL), |
80 left_header_view_(NULL), | 80 left_header_view_(NULL), |
81 left_view_x_inset_(HeaderPainterUtil::GetDefaultLeftViewXInset()), | 81 left_view_x_inset_(HeaderPainterUtil::GetDefaultLeftViewXInset()), |
| 82 active_frame_color_(kDefaultFrameColor), |
| 83 inactive_frame_color_(kDefaultFrameColor), |
82 caption_button_container_(NULL), | 84 caption_button_container_(NULL), |
83 height_(0), | 85 height_(0), |
84 mode_(MODE_INACTIVE), | 86 mode_(MODE_INACTIVE), |
85 initial_paint_(true), | 87 initial_paint_(true), |
86 activation_animation_(new gfx::SlideAnimation(this)) { | 88 activation_animation_(new gfx::SlideAnimation(this)) { |
87 } | 89 } |
88 | 90 |
89 DefaultHeaderPainter::~DefaultHeaderPainter() { | 91 DefaultHeaderPainter::~DefaultHeaderPainter() { |
90 } | 92 } |
91 | 93 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 159 } |
158 initial_paint_ = false; | 160 initial_paint_ = false; |
159 } | 161 } |
160 | 162 |
161 int corner_radius = (frame_->IsMaximized() || frame_->IsFullscreen()) ? | 163 int corner_radius = (frame_->IsMaximized() || frame_->IsFullscreen()) ? |
162 0 : HeaderPainterUtil::GetTopCornerRadiusWhenRestored(); | 164 0 : HeaderPainterUtil::GetTopCornerRadiusWhenRestored(); |
163 | 165 |
164 SkPaint paint; | 166 SkPaint paint; |
165 int active_alpha = activation_animation_->CurrentValueBetween(0, 255); | 167 int active_alpha = activation_animation_->CurrentValueBetween(0, 255); |
166 paint.setColor(color_utils::AlphaBlend( | 168 paint.setColor(color_utils::AlphaBlend( |
167 kFrameColor, GetInactiveFrameColor(), active_alpha)); | 169 active_frame_color_, GetInactiveFrameColor(), active_alpha)); |
168 | 170 |
169 TileRoundRect(canvas, paint, GetLocalBounds(), corner_radius); | 171 TileRoundRect(canvas, paint, GetLocalBounds(), corner_radius); |
170 | 172 |
171 if (!frame_->IsMaximized() && | 173 if (!frame_->IsMaximized() && |
172 !frame_->IsFullscreen() && | 174 !frame_->IsFullscreen() && |
173 mode_ == MODE_INACTIVE) { | 175 mode_ == MODE_INACTIVE) { |
174 PaintHighlightForInactiveRestoredWindow(canvas); | 176 PaintHighlightForInactiveRestoredWindow(canvas); |
175 } | 177 } |
176 if (frame_->widget_delegate() && | 178 if (frame_->widget_delegate() && |
177 frame_->widget_delegate()->ShouldShowWindowTitle()) { | 179 frame_->widget_delegate()->ShouldShowWindowTitle()) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 view_->SchedulePaintInRect(GetTitleBounds()); | 212 view_->SchedulePaintInRect(GetTitleBounds()); |
211 } | 213 } |
212 | 214 |
213 void DefaultHeaderPainter::UpdateLeftViewXInset(int left_view_x_inset) { | 215 void DefaultHeaderPainter::UpdateLeftViewXInset(int left_view_x_inset) { |
214 if (left_view_x_inset_ != left_view_x_inset) { | 216 if (left_view_x_inset_ != left_view_x_inset) { |
215 left_view_x_inset_ = left_view_x_inset; | 217 left_view_x_inset_ = left_view_x_inset; |
216 LayoutLeftHeaderView(); | 218 LayoutLeftHeaderView(); |
217 } | 219 } |
218 } | 220 } |
219 | 221 |
| 222 void DefaultHeaderPainter::SetFrameColors(SkColor active_frame_color, |
| 223 SkColor inactive_frame_color) { |
| 224 active_frame_color_ = active_frame_color; |
| 225 inactive_frame_color_ = inactive_frame_color; |
| 226 } |
| 227 |
220 void DefaultHeaderPainter::UpdateLeftHeaderView(views::View* left_header_view) { | 228 void DefaultHeaderPainter::UpdateLeftHeaderView(views::View* left_header_view) { |
221 left_header_view_ = left_header_view; | 229 left_header_view_ = left_header_view; |
222 } | 230 } |
223 | 231 |
224 /////////////////////////////////////////////////////////////////////////////// | 232 /////////////////////////////////////////////////////////////////////////////// |
225 // gfx::AnimationDelegate overrides: | 233 // gfx::AnimationDelegate overrides: |
226 | 234 |
227 void DefaultHeaderPainter::AnimationProgressed( | 235 void DefaultHeaderPainter::AnimationProgressed( |
228 const gfx::Animation* animation) { | 236 const gfx::Animation* animation) { |
229 view_->SchedulePaintInRect(GetLocalBounds()); | 237 view_->SchedulePaintInRect(GetLocalBounds()); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const { | 334 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const { |
327 return gfx::Rect(view_->width(), height_); | 335 return gfx::Rect(view_->width(), height_); |
328 } | 336 } |
329 | 337 |
330 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { | 338 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { |
331 return HeaderPainterUtil::GetTitleBounds( | 339 return HeaderPainterUtil::GetTitleBounds( |
332 left_header_view_, caption_button_container_, GetTitleFontList()); | 340 left_header_view_, caption_button_container_, GetTitleFontList()); |
333 } | 341 } |
334 | 342 |
335 SkColor DefaultHeaderPainter::GetInactiveFrameColor() const { | 343 SkColor DefaultHeaderPainter::GetInactiveFrameColor() const { |
336 SkColor color = kFrameColor; | 344 SkColor color = inactive_frame_color_; |
337 if (!frame_->IsMaximized() && !frame_->IsFullscreen()) { | 345 if (!frame_->IsMaximized() && !frame_->IsFullscreen()) { |
338 color = SkColorSetARGB(kInactiveFrameAlpha, | 346 color = SkColorSetARGB(kInactiveFrameAlpha, |
339 SkColorGetR(color), | 347 SkColorGetR(color), |
340 SkColorGetG(color), | 348 SkColorGetG(color), |
341 SkColorGetB(color)); | 349 SkColorGetB(color)); |
342 } | 350 } |
343 return color; | 351 return color; |
344 } | 352 } |
345 | 353 |
346 } // namespace ash | 354 } // namespace ash |
OLD | NEW |