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