OLD | NEW |
---|---|
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 #include "ui/app_list/app_list_bubble_border.h" | 5 #include "ui/views/bubble/bubble_border_geometric.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkPath.h" | 7 #include <algorithm> // for std::max |
8 #include "third_party/skia/include/core/SkPaint.h" | 8 |
9 #include "third_party/skia/include/effects/SkGradientShader.h" | 9 #include "base/logging.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
11 #include "ui/gfx/path.h" | 11 #include "ui/gfx/path.h" |
12 #include "ui/gfx/rect.h" | |
13 #include "ui/gfx/screen.h" | |
12 #include "ui/gfx/skia_util.h" | 14 #include "ui/gfx/skia_util.h" |
13 | 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 // Bubble border corner radius. | 18 // Bubble border corner radius. |
17 const int kCornerRadius = 2; | 19 const int kCornerRadius = 2; |
18 | 20 |
19 // Arrow width and height. | 21 // Arrow width and height. |
20 const int kArrowHeight = 10; | 22 const int kArrowHeight = 10; |
21 const int kArrowWidth = 20; | 23 const int kArrowWidth = 20; |
22 | 24 |
23 // Bubble border color and width. | 25 const int kBorderSize = 1; |
24 const SkColor kBorderColor = SkColorSetARGB(0x26, 0, 0, 0); | 26 const SkColor kBorderColor = SkColorSetARGB(0x26, 0, 0, 0); |
25 const int kBorderSize = 1; | 27 const SkColor kBackgroundColor = SK_ColorWHITE; |
26 | |
27 const SkColor kSearchBoxBackground = SK_ColorWHITE; | |
28 const SkColor kContentsBackground = SkColorSetRGB(0xFC, 0xFC, 0xFC); | |
29 | |
30 // Colors and sizes of top separator between searchbox and grid view. | |
31 const SkColor kTopSeparatorColor = SkColorSetRGB(0xF0, 0xF0, 0xF0); | |
32 const int kTopSeparatorSize = 1; | |
33 | 28 |
34 // Builds a bubble shape for given |bounds|. | 29 // Builds a bubble shape for given |bounds|. |
35 void BuildShape(const gfx::Rect& bounds, | 30 void BuildShape(const gfx::Rect& bounds, |
36 views::BubbleBorder::ArrowLocation arrow_location, | 31 views::BubbleBorder::ArrowLocation arrow_location, |
37 SkScalar arrow_offset, | 32 SkScalar arrow_offset, |
38 SkScalar padding, | 33 SkScalar padding, |
39 SkPath* path) { | 34 SkPath* path, |
40 const SkScalar corner_radius = SkIntToScalar(kCornerRadius); | 35 int corner_radius_int, |
36 int arrow_height_int, | |
37 int arrow_width_int) { | |
38 const SkScalar corner_radius = SkIntToScalar(corner_radius_int); | |
41 | 39 |
42 const SkScalar left = SkIntToScalar(bounds.x()) + padding; | 40 const SkScalar left = SkIntToScalar(bounds.x()) + padding; |
43 const SkScalar top = SkIntToScalar(bounds.y()) + padding; | 41 const SkScalar top = SkIntToScalar(bounds.y()) + padding; |
44 const SkScalar right = SkIntToScalar(bounds.right()) - padding; | 42 const SkScalar right = SkIntToScalar(bounds.right()) - padding; |
45 const SkScalar bottom = SkIntToScalar(bounds.bottom()) - padding; | 43 const SkScalar bottom = SkIntToScalar(bounds.bottom()) - padding; |
46 | 44 |
47 const SkScalar center_x = SkIntToScalar((bounds.x() + bounds.right()) / 2); | 45 const SkScalar center_x = SkIntToScalar((bounds.x() + bounds.right()) / 2); |
48 const SkScalar center_y = SkIntToScalar((bounds.y() + bounds.bottom()) / 2); | 46 const SkScalar center_y = SkIntToScalar((bounds.y() + bounds.bottom()) / 2); |
49 | 47 |
50 const SkScalar half_arrow_width = (SkIntToScalar(kArrowWidth) - padding) / 2; | 48 const SkScalar half_arrow_width = |
51 const SkScalar arrow_height = SkIntToScalar(kArrowHeight) - padding; | 49 (SkIntToScalar(arrow_width_int) - padding) / 2; |
50 const SkScalar arrow_height = SkIntToScalar(arrow_height_int) - padding; | |
52 | 51 |
53 path->reset(); | 52 path->reset(); |
54 path->incReserve(12); | 53 path->incReserve(12); |
55 | 54 |
56 switch (arrow_location) { | 55 switch (arrow_location) { |
57 case views::BubbleBorder::TOP_LEFT: | 56 case views::BubbleBorder::TOP_LEFT: |
58 case views::BubbleBorder::TOP_RIGHT: | 57 case views::BubbleBorder::TOP_RIGHT: |
59 path->moveTo(center_x, bottom); | 58 path->moveTo(center_x, bottom); |
60 path->arcTo(right, bottom, right, center_y, corner_radius); | 59 path->arcTo(right, bottom, right, center_y, corner_radius); |
61 path->arcTo(right, top, center_x - half_arrow_width, top, | 60 path->arcTo(right, top, center_x - half_arrow_width, top, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 corner_radius, | 108 corner_radius, |
110 corner_radius); | 109 corner_radius); |
111 break; | 110 break; |
112 } | 111 } |
113 | 112 |
114 path->close(); | 113 path->close(); |
115 } | 114 } |
116 | 115 |
117 } // namespace | 116 } // namespace |
118 | 117 |
119 namespace app_list { | 118 namespace views { |
120 | 119 |
121 AppListBubbleBorder::AppListBubbleBorder(views::View* app_list_view, | 120 BubbleBorderGeometric::BubbleBorderGeometric(ArrowLocation arrow_location) |
122 views::View* search_box_view) | 121 : BubbleBorder(arrow_location, |
123 : views::BubbleBorder(views::BubbleBorder::BOTTOM_RIGHT, | 122 views::BubbleBorder::NO_SHADOW), |
msw
2012/08/03 17:37:37
nit: this fits on the line above.
varunjain
2012/08/03 17:47:38
Done.
| |
124 views::BubbleBorder::NO_SHADOW), | 123 corner_radius_(kCornerRadius), |
125 app_list_view_(app_list_view), | 124 border_size_(kBorderSize), |
126 search_box_view_(search_box_view) { | 125 arrow_height_(kArrowHeight), |
127 const gfx::ShadowValue kShadows[] = { | 126 arrow_width_(kArrowWidth), |
128 // Offset (0, 5), blur=30, color=0.36 black | 127 background_color_(kBackgroundColor), |
129 gfx::ShadowValue(gfx::Point(0, 5), 30, SkColorSetARGB(0x72, 0, 0, 0)), | 128 border_color_(kBorderColor) { |
130 }; | 129 SetShadow(gfx::ShadowValue( |
131 shadows_.assign(kShadows, kShadows + arraysize(kShadows)); | 130 gfx::Point(0, 5), 30, SkColorSetARGB(0x72, 0, 0, 0))); |
msw
2012/08/03 17:37:37
nit: please make the color a const, possibly the b
varunjain
2012/08/03 17:47:38
Done.
| |
132 } | 131 } |
133 | 132 |
134 AppListBubbleBorder::~AppListBubbleBorder() { | 133 BubbleBorderGeometric::~BubbleBorderGeometric() {} |
134 | |
135 gfx::Rect BubbleBorderGeometric::ComputeOffsetAndUpdateBubbleRect( | |
136 gfx::Rect bubble_rect, | |
137 const gfx::Rect& anchor_view_rect) { | |
138 offset_ = gfx::Point(); | |
139 | |
140 gfx::Rect monitor_rect = gfx::Screen::GetDisplayNearestPoint( | |
141 anchor_view_rect.CenterPoint()).bounds(); | |
142 if (monitor_rect.IsEmpty() || monitor_rect.Contains(bubble_rect)) | |
143 return bubble_rect; | |
144 | |
145 gfx::Point offset; | |
146 | |
147 if (has_arrow(arrow_location())) { | |
148 if (is_arrow_on_horizontal(arrow_location())) { | |
149 if (bubble_rect.x() < monitor_rect.x()) | |
150 offset.set_x(monitor_rect.x() - bubble_rect.x()); | |
151 else if (bubble_rect.right() > monitor_rect.right()) | |
152 offset.set_x(monitor_rect.right() - bubble_rect.right()); | |
153 } else { | |
154 if (bubble_rect.y() < monitor_rect.y()) | |
155 offset.set_y(monitor_rect.y() - bubble_rect.y()); | |
156 else if (bubble_rect.bottom() > monitor_rect.bottom()) | |
157 offset.set_y(monitor_rect.bottom() - bubble_rect.bottom()); | |
158 } | |
159 } | |
160 | |
161 bubble_rect.Offset(offset); | |
162 set_offset(offset); | |
163 | |
164 return bubble_rect; | |
135 } | 165 } |
136 | 166 |
137 bool AppListBubbleBorder::ArrowAtTopOrBottom() const { | 167 void BubbleBorderGeometric::GetMask(const gfx::Rect& bounds, |
138 return arrow_location() == views::BubbleBorder::TOP_LEFT || | 168 gfx::Path* mask) const { |
139 arrow_location() == views::BubbleBorder::TOP_RIGHT || | |
140 arrow_location() == views::BubbleBorder::BOTTOM_LEFT || | |
141 arrow_location() == views::BubbleBorder::BOTTOM_RIGHT; | |
142 } | |
143 | |
144 bool AppListBubbleBorder::ArrowOnLeftOrRight() const { | |
145 return arrow_location() == views::BubbleBorder::LEFT_TOP || | |
146 arrow_location() == views::BubbleBorder::LEFT_BOTTOM || | |
147 arrow_location() == views::BubbleBorder::RIGHT_TOP || | |
148 arrow_location() == views::BubbleBorder::RIGHT_BOTTOM; | |
149 } | |
150 | |
151 void AppListBubbleBorder::GetMask(const gfx::Rect& bounds, | |
152 gfx::Path* mask) const { | |
153 gfx::Insets insets; | 169 gfx::Insets insets; |
154 GetInsets(&insets); | 170 GetInsets(&insets); |
155 | 171 |
156 gfx::Rect content_bounds(bounds); | 172 gfx::Rect content_bounds(bounds); |
157 content_bounds.Inset(insets); | 173 content_bounds.Inset(insets); |
158 | 174 |
159 BuildShape(content_bounds, | 175 BuildShape(content_bounds, |
160 arrow_location(), | 176 arrow_location(), |
161 SkIntToScalar(GetArrowOffset()), | 177 SkIntToScalar(GetArrowOffset()), |
162 SkIntToScalar(kBorderSize), | 178 SkIntToScalar(kBorderSize), |
163 mask); | 179 mask, |
180 corner_radius_, | |
181 arrow_height_, | |
182 arrow_width_); | |
164 } | 183 } |
165 | 184 |
166 int AppListBubbleBorder::GetArrowOffset() const { | 185 void BubbleBorderGeometric::SetShadow(gfx::ShadowValue shadow) { |
167 if (ArrowAtTopOrBottom()) { | 186 shadows_.clear(); |
168 // Picks x offset and moves bubble arrow in the opposite direction. | 187 shadows_.push_back(shadow); |
169 // i.e. If bubble bounds is moved to right (positive offset), we need to | 188 } |
170 // move arrow to left so that it points to the same position. | 189 |
171 return -offset_.x(); | 190 int BubbleBorderGeometric::border_thickness() const { |
172 } else if (ArrowOnLeftOrRight()) { | 191 return border_size_; |
173 // Picks y offset and moves bubble arrow in the opposite direction. | 192 } |
174 return -offset_.y(); | 193 |
194 void BubbleBorderGeometric::PaintBackground(gfx::Canvas* canvas, | |
195 const gfx::Rect& bounds) const { | |
196 canvas->FillRect(bounds, background_color_); | |
197 } | |
198 | |
199 int BubbleBorderGeometric::GetArrowOffset() const { | |
200 if (has_arrow(arrow_location())) { | |
201 if (is_arrow_on_horizontal(arrow_location())) { | |
202 // Picks x offset and moves bubble arrow in the opposite direction. | |
203 // i.e. If bubble bounds is moved to right (positive offset), we need to | |
204 // move arrow to left so that it points to the same position. | |
205 return -offset_.x(); | |
206 } else { | |
207 // Picks y offset and moves bubble arrow in the opposite direction. | |
208 return -offset_.y(); | |
209 } | |
175 } | 210 } |
176 | 211 |
177 // Other style does not have an arrow, so return 0. | 212 // Other style does not have an arrow, so return 0. |
178 return 0; | 213 return 0; |
179 } | 214 } |
180 | 215 |
181 void AppListBubbleBorder::PaintBackground(gfx::Canvas* canvas, | 216 void BubbleBorderGeometric::GetInsets(gfx::Insets* insets) const { |
182 const gfx::Rect& bounds) const { | |
183 const gfx::Rect search_box_view_bounds = | |
184 app_list_view_->ConvertRectToWidget(search_box_view_->bounds()); | |
185 gfx::Rect search_box_rect(bounds.x(), | |
186 bounds.y(), | |
187 bounds.width(), | |
188 search_box_view_bounds.bottom() - bounds.y()); | |
189 | |
190 SkPaint paint; | |
191 paint.setStyle(SkPaint::kFill_Style); | |
192 paint.setColor(kSearchBoxBackground); | |
193 canvas->DrawRect(search_box_rect, paint); | |
194 | |
195 gfx::Rect seperator_rect(search_box_rect); | |
196 seperator_rect.set_y(seperator_rect.bottom()); | |
197 seperator_rect.set_height(kTopSeparatorSize); | |
198 canvas->FillRect(seperator_rect, kTopSeparatorColor); | |
199 | |
200 gfx::Rect contents_rect(bounds.x(), | |
201 seperator_rect.bottom(), | |
202 bounds.width(), | |
203 bounds.bottom() - seperator_rect.bottom()); | |
204 | |
205 paint.setColor(kContentsBackground); | |
206 canvas->DrawRect(contents_rect, paint); | |
207 } | |
208 | |
209 void AppListBubbleBorder::GetInsets(gfx::Insets* insets) const { | |
210 // Negate to change from outer margin to inner padding. | 217 // Negate to change from outer margin to inner padding. |
211 gfx::Insets shadow_padding(-gfx::ShadowValue::GetMargin(shadows_)); | 218 gfx::Insets shadow_padding(-gfx::ShadowValue::GetMargin(shadows_)); |
212 | 219 |
213 if (arrow_location() == views::BubbleBorder::TOP_LEFT || | 220 if (arrow_location() == views::BubbleBorder::TOP_LEFT || |
214 arrow_location() == views::BubbleBorder::TOP_RIGHT) { | 221 arrow_location() == views::BubbleBorder::TOP_RIGHT) { |
215 // Arrow at top. | 222 // Arrow at top. |
216 insets->Set(shadow_padding.top() + kArrowHeight, | 223 insets->Set(shadow_padding.top() + arrow_height_, |
217 shadow_padding.left(), | 224 shadow_padding.left(), |
218 shadow_padding.bottom(), | 225 shadow_padding.bottom(), |
219 shadow_padding.right()); | 226 shadow_padding.right()); |
220 } else if (arrow_location() == views::BubbleBorder::BOTTOM_LEFT || | 227 } else if (arrow_location() == views::BubbleBorder::BOTTOM_LEFT || |
221 arrow_location() == views::BubbleBorder::BOTTOM_RIGHT) { | 228 arrow_location() == views::BubbleBorder::BOTTOM_RIGHT) { |
222 // Arrow at bottom. | 229 // Arrow at bottom. |
223 insets->Set(shadow_padding.top(), | 230 insets->Set(shadow_padding.top(), |
224 shadow_padding.left(), | 231 shadow_padding.left(), |
225 shadow_padding.bottom() + kArrowHeight, | 232 shadow_padding.bottom() + arrow_height_, |
226 shadow_padding.right()); | 233 shadow_padding.right()); |
227 } else if (arrow_location() == views::BubbleBorder::LEFT_TOP || | 234 } else if (arrow_location() == views::BubbleBorder::LEFT_TOP || |
228 arrow_location() == views::BubbleBorder::LEFT_BOTTOM) { | 235 arrow_location() == views::BubbleBorder::LEFT_BOTTOM) { |
229 // Arrow on left. | 236 // Arrow on left. |
230 insets->Set(shadow_padding.top(), | 237 insets->Set(shadow_padding.top(), |
231 shadow_padding.left() + kArrowHeight, | 238 shadow_padding.left() + arrow_height_, |
232 shadow_padding.bottom(), | 239 shadow_padding.bottom(), |
233 shadow_padding.right()); | 240 shadow_padding.right()); |
234 } else if (arrow_location() == views::BubbleBorder::RIGHT_TOP || | 241 } else if (arrow_location() == views::BubbleBorder::RIGHT_TOP || |
235 arrow_location() == views::BubbleBorder::RIGHT_BOTTOM) { | 242 arrow_location() == views::BubbleBorder::RIGHT_BOTTOM) { |
236 // Arrow on right. | 243 // Arrow on right. |
237 insets->Set(shadow_padding.top(), | 244 insets->Set(shadow_padding.top(), |
238 shadow_padding.left(), | 245 shadow_padding.left(), |
239 shadow_padding.bottom(), | 246 shadow_padding.bottom(), |
240 shadow_padding.right() + kArrowHeight); | 247 shadow_padding.right() + arrow_height_); |
241 } | 248 } |
242 } | 249 } |
243 | 250 |
244 gfx::Rect AppListBubbleBorder::GetBounds( | 251 gfx::Rect BubbleBorderGeometric::GetBounds( |
245 const gfx::Rect& position_relative_to, | 252 const gfx::Rect& position_relative_to, |
246 const gfx::Size& contents_size) const { | 253 const gfx::Size& contents_size) const { |
247 gfx::Size border_size(contents_size); | 254 gfx::Size border_size(contents_size); |
248 gfx::Insets insets; | 255 gfx::Insets insets; |
249 GetInsets(&insets); | 256 GetInsets(&insets); |
250 border_size.Enlarge(insets.width(), insets.height()); | 257 border_size.Enlarge(insets.width(), insets.height()); |
251 | 258 |
252 // Negate to change from outer margin to inner padding. | 259 // Negate to change from outer margin to inner padding. |
253 gfx::Insets shadow_padding(-gfx::ShadowValue::GetMargin(shadows_)); | 260 gfx::Insets shadow_padding(-gfx::ShadowValue::GetMargin(shadows_)); |
254 | 261 |
(...skipping 13 matching lines...) Expand all Loading... | |
268 GetArrowOffset(); | 275 GetArrowOffset(); |
269 int arrow_tip_y = insets.top() + contents_size.height() / 2 + | 276 int arrow_tip_y = insets.top() + contents_size.height() / 2 + |
270 GetArrowOffset() + 1; | 277 GetArrowOffset() + 1; |
271 | 278 |
272 if (arrow_location() == views::BubbleBorder::TOP_LEFT || | 279 if (arrow_location() == views::BubbleBorder::TOP_LEFT || |
273 arrow_location() == views::BubbleBorder::TOP_RIGHT) { | 280 arrow_location() == views::BubbleBorder::TOP_RIGHT) { |
274 // Arrow at top. | 281 // Arrow at top. |
275 return gfx::Rect( | 282 return gfx::Rect( |
276 gfx::Point(anchor_center_x - arrow_tip_x, | 283 gfx::Point(anchor_center_x - arrow_tip_x, |
277 position_relative_to.bottom() - shadow_padding.top() - | 284 position_relative_to.bottom() - shadow_padding.top() - |
278 kArrowHeight), | 285 arrow_height_), |
279 border_size); | 286 border_size); |
280 } else if (arrow_location() == views::BubbleBorder::BOTTOM_LEFT || | 287 } else if (arrow_location() == views::BubbleBorder::BOTTOM_LEFT || |
281 arrow_location() == views::BubbleBorder::BOTTOM_RIGHT) { | 288 arrow_location() == views::BubbleBorder::BOTTOM_RIGHT) { |
282 // Arrow at bottom. | 289 // Arrow at bottom. |
283 return gfx::Rect( | 290 return gfx::Rect( |
284 gfx::Point(anchor_center_x - arrow_tip_x, | 291 gfx::Point(anchor_center_x - arrow_tip_x, |
285 position_relative_to.y() - border_size.height() + | 292 position_relative_to.y() - border_size.height() + |
286 shadow_padding.bottom() + kArrowHeight), | 293 shadow_padding.bottom() + arrow_height_), |
287 border_size); | 294 border_size); |
288 } else if (arrow_location() == views::BubbleBorder::LEFT_TOP || | 295 } else if (arrow_location() == views::BubbleBorder::LEFT_TOP || |
289 arrow_location() == views::BubbleBorder::LEFT_BOTTOM) { | 296 arrow_location() == views::BubbleBorder::LEFT_BOTTOM) { |
290 // Arrow on left. | 297 // Arrow on left. |
291 return gfx::Rect( | 298 return gfx::Rect( |
292 gfx::Point(position_relative_to.right() - shadow_padding.left() - | 299 gfx::Point(position_relative_to.right() - shadow_padding.left() - |
293 kArrowHeight, | 300 arrow_height_, |
294 anchor_center_y - arrow_tip_y), | 301 anchor_center_y - arrow_tip_y), |
295 border_size); | 302 border_size); |
296 } else if (arrow_location() == views::BubbleBorder::RIGHT_TOP || | 303 } else if (arrow_location() == views::BubbleBorder::RIGHT_TOP || |
297 arrow_location() == views::BubbleBorder::RIGHT_BOTTOM) { | 304 arrow_location() == views::BubbleBorder::RIGHT_BOTTOM) { |
298 // Arrow on right. | 305 // Arrow on right. |
299 return gfx::Rect( | 306 return gfx::Rect( |
300 gfx::Point(position_relative_to.x() - border_size.width() + | 307 gfx::Point(position_relative_to.x() - border_size.width() + |
301 shadow_padding.right() + kArrowHeight, | 308 shadow_padding.right() + arrow_height_, |
302 anchor_center_y - arrow_tip_y), | 309 anchor_center_y - arrow_tip_y), |
303 border_size); | 310 border_size); |
304 } | 311 } |
305 | 312 |
306 // No arrow bubble, center align with anchor. | 313 // No arrow bubble, center align with anchor. |
307 return position_relative_to.Center(border_size); | 314 return position_relative_to.Center(border_size); |
308 } | 315 } |
309 | 316 |
310 void AppListBubbleBorder::Paint(const views::View& view, | 317 void BubbleBorderGeometric::GetInsetsForArrowLocation( |
311 gfx::Canvas* canvas) const { | 318 gfx::Insets* insets, |
319 ArrowLocation arrow_loc) const { | |
320 int top = border_size_; | |
321 int bottom = border_size_; | |
322 int left = border_size_; | |
323 int right = border_size_; | |
324 switch (arrow_loc) { | |
325 case TOP_LEFT: | |
326 case TOP_RIGHT: | |
327 top = std::max(top, arrow_height_); | |
328 break; | |
329 | |
330 case BOTTOM_LEFT: | |
331 case BOTTOM_RIGHT: | |
332 bottom = std::max(bottom, arrow_height_); | |
333 break; | |
334 | |
335 case LEFT_TOP: | |
336 case LEFT_BOTTOM: | |
337 left = std::max(left, arrow_height_); | |
338 break; | |
339 | |
340 case RIGHT_TOP: | |
341 case RIGHT_BOTTOM: | |
342 right = std::max(right, arrow_height_); | |
343 break; | |
344 | |
345 case NONE: | |
346 case FLOAT: | |
347 // Nothing to do. | |
348 break; | |
349 } | |
350 insets->Set(top, left, bottom, right); | |
351 } | |
352 | |
353 void BubbleBorderGeometric::Paint(const views::View& view, | |
354 gfx::Canvas* canvas) const { | |
312 gfx::Insets insets; | 355 gfx::Insets insets; |
313 GetInsets(&insets); | 356 GetInsets(&insets); |
314 | 357 |
315 gfx::Rect content_bounds = view.bounds(); | 358 gfx::Rect content_bounds = view.bounds(); |
316 content_bounds.Inset(insets); | 359 content_bounds.Inset(insets); |
317 | 360 |
318 SkPath path; | 361 SkPath path; |
319 // Pads with 0.5 pixel since anti alias is used. | 362 // Pads with 0.5 pixel since anti alias is used. |
320 BuildShape(content_bounds, | 363 BuildShape(content_bounds, |
321 arrow_location(), | 364 arrow_location(), |
322 SkIntToScalar(GetArrowOffset()), | 365 SkIntToScalar(GetArrowOffset()), |
323 SkDoubleToScalar(0.5), | 366 SkDoubleToScalar(0.5), |
324 &path); | 367 &path, |
368 corner_radius_, | |
369 arrow_height_, | |
370 arrow_width_); | |
325 | 371 |
326 // Draw border and shadow. Note fill is needed to generate enough shadow. | 372 // Draw border and shadow. Note fill is needed to generate enough shadow. |
327 SkPaint paint; | 373 SkPaint paint; |
328 paint.setAntiAlias(true); | 374 paint.setAntiAlias(true); |
329 paint.setStyle(SkPaint::kStrokeAndFill_Style); | 375 paint.setStyle(SkPaint::kStrokeAndFill_Style); |
330 paint.setStrokeWidth(SkIntToScalar(kBorderSize)); | 376 paint.setStrokeWidth(SkIntToScalar(border_size_)); |
331 paint.setColor(kBorderColor); | 377 paint.setColor(border_color_); |
332 SkSafeUnref(paint.setLooper(gfx::CreateShadowDrawLooper(shadows_))); | 378 SkSafeUnref(paint.setLooper(gfx::CreateShadowDrawLooper(shadows_))); |
333 canvas->DrawPath(path, paint); | 379 canvas->DrawPath(path, paint); |
334 | 380 |
335 // Pads with kBoprderSize pixels to leave space for border lines. | 381 // Pads with |border_size_| pixels to leave space for border lines. |
336 BuildShape(content_bounds, | 382 BuildShape(content_bounds, |
337 arrow_location(), | 383 arrow_location(), |
338 SkIntToScalar(GetArrowOffset()), | 384 SkIntToScalar(GetArrowOffset()), |
339 SkIntToScalar(kBorderSize), | 385 SkIntToScalar(border_size_), |
340 &path); | 386 &path, |
387 corner_radius_, | |
388 arrow_height_, | |
389 arrow_width_); | |
341 canvas->Save(); | 390 canvas->Save(); |
342 canvas->ClipPath(path); | 391 canvas->ClipPath(path); |
343 | 392 |
344 // Use full bounds so that arrow is also painted. | 393 // Use full bounds so that arrow is also painted. |
345 const gfx::Rect& bounds = view.bounds(); | 394 const gfx::Rect& bounds = view.bounds(); |
346 PaintBackground(canvas, bounds); | 395 PaintBackground(canvas, bounds); |
347 | 396 |
348 canvas->Restore(); | 397 canvas->Restore(); |
349 } | 398 } |
350 | 399 |
351 } // namespace app_list | 400 } // namespace views |
OLD | NEW |