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_GEOMETRIC_H_ |
| 6 #define UI_VIEWS_BUBBLE_BUBBLE_BORDER_GEOMETRIC_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 BubbleBorderGeometric : public BubbleBorder { |
| 17 public: |
| 18 explicit BubbleBorderGeometric(ArrowLocation arrow_location); |
| 19 virtual ~BubbleBorderGeometric(); |
| 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() { return corner_radius_; } |
| 37 |
| 38 void set_border_size(int border_size) { border_size_ = border_size; } |
| 39 int border_size() { return border_size_; } |
| 40 |
| 41 void set_arrow_height(int arrow_height) { arrow_height_ = arrow_height; } |
| 42 int arrow_height() { return arrow_height_; } |
| 43 |
| 44 void set_arrow_width(int arrow_width) { arrow_width_ = arrow_width; } |
| 45 int arrow_width() { return arrow_width_; } |
| 46 |
| 47 void SetShadow(gfx::ShadowValue shadow); |
| 48 |
| 49 // views::BubbleBorder overrides: |
| 50 int border_thickness() const OVERRIDE; |
| 51 |
| 52 protected: |
| 53 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 void GetInsetsForArrowLocation(gfx::Insets* insets, |
| 65 ArrowLocation arrow_loc) const OVERRIDE; |
| 66 |
| 67 // views::Border overrides: |
| 68 virtual void Paint(const View& view, |
| 69 gfx::Canvas* canvas) const OVERRIDE; |
| 70 |
| 71 int corner_radius_; |
| 72 int border_size_; |
| 73 int arrow_height_; |
| 74 int arrow_width_; |
| 75 SkColor background_color_; |
| 76 SkColor border_color_; |
| 77 |
| 78 // Offset in pixels by which the arrow is shifted relative the default middle |
| 79 // position. If the arrow is placed horizontally (at top or bottom), the |x_| |
| 80 // component of |offset_| specifies the offset, else, the |y_| component. |
| 81 gfx::Point offset_; |
| 82 |
| 83 gfx::ShadowValues shadows_; |
| 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(BubbleBorderGeometric); |
| 86 }; |
| 87 |
| 88 } // namespace views |
| 89 |
| 90 #endif // UI_VIEWS_BUBBLE_BUBBLE_BORDER_GEOMETRIC_H_ |
OLD | NEW |