Index: ash/shelf/shelf_widget.cc |
diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc |
index 8c7733ff2d60dbd6ceb77662bebd992a1245aae5..8c54203492fec9985ad2a1faf1d79df49aed6f63 100644 |
--- a/ash/shelf/shelf_widget.cc |
+++ b/ash/shelf/shelf_widget.cc |
@@ -238,7 +238,8 @@ namespace ash { |
// sizes it to the width of the shelf minus the size of the status area. |
class ShelfWidget::DelegateView : public views::WidgetDelegate, |
public views::AccessiblePaneView, |
- public internal::BackgroundAnimatorDelegate { |
+ public internal::BackgroundAnimatorDelegate, |
+ public aura::WindowObserver { |
public: |
explicit DelegateView(ShelfWidget* shelf); |
virtual ~DelegateView(); |
@@ -272,8 +273,18 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate, |
virtual bool CanActivate() const OVERRIDE; |
virtual void Layout() 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; |
+ // aura::WindowObserver overrides. |
James Cook
2013/09/05 23:41:00
tiny nit: "overrides:" instead of "overrides."
Mr4D (OOO till 08-26)
2013/09/05 23:47:26
Done
|
+ // 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: |
virtual void UpdateBackground(int alpha) OVERRIDE; |
@@ -324,6 +335,8 @@ ShelfWidget::DelegateView::DelegateView(ShelfWidget* shelf) |
} |
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) { |
@@ -348,7 +361,9 @@ void ShelfWidget::DelegateView::SetDimmed(bool value) { |
dimmer_->SetContentsView(dimmer_view_); |
dimmer_->GetNativeView()->SetName("ShelfDimmerView"); |
dimmer_->Show(); |
+ shelf_->GetNativeView()->AddObserver(this); |
} else { |
+ shelf_->GetNativeView()->RemoveObserver(this); |
dimmer_view_ = NULL; |
dimmer_.reset(NULL); |
} |
@@ -428,6 +443,16 @@ void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { |
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 |
James Cook
2013/09/05 23:41:00
nit: coming -> Coming
Mr4D (OOO till 08-26)
2013/09/05 23:47:26
Done.
|
+ // in screen coordinates and not relative to the parent it needs to be |
+ // repositioned accordingly. |
+ dimmer_->SetBounds(GetBoundsInScreen()); |
+} |
+ |
void ShelfWidget::DelegateView::ForceUndimming(bool force) { |
if (GetDimmed()) |
dimmer_view_->ForceUndimming(force); |