| 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 "ash/resources/vector_icons/vector_icons.h" |
| 11 #include "base/debug/leak_annotations.h" | 11 #include "base/debug/leak_annotations.h" |
| 12 #include "base/logging.h" // DCHECK | 12 #include "base/logging.h" // DCHECK |
| 13 #include "grit/ash_resources.h" | 13 #include "grit/ash_resources.h" |
| 14 #include "third_party/skia/include/core/SkPaint.h" | |
| 15 #include "third_party/skia/include/core/SkPath.h" | 14 #include "third_party/skia/include/core/SkPath.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/gfx/animation/slide_animation.h" | 16 #include "ui/gfx/animation/slide_animation.h" |
| 18 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
| 19 #include "ui/gfx/color_utils.h" | 18 #include "ui/gfx/color_utils.h" |
| 20 #include "ui/gfx/font_list.h" | 19 #include "ui/gfx/font_list.h" |
| 21 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
| 22 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
| 23 #include "ui/gfx/scoped_canvas.h" | 22 #include "ui/gfx/scoped_canvas.h" |
| 24 #include "ui/gfx/skia_util.h" | 23 #include "ui/gfx/skia_util.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 38 // Color of the inactive window header/content separator line. | 37 // Color of the inactive window header/content separator line. |
| 39 const SkColor kHeaderContentSeparatorInactiveColor = | 38 const SkColor kHeaderContentSeparatorInactiveColor = |
| 40 SkColorSetRGB(180, 180, 182); | 39 SkColorSetRGB(180, 180, 182); |
| 41 // The default color of the frame. | 40 // The default color of the frame. |
| 42 const SkColor kDefaultFrameColor = SkColorSetRGB(242, 242, 242); | 41 const SkColor kDefaultFrameColor = SkColorSetRGB(242, 242, 242); |
| 43 // Duration of crossfade animation for activating and deactivating frame. | 42 // Duration of crossfade animation for activating and deactivating frame. |
| 44 const int kActivationCrossfadeDurationMs = 200; | 43 const int kActivationCrossfadeDurationMs = 200; |
| 45 | 44 |
| 46 // Tiles an image into an area, rounding the top corners. | 45 // Tiles an image into an area, rounding the top corners. |
| 47 void TileRoundRect(gfx::Canvas* canvas, | 46 void TileRoundRect(gfx::Canvas* canvas, |
| 48 const SkPaint& paint, | 47 const cc::PaintFlags& paint, |
| 49 const gfx::Rect& bounds, | 48 const gfx::Rect& bounds, |
| 50 int corner_radius) { | 49 int corner_radius) { |
| 51 SkRect rect = gfx::RectToSkRect(bounds); | 50 SkRect rect = gfx::RectToSkRect(bounds); |
| 52 const SkScalar corner_radius_scalar = SkIntToScalar(corner_radius); | 51 const SkScalar corner_radius_scalar = SkIntToScalar(corner_radius); |
| 53 SkScalar radii[8] = {corner_radius_scalar, | 52 SkScalar radii[8] = {corner_radius_scalar, |
| 54 corner_radius_scalar, // top-left | 53 corner_radius_scalar, // top-left |
| 55 corner_radius_scalar, | 54 corner_radius_scalar, |
| 56 corner_radius_scalar, // top-right | 55 corner_radius_scalar, // top-right |
| 57 0, | 56 0, |
| 58 0, // bottom-right | 57 0, // bottom-right |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 else | 131 else |
| 133 activation_animation_->Reset(0); | 132 activation_animation_->Reset(0); |
| 134 } | 133 } |
| 135 initial_paint_ = false; | 134 initial_paint_ = false; |
| 136 } | 135 } |
| 137 | 136 |
| 138 int corner_radius = (frame_->IsMaximized() || frame_->IsFullscreen()) | 137 int corner_radius = (frame_->IsMaximized() || frame_->IsFullscreen()) |
| 139 ? 0 | 138 ? 0 |
| 140 : HeaderPainterUtil::GetTopCornerRadiusWhenRestored(); | 139 : HeaderPainterUtil::GetTopCornerRadiusWhenRestored(); |
| 141 | 140 |
| 142 SkPaint paint; | 141 cc::PaintFlags paint; |
| 143 int active_alpha = activation_animation_->CurrentValueBetween(0, 255); | 142 int active_alpha = activation_animation_->CurrentValueBetween(0, 255); |
| 144 paint.setColor(color_utils::AlphaBlend(active_frame_color_, | 143 paint.setColor(color_utils::AlphaBlend(active_frame_color_, |
| 145 inactive_frame_color_, active_alpha)); | 144 inactive_frame_color_, active_alpha)); |
| 146 paint.setAntiAlias(true); | 145 paint.setAntiAlias(true); |
| 147 TileRoundRect(canvas, paint, GetLocalBounds(), corner_radius); | 146 TileRoundRect(canvas, paint, GetLocalBounds(), corner_radius); |
| 148 | 147 |
| 149 if (!frame_->IsMaximized() && !frame_->IsFullscreen() && | 148 if (!frame_->IsMaximized() && !frame_->IsFullscreen() && |
| 150 mode_ == MODE_INACTIVE && !UsesCustomFrameColors()) { | 149 mode_ == MODE_INACTIVE && !UsesCustomFrameColors()) { |
| 151 PaintHighlightForInactiveRestoredWindow(canvas); | 150 PaintHighlightForInactiveRestoredWindow(canvas); |
| 152 } | 151 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 title_bounds.set_x(view_->GetMirroredXForRect(title_bounds)); | 262 title_bounds.set_x(view_->GetMirroredXForRect(title_bounds)); |
| 264 canvas->DrawStringRectWithFlags( | 263 canvas->DrawStringRectWithFlags( |
| 265 frame_->widget_delegate()->GetWindowTitle(), GetTitleFontList(), | 264 frame_->widget_delegate()->GetWindowTitle(), GetTitleFontList(), |
| 266 kTitleTextColor, title_bounds, gfx::Canvas::NO_SUBPIXEL_RENDERING); | 265 kTitleTextColor, title_bounds, gfx::Canvas::NO_SUBPIXEL_RENDERING); |
| 267 } | 266 } |
| 268 | 267 |
| 269 void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) { | 268 void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) { |
| 270 gfx::ScopedCanvas scoped_canvas(canvas); | 269 gfx::ScopedCanvas scoped_canvas(canvas); |
| 271 const float scale = canvas->UndoDeviceScaleFactor(); | 270 const float scale = canvas->UndoDeviceScaleFactor(); |
| 272 gfx::RectF rect(0, painted_height_ * scale - 1, view_->width() * scale, 1); | 271 gfx::RectF rect(0, painted_height_ * scale - 1, view_->width() * scale, 1); |
| 273 SkPaint paint; | 272 cc::PaintFlags paint; |
| 274 paint.setColor((mode_ == MODE_ACTIVE) ? kHeaderContentSeparatorColor | 273 paint.setColor((mode_ == MODE_ACTIVE) ? kHeaderContentSeparatorColor |
| 275 : kHeaderContentSeparatorInactiveColor); | 274 : kHeaderContentSeparatorInactiveColor); |
| 276 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint); | 275 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint); |
| 277 } | 276 } |
| 278 | 277 |
| 279 bool DefaultHeaderPainter::ShouldUseLightImages() { | 278 bool DefaultHeaderPainter::ShouldUseLightImages() { |
| 280 return color_utils::IsDark(mode_ == MODE_INACTIVE ? inactive_frame_color_ | 279 return color_utils::IsDark(mode_ == MODE_INACTIVE ? inactive_frame_color_ |
| 281 : active_frame_color_); | 280 : active_frame_color_); |
| 282 } | 281 } |
| 283 | 282 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 314 return HeaderPainterUtil::GetTitleBounds( | 313 return HeaderPainterUtil::GetTitleBounds( |
| 315 left_header_view_, caption_button_container_, GetTitleFontList()); | 314 left_header_view_, caption_button_container_, GetTitleFontList()); |
| 316 } | 315 } |
| 317 | 316 |
| 318 bool DefaultHeaderPainter::UsesCustomFrameColors() const { | 317 bool DefaultHeaderPainter::UsesCustomFrameColors() const { |
| 319 return active_frame_color_ != kDefaultFrameColor || | 318 return active_frame_color_ != kDefaultFrameColor || |
| 320 inactive_frame_color_ != kDefaultFrameColor; | 319 inactive_frame_color_ != kDefaultFrameColor; |
| 321 } | 320 } |
| 322 | 321 |
| 323 } // namespace ash | 322 } // namespace ash |
| OLD | NEW |