Add GTK_ALIGN_BASELINE to GtkAlign

Setting this means baseline aware containers should align the widget
according to the baseline. For other containers this behaves like
FILL.

In order to not suprise old code with a new enum value we always
return _FILL for _BASELINE unless you specifically request it via
gtk_widget_get_valign_with_baseline().
This commit is contained in:
Alexander Larsson
2013-03-05 15:06:12 +01:00
parent 655c781b6e
commit f15bc7818e
3 changed files with 22 additions and 3 deletions

View File

@ -51,6 +51,7 @@ G_BEGIN_DECLS
* or top * or top
* @GTK_ALIGN_CENTER: center natural width of widget inside the * @GTK_ALIGN_CENTER: center natural width of widget inside the
* allocation * allocation
* @GTK_ALIGN_BASELINE: align the widget according to the baseline. Since 3.10.
* *
* Controls how a widget deals with extra space in a single (x or y) * Controls how a widget deals with extra space in a single (x or y)
* dimension. * dimension.
@ -64,13 +65,18 @@ G_BEGIN_DECLS
* *
* Note that in horizontal context @GTK_ALIGN_START and @GTK_ALIGN_END * Note that in horizontal context @GTK_ALIGN_START and @GTK_ALIGN_END
* are interpreted relative to text direction. * are interpreted relative to text direction.
*
* GTK_ALIGN_BASELINE support for it is optional for containers and widgets, and
* it is only supported for vertical alignment. When its not supported by
* a child or a container it is treated as @GTK_ALIGN_FILL.
*/ */
typedef enum typedef enum
{ {
GTK_ALIGN_FILL, GTK_ALIGN_FILL,
GTK_ALIGN_START, GTK_ALIGN_START,
GTK_ALIGN_END, GTK_ALIGN_END,
GTK_ALIGN_CENTER GTK_ALIGN_CENTER,
GTK_ALIGN_BASELINE
} GtkAlign; } GtkAlign;

View File

@ -5721,6 +5721,7 @@ adjust_for_align (GtkAlign align,
{ {
switch (align) switch (align)
{ {
case GTK_ALIGN_BASELINE:
case GTK_ALIGN_FILL: case GTK_ALIGN_FILL:
/* change nothing */ /* change nothing */
break; break;
@ -13518,6 +13519,13 @@ gtk_widget_set_halign (GtkWidget *widget,
g_object_notify (G_OBJECT (widget), "halign"); g_object_notify (G_OBJECT (widget), "halign");
} }
GtkAlign
gtk_widget_get_valign_with_baseline (GtkWidget *widget)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL);
return _gtk_widget_get_aux_info_or_defaults (widget)->valign;
}
/** /**
* gtk_widget_get_valign: * gtk_widget_get_valign:
* @widget: a #GtkWidget * @widget: a #GtkWidget
@ -13529,8 +13537,12 @@ gtk_widget_set_halign (GtkWidget *widget,
GtkAlign GtkAlign
gtk_widget_get_valign (GtkWidget *widget) gtk_widget_get_valign (GtkWidget *widget)
{ {
g_return_val_if_fail (GTK_IS_WIDGET (widget), GTK_ALIGN_FILL); GtkAlign align;
return _gtk_widget_get_aux_info_or_defaults (widget)->valign;
align = gtk_widget_get_valign_with_baseline (widget);
if (align == GTK_ALIGN_BASELINE)
return GTK_ALIGN_FILL;
return align;
} }
/** /**

View File

@ -760,6 +760,7 @@ GtkAlign gtk_widget_get_halign (GtkWidget *widget);
void gtk_widget_set_halign (GtkWidget *widget, void gtk_widget_set_halign (GtkWidget *widget,
GtkAlign align); GtkAlign align);
GtkAlign gtk_widget_get_valign (GtkWidget *widget); GtkAlign gtk_widget_get_valign (GtkWidget *widget);
GtkAlign gtk_widget_get_valign_with_baseline (GtkWidget *widget);
void gtk_widget_set_valign (GtkWidget *widget, void gtk_widget_set_valign (GtkWidget *widget,
GtkAlign align); GtkAlign align);
gint gtk_widget_get_margin_left (GtkWidget *widget); gint gtk_widget_get_margin_left (GtkWidget *widget);