Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: ui/views/bubble/bubble_border.h

Issue 454173002: Fixed BubbleBorder sizing problems & added unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor nit fixes. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/bubble/bubble_border.cc » ('j') | ui/views/bubble/bubble_border_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/bubble/bubble_border.h
diff --git a/ui/views/bubble/bubble_border.h b/ui/views/bubble/bubble_border.h
index 15f0f85f60ddcae2a44a1f373ecc4dbb1320866f..8ce546a64da9a358962fc9d5ed94d21fd18732f1 100644
--- a/ui/views/bubble/bubble_border.h
+++ b/ui/views/bubble/bubble_border.h
@@ -7,19 +7,47 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/gfx/image/image_skia.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
namespace gfx {
-class ImageSkia;
class Rect;
}
namespace views {
+class Painter;
namespace internal {
-struct BorderImages;
-}
+
+// A helper that combines each border image-set painter with arrows and metrics.
+struct BorderImages {
+ BorderImages(const int border_image_ids[],
+ const int arrow_image_ids[],
+ int border_interior_thickness,
+ int arrow_interior_thickness,
+ int corner_radius);
+ virtual ~BorderImages();
+
+ scoped_ptr<Painter> border_painter;
+ gfx::ImageSkia left_arrow;
+ gfx::ImageSkia top_arrow;
+ gfx::ImageSkia right_arrow;
+ gfx::ImageSkia bottom_arrow;
+
+ // The thickness of border and arrow images and their interior areas.
+ // Thickness is the width of left/right and the height of top/bottom images.
+ // The interior is measured without including stroke or shadow pixels.
+ int border_thickness;
+ int border_interior_thickness;
+ int arrow_thickness;
+ int arrow_interior_thickness;
+ // The corner radius of the bubble's rounded-rect interior area.
+ int corner_radius;
+};
+
+} // namespace internal
// Renders a border, with optional arrow, and a custom dropshadow.
// This can be used to produce floating "bubble" objects with rounded corners.
@@ -173,11 +201,19 @@ class VIEWS_EXPORT BubbleBorder : public Border {
virtual gfx::Size GetMinimumSize() const OVERRIDE;
private:
+ FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, GetSizeForContentsSizeTest);
+ FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, GetBoundsOriginTest);
+
+ // The border and arrow stroke size used in image assets, in pixels.
+ static const int kStroke;
+
gfx::Size GetSizeForContentsSize(const gfx::Size& contents_size) const;
gfx::ImageSkia* GetArrowImage() const;
gfx::Rect GetArrowRect(const gfx::Rect& bounds) const;
void DrawArrow(gfx::Canvas* canvas, const gfx::Rect& arrow_bounds) const;
+ internal::BorderImages* GetImagesForTest() const;
+
Arrow arrow_;
int arrow_offset_;
ArrowPaintType arrow_paint_type_;
« no previous file with comments | « no previous file | ui/views/bubble/bubble_border.cc » ('j') | ui/views/bubble/bubble_border_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698