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

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

Issue 1761183002: color_utils cleanup: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename functions Created 4 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
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/ash_layout_constants.h" 7 #include "ash/ash_layout_constants.h"
8 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" 8 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
9 #include "ash/frame/header_painter_util.h" 9 #include "ash/frame/header_painter_util.h"
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
(...skipping 24 matching lines...) Expand all
35 const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40); 35 const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40);
36 // Color of the active window header/content separator line. 36 // Color of the active window header/content separator line.
37 const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(150, 150, 152); 37 const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(150, 150, 152);
38 // Color of the inactive window header/content separator line. 38 // Color of the inactive window header/content separator line.
39 const SkColor kHeaderContentSeparatorInactiveColor = 39 const SkColor kHeaderContentSeparatorInactiveColor =
40 SkColorSetRGB(180, 180, 182); 40 SkColorSetRGB(180, 180, 182);
41 // The default color of the frame. 41 // The default color of the frame.
42 const SkColor kDefaultFrameColor = SkColorSetRGB(242, 242, 242); 42 const SkColor kDefaultFrameColor = SkColorSetRGB(242, 242, 242);
43 // Duration of crossfade animation for activating and deactivating frame. 43 // Duration of crossfade animation for activating and deactivating frame.
44 const int kActivationCrossfadeDurationMs = 200; 44 const int kActivationCrossfadeDurationMs = 200;
45 // Luminance below which to use white caption buttons.
46 const int kMaxLuminanceForLightButtons = 125;
47 45
48 // Tiles an image into an area, rounding the top corners. 46 // Tiles an image into an area, rounding the top corners.
49 void TileRoundRect(gfx::Canvas* canvas, 47 void TileRoundRect(gfx::Canvas* canvas,
50 const SkPaint& paint, 48 const SkPaint& paint,
51 const gfx::Rect& bounds, 49 const gfx::Rect& bounds,
52 int corner_radius) { 50 int corner_radius) {
53 SkRect rect = gfx::RectToSkRect(bounds); 51 SkRect rect = gfx::RectToSkRect(bounds);
54 const SkScalar corner_radius_scalar = SkIntToScalar(corner_radius); 52 const SkScalar corner_radius_scalar = SkIntToScalar(corner_radius);
55 SkScalar radii[8] = { 53 SkScalar radii[8] = {
56 corner_radius_scalar, corner_radius_scalar, // top-left 54 corner_radius_scalar, corner_radius_scalar, // top-left
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 gfx::ScopedCanvas scoped_canvas(canvas); 270 gfx::ScopedCanvas scoped_canvas(canvas);
273 const float scale = canvas->UndoDeviceScaleFactor(); 271 const float scale = canvas->UndoDeviceScaleFactor();
274 gfx::RectF rect(0, painted_height_ * scale - 1, view_->width() * scale, 1); 272 gfx::RectF rect(0, painted_height_ * scale - 1, view_->width() * scale, 1);
275 SkPaint paint; 273 SkPaint paint;
276 paint.setColor((mode_ == MODE_ACTIVE) ? 274 paint.setColor((mode_ == MODE_ACTIVE) ?
277 kHeaderContentSeparatorColor : kHeaderContentSeparatorInactiveColor); 275 kHeaderContentSeparatorColor : kHeaderContentSeparatorInactiveColor);
278 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint); 276 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint);
279 } 277 }
280 278
281 bool DefaultHeaderPainter::ShouldUseLightImages() { 279 bool DefaultHeaderPainter::ShouldUseLightImages() {
282 int luminance = color_utils::GetLuminanceForColor( 280 return color_utils::IsDark(mode_ == MODE_INACTIVE ? inactive_frame_color_
283 mode_ == MODE_INACTIVE ? inactive_frame_color_ : active_frame_color_); 281 : active_frame_color_);
284 return luminance < kMaxLuminanceForLightButtons;
285 } 282 }
286 283
287 void DefaultHeaderPainter::UpdateAllButtonImages() { 284 void DefaultHeaderPainter::UpdateAllButtonImages() {
288 caption_button_container_->SetUseLightImages(ShouldUseLightImages()); 285 caption_button_container_->SetUseLightImages(ShouldUseLightImages());
289 caption_button_container_->SetButtonImage( 286 caption_button_container_->SetButtonImage(
290 CAPTION_BUTTON_ICON_MINIMIZE, gfx::VectorIconId::WINDOW_CONTROL_MINIMIZE); 287 CAPTION_BUTTON_ICON_MINIMIZE, gfx::VectorIconId::WINDOW_CONTROL_MINIMIZE);
291 288
292 UpdateSizeButtonImages(); 289 UpdateSizeButtonImages();
293 290
294 caption_button_container_->SetButtonImage( 291 caption_button_container_->SetButtonImage(
(...skipping 24 matching lines...) Expand all
319 return HeaderPainterUtil::GetTitleBounds( 316 return HeaderPainterUtil::GetTitleBounds(
320 left_header_view_, caption_button_container_, GetTitleFontList()); 317 left_header_view_, caption_button_container_, GetTitleFontList());
321 } 318 }
322 319
323 bool DefaultHeaderPainter::UsesCustomFrameColors() const { 320 bool DefaultHeaderPainter::UsesCustomFrameColors() const {
324 return active_frame_color_ != kDefaultFrameColor || 321 return active_frame_color_ != kDefaultFrameColor ||
325 inactive_frame_color_ != kDefaultFrameColor; 322 inactive_frame_color_ != kDefaultFrameColor;
326 } 323 }
327 324
328 } // namespace ash 325 } // namespace ash
OLDNEW
« no previous file with comments | « apps/ui/views/app_window_frame_view.cc ('k') | chrome/browser/extensions/bookmark_app_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698