summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-05 07:57:10 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-05 07:57:10 +0000
commitf861719588545d92ba979f491f4cd10cbf544016 (patch)
tree5f5a64d4ba48a8d884ee360a562fb08371404ed6 /views/widget
parent84aa957953cf6eb36c4e8886a28aede5fd98f748 (diff)
downloadchromium_src-f861719588545d92ba979f491f4cd10cbf544016.zip
chromium_src-f861719588545d92ba979f491f4cd10cbf544016.tar.gz
chromium_src-f861719588545d92ba979f491f4cd10cbf544016.tar.bz2
Re-land r51526
Auto-size the views version of the options dialog. This adds support for auto-sizing tab controls, adjusts the options dialog to use it and takes care of any fallout due to the new layout handling. Also fixes a couple of small bugs in the views Layout() machinery and sanitizes layouting of options pages. BUG=36497 TEST=unit tests in tabbed_pane_unittest.cc and grid_layout_unittest.cc, as well as checking the options dialog in any supported language. original issuse: http://codereview.chromium.org/2812026/show Review URL: http://codereview.chromium.org/2883022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51628 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/widget_gtk.cc14
-rw-r--r--views/widget/widget_gtk.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 1e73e38..c9144d7 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -500,6 +500,8 @@ void WidgetGtk::Init(GtkWidget* parent,
GDK_KEY_RELEASE_MASK);
SetRootViewForWidget(widget_, root_view_.get());
+ g_signal_connect_after(G_OBJECT(window_contents_), "size_request",
+ G_CALLBACK(&OnSizeRequestThunk), this);
g_signal_connect_after(G_OBJECT(window_contents_), "size_allocate",
G_CALLBACK(&OnSizeAllocateThunk), this);
gtk_widget_set_app_paintable(window_contents_, true);
@@ -883,6 +885,18 @@ int WidgetGtk::GetFlagsForEventButton(const GdkEventButton& event) {
return flags;
}
+void WidgetGtk::OnSizeRequest(GtkWidget* widget, GtkRequisition* requisition) {
+ // Do only return the preferred size for child windows. GtkWindow interprets
+ // the requisition as a minimum size for top level windows, returning a
+ // preferred size for these would prevents us from setting smaller window
+ // sizes.
+ if (type_ == TYPE_CHILD) {
+ gfx::Size size(root_view_->GetPreferredSize());
+ requisition->width = size.width();
+ requisition->height = size.height();
+ }
+}
+
void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) {
// See comment next to size_ as to why we do this. Also note, it's tempting
// to put this in the static method so subclasses don't need to worry about
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h
index 816a263..3700aa3 100644
--- a/views/widget/widget_gtk.h
+++ b/views/widget/widget_gtk.h
@@ -223,6 +223,7 @@ class WidgetGtk
// Event handlers:
CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnButtonPress, GdkEventButton*);
+ CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnSizeRequest, GtkRequisition*);
CHROMEGTK_CALLBACK_1(WidgetGtk, void, OnSizeAllocate, GtkAllocation*);
CHROMEGTK_CALLBACK_1(WidgetGtk, gboolean, OnPaint, GdkEventExpose*);
CHROMEGTK_CALLBACK_4(WidgetGtk, void, OnDragDataGet,