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" |
(...skipping 26 matching lines...) Expand all Loading... |
37 int right, | 37 int right, |
38 SkColor color) | 38 SkColor color) |
39 : color_(color), | 39 : color_(color), |
40 insets_(top, left, bottom, right) { | 40 insets_(top, left, bottom, right) { |
41 } | 41 } |
42 | 42 |
43 void SidedSolidBorder::Paint(const View& view, gfx::Canvas* canvas) { | 43 void SidedSolidBorder::Paint(const View& view, gfx::Canvas* canvas) { |
44 // Top border. | 44 // Top border. |
45 canvas->FillRect(gfx::Rect(0, 0, view.width(), insets_.top()), color_); | 45 canvas->FillRect(gfx::Rect(0, 0, view.width(), insets_.top()), color_); |
46 // Left border. | 46 // Left border. |
47 canvas->FillRect(gfx::Rect(0, 0, insets_.left(), view.height()), color_); | 47 canvas->FillRect(gfx::Rect(0, insets_.top(), insets_.left(), |
| 48 view.height() - insets_.height()), color_); |
48 // Bottom border. | 49 // Bottom border. |
49 canvas->FillRect(gfx::Rect(0, view.height() - insets_.bottom(), view.width(), | 50 canvas->FillRect(gfx::Rect(0, view.height() - insets_.bottom(), view.width(), |
50 insets_.bottom()), color_); | 51 insets_.bottom()), color_); |
51 // Right border. | 52 // Right border. |
52 canvas->FillRect(gfx::Rect(view.width() - insets_.right(), 0, insets_.right(), | 53 canvas->FillRect(gfx::Rect(view.width() - insets_.right(), insets_.top(), |
53 view.height()), color_); | 54 insets_.right(), view.height() - insets_.height()), |
| 55 color_); |
54 } | 56 } |
55 | 57 |
56 gfx::Insets SidedSolidBorder::GetInsets() const { | 58 gfx::Insets SidedSolidBorder::GetInsets() const { |
57 return insets_; | 59 return insets_; |
58 } | 60 } |
59 | 61 |
60 gfx::Size SidedSolidBorder::GetMinimumSize() const { | 62 gfx::Size SidedSolidBorder::GetMinimumSize() const { |
61 return gfx::Size(insets_.width(), insets_.height()); | 63 return gfx::Size(insets_.width(), insets_.height()); |
62 } | 64 } |
63 | 65 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 return make_scoped_ptr(new SidedSolidBorder(top, left, bottom, right, color)); | 155 return make_scoped_ptr(new SidedSolidBorder(top, left, bottom, right, color)); |
154 } | 156 } |
155 | 157 |
156 // static | 158 // static |
157 scoped_ptr<Border> Border::CreateBorderPainter(Painter* painter, | 159 scoped_ptr<Border> Border::CreateBorderPainter(Painter* painter, |
158 const gfx::Insets& insets) { | 160 const gfx::Insets& insets) { |
159 return make_scoped_ptr(new BorderPainter(painter, insets)); | 161 return make_scoped_ptr(new BorderPainter(painter, insets)); |
160 } | 162 } |
161 | 163 |
162 } // namespace views | 164 } // namespace views |
OLD | NEW |