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 #include "ui/views/border.h" | 5 #include "ui/views/border.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
10 #include "ui/views/painter.h" | 10 #include "ui/views/painter.h" |
11 #include "ui/views/view.h" | 11 #include "ui/views/view.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 // A simple border with different thicknesses on each side and single color. | 17 // A simple border with different thicknesses on each side and single color. |
18 class SidedSolidBorder : public Border { | 18 class SidedSolidBorder : public Border { |
19 public: | 19 public: |
20 SidedSolidBorder(int top, int left, int bottom, int right, SkColor color); | 20 SidedSolidBorder(int top, int left, int bottom, int right, SkColor color); |
21 | 21 |
22 // Overridden from Border: | 22 // Overridden from Border: |
23 virtual void Paint(const View& view, gfx::Canvas* canvas) OVERRIDE; | 23 virtual void Paint(const View& view, gfx::Canvas* canvas) override; |
24 virtual gfx::Insets GetInsets() const OVERRIDE; | 24 virtual gfx::Insets GetInsets() const override; |
25 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 25 virtual gfx::Size GetMinimumSize() const override; |
26 | 26 |
27 private: | 27 private: |
28 const SkColor color_; | 28 const SkColor color_; |
29 const gfx::Insets insets_; | 29 const gfx::Insets insets_; |
30 | 30 |
31 DISALLOW_COPY_AND_ASSIGN(SidedSolidBorder); | 31 DISALLOW_COPY_AND_ASSIGN(SidedSolidBorder); |
32 }; | 32 }; |
33 | 33 |
34 SidedSolidBorder::SidedSolidBorder(int top, | 34 SidedSolidBorder::SidedSolidBorder(int top, |
35 int left, | 35 int left, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 private: | 71 private: |
72 DISALLOW_COPY_AND_ASSIGN(SolidBorder); | 72 DISALLOW_COPY_AND_ASSIGN(SolidBorder); |
73 }; | 73 }; |
74 | 74 |
75 class EmptyBorder : public Border { | 75 class EmptyBorder : public Border { |
76 public: | 76 public: |
77 EmptyBorder(int top, int left, int bottom, int right) | 77 EmptyBorder(int top, int left, int bottom, int right) |
78 : insets_(top, left, bottom, right) {} | 78 : insets_(top, left, bottom, right) {} |
79 | 79 |
80 // Overridden from Border: | 80 // Overridden from Border: |
81 virtual void Paint(const View& view, gfx::Canvas* canvas) OVERRIDE {} | 81 virtual void Paint(const View& view, gfx::Canvas* canvas) override {} |
82 | 82 |
83 virtual gfx::Insets GetInsets() const OVERRIDE { | 83 virtual gfx::Insets GetInsets() const override { |
84 return insets_; | 84 return insets_; |
85 } | 85 } |
86 | 86 |
87 virtual gfx::Size GetMinimumSize() const OVERRIDE { | 87 virtual gfx::Size GetMinimumSize() const override { |
88 return gfx::Size(); | 88 return gfx::Size(); |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
92 const gfx::Insets insets_; | 92 const gfx::Insets insets_; |
93 | 93 |
94 DISALLOW_COPY_AND_ASSIGN(EmptyBorder); | 94 DISALLOW_COPY_AND_ASSIGN(EmptyBorder); |
95 }; | 95 }; |
96 | 96 |
97 class BorderPainter : public Border { | 97 class BorderPainter : public Border { |
98 public: | 98 public: |
99 explicit BorderPainter(Painter* painter, const gfx::Insets& insets) | 99 explicit BorderPainter(Painter* painter, const gfx::Insets& insets) |
100 : painter_(painter), | 100 : painter_(painter), |
101 insets_(insets) { | 101 insets_(insets) { |
102 DCHECK(painter); | 102 DCHECK(painter); |
103 } | 103 } |
104 | 104 |
105 virtual ~BorderPainter() {} | 105 virtual ~BorderPainter() {} |
106 | 106 |
107 // Overridden from Border: | 107 // Overridden from Border: |
108 virtual void Paint(const View& view, gfx::Canvas* canvas) OVERRIDE { | 108 virtual void Paint(const View& view, gfx::Canvas* canvas) override { |
109 Painter::PaintPainterAt(canvas, painter_.get(), view.GetLocalBounds()); | 109 Painter::PaintPainterAt(canvas, painter_.get(), view.GetLocalBounds()); |
110 } | 110 } |
111 | 111 |
112 virtual gfx::Insets GetInsets() const OVERRIDE { | 112 virtual gfx::Insets GetInsets() const override { |
113 return insets_; | 113 return insets_; |
114 } | 114 } |
115 | 115 |
116 virtual gfx::Size GetMinimumSize() const OVERRIDE { | 116 virtual gfx::Size GetMinimumSize() const override { |
117 return painter_->GetMinimumSize(); | 117 return painter_->GetMinimumSize(); |
118 } | 118 } |
119 | 119 |
120 private: | 120 private: |
121 scoped_ptr<Painter> painter_; | 121 scoped_ptr<Painter> painter_; |
122 const gfx::Insets insets_; | 122 const gfx::Insets insets_; |
123 | 123 |
124 DISALLOW_COPY_AND_ASSIGN(BorderPainter); | 124 DISALLOW_COPY_AND_ASSIGN(BorderPainter); |
125 }; | 125 }; |
126 | 126 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 new SidedSolidBorder(top, left, bottom, right, color)); | 160 new SidedSolidBorder(top, left, bottom, right, color)); |
161 } | 161 } |
162 | 162 |
163 // static | 163 // static |
164 scoped_ptr<Border> Border::CreateBorderPainter(Painter* painter, | 164 scoped_ptr<Border> Border::CreateBorderPainter(Painter* painter, |
165 const gfx::Insets& insets) { | 165 const gfx::Insets& insets) { |
166 return scoped_ptr<Border>(new BorderPainter(painter, insets)); | 166 return scoped_ptr<Border>(new BorderPainter(painter, insets)); |
167 } | 167 } |
168 | 168 |
169 } // namespace views | 169 } // namespace views |
OLD | NEW |