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

Side by Side 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: Combined test fixtures and rewrote tests to be more easily maintained. 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 unified diff | Download patch
OLDNEW
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 "ui/views/background.h" 10 #include "ui/views/background.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 void set_arrow_offset(int offset) { arrow_offset_ = offset; } 151 void set_arrow_offset(int offset) { arrow_offset_ = offset; }
152 152
153 // Sets the way the arrow is actually painted. Default is PAINT_NORMAL. 153 // Sets the way the arrow is actually painted. Default is PAINT_NORMAL.
154 void set_paint_arrow(ArrowPaintType value) { arrow_paint_type_ = value; } 154 void set_paint_arrow(ArrowPaintType value) { arrow_paint_type_ = value; }
155 155
156 // Get the desired widget bounds (in screen coordinates) given the anchor rect 156 // Get the desired widget bounds (in screen coordinates) given the anchor rect
157 // and bubble content size; calculated from shadow and arrow image dimensions. 157 // and bubble content size; calculated from shadow and arrow image dimensions.
158 virtual gfx::Rect GetBounds(const gfx::Rect& anchor_rect, 158 virtual gfx::Rect GetBounds(const gfx::Rect& anchor_rect,
159 const gfx::Size& contents_size) const; 159 const gfx::Size& contents_size) const;
160 160
161 // Get the arrow thickness.
msw 2014/08/19 21:35:39 Expanding unit tests shouldn't expand BubbleBorder
bruthig 2014/08/20 15:01:28 The reason I didn't add a BorderImages* GetImagesF
msw 2014/08/20 20:41:02 Yeah, move the internal::BorderImages decl to this
bruthig 2014/08/22 19:45:04 Done.
162 int GetArrowThickness() const;
163
164 // Get the top arrow width.
165 int GetTopArrowWidth() const;
166
167 // Get the border thickness.
168 int GetBorderThickness() const;
169
170 // Get the border interior thickness.
171 int GetBorderInteriorThickness() const;
172
161 // Get the border exterior thickness, including stroke and shadow, in pixels. 173 // Get the border exterior thickness, including stroke and shadow, in pixels.
162 int GetBorderThickness() const; 174 int GetBorderExteriorThickness() const;
msw 2014/08/19 21:35:39 nit: revert this name change when you remove the a
bruthig 2014/08/22 19:45:04 Done.
163 175
164 // Returns the corner radius of the current image set. 176 // Returns the corner radius of the current image set.
165 int GetBorderCornerRadius() const; 177 int GetBorderCornerRadius() const;
166 178
167 // Gets the arrow offset to use. 179 // Gets the arrow offset to use.
168 int GetArrowOffset(const gfx::Size& border_size) const; 180 int GetArrowOffset(const gfx::Size& border_size) const;
169 181
182 // Gets the arrow size to use.
183 int GetArrowSize() const;
184
170 // Overridden from Border: 185 // Overridden from Border:
171 virtual void Paint(const View& view, gfx::Canvas* canvas) OVERRIDE; 186 virtual void Paint(const View& view, gfx::Canvas* canvas) OVERRIDE;
172 virtual gfx::Insets GetInsets() const OVERRIDE; 187 virtual gfx::Insets GetInsets() const OVERRIDE;
173 virtual gfx::Size GetMinimumSize() const OVERRIDE; 188 virtual gfx::Size GetMinimumSize() const OVERRIDE;
174 189
175 private: 190 private:
191 friend class BubbleBorderTest;
192
176 gfx::Size GetSizeForContentsSize(const gfx::Size& contents_size) const; 193 gfx::Size GetSizeForContentsSize(const gfx::Size& contents_size) const;
177 gfx::ImageSkia* GetArrowImage() const; 194 gfx::ImageSkia* GetArrowImage() const;
178 gfx::Rect GetArrowRect(const gfx::Rect& bounds) const; 195 gfx::Rect GetArrowRect(const gfx::Rect& bounds) const;
179 void DrawArrow(gfx::Canvas* canvas, const gfx::Rect& arrow_bounds) const; 196 void DrawArrow(gfx::Canvas* canvas, const gfx::Rect& arrow_bounds) const;
180 197
198 // The border and arrow stroke size used in image assets, in pixels.
199 static const int kStroke;
msw 2014/08/19 21:35:39 statics should be declared before functions as per
bruthig 2014/08/22 19:45:04 Done.
181 Arrow arrow_; 200 Arrow arrow_;
182 int arrow_offset_; 201 int arrow_offset_;
183 ArrowPaintType arrow_paint_type_; 202 ArrowPaintType arrow_paint_type_;
184 BubbleAlignment alignment_; 203 BubbleAlignment alignment_;
185 Shadow shadow_; 204 Shadow shadow_;
186 internal::BorderImages* images_; 205 internal::BorderImages* images_;
187 SkColor background_color_; 206 SkColor background_color_;
188 bool use_theme_background_color_; 207 bool use_theme_background_color_;
189 208
190 DISALLOW_COPY_AND_ASSIGN(BubbleBorder); 209 DISALLOW_COPY_AND_ASSIGN(BubbleBorder);
(...skipping 10 matching lines...) Expand all
201 220
202 private: 221 private:
203 BubbleBorder* border_; 222 BubbleBorder* border_;
204 223
205 DISALLOW_COPY_AND_ASSIGN(BubbleBackground); 224 DISALLOW_COPY_AND_ASSIGN(BubbleBackground);
206 }; 225 };
207 226
208 } // namespace views 227 } // namespace views
209 228
210 #endif // UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ 229 #endif // UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698