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 MASH_WM_SHADOW_H_ | 5 #ifndef ASH_MUS_SHADOW_H_ |
6 #define MASH_WM_SHADOW_H_ | 6 #define ASH_MUS_SHADOW_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/mus/public/cpp/window_observer.h" | 11 #include "components/mus/public/cpp/window_observer.h" |
12 #include "ui/compositor/layer_animation_observer.h" | 12 #include "ui/compositor/layer_animation_observer.h" |
13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 class Layer; | 16 class Layer; |
17 } // namespace ui | 17 } // namespace ui |
18 | 18 |
19 namespace mash { | 19 namespace ash { |
20 namespace wm { | 20 namespace mus { |
21 | 21 |
22 // Simple class that draws a drop shadow around content at given bounds. | 22 // Simple class that draws a drop shadow around content at given bounds. |
23 class Shadow : public ui::ImplicitAnimationObserver, | 23 class Shadow : public ui::ImplicitAnimationObserver, |
24 public mus::WindowObserver { | 24 public ::mus::WindowObserver { |
25 public: | 25 public: |
26 enum Style { | 26 enum Style { |
27 // Active windows have more opaque shadows, shifted down to make the window | 27 // Active windows have more opaque shadows, shifted down to make the window |
28 // appear "higher". | 28 // appear "higher". |
29 STYLE_ACTIVE, | 29 STYLE_ACTIVE, |
30 | 30 |
31 // Inactive windows have less opaque shadows. | 31 // Inactive windows have less opaque shadows. |
32 STYLE_INACTIVE, | 32 STYLE_INACTIVE, |
33 | 33 |
34 // Small windows like tooltips and context menus have lighter, smaller | 34 // Small windows like tooltips and context menus have lighter, smaller |
(...skipping 21 matching lines...) Expand all Loading... |
56 const gfx::Rect& content_bounds() const { return content_bounds_; } | 56 const gfx::Rect& content_bounds() const { return content_bounds_; } |
57 Style style() const { return style_; } | 57 Style style() const { return style_; } |
58 | 58 |
59 // Moves and resizes the shadow layer to frame |content_bounds|. | 59 // Moves and resizes the shadow layer to frame |content_bounds|. |
60 void SetContentBounds(const gfx::Rect& content_bounds); | 60 void SetContentBounds(const gfx::Rect& content_bounds); |
61 | 61 |
62 // Sets the shadow's style, animating opacity as necessary. | 62 // Sets the shadow's style, animating opacity as necessary. |
63 void SetStyle(Style style); | 63 void SetStyle(Style style); |
64 | 64 |
65 // Installs this shadow for |window|. | 65 // Installs this shadow for |window|. |
66 void Install(mus::Window* window); | 66 void Install(::mus::Window* window); |
67 | 67 |
68 // ui::ImplicitAnimationObserver overrides: | 68 // ui::ImplicitAnimationObserver overrides: |
69 void OnImplicitAnimationsCompleted() override; | 69 void OnImplicitAnimationsCompleted() override; |
70 | 70 |
71 private: | 71 private: |
72 // Updates the shadow images to the current |style_|. | 72 // Updates the shadow images to the current |style_|. |
73 void UpdateImagesForStyle(); | 73 void UpdateImagesForStyle(); |
74 | 74 |
75 // Updates the shadow layer bounds based on the inteior inset and the current | 75 // Updates the shadow layer bounds based on the inteior inset and the current |
76 // |content_bounds_|. | 76 // |content_bounds_|. |
77 void UpdateLayerBounds(); | 77 void UpdateLayerBounds(); |
78 | 78 |
79 // WindowObserver: | 79 // WindowObserver: |
80 void OnWindowDestroyed(mus::Window* window) override; | 80 void OnWindowDestroyed(::mus::Window* window) override; |
81 | 81 |
82 // The current style, set when the transition animation starts. | 82 // The current style, set when the transition animation starts. |
83 Style style_; | 83 Style style_; |
84 | 84 |
85 // The parent layer of the shadow layer. It serves as a container accessible | 85 // The parent layer of the shadow layer. It serves as a container accessible |
86 // from the outside to control the visibility of the shadow. | 86 // from the outside to control the visibility of the shadow. |
87 std::unique_ptr<ui::Layer> layer_; | 87 std::unique_ptr<ui::Layer> layer_; |
88 | 88 |
89 // The actual shadow layer corresponding to a cc::NinePatchLayer. | 89 // The actual shadow layer corresponding to a cc::NinePatchLayer. |
90 std::unique_ptr<ui::Layer> shadow_layer_; | 90 std::unique_ptr<ui::Layer> shadow_layer_; |
91 | 91 |
92 // Size of the current shadow image. | 92 // Size of the current shadow image. |
93 gfx::Size image_size_; | 93 gfx::Size image_size_; |
94 | 94 |
95 // Bounds of the content that the shadow encloses. | 95 // Bounds of the content that the shadow encloses. |
96 gfx::Rect content_bounds_; | 96 gfx::Rect content_bounds_; |
97 | 97 |
98 // The interior inset of the shadow images. The content bounds of the image | 98 // The interior inset of the shadow images. The content bounds of the image |
99 // grid should be set to |content_bounds_| inset by this amount. | 99 // grid should be set to |content_bounds_| inset by this amount. |
100 int interior_inset_; | 100 int interior_inset_; |
101 | 101 |
102 mus::Window* window_; | 102 ::mus::Window* window_; |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(Shadow); | 104 DISALLOW_COPY_AND_ASSIGN(Shadow); |
105 }; | 105 }; |
106 | 106 |
107 } // namespace wm | 107 } // namespace mus |
108 } // namespace mash | 108 } // namespace ash |
109 | 109 |
110 #endif // MASH_WM_SHADOW_H_ | 110 #endif // ASH_MUS_SHADOW_H_ |
OLD | NEW |