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/views/controls/menu/menu_scroll_view_container.h" | 5 #include "ui/views/controls/menu/menu_scroll_view_container.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkPaint.h" | 7 #include "third_party/skia/include/core/SkPaint.h" |
8 #include "third_party/skia/include/core/SkPath.h" | 8 #include "third_party/skia/include/core/SkPath.h" |
9 #include "ui/base/accessibility/accessible_view_state.h" | 9 #include "ui/base/accessibility/accessible_view_state.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
11 #include "ui/native_theme/native_theme.h" | 11 #include "ui/native_theme/native_theme.h" |
12 #include "ui/views/border.h" | 12 #include "ui/views/border.h" |
13 #include "ui/views/bubble/bubble_border.h" | 13 #include "ui/views/bubble/bubble_border.h" |
14 #include "ui/views/controls/menu/menu_config.h" | 14 #include "ui/views/controls/menu/menu_config.h" |
15 #include "ui/views/controls/menu/menu_controller.h" | 15 #include "ui/views/controls/menu/menu_controller.h" |
16 #include "ui/views/controls/menu/menu_item_view.h" | 16 #include "ui/views/controls/menu/menu_item_view.h" |
17 #include "ui/views/controls/menu/submenu_view.h" | 17 #include "ui/views/controls/menu/submenu_view.h" |
18 #include "ui/views/round_rect_painter.h" | 18 #include "ui/views/round_rect_painter.h" |
19 | 19 |
| 20 #if defined(USE_AURA) |
| 21 #include "ui/native_theme/native_theme_aura.h" |
| 22 #endif |
| 23 |
20 using ui::NativeTheme; | 24 using ui::NativeTheme; |
21 | 25 |
22 // Height of the scroll arrow. | 26 // Height of the scroll arrow. |
23 // This goes up to 4 with large fonts, but this is close enough for now. | 27 // This goes up to 4 with large fonts, but this is close enough for now. |
24 static const int scroll_arrow_height = 3; | 28 static const int scroll_arrow_height = 3; |
25 | 29 |
26 namespace views { | 30 namespace views { |
27 | 31 |
28 namespace { | 32 namespace { |
29 | 33 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 Layout(); | 267 Layout(); |
264 } | 268 } |
265 | 269 |
266 void MenuScrollViewContainer::CreateDefaultBorder() { | 270 void MenuScrollViewContainer::CreateDefaultBorder() { |
267 arrow_location_ = BubbleBorder::NONE; | 271 arrow_location_ = BubbleBorder::NONE; |
268 bubble_border_ = NULL; | 272 bubble_border_ = NULL; |
269 | 273 |
270 const MenuConfig& menu_config = | 274 const MenuConfig& menu_config = |
271 content_view_->GetMenuItem()->GetMenuConfig(); | 275 content_view_->GetMenuItem()->GetMenuConfig(); |
272 | 276 |
| 277 bool use_border = true; |
273 int padding = menu_config.corner_radius > 0 ? | 278 int padding = menu_config.corner_radius > 0 ? |
274 kBorderPaddingDueToRoundedCorners : 0; | 279 kBorderPaddingDueToRoundedCorners : 0; |
| 280 |
| 281 #if defined(USE_AURA) |
| 282 if (menu_config.native_theme == ui::NativeThemeAura::instance()) { |
| 283 // In case of NativeThemeAura the border gets drawn with the shadow. |
| 284 // Furthermore no additional padding is wanted. |
| 285 use_border = false; |
| 286 padding = 0; |
| 287 } |
| 288 #endif |
| 289 |
275 int top = menu_config.menu_vertical_border_size + padding; | 290 int top = menu_config.menu_vertical_border_size + padding; |
276 int left = menu_config.menu_horizontal_border_size + padding; | 291 int left = menu_config.menu_horizontal_border_size + padding; |
277 int bottom = menu_config.menu_vertical_border_size + padding; | 292 int bottom = menu_config.menu_vertical_border_size + padding; |
278 int right = menu_config.menu_horizontal_border_size + padding; | 293 int right = menu_config.menu_horizontal_border_size + padding; |
279 | 294 |
280 if (NativeTheme::IsNewMenuStyleEnabled()) { | 295 if (use_border && NativeTheme::IsNewMenuStyleEnabled()) { |
281 set_border(views::Border::CreateBorderPainter( | 296 set_border(views::Border::CreateBorderPainter( |
282 new views::RoundRectPainter(menu_config.native_theme->GetSystemColor( | 297 new views::RoundRectPainter(menu_config.native_theme->GetSystemColor( |
283 ui::NativeTheme::kColorId_MenuBorderColor), | 298 ui::NativeTheme::kColorId_MenuBorderColor), |
284 menu_config.corner_radius), | 299 menu_config.corner_radius), |
285 gfx::Insets(top, left, bottom, right))); | 300 gfx::Insets(top, left, bottom, right))); |
286 } else { | 301 } else { |
287 set_border(Border::CreateEmptyBorder(top, left, bottom, right)); | 302 set_border(Border::CreateEmptyBorder(top, left, bottom, right)); |
288 } | 303 } |
289 } | 304 } |
290 | 305 |
(...skipping 15 matching lines...) Expand all Loading... |
306 case views::MenuItemView::BUBBLE_ABOVE: | 321 case views::MenuItemView::BUBBLE_ABOVE: |
307 return BubbleBorder::BOTTOM_CENTER; | 322 return BubbleBorder::BOTTOM_CENTER; |
308 case views::MenuItemView::BUBBLE_BELOW: | 323 case views::MenuItemView::BUBBLE_BELOW: |
309 return BubbleBorder::TOP_CENTER; | 324 return BubbleBorder::TOP_CENTER; |
310 default: | 325 default: |
311 return BubbleBorder::NONE; | 326 return BubbleBorder::NONE; |
312 } | 327 } |
313 } | 328 } |
314 | 329 |
315 } // namespace views | 330 } // namespace views |
OLD | NEW |