Commit 24950ec1 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Added gtk_extended_layout_is_height_for_width()

Added an indicator telling whether a widget prefers to be allocated
as height-for-width or width-for-height. Usually this depends on the
orientation of a container or the nature of a content widget like GtkLabel.

This indicator is only used in the seldom case where a parent is allocating
free space to the child and the child can flow in either direction, GtkWindow
and GtkScrolledWindow are users of this api.
parent 629bb5a2
......@@ -1517,6 +1517,7 @@ gtk_extended_layout_get_type G_GNUC_CONST
gtk_extended_layout_get_desired_size
gtk_extended_layout_get_height_for_width
gtk_extended_layout_get_width_for_height
gtk_extended_layout_is_height_for_width
#endif
#endif
......
......@@ -70,6 +70,37 @@ gtk_extended_layout_get_desired_size (GtkExtendedLayout *layout,
_gtk_size_group_compute_desired_size (GTK_WIDGET (layout), minimum_size, natural_size);
}
/**
* gtk_extended_layout_is_height_for_width:
* @layout: a #GtkExtendedLayout instance
*
* Gets whether the widget prefers a height-for-width layout
* or a width-for-height layout
*
* Returns: %TRUE if the widget prefers height-for-width, %FALSE if
* the widget should be treated with a width-for-height preference.
*
* Since: 3.0
*/
gboolean
gtk_extended_layout_is_height_for_width (GtkExtendedLayout *layout)
{
GtkExtendedLayoutIface *iface;
g_return_val_if_fail (GTK_IS_EXTENDED_LAYOUT (layout), FALSE);
iface = GTK_EXTENDED_LAYOUT_GET_IFACE (layout);
if (iface->is_height_for_width)
return iface->is_height_for_width (layout);
/* By default widgets are height-for-width. */
return TRUE;
}
/**
* gtk_extended_layout_get_width_for_height:
* @layout: a #GtkExtendedLayout instance
......@@ -92,6 +123,12 @@ gtk_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
g_return_if_fail (GTK_IS_EXTENDED_LAYOUT (layout));
/* XXX Maybe here we do _gtk_size_group_compute_width_for_height()
* and return hard coded minimum widths/heights for for widgets with
* explicit size requests as well as fetch the common minimum/natural
* widths/heights for size grouped widgets.
*/
iface = GTK_EXTENDED_LAYOUT_GET_IFACE (layout);
iface->get_width_for_height (layout, height, minimum_width, natural_width);
......
......@@ -42,32 +42,41 @@ struct _GtkExtendedLayoutIface
/* virtual table */
void (*get_desired_size) (GtkExtendedLayout *layout,
GtkRequisition *minimum_size,
GtkRequisition *natural_size);
void (*get_width_for_height) (GtkExtendedLayout *layout,
gint height,
gint *minimum_width,
gint *natural_width);
void (*get_height_for_width) (GtkExtendedLayout *layout,
gint width,
gint *minimum_height,
gint *natural_height);
/* TODO: Change for get_desired_width()/get_desired_height() for clarity sake */
void (* get_desired_size) (GtkExtendedLayout *layout,
GtkRequisition *minimum_size,
GtkRequisition *natural_size);
gboolean (* is_height_for_width) (GtkExtendedLayout *layout);
void (* get_width_for_height) (GtkExtendedLayout *layout,
gint height,
gint *minimum_width,
gint *natural_width);
void (* get_height_for_width) (GtkExtendedLayout *layout,
gint width,
gint *minimum_height,
gint *natural_height);
};
GType gtk_extended_layout_get_type (void) G_GNUC_CONST;
void gtk_extended_layout_get_desired_size (GtkExtendedLayout *layout,
GtkRequisition *minimum_size,
GtkRequisition *natural_size);
void gtk_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
gint height,
gint *minimum_width,
gint *natural_width);
void gtk_extended_layout_get_height_for_width (GtkExtendedLayout *layout,
gint width,
gint *minimum_height,
gint *natural_height);
GType gtk_extended_layout_get_type (void) G_GNUC_CONST;
void gtk_extended_layout_get_desired_size (GtkExtendedLayout *layout,
GtkRequisition *minimum_size,
GtkRequisition *natural_size);
gboolean gtk_extended_layout_is_height_for_width (GtkExtendedLayout *layout);
void gtk_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
gint height,
gint *minimum_width,
gint *natural_width);
void gtk_extended_layout_get_height_for_width (GtkExtendedLayout *layout,
gint width,
gint *minimum_height,
gint *natural_height);
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment