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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_COMMON_WINDOW_DIMMER_H_
6 #define ASH_COMMON_WINDOW_DIMMER_H_
7
5 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "ash/common/wm_window_observer.h"
6 #include "base/macros.h" 10 #include "base/macros.h"
7 #include "ui/aura/window.h"
8 #include "ui/aura/window_observer.h"
9 11
10 namespace ash { 12 namespace ash {
11 13
12 // A window used to dim the child windows of the given container. 14 // WindowDimmer creates a window whose opacity is animated by way of
13 class ASH_EXPORT DimWindow : public aura::Window, public aura::WindowObserver { 15 // SetDimOpacity() and whose size matches that of its parent. WindowDimmer is
16 // intended to be used in cases where a certain set of windows need to appear
17 // partially obscured. This is achieved by creating WindowDimmer, setting the
18 // opacity, and then stacking window() above the windows that are to appear
19 // obscured.
James Cook 2016/09/09 21:33:36 Maybe comment on the usual lifetime, specifically
sky 2016/09/09 21:50:45 Done.
20 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.
14 public: 21 public:
15 // Return a dim window for the container if any, or nullptr. 22 // Creates a new WindowDimmer. The window() created by WindowDimmer is added
16 static DimWindow* Get(aura::Window* container); 23 // to |parent| and stacked above all other child windows.
17 24 explicit WindowDimmer(WmWindow* parent);
18 explicit DimWindow(aura::Window* parent); 25 ~WindowDimmer() override;
19 ~DimWindow() override;
20 26
21 void SetDimOpacity(float target_opacity); 27 void SetDimOpacity(float target_opacity);
22 28
23 // aura::WindowObserver: 29 WmWindow* parent() { return parent_; }
24 void OnWindowBoundsChanged(aura::Window* window, 30 WmWindow* window() { return window_; }
31
32 // NOTE: WindowDimmer is an observer for both |parent_| and |window_|.
James Cook 2016/09/09 21:33:36 Thanks for documenting this.
33 // WmWindowObserver:
34 void OnWindowBoundsChanged(WmWindow* window,
25 const gfx::Rect& old_bounds, 35 const gfx::Rect& old_bounds,
26 const gfx::Rect& new_bounds) override; 36 const gfx::Rect& new_bounds) override;
27 void OnWindowDestroying(aura::Window* window) override; 37 void OnWindowDestroying(WmWindow* window) override;
38 void OnWindowTreeChanging(WmWindow* window,
39 const TreeChangeParams& params) override;
28 40
29 private: 41 private:
30 aura::Window* parent_; 42 WmWindow* parent_;
43 WmWindow* window_;
31 44
32 DISALLOW_COPY_AND_ASSIGN(DimWindow); 45 DISALLOW_COPY_AND_ASSIGN(WindowDimmer);
33 }; 46 };
34 47
35 } // namespace ash 48 } // namespace ash
49
50 #endif // ASH_COMMON_WINDOW_DIMMER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698