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/painter.h" | 5 #include "ui/views/painter.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 "third_party/skia/include/effects/SkGradientShader.h" | 9 #include "third_party/skia/include/effects/SkGradientShader.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace { | 23 namespace { |
24 | 24 |
25 // DashedFocusPainter ---------------------------------------------------------- | 25 // DashedFocusPainter ---------------------------------------------------------- |
26 | 26 |
27 class DashedFocusPainter : public Painter { | 27 class DashedFocusPainter : public Painter { |
28 public: | 28 public: |
29 explicit DashedFocusPainter(const gfx::Insets& insets); | 29 explicit DashedFocusPainter(const gfx::Insets& insets); |
30 virtual ~DashedFocusPainter(); | 30 virtual ~DashedFocusPainter(); |
31 | 31 |
32 // Painter: | 32 // Painter: |
33 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 33 virtual gfx::Size GetMinimumSize() const override; |
34 virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE; | 34 virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) override; |
35 | 35 |
36 private: | 36 private: |
37 const gfx::Insets insets_; | 37 const gfx::Insets insets_; |
38 | 38 |
39 DISALLOW_COPY_AND_ASSIGN(DashedFocusPainter); | 39 DISALLOW_COPY_AND_ASSIGN(DashedFocusPainter); |
40 }; | 40 }; |
41 | 41 |
42 DashedFocusPainter::DashedFocusPainter(const gfx::Insets& insets) | 42 DashedFocusPainter::DashedFocusPainter(const gfx::Insets& insets) |
43 : insets_(insets) { | 43 : insets_(insets) { |
44 } | 44 } |
(...skipping 12 matching lines...) Expand all Loading... |
57 } | 57 } |
58 | 58 |
59 // SolidFocusPainter ----------------------------------------------------------- | 59 // SolidFocusPainter ----------------------------------------------------------- |
60 | 60 |
61 class SolidFocusPainter : public Painter { | 61 class SolidFocusPainter : public Painter { |
62 public: | 62 public: |
63 SolidFocusPainter(SkColor color, const gfx::Insets& insets); | 63 SolidFocusPainter(SkColor color, const gfx::Insets& insets); |
64 virtual ~SolidFocusPainter(); | 64 virtual ~SolidFocusPainter(); |
65 | 65 |
66 // Painter: | 66 // Painter: |
67 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 67 virtual gfx::Size GetMinimumSize() const override; |
68 virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE; | 68 virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) override; |
69 | 69 |
70 private: | 70 private: |
71 const SkColor color_; | 71 const SkColor color_; |
72 const gfx::Insets insets_; | 72 const gfx::Insets insets_; |
73 | 73 |
74 DISALLOW_COPY_AND_ASSIGN(SolidFocusPainter); | 74 DISALLOW_COPY_AND_ASSIGN(SolidFocusPainter); |
75 }; | 75 }; |
76 | 76 |
77 SolidFocusPainter::SolidFocusPainter(SkColor color, | 77 SolidFocusPainter::SolidFocusPainter(SkColor color, |
78 const gfx::Insets& insets) | 78 const gfx::Insets& insets) |
(...skipping 18 matching lines...) Expand all Loading... |
97 | 97 |
98 class GradientPainter : public Painter { | 98 class GradientPainter : public Painter { |
99 public: | 99 public: |
100 GradientPainter(bool horizontal, | 100 GradientPainter(bool horizontal, |
101 SkColor* colors, | 101 SkColor* colors, |
102 SkScalar* pos, | 102 SkScalar* pos, |
103 size_t count); | 103 size_t count); |
104 virtual ~GradientPainter(); | 104 virtual ~GradientPainter(); |
105 | 105 |
106 // Painter: | 106 // Painter: |
107 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 107 virtual gfx::Size GetMinimumSize() const override; |
108 virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE; | 108 virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) override; |
109 | 109 |
110 private: | 110 private: |
111 // If |horizontal_| is true then the gradient is painted horizontally. | 111 // If |horizontal_| is true then the gradient is painted horizontally. |
112 bool horizontal_; | 112 bool horizontal_; |
113 // The gradient colors. | 113 // The gradient colors. |
114 scoped_ptr<SkColor[]> colors_; | 114 scoped_ptr<SkColor[]> colors_; |
115 // The relative positions of the corresponding gradient colors. | 115 // The relative positions of the corresponding gradient colors. |
116 scoped_ptr<SkScalar[]> pos_; | 116 scoped_ptr<SkScalar[]> pos_; |
117 // The number of elements in |colors_| and |pos_|. | 117 // The number of elements in |colors_| and |pos_|. |
118 size_t count_; | 118 size_t count_; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // Constructs an ImagePainter with the specified image resource ids. | 168 // Constructs an ImagePainter with the specified image resource ids. |
169 // See CreateImageGridPainter()'s comment regarding image ID count and order. | 169 // See CreateImageGridPainter()'s comment regarding image ID count and order. |
170 explicit ImagePainter(const int image_ids[]); | 170 explicit ImagePainter(const int image_ids[]); |
171 | 171 |
172 // Constructs an ImagePainter with the specified image and insets. | 172 // Constructs an ImagePainter with the specified image and insets. |
173 ImagePainter(const gfx::ImageSkia& image, const gfx::Insets& insets); | 173 ImagePainter(const gfx::ImageSkia& image, const gfx::Insets& insets); |
174 | 174 |
175 virtual ~ImagePainter(); | 175 virtual ~ImagePainter(); |
176 | 176 |
177 // Painter: | 177 // Painter: |
178 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 178 virtual gfx::Size GetMinimumSize() const override; |
179 virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE; | 179 virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) override; |
180 | 180 |
181 private: | 181 private: |
182 scoped_ptr<gfx::NineImagePainter> nine_painter_; | 182 scoped_ptr<gfx::NineImagePainter> nine_painter_; |
183 | 183 |
184 DISALLOW_COPY_AND_ASSIGN(ImagePainter); | 184 DISALLOW_COPY_AND_ASSIGN(ImagePainter); |
185 }; | 185 }; |
186 | 186 |
187 ImagePainter::ImagePainter(const int image_ids[]) | 187 ImagePainter::ImagePainter(const int image_ids[]) |
188 : nine_painter_(ui::CreateNineImagePainter(image_ids)) { | 188 : nine_painter_(ui::CreateNineImagePainter(image_ids)) { |
189 } | 189 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 canvas->DrawImageInt(*images_[LEFT], 0, 0); | 314 canvas->DrawImageInt(*images_[LEFT], 0, 0); |
315 canvas->DrawImageInt(*images_[RIGHT], size.width() - images_[RIGHT]->width(), | 315 canvas->DrawImageInt(*images_[RIGHT], size.width() - images_[RIGHT]->width(), |
316 0); | 316 0); |
317 canvas->TileImageInt( | 317 canvas->TileImageInt( |
318 *images_[CENTER], images_[LEFT]->width(), 0, | 318 *images_[CENTER], images_[LEFT]->width(), 0, |
319 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), | 319 size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), |
320 images_[LEFT]->height()); | 320 images_[LEFT]->height()); |
321 } | 321 } |
322 | 322 |
323 } // namespace views | 323 } // namespace views |
OLD | NEW |