summaryrefslogtreecommitdiffstats
path: root/ash/shelf
diff options
context:
space:
mode:
authorskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 22:48:45 +0000
committerskuhne@chromium.org <skuhne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-06 22:48:45 +0000
commit3866a3c81d30bb1999126ab12037afc5ffba0cb6 (patch)
tree78403d5b8005a1e0df915432110fd5f426d2f689 /ash/shelf
parent84ca424013854ff26f0a1c8212bcb87561e7bb8a (diff)
downloadchromium_src-3866a3c81d30bb1999126ab12037afc5ffba0cb6.zip
chromium_src-3866a3c81d30bb1999126ab12037afc5ffba0cb6.tar.gz
chromium_src-3866a3c81d30bb1999126ab12037afc5ffba0cb6.tar.bz2
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
Diffstat (limited to 'ash/shelf')
-rw-r--r--ash/shelf/shelf_widget.cc29
1 files changed, 28 insertions, 1 deletions
diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc
index 8c7733f..4c187b8 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:
+ // 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,11 @@ void ShelfWidget::DelegateView::SetDimmed(bool value) {
dimmer_->SetContentsView(dimmer_view_);
dimmer_->GetNativeView()->SetName("ShelfDimmerView");
dimmer_->Show();
+ shelf_->GetNativeView()->AddObserver(this);
} else {
+ // Some unit tests will come here with a destroyed window.
+ if (shelf_->GetNativeView())
+ shelf_->GetNativeView()->RemoveObserver(this);
dimmer_view_ = NULL;
dimmer_.reset(NULL);
}
@@ -428,6 +445,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
+ // 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);