diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 19:20:49 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 19:20:49 +0000 |
commit | f6017e4335b3ca6a13b64325cfab48291f84514a (patch) | |
tree | 2080982d2f4ec9226db7d633850799c7711bdbf3 /views/controls/button | |
parent | cf61462348b622940a74a73d024e17415217cfd4 (diff) | |
download | chromium_src-f6017e4335b3ca6a13b64325cfab48291f84514a.zip chromium_src-f6017e4335b3ca6a13b64325cfab48291f84514a.tar.gz chromium_src-f6017e4335b3ca6a13b64325cfab48291f84514a.tar.bz2 |
Fix NativeViewHostGtk clipping.
Basically, I introduce an additional GtkFixed into the GtkWidget hierarchy. When clipping is required, this is re-created with a X Window and clipping is performed. For some reason, Gtk+Cairo won't clip rendering to the parent GtkWidget if there isn't an associated X Window.
This also fixes the GetPreferredSize implementation for NativeButtonGtk which would return ever increasing values of size each time it was called.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/159153
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21423 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/button')
-rw-r--r-- | views/controls/button/native_button_gtk.cc | 13 | ||||
-rw-r--r-- | views/controls/button/native_button_gtk.h | 6 |
2 files changed, 16 insertions, 3 deletions
diff --git a/views/controls/button/native_button_gtk.cc b/views/controls/button/native_button_gtk.cc index 1680019..7bd4da6 100644 --- a/views/controls/button/native_button_gtk.cc +++ b/views/controls/button/native_button_gtk.cc @@ -34,6 +34,7 @@ void NativeButtonGtk::UpdateLabel() { gtk_button_set_label(GTK_BUTTON(native_view()), WideToUTF8(native_button_->label()).c_str()); + preferred_size_ = gfx::Size(); } void NativeButtonGtk::UpdateFont() { @@ -41,6 +42,7 @@ void NativeButtonGtk::UpdateFont() { return; NOTIMPLEMENTED(); + preferred_size_ = gfx::Size(); // SendMessage(GetHWND(), WM_SETFONT, // reinterpret_cast<WPARAM>(native_button_->font().hfont()), // FALSE); @@ -75,9 +77,14 @@ gfx::NativeView NativeButtonGtk::GetTestingHandle() const { gfx::Size NativeButtonGtk::GetPreferredSize() { if (!native_view()) return gfx::Size(); - GtkRequisition size_request = { 0, 0 }; - gtk_widget_size_request(native_view(), &size_request); - return gfx::Size(size_request.width, size_request.height); + + if (preferred_size_.IsEmpty()) { + GtkRequisition size_request = { 0, 0 }; + gtk_widget_size_request(native_view(), &size_request); + preferred_size_.SetSize(size_request.width, + std::max(size_request.height, 29)); + } + return preferred_size_; } void NativeButtonGtk::CreateNativeControl() { diff --git a/views/controls/button/native_button_gtk.h b/views/controls/button/native_button_gtk.h index 6c3f600..1d0dfc1 100644 --- a/views/controls/button/native_button_gtk.h +++ b/views/controls/button/native_button_gtk.h @@ -44,6 +44,12 @@ class NativeButtonGtk : public NativeControlGtk, public NativeButtonWrapper { // The NativeButton we are bound to. NativeButton* native_button_; + // The preferred size from the last size_request. We save this until we are + // notified that data may have caused the preferred size to change because + // otherwise it seems every time we call gtk_widget_size_request the size + // returned is a little larger (?!). + gfx::Size preferred_size_; + DISALLOW_COPY_AND_ASSIGN(NativeButtonGtk); }; |