From aca37c897439171344924f79d8d20978b893cf42 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 21 Jun 2016 18:05:01 +0900 Subject: [PATCH] Update menubar color when theme changes --- atom/browser/ui/views/menu_bar.cc | 23 +++++++++++++++-------- atom/browser/ui/views/menu_bar.h | 4 +++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/atom/browser/ui/views/menu_bar.cc b/atom/browser/ui/views/menu_bar.cc index 872375ccbbd..796e6ef8045 100644 --- a/atom/browser/ui/views/menu_bar.cc +++ b/atom/browser/ui/views/menu_bar.cc @@ -50,14 +50,7 @@ void GetMenuBarColor(SkColor* enabled, SkColor* disabled, SkColor* highlight, MenuBar::MenuBar() : background_color_(kDefaultColor), menu_model_(NULL) { -#if defined(OS_WIN) - background_color_ = color_utils::GetSysSkColor(COLOR_MENUBAR); -#elif defined(USE_X11) - GetMenuBarColor(&enabled_color_, &disabled_color_, &highlight_color_, - &hover_color_, &background_color_); -#endif - - set_background(views::Background::CreateSolidBackground(background_color_)); + UpdateMenuBarColor(); SetLayoutManager(new views::BoxLayout( views::BoxLayout::kHorizontal, 0, 0, 0)); } @@ -159,4 +152,18 @@ void MenuBar::OnMenuButtonClicked(views::MenuButton* source, menu_delegate.RunMenu(menu_model_->GetSubmenuModelAt(id), source); } +void MenuBar::OnNativeThemeChanged(const ui::NativeTheme* theme) { + UpdateMenuBarColor(); +} + +void MenuBar::UpdateMenuBarColor() { +#if defined(OS_WIN) + background_color_ = color_utils::GetSysSkColor(COLOR_MENUBAR); +#elif defined(USE_X11) + GetMenuBarColor(&enabled_color_, &disabled_color_, &highlight_color_, + &hover_color_, &background_color_); +#endif + set_background(views::Background::CreateSolidBackground(background_color_)); +} + } // namespace atom diff --git a/atom/browser/ui/views/menu_bar.h b/atom/browser/ui/views/menu_bar.h index 9f38a5981c7..eb62784e71c 100644 --- a/atom/browser/ui/views/menu_bar.h +++ b/atom/browser/ui/views/menu_bar.h @@ -60,9 +60,11 @@ class MenuBar : public views::View, void OnMenuButtonClicked(views::MenuButton* source, const gfx::Point& point, const ui::Event* event) override; - + void OnNativeThemeChanged(const ui::NativeTheme* theme) override; private: + void UpdateMenuBarColor(); + SkColor background_color_; #if defined(USE_X11)