diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-27 15:06:03 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-27 15:06:03 +0000 |
commit | 65e3abbad1e5d111675658f1df562c40389bbda5 (patch) | |
tree | a7aba3f6a60e08bf29d2cc90e2d343f3530b812c /chrome/browser | |
parent | 73ec57ae143da9b6a9a993b292b96156e90584e4 (diff) | |
download | chromium_src-65e3abbad1e5d111675658f1df562c40389bbda5.zip chromium_src-65e3abbad1e5d111675658f1df562c40389bbda5.tar.gz chromium_src-65e3abbad1e5d111675658f1df562c40389bbda5.tar.bz2 |
Draw background of Linux extension toolstrips.
This makes Linux extension shelf quite pretty now IMHO.
TEST=Just see it.
http://crbug.com/16759
Review URL: http://codereview.chromium.org/174585
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24605 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gtk/extension_shelf_gtk.cc | 17 | ||||
-rw-r--r-- | chrome/browser/gtk/extension_shelf_gtk.h | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/extension_view_gtk.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/extension_view_gtk.h | 3 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_gtk.cc | 5 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_gtk.h | 1 |
6 files changed, 36 insertions, 0 deletions
diff --git a/chrome/browser/gtk/extension_shelf_gtk.cc b/chrome/browser/gtk/extension_shelf_gtk.cc index 121f77d..0383dcc 100644 --- a/chrome/browser/gtk/extension_shelf_gtk.cc +++ b/chrome/browser/gtk/extension_shelf_gtk.cc @@ -37,6 +37,10 @@ class ExtensionShelfGtk::Toolstrip { void AddToolstripToBox(GtkWidget* box); void RemoveToolstripFromBox(GtkWidget* box); + void SetBackground(const SkBitmap& background) { + host_->view()->SetBackground(background); + } + private: void Init(); @@ -93,7 +97,9 @@ void ExtensionShelfGtk::Hide() { void ExtensionShelfGtk::ToolstripInsertedAt(ExtensionHost* host, int index) { + InitBackground(); Toolstrip* toolstrip = new Toolstrip(host); + toolstrip->SetBackground(*background_.get()); toolstrip->AddToolstripToBox(shelf_hbox_); toolstrips_.insert(toolstrip); model_->SetToolstripDataAt(index, toolstrip); @@ -188,6 +194,17 @@ void ExtensionShelfGtk::Init(Profile* profile) { model_->AddObserver(this); } +void ExtensionShelfGtk::InitBackground() { + if (background_.get()) + return; + background_.reset(new SkBitmap); + background_->setConfig(SkBitmap::kARGB_8888_Config, 3, 3); + background_->allocPixels(); + background_->eraseRGB(kBackgroundColor.red >> 8, + kBackgroundColor.green >> 8, + kBackgroundColor.blue >> 8); +} + void ExtensionShelfGtk::AdjustHeight() { if (model_->empty() || toolstrips_.empty()) { // It's possible that |model_| is not empty, but |toolstrips_| are empty diff --git a/chrome/browser/gtk/extension_shelf_gtk.h b/chrome/browser/gtk/extension_shelf_gtk.h index 550f9ec..4c124ebed 100644 --- a/chrome/browser/gtk/extension_shelf_gtk.h +++ b/chrome/browser/gtk/extension_shelf_gtk.h @@ -57,6 +57,9 @@ class ExtensionShelfGtk : public ExtensionShelfModelObserver, // Create the contents of the extension shelf. void Init(Profile* profile); + // Lazily initialize background bitmap. Can be called many times. + void InitBackground(); + // Determines what is our target height and sets it. void AdjustHeight(); @@ -80,6 +83,9 @@ class ExtensionShelfGtk : public ExtensionShelfModelObserver, // Used to position all children. GtkWidget* shelf_hbox_; + // Lazily-initialized background for toolstrips. + scoped_ptr<SkBitmap> background_; + GtkThemeProvider* theme_provider_; // The model representing the toolstrips on the shelf. diff --git a/chrome/browser/gtk/extension_view_gtk.cc b/chrome/browser/gtk/extension_view_gtk.cc index e2712cf..4c06cfb 100644 --- a/chrome/browser/gtk/extension_view_gtk.cc +++ b/chrome/browser/gtk/extension_view_gtk.cc @@ -28,6 +28,10 @@ RenderViewHost* ExtensionViewGtk::render_view_host() const { return extension_host_->render_view_host(); } +void ExtensionViewGtk::SetBackground(const SkBitmap& background) { + render_widget_host_view_->SetBackground(background); +} + void ExtensionViewGtk::UpdatePreferredWidth(int pref_width) { gtk_widget_set_size_request(native_view(), pref_width, -1); } diff --git a/chrome/browser/gtk/extension_view_gtk.h b/chrome/browser/gtk/extension_view_gtk.h index 495039d..7612c94 100644 --- a/chrome/browser/gtk/extension_view_gtk.h +++ b/chrome/browser/gtk/extension_view_gtk.h @@ -12,6 +12,7 @@ class Browser; class ExtensionHost; class RenderViewHost; class RenderWidgetHostViewGtk; +class SkBitmap; class ExtensionViewGtk { public: @@ -25,6 +26,8 @@ class ExtensionViewGtk { bool is_toolstrip() const { return is_toolstrip_; } void set_is_toolstrip(bool is_toolstrip) { is_toolstrip_ = is_toolstrip; } + void SetBackground(const SkBitmap& background); + // Method for the ExtensionHost to notify us about the correct width for // extension contents. void UpdatePreferredWidth(int pref_width); diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index 7516971..159e1cd 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -540,6 +540,11 @@ BackingStore* RenderWidgetHostViewGtk::AllocBackingStore( gtk_widget_get_visual(view_.get())->depth); } +void RenderWidgetHostViewGtk::SetBackground(const SkBitmap& background) { + RenderWidgetHostView::SetBackground(background); + host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); +} + void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { DCHECK(!about_to_validate_and_paint_); diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.h b/chrome/browser/renderer_host/render_widget_host_view_gtk.h index 97ec6cf..95b8c2d 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.h +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h @@ -64,6 +64,7 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView { virtual void PasteFromSelectionClipboard(); virtual void ShowingContextMenu(bool showing); virtual BackingStore* AllocBackingStore(const gfx::Size& size); + virtual void SetBackground(const SkBitmap& background); virtual void CreatePluginContainer(gfx::PluginWindowHandle id); virtual void DestroyPluginContainer(gfx::PluginWindowHandle id); |