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

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

Issue 2387503002: Fix menu scroll indicators and highlights overlapping the menu border. (Closed)
Patch Set: inset in layout instead Created 4 years, 2 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
« no previous file with comments | « ui/views/controls/menu/menu_config.cc ('k') | ui/views/round_rect_painter.h » ('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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 void MenuScrollViewContainer::CreateDefaultBorder() { 276 void MenuScrollViewContainer::CreateDefaultBorder() {
277 DCHECK_EQ(arrow_, BubbleBorder::NONE); 277 DCHECK_EQ(arrow_, BubbleBorder::NONE);
278 bubble_border_ = nullptr; 278 bubble_border_ = nullptr;
279 279
280 const MenuConfig& menu_config = MenuConfig::instance(); 280 const MenuConfig& menu_config = MenuConfig::instance();
281 281
282 int padding = menu_config.use_outer_border && menu_config.corner_radius > 0 282 int padding = menu_config.use_outer_border && menu_config.corner_radius > 0
283 ? kBorderPaddingDueToRoundedCorners 283 ? kBorderPaddingDueToRoundedCorners
284 : 0; 284 : 0;
285 285
286 int top = menu_config.menu_vertical_border_size + padding; 286 const int vertical_inset = menu_config.menu_vertical_border_size + padding;
287 int left = menu_config.menu_horizontal_border_size + padding; 287 const int horizontal_inset =
288 int bottom = menu_config.menu_vertical_border_size + padding; 288 menu_config.menu_horizontal_border_size + padding;
289 int right = menu_config.menu_horizontal_border_size + padding;
290 289
291 if (menu_config.use_outer_border) { 290 if (menu_config.use_outer_border) {
292 SkColor color = GetNativeTheme() 291 SkColor color = GetNativeTheme()
293 ? GetNativeTheme()->GetSystemColor( 292 ? GetNativeTheme()->GetSystemColor(
294 ui::NativeTheme::kColorId_MenuBorderColor) 293 ui::NativeTheme::kColorId_MenuBorderColor)
295 : gfx::kPlaceholderColor; 294 : gfx::kPlaceholderColor;
296 SetBorder(views::Border::CreateBorderPainter( 295 SetBorder(views::Border::CreateBorderPainter(
297 base::MakeUnique<views::RoundRectPainter>(color, 296 base::MakeUnique<views::RoundRectPainter>(color,
298 menu_config.corner_radius), 297 menu_config.corner_radius),
299 gfx::Insets(top, left, bottom, right))); 298 gfx::Insets(vertical_inset, horizontal_inset)));
300 } else { 299 } else {
301 SetBorder(Border::CreateEmptyBorder(top, left, bottom, right)); 300 SetBorder(Border::CreateEmptyBorder(vertical_inset, horizontal_inset,
301 vertical_inset, horizontal_inset));
302 } 302 }
303 } 303 }
304 304
305 void MenuScrollViewContainer::CreateBubbleBorder() { 305 void MenuScrollViewContainer::CreateBubbleBorder() {
306 bubble_border_ = new BubbleBorder(arrow_, 306 bubble_border_ = new BubbleBorder(arrow_,
307 BubbleBorder::SMALL_SHADOW, 307 BubbleBorder::SMALL_SHADOW,
308 SK_ColorWHITE); 308 SK_ColorWHITE);
309 SetBorder(std::unique_ptr<Border>(bubble_border_)); 309 SetBorder(std::unique_ptr<Border>(bubble_border_));
310 set_background(new BubbleBackground(bubble_border_)); 310 set_background(new BubbleBackground(bubble_border_));
311 } 311 }
312 312
313 BubbleBorder::Arrow MenuScrollViewContainer::BubbleBorderTypeFromAnchor( 313 BubbleBorder::Arrow MenuScrollViewContainer::BubbleBorderTypeFromAnchor(
314 MenuAnchorPosition anchor) { 314 MenuAnchorPosition anchor) {
315 switch (anchor) { 315 switch (anchor) {
316 case MENU_ANCHOR_BUBBLE_LEFT: 316 case MENU_ANCHOR_BUBBLE_LEFT:
317 return BubbleBorder::RIGHT_CENTER; 317 return BubbleBorder::RIGHT_CENTER;
318 case MENU_ANCHOR_BUBBLE_RIGHT: 318 case MENU_ANCHOR_BUBBLE_RIGHT:
319 return BubbleBorder::LEFT_CENTER; 319 return BubbleBorder::LEFT_CENTER;
320 case MENU_ANCHOR_BUBBLE_ABOVE: 320 case MENU_ANCHOR_BUBBLE_ABOVE:
321 return BubbleBorder::BOTTOM_CENTER; 321 return BubbleBorder::BOTTOM_CENTER;
322 case MENU_ANCHOR_BUBBLE_BELOW: 322 case MENU_ANCHOR_BUBBLE_BELOW:
323 return BubbleBorder::TOP_CENTER; 323 return BubbleBorder::TOP_CENTER;
324 default: 324 default:
325 return BubbleBorder::NONE; 325 return BubbleBorder::NONE;
326 } 326 }
327 } 327 }
328 328
329 } // namespace views 329 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_config.cc ('k') | ui/views/round_rect_painter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698