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

Unified Diff: ash/shelf/shelf_widget.cc

Issue 24011002: Repositioning of the dimmer overlay when the shelf gets only moved and not resized. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit test Created 7 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_widget.cc
diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc
index 8c7733ff2d60dbd6ceb77662bebd992a1245aae5..4c187b86a90d6f85406bda9d5fa9563a5fdac66f 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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698