| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_VIEWS_BUBBLE_BUBBLE_BORDER_2_H_ | |
| 6 #define UI_VIEWS_BUBBLE_BUBBLE_BORDER_2_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "ui/gfx/shadow_value.h" | |
| 11 #include "ui/views/bubble/bubble_border.h" | |
| 12 | |
| 13 namespace views { | |
| 14 | |
| 15 // A BubbleBorder rendered with Skia drawing commands instead of images. | |
| 16 class VIEWS_EXPORT BubbleBorder2 : public BubbleBorder { | |
| 17 public: | |
| 18 explicit BubbleBorder2(ArrowLocation arrow_location); | |
| 19 virtual ~BubbleBorder2(); | |
| 20 | |
| 21 // Given the |bubble_rect| that this border encloses, and the bounds of the | |
| 22 // anchor view |anchor_view_rect|, compute the right offset to place the | |
| 23 // arrow at shifting the |bubble_rect| to fit inside the display area if | |
| 24 // needed. Returns the shifted |bubble_rect|. | |
| 25 gfx::Rect ComputeOffsetAndUpdateBubbleRect(gfx::Rect bubble_rect, | |
| 26 const gfx::Rect& anchor_view_rect); | |
| 27 | |
| 28 // Returns the path in |mask| that would be created if this border were to be | |
| 29 // applied to the rect specified by |bounds|. | |
| 30 void GetMask(const gfx::Rect& bounds, gfx::Path* mask) const; | |
| 31 | |
| 32 void set_offset(const gfx::Point& offset) { offset_ = offset; } | |
| 33 const gfx::Point& offset() const { return offset_; } | |
| 34 | |
| 35 void set_corner_radius(int corner_radius) { corner_radius_ = corner_radius; } | |
| 36 int corner_radius() const { return corner_radius_; } | |
| 37 | |
| 38 void set_border_size(int border_size) { border_size_ = border_size; } | |
| 39 int border_size() const { return border_size_; } | |
| 40 | |
| 41 void set_arrow_height(int arrow_height) { arrow_height_ = arrow_height; } | |
| 42 int arrow_height() const { return arrow_height_; } | |
| 43 | |
| 44 void set_arrow_width(int arrow_width) { arrow_width_ = arrow_width; } | |
| 45 int arrow_width() const { return arrow_width_; } | |
| 46 | |
| 47 void SetShadow(gfx::ShadowValue shadow); | |
| 48 | |
| 49 // views::BubbleBorder overrides: | |
| 50 virtual int GetBorderThickness() const OVERRIDE; | |
| 51 | |
| 52 protected: | |
| 53 virtual void PaintBackground(gfx::Canvas* canvas, | |
| 54 const gfx::Rect& bounds) const; | |
| 55 | |
| 56 private: | |
| 57 // Gets arrow offset based on arrow location and |offset_|. | |
| 58 int GetArrowOffset() const; | |
| 59 | |
| 60 // views::BubbleBorder overrides: | |
| 61 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE; | |
| 62 virtual gfx::Rect GetBounds(const gfx::Rect& position_relative_to, | |
| 63 const gfx::Size& contents_size) const OVERRIDE; | |
| 64 virtual void GetInsetsForArrowLocation( | |
| 65 gfx::Insets* insets, | |
| 66 ArrowLocation arrow_loc) const OVERRIDE; | |
| 67 | |
| 68 // views::Border overrides: | |
| 69 virtual void Paint(const View& view, | |
| 70 gfx::Canvas* canvas) const OVERRIDE; | |
| 71 | |
| 72 int corner_radius_; | |
| 73 int border_size_; | |
| 74 int arrow_height_; | |
| 75 int arrow_width_; | |
| 76 SkColor background_color_; | |
| 77 SkColor border_color_; | |
| 78 | |
| 79 // Offset in pixels by which the arrow is shifted relative the default middle | |
| 80 // position. If the arrow is placed horizontally (at top or bottom), the |x_| | |
| 81 // component of |offset_| specifies the offset, else, the |y_| component. | |
| 82 gfx::Point offset_; | |
| 83 | |
| 84 gfx::ShadowValues shadows_; | |
| 85 | |
| 86 DISALLOW_COPY_AND_ASSIGN(BubbleBorder2); | |
| 87 }; | |
| 88 | |
| 89 } // namespace views | |
| 90 | |
| 91 #endif // UI_VIEWS_BUBBLE_BUBBLE_BORDER_2_H_ | |
| OLD | NEW |