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

Side by Side Diff: ui/views/controls/menu/menu_scroll_view_container.cc

Issue 2480813003: Reduce views::Border creation verbosity by promoting factory functions (Closed)
Patch Set: fix bad merge Created 4 years, 1 month 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
« no previous file with comments | « ui/views/controls/label_unittest.cc ('k') | ui/views/controls/scroll_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/views/controls/menu/menu_scroll_view_container.h" 5 #include "ui/views/controls/menu/menu_scroll_view_container.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "third_party/skia/include/core/SkPaint.h" 9 #include "third_party/skia/include/core/SkPaint.h"
10 #include "third_party/skia/include/core/SkPath.h" 10 #include "third_party/skia/include/core/SkPath.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 282
283 const int vertical_inset = menu_config.menu_vertical_border_size + padding; 283 const int vertical_inset = menu_config.menu_vertical_border_size + padding;
284 const int horizontal_inset = 284 const int horizontal_inset =
285 menu_config.menu_horizontal_border_size + padding; 285 menu_config.menu_horizontal_border_size + padding;
286 286
287 if (menu_config.use_outer_border) { 287 if (menu_config.use_outer_border) {
288 SkColor color = GetNativeTheme() 288 SkColor color = GetNativeTheme()
289 ? GetNativeTheme()->GetSystemColor( 289 ? GetNativeTheme()->GetSystemColor(
290 ui::NativeTheme::kColorId_MenuBorderColor) 290 ui::NativeTheme::kColorId_MenuBorderColor)
291 : gfx::kPlaceholderColor; 291 : gfx::kPlaceholderColor;
292 SetBorder(views::Border::CreateBorderPainter( 292 SetBorder(views::CreateBorderPainter(
293 base::MakeUnique<views::RoundRectPainter>(color, 293 base::MakeUnique<views::RoundRectPainter>(color,
294 menu_config.corner_radius), 294 menu_config.corner_radius),
295 gfx::Insets(vertical_inset, horizontal_inset))); 295 gfx::Insets(vertical_inset, horizontal_inset)));
296 } else { 296 } else {
297 SetBorder(Border::CreateEmptyBorder(vertical_inset, horizontal_inset, 297 SetBorder(CreateEmptyBorder(vertical_inset, horizontal_inset,
298 vertical_inset, horizontal_inset)); 298 vertical_inset, horizontal_inset));
299 } 299 }
300 } 300 }
301 301
302 void MenuScrollViewContainer::CreateBubbleBorder() { 302 void MenuScrollViewContainer::CreateBubbleBorder() {
303 bubble_border_ = new BubbleBorder(arrow_, 303 bubble_border_ = new BubbleBorder(arrow_,
304 BubbleBorder::SMALL_SHADOW, 304 BubbleBorder::SMALL_SHADOW,
305 SK_ColorWHITE); 305 SK_ColorWHITE);
306 SetBorder(std::unique_ptr<Border>(bubble_border_)); 306 SetBorder(std::unique_ptr<Border>(bubble_border_));
307 set_background(new BubbleBackground(bubble_border_)); 307 set_background(new BubbleBackground(bubble_border_));
308 } 308 }
309 309
310 BubbleBorder::Arrow MenuScrollViewContainer::BubbleBorderTypeFromAnchor( 310 BubbleBorder::Arrow MenuScrollViewContainer::BubbleBorderTypeFromAnchor(
311 MenuAnchorPosition anchor) { 311 MenuAnchorPosition anchor) {
312 switch (anchor) { 312 switch (anchor) {
313 case MENU_ANCHOR_BUBBLE_LEFT: 313 case MENU_ANCHOR_BUBBLE_LEFT:
314 return BubbleBorder::RIGHT_CENTER; 314 return BubbleBorder::RIGHT_CENTER;
315 case MENU_ANCHOR_BUBBLE_RIGHT: 315 case MENU_ANCHOR_BUBBLE_RIGHT:
316 return BubbleBorder::LEFT_CENTER; 316 return BubbleBorder::LEFT_CENTER;
317 case MENU_ANCHOR_BUBBLE_ABOVE: 317 case MENU_ANCHOR_BUBBLE_ABOVE:
318 return BubbleBorder::BOTTOM_CENTER; 318 return BubbleBorder::BOTTOM_CENTER;
319 case MENU_ANCHOR_BUBBLE_BELOW: 319 case MENU_ANCHOR_BUBBLE_BELOW:
320 return BubbleBorder::TOP_CENTER; 320 return BubbleBorder::TOP_CENTER;
321 default: 321 default:
322 return BubbleBorder::NONE; 322 return BubbleBorder::NONE;
323 } 323 }
324 } 324 }
325 325
326 } // namespace views 326 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label_unittest.cc ('k') | ui/views/controls/scroll_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698