if (in_measure)
{
g_warning ("%s %p: widget tried to gtk_widget_measure inside " " GtkWidget::measure implementation. " "Should just invoke GTK_WIDGET_GET_CLASS(widget)->measure " "directly rather than using gtk_widget_measure",
G_OBJECT_TYPE_NAME (widget), widget);
}
staticvoid
gtk_widget_query_size_for_orientation (GtkWidget *widget,
GtkOrientation orientation, int for_size, int *minimum, int *natural, int *minimum_baseline, int *natural_baseline)
{
SizeRequestCache *cache; int min_size = 0; int nat_size = 0; int min_baseline = -1; int nat_baseline = -1;
gboolean found_in_cache;
gtk_widget_clear_resize_queued (widget);
/* We check the request mode first, to determine whether the widget even does *anywfh/hfwhandling.Ifitdoesn't,weresetfor_sizeto-1andensure
* that we only cache one size for the widget (i.e. a lot more cache hits). */
cache = _gtk_widget_peek_request_cache (widget); if (G_UNLIKELY (!cache->request_mode_valid))
{
cache->request_mode = fetch_request_mode (widget);
cache->request_mode_valid = TRUE;
}
if (cache->request_mode == GTK_SIZE_REQUEST_CONSTANT_SIZE)
for_size = -1;
if (!found_in_cache)
{
GtkWidgetClass *widget_class;
GtkCssStyle *style;
GtkBorder margin, border, padding; int adjusted_min, adjusted_natural; int reported_min_size = 0; int reported_nat_size = 0; int css_min_size; int css_min_for_size; int css_extra_for_size; int css_extra_size; int widget_margins_for_size;
if (layout_manager != NULL)
{ if (for_size < 0)
{
push_recursion_check (widget, orientation);
gtk_layout_manager_measure (layout_manager, widget,
orientation, -1,
&reported_min_size, &reported_nat_size,
&min_baseline, &nat_baseline);
pop_recursion_check (widget, orientation);
} else
{ int adjusted_for_size; int minimum_for_size = 0; int natural_for_size = 0;
/* Pull the minimum for_size from the cache as it's needed to adjust
* the proposed 'for_size' */
gtk_layout_manager_measure (layout_manager, widget,
OPPOSITE_ORIENTATION (orientation), -1,
&minimum_for_size, &natural_for_size,
NULL, NULL);
if (minimum_for_size < css_min_for_size)
minimum_for_size = css_min_for_size;
if (for_size < minimum_for_size)
for_size = minimum_for_size;
/* Pull the minimum for_size from the cache as it's needed to adjust
* the proposed 'for_size' */
gtk_widget_measure (widget, OPPOSITE_ORIENTATION (orientation), -1,
&minimum_for_size, &natural_for_size, NULL, NULL);
if (minimum_for_size < css_min_for_size)
minimum_for_size = css_min_for_size;
if (for_size < minimum_for_size)
for_size = minimum_for_size;
min_size = MAX (0, MAX (reported_min_size, css_min_size)) + css_extra_size;
nat_size = MAX (0, MAX (reported_nat_size, css_min_size)) + css_extra_size;
if (G_UNLIKELY (min_size > nat_size))
{ if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
g_warning ("%s %p (%s) reported min width %d and natural width %d in measure() with for_size=%d; natural size must be >= min size",
G_OBJECT_TYPE_NAME (widget), widget,
g_quark_to_string (gtk_css_node_get_name (gtk_widget_get_css_node (widget))),
min_size, nat_size, for_size);
} else
{
g_warning ("%s %p (%s) reported min height %d and natural height %d in measure() with for_size=%d; natural size must be >= min size",
G_OBJECT_TYPE_NAME (widget), widget,
g_quark_to_string (gtk_css_node_get_name (gtk_widget_get_css_node (widget))),
min_size, nat_size, for_size);
}
nat_size = min_size;
} elseif (G_UNLIKELY (min_size < 0))
{
g_warning ("%s %p (%s) reported min %s %d, but sizes must be >= 0",
G_OBJECT_TYPE_NAME (widget), widget,
g_quark_to_string (gtk_css_node_get_name (gtk_widget_get_css_node (widget))),
orientation == GTK_ORIENTATION_HORIZONTAL ? "width" : "height",
min_size);
min_size = 0;
nat_size = MAX (0, min_size);
}
if (for_size >= 0)
{ int min_opposite_size;
gtk_widget_measure (widget, OPPOSITE_ORIENTATION (orientation), -1, &min_opposite_size, NULL, NULL, NULL); if (for_size < min_opposite_size)
{
g_warning ("Trying to measure %s %p for %s of %d, but it needs at least %d",
gtk_widget_get_name (widget), widget,
(orientation == GTK_ORIENTATION_VERTICAL) ? "width" : "height",
for_size, min_opposite_size);
for_size = min_opposite_size;
}
}
/* This is the main function that checks for a cached size and *possiblyqueriesthewidgetclasstocomputethesizeifit's *notcached.
*/ if (!_gtk_widget_get_visible (widget) && !GTK_IS_ROOT (widget))
{ if (minimum)
*minimum = 0; if (natural)
*natural = 0; if (minimum_baseline)
*minimum_baseline = -1; if (natural_baseline)
*natural_baseline = -1; return;
}
if (n_requested_sizes == 0 || extra_space == 0) return extra_space;
spreading = g_newa (guint, n_requested_sizes);
for (i = 0; i < n_requested_sizes; i++)
spreading[i] = i;
/* Distribute the container's extra space c_gap. We want to assign *thisspacesuchthatthesumofextraspaceassignedtochildren *(c^i_gap)isequaltoc_cap.Thecasethatthere'snotenough *spaceforallchildrentotaketheirnaturalsizeneedssome *attention.Thegoalswewanttoachieveare: * *a)Maximizenumberofchildrentakingtheirnaturalsize. *b)Theallocatedsizeofchildrenshouldbeacontinuous *functionofc_gap.Thatis,increasingthecontainersizeby *onepixelshouldnevermakedrasticchangesinthedistribution. *c)Ifchilditakesitsnaturalsizeandchildjdoesn't, *childjshouldhavereceivedatleastasmuchgapaschildi. * *Thefollowingcodedistributestheadditionalspacebyfollowing *theserules.
*/
/* Sort descending by gap and position. */
g_sort_array (spreading, n_requested_sizes, sizeof (guint), compare_gap, sizes);
/* Distribute available space. *ThismasterpieceofaloopwasconceivedbyBehdadEsfahbod.
*/ for (i = n_requested_sizes - 1; extra_space > 0 && i >= 0; --i)
{ /* Divide remaining space by number of remaining children. *Sortorderandreducingremainingspacebyassignedspace *ensuresthatspaceisdistributedequally.
*/ int glue = (extra_space + i) / (i + 1); int gap = sizes[(spreading[i])].natural_size
- sizes[(spreading[i])].minimum_size;
int extra = MIN (glue, gap);
sizes[spreading[i]].minimum_size += extra;
extra_space -= extra;
}
return extra_space;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-07-02)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.