Merge pull request #6161 from electron/refresh-menu-bar-color
Update menubar color when theme changes
This commit is contained in:
commit
f45e6c6c38
2 changed files with 18 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue