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_WM_CORE_SHADOW_H_
6 #define UI_WM_CORE_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/wm/core/wm_core_export.h"
22 // Simple class that draws a drop shadow around content at given bounds.
23 class WM_CORE_EXPORT Shadow : public ui::ImplicitAnimationObserver {
26 // Active windows have more opaque shadows, shifted down to make the window
30 // Inactive windows have less opaque shadows.
33 // Small windows like tooltips and context menus have lighter, smaller
41 void Init(Style style);
43 // Returns |image_grid_|'s ui::Layer. This is exposed so it can be added to
44 // the same layer as the content and stacked below it. SetContentBounds()
45 // should be used to adjust the shadow's size and position (rather than
46 // applying transformations to this layer).
47 ui::Layer* layer() const;
49 const gfx::Rect& content_bounds() const { return content_bounds_; }
50 Style style() const { return style_; }
52 // Moves and resizes |image_grid_| to frame |content_bounds|.
53 void SetContentBounds(const gfx::Rect& content_bounds);
55 // Sets the shadow's style, animating opacity as necessary.
56 void SetStyle(Style style);
58 // ui::ImplicitAnimationObserver overrides:
59 virtual void OnImplicitAnimationsCompleted() OVERRIDE;
62 // Updates the |image_grid_| images to the current |style_|.
63 void UpdateImagesForStyle();
65 // Updates the |image_grid_| bounds based on its image sizes and the
66 // current |content_bounds_|.
67 void UpdateImageGridBounds();
69 // The current style, set when the transition animation starts.
72 scoped_ptr<ImageGrid> image_grid_;
74 // Bounds of the content that the shadow encloses.
75 gfx::Rect content_bounds_;
77 // The interior inset of the shadow images. The content bounds of the image
78 // grid should be set to |content_bounds_| inset by this amount.
81 DISALLOW_COPY_AND_ASSIGN(Shadow);
86 #endif // UI_WM_CORE_SHADOW_H_