Partial fix for the toolbox problem... it's still not perfect.

2000-02-03  Kelly Lynn Martin  <kelly@poverty.bloomington.in.us>

	* app/gtkhwrapbox.c (layout_row, layout_rows):
	* app/gtkvwrapbox.c (layout_col, layout_cols):
	Partial fix for the toolbox problem... it's still not perfect.
This commit is contained in:
Kelly Lynn Martin 2000-02-03 03:10:05 +00:00 committed by Kelly Martin
parent 6ec1b424a4
commit 608ddcb1b7
5 changed files with 114 additions and 34 deletions

View File

@ -1,3 +1,9 @@
2000-02-03 Kelly Lynn Martin <kelly@poverty.bloomington.in.us>
* app/gtkhwrapbox.c (layout_row, layout_rows):
* app/gtkvwrapbox.c (layout_col, layout_cols):
Partial fix for the toolbox problem... it's still not perfect.
Fri Feb 4 01:29:08 CET 2000 Sven Neumann <sven@gimp.org> Fri Feb 4 01:29:08 CET 2000 Sven Neumann <sven@gimp.org>
* libgimp/gimpcolorbutton.c: documented GimpColorButton * libgimp/gimpcolorbutton.c: documented GimpColorButton

View File

@ -345,7 +345,8 @@ layout_row (GtkWrapBox *wbox,
GtkAllocation *area, GtkAllocation *area,
GSList *children, GSList *children,
guint children_per_line, guint children_per_line,
gboolean vexpand) gboolean vexpand,
gint *shortfall)
{ {
GSList *slist; GSList *slist;
guint n_children = 0, n_expand_children = 0, have_expand_children = 0, total_width = 0; guint n_children = 0, n_expand_children = 0, have_expand_children = 0, total_width = 0;
@ -358,7 +359,7 @@ layout_row (GtkWrapBox *wbox,
GtkRequisition child_requisition; GtkRequisition child_requisition;
n_children++; n_children++;
if (child->hexpand) if (child->hexpand || wbox->justify == GTK_JUSTIFY_FILL)
n_expand_children++; n_expand_children++;
get_child_requisition (wbox, child->widget, &child_requisition); get_child_requisition (wbox, child->widget, &child_requisition);
@ -366,10 +367,14 @@ layout_row (GtkWrapBox *wbox,
} }
width = MAX (1, area->width - (n_children - 1) * wbox->hspacing); width = MAX (1, area->width - (n_children - 1) * wbox->hspacing);
if (width > total_width) extra = width - total_width;
extra = width - total_width; if (extra < 0)
else {
extra = 0; g_warning("gtkhwrapbox: not enough space!\n");
if (shortfall && *shortfall < -extra)
*shortfall = -extra;
extra = 0;
}
have_expand_children = n_expand_children && extra; have_expand_children = n_expand_children && extra;
x = area->x; x = area->x;
@ -410,6 +415,12 @@ layout_row (GtkWrapBox *wbox,
width = 0; width = 0;
extra = 0; extra = 0;
} }
else
{
g_warning("gtkhwrapbox: unhandled wbox justification");
width = 0;
extra = 0;
}
} }
n_children = 0; n_children = 0;
@ -447,6 +458,7 @@ layout_row (GtkWrapBox *wbox,
if (have_expand_children) if (have_expand_children)
{ {
child_allocation.width = child_requisition.width; child_allocation.width = child_requisition.width;
if (child->hexpand || wbox->justify == GTK_JUSTIFY_FILL) if (child->hexpand || wbox->justify == GTK_JUSTIFY_FILL)
{ {
guint space; guint space;
@ -468,7 +480,7 @@ layout_row (GtkWrapBox *wbox,
{ {
/* g_print ("child_allocation.x %d += %d * %f ", /* g_print ("child_allocation.x %d += %d * %f ",
child_allocation.x, n_children, extra); */ child_allocation.x, n_children, extra); */
child_allocation.x += n_children * extra; child_allocation.x += (n_children * extra) / 2;
/* g_print ("= %d\n", /* g_print ("= %d\n",
child_allocation.x); */ child_allocation.x); */
child_allocation.width = MIN (child_requisition.width, child_allocation.width = MIN (child_requisition.width,
@ -503,6 +515,7 @@ layout_rows (GtkWrapBox *wbox,
guint total_height = 0, n_expand_lines = 0, n_lines = 0; guint total_height = 0, n_expand_lines = 0, n_lines = 0;
gfloat shrink_height; gfloat shrink_height;
guint children_per_line; guint children_per_line;
gint shortfall = 0;
next_child = wbox->children; next_child = wbox->children;
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox, slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
@ -619,13 +632,18 @@ layout_rows (GtkWrapBox *wbox,
&row_allocation, &row_allocation,
line->children, line->children,
children_per_line, children_per_line,
line->expand); line->expand,
&shortfall);
g_slist_free (line->children); g_slist_free (line->children);
g_free (line); g_free (line);
line = next_line; line = next_line;
} }
} }
if (shortfall > 0)
{
g_warning("hwrapbox too small, shortfall is %d\n", shortfall);
}
} }
static void static void

View File

@ -345,7 +345,8 @@ layout_col (GtkWrapBox *wbox,
GtkAllocation *area, GtkAllocation *area,
GSList *children, GSList *children,
guint children_per_line, guint children_per_line,
gboolean hexpand) gboolean hexpand,
gint *shortfall)
{ {
GSList *slist; GSList *slist;
guint n_children = 0, n_expand_children = 0, have_expand_children = 0, total_height = 0; guint n_children = 0, n_expand_children = 0, have_expand_children = 0, total_height = 0;
@ -358,7 +359,7 @@ layout_col (GtkWrapBox *wbox,
GtkRequisition child_requisition; GtkRequisition child_requisition;
n_children++; n_children++;
if (child->vexpand) if (child->vexpand || wbox->justify == GTK_JUSTIFY_FILL)
n_expand_children++; n_expand_children++;
get_child_requisition (wbox, child->widget, &child_requisition); get_child_requisition (wbox, child->widget, &child_requisition);
@ -366,10 +367,15 @@ layout_col (GtkWrapBox *wbox,
} }
height = MAX (1, area->height - (n_children - 1) * wbox->vspacing); height = MAX (1, area->height - (n_children - 1) * wbox->vspacing);
if (height > total_height) extra = height - total_height;
extra = height - total_height;
else if (extra < 0)
extra = 0; {
g_warning("gtkvwrapbox: not enough space!\n");
if (shortfall && *shortfall < -extra)
*shortfall = -extra;
extra = 0;
}
have_expand_children = n_expand_children && extra; have_expand_children = n_expand_children && extra;
y = area->y; y = area->y;
@ -409,9 +415,15 @@ layout_col (GtkWrapBox *wbox,
y += extra; y += extra;
height = 0; height = 0;
extra = 0; extra = 0;
}
else
{
g_warning ("gtkvwrapbox: unhandled wbox justification");
height = 0;
extra = 0;
} }
} }
n_children = 0; n_children = 0;
for (slist = children; slist; slist = slist->next) for (slist = children; slist; slist = slist->next)
{ {
@ -447,6 +459,7 @@ layout_col (GtkWrapBox *wbox,
if (have_expand_children) if (have_expand_children)
{ {
child_allocation.height = child_requisition.height; child_allocation.height = child_requisition.height;
if (child->vexpand || wbox->justify == GTK_JUSTIFY_FILL) if (child->vexpand || wbox->justify == GTK_JUSTIFY_FILL)
{ {
guint space; guint space;
@ -503,6 +516,7 @@ layout_cols (GtkWrapBox *wbox,
guint total_width = 0, n_expand_lines = 0, n_lines = 0; guint total_width = 0, n_expand_lines = 0, n_lines = 0;
gfloat shrink_width; gfloat shrink_width;
guint children_per_line; guint children_per_line;
gint shortfall = 0;
next_child = wbox->children; next_child = wbox->children;
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox, slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
@ -619,13 +633,18 @@ layout_cols (GtkWrapBox *wbox,
&col_allocation, &col_allocation,
line->children, line->children,
children_per_line, children_per_line,
line->expand); line->expand,
&shortfall);
g_slist_free (line->children); g_slist_free (line->children);
g_free (line); g_free (line);
line = next_line; line = next_line;
} }
} }
if (shortfall > 0)
{
g_warning("vwrapbox too small, shortfall is %d\n", shortfall);
}
} }
static void static void

View File

@ -345,7 +345,8 @@ layout_row (GtkWrapBox *wbox,
GtkAllocation *area, GtkAllocation *area,
GSList *children, GSList *children,
guint children_per_line, guint children_per_line,
gboolean vexpand) gboolean vexpand,
gint *shortfall)
{ {
GSList *slist; GSList *slist;
guint n_children = 0, n_expand_children = 0, have_expand_children = 0, total_width = 0; guint n_children = 0, n_expand_children = 0, have_expand_children = 0, total_width = 0;
@ -358,7 +359,7 @@ layout_row (GtkWrapBox *wbox,
GtkRequisition child_requisition; GtkRequisition child_requisition;
n_children++; n_children++;
if (child->hexpand) if (child->hexpand || wbox->justify == GTK_JUSTIFY_FILL)
n_expand_children++; n_expand_children++;
get_child_requisition (wbox, child->widget, &child_requisition); get_child_requisition (wbox, child->widget, &child_requisition);
@ -366,10 +367,14 @@ layout_row (GtkWrapBox *wbox,
} }
width = MAX (1, area->width - (n_children - 1) * wbox->hspacing); width = MAX (1, area->width - (n_children - 1) * wbox->hspacing);
if (width > total_width) extra = width - total_width;
extra = width - total_width; if (extra < 0)
else {
extra = 0; g_warning("gtkhwrapbox: not enough space!\n");
if (shortfall && *shortfall < -extra)
*shortfall = -extra;
extra = 0;
}
have_expand_children = n_expand_children && extra; have_expand_children = n_expand_children && extra;
x = area->x; x = area->x;
@ -410,6 +415,12 @@ layout_row (GtkWrapBox *wbox,
width = 0; width = 0;
extra = 0; extra = 0;
} }
else
{
g_warning("gtkhwrapbox: unhandled wbox justification");
width = 0;
extra = 0;
}
} }
n_children = 0; n_children = 0;
@ -447,6 +458,7 @@ layout_row (GtkWrapBox *wbox,
if (have_expand_children) if (have_expand_children)
{ {
child_allocation.width = child_requisition.width; child_allocation.width = child_requisition.width;
if (child->hexpand || wbox->justify == GTK_JUSTIFY_FILL) if (child->hexpand || wbox->justify == GTK_JUSTIFY_FILL)
{ {
guint space; guint space;
@ -468,7 +480,7 @@ layout_row (GtkWrapBox *wbox,
{ {
/* g_print ("child_allocation.x %d += %d * %f ", /* g_print ("child_allocation.x %d += %d * %f ",
child_allocation.x, n_children, extra); */ child_allocation.x, n_children, extra); */
child_allocation.x += n_children * extra; child_allocation.x += (n_children * extra) / 2;
/* g_print ("= %d\n", /* g_print ("= %d\n",
child_allocation.x); */ child_allocation.x); */
child_allocation.width = MIN (child_requisition.width, child_allocation.width = MIN (child_requisition.width,
@ -503,6 +515,7 @@ layout_rows (GtkWrapBox *wbox,
guint total_height = 0, n_expand_lines = 0, n_lines = 0; guint total_height = 0, n_expand_lines = 0, n_lines = 0;
gfloat shrink_height; gfloat shrink_height;
guint children_per_line; guint children_per_line;
gint shortfall = 0;
next_child = wbox->children; next_child = wbox->children;
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox, slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
@ -619,13 +632,18 @@ layout_rows (GtkWrapBox *wbox,
&row_allocation, &row_allocation,
line->children, line->children,
children_per_line, children_per_line,
line->expand); line->expand,
&shortfall);
g_slist_free (line->children); g_slist_free (line->children);
g_free (line); g_free (line);
line = next_line; line = next_line;
} }
} }
if (shortfall > 0)
{
g_warning("hwrapbox too small, shortfall is %d\n", shortfall);
}
} }
static void static void

View File

@ -345,7 +345,8 @@ layout_col (GtkWrapBox *wbox,
GtkAllocation *area, GtkAllocation *area,
GSList *children, GSList *children,
guint children_per_line, guint children_per_line,
gboolean hexpand) gboolean hexpand,
gint *shortfall)
{ {
GSList *slist; GSList *slist;
guint n_children = 0, n_expand_children = 0, have_expand_children = 0, total_height = 0; guint n_children = 0, n_expand_children = 0, have_expand_children = 0, total_height = 0;
@ -358,7 +359,7 @@ layout_col (GtkWrapBox *wbox,
GtkRequisition child_requisition; GtkRequisition child_requisition;
n_children++; n_children++;
if (child->vexpand) if (child->vexpand || wbox->justify == GTK_JUSTIFY_FILL)
n_expand_children++; n_expand_children++;
get_child_requisition (wbox, child->widget, &child_requisition); get_child_requisition (wbox, child->widget, &child_requisition);
@ -366,10 +367,15 @@ layout_col (GtkWrapBox *wbox,
} }
height = MAX (1, area->height - (n_children - 1) * wbox->vspacing); height = MAX (1, area->height - (n_children - 1) * wbox->vspacing);
if (height > total_height) extra = height - total_height;
extra = height - total_height;
else if (extra < 0)
extra = 0; {
g_warning("gtkvwrapbox: not enough space!\n");
if (shortfall && *shortfall < -extra)
*shortfall = -extra;
extra = 0;
}
have_expand_children = n_expand_children && extra; have_expand_children = n_expand_children && extra;
y = area->y; y = area->y;
@ -409,9 +415,15 @@ layout_col (GtkWrapBox *wbox,
y += extra; y += extra;
height = 0; height = 0;
extra = 0; extra = 0;
}
else
{
g_warning ("gtkvwrapbox: unhandled wbox justification");
height = 0;
extra = 0;
} }
} }
n_children = 0; n_children = 0;
for (slist = children; slist; slist = slist->next) for (slist = children; slist; slist = slist->next)
{ {
@ -447,6 +459,7 @@ layout_col (GtkWrapBox *wbox,
if (have_expand_children) if (have_expand_children)
{ {
child_allocation.height = child_requisition.height; child_allocation.height = child_requisition.height;
if (child->vexpand || wbox->justify == GTK_JUSTIFY_FILL) if (child->vexpand || wbox->justify == GTK_JUSTIFY_FILL)
{ {
guint space; guint space;
@ -503,6 +516,7 @@ layout_cols (GtkWrapBox *wbox,
guint total_width = 0, n_expand_lines = 0, n_lines = 0; guint total_width = 0, n_expand_lines = 0, n_lines = 0;
gfloat shrink_width; gfloat shrink_width;
guint children_per_line; guint children_per_line;
gint shortfall = 0;
next_child = wbox->children; next_child = wbox->children;
slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox, slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox,
@ -619,13 +633,18 @@ layout_cols (GtkWrapBox *wbox,
&col_allocation, &col_allocation,
line->children, line->children,
children_per_line, children_per_line,
line->expand); line->expand,
&shortfall);
g_slist_free (line->children); g_slist_free (line->children);
g_free (line); g_free (line);
line = next_line; line = next_line;
} }
} }
if (shortfall > 0)
{
g_warning("vwrapbox too small, shortfall is %d\n", shortfall);
}
} }
static void static void