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

Unified Diff: ui/views/controls/menu/menu_scroll_view_container.cc

Issue 1454583002: Change Views menus to consistently use GetNativeTheme for theming. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get menu config from item Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/menu/menu_scroll_view_container.h ('k') | ui/views/controls/menu/menu_separator_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/menu/menu_scroll_view_container.cc
diff --git a/ui/views/controls/menu/menu_scroll_view_container.cc b/ui/views/controls/menu/menu_scroll_view_container.cc
index f7490d8e1674695fbf9520fb708bd96dd25e30d8..4412a3307d381601d0d8374b9a86c7b294a72ceb 100644
--- a/ui/views/controls/menu/menu_scroll_view_container.cc
+++ b/ui/views/controls/menu/menu_scroll_view_container.cc
@@ -8,6 +8,7 @@
#include "third_party/skia/include/core/SkPath.h"
#include "ui/accessibility/ax_view_state.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/color_palette.h"
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/controls/menu/menu_config.h"
@@ -201,18 +202,11 @@ void MenuScrollViewContainer::SetBubbleArrowOffset(int offset) {
bubble_border_->set_arrow_offset(offset);
}
-void MenuScrollViewContainer::OnPaintBackground(gfx::Canvas* canvas) {
- if (background()) {
- View::OnPaintBackground(canvas);
- return;
- }
-
- gfx::Rect bounds(0, 0, width(), height());
- NativeTheme::ExtraParams extra;
- const MenuConfig& menu_config = content_view_->GetMenuItem()->GetMenuConfig();
- extra.menu_background.corner_radius = menu_config.corner_radius;
- GetNativeTheme()->Paint(canvas->sk_canvas(),
- NativeTheme::kMenuPopupBackground, NativeTheme::kNormal, bounds, extra);
+gfx::Size MenuScrollViewContainer::GetPreferredSize() const {
+ gfx::Size prefsize = scroll_view_->GetContents()->GetPreferredSize();
+ gfx::Insets insets = GetInsets();
+ prefsize.Enlarge(insets.width(), insets.height());
+ return prefsize;
}
void MenuScrollViewContainer::Layout() {
@@ -242,11 +236,24 @@ void MenuScrollViewContainer::Layout() {
scroll_view_->Layout();
}
-gfx::Size MenuScrollViewContainer::GetPreferredSize() const {
- gfx::Size prefsize = scroll_view_->GetContents()->GetPreferredSize();
- gfx::Insets insets = GetInsets();
- prefsize.Enlarge(insets.width(), insets.height());
- return prefsize;
+void MenuScrollViewContainer::OnNativeThemeChanged(
+ const ui::NativeTheme* theme) {
+ if (arrow_ == BubbleBorder::NONE)
+ CreateDefaultBorder();
+}
+
+void MenuScrollViewContainer::OnPaintBackground(gfx::Canvas* canvas) {
+ if (background()) {
+ View::OnPaintBackground(canvas);
+ return;
+ }
+
+ gfx::Rect bounds(0, 0, width(), height());
+ NativeTheme::ExtraParams extra;
+ const MenuConfig& menu_config = content_view_->GetMenuItem()->GetMenuConfig();
+ extra.menu_background.corner_radius = menu_config.corner_radius;
+ GetNativeTheme()->Paint(canvas->sk_canvas(),
+ NativeTheme::kMenuPopupBackground, NativeTheme::kNormal, bounds, extra);
}
void MenuScrollViewContainer::GetAccessibleState(
@@ -270,8 +277,8 @@ void MenuScrollViewContainer::OnBoundsChanged(
}
void MenuScrollViewContainer::CreateDefaultBorder() {
- arrow_ = BubbleBorder::NONE;
- bubble_border_ = NULL;
+ DCHECK_EQ(arrow_, BubbleBorder::NONE);
+ bubble_border_ = nullptr;
const MenuConfig& menu_config =
content_view_->GetMenuItem()->GetMenuConfig();
@@ -286,11 +293,12 @@ void MenuScrollViewContainer::CreateDefaultBorder() {
int right = menu_config.menu_horizontal_border_size + padding;
if (menu_config.use_outer_border) {
+ SkColor color = GetNativeTheme()
+ ? GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_MenuBorderColor)
+ : gfx::kPlaceholderColor;
SetBorder(views::Border::CreateBorderPainter(
- new views::RoundRectPainter(
- menu_config.native_theme->GetSystemColor(
- ui::NativeTheme::kColorId_MenuBorderColor),
- menu_config.corner_radius),
+ new views::RoundRectPainter(color, menu_config.corner_radius),
gfx::Insets(top, left, bottom, right)));
} else {
SetBorder(Border::CreateEmptyBorder(top, left, bottom, right));
« no previous file with comments | « ui/views/controls/menu/menu_scroll_view_container.h ('k') | ui/views/controls/menu/menu_separator_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698