summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/views/border.cc42
-rw-r--r--ui/views/border.h6
2 files changed, 38 insertions, 10 deletions
diff --git a/ui/views/border.cc b/ui/views/border.cc
index 7c6a981..dad74d7 100644
--- a/ui/views/border.cc
+++ b/ui/views/border.cc
@@ -12,29 +12,33 @@ namespace views {
namespace {
-// A simple border with a fixed thickness and single color.
-class SolidBorder : public Border {
+// A simple border with different thicknesses on each side and single color.
+class SidedSolidBorder : public Border {
public:
- SolidBorder(int thickness, SkColor color);
+ SidedSolidBorder(int top, int left, int bottom, int right, SkColor color);
virtual void Paint(const View& view, gfx::Canvas* canvas) const;
virtual void GetInsets(gfx::Insets* insets) const;
private:
- int thickness_;
+ int top_, left_, bottom_, right_;
SkColor color_;
gfx::Insets insets_;
- DISALLOW_COPY_AND_ASSIGN(SolidBorder);
+ DISALLOW_COPY_AND_ASSIGN(SidedSolidBorder);
};
-SolidBorder::SolidBorder(int thickness, SkColor color)
- : thickness_(thickness),
+SidedSolidBorder::SidedSolidBorder(int top, int left, int bottom, int right,
+ SkColor color)
+ : top_(top),
+ left_(left),
+ bottom_(bottom),
+ right_(right),
color_(color),
- insets_(thickness, thickness, thickness, thickness) {
+ insets_(top, left, bottom, right) {
}
-void SolidBorder::Paint(const View& view, gfx::Canvas* canvas) const {
+void SidedSolidBorder::Paint(const View& view, gfx::Canvas* canvas) const {
// Top border.
canvas->FillRect(gfx::Rect(0, 0, view.width(), insets_.top()), color_);
// Left border.
@@ -47,11 +51,22 @@ void SolidBorder::Paint(const View& view, gfx::Canvas* canvas) const {
view.height()), color_);
}
-void SolidBorder::GetInsets(gfx::Insets* insets) const {
+void SidedSolidBorder::GetInsets(gfx::Insets* insets) const {
DCHECK(insets);
insets->Set(insets_.top(), insets_.left(), insets_.bottom(), insets_.right());
}
+// A variation of SidedSolidBorder, where each side has the same thickness.
+class SolidBorder : public SidedSolidBorder {
+ public:
+ SolidBorder(int thickness, SkColor color)
+ : SidedSolidBorder(thickness, thickness, thickness, thickness, color) {
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SolidBorder);
+};
+
class EmptyBorder : public Border {
public:
EmptyBorder(int top, int left, int bottom, int right)
@@ -117,6 +132,13 @@ Border* Border::CreateEmptyBorder(int top, int left, int bottom, int right) {
return new EmptyBorder(top, left, bottom, right);
}
+// static
+Border* Border::CreateSolidSidedBorder(int top, int left,
+ int bottom, int right,
+ SkColor color) {
+ return new SidedSolidBorder(top, left, bottom, right, color);
+}
+
//static
Border* Border::CreateBorderPainter(Painter* painter) {
return new BorderPainter(painter);
diff --git a/ui/views/border.h b/ui/views/border.h
index d28a523..a362fcc 100644
--- a/ui/views/border.h
+++ b/ui/views/border.h
@@ -48,6 +48,12 @@ class VIEWS_EXPORT Border {
// paint anything.
static Border* CreateEmptyBorder(int top, int left, int bottom, int right);
+ // Creates a border of the specified color, and specified thickness on each
+ // side.
+ static Border* CreateSolidSidedBorder(int top, int left,
+ int bottom, int right,
+ SkColor color);
+
// Creates a Border from the specified Painter. The border owns the painter,
// thus the painter is deleted when the Border is deleted.
static Border* CreateBorderPainter(Painter* painter);