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

Side by Side Diff: ash/mus/shadow.h

Issue 2690363002: chromeos: removes mash shadows (Closed)
Patch Set: merge Created 3 years, 10 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
« no previous file with comments | « ash/mus/non_client_frame_controller.cc ('k') | ash/mus/shadow.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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_MUS_SHADOW_H_
6 #define ASH_MUS_SHADOW_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "ui/aura/window_observer.h"
12 #include "ui/compositor/layer_animation_observer.h"
13 #include "ui/gfx/geometry/rect.h"
14
15 namespace ui {
16 class Layer;
17 } // namespace ui
18
19 namespace ash {
20 namespace mus {
21
22 // Simple class that draws a drop shadow around content at given bounds.
23 // http://crbug.com/670840.
24 class Shadow : public ui::ImplicitAnimationObserver,
25 public aura::WindowObserver {
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
32 // Inactive windows have less opaque shadows.
33 STYLE_INACTIVE,
34
35 // Small windows like tooltips and context menus have lighter, smaller
36 // shadows.
37 STYLE_SMALL,
38 };
39
40 Shadow();
41 ~Shadow() override;
42
43 void Init(Style style);
44
45 static Shadow* Get(aura::Window* window);
46
47 // Returns the interio inset for the specified style. The interior inset
48 // is the amount of padding added to each side of the content bounds that the
49 // shadow renders into. In other words the shadow extends from all sides of
50 // the layer by this value.
51 static int GetInteriorInsetForStyle(Style style);
52
53 // Returns |layer_.get()|. This is exposed so it can be added to the same
54 // layer as the content and stacked below it. SetContentBounds() should be
55 // used to adjust the shadow's size and position (rather than applying
56 // transformations to this layer).
57 ui::Layer* layer() const { return layer_.get(); }
58
59 const gfx::Rect& content_bounds() const { return content_bounds_; }
60 Style style() const { return style_; }
61
62 // Moves and resizes the shadow layer to frame |content_bounds|.
63 void SetContentBounds(const gfx::Rect& content_bounds);
64
65 // Sets the shadow's style, animating opacity as necessary.
66 void SetStyle(Style style);
67
68 // Installs this shadow for |window|.
69 void Install(aura::Window* window);
70
71 // ui::ImplicitAnimationObserver overrides:
72 void OnImplicitAnimationsCompleted() override;
73
74 private:
75 // Updates the shadow images to the current |style_|.
76 void UpdateImagesForStyle();
77
78 // Updates the shadow layer bounds based on the inteior inset and the current
79 // |content_bounds_|.
80 void UpdateLayerBounds();
81
82 // WindowObserver:
83 void OnWindowDestroyed(aura::Window* window) override;
84
85 // The current style, set when the transition animation starts.
86 Style style_;
87
88 // The parent layer of the shadow layer. It serves as a container accessible
89 // from the outside to control the visibility of the shadow.
90 std::unique_ptr<ui::Layer> layer_;
91
92 // The actual shadow layer corresponding to a cc::NinePatchLayer.
93 std::unique_ptr<ui::Layer> shadow_layer_;
94
95 // Size of the current shadow image.
96 gfx::Size image_size_;
97
98 // Bounds of the content that the shadow encloses.
99 gfx::Rect content_bounds_;
100
101 // The interior inset of the shadow images. The content bounds of the image
102 // grid should be set to |content_bounds_| inset by this amount.
103 int interior_inset_;
104
105 aura::Window* window_;
106
107 DISALLOW_COPY_AND_ASSIGN(Shadow);
108 };
109
110 } // namespace mus
111 } // namespace ash
112
113 #endif // ASH_MUS_SHADOW_H_
OLDNEW
« no previous file with comments | « ash/mus/non_client_frame_controller.cc ('k') | ash/mus/shadow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698