Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: ui/wm/core/shadow.h

Issue 385123005: Change ui::wm::Shadow to use cc::NinePatchLayer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 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 UI_WM_CORE_SHADOW_H_ 5 #ifndef UI_WM_CORE_SHADOW_H_
6 #define UI_WM_CORE_SHADOW_H_ 6 #define UI_WM_CORE_SHADOW_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "ui/compositor/layer_animation_observer.h" 10 #include "ui/compositor/layer_animation_observer.h"
11 #include "ui/gfx/rect.h" 11 #include "ui/gfx/rect.h"
12 #include "ui/wm/wm_export.h" 12 #include "ui/wm/wm_export.h"
13 13
14 namespace ui { 14 namespace ui {
15 class Layer; 15 class Layer;
16 } // namespace ui 16 } // namespace ui
17 17
18 namespace wm { 18 namespace wm {
19 19
20 class ImageGrid;
21
22 // Simple class that draws a drop shadow around content at given bounds. 20 // Simple class that draws a drop shadow around content at given bounds.
23 class WM_EXPORT Shadow : public ui::ImplicitAnimationObserver { 21 class WM_EXPORT Shadow : public ui::ImplicitAnimationObserver {
24 public: 22 public:
25 enum Style { 23 enum Style {
26 // Active windows have more opaque shadows, shifted down to make the window 24 // Active windows have more opaque shadows, shifted down to make the window
27 // appear "higher". 25 // appear "higher".
28 STYLE_ACTIVE, 26 STYLE_ACTIVE,
29 27
30 // Inactive windows have less opaque shadows. 28 // Inactive windows have less opaque shadows.
31 STYLE_INACTIVE, 29 STYLE_INACTIVE,
32 30
33 // Small windows like tooltips and context menus have lighter, smaller 31 // Small windows like tooltips and context menus have lighter, smaller
34 // shadows. 32 // shadows.
35 STYLE_SMALL, 33 STYLE_SMALL,
36 }; 34 };
37 35
38 Shadow(); 36 Shadow();
39 virtual ~Shadow(); 37 virtual ~Shadow();
40 38
41 void Init(Style style); 39 void Init(Style style);
42 40
43 // Returns |image_grid_|'s ui::Layer. This is exposed so it can be added to 41 // Returns |layer_.get()|. This is exposed so it can be added to the same
44 // the same layer as the content and stacked below it. SetContentBounds() 42 // layer as the content and stacked below it. SetContentBounds() should be
45 // should be used to adjust the shadow's size and position (rather than 43 // used to adjust the shadow's size and position (rather than applying
46 // applying transformations to this layer). 44 // transformations to this layer).
47 ui::Layer* layer() const; 45 ui::Layer* layer() const { return layer_.get(); }
48 46
49 const gfx::Rect& content_bounds() const { return content_bounds_; } 47 const gfx::Rect& content_bounds() const { return content_bounds_; }
50 Style style() const { return style_; } 48 Style style() const { return style_; }
51 49
52 // Moves and resizes |image_grid_| to frame |content_bounds|. 50 // Moves and resizes the shadow layer to frame |content_bounds|.
53 void SetContentBounds(const gfx::Rect& content_bounds); 51 void SetContentBounds(const gfx::Rect& content_bounds);
54 52
55 // Sets the shadow's style, animating opacity as necessary. 53 // Sets the shadow's style, animating opacity as necessary.
56 void SetStyle(Style style); 54 void SetStyle(Style style);
57 55
58 // ui::ImplicitAnimationObserver overrides: 56 // ui::ImplicitAnimationObserver overrides:
59 virtual void OnImplicitAnimationsCompleted() OVERRIDE; 57 virtual void OnImplicitAnimationsCompleted() OVERRIDE;
60 58
61 private: 59 private:
62 // Updates the |image_grid_| images to the current |style_|. 60 // Updates the shadow images to the current |style_|.
63 void UpdateImagesForStyle(); 61 void UpdateImagesForStyle();
64 62
65 // Updates the |image_grid_| bounds based on its image sizes and the 63 // Updates the image bounds based on its image sizes and the current
66 // current |content_bounds_|. 64 // |content_bounds_|.
67 void UpdateImageGridBounds(); 65 void UpdateImageBounds();
68 66
69 // The current style, set when the transition animation starts. 67 // The current style, set when the transition animation starts.
70 Style style_; 68 Style style_;
71 69
72 scoped_ptr<ImageGrid> image_grid_; 70 scoped_ptr<ui::Layer> layer_;
73 71
74 // Bounds of the content that the shadow encloses. 72 // Bounds of the content that the shadow encloses.
75 gfx::Rect content_bounds_; 73 gfx::Rect content_bounds_;
76 74
77 // The interior inset of the shadow images. The content bounds of the image 75 // 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. 76 // grid should be set to |content_bounds_| inset by this amount.
79 int interior_inset_; 77 int interior_inset_;
80 78
81 DISALLOW_COPY_AND_ASSIGN(Shadow); 79 DISALLOW_COPY_AND_ASSIGN(Shadow);
82 }; 80 };
83 81
84 } // namespace wm 82 } // namespace wm
85 83
86 #endif // UI_WM_CORE_SHADOW_H_ 84 #endif // UI_WM_CORE_SHADOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698