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 80a97ede1a476954be72d7ace2d559feda3354a2..b1d3b65018ccdad26757aa193c148545d0258b1d 100644 |
--- a/ash/common/wm/dock/docked_window_layout_manager.cc |
+++ b/ash/common/wm/dock/docked_window_layout_manager.cc |
@@ -5,6 +5,8 @@ |
#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" |
@@ -47,19 +49,22 @@ const int kFadeDurationMs = 60; |
const int kMinimizeDurationMs = 720; |
class DockedBackgroundWidget : public views::Widget, |
- public BackgroundAnimatorDelegate, |
- public WmShelfObserver { |
+ public WmShelfObserver, |
+ public ShelfBackgroundAnimatorObserver { |
public: |
explicit DockedBackgroundWidget(DockedWindowLayoutManager* manager) |
: manager_(manager), |
alignment_(DOCKED_ALIGNMENT_NONE), |
- background_animator_(this, 0, GetShelfConstant(SHELF_BACKGROUND_ALPHA)), |
- alpha_(0), |
+ asset_background_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); |
+ background_animator_.PaintBackground(SHELF_BACKGROUND_DEFAULT, |
+ BACKGROUND_CHANGE_IMMEDIATE); |
} |
~DockedBackgroundWidget() override { |
@@ -84,15 +89,12 @@ class DockedBackgroundWidget : public views::Widget, |
gfx::Rect local_window_bounds(GetWindowBoundsInScreen().size()); |
ui::PaintRecorder recorder(context, local_window_bounds.size()); |
- if (MaterialDesignController::IsShelfMaterial()) { |
- recorder.canvas()->FillRect( |
- local_window_bounds, SkColorSetA(kShelfBaseColor, alpha_)); |
- } else { |
+ if (!MaterialDesignController::IsShelfMaterial()) { |
const gfx::ImageSkia& shelf_background(alignment_ == DOCKED_ALIGNMENT_LEFT |
? shelf_background_left_ |
: shelf_background_right_); |
SkPaint paint; |
- paint.setAlpha(alpha_); |
+ paint.setAlpha(asset_background_alpha_); |
recorder.canvas()->DrawImageInt( |
shelf_background, 0, 0, shelf_background.width(), |
shelf_background.height(), |
@@ -113,9 +115,14 @@ class DockedBackgroundWidget : public views::Widget, |
} |
} |
- // BackgroundAnimatorDelegate: |
- void UpdateBackground(int alpha) override { |
- alpha_ = alpha; |
+ // ShelfBackgroundAnimatorObserver: |
+ void UpdateShelfOpaqueBackground(int alpha) override { |
+ const double kMaxAlpha = 255.0; |
James Cook
2016/06/14 17:50:02
float?
bruthig
2016/07/26 19:50:03
Done.
|
+ opaque_background_.SetOpacity(alpha / kMaxAlpha); |
+ } |
+ |
+ void UpdateShelfAssetBackground(int alpha) override { |
+ asset_background_alpha_ = alpha; |
SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); |
} |
@@ -175,24 +182,7 @@ class DockedBackgroundWidget : public views::Widget, |
BackgroundAnimatorChangeType change_type = |
IsVisible() ? visible_background_change_type_ |
: BACKGROUND_CHANGE_IMMEDIATE; |
- |
- 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); |
+ background_animator_.PaintBackground(background_type, change_type); |
SchedulePaintInRect(gfx::Rect(GetWindowBoundsInScreen().size())); |
} |
@@ -201,11 +191,12 @@ class DockedBackgroundWidget : public views::Widget, |
DockedAlignment alignment_; |
// The animator for the background transitions. |
- BackgroundAnimator background_animator_; |
+ ShelfBackgroundAnimator background_animator_; |
// The alpha to use for drawing image assets covering the docked background. |
- int alpha_; |
+ int asset_background_alpha_; |
+ // TODO(bruthig): Remove opaque_background_. |
// Solid black background that can be made fully opaque. |
ui::Layer opaque_background_; |