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

Unified Diff: ash/common/wm/dock/docked_window_layout_manager.cc

Issue 2191153002: Revert of Replaced BackgroundAnimator with ShelfBackgroundAnimator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/wm/background_animator.cc ('k') | ash/root_window_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/wm/dock/docked_window_layout_manager.cc
diff --git a/ash/common/wm/dock/docked_window_layout_manager.cc b/ash/common/wm/dock/docked_window_layout_manager.cc
index 19b8b67e2b6987bfe03cdf001c3e6b273c3fa927..b4492e6c255a2876e9fc64ff770c687b4041a174 100644
--- a/ash/common/wm/dock/docked_window_layout_manager.cc
+++ b/ash/common/wm/dock/docked_window_layout_manager.cc
@@ -5,8 +5,6 @@
#include "ash/common/wm/dock/docked_window_layout_manager.h"
#include "ash/common/material_design/material_design_controller.h"
-#include "ash/common/shelf/shelf_background_animator.h"
-#include "ash/common/shelf/shelf_background_animator_observer.h"
#include "ash/common/shelf/shelf_constants.h"
#include "ash/common/shelf/wm_shelf.h"
#include "ash/common/shelf/wm_shelf_observer.h"
@@ -50,25 +48,22 @@
const int kMinimizeDurationMs = 720;
class DockedBackgroundWidget : public views::Widget,
- public WmShelfObserver,
- public ShelfBackgroundAnimatorObserver {
+ public BackgroundAnimatorDelegate,
+ public WmShelfObserver {
public:
explicit DockedBackgroundWidget(DockedWindowLayoutManager* manager)
: manager_(manager),
alignment_(DOCKED_ALIGNMENT_NONE),
- background_animator_(SHELF_BACKGROUND_DEFAULT, nullptr),
- asset_background_alpha_(0),
+ background_animator_(this, 0, GetShelfConstant(SHELF_BACKGROUND_ALPHA)),
+ alpha_(0),
opaque_background_(ui::LAYER_SOLID_COLOR),
visible_background_type_(manager_->shelf()->GetBackgroundType()),
visible_background_change_type_(BACKGROUND_CHANGE_IMMEDIATE) {
manager_->shelf()->AddObserver(this);
InitWidget(manager_->dock_container());
-
- background_animator_.AddObserver(this);
}
~DockedBackgroundWidget() override {
- background_animator_.RemoveObserver(this);
manager_->shelf()->RemoveObserver(this);
}
@@ -90,12 +85,15 @@
gfx::Rect local_window_bounds(GetWindowBoundsInScreen().size());
ui::PaintRecorder recorder(context, local_window_bounds.size());
- if (!MaterialDesignController::IsShelfMaterial()) {
+ if (MaterialDesignController::IsShelfMaterial()) {
+ recorder.canvas()->FillRect(local_window_bounds,
+ SkColorSetA(kShelfBaseColor, alpha_));
+ } else {
const gfx::ImageSkia& shelf_background(alignment_ == DOCKED_ALIGNMENT_LEFT
? shelf_background_left_
: shelf_background_right_);
SkPaint paint;
- paint.setAlpha(asset_background_alpha_);
+ paint.setAlpha(alpha_);
recorder.canvas()->DrawImageInt(
shelf_background, 0, 0, shelf_background.width(),
shelf_background.height(),
@@ -115,21 +113,15 @@
}
}
- // ShelfBackgroundAnimatorObserver:
- void UpdateShelfOpaqueBackground(int alpha) override {
- const float kMaxAlpha = 255.0f;
- opaque_background_.SetOpacity(alpha / kMaxAlpha);
- }
-
- void UpdateShelfAssetBackground(int alpha) override {
- asset_background_alpha_ = alpha;
+ // BackgroundAnimatorDelegate:
+ void UpdateBackground(int alpha) override {
+ alpha_ = alpha;
SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size()));
}
- // WmShelfObserver:
- void OnBackgroundTypeChanged(
- ShelfBackgroundType background_type,
- BackgroundAnimatorChangeType change_type) override {
+ // ShelfLayoutManagerObserver:
+ void OnBackgroundUpdated(ShelfBackgroundType background_type,
+ BackgroundAnimatorChangeType change_type) override {
// Sets the background type. Starts an animation to transition to
// |background_type| if the widget is visible. If the widget is not visible,
// the animation is postponed till the widget becomes visible.
@@ -183,7 +175,24 @@
BackgroundAnimatorChangeType change_type =
IsVisible() ? visible_background_change_type_
: BACKGROUND_CHANGE_IMMEDIATE;
- background_animator_.PaintBackground(background_type, change_type);
+
+ float target_opacity =
+ (background_type == SHELF_BACKGROUND_MAXIMIZED) ? 1.0f : 0.0f;
+ std::unique_ptr<ui::ScopedLayerAnimationSettings>
+ opaque_background_animation;
+ if (change_type != BACKGROUND_CHANGE_IMMEDIATE) {
+ opaque_background_animation.reset(new ui::ScopedLayerAnimationSettings(
+ opaque_background_.GetAnimator()));
+ opaque_background_animation->SetTransitionDuration(
+ base::TimeDelta::FromMilliseconds(kTimeToSwitchBackgroundMs));
+ }
+ opaque_background_.SetOpacity(target_opacity);
+
+ // TODO(varkha): use ui::Layer on both opaque_background and normal
+ // background retire background_animator_ at all. It would be simpler.
+ // See also ShelfWidget::SetPaintsBackground.
+ background_animator_.SetPaintsBackground(
+ background_type != SHELF_BACKGROUND_DEFAULT, change_type);
SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size()));
}
@@ -192,12 +201,11 @@
DockedAlignment alignment_;
// The animator for the background transitions.
- ShelfBackgroundAnimator background_animator_;
+ BackgroundAnimator background_animator_;
// The alpha to use for drawing image assets covering the docked background.
- int asset_background_alpha_;
-
- // TODO(bruthig): Remove opaque_background_ (see https://crbug.com/621551).
+ int alpha_;
+
// Solid black background that can be made fully opaque.
ui::Layer opaque_background_;
« no previous file with comments | « ash/common/wm/background_animator.cc ('k') | ash/root_window_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698