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/common/frame/default_header_painter.h" | 5 #include "ash/common/frame/default_header_painter.h" |
6 | 6 |
7 #include "ash/common/ash_layout_constants.h" | 7 #include "ash/common/ash_layout_constants.h" |
8 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h
" | 8 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h
" |
9 #include "ash/common/frame/header_painter_util.h" | 9 #include "ash/common/frame/header_painter_util.h" |
| 10 #include "ash/resources/vector_icons/vector_icons.h" |
10 #include "base/debug/leak_annotations.h" | 11 #include "base/debug/leak_annotations.h" |
11 #include "base/logging.h" // DCHECK | 12 #include "base/logging.h" // DCHECK |
12 #include "grit/ash_resources.h" | 13 #include "grit/ash_resources.h" |
13 #include "third_party/skia/include/core/SkPaint.h" | 14 #include "third_party/skia/include/core/SkPaint.h" |
14 #include "third_party/skia/include/core/SkPath.h" | 15 #include "third_party/skia/include/core/SkPath.h" |
15 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/gfx/animation/slide_animation.h" | 17 #include "ui/gfx/animation/slide_animation.h" |
17 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
18 #include "ui/gfx/color_utils.h" | 19 #include "ui/gfx/color_utils.h" |
19 #include "ui/gfx/font_list.h" | 20 #include "ui/gfx/font_list.h" |
20 #include "ui/gfx/geometry/rect.h" | 21 #include "ui/gfx/geometry/rect.h" |
21 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
22 #include "ui/gfx/scoped_canvas.h" | 23 #include "ui/gfx/scoped_canvas.h" |
23 #include "ui/gfx/skia_util.h" | 24 #include "ui/gfx/skia_util.h" |
24 #include "ui/gfx/vector_icons_public.h" | |
25 #include "ui/views/view.h" | 25 #include "ui/views/view.h" |
26 #include "ui/views/widget/native_widget_aura.h" | 26 #include "ui/views/widget/native_widget_aura.h" |
27 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
28 #include "ui/views/widget/widget_delegate.h" | 28 #include "ui/views/widget/widget_delegate.h" |
29 | 29 |
30 using views::Widget; | 30 using views::Widget; |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 // Color for the window title text. | 34 // Color for the window title text. |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint); | 276 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint); |
277 } | 277 } |
278 | 278 |
279 bool DefaultHeaderPainter::ShouldUseLightImages() { | 279 bool DefaultHeaderPainter::ShouldUseLightImages() { |
280 return color_utils::IsDark(mode_ == MODE_INACTIVE ? inactive_frame_color_ | 280 return color_utils::IsDark(mode_ == MODE_INACTIVE ? inactive_frame_color_ |
281 : active_frame_color_); | 281 : active_frame_color_); |
282 } | 282 } |
283 | 283 |
284 void DefaultHeaderPainter::UpdateAllButtonImages() { | 284 void DefaultHeaderPainter::UpdateAllButtonImages() { |
285 caption_button_container_->SetUseLightImages(ShouldUseLightImages()); | 285 caption_button_container_->SetUseLightImages(ShouldUseLightImages()); |
286 caption_button_container_->SetButtonImage( | 286 caption_button_container_->SetButtonImage(CAPTION_BUTTON_ICON_MINIMIZE, |
287 CAPTION_BUTTON_ICON_MINIMIZE, gfx::VectorIconId::WINDOW_CONTROL_MINIMIZE); | 287 kWindowControlMinimizeIcon); |
288 | 288 |
289 UpdateSizeButtonImages(); | 289 UpdateSizeButtonImages(); |
290 | 290 |
291 caption_button_container_->SetButtonImage( | 291 caption_button_container_->SetButtonImage(CAPTION_BUTTON_ICON_CLOSE, |
292 CAPTION_BUTTON_ICON_CLOSE, gfx::VectorIconId::WINDOW_CONTROL_CLOSE); | 292 kWindowControlCloseIcon); |
293 | 293 |
294 caption_button_container_->SetButtonImage( | 294 caption_button_container_->SetButtonImage(CAPTION_BUTTON_ICON_LEFT_SNAPPED, |
295 CAPTION_BUTTON_ICON_LEFT_SNAPPED, | 295 kWindowControlLeftSnappedIcon); |
296 gfx::VectorIconId::WINDOW_CONTROL_LEFT_SNAPPED); | |
297 | 296 |
298 caption_button_container_->SetButtonImage( | 297 caption_button_container_->SetButtonImage(CAPTION_BUTTON_ICON_RIGHT_SNAPPED, |
299 CAPTION_BUTTON_ICON_RIGHT_SNAPPED, | 298 kWindowControlRightSnappedIcon); |
300 gfx::VectorIconId::WINDOW_CONTROL_RIGHT_SNAPPED); | |
301 } | 299 } |
302 | 300 |
303 void DefaultHeaderPainter::UpdateSizeButtonImages() { | 301 void DefaultHeaderPainter::UpdateSizeButtonImages() { |
304 gfx::VectorIconId icon_id = frame_->IsMaximized() || frame_->IsFullscreen() | 302 const gfx::VectorIcon& icon = frame_->IsMaximized() || frame_->IsFullscreen() |
305 ? gfx::VectorIconId::WINDOW_CONTROL_RESTORE | 303 ? kWindowControlRestoreIcon |
306 : gfx::VectorIconId::WINDOW_CONTROL_MAXIMIZE; | 304 : kWindowControlMaximizeIcon; |
307 caption_button_container_->SetButtonImage( | 305 caption_button_container_->SetButtonImage( |
308 CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, icon_id); | 306 CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, icon); |
309 } | 307 } |
310 | 308 |
311 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const { | 309 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const { |
312 return gfx::Rect(view_->width(), painted_height_); | 310 return gfx::Rect(view_->width(), painted_height_); |
313 } | 311 } |
314 | 312 |
315 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { | 313 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { |
316 return HeaderPainterUtil::GetTitleBounds( | 314 return HeaderPainterUtil::GetTitleBounds( |
317 left_header_view_, caption_button_container_, GetTitleFontList()); | 315 left_header_view_, caption_button_container_, GetTitleFontList()); |
318 } | 316 } |
319 | 317 |
320 bool DefaultHeaderPainter::UsesCustomFrameColors() const { | 318 bool DefaultHeaderPainter::UsesCustomFrameColors() const { |
321 return active_frame_color_ != kDefaultFrameColor || | 319 return active_frame_color_ != kDefaultFrameColor || |
322 inactive_frame_color_ != kDefaultFrameColor; | 320 inactive_frame_color_ != kDefaultFrameColor; |
323 } | 321 } |
324 | 322 |
325 } // namespace ash | 323 } // namespace ash |
OLD | NEW |