Merge pull request #6161 from electron/refresh-menu-bar-color

Update menubar color when theme changes
This commit is contained in:
Cheng Zhao 2016-06-21 09:34:55 +00:00 committed by GitHub
commit f45e6c6c38
2 changed files with 18 additions and 9 deletions

View file

@ -50,14 +50,7 @@ void GetMenuBarColor(SkColor* enabled, SkColor* disabled, SkColor* highlight,
MenuBar::MenuBar() MenuBar::MenuBar()
: background_color_(kDefaultColor), : background_color_(kDefaultColor),
menu_model_(NULL) { menu_model_(NULL) {
#if defined(OS_WIN) UpdateMenuBarColor();
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_));
SetLayoutManager(new views::BoxLayout( SetLayoutManager(new views::BoxLayout(
views::BoxLayout::kHorizontal, 0, 0, 0)); views::BoxLayout::kHorizontal, 0, 0, 0));
} }
@ -159,4 +152,18 @@ void MenuBar::OnMenuButtonClicked(views::MenuButton* source,
menu_delegate.RunMenu(menu_model_->GetSubmenuModelAt(id), 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 } // namespace atom

View file

@ -60,9 +60,11 @@ class MenuBar : public views::View,
void OnMenuButtonClicked(views::MenuButton* source, void OnMenuButtonClicked(views::MenuButton* source,
const gfx::Point& point, const gfx::Point& point,
const ui::Event* event) override; const ui::Event* event) override;
void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
private: private:
void UpdateMenuBarColor();
SkColor background_color_; SkColor background_color_;
#if defined(USE_X11) #if defined(USE_X11)