OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_COMMON_WINDOW_DIMMER_H_ | |
6 #define ASH_COMMON_WINDOW_DIMMER_H_ | |
7 | |
8 #include "ash/ash_export.h" | |
9 #include "base/macros.h" | |
10 #include "ui/aura/window_observer.h" | |
11 | |
12 namespace ash { | |
13 | |
14 class WmWindow; | |
15 | |
16 // WindowDimmer creates a window whose opacity is animated by way of | |
17 // SetDimOpacity() and whose size matches that of its parent. WindowDimmer is | |
18 // intended to be used in cases where a certain set of windows need to appear | |
19 // partially obscured. This is achieved by creating WindowDimmer, setting the | |
20 // opacity, and then stacking window() above the windows that are to appear | |
21 // obscured. The window created by WindowDimmer is owned by the parent, but also | |
22 // deleted if WindowDimmer is deleted. It is expected that WindowDimmer is | |
23 // deleted when the parent window is deleted (such as happens with | |
24 // WmWindowUserData). | |
25 class ASH_EXPORT WindowDimmer : public aura::WindowObserver { | |
26 public: | |
27 // Creates a new WindowDimmer. The window() created by WindowDimmer is added | |
28 // to |parent| and stacked above all other child windows. | |
29 explicit WindowDimmer(WmWindow* parent); | |
30 ~WindowDimmer() override; | |
31 | |
32 void SetDimOpacity(float target_opacity); | |
33 | |
34 WmWindow* parent() { return parent_; } | |
35 WmWindow* window() { return window_; } | |
36 | |
37 // NOTE: WindowDimmer is an observer for both |parent_| and |window_|. | |
38 // aura::WindowObserver: | |
39 void OnWindowBoundsChanged(aura::Window* window, | |
40 const gfx::Rect& old_bounds, | |
41 const gfx::Rect& new_bounds) override; | |
42 void OnWindowDestroying(aura::Window* window) override; | |
43 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override; | |
44 | |
45 private: | |
46 WmWindow* parent_; | |
47 WmWindow* window_; | |
48 | |
49 DISALLOW_COPY_AND_ASSIGN(WindowDimmer); | |
50 }; | |
51 | |
52 } // namespace ash | |
53 | |
54 #endif // ASH_COMMON_WINDOW_DIMMER_H_ | |
OLD | NEW |