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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 gfx::Rect title_bounds = GetTitleBounds(); | 255 gfx::Rect title_bounds = GetTitleBounds(); |
256 title_bounds.set_x(view_->GetMirroredXForRect(title_bounds)); | 256 title_bounds.set_x(view_->GetMirroredXForRect(title_bounds)); |
257 canvas->DrawStringRectWithFlags(frame_->widget_delegate()->GetWindowTitle(), | 257 canvas->DrawStringRectWithFlags(frame_->widget_delegate()->GetWindowTitle(), |
258 GetTitleFontList(), | 258 GetTitleFontList(), |
259 kTitleTextColor, | 259 kTitleTextColor, |
260 title_bounds, | 260 title_bounds, |
261 gfx::Canvas::NO_SUBPIXEL_RENDERING); | 261 gfx::Canvas::NO_SUBPIXEL_RENDERING); |
262 } | 262 } |
263 | 263 |
264 void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) { | 264 void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) { |
265 SkColor color = (mode_ == MODE_ACTIVE) ? | 265 const float scale = canvas->SaveAndUnscale(); |
266 kHeaderContentSeparatorColor : | 266 gfx::RectF rect(0, painted_height_ * scale - 1, view_->width() * scale, 1); |
267 kHeaderContentSeparatorInactiveColor; | |
268 | |
269 SkPaint paint; | 267 SkPaint paint; |
270 paint.setColor(color); | 268 paint.setColor((mode_ == MODE_ACTIVE) ? |
271 // Draw the line as 1px thick regardless of scale factor. | 269 kHeaderContentSeparatorColor : kHeaderContentSeparatorInactiveColor); |
272 paint.setStrokeWidth(0); | 270 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint); |
273 | 271 canvas->Restore(); |
274 float thickness = 1 / canvas->image_scale(); | |
275 SkScalar y = SkIntToScalar(painted_height_) - SkFloatToScalar(thickness); | |
276 canvas->sk_canvas()->drawLine(0, y, SkIntToScalar(view_->width()), y, paint); | |
277 } | 272 } |
278 | 273 |
279 void DefaultHeaderPainter::LayoutLeftHeaderView() { | 274 void DefaultHeaderPainter::LayoutLeftHeaderView() { |
280 if (left_header_view_) { | 275 if (left_header_view_) { |
281 // Vertically center the left header view with respect to the caption button | 276 // Vertically center the left header view with respect to the caption button |
282 // container. | 277 // container. |
283 // Floor when computing the center of |caption_button_container_|. | 278 // Floor when computing the center of |caption_button_container_|. |
284 gfx::Size size = left_header_view_->GetPreferredSize(); | 279 gfx::Size size = left_header_view_->GetPreferredSize(); |
285 int icon_offset_y = caption_button_container_->height() / 2 - | 280 int icon_offset_y = caption_button_container_->height() / 2 - |
286 size.height() / 2; | 281 size.height() / 2; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 return HeaderPainterUtil::GetTitleBounds( | 347 return HeaderPainterUtil::GetTitleBounds( |
353 left_header_view_, caption_button_container_, GetTitleFontList()); | 348 left_header_view_, caption_button_container_, GetTitleFontList()); |
354 } | 349 } |
355 | 350 |
356 bool DefaultHeaderPainter::UsesCustomFrameColors() const { | 351 bool DefaultHeaderPainter::UsesCustomFrameColors() const { |
357 return active_frame_color_ != kDefaultFrameColor || | 352 return active_frame_color_ != kDefaultFrameColor || |
358 inactive_frame_color_ != kDefaultFrameColor; | 353 inactive_frame_color_ != kDefaultFrameColor; |
359 } | 354 } |
360 | 355 |
361 } // namespace ash | 356 } // namespace ash |
OLD | NEW |