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

Unified Diff: ui/wm/core/shadow.cc

Issue 2596743002: Replace WM shadow types (on/off) and styles (small/inactive/active) (Closed)
Patch Set: . Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: ui/wm/core/shadow.cc
diff --git a/ui/wm/core/shadow.cc b/ui/wm/core/shadow.cc
index 22e12576f7234ec7f65f32219c5ad0a6835d2719..93683575501532bab41357651608cca417d6998b 100644
--- a/ui/wm/core/shadow.cc
+++ b/ui/wm/core/shadow.cc
@@ -67,8 +67,8 @@ Shadow::Shadow() {}
Shadow::~Shadow() {}
-void Shadow::Init(Style style) {
- style_ = style;
+void Shadow::Init(ShadowElevation elevation) {
+ desired_elevation_ = static_cast<int>(elevation);
layer_.reset(new ui::Layer(ui::LAYER_NOT_DRAWN));
RecreateShadowLayer();
}
@@ -83,11 +83,12 @@ void Shadow::SetContentBounds(const gfx::Rect& content_bounds) {
UpdateLayerBounds();
}
-void Shadow::SetStyle(Style style) {
- if (style_ == style)
+void Shadow::SetElevation(ShadowElevation elevation) {
+ const int elevation_value = static_cast<int>(elevation);
+ if (desired_elevation_ == elevation_value)
return;
- style_ = style;
+ desired_elevation_ = elevation_value;
// Stop waiting for any as yet unfinished implicit animations.
StopObservingImplicitAnimations();
@@ -137,14 +138,13 @@ void Shadow::UpdateLayerBounds() {
if (content_bounds_.IsEmpty())
return;
- // The elevation depends on the style, but the ninebox assumption breaks down
- // when the window is too small. The height/width of |blur_region| will be
- // 4 * elevation (see GetDetailsForElevation), so cap elevation at the most we
- // can handle.
+ // The ninebox assumption breaks down when the window is too small for the
+ // desired elevation. The height/width of |blur_region| will be 4 * elevation
+ // (see GetDetailsForElevation), so cap elevation at the most we can handle.
const int smaller_dimension =
std::min(content_bounds_.width(), content_bounds_.height());
const int size_adjusted_elevation = std::min(
- (smaller_dimension - 2 * kRoundedCornerRadius) / 4, ElevationForStyle());
+ (smaller_dimension - 2 * kRoundedCornerRadius) / 4, desired_elevation_);
const ShadowDetails& details =
GetDetailsForElevation(size_adjusted_elevation);
gfx::Insets blur_region = gfx::ShadowValue::GetBlurRegion(details.values) +
@@ -204,17 +204,4 @@ void Shadow::UpdateLayerBounds() {
blur_region.height()));
}
-int Shadow::ElevationForStyle() {
- switch (style_) {
- case STYLE_ACTIVE:
- return 24;
- case STYLE_INACTIVE:
- return 8;
- case STYLE_SMALL:
- return 6;
- }
- NOTREACHED();
- return 0;
-}
-
} // namespace wm

Powered by Google App Engine
This is Rietveld 408576698