| 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_BUBBLE_BUBBLE_BORDER_H_ | 5 #ifndef UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ |
| 6 #define UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ | 6 #define UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 enum ArrowPaintType { | 102 enum ArrowPaintType { |
| 103 // Fully render the arrow. | 103 // Fully render the arrow. |
| 104 PAINT_NORMAL, | 104 PAINT_NORMAL, |
| 105 // Leave space for the arrow, but do not paint it. | 105 // Leave space for the arrow, but do not paint it. |
| 106 PAINT_TRANSPARENT, | 106 PAINT_TRANSPARENT, |
| 107 // Neither paint nor leave space for the arrow. | 107 // Neither paint nor leave space for the arrow. |
| 108 PAINT_NONE, | 108 PAINT_NONE, |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 BubbleBorder(Arrow arrow, Shadow shadow, SkColor color); | 111 BubbleBorder(Arrow arrow, Shadow shadow, SkColor color); |
| 112 virtual ~BubbleBorder(); | 112 ~BubbleBorder() override; |
| 113 | 113 |
| 114 // Returns the radius of the corner of the border. | 114 // Returns the radius of the corner of the border. |
| 115 // TODO(xiyuan): Get rid of this since it's part of BorderImages now? | 115 // TODO(xiyuan): Get rid of this since it's part of BorderImages now? |
| 116 static int GetCornerRadius() { | 116 static int GetCornerRadius() { |
| 117 // We can't safely calculate a border radius by comparing the sizes of the | 117 // We can't safely calculate a border radius by comparing the sizes of the |
| 118 // side and corner images, because either may have been extended in various | 118 // side and corner images, because either may have been extended in various |
| 119 // directions in order to do more subtle dropshadow fading or other effects. | 119 // directions in order to do more subtle dropshadow fading or other effects. |
| 120 // So we hardcode the most accurate value. | 120 // So we hardcode the most accurate value. |
| 121 return 4; | 121 return 4; |
| 122 } | 122 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // Get the border exterior thickness, including stroke and shadow, in pixels. | 189 // Get the border exterior thickness, including stroke and shadow, in pixels. |
| 190 int GetBorderThickness() const; | 190 int GetBorderThickness() const; |
| 191 | 191 |
| 192 // Returns the corner radius of the current image set. | 192 // Returns the corner radius of the current image set. |
| 193 int GetBorderCornerRadius() const; | 193 int GetBorderCornerRadius() const; |
| 194 | 194 |
| 195 // Gets the arrow offset to use. | 195 // Gets the arrow offset to use. |
| 196 int GetArrowOffset(const gfx::Size& border_size) const; | 196 int GetArrowOffset(const gfx::Size& border_size) const; |
| 197 | 197 |
| 198 // Overridden from Border: | 198 // Overridden from Border: |
| 199 virtual void Paint(const View& view, gfx::Canvas* canvas) override; | 199 void Paint(const View& view, gfx::Canvas* canvas) override; |
| 200 virtual gfx::Insets GetInsets() const override; | 200 gfx::Insets GetInsets() const override; |
| 201 virtual gfx::Size GetMinimumSize() const override; | 201 gfx::Size GetMinimumSize() const override; |
| 202 | 202 |
| 203 private: | 203 private: |
| 204 FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, GetSizeForContentsSizeTest); | 204 FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, GetSizeForContentsSizeTest); |
| 205 FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, GetBoundsOriginTest); | 205 FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, GetBoundsOriginTest); |
| 206 | 206 |
| 207 // The border and arrow stroke size used in image assets, in pixels. | 207 // The border and arrow stroke size used in image assets, in pixels. |
| 208 static const int kStroke; | 208 static const int kStroke; |
| 209 | 209 |
| 210 gfx::Size GetSizeForContentsSize(const gfx::Size& contents_size) const; | 210 gfx::Size GetSizeForContentsSize(const gfx::Size& contents_size) const; |
| 211 gfx::ImageSkia* GetArrowImage() const; | 211 gfx::ImageSkia* GetArrowImage() const; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 226 DISALLOW_COPY_AND_ASSIGN(BubbleBorder); | 226 DISALLOW_COPY_AND_ASSIGN(BubbleBorder); |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 // A Background that clips itself to the specified BubbleBorder and uses | 229 // A Background that clips itself to the specified BubbleBorder and uses |
| 230 // the background color of the BubbleBorder. | 230 // the background color of the BubbleBorder. |
| 231 class VIEWS_EXPORT BubbleBackground : public Background { | 231 class VIEWS_EXPORT BubbleBackground : public Background { |
| 232 public: | 232 public: |
| 233 explicit BubbleBackground(BubbleBorder* border) : border_(border) {} | 233 explicit BubbleBackground(BubbleBorder* border) : border_(border) {} |
| 234 | 234 |
| 235 // Overridden from Background: | 235 // Overridden from Background: |
| 236 virtual void Paint(gfx::Canvas* canvas, View* view) const override; | 236 void Paint(gfx::Canvas* canvas, View* view) const override; |
| 237 | 237 |
| 238 private: | 238 private: |
| 239 BubbleBorder* border_; | 239 BubbleBorder* border_; |
| 240 | 240 |
| 241 DISALLOW_COPY_AND_ASSIGN(BubbleBackground); | 241 DISALLOW_COPY_AND_ASSIGN(BubbleBackground); |
| 242 }; | 242 }; |
| 243 | 243 |
| 244 } // namespace views | 244 } // namespace views |
| 245 | 245 |
| 246 #endif // UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ | 246 #endif // UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ |
| OLD | NEW |