| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mash/wm/frame/default_header_painter.h" | 5 #include "mash/wm/frame/default_header_painter.h" |
| 6 | 6 |
| 7 #include "base/debug/leak_annotations.h" | 7 #include "base/debug/leak_annotations.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "grit/mash_wm_resources.h" | 9 #include "grit/mash_wm_resources.h" |
| 10 #include "mash/wm/frame/caption_buttons/frame_caption_button_container_view.h" | 10 #include "mash/wm/frame/caption_buttons/frame_caption_button_container_view.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40); | 33 const SkColor kTitleTextColor = SkColorSetRGB(40, 40, 40); |
| 34 // Color of the active window header/content separator line. | 34 // Color of the active window header/content separator line. |
| 35 const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(150, 150, 152); | 35 const SkColor kHeaderContentSeparatorColor = SkColorSetRGB(150, 150, 152); |
| 36 // Color of the inactive window header/content separator line. | 36 // Color of the inactive window header/content separator line. |
| 37 const SkColor kHeaderContentSeparatorInactiveColor = | 37 const SkColor kHeaderContentSeparatorInactiveColor = |
| 38 SkColorSetRGB(180, 180, 182); | 38 SkColorSetRGB(180, 180, 182); |
| 39 // The default color of the frame. | 39 // The default color of the frame. |
| 40 const SkColor kDefaultFrameColor = SkColorSetRGB(242, 242, 242); | 40 const SkColor kDefaultFrameColor = SkColorSetRGB(242, 242, 242); |
| 41 // Duration of crossfade animation for activating and deactivating frame. | 41 // Duration of crossfade animation for activating and deactivating frame. |
| 42 const int kActivationCrossfadeDurationMs = 200; | 42 const int kActivationCrossfadeDurationMs = 200; |
| 43 // Luminance below which to use white caption buttons. | |
| 44 const int kMaxLuminanceForLightButtons = 125; | |
| 45 | 43 |
| 46 // Tiles an image into an area, rounding the top corners. | 44 // Tiles an image into an area, rounding the top corners. |
| 47 void TileRoundRect(gfx::Canvas* canvas, | 45 void TileRoundRect(gfx::Canvas* canvas, |
| 48 const SkPaint& paint, | 46 const SkPaint& paint, |
| 49 const gfx::Rect& bounds, | 47 const gfx::Rect& bounds, |
| 50 int corner_radius) { | 48 int corner_radius) { |
| 51 SkRect rect = gfx::RectToSkRect(bounds); | 49 SkRect rect = gfx::RectToSkRect(bounds); |
| 52 const SkScalar corner_radius_scalar = SkIntToScalar(corner_radius); | 50 const SkScalar corner_radius_scalar = SkIntToScalar(corner_radius); |
| 53 SkScalar radii[8] = {corner_radius_scalar, | 51 SkScalar radii[8] = {corner_radius_scalar, |
| 54 corner_radius_scalar, // top-left | 52 corner_radius_scalar, // top-left |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 gfx::ScopedCanvas scoped_canvas(canvas); | 260 gfx::ScopedCanvas scoped_canvas(canvas); |
| 263 const float scale = canvas->UndoDeviceScaleFactor(); | 261 const float scale = canvas->UndoDeviceScaleFactor(); |
| 264 gfx::RectF rect(0, painted_height_ * scale - 1, view_->width() * scale, 1); | 262 gfx::RectF rect(0, painted_height_ * scale - 1, view_->width() * scale, 1); |
| 265 SkPaint paint; | 263 SkPaint paint; |
| 266 paint.setColor((mode_ == MODE_ACTIVE) ? kHeaderContentSeparatorColor | 264 paint.setColor((mode_ == MODE_ACTIVE) ? kHeaderContentSeparatorColor |
| 267 : kHeaderContentSeparatorInactiveColor); | 265 : kHeaderContentSeparatorInactiveColor); |
| 268 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint); | 266 canvas->sk_canvas()->drawRect(gfx::RectFToSkRect(rect), paint); |
| 269 } | 267 } |
| 270 | 268 |
| 271 bool DefaultHeaderPainter::ShouldUseLightImages() { | 269 bool DefaultHeaderPainter::ShouldUseLightImages() { |
| 272 int luminance = color_utils::GetLuminanceForColor( | 270 return color_utils::IsDark( |
| 273 mode_ == MODE_INACTIVE ? inactive_frame_color_ : active_frame_color_); | 271 mode_ == MODE_INACTIVE ? inactive_frame_color_ : active_frame_color_); |
| 274 return luminance < kMaxLuminanceForLightButtons; | |
| 275 } | 272 } |
| 276 | 273 |
| 277 void DefaultHeaderPainter::UpdateAllButtonImages() { | 274 void DefaultHeaderPainter::UpdateAllButtonImages() { |
| 278 bool use_light_images = ShouldUseLightImages(); | 275 bool use_light_images = ShouldUseLightImages(); |
| 279 caption_button_container_->SetButtonImages( | 276 caption_button_container_->SetButtonImages( |
| 280 CAPTION_BUTTON_ICON_MINIMIZE, | 277 CAPTION_BUTTON_ICON_MINIMIZE, |
| 281 use_light_images ? IDR_MASH_WM_WINDOW_CONTROL_ICON_MINIMIZE_WHITE | 278 use_light_images ? IDR_MASH_WM_WINDOW_CONTROL_ICON_MINIMIZE_WHITE |
| 282 : IDR_MASH_WM_WINDOW_CONTROL_ICON_MINIMIZE, | 279 : IDR_MASH_WM_WINDOW_CONTROL_ICON_MINIMIZE, |
| 283 IDR_MASH_WM_WINDOW_CONTROL_BACKGROUND_H, | 280 IDR_MASH_WM_WINDOW_CONTROL_BACKGROUND_H, |
| 284 IDR_MASH_WM_WINDOW_CONTROL_BACKGROUND_P); | 281 IDR_MASH_WM_WINDOW_CONTROL_BACKGROUND_P); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 left_header_view_, caption_button_container_, GetTitleFontList()); | 328 left_header_view_, caption_button_container_, GetTitleFontList()); |
| 332 } | 329 } |
| 333 | 330 |
| 334 bool DefaultHeaderPainter::UsesCustomFrameColors() const { | 331 bool DefaultHeaderPainter::UsesCustomFrameColors() const { |
| 335 return active_frame_color_ != kDefaultFrameColor || | 332 return active_frame_color_ != kDefaultFrameColor || |
| 336 inactive_frame_color_ != kDefaultFrameColor; | 333 inactive_frame_color_ != kDefaultFrameColor; |
| 337 } | 334 } |
| 338 | 335 |
| 339 } // namespace wm | 336 } // namespace wm |
| 340 } // namespace mash | 337 } // namespace mash |
| OLD | NEW |