| OLD | NEW |
| 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. The window created by WindowDimmer is owned by the parent, but also |
| 20 // deleted if WindowDimmer is deleted. It is expected that WindowDimmer is |
| 21 // deleted when the parent window is deleted (such as happens with |
| 22 // WmWindowUserData). |
| 23 class ASH_EXPORT WindowDimmer : public WmWindowObserver { |
| 14 public: | 24 public: |
| 15 // Return a dim window for the container if any, or nullptr. | 25 // Creates a new WindowDimmer. The window() created by WindowDimmer is added |
| 16 static DimWindow* Get(aura::Window* container); | 26 // to |parent| and stacked above all other child windows. |
| 17 | 27 explicit WindowDimmer(WmWindow* parent); |
| 18 explicit DimWindow(aura::Window* parent); | 28 ~WindowDimmer() override; |
| 19 ~DimWindow() override; | |
| 20 | 29 |
| 21 void SetDimOpacity(float target_opacity); | 30 void SetDimOpacity(float target_opacity); |
| 22 | 31 |
| 23 // aura::WindowObserver: | 32 WmWindow* parent() { return parent_; } |
| 24 void OnWindowBoundsChanged(aura::Window* window, | 33 WmWindow* window() { return window_; } |
| 34 |
| 35 // NOTE: WindowDimmer is an observer for both |parent_| and |window_|. |
| 36 // WmWindowObserver: |
| 37 void OnWindowBoundsChanged(WmWindow* window, |
| 25 const gfx::Rect& old_bounds, | 38 const gfx::Rect& old_bounds, |
| 26 const gfx::Rect& new_bounds) override; | 39 const gfx::Rect& new_bounds) override; |
| 27 void OnWindowDestroying(aura::Window* window) override; | 40 void OnWindowDestroying(WmWindow* window) override; |
| 41 void OnWindowTreeChanging(WmWindow* window, |
| 42 const TreeChangeParams& params) override; |
| 28 | 43 |
| 29 private: | 44 private: |
| 30 aura::Window* parent_; | 45 WmWindow* parent_; |
| 46 WmWindow* window_; |
| 31 | 47 |
| 32 DISALLOW_COPY_AND_ASSIGN(DimWindow); | 48 DISALLOW_COPY_AND_ASSIGN(WindowDimmer); |
| 33 }; | 49 }; |
| 34 | 50 |
| 35 } // namespace ash | 51 } // namespace ash |
| 52 |
| 53 #endif // ASH_COMMON_WINDOW_DIMMER_H_ |
| OLD | NEW |