| 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 #ifndef UI_VIEWS_PAINTER_H_ | 5 #ifndef UI_VIEWS_PAINTER_H_ |
| 6 #define UI_VIEWS_PAINTER_H_ | 6 #define UI_VIEWS_PAINTER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 const gfx::Rect& rect); | 43 const gfx::Rect& rect); |
| 44 | 44 |
| 45 // Convenience that paints |focus_painter| only if |view| HasFocus() and | 45 // Convenience that paints |focus_painter| only if |view| HasFocus() and |
| 46 // |focus_painter| is non-NULL. | 46 // |focus_painter| is non-NULL. |
| 47 static void PaintFocusPainter(View* view, | 47 static void PaintFocusPainter(View* view, |
| 48 gfx::Canvas* canvas, | 48 gfx::Canvas* canvas, |
| 49 Painter* focus_painter); | 49 Painter* focus_painter); |
| 50 | 50 |
| 51 // Creates a painter that draws a RoundRect with a solid color and given | 51 // Creates a painter that draws a RoundRect with a solid color and given |
| 52 // corner radius. | 52 // corner radius. |
| 53 static Painter* CreateSolidRoundRectPainter(SkColor color, float radius); | 53 static std::unique_ptr<Painter> CreateSolidRoundRectPainter(SkColor color, |
| 54 float radius); |
| 54 | 55 |
| 55 // Creates a painter that draws a RoundRect with a solid color and a given | 56 // Creates a painter that draws a RoundRect with a solid color and a given |
| 56 // corner radius, and also adds a 1px border (inset) in the given color. | 57 // corner radius, and also adds a 1px border (inset) in the given color. |
| 57 static Painter* CreateRoundRectWith1PxBorderPainter(SkColor bg_color, | 58 static std::unique_ptr<Painter> CreateRoundRectWith1PxBorderPainter( |
| 58 SkColor stroke_color, | 59 SkColor bg_color, |
| 59 float radius); | 60 SkColor stroke_color, |
| 61 float radius); |
| 60 | 62 |
| 61 // Creates a painter that draws a gradient between the two colors. | 63 // TODO(estade): remove. The last client (table_header.cc) is going away soon. |
| 62 static Painter* CreateHorizontalGradient(SkColor c1, SkColor c2); | 64 static std::unique_ptr<Painter> CreateVerticalGradient(SkColor c1, |
| 63 static Painter* CreateVerticalGradient(SkColor c1, SkColor c2); | 65 SkColor c2); |
| 64 | |
| 65 // Creates a painter that draws a multi-color gradient. |colors| contains the | |
| 66 // gradient colors and |pos| the relative positions of the colors. The first | |
| 67 // element in |pos| must be 0.0 and the last element 1.0. |count| contains | |
| 68 // the number of elements in |colors| and |pos|. | |
| 69 static Painter* CreateVerticalMultiColorGradient(SkColor* colors, | |
| 70 SkScalar* pos, | |
| 71 size_t count); | |
| 72 | 66 |
| 73 // Creates a painter that divides |image| into nine regions. The four corners | 67 // Creates a painter that divides |image| into nine regions. The four corners |
| 74 // are rendered at the size specified in insets (eg. the upper-left corner is | 68 // are rendered at the size specified in insets (eg. the upper-left corner is |
| 75 // rendered at 0 x 0 with a size of insets.left() x insets.top()). The center | 69 // rendered at 0 x 0 with a size of insets.left() x insets.top()). The center |
| 76 // and edge images are stretched to fill the painted area. | 70 // and edge images are stretched to fill the painted area. |
| 77 static Painter* CreateImagePainter(const gfx::ImageSkia& image, | 71 static std::unique_ptr<Painter> CreateImagePainter( |
| 78 const gfx::Insets& insets); | 72 const gfx::ImageSkia& image, |
| 73 const gfx::Insets& insets); |
| 79 | 74 |
| 80 // Creates a painter that paints images in a scalable grid. The images must | 75 // Creates a painter that paints images in a scalable grid. The images must |
| 81 // share widths by column and heights by row. The corners are painted at full | 76 // share widths by column and heights by row. The corners are painted at full |
| 82 // size, while center and edge images are stretched to fill the painted area. | 77 // size, while center and edge images are stretched to fill the painted area. |
| 83 // The center image may be zero (to be skipped). This ordering must be used: | 78 // The center image may be zero (to be skipped). This ordering must be used: |
| 84 // Top-Left/Top/Top-Right/Left/[Center]/Right/Bottom-Left/Bottom/Bottom-Right. | 79 // Top-Left/Top/Top-Right/Left/[Center]/Right/Bottom-Left/Bottom/Bottom-Right. |
| 85 static Painter* CreateImageGridPainter(const int image_ids[]); | 80 static std::unique_ptr<Painter> CreateImageGridPainter(const int image_ids[]); |
| 86 | 81 |
| 87 // Factory methods for creating painters intended for rendering focus. | 82 // Factory methods for creating painters intended for rendering focus. |
| 88 static std::unique_ptr<Painter> CreateDashedFocusPainter(); | 83 static std::unique_ptr<Painter> CreateDashedFocusPainter(); |
| 89 static std::unique_ptr<Painter> CreateDashedFocusPainterWithInsets( | 84 static std::unique_ptr<Painter> CreateDashedFocusPainterWithInsets( |
| 90 const gfx::Insets& insets); | 85 const gfx::Insets& insets); |
| 91 // Deprecated: used the InsetsF version below. | 86 // Deprecated: used the InsetsF version below. |
| 92 static std::unique_ptr<Painter> CreateSolidFocusPainter( | 87 static std::unique_ptr<Painter> CreateSolidFocusPainter( |
| 93 SkColor color, | 88 SkColor color, |
| 94 const gfx::Insets& insets); | 89 const gfx::Insets& insets); |
| 95 static std::unique_ptr<Painter> CreateSolidFocusPainter( | 90 static std::unique_ptr<Painter> CreateSolidFocusPainter( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 128 |
| 134 // NOTE: the images are owned by ResourceBundle. Don't free them. | 129 // NOTE: the images are owned by ResourceBundle. Don't free them. |
| 135 const gfx::ImageSkia* images_[3]; | 130 const gfx::ImageSkia* images_[3]; |
| 136 | 131 |
| 137 DISALLOW_COPY_AND_ASSIGN(HorizontalPainter); | 132 DISALLOW_COPY_AND_ASSIGN(HorizontalPainter); |
| 138 }; | 133 }; |
| 139 | 134 |
| 140 } // namespace views | 135 } // namespace views |
| 141 | 136 |
| 142 #endif // UI_VIEWS_PAINTER_H_ | 137 #endif // UI_VIEWS_PAINTER_H_ |
| OLD | NEW |