OLD | NEW |
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_GFX_SHADOW_VALUE_ | 5 #ifndef UI_GFX_SHADOW_VALUE_H_ |
6 #define UI_GFX_SHADOW_VALUE_ | 6 #define UI_GFX_SHADOW_VALUE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "third_party/skia/include/core/SkColor.h" | 12 #include "third_party/skia/include/core/SkColor.h" |
13 #include "ui/base/ui_export.h" | 13 #include "ui/base/ui_export.h" |
14 #include "ui/gfx/point.h" | 14 #include "ui/gfx/point.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 | 17 |
18 class Insets; | 18 class Insets; |
19 | 19 |
| 20 class ShadowValue; |
| 21 typedef std::vector<ShadowValue> ShadowValues; |
| 22 |
20 // ShadowValue encapsulates parameters needed to define a shadow, including the | 23 // ShadowValue encapsulates parameters needed to define a shadow, including the |
21 // shadow's offset, blur amount and color. | 24 // shadow's offset, blur amount and color. |
22 class UI_EXPORT ShadowValue { | 25 class UI_EXPORT ShadowValue { |
23 public: | 26 public: |
24 ShadowValue(); | 27 ShadowValue(); |
25 ShadowValue(const gfx::Point& offset, double blur, SkColor color); | 28 ShadowValue(const gfx::Point& offset, double blur, SkColor color); |
26 ~ShadowValue(); | 29 ~ShadowValue(); |
27 | 30 |
28 int x() const { return offset_.x(); } | 31 int x() const { return offset_.x(); } |
29 int y() const { return offset_.y(); } | 32 int y() const { return offset_.y(); } |
30 const gfx::Point& offset() const { return offset_; } | 33 const gfx::Point& offset() const { return offset_; } |
31 double blur() const { return blur_; } | 34 double blur() const { return blur_; } |
32 SkColor color() const { return color_; } | 35 SkColor color() const { return color_; } |
33 | 36 |
34 std::string ToString() const; | 37 std::string ToString() const; |
35 | 38 |
36 // Gets margin space needed for shadows. Note that values in returned Insets | 39 // Gets margin space needed for shadows. Note that values in returned Insets |
37 // are negative because shadow margins are outside a boundary. | 40 // are negative because shadow margins are outside a boundary. |
38 static Insets GetMargin(const std::vector<ShadowValue>& shadows); | 41 static Insets GetMargin(const ShadowValues& shadows); |
39 | 42 |
40 private: | 43 private: |
41 gfx::Point offset_; | 44 gfx::Point offset_; |
42 | 45 |
43 // Blur amount of the shadow in pixels. If underlying implementation supports | 46 // Blur amount of the shadow in pixels. If underlying implementation supports |
44 // (e.g. Skia), it can have fraction part such as 0.5 pixel. The value | 47 // (e.g. Skia), it can have fraction part such as 0.5 pixel. The value |
45 // defines a range from full shadow color at the start point inside the | 48 // defines a range from full shadow color at the start point inside the |
46 // shadow to fully transparent at the end point outside it. The range is | 49 // shadow to fully transparent at the end point outside it. The range is |
47 // perpendicular to and centered on the shadow edge. For example, a blur | 50 // perpendicular to and centered on the shadow edge. For example, a blur |
48 // amount of 4.0 means to have a blurry shadow edge of 4 pixels that | 51 // amount of 4.0 means to have a blurry shadow edge of 4 pixels that |
49 // transitions from full shadow color to fully transparent and with 2 pixels | 52 // transitions from full shadow color to fully transparent and with 2 pixels |
50 // inside the shadow and 2 pixels goes beyond the edge. | 53 // inside the shadow and 2 pixels goes beyond the edge. |
51 double blur_; | 54 double blur_; |
52 | 55 |
53 SkColor color_; | 56 SkColor color_; |
54 }; | 57 }; |
55 | 58 |
56 } // namespace gfx | 59 } // namespace gfx |
57 | 60 |
58 #endif // UI_GFX_SHADOW_VALUE_ | 61 #endif // UI_GFX_SHADOW_VALUE_H_ |
OLD | NEW |