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_VIEWS_BORDER_H_ | 5 #ifndef UI_VIEWS_BORDER_H_ |
6 #define UI_VIEWS_BORDER_H_ | 6 #define UI_VIEWS_BORDER_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "third_party/skia/include/core/SkColor.h" | 11 #include "third_party/skia/include/core/SkColor.h" |
11 #include "ui/gfx/geometry/insets.h" | 12 #include "ui/gfx/geometry/insets.h" |
12 #include "ui/views/views_export.h" | 13 #include "ui/views/views_export.h" |
13 | 14 |
14 namespace gfx{ | 15 namespace gfx{ |
15 class Canvas; | 16 class Canvas; |
16 class Size; | 17 class Size; |
17 } | 18 } |
18 | 19 |
19 namespace views { | 20 namespace views { |
(...skipping 16 matching lines...) Expand all Loading... |
36 // painting. | 37 // painting. |
37 // | 38 // |
38 //////////////////////////////////////////////////////////////////////////////// | 39 //////////////////////////////////////////////////////////////////////////////// |
39 | 40 |
40 class VIEWS_EXPORT Border { | 41 class VIEWS_EXPORT Border { |
41 public: | 42 public: |
42 Border(); | 43 Border(); |
43 virtual ~Border(); | 44 virtual ~Border(); |
44 | 45 |
45 // Convenience for creating a scoped_ptr with no Border. | 46 // Convenience for creating a scoped_ptr with no Border. |
46 static scoped_ptr<Border> NullBorder(); | 47 static std::unique_ptr<Border> NullBorder(); |
47 | 48 |
48 // Creates a border that is a simple line of the specified thickness and | 49 // Creates a border that is a simple line of the specified thickness and |
49 // color. | 50 // color. |
50 static scoped_ptr<Border> CreateSolidBorder(int thickness, SkColor color); | 51 static std::unique_ptr<Border> CreateSolidBorder(int thickness, |
| 52 SkColor color); |
51 | 53 |
52 // Creates a border that is a rounded rectangle of the specified thickness and | 54 // Creates a border that is a rounded rectangle of the specified thickness and |
53 // color. | 55 // color. |
54 static scoped_ptr<Border> CreateRoundedRectBorder(int thickness, | 56 static std::unique_ptr<Border> CreateRoundedRectBorder(int thickness, |
55 int corner_radius, | 57 int corner_radius, |
56 SkColor color); | 58 SkColor color); |
57 | 59 |
58 // Creates a border for reserving space. The returned border does not | 60 // Creates a border for reserving space. The returned border does not |
59 // paint anything. | 61 // paint anything. |
60 static scoped_ptr<Border> CreateEmptyBorder(const gfx::Insets& insets); | 62 static std::unique_ptr<Border> CreateEmptyBorder(const gfx::Insets& insets); |
61 static scoped_ptr<Border> CreateEmptyBorder(int top, | 63 static std::unique_ptr<Border> CreateEmptyBorder(int top, |
62 int left, | 64 int left, |
63 int bottom, | 65 int bottom, |
64 int right); | 66 int right); |
65 | 67 |
66 // Creates a border of the specified color, and specified thickness on each | 68 // Creates a border of the specified color, and specified thickness on each |
67 // side. | 69 // side. |
68 static scoped_ptr<Border> CreateSolidSidedBorder(int top, | 70 static std::unique_ptr<Border> CreateSolidSidedBorder(int top, |
69 int left, | 71 int left, |
70 int bottom, | 72 int bottom, |
71 int right, | 73 int right, |
72 SkColor color); | 74 SkColor color); |
73 | 75 |
74 // Creates a Border from the specified Painter. The border owns the painter, | 76 // Creates a Border from the specified Painter. The border owns the painter, |
75 // thus the painter is deleted when the Border is deleted. | 77 // thus the painter is deleted when the Border is deleted. |
76 // |insets| define size of an area allocated for a Border. | 78 // |insets| define size of an area allocated for a Border. |
77 static scoped_ptr<Border> CreateBorderPainter(Painter* painter, | 79 static std::unique_ptr<Border> CreateBorderPainter(Painter* painter, |
78 const gfx::Insets& insets); | 80 const gfx::Insets& insets); |
79 | 81 |
80 // Renders the border for the specified view. | 82 // Renders the border for the specified view. |
81 virtual void Paint(const View& view, gfx::Canvas* canvas) = 0; | 83 virtual void Paint(const View& view, gfx::Canvas* canvas) = 0; |
82 | 84 |
83 // Returns the border insets. | 85 // Returns the border insets. |
84 virtual gfx::Insets GetInsets() const = 0; | 86 virtual gfx::Insets GetInsets() const = 0; |
85 | 87 |
86 // Returns the minimum size this border requires. Note that this may not be | 88 // Returns the minimum size this border requires. Note that this may not be |
87 // the same as the insets. For example, a Border may paint images to draw | 89 // the same as the insets. For example, a Border may paint images to draw |
88 // some graphical border around a view, and this would return the minimum size | 90 // some graphical border around a view, and this would return the minimum size |
89 // such that these images would not be clipped or overlapping -- but the | 91 // such that these images would not be clipped or overlapping -- but the |
90 // insets may be larger or smaller, depending on how the view wanted its | 92 // insets may be larger or smaller, depending on how the view wanted its |
91 // content laid out relative to these images. | 93 // content laid out relative to these images. |
92 virtual gfx::Size GetMinimumSize() const = 0; | 94 virtual gfx::Size GetMinimumSize() const = 0; |
93 | 95 |
94 private: | 96 private: |
95 DISALLOW_COPY_AND_ASSIGN(Border); | 97 DISALLOW_COPY_AND_ASSIGN(Border); |
96 }; | 98 }; |
97 | 99 |
98 } // namespace views | 100 } // namespace views |
99 | 101 |
100 #endif // UI_VIEWS_BORDER_H_ | 102 #endif // UI_VIEWS_BORDER_H_ |
OLD | NEW |