| 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_BACKGROUND_H_ | 5 #ifndef UI_VIEWS_BACKGROUND_H_ |
| 6 #define UI_VIEWS_BACKGROUND_H_ | 6 #define UI_VIEWS_BACKGROUND_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // Creates a background that fills the canvas in the specified color. | 50 // Creates a background that fills the canvas in the specified color. |
| 51 static Background* CreateSolidBackground(int r, int g, int b) { | 51 static Background* CreateSolidBackground(int r, int g, int b) { |
| 52 return CreateSolidBackground(SkColorSetRGB(r, g, b)); | 52 return CreateSolidBackground(SkColorSetRGB(r, g, b)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Creates a background that fills the canvas in the specified color. | 55 // Creates a background that fills the canvas in the specified color. |
| 56 static Background* CreateSolidBackground(int r, int g, int b, int a) { | 56 static Background* CreateSolidBackground(int r, int g, int b, int a) { |
| 57 return CreateSolidBackground(SkColorSetARGB(a, r, g, b)); | 57 return CreateSolidBackground(SkColorSetARGB(a, r, g, b)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Creates a background that contains a vertical gradient that varies | |
| 61 // from |color1| to |color2| | |
| 62 static Background* CreateVerticalGradientBackground(SkColor color1, | |
| 63 SkColor color2); | |
| 64 | |
| 65 // Creates Chrome's standard panel background | 60 // Creates Chrome's standard panel background |
| 66 static Background* CreateStandardPanelBackground(); | 61 static Background* CreateStandardPanelBackground(); |
| 67 | 62 |
| 68 // Creates a Background from the specified Painter. | 63 // Creates a Background from the specified Painter. |
| 69 static Background* CreateBackgroundPainter(std::unique_ptr<Painter> painter); | 64 static Background* CreateBackgroundPainter(std::unique_ptr<Painter> painter); |
| 70 | 65 |
| 71 // Render the background for the provided view | 66 // Render the background for the provided view |
| 72 virtual void Paint(gfx::Canvas* canvas, View* view) const = 0; | 67 virtual void Paint(gfx::Canvas* canvas, View* view) const = 0; |
| 73 | 68 |
| 74 // Set a solid, opaque color to be used when drawing backgrounds of native | 69 // Set a solid, opaque color to be used when drawing backgrounds of native |
| 75 // controls. Unfortunately alpha=0 is not an option. | 70 // controls. Unfortunately alpha=0 is not an option. |
| 76 void SetNativeControlColor(SkColor color); | 71 void SetNativeControlColor(SkColor color); |
| 77 | 72 |
| 78 // Returns the "background color". This is equivalent to the color set in | 73 // Returns the "background color". This is equivalent to the color set in |
| 79 // SetNativeControlColor(). For solid backgrounds, this is the color; for | 74 // SetNativeControlColor(). For solid backgrounds, this is the color; for |
| 80 // gradient backgrounds, it's the midpoint of the gradient; for painter | 75 // gradient backgrounds, it's the midpoint of the gradient; for painter |
| 81 // backgrounds, this is not useful (returns a default color). | 76 // backgrounds, this is not useful (returns a default color). |
| 82 SkColor get_color() const { return color_; } | 77 SkColor get_color() const { return color_; } |
| 83 | 78 |
| 84 private: | 79 private: |
| 85 SkColor color_; | 80 SkColor color_; |
| 86 | 81 |
| 87 DISALLOW_COPY_AND_ASSIGN(Background); | 82 DISALLOW_COPY_AND_ASSIGN(Background); |
| 88 }; | 83 }; |
| 89 | 84 |
| 90 } // namespace views | 85 } // namespace views |
| 91 | 86 |
| 92 #endif // UI_VIEWS_BACKGROUND_H_ | 87 #endif // UI_VIEWS_BACKGROUND_H_ |
| OLD | NEW |