Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: ash/frame/default_header_painter.cc

Issue 200493004: Make the header/content separator into a hairline for apps in hidpi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/frame/custom_frame_view_ash_unittest.cc ('k') | ash/frame/header_painter_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 #include "ui/views/widget/native_widget_aura.h" 23 #include "ui/views/widget/native_widget_aura.h"
24 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
25 #include "ui/views/widget/widget_delegate.h" 25 #include "ui/views/widget/widget_delegate.h"
26 26
27 using views::Widget; 27 using views::Widget;
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 // Size of header/content separator line.
34 const int kHeaderContentSeparatorSize = 1;
35 // Color of the active window header/content separator line. 33 // Color of the active window header/content separator line.
36 const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(180, 180, 182); 34 const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(180, 180, 182);
37 // Color of the inactive window header/content separator line. 35 // Color of the inactive window header/content separator line.
38 const SkColor kHeaderContentSeparatorInactiveColor = 36 const SkColor kHeaderContentSeparatorInactiveColor =
39 SkColorSetRGB(150, 150, 152); 37 SkColorSetRGB(150, 150, 152);
40 // Duration of crossfade animation for activating and deactivating frame. 38 // Duration of crossfade animation for activating and deactivating frame.
41 const int kActivationCrossfadeDurationMs = 200; 39 const int kActivationCrossfadeDurationMs = 200;
42 40
43 // Tiles an image into an area, rounding the top corners. 41 // Tiles an image into an area, rounding the top corners.
44 void TileRoundRect(gfx::Canvas* canvas, 42 void TileRoundRect(gfx::Canvas* canvas,
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 caption_button_container_->SetBounds( 209 caption_button_container_->SetBounds(
212 view_->width() - caption_button_container_size.width(), 210 view_->width() - caption_button_container_size.width(),
213 0, 211 0,
214 caption_button_container_size.width(), 212 caption_button_container_size.width(),
215 caption_button_container_size.height()); 213 caption_button_container_size.height());
216 214
217 if (window_icon_) { 215 if (window_icon_) {
218 // Vertically center the window icon with respect to the caption button 216 // Vertically center the window icon with respect to the caption button
219 // container. 217 // container.
220 int icon_size = HeaderPainterUtil::GetIconSize(); 218 int icon_size = HeaderPainterUtil::GetIconSize();
221 int icon_offset_y = (caption_button_container_->height() - icon_size) / 2; 219 // Floor when computing the center of |caption_button_container|.
220 int icon_offset_y = caption_button_container_->height() / 2 - icon_size / 2;
222 window_icon_->SetBounds(HeaderPainterUtil::GetIconXOffset(), icon_offset_y, 221 window_icon_->SetBounds(HeaderPainterUtil::GetIconXOffset(), icon_offset_y,
223 icon_size, icon_size); 222 icon_size, icon_size);
224 } 223 }
225 224
226 SetHeaderHeightForPainting(caption_button_container_->height() + 225 // The header/content separator line overlays the caption buttons.
227 kHeaderContentSeparatorSize); 226 SetHeaderHeightForPainting(caption_button_container_->height());
228 } 227 }
229 228
230 int DefaultHeaderPainter::GetHeaderHeightForPainting() const { 229 int DefaultHeaderPainter::GetHeaderHeightForPainting() const {
231 return height_; 230 return height_;
232 } 231 }
233 232
234 void DefaultHeaderPainter::SetHeaderHeightForPainting(int height) { 233 void DefaultHeaderPainter::SetHeaderHeightForPainting(int height) {
235 height_ = height; 234 height_ = height;
236 } 235 }
237 236
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 kTitleTextColor, 292 kTitleTextColor,
294 title_bounds, 293 title_bounds,
295 gfx::Canvas::NO_SUBPIXEL_RENDERING); 294 gfx::Canvas::NO_SUBPIXEL_RENDERING);
296 } 295 }
297 296
298 void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) { 297 void DefaultHeaderPainter::PaintHeaderContentSeparator(gfx::Canvas* canvas) {
299 SkColor color = (mode_ == MODE_ACTIVE) ? 298 SkColor color = (mode_ == MODE_ACTIVE) ?
300 kHeaderContentSeparatorColor : 299 kHeaderContentSeparatorColor :
301 kHeaderContentSeparatorInactiveColor; 300 kHeaderContentSeparatorInactiveColor;
302 301
303 canvas->FillRect(gfx::Rect(0, 302 SkPaint paint;
304 height_ - kHeaderContentSeparatorSize, 303 paint.setColor(color);
305 view_->width(), 304 // Draw the line as 1px thick regardless of scale factor.
James Cook 2014/03/17 16:55:59 Thanks for this comment. It saves the reader from
306 kHeaderContentSeparatorSize), 305 paint.setStrokeWidth(0);
307 color); 306
307 float thickness = 1 / canvas->image_scale();
308 SkScalar y = SkIntToScalar(height_) - SkFloatToScalar(thickness);
309 canvas->sk_canvas()->drawLine(0, y, SkIntToScalar(view_->width()), y, paint);
308 } 310 }
309 311
310 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const { 312 gfx::Rect DefaultHeaderPainter::GetLocalBounds() const {
311 return gfx::Rect(view_->width(), height_); 313 return gfx::Rect(view_->width(), height_);
312 } 314 }
313 315
314 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const { 316 gfx::Rect DefaultHeaderPainter::GetTitleBounds() const {
315 return HeaderPainterUtil::GetTitleBounds( 317 return HeaderPainterUtil::GetTitleBounds(
316 window_icon_, caption_button_container_, GetTitleFontList()); 318 window_icon_, caption_button_container_, GetTitleFontList());
317 } 319 }
318 320
319 } // namespace ash 321 } // namespace ash
OLDNEW
« no previous file with comments | « ash/frame/custom_frame_view_ash_unittest.cc ('k') | ash/frame/header_painter_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698