OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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_WM_SHADOW_H_ | |
6 #define ASH_WM_SHADOW_H_ | |
7 | |
8 #include "ash/ash_export.h" | |
9 #include "base/basictypes.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "ui/compositor/layer_animation_observer.h" | |
12 #include "ui/gfx/rect.h" | |
13 | |
14 namespace ui { | |
15 class Layer; | |
16 } // namespace ui | |
17 | |
18 namespace ash { | |
19 namespace internal { | |
20 | |
21 class ImageGrid; | |
22 | |
23 // Simple class that draws a drop shadow around content at given bounds. | |
24 class ASH_EXPORT Shadow : public ui::ImplicitAnimationObserver { | |
25 public: | |
26 enum Style { | |
27 // Active windows have more opaque shadows, shifted down to make the window | |
28 // appear "higher". | |
29 STYLE_ACTIVE, | |
30 | |
31 // Inactive windows have less opaque shadows. | |
32 STYLE_INACTIVE, | |
33 | |
34 // Small windows like tooltips and context menus have lighter, smaller | |
35 // shadows. | |
36 STYLE_SMALL, | |
37 }; | |
38 | |
39 Shadow(); | |
40 virtual ~Shadow(); | |
41 | |
42 void Init(Style style); | |
43 | |
44 // Returns |image_grid_|'s ui::Layer. This is exposed so it can be added to | |
45 // the same layer as the content and stacked below it. SetContentBounds() | |
46 // should be used to adjust the shadow's size and position (rather than | |
47 // applying transformations to this layer). | |
48 ui::Layer* layer() const; | |
49 | |
50 const gfx::Rect& content_bounds() const { return content_bounds_; } | |
51 Style style() const { return style_; } | |
52 | |
53 // Moves and resizes |image_grid_| to frame |content_bounds|. | |
54 void SetContentBounds(const gfx::Rect& content_bounds); | |
55 | |
56 // Sets the shadow's style, animating opacity as necessary. | |
57 void SetStyle(Style style); | |
58 | |
59 // ui::ImplicitAnimationObserver overrides: | |
60 virtual void OnImplicitAnimationsCompleted() OVERRIDE; | |
61 | |
62 private: | |
63 // Updates the |image_grid_| images to the current |style_|. | |
64 void UpdateImagesForStyle(); | |
65 | |
66 // Updates the |image_grid_| bounds based on its image sizes and the | |
67 // current |content_bounds_|. | |
68 void UpdateImageGridBounds(); | |
69 | |
70 // The current style, set when the transition animation starts. | |
71 Style style_; | |
72 | |
73 scoped_ptr<ImageGrid> image_grid_; | |
74 | |
75 // Bounds of the content that the shadow encloses. | |
76 gfx::Rect content_bounds_; | |
77 | |
78 DISALLOW_COPY_AND_ASSIGN(Shadow); | |
79 }; | |
80 | |
81 } // namespace internal | |
82 } // namespace ash | |
83 | |
84 #endif // ASH_WM_SHADOW_H_ | |
OLD | NEW |