Commit 2f994844 authored by oshima's avatar oshima Committed by Commit bot

Use 0.2f opacity only when the shadow animation is applied.

The opacity stays 0.2f if the window is created and shown in inactive state because the opacity is set back to 1.0f only when the animation is applied. This CL uses 1.0f opacity as initial opacity and when transitioning from/to small shadow.

BUG=433574
TEST=manual test. See the bug for repro step.

Review URL: https://codereview.chromium.org/798673002

Cr-Commit-Position: refs/heads/master@{#308187}
parent 6d72f40b
...@@ -12,10 +12,9 @@ ...@@ -12,10 +12,9 @@
namespace { namespace {
// Shadow opacity for different styles. // The opacity used for active shadow when animating between
const float kActiveShadowOpacity = 1.0f; // inactive/active shadow.
const float kInactiveShadowOpacity = 0.2f; const float kInactiveShadowAnimationOpacity = 0.2f;
const float kSmallShadowOpacity = 1.0f;
// Shadow aperture for different styles. // Shadow aperture for different styles.
// Note that this may be greater than interior inset to allow shadows with // Note that this may be greater than interior inset to allow shadows with
...@@ -32,18 +31,6 @@ const int kSmallInteriorInset = 4; ...@@ -32,18 +31,6 @@ const int kSmallInteriorInset = 4;
// Duration for opacity animation in milliseconds. // Duration for opacity animation in milliseconds.
const int kShadowAnimationDurationMs = 100; const int kShadowAnimationDurationMs = 100;
float GetOpacityForStyle(wm::Shadow::Style style) {
switch (style) {
case wm::Shadow::STYLE_ACTIVE:
return kActiveShadowOpacity;
case wm::Shadow::STYLE_INACTIVE:
return kInactiveShadowOpacity;
case wm::Shadow::STYLE_SMALL:
return kSmallShadowOpacity;
}
return 1.0f;
}
int GetShadowApertureForStyle(wm::Shadow::Style style) { int GetShadowApertureForStyle(wm::Shadow::Style style) {
switch (style) { switch (style) {
case wm::Shadow::STYLE_ACTIVE: case wm::Shadow::STYLE_ACTIVE:
...@@ -89,7 +76,6 @@ void Shadow::Init(Style style) { ...@@ -89,7 +76,6 @@ void Shadow::Init(Style style) {
shadow_layer_->set_name("Shadow"); shadow_layer_->set_name("Shadow");
shadow_layer_->SetVisible(true); shadow_layer_->SetVisible(true);
shadow_layer_->SetFillsBoundsOpaquely(false); shadow_layer_->SetFillsBoundsOpaquely(false);
shadow_layer_->SetOpacity(GetOpacityForStyle(style_));
} }
void Shadow::SetContentBounds(const gfx::Rect& content_bounds) { void Shadow::SetContentBounds(const gfx::Rect& content_bounds) {
...@@ -111,7 +97,8 @@ void Shadow::SetStyle(Style style) { ...@@ -111,7 +97,8 @@ void Shadow::SetStyle(Style style) {
// animations. // animations.
if (style == STYLE_SMALL || old_style == STYLE_SMALL) { if (style == STYLE_SMALL || old_style == STYLE_SMALL) {
UpdateImagesForStyle(); UpdateImagesForStyle();
shadow_layer_->SetOpacity(GetOpacityForStyle(style)); // Make sure the shadow is fully opaque.
shadow_layer_->SetOpacity(1.0f);
return; return;
} }
...@@ -121,7 +108,7 @@ void Shadow::SetStyle(Style style) { ...@@ -121,7 +108,7 @@ void Shadow::SetStyle(Style style) {
if (style == STYLE_ACTIVE) { if (style == STYLE_ACTIVE) {
UpdateImagesForStyle(); UpdateImagesForStyle();
// Opacity was baked into inactive image, start opacity low to match. // Opacity was baked into inactive image, start opacity low to match.
shadow_layer_->SetOpacity(kInactiveShadowOpacity); shadow_layer_->SetOpacity(kInactiveShadowAnimationOpacity);
} }
{ {
...@@ -132,10 +119,13 @@ void Shadow::SetStyle(Style style) { ...@@ -132,10 +119,13 @@ void Shadow::SetStyle(Style style) {
base::TimeDelta::FromMilliseconds(kShadowAnimationDurationMs)); base::TimeDelta::FromMilliseconds(kShadowAnimationDurationMs));
switch (style_) { switch (style_) {
case STYLE_ACTIVE: case STYLE_ACTIVE:
shadow_layer_->SetOpacity(kActiveShadowOpacity); // Animate the active shadow from kInactiveShadowAnimationOpacity to
// 1.0f.
shadow_layer_->SetOpacity(1.0f);
break; break;
case STYLE_INACTIVE: case STYLE_INACTIVE:
shadow_layer_->SetOpacity(kInactiveShadowOpacity); // The opacity will be reset to 1.0f when animation is completed.
shadow_layer_->SetOpacity(kInactiveShadowAnimationOpacity);
break; break;
default: default:
NOTREACHED() << "Unhandled style " << style_; NOTREACHED() << "Unhandled style " << style_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment