[gtk+/grid-widget: 16/20] Fix some cornercases of the height-for-width implementation
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/grid-widget: 16/20] Fix some cornercases of the height-for-width implementation
- Date: Fri, 15 Oct 2010 00:06:06 +0000 (UTC)
commit c02c6a52c132447d4fa13cf060202d78a034dde2
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Oct 10 14:47:20 2010 -0400
Fix some cornercases of the height-for-width implementation
* get_preferred_height just returns the preferred height for
the minimum width when called in height-for-width mode.
* get_preferred_width_for_height just returns the preferred
width when called in height-for-width mode.
* get_preferred_height_for_width never returns a height for
width that is smaller than the minimal width.
gtk/gtkgrid.c | 36 +++++++++++++++++++++++++-----------
1 files changed, 25 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c
index e5d03fb..3c5b473 100644
--- a/gtk/gtkgrid.c
+++ b/gtk/gtkgrid.c
@@ -1087,8 +1087,11 @@ gtk_grid_get_size_for_orientation (GtkGrid *grid,
gint *minimum,
gint *natural)
{
+ gint min_size;
+
gtk_grid_request_lines (grid, 1 - orientation, FALSE);
- gtk_grid_allocate_lines (grid, 1 - orientation, size);
+ gtk_grid_request_sum (grid, 1 - orientation, &min_size, NULL);
+ gtk_grid_allocate_lines (grid, 1 - orientation, MAX (size, min_size));
gtk_grid_request_lines (grid, orientation, TRUE);
gtk_grid_request_sum (grid, orientation, minimum, natural);
}
@@ -1098,7 +1101,13 @@ gtk_grid_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
- gtk_grid_get_size (GTK_GRID (widget), GTK_ORIENTATION_HORIZONTAL, minimum, natural);
+ GtkGrid *grid = GTK_GRID (widget);
+
+ if (gtk_grid_get_request_mode (widget) == GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT)
+
+ gtk_grid_get_size_for_orientation (grid, GTK_ORIENTATION_HORIZONTAL, 0, minimum, natural);
+ else
+ gtk_grid_get_size (grid, GTK_ORIENTATION_HORIZONTAL, minimum, natural);
}
static void
@@ -1106,7 +1115,12 @@ gtk_grid_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
- gtk_grid_get_size (GTK_GRID (widget), GTK_ORIENTATION_VERTICAL, minimum, natural);
+ GtkGrid *grid = GTK_GRID (widget);
+
+ if (gtk_grid_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
+ gtk_grid_get_size_for_orientation (grid, GTK_ORIENTATION_VERTICAL, 0, minimum, natural);
+ else
+ gtk_grid_get_size (grid, GTK_ORIENTATION_VERTICAL, minimum, natural);
}
static void
@@ -1117,10 +1131,10 @@ gtk_grid_get_preferred_width_for_height (GtkWidget *widget,
{
GtkGrid *grid = GTK_GRID (widget);
- if (gtk_grid_get_request_mode (widget) != GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT)
- gtk_grid_get_size (grid, GTK_ORIENTATION_VERTICAL, &height, NULL);
-
- gtk_grid_get_size_for_orientation (grid, GTK_ORIENTATION_HORIZONTAL, height, minimum, natural);
+ if (gtk_grid_get_request_mode (widget) == GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT)
+ gtk_grid_get_size_for_orientation (grid, GTK_ORIENTATION_HORIZONTAL, height, minimum, natural);
+ else
+ gtk_grid_get_size (grid, GTK_ORIENTATION_HORIZONTAL, minimum, natural);
}
static void
@@ -1131,10 +1145,10 @@ gtk_grid_get_preferred_height_for_width (GtkWidget *widget,
{
GtkGrid *grid = GTK_GRID (widget);
- if (gtk_grid_get_request_mode (widget) != GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
- gtk_grid_get_size (grid, GTK_ORIENTATION_HORIZONTAL, &width, NULL);
-
- gtk_grid_get_size_for_orientation (grid, GTK_ORIENTATION_VERTICAL, width, minimum, natural);
+ if (gtk_grid_get_request_mode (widget) == GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH)
+ gtk_grid_get_size_for_orientation (grid, GTK_ORIENTATION_VERTICAL, width, minimum, natural);
+ else
+ gtk_grid_get_size (grid, GTK_ORIENTATION_VERTICAL, minimum, natural);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]