Add setBackgroundColor method

This commit is contained in:
Cheng Zhao 2015-10-23 11:35:33 +08:00
parent 4a6134f3f7
commit e36d455d51
8 changed files with 31 additions and 14 deletions

View file

@ -230,23 +230,9 @@ NativeWindowViews::NativeWindowViews(
// Add web view.
SetLayoutManager(new MenuLayout(this, kMenuBarHeight));
// web views' background color.
SkColor background_color = SK_ColorWHITE;
std::string color_name;
if (options.Get(switches::kBackgroundColor, &color_name))
background_color = ParseHexColor(color_name);
set_background(views::Background::CreateSolidBackground(background_color));
AddChildView(web_view_);
#if defined(OS_WIN)
// Set the background color of native window.
HBRUSH brush = CreateSolidBrush(skia::SkColorToCOLORREF(background_color));
ULONG_PTR previous_brush = SetClassLongPtr(
GetAcceleratedWidget(), GCLP_HBRBACKGROUND, (LONG)brush);
if (previous_brush)
DeleteObject((HBRUSH)previous_brush);
// Save initial window state.
if (fullscreen)
last_window_state_ = ui::SHOW_STATE_FULLSCREEN;
@ -534,6 +520,21 @@ bool NativeWindowViews::IsKiosk() {
return IsFullscreen();
}
void NativeWindowViews::SetBackgroundColor(const std::string& color_name) {
// web views' background color.
SkColor background_color = ParseHexColor(color_name);
set_background(views::Background::CreateSolidBackground(background_color));
#if defined(OS_WIN)
// Set the background color of native window.
HBRUSH brush = CreateSolidBrush(skia::SkColorToCOLORREF(background_color));
ULONG_PTR previous_brush = SetClassLongPtr(
GetAcceleratedWidget(), GCLP_HBRBACKGROUND, (LONG)brush);
if (previous_brush)
DeleteObject((HBRUSH)previous_brush);
#endif
}
void NativeWindowViews::SetMenu(ui::MenuModel* menu_model) {
if (menu_model == nullptr) {
// Remove accelerators