Commit 3866a3c8 authored by skuhne@chromium.org's avatar skuhne@chromium.org

Repositioning of the dimmer overlay when the shelf gets only moved and not resized.

The "dimmer" cannot be parented by the shelf, but it needs to overlay it. The existing OnBoundsChanged call will only detect size changes since the position relatively to its parent never changes. Therefore the shelf's window needs to be observed as well to get absolute location changes.

BUG=285415
TEST=visual

Review URL: https://chromiumcodereview.appspot.com/24011002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221804 0039d316-1c4b-4281-b951-d872f2087c98
parent 84ca4240
...@@ -238,7 +238,8 @@ namespace ash { ...@@ -238,7 +238,8 @@ namespace ash {
// sizes it to the width of the shelf minus the size of the status area. // sizes it to the width of the shelf minus the size of the status area.
class ShelfWidget::DelegateView : public views::WidgetDelegate, class ShelfWidget::DelegateView : public views::WidgetDelegate,
public views::AccessiblePaneView, public views::AccessiblePaneView,
public internal::BackgroundAnimatorDelegate { public internal::BackgroundAnimatorDelegate,
public aura::WindowObserver {
public: public:
explicit DelegateView(ShelfWidget* shelf); explicit DelegateView(ShelfWidget* shelf);
virtual ~DelegateView(); virtual ~DelegateView();
...@@ -272,8 +273,18 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate, ...@@ -272,8 +273,18 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate,
virtual bool CanActivate() const OVERRIDE; virtual bool CanActivate() const OVERRIDE;
virtual void Layout() OVERRIDE; virtual void Layout() OVERRIDE;
virtual void ReorderChildLayers(ui::Layer* parent_layer) OVERRIDE; virtual void ReorderChildLayers(ui::Layer* parent_layer) OVERRIDE;
// This will be called when the parent local bounds change.
virtual void OnBoundsChanged(const gfx::Rect& old_bounds) OVERRIDE; virtual void OnBoundsChanged(const gfx::Rect& old_bounds) OVERRIDE;
// aura::WindowObserver overrides:
// This will be called when the shelf itself changes its absolute position.
// Since the |dimmer_| panel needs to be placed in screen coordinates it needs
// to be repositioned. The difference to the OnBoundsChanged call above is
// that this gets also triggered when the shelf only moves.
virtual void OnWindowBoundsChanged(aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) OVERRIDE;
// BackgroundAnimatorDelegate overrides: // BackgroundAnimatorDelegate overrides:
virtual void UpdateBackground(int alpha) OVERRIDE; virtual void UpdateBackground(int alpha) OVERRIDE;
...@@ -324,6 +335,8 @@ ShelfWidget::DelegateView::DelegateView(ShelfWidget* shelf) ...@@ -324,6 +335,8 @@ ShelfWidget::DelegateView::DelegateView(ShelfWidget* shelf)
} }
ShelfWidget::DelegateView::~DelegateView() { ShelfWidget::DelegateView::~DelegateView() {
// Make sure that the dimmer goes away since it might have set an observer.
SetDimmed(false);
} }
void ShelfWidget::DelegateView::SetDimmed(bool value) { void ShelfWidget::DelegateView::SetDimmed(bool value) {
...@@ -348,7 +361,11 @@ void ShelfWidget::DelegateView::SetDimmed(bool value) { ...@@ -348,7 +361,11 @@ void ShelfWidget::DelegateView::SetDimmed(bool value) {
dimmer_->SetContentsView(dimmer_view_); dimmer_->SetContentsView(dimmer_view_);
dimmer_->GetNativeView()->SetName("ShelfDimmerView"); dimmer_->GetNativeView()->SetName("ShelfDimmerView");
dimmer_->Show(); dimmer_->Show();
shelf_->GetNativeView()->AddObserver(this);
} else { } else {
// Some unit tests will come here with a destroyed window.
if (shelf_->GetNativeView())
shelf_->GetNativeView()->RemoveObserver(this);
dimmer_view_ = NULL; dimmer_view_ = NULL;
dimmer_.reset(NULL); dimmer_.reset(NULL);
} }
...@@ -428,6 +445,16 @@ void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { ...@@ -428,6 +445,16 @@ void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) {
dimmer_->SetBounds(GetBoundsInScreen()); dimmer_->SetBounds(GetBoundsInScreen());
} }
void ShelfWidget::DelegateView::OnWindowBoundsChanged(
aura::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) {
// Coming here the shelf got repositioned and since the |dimmer_| is placed
// in screen coordinates and not relative to the parent it needs to be
// repositioned accordingly.
dimmer_->SetBounds(GetBoundsInScreen());
}
void ShelfWidget::DelegateView::ForceUndimming(bool force) { void ShelfWidget::DelegateView::ForceUndimming(bool force) {
if (GetDimmed()) if (GetDimmed())
dimmer_view_->ForceUndimming(force); dimmer_view_->ForceUndimming(force);
......
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