Index: ui/views/bubble/bubble_border_geometric.h |
diff --git a/ui/views/bubble/bubble_border_geometric.h b/ui/views/bubble/bubble_border_geometric.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..74151f4113027858319b2e414fe10db5ee995645 |
--- /dev/null |
+++ b/ui/views/bubble/bubble_border_geometric.h |
@@ -0,0 +1,90 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_VIEWS_BUBBLE_BUBBLE_BORDER_GEOMETRIC_H_ |
+#define UI_VIEWS_BUBBLE_BUBBLE_BORDER_GEOMETRIC_H_ |
+ |
+#include "base/basictypes.h" |
+#include "base/compiler_specific.h" |
+#include "ui/gfx/shadow_value.h" |
+#include "ui/views/bubble/bubble_border.h" |
+ |
+namespace views { |
+ |
+// A BubbleBorder rendered with Skia drawing commands instead of images. |
+class VIEWS_EXPORT BubbleBorderGeometric : public BubbleBorder { |
+ public: |
+ explicit BubbleBorderGeometric(ArrowLocation arrow_location); |
+ virtual ~BubbleBorderGeometric(); |
+ |
+ // Given the |bubble_rect| that this border encloses, and the bounds of the |
+ // anchor view |anchor_view_rect|, compute the right offset to place the |
+ // arrow at shifting the |bubble_rect| to fit inside the display area if |
+ // needed. Returns the shifted |bubble_rect|. |
+ gfx::Rect ComputeOffsetAndUpdateBubbleRect(gfx::Rect bubble_rect, |
+ const gfx::Rect& anchor_view_rect); |
+ |
+ // Returns the path in |mask| that would be created if this border were to be |
+ // applied to the rect specified by |bounds|. |
+ void GetMask(const gfx::Rect& bounds, gfx::Path* mask) const; |
+ |
+ void set_offset(const gfx::Point& offset) { offset_ = offset; } |
+ const gfx::Point& offset() const { return offset_; } |
+ |
+ void set_corner_radius(int corner_radius) { corner_radius_ = corner_radius; } |
+ int corner_radius() { return corner_radius_; } |
+ |
+ void set_border_size(int border_size) { border_size_ = border_size; } |
+ int border_size() { return border_size_; } |
+ |
+ void set_arrow_height(int arrow_height) { arrow_height_ = arrow_height; } |
+ int arrow_height() { return arrow_height_; } |
+ |
+ void set_arrow_width(int arrow_width) { arrow_width_ = arrow_width; } |
+ int arrow_width() { return arrow_width_; } |
+ |
+ void SetShadow(gfx::ShadowValue shadow); |
+ |
+ // views::BubbleBorder overrides: |
+ int border_thickness() const OVERRIDE; |
+ |
+ protected: |
+ void PaintBackground(gfx::Canvas* canvas, |
+ const gfx::Rect& bounds) const; |
+ |
+ private: |
+ // Gets arrow offset based on arrow location and |offset_|. |
+ int GetArrowOffset() const; |
+ |
+ // views::BubbleBorder overrides: |
+ virtual void GetInsets(gfx::Insets* insets) const OVERRIDE; |
+ virtual gfx::Rect GetBounds(const gfx::Rect& position_relative_to, |
+ const gfx::Size& contents_size) const OVERRIDE; |
+ void GetInsetsForArrowLocation(gfx::Insets* insets, |
+ ArrowLocation arrow_loc) const OVERRIDE; |
+ |
+ // views::Border overrides: |
+ virtual void Paint(const View& view, |
+ gfx::Canvas* canvas) const OVERRIDE; |
+ |
+ int corner_radius_; |
+ int border_size_; |
+ int arrow_height_; |
+ int arrow_width_; |
+ SkColor background_color_; |
+ SkColor border_color_; |
+ |
+ // Offset in pixels by which the arrow is shifted relative the default middle |
+ // position. If the arrow is placed horizontally (at top or bottom), the |x_| |
+ // component of |offset_| specifies the offset, else, the |y_| component. |
+ gfx::Point offset_; |
+ |
+ gfx::ShadowValues shadows_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BubbleBorderGeometric); |
+}; |
+ |
+} // namespace views |
+ |
+#endif // UI_VIEWS_BUBBLE_BUBBLE_BORDER_GEOMETRIC_H_ |