| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_ |
| 6 #define CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_ | 6 #define CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_ |
| 7 | 7 |
| 8 #include "third_party/skia/include/core/SkColor.h" | 8 #include "third_party/skia/include/core/SkColor.h" |
| 9 #include "views/background.h" |
| 9 #include "views/border.h" | 10 #include "views/border.h" |
| 10 | 11 |
| 11 class SkBitmap; | 12 class SkBitmap; |
| 12 | 13 |
| 13 // Renders a round-rect border, with optional arrow (off by default), and a | 14 // Renders a round-rect border, with optional arrow (off by default), and a |
| 14 // custom dropshadow. This can be used to produce floating "bubble" objects. | 15 // custom dropshadow. This can be used to produce floating "bubble" objects. |
| 15 class BubbleBorder : public views::Border { | 16 class BubbleBorder : public views::Border { |
| 16 public: | 17 public: |
| 17 // Possible locations for the (optional) arrow. | 18 // Possible locations for the (optional) arrow. |
| 18 enum ArrowLocation { | 19 enum ArrowLocation { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 39 // Sets the location for the arrow. | 40 // Sets the location for the arrow. |
| 40 void set_arrow_location(ArrowLocation arrow_location) { | 41 void set_arrow_location(ArrowLocation arrow_location) { |
| 41 arrow_location_ = arrow_location; | 42 arrow_location_ = arrow_location; |
| 42 } | 43 } |
| 43 | 44 |
| 44 // Sets the background color for the arrow body. This is irrelevant if you do | 45 // Sets the background color for the arrow body. This is irrelevant if you do |
| 45 // not also set the arrow location to something other than NONE. | 46 // not also set the arrow location to something other than NONE. |
| 46 void set_background_color(SkColor background_color) { | 47 void set_background_color(SkColor background_color) { |
| 47 background_color_ = background_color; | 48 background_color_ = background_color; |
| 48 } | 49 } |
| 50 SkColor background_color() const { return background_color_; } |
| 49 | 51 |
| 50 // For borders with an arrow, gives the desired bounds (in screen coordinates) | 52 // For borders with an arrow, gives the desired bounds (in screen coordinates) |
| 51 // given the rect to point to and the size of the contained contents. This | 53 // given the rect to point to and the size of the contained contents. This |
| 52 // depends on the arrow location, so if you change that, you should call this | 54 // depends on the arrow location, so if you change that, you should call this |
| 53 // again to find out the new coordinates. | 55 // again to find out the new coordinates. |
| 54 // | 56 // |
| 55 // For borders without an arrow, gives the bounds with the content centered | 57 // For borders without an arrow, gives the bounds with the content centered |
| 56 // underneath the supplied rect. | 58 // underneath the supplied rect. |
| 57 gfx::Rect GetBounds(const gfx::Rect& position_relative_to, | 59 gfx::Rect GetBounds(const gfx::Rect& position_relative_to, |
| 58 const gfx::Size& contents_size) const; | 60 const gfx::Size& contents_size) const; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 static SkBitmap* bottom_arrow_; | 94 static SkBitmap* bottom_arrow_; |
| 93 | 95 |
| 94 static int arrow_x_offset_; | 96 static int arrow_x_offset_; |
| 95 | 97 |
| 96 ArrowLocation arrow_location_; | 98 ArrowLocation arrow_location_; |
| 97 SkColor background_color_; | 99 SkColor background_color_; |
| 98 | 100 |
| 99 DISALLOW_COPY_AND_ASSIGN(BubbleBorder); | 101 DISALLOW_COPY_AND_ASSIGN(BubbleBorder); |
| 100 }; | 102 }; |
| 101 | 103 |
| 104 // A Background that clips itself to the specified BubbleBorder and uses |
| 105 // the background color of the BubbleBorder. |
| 106 class BubbleBackground : public views::Background { |
| 107 public: |
| 108 BubbleBackground(BubbleBorder* border) : border_(border) {} |
| 109 |
| 110 // Background overrides. |
| 111 virtual void Paint(gfx::Canvas* canvas, views::View* view) const; |
| 112 |
| 113 private: |
| 114 BubbleBorder* border_; |
| 115 |
| 116 DISALLOW_COPY_AND_ASSIGN(BubbleBackground); |
| 117 }; |
| 118 |
| 102 #endif // #ifndef CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_ | 119 #endif // #ifndef CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_ |
| OLD | NEW |