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

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

Issue 2475033003: Add ability to specify extra insets for a view via its border. (Closed)
Patch Set: better comment Created 4 years, 1 month 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/common/system/user/user_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 <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 int right); 66 int right);
67 67
68 // 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
69 // side. 69 // side.
70 static std::unique_ptr<Border> CreateSolidSidedBorder(int top, 70 static std::unique_ptr<Border> CreateSolidSidedBorder(int top,
71 int left, 71 int left,
72 int bottom, 72 int bottom,
73 int right, 73 int right,
74 SkColor color); 74 SkColor color);
75 75
76 // Adds extra, unpainted insets to |border|. This is effectively equivalent to
77 // adding an EmptyBorder and then |border|. Example:
sky 2016/11/04 15:32:53 optional: I would take this second sentence to mea
Evan Stade 2016/11/04 15:50:16 ok
78 //
79 // view->SetBorder(Border::AddInteriorPadding(
80 // Border::CreateSolidBorder(1, SK_ColorRED),
81 // gfx::Insets(2, 0, 0, 0)));
82 //
83 // yields a single dip red border and an additional 2dip of unpainted padding
84 // above the view content (below the border).
85 static std::unique_ptr<Border> AddInteriorPadding(
86 std::unique_ptr<Border> border,
87 const gfx::Insets& insets);
88
76 // Creates a Border from the specified Painter. 89 // Creates a Border from the specified Painter.
77 // |insets| define size of an area allocated for a Border. 90 // |insets| define size of an area allocated for a Border.
78 static std::unique_ptr<Border> CreateBorderPainter( 91 static std::unique_ptr<Border> CreateBorderPainter(
79 std::unique_ptr<Painter> painter, 92 std::unique_ptr<Painter> painter,
80 const gfx::Insets& insets); 93 const gfx::Insets& insets);
81 94
82 // Renders the border for the specified view. 95 // Renders the border for the specified view.
83 virtual void Paint(const View& view, gfx::Canvas* canvas) = 0; 96 virtual void Paint(const View& view, gfx::Canvas* canvas) = 0;
84 97
85 // Returns the border insets. 98 // Returns the border insets.
86 virtual gfx::Insets GetInsets() const = 0; 99 virtual gfx::Insets GetInsets() const = 0;
87 100
88 // Returns the minimum size this border requires. Note that this may not be 101 // Returns the minimum size this border requires. Note that this may not be
89 // the same as the insets. For example, a Border may paint images to draw 102 // the same as the insets. For example, a Border may paint images to draw
90 // some graphical border around a view, and this would return the minimum size 103 // some graphical border around a view, and this would return the minimum size
91 // such that these images would not be clipped or overlapping -- but the 104 // such that these images would not be clipped or overlapping -- but the
92 // insets may be larger or smaller, depending on how the view wanted its 105 // insets may be larger or smaller, depending on how the view wanted its
93 // content laid out relative to these images. 106 // content laid out relative to these images.
94 virtual gfx::Size GetMinimumSize() const = 0; 107 virtual gfx::Size GetMinimumSize() const = 0;
95 108
96 private: 109 private:
97 DISALLOW_COPY_AND_ASSIGN(Border); 110 DISALLOW_COPY_AND_ASSIGN(Border);
98 }; 111 };
99 112
100 } // namespace views 113 } // namespace views
101 114
102 #endif // UI_VIEWS_BORDER_H_ 115 #endif // UI_VIEWS_BORDER_H_
OLDNEW
« no previous file with comments | « ash/common/system/user/user_view.cc ('k') | ui/views/border.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698