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.
5 #ifndef UI_VIEWS_COREWM_SHADOW_H_
6 #define UI_VIEWS_COREWM_SHADOW_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ui/compositor/layer_animation_observer.h"
11 #include "ui/gfx/rect.h"
12 #include "ui/views/views_export.h"
23 // Simple class that draws a drop shadow around content at given bounds.
24 class VIEWS_EXPORT Shadow : public ui::ImplicitAnimationObserver {
27 // Active windows have more opaque shadows, shifted down to make the window
31 // Inactive windows have less opaque shadows.
34 // Small windows like tooltips and context menus have lighter, smaller
42 void Init(Style style);
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;
50 const gfx::Rect& content_bounds() const { return content_bounds_; }
51 Style style() const { return style_; }
53 // Moves and resizes |image_grid_| to frame |content_bounds|.
54 void SetContentBounds(const gfx::Rect& content_bounds);
56 // Sets the shadow's style, animating opacity as necessary.
57 void SetStyle(Style style);
59 // ui::ImplicitAnimationObserver overrides:
60 virtual void OnImplicitAnimationsCompleted() OVERRIDE;
63 // Updates the |image_grid_| images to the current |style_|.
64 void UpdateImagesForStyle();
66 // Updates the |image_grid_| bounds based on its image sizes and the
67 // current |content_bounds_|.
68 void UpdateImageGridBounds();
70 // The current style, set when the transition animation starts.
73 scoped_ptr<ImageGrid> image_grid_;
75 // Bounds of the content that the shadow encloses.
76 gfx::Rect content_bounds_;
78 // The interior inset of the shadow images. The content bounds of the image
79 // grid should be set to |content_bounds_| inset by this amount.
82 DISALLOW_COPY_AND_ASSIGN(Shadow);
88 #endif // UI_VIEWS_COREWM_SHADOW_H_