diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 04:04:10 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-12 04:04:10 +0000 |
commit | fab194c0a29d3b19d12f198fde00647455644398 (patch) | |
tree | 79091489356f9f6429ddb300e63f4ac4ac73a2fa /views | |
parent | 5c7c41ad79c21366a9a27b4fea114b2ebf8fbc58 (diff) | |
download | chromium_src-fab194c0a29d3b19d12f198fde00647455644398.zip chromium_src-fab194c0a29d3b19d12f198fde00647455644398.tar.gz chromium_src-fab194c0a29d3b19d12f198fde00647455644398.tar.bz2 |
Implements WidgetGtk::SetOpacity.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/164346
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23169 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/widget/widget_gtk.cc | 14 | ||||
-rw-r--r-- | views/widget/widget_gtk.h | 2 |
2 files changed, 13 insertions, 3 deletions
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 8a65022..6534cca 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -68,7 +68,8 @@ WidgetGtk::WidgetGtk(Type type) last_mouse_event_was_move_(false), ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), delete_on_destroy_(true), - transparent_(false) { + transparent_(false), + opacity_(255) { if (type_ != TYPE_CHILD) focus_manager_.reset(new FocusManager(this)); } @@ -136,6 +137,9 @@ void WidgetGtk::Init(GtkWidget* parent, // Make container here. CreateGtkWidget(parent, bounds); + if (opacity_ != 255) + SetOpacity(opacity_); + // Make sure we receive our motion events. // In general we register most events on the parent of all widgets. At a @@ -317,8 +321,12 @@ void WidgetGtk::PaintNow(const gfx::Rect& update_rect) { } void WidgetGtk::SetOpacity(unsigned char opacity) { - // TODO(port): implement this feature. - NOTIMPLEMENTED(); + opacity_ = opacity; + if (widget_) { + // We can only set the opacity when the widget has been realized. + gdk_window_set_opacity(widget_->window, static_cast<gdouble>(opacity) / + static_cast<gdouble>(255)); + } } RootView* WidgetGtk::GetRootView() { diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h index b3308c4..f8c6a20 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/widget_gtk.h @@ -253,6 +253,8 @@ class WidgetGtk : public Widget, public MessageLoopForUI::Observer { scoped_ptr<DefaultThemeProvider> default_theme_provider_; + unsigned char opacity_; + DISALLOW_COPY_AND_ASSIGN(WidgetGtk); }; |