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

Unified Diff: ash/common/wm/window_dimmer.h

Issue 2320273002: Refactors DimWindow and moves to ash/common (Closed)
Patch Set: WmWindowUserData test Created 4 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
Index: ash/common/wm/window_dimmer.h
diff --git a/ash/wm/dim_window.h b/ash/common/wm/window_dimmer.h
similarity index 26%
rename from ash/wm/dim_window.h
rename to ash/common/wm/window_dimmer.h
index 8d86c63d02dbeba44449d2a25a40698ce950a786..916b201329f8eb53c66d99a67dad6949517b2983 100644
--- a/ash/wm/dim_window.h
+++ b/ash/common/wm/window_dimmer.h
@@ -2,34 +2,49 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef ASH_COMMON_WINDOW_DIMMER_H_
+#define ASH_COMMON_WINDOW_DIMMER_H_
+
#include "ash/ash_export.h"
+#include "ash/common/wm_window_observer.h"
#include "base/macros.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_observer.h"
namespace ash {
-// A window used to dim the child windows of the given container.
-class ASH_EXPORT DimWindow : public aura::Window, public aura::WindowObserver {
+// WindowDimmer creates a window whose opacity is animated by way of
+// SetDimOpacity() and whose size matches that of its parent. WindowDimmer is
+// intended to be used in cases where a certain set of windows need to appear
+// partially obscured. This is achieved by creating WindowDimmer, setting the
+// opacity, and then stacking window() above the windows that are to appear
+// obscured.
James Cook 2016/09/09 21:33:36 Maybe comment on the usual lifetime, specifically
sky 2016/09/09 21:50:45 Done.
+class ASH_EXPORT WindowDimmer : public WmWindowObserver {
sky 2016/09/09 20:28:32 I changed this code around so that it owns window_
James Cook 2016/09/09 21:33:36 Acknowledged.
public:
- // Return a dim window for the container if any, or nullptr.
- static DimWindow* Get(aura::Window* container);
-
- explicit DimWindow(aura::Window* parent);
- ~DimWindow() override;
+ // Creates a new WindowDimmer. The window() created by WindowDimmer is added
+ // to |parent| and stacked above all other child windows.
+ explicit WindowDimmer(WmWindow* parent);
+ ~WindowDimmer() override;
void SetDimOpacity(float target_opacity);
- // aura::WindowObserver:
- void OnWindowBoundsChanged(aura::Window* window,
+ WmWindow* parent() { return parent_; }
+ WmWindow* window() { return window_; }
+
+ // NOTE: WindowDimmer is an observer for both |parent_| and |window_|.
James Cook 2016/09/09 21:33:36 Thanks for documenting this.
+ // WmWindowObserver:
+ void OnWindowBoundsChanged(WmWindow* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override;
- void OnWindowDestroying(aura::Window* window) override;
+ void OnWindowDestroying(WmWindow* window) override;
+ void OnWindowTreeChanging(WmWindow* window,
+ const TreeChangeParams& params) override;
private:
- aura::Window* parent_;
+ WmWindow* parent_;
+ WmWindow* window_;
- DISALLOW_COPY_AND_ASSIGN(DimWindow);
+ DISALLOW_COPY_AND_ASSIGN(WindowDimmer);
};
} // namespace ash
+
+#endif // ASH_COMMON_WINDOW_DIMMER_H_

Powered by Google App Engine
This is Rietveld 408576698