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

Side by Side Diff: ui/views/border.h

Issue 145033006: views: Make View::set_border() take a scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove ClearBorder() Created 6 years, 11 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
« no previous file with comments | « ui/message_center/views/notifier_settings_view.cc ('k') | ui/views/border.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
9 #include "third_party/skia/include/core/SkColor.h" 10 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/gfx/insets.h" 11 #include "ui/gfx/insets.h"
11 #include "ui/views/views_export.h" 12 #include "ui/views/views_export.h"
12 13
13 namespace gfx{ 14 namespace gfx{
14 class Canvas; 15 class Canvas;
15 class Size; 16 class Size;
16 } 17 }
17 18
18 namespace views { 19 namespace views {
19 20
20 class Painter; 21 class Painter;
21 class View; 22 class View;
22 23
23 //////////////////////////////////////////////////////////////////////////////// 24 ////////////////////////////////////////////////////////////////////////////////
24 // 25 //
25 // Border class. 26 // Border class.
26 // 27 //
27 // The border class is used to display a border around a view. 28 // The border class is used to display a border around a view.
28 // To set a border on a view, just call SetBorder on the view, for example: 29 // To set a border on a view, just call SetBorder on the view, for example:
29 // view->set_border(Border::CreateSolidBorder(1, SkColorSetRGB(25, 25, 112)); 30 // view->SetBorder(Border::CreateSolidBorder(1, SkColorSetRGB(25, 25, 112));
30 // Once set on a view, the border is owned by the view. 31 // Once set on a view, the border is owned by the view.
31 // 32 //
32 // IMPORTANT NOTE: not all views support borders at this point. In order to 33 // IMPORTANT NOTE: not all views support borders at this point. In order to
33 // support the border, views should make sure to use bounds excluding the 34 // support the border, views should make sure to use bounds excluding the
34 // border (by calling View::GetLocalBoundsExcludingBorder) when doing layout and 35 // border (by calling View::GetLocalBoundsExcludingBorder) when doing layout and
35 // painting. 36 // painting.
36 // 37 //
37 //////////////////////////////////////////////////////////////////////////////// 38 ////////////////////////////////////////////////////////////////////////////////
38 39
39 class TextButtonBorder; 40 class TextButtonBorder;
40 41
41 class VIEWS_EXPORT Border { 42 class VIEWS_EXPORT Border {
42 public: 43 public:
43 Border(); 44 Border();
44 virtual ~Border(); 45 virtual ~Border();
45 46
47 // Documents that you are not drawing a border.
sky 2014/01/24 16:33:47 Convenience for creating a scoped_ptr with no Bord
48 static scoped_ptr<Border> NullBorder();
49
46 // Creates a border that is a simple line of the specified thickness and 50 // Creates a border that is a simple line of the specified thickness and
47 // color. 51 // color.
48 static Border* CreateSolidBorder(int thickness, SkColor color); 52 static scoped_ptr<Border> CreateSolidBorder(int thickness, SkColor color);
49 53
50 // Creates a border for reserving space. The returned border does not 54 // Creates a border for reserving space. The returned border does not
51 // paint anything. 55 // paint anything.
52 static Border* CreateEmptyBorder(int top, int left, int bottom, int right); 56 static scoped_ptr<Border> CreateEmptyBorder(int top,
57 int left,
58 int bottom,
59 int right);
53 60
54 // Creates a border of the specified color, and specified thickness on each 61 // Creates a border of the specified color, and specified thickness on each
55 // side. 62 // side.
56 static Border* CreateSolidSidedBorder(int top, 63 static scoped_ptr<Border> CreateSolidSidedBorder(int top,
57 int left, 64 int left,
58 int bottom, 65 int bottom,
59 int right, 66 int right,
60 SkColor color); 67 SkColor color);
61 68
62 // Creates a Border from the specified Painter. The border owns the painter, 69 // Creates a Border from the specified Painter. The border owns the painter,
63 // thus the painter is deleted when the Border is deleted. 70 // thus the painter is deleted when the Border is deleted.
64 // |insets| define size of an area allocated for a Border. 71 // |insets| define size of an area allocated for a Border.
65 static Border* CreateBorderPainter(Painter* painter, 72 static scoped_ptr<Border> CreateBorderPainter(Painter* painter,
66 const gfx::Insets& insets); 73 const gfx::Insets& insets);
67 74
68 // Renders the border for the specified view. 75 // Renders the border for the specified view.
69 virtual void Paint(const View& view, gfx::Canvas* canvas) = 0; 76 virtual void Paint(const View& view, gfx::Canvas* canvas) = 0;
70 77
71 // Returns the border insets. 78 // Returns the border insets.
72 virtual gfx::Insets GetInsets() const = 0; 79 virtual gfx::Insets GetInsets() const = 0;
73 80
74 // Returns the minimum size this border requires. Note that this may not be 81 // Returns the minimum size this border requires. Note that this may not be
75 // the same as the insets. For example, a Border may paint images to draw 82 // the same as the insets. For example, a Border may paint images to draw
76 // some graphical border around a view, and this would return the minimum size 83 // some graphical border around a view, and this would return the minimum size
77 // such that these images would not be clipped or overlapping -- but the 84 // such that these images would not be clipped or overlapping -- but the
78 // insets may be larger or smaller, depending on how the view wanted its 85 // insets may be larger or smaller, depending on how the view wanted its
79 // content laid out relative to these images. 86 // content laid out relative to these images.
80 virtual gfx::Size GetMinimumSize() const = 0; 87 virtual gfx::Size GetMinimumSize() const = 0;
81 88
82 // Manual RTTI for text buttons. 89 // Manual RTTI for text buttons.
83 virtual TextButtonBorder* AsTextButtonBorder(); 90 virtual TextButtonBorder* AsTextButtonBorder();
84 virtual const TextButtonBorder* AsTextButtonBorder() const; 91 virtual const TextButtonBorder* AsTextButtonBorder() const;
85 92
86 private: 93 private:
87 DISALLOW_COPY_AND_ASSIGN(Border); 94 DISALLOW_COPY_AND_ASSIGN(Border);
88 }; 95 };
89 96
90 } // namespace views 97 } // namespace views
91 98
92 #endif // UI_VIEWS_BORDER_H_ 99 #endif // UI_VIEWS_BORDER_H_
OLDNEW
« no previous file with comments | « ui/message_center/views/notifier_settings_view.cc ('k') | ui/views/border.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698