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

Side by Side Diff: apps/ui/views/app_window_frame_view.cc

Issue 1761183002: color_utils cleanup: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | ash/frame/default_header_painter.cc » ('j') | ash/frame/default_header_painter.cc » ('J')
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 "apps/ui/views/app_window_frame_view.h" 5 #include "apps/ui/views/app_window_frame_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "extensions/browser/app_window/native_app_window.h" 8 #include "extensions/browser/app_window/native_app_window.h"
9 #include "extensions/common/draggable_region.h" 9 #include "extensions/common/draggable_region.h"
10 #include "grit/theme_resources.h" 10 #include "grit/theme_resources.h"
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 367
368 SkColor AppWindowFrameView::CurrentFrameColor() { 368 SkColor AppWindowFrameView::CurrentFrameColor() {
369 return widget_->IsActive() ? active_frame_color_ : inactive_frame_color_; 369 return widget_->IsActive() ? active_frame_color_ : inactive_frame_color_;
370 } 370 }
371 371
372 void AppWindowFrameView::SetButtonImagesForFrame() { 372 void AppWindowFrameView::SetButtonImagesForFrame() {
373 DCHECK(draw_frame_); 373 DCHECK(draw_frame_);
374 374
375 // If the frame is dark, we should use the light images so they have 375 // If the frame is dark, we should use the light images so they have
376 // some contrast. 376 // some contrast.
377 unsigned char frame_luma = 377 const uint8_t kLumaThreshold = 100;
378 color_utils::GetLuminanceForColor(CurrentFrameColor()); 378 bool use_light = color_utils::Luma(CurrentFrameColor()) < kLumaThreshold;
379 const unsigned char kLuminanceThreshold = 100;
380 bool use_light = frame_luma < kLuminanceThreshold;
381 379
382 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 380 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
383 if (use_light) { 381 if (use_light) {
384 maximize_button_->SetImage( 382 maximize_button_->SetImage(
385 views::CustomButton::STATE_NORMAL, 383 views::CustomButton::STATE_NORMAL,
386 rb.GetNativeImageNamed(IDR_APP_WINDOW_MAXIMIZE_L).ToImageSkia()); 384 rb.GetNativeImageNamed(IDR_APP_WINDOW_MAXIMIZE_L).ToImageSkia());
387 restore_button_->SetImage( 385 restore_button_->SetImage(
388 views::CustomButton::STATE_NORMAL, 386 views::CustomButton::STATE_NORMAL,
389 rb.GetNativeImageNamed(IDR_APP_WINDOW_RESTORE_L).ToImageSkia()); 387 rb.GetNativeImageNamed(IDR_APP_WINDOW_RESTORE_L).ToImageSkia());
390 minimize_button_->SetImage( 388 minimize_button_->SetImage(
391 views::CustomButton::STATE_NORMAL, 389 views::CustomButton::STATE_NORMAL,
392 rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_L).ToImageSkia()); 390 rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_L).ToImageSkia());
393 } else { 391 } else {
394 maximize_button_->SetImage( 392 maximize_button_->SetImage(
395 views::CustomButton::STATE_NORMAL, 393 views::CustomButton::STATE_NORMAL,
396 rb.GetNativeImageNamed(IDR_APP_WINDOW_MAXIMIZE).ToImageSkia()); 394 rb.GetNativeImageNamed(IDR_APP_WINDOW_MAXIMIZE).ToImageSkia());
397 restore_button_->SetImage( 395 restore_button_->SetImage(
398 views::CustomButton::STATE_NORMAL, 396 views::CustomButton::STATE_NORMAL,
399 rb.GetNativeImageNamed(IDR_APP_WINDOW_RESTORE).ToImageSkia()); 397 rb.GetNativeImageNamed(IDR_APP_WINDOW_RESTORE).ToImageSkia());
400 minimize_button_->SetImage( 398 minimize_button_->SetImage(
401 views::CustomButton::STATE_NORMAL, 399 views::CustomButton::STATE_NORMAL,
402 rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE).ToImageSkia()); 400 rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE).ToImageSkia());
403 } 401 }
404 } 402 }
405 403
406 } // namespace apps 404 } // namespace apps
OLDNEW
« no previous file with comments | « no previous file | ash/frame/default_header_painter.cc » ('j') | ash/frame/default_header_painter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698