| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/shelf/shelf_background_animator.h" | 5 #include "ash/shelf/shelf_background_animator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/animation/animation_change_type.h" | 9 #include "ash/animation/animation_change_type.h" |
| 10 #include "ash/ash_switches.h" |
| 10 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
| 11 #include "ash/shelf/shelf_background_animator_observer.h" | 12 #include "ash/shelf/shelf_background_animator_observer.h" |
| 12 #include "ash/shelf/shelf_constants.h" | 13 #include "ash/shelf/shelf_constants.h" |
| 13 #include "ash/wallpaper/wallpaper_controller.h" | 14 #include "ash/wallpaper/wallpaper_controller.h" |
| 15 #include "base/command_line.h" |
| 14 #include "ui/gfx/animation/slide_animation.h" | 16 #include "ui/gfx/animation/slide_animation.h" |
| 15 #include "ui/gfx/color_utils.h" | 17 #include "ui/gfx/color_utils.h" |
| 16 | 18 |
| 19 using ColorProfile = color_utils::ColorProfile; |
| 20 using LumaRange = color_utils::LumaRange; |
| 21 using SaturationRange = color_utils::SaturationRange; |
| 22 |
| 17 namespace ash { | 23 namespace ash { |
| 18 | 24 |
| 25 namespace { |
| 26 |
| 27 // Returns color profile used for shelf based on the kAshShelfColorScheme |
| 28 // command line arg. |
| 29 ColorProfile GetShelfColorProfile() { |
| 30 const std::string switch_value = |
| 31 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 32 switches::kAshShelfColorScheme); |
| 33 |
| 34 ColorProfile color_profile(LumaRange::DARK, SaturationRange::MUTED); |
| 35 |
| 36 if (switch_value.find("light") != std::string::npos) |
| 37 color_profile.luma = LumaRange::LIGHT; |
| 38 else if (switch_value.find("normal") != std::string::npos) |
| 39 color_profile.luma = LumaRange::NORMAL; |
| 40 else if (switch_value.find("dark") != std::string::npos) |
| 41 color_profile.luma = LumaRange::DARK; |
| 42 |
| 43 if (switch_value.find("vibrant") != std::string::npos) |
| 44 color_profile.saturation = SaturationRange::VIBRANT; |
| 45 else if (switch_value.find("muted") != std::string::npos) |
| 46 color_profile.saturation = SaturationRange::MUTED; |
| 47 |
| 48 return color_profile; |
| 49 } |
| 50 |
| 51 } // namespace |
| 52 |
| 19 ShelfBackgroundAnimator::AnimationValues::AnimationValues() {} | 53 ShelfBackgroundAnimator::AnimationValues::AnimationValues() {} |
| 20 | 54 |
| 21 ShelfBackgroundAnimator::AnimationValues::~AnimationValues() {} | 55 ShelfBackgroundAnimator::AnimationValues::~AnimationValues() {} |
| 22 | 56 |
| 23 void ShelfBackgroundAnimator::AnimationValues::UpdateCurrentValues(double t) { | 57 void ShelfBackgroundAnimator::AnimationValues::UpdateCurrentValues(double t) { |
| 24 current_color_ = | 58 current_color_ = |
| 25 gfx::Tween::ColorValueBetween(t, initial_color_, target_color_); | 59 gfx::Tween::ColorValueBetween(t, initial_color_, target_color_); |
| 26 } | 60 } |
| 27 | 61 |
| 28 void ShelfBackgroundAnimator::AnimationValues::SetTargetValues( | 62 void ShelfBackgroundAnimator::AnimationValues::SetTargetValues( |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 case SHELF_BACKGROUND_OVERLAP: | 240 case SHELF_BACKGROUND_OVERLAP: |
| 207 target_shelf_color_alpha = kShelfTranslucentAlpha; | 241 target_shelf_color_alpha = kShelfTranslucentAlpha; |
| 208 target_item_color_alpha = 0; | 242 target_item_color_alpha = 0; |
| 209 break; | 243 break; |
| 210 case SHELF_BACKGROUND_MAXIMIZED: | 244 case SHELF_BACKGROUND_MAXIMIZED: |
| 211 target_shelf_color_alpha = kMaxAlpha; | 245 target_shelf_color_alpha = kMaxAlpha; |
| 212 target_item_color_alpha = 0; | 246 target_item_color_alpha = 0; |
| 213 break; | 247 break; |
| 214 } | 248 } |
| 215 | 249 |
| 250 WallpaperController::ColorProfileIndex index = |
| 251 wallpaper_controller_->GetColorProfileIndex(GetShelfColorProfile()); |
| 216 SkColor target_color = wallpaper_controller_ | 252 SkColor target_color = wallpaper_controller_ |
| 217 ? wallpaper_controller_->prominent_color() | 253 ? wallpaper_controller_->prominent_colors()[index] |
| 218 : kShelfDefaultBaseColor; | 254 : kShelfDefaultBaseColor; |
| 219 if (target_color == WallpaperController::kInvalidColor) { | 255 if (target_color == WallpaperController::kInvalidColor) { |
| 220 target_color = kShelfDefaultBaseColor; | 256 target_color = kShelfDefaultBaseColor; |
| 221 } else { | 257 } else { |
| 222 int darkening_alpha = 0; | 258 int darkening_alpha = 0; |
| 223 | 259 |
| 224 switch (background_type) { | 260 switch (background_type) { |
| 225 case SHELF_BACKGROUND_DEFAULT: | 261 case SHELF_BACKGROUND_DEFAULT: |
| 226 case SHELF_BACKGROUND_OVERLAP: | 262 case SHELF_BACKGROUND_OVERLAP: |
| 227 darkening_alpha = kShelfTranslucentColorDarkenAlpha; | 263 darkening_alpha = kShelfTranslucentColorDarkenAlpha; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 242 | 278 |
| 243 void ShelfBackgroundAnimator::SetAnimationValues(double t) { | 279 void ShelfBackgroundAnimator::SetAnimationValues(double t) { |
| 244 DCHECK_GE(t, 0.0); | 280 DCHECK_GE(t, 0.0); |
| 245 DCHECK_LE(t, 1.0); | 281 DCHECK_LE(t, 1.0); |
| 246 shelf_background_values_.UpdateCurrentValues(t); | 282 shelf_background_values_.UpdateCurrentValues(t); |
| 247 item_background_values_.UpdateCurrentValues(t); | 283 item_background_values_.UpdateCurrentValues(t); |
| 248 NotifyObservers(); | 284 NotifyObservers(); |
| 249 } | 285 } |
| 250 | 286 |
| 251 } // namespace ash | 287 } // namespace ash |
| OLD | NEW |