mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-07 11:20:09 +00:00
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.
This commit is contained in:
parent
629bb5a265
commit
24950ec144
@ -1517,6 +1517,7 @@ gtk_extended_layout_get_type G_GNUC_CONST
|
|||||||
gtk_extended_layout_get_desired_size
|
gtk_extended_layout_get_desired_size
|
||||||
gtk_extended_layout_get_height_for_width
|
gtk_extended_layout_get_height_for_width
|
||||||
gtk_extended_layout_get_width_for_height
|
gtk_extended_layout_get_width_for_height
|
||||||
|
gtk_extended_layout_is_height_for_width
|
||||||
#endif
|
#endif
|
||||||
#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_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:
|
* gtk_extended_layout_get_width_for_height:
|
||||||
* @layout: a #GtkExtendedLayout instance
|
* @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));
|
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 = GTK_EXTENDED_LAYOUT_GET_IFACE (layout);
|
||||||
iface->get_width_for_height (layout, height, minimum_width, natural_width);
|
iface->get_width_for_height (layout, height, minimum_width, natural_width);
|
||||||
|
|
||||||
|
@ -42,14 +42,19 @@ struct _GtkExtendedLayoutIface
|
|||||||
|
|
||||||
/* virtual table */
|
/* virtual table */
|
||||||
|
|
||||||
void (*get_desired_size) (GtkExtendedLayout *layout,
|
|
||||||
|
/* TODO: Change for get_desired_width()/get_desired_height() for clarity sake */
|
||||||
|
void (* get_desired_size) (GtkExtendedLayout *layout,
|
||||||
GtkRequisition *minimum_size,
|
GtkRequisition *minimum_size,
|
||||||
GtkRequisition *natural_size);
|
GtkRequisition *natural_size);
|
||||||
void (*get_width_for_height) (GtkExtendedLayout *layout,
|
|
||||||
|
gboolean (* is_height_for_width) (GtkExtendedLayout *layout);
|
||||||
|
|
||||||
|
void (* get_width_for_height) (GtkExtendedLayout *layout,
|
||||||
gint height,
|
gint height,
|
||||||
gint *minimum_width,
|
gint *minimum_width,
|
||||||
gint *natural_width);
|
gint *natural_width);
|
||||||
void (*get_height_for_width) (GtkExtendedLayout *layout,
|
void (* get_height_for_width) (GtkExtendedLayout *layout,
|
||||||
gint width,
|
gint width,
|
||||||
gint *minimum_height,
|
gint *minimum_height,
|
||||||
gint *natural_height);
|
gint *natural_height);
|
||||||
@ -60,6 +65,9 @@ GType gtk_extended_layout_get_type (void) G_GNUC_CONST;
|
|||||||
void gtk_extended_layout_get_desired_size (GtkExtendedLayout *layout,
|
void gtk_extended_layout_get_desired_size (GtkExtendedLayout *layout,
|
||||||
GtkRequisition *minimum_size,
|
GtkRequisition *minimum_size,
|
||||||
GtkRequisition *natural_size);
|
GtkRequisition *natural_size);
|
||||||
|
|
||||||
|
|
||||||
|
gboolean gtk_extended_layout_is_height_for_width (GtkExtendedLayout *layout);
|
||||||
void gtk_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
|
void gtk_extended_layout_get_width_for_height (GtkExtendedLayout *layout,
|
||||||
gint height,
|
gint height,
|
||||||
gint *minimum_width,
|
gint *minimum_width,
|
||||||
@ -69,6 +77,7 @@ void gtk_extended_layout_get_height_for_width (GtkExtendedLayout *layout,
|
|||||||
gint *minimum_height,
|
gint *minimum_height,
|
||||||
gint *natural_height);
|
gint *natural_height);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_EXTENDED_LAYOUT_H__ */
|
#endif /* __GTK_EXTENDED_LAYOUT_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user