| 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 |
| 11 #include "grit/ash_resources.h" | 11 #include "grit/ash_resources.h" |
| 12 #include "third_party/skia/include/core/SkPaint.h" | 12 #include "third_party/skia/include/core/SkPaint.h" |
| 13 #include "third_party/skia/include/core/SkPath.h" | 13 #include "third_party/skia/include/core/SkPath.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/gfx/animation/slide_animation.h" | 15 #include "ui/gfx/animation/slide_animation.h" |
| 16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/color_utils.h" | 17 #include "ui/gfx/color_utils.h" |
| 18 #include "ui/gfx/font_list.h" | 18 #include "ui/gfx/font_list.h" |
| 19 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| 20 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
| 21 #include "ui/gfx/scoped_canvas.h" |
| 21 #include "ui/gfx/skia_util.h" | 22 #include "ui/gfx/skia_util.h" |
| 22 #include "ui/views/view.h" | 23 #include "ui/views/view.h" |
| 23 #include "ui/views/widget/native_widget_aura.h" | 24 #include "ui/views/widget/native_widget_aura.h" |
| 24 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
| 25 #include "ui/views/widget/widget_delegate.h" | 26 #include "ui/views/widget/widget_delegate.h" |
| 26 | 27 |
| 27 using views::Widget; | 28 using views::Widget; |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 gfx::Rect title_bounds = GetTitleBounds(); | 256 gfx::Rect title_bounds = GetTitleBounds(); |
| 256 title_bounds.set_x(view_->GetMirroredXForRect(title_bounds)); | 257 title_bounds.set_x(view_->GetMirroredXForRect(title_bounds)); |
| 257 canvas->DrawStringRectWithFlags(frame_->widget_delegate()->GetWindowTitle(), | 258 canvas->DrawStringRectWithFlags(frame_->widget_delegate()->GetWindowTitle(), |
| 258 GetTitleFontList(), | 259 GetTitleFontList(), |
| 259 kTitleTextColor, | 260 kTitleTextColor, |
| 260 title_bounds, | 261 title_bounds, |
| 261 gfx::Canvas::NO_SUBPIXEL_RENDERING); | 262 gfx::Canvas::NO_SUBPIXEL_RENDERING); |
| 262 } | 263 } |
| 263 | 264 |
| 264 void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) { | 265 void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) { |
| 265 const float scale = canvas->SaveAndUnscale(); | 266 gfx::ScopedCanvas scoped_canvas(canvas); |
| 267 const float scale = canvas->UndoDeviceScaleFactor(); |
| 266 gfx::RectF rect(0, painted_height_ * scale - 1, view_->width() * scale, 1); | 268 gfx::RectF rect(0, painted_height_ * scale - 1, view_->width() * scale, 1); |
| 267 SkPaint paint; | 269 SkPaint paint; |
| 268 paint.setColor((mode_ == MODE_ACTIVE) ? | 270 paint.setColor((mode_ == MODE_ACTIVE) ? |
| 269 kHeaderContentSeparatorColor : kHeaderContentSeparatorInactiveColor); | 271 kHeaderContentSeparatorColor : kHeaderContentSeparatorInactiveColor); |
| 270 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint); | 272 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint); |
| 271 canvas->Restore(); | |
| 272 } | 273 } |
| 273 | 274 |
| 274 void DefaultHeaderPainter::LayoutLeftHeaderView() { | 275 void DefaultHeaderPainter::LayoutLeftHeaderView() { |
| 275 if (left_header_view_) { | 276 if (left_header_view_) { |
| 276 // Vertically center the left header view with respect to the caption button | 277 // Vertically center the left header view with respect to the caption button |
| 277 // container. | 278 // container. |
| 278 // Floor when computing the center of |caption_button_container_|. | 279 // Floor when computing the center of |caption_button_container_|. |
| 279 gfx::Size size = left_header_view_->GetPreferredSize(); | 280 gfx::Size size = left_header_view_->GetPreferredSize(); |
| 280 int icon_offset_y = caption_button_container_->height() / 2 - | 281 int icon_offset_y = caption_button_container_->height() / 2 - |
| 281 size.height() / 2; | 282 size.height() / 2; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 return HeaderPainterUtil::GetTitleBounds( | 348 return HeaderPainterUtil::GetTitleBounds( |
| 348 left_header_view_, caption_button_container_, GetTitleFontList()); | 349 left_header_view_, caption_button_container_, GetTitleFontList()); |
| 349 } | 350 } |
| 350 | 351 |
| 351 bool DefaultHeaderPainter::UsesCustomFrameColors() const { | 352 bool DefaultHeaderPainter::UsesCustomFrameColors() const { |
| 352 return active_frame_color_ != kDefaultFrameColor || | 353 return active_frame_color_ != kDefaultFrameColor || |
| 353 inactive_frame_color_ != kDefaultFrameColor; | 354 inactive_frame_color_ != kDefaultFrameColor; |
| 354 } | 355 } |
| 355 | 356 |
| 356 } // namespace ash | 357 } // namespace ash |
| OLD | NEW |