mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
Merge branch 'deprecate-get-allocation' into 'main'
Deprecate get allocation See merge request GNOME/gtk!5882
This commit is contained in:
commit
8b91762c42
@ -2548,7 +2548,9 @@ gtk_flow_box_snapshot (GtkWidget *widget,
|
||||
GtkWidget *child;
|
||||
|
||||
child = g_sequence_get (iter);
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_widget_get_allocation (GTK_WIDGET (child), &rect);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
if (line_rect.width == 0)
|
||||
line_rect = rect;
|
||||
else
|
||||
@ -3350,7 +3352,9 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
|
||||
{
|
||||
child = priv->cursor_child;
|
||||
iter = CHILD_PRIV (child)->iter;
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_widget_get_allocation (GTK_WIDGET (child), &allocation);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
start = vertical ? allocation.x : allocation.y;
|
||||
|
||||
if (count < 0)
|
||||
@ -3369,7 +3373,9 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
|
||||
/* go up an even number of rows */
|
||||
if (i % priv->cur_children_per_line == 0)
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_widget_get_allocation (GTK_WIDGET (prev), &allocation);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
if ((vertical ? allocation.x : allocation.y) < start - page_size)
|
||||
break;
|
||||
}
|
||||
@ -3393,7 +3399,9 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
|
||||
|
||||
if (i % priv->cur_children_per_line == 0)
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_widget_get_allocation (GTK_WIDGET (next), &allocation);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
if ((vertical ? allocation.x : allocation.y) > start + page_size)
|
||||
break;
|
||||
}
|
||||
@ -3402,7 +3410,9 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
|
||||
i++;
|
||||
}
|
||||
}
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_widget_get_allocation (GTK_WIDGET (child), &allocation);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1162,7 +1162,7 @@ grid_request_allocate (GridRequest *request,
|
||||
lines = &request->lines[orientation];
|
||||
spacing = get_spacing (request->layout, request->widget, orientation);
|
||||
|
||||
baseline = gtk_widget_get_allocated_baseline (request->widget);
|
||||
baseline = gtk_widget_get_baseline (request->widget);
|
||||
|
||||
if (orientation == GTK_ORIENTATION_VERTICAL && baseline != -1 &&
|
||||
self->baseline_row >= lines->min && self->baseline_row < lines->max &&
|
||||
@ -1298,7 +1298,7 @@ grid_request_position (GridRequest *request,
|
||||
lines = &request->lines[orientation];
|
||||
spacing = get_spacing (request->layout, request->widget, orientation);
|
||||
|
||||
allocated_baseline = gtk_widget_get_allocated_baseline (request->widget);
|
||||
allocated_baseline = gtk_widget_get_baseline (request->widget);
|
||||
|
||||
position = 0;
|
||||
for (i = 0; i < lines->max - lines->min; i++)
|
||||
|
@ -1014,7 +1014,7 @@ gtk_image_snapshot (GtkWidget *widget,
|
||||
|
||||
x = (width - ceil (w)) / 2;
|
||||
|
||||
baseline = gtk_widget_get_allocated_baseline (widget);
|
||||
baseline = gtk_widget_get_baseline (widget);
|
||||
if (baseline == -1)
|
||||
y = floor(height - ceil (h)) / 2;
|
||||
else
|
||||
|
@ -432,7 +432,7 @@ gtk_inscription_get_layout_location (GtkInscription *self,
|
||||
else
|
||||
x = floor ((xalign * (widget_width - logical.width)) - logical.x);
|
||||
|
||||
baseline = gtk_widget_get_allocated_baseline (widget);
|
||||
baseline = gtk_widget_get_baseline (widget);
|
||||
if (baseline != -1)
|
||||
{
|
||||
int layout_baseline = pango_layout_get_baseline (self->layout) / PANGO_SCALE;
|
||||
|
@ -1335,7 +1335,7 @@ get_layout_location (GtkLabel *self,
|
||||
pango_layout_get_pixel_extents (self->layout, NULL, &logical);
|
||||
x = floor ((xalign * (widget_width - logical.width)) - logical.x);
|
||||
|
||||
baseline = gtk_widget_get_allocated_baseline (widget);
|
||||
baseline = gtk_widget_get_baseline (widget);
|
||||
if (baseline != -1)
|
||||
{
|
||||
int layout_baseline = pango_layout_get_baseline (self->layout) / PANGO_SCALE;
|
||||
|
@ -1855,24 +1855,22 @@ gtk_scrolled_window_snapshot_scrollbars_junction (GtkScrolledWindow *scrolled_wi
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
|
||||
GtkAllocation hscr_allocation, vscr_allocation;
|
||||
graphene_rect_t hscr_bounds, vscr_bounds;
|
||||
GtkCssStyle *style;
|
||||
GdkRectangle junction_rect;
|
||||
GtkCssBoxes boxes;
|
||||
|
||||
gtk_widget_get_allocation (GTK_WIDGET (priv->hscrollbar), &hscr_allocation);
|
||||
gtk_widget_get_allocation (GTK_WIDGET (priv->vscrollbar), &vscr_allocation);
|
||||
if (!gtk_widget_compute_bounds (GTK_WIDGET (priv->hscrollbar), GTK_WIDGET (scrolled_window), &hscr_bounds))
|
||||
return;
|
||||
|
||||
junction_rect.x = vscr_allocation.x;
|
||||
junction_rect.y = hscr_allocation.y;
|
||||
junction_rect.width = vscr_allocation.width;
|
||||
junction_rect.height = hscr_allocation.height;
|
||||
if (!gtk_widget_compute_bounds (GTK_WIDGET (priv->vscrollbar), GTK_WIDGET (scrolled_window), &vscr_bounds))
|
||||
return;
|
||||
|
||||
style = gtk_css_node_get_style (priv->junction_node);
|
||||
|
||||
gtk_css_boxes_init_border_box (&boxes, style,
|
||||
junction_rect.x, junction_rect.y,
|
||||
junction_rect.width, junction_rect.height);
|
||||
vscr_bounds.origin.x, hscr_bounds.origin.y,
|
||||
vscr_bounds.size.width, hscr_bounds.size.height);
|
||||
|
||||
gtk_css_style_snapshot_background (&boxes, snapshot);
|
||||
gtk_css_style_snapshot_border (&boxes, snapshot);
|
||||
}
|
||||
|
@ -6234,7 +6234,7 @@ gtk_text_selection_bubble_popup_show (gpointer user_data)
|
||||
const int text_width = gtk_widget_get_width (GTK_WIDGET (self));
|
||||
const int text_height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||
cairo_rectangle_int_t rect;
|
||||
GtkAllocation allocation;
|
||||
graphene_point_t p;
|
||||
gboolean has_selection;
|
||||
int start_x, end_x;
|
||||
GtkWidget *box;
|
||||
@ -6279,13 +6279,15 @@ gtk_text_selection_bubble_popup_show (gpointer user_data)
|
||||
|
||||
g_object_unref (model);
|
||||
|
||||
gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
|
||||
if (!gtk_widget_compute_point (GTK_WIDGET (self), gtk_widget_get_parent (GTK_WIDGET (self)),
|
||||
&GRAPHENE_POINT_INIT (0, 0), &p))
|
||||
graphene_point_init (&p, 0, 0);
|
||||
|
||||
gtk_text_get_cursor_locations (self, &start_x, NULL);
|
||||
|
||||
start_x -= priv->scroll_offset;
|
||||
start_x = CLAMP (start_x, 0, text_width);
|
||||
rect.y = - allocation.y;
|
||||
rect.y = - p.y;
|
||||
rect.height = text_height;
|
||||
|
||||
if (has_selection)
|
||||
@ -6293,12 +6295,12 @@ gtk_text_selection_bubble_popup_show (gpointer user_data)
|
||||
end_x = gtk_text_get_selection_bound_location (self) - priv->scroll_offset;
|
||||
end_x = CLAMP (end_x, 0, text_width);
|
||||
|
||||
rect.x = - allocation.x + MIN (start_x, end_x);
|
||||
rect.x = - p.x + MIN (start_x, end_x);
|
||||
rect.width = ABS (end_x - start_x);
|
||||
}
|
||||
else
|
||||
{
|
||||
rect.x = - allocation.x + start_x;
|
||||
rect.x = - p.x + start_x;
|
||||
rect.width = 0;
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,6 @@ gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end)
|
||||
{
|
||||
GtkAllocation allocation;
|
||||
GdkPaintable *paintable;
|
||||
GtkSnapshot *snapshot;
|
||||
int layout_width, layout_height;
|
||||
@ -244,8 +243,7 @@ gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
|
||||
|
||||
style = gtk_text_attributes_new ();
|
||||
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
layout_width = allocation.width;
|
||||
layout_width = gtk_widget_get_width (widget);
|
||||
|
||||
set_attributes_from_style (widget, style);
|
||||
|
||||
|
@ -5248,13 +5248,10 @@ gtk_text_view_show_magnifier (GtkTextView *text_view,
|
||||
{
|
||||
cairo_rectangle_int_t rect;
|
||||
GtkTextViewPrivate *priv;
|
||||
GtkAllocation allocation;
|
||||
GtkRequisition req;
|
||||
|
||||
#define N_LINES 1
|
||||
|
||||
gtk_widget_get_allocation (GTK_WIDGET (text_view), &allocation);
|
||||
|
||||
priv = text_view->priv;
|
||||
_gtk_text_view_ensure_magnifier (text_view);
|
||||
|
||||
@ -5273,11 +5270,10 @@ gtk_text_view_show_magnifier (GtkTextView *text_view,
|
||||
_gtk_magnifier_set_coords (GTK_MAGNIFIER (priv->magnifier),
|
||||
rect.x, rect.y + rect.height / 2);
|
||||
|
||||
rect.x = CLAMP (rect.x, 0, allocation.width);
|
||||
rect.x = CLAMP (rect.x, 0, gtk_widget_get_width (GTK_WIDGET (text_view)));
|
||||
rect.y += rect.height / 4;
|
||||
rect.height -= rect.height / 4;
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (priv->magnifier_popover),
|
||||
&rect);
|
||||
gtk_popover_set_pointing_to (GTK_POPOVER (priv->magnifier_popover), &rect);
|
||||
|
||||
gtk_popover_popup (GTK_POPOVER (priv->magnifier_popover));
|
||||
|
||||
|
@ -241,7 +241,7 @@
|
||||
*
|
||||
* If a widget ends up baseline aligned it will be allocated all the space in
|
||||
* the parent as if it was %GTK_ALIGN_FILL, but the selected baseline can be
|
||||
* found via [id@gtk_widget_get_allocated_baseline]. If the baseline has a
|
||||
* found via [id@gtk_widget_get_baseline]. If the baseline has a
|
||||
* value other than -1 you need to align the widget such that the baseline
|
||||
* appears at the position.
|
||||
*
|
||||
@ -10092,6 +10092,8 @@ gtk_widget_get_has_tooltip (GtkWidget *widget)
|
||||
* So a layout container is guaranteed that its children stay inside
|
||||
* the assigned bounds, but not that they have exactly the bounds the
|
||||
* container assigned.
|
||||
*
|
||||
* Deprecated: 4.12: Use [method@Gtk.Widget.compute_bounds] or [method@Gtk.Widget.get_width] instead
|
||||
*/
|
||||
void
|
||||
gtk_widget_get_allocation (GtkWidget *widget,
|
||||
@ -10474,9 +10476,31 @@ gtk_widget_get_allocated_height (GtkWidget *widget)
|
||||
* child widgets in `GtkWidget`Class.size_allocate().
|
||||
*
|
||||
* Returns: the baseline of the @widget, or -1 if none
|
||||
*
|
||||
* Deprecated: 4.12: Use [method@Gtk.Widget.get_baseline] instead
|
||||
*/
|
||||
int
|
||||
gtk_widget_get_allocated_baseline (GtkWidget *widget)
|
||||
{
|
||||
return gtk_widget_get_baseline (widget);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_widget_get_baseline:
|
||||
* @widget: the widget to query
|
||||
*
|
||||
* Returns the baseline that has currently been allocated to @widget.
|
||||
*
|
||||
* This function is intended to be used when implementing handlers
|
||||
* for the `GtkWidget`Class.snapshot() function, and when allocating
|
||||
* child widgets in `GtkWidget`Class.size_allocate().
|
||||
*
|
||||
* Returns: the baseline of the @widget, or -1 if none
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
int
|
||||
gtk_widget_get_baseline (GtkWidget *widget)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GtkCssStyle *style;
|
||||
|
@ -473,10 +473,10 @@ GDK_AVAILABLE_IN_ALL
|
||||
int gtk_widget_get_allocated_width (GtkWidget *widget);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
int gtk_widget_get_allocated_height (GtkWidget *widget);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_12_FOR(gtk_widget_get_baseline)
|
||||
int gtk_widget_get_allocated_baseline (GtkWidget *widget);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_12_FOR(gtk_widget_compute_bounds)
|
||||
void gtk_widget_get_allocation (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@ -497,6 +497,8 @@ GDK_AVAILABLE_IN_ALL
|
||||
int gtk_widget_get_width (GtkWidget *widget);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
int gtk_widget_get_height (GtkWidget *widget);
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
int gtk_widget_get_baseline (GtkWidget *widget);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
int gtk_widget_get_size (GtkWidget *widget,
|
||||
GtkOrientation orientation);
|
||||
|
@ -36,7 +36,7 @@ recurse_child_widgets (GtkWidget *widget,
|
||||
gtk_snapshot_push_rounded_clip (snapshot, gtk_css_boxes_get_padding_box (&boxes));
|
||||
}
|
||||
|
||||
baseline = gtk_widget_get_allocated_baseline (widget);
|
||||
baseline = gtk_widget_get_baseline (widget);
|
||||
|
||||
if (baseline != -1)
|
||||
{
|
||||
|
@ -61,8 +61,8 @@ struct _GtkInspectorMiscInfo
|
||||
GtkWidget *measure_expand_toggle;
|
||||
GtkWidget *measure_picture;
|
||||
GdkPaintable *measure_graph;
|
||||
GtkWidget *allocated_size_row;
|
||||
GtkWidget *allocated_size;
|
||||
GtkWidget *bounds_row;
|
||||
GtkWidget *bounds;
|
||||
GtkWidget *baseline_row;
|
||||
GtkWidget *baseline;
|
||||
GtkWidget *surface_row;
|
||||
@ -145,20 +145,22 @@ static void
|
||||
update_allocation (GtkWidget *w,
|
||||
GtkInspectorMiscInfo *sl)
|
||||
{
|
||||
GtkAllocation alloc;
|
||||
graphene_rect_t bounds;
|
||||
char *size_label;
|
||||
GEnumClass *class;
|
||||
GEnumValue *value;
|
||||
|
||||
gtk_widget_get_allocation (w, &alloc);
|
||||
size_label = g_strdup_printf ("%d × %d +%d +%d",
|
||||
alloc.width, alloc.height,
|
||||
alloc.x, alloc.y);
|
||||
if (!gtk_widget_compute_bounds (w, gtk_widget_get_parent (w), &bounds))
|
||||
graphene_rect_init (&bounds, 0, 0, 0, 0);
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (sl->allocated_size), size_label);
|
||||
size_label = g_strdup_printf ("%g × %g +%g +%g",
|
||||
bounds.size.width, bounds.size.height,
|
||||
bounds.origin.x, bounds.origin.y);
|
||||
|
||||
gtk_label_set_label (GTK_LABEL (sl->bounds), size_label);
|
||||
g_free (size_label);
|
||||
|
||||
size_label = g_strdup_printf ("%d", gtk_widget_get_allocated_baseline (w));
|
||||
size_label = g_strdup_printf ("%d", gtk_widget_get_baseline (w));
|
||||
gtk_label_set_label (GTK_LABEL (sl->baseline), size_label);
|
||||
g_free (size_label);
|
||||
|
||||
@ -503,7 +505,7 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
|
||||
gtk_widget_set_visible (sl->state_row, GTK_IS_WIDGET (object));
|
||||
gtk_widget_set_visible (sl->direction_row, GTK_IS_WIDGET (object));
|
||||
gtk_widget_set_visible (sl->request_mode_row, GTK_IS_WIDGET (object));
|
||||
gtk_widget_set_visible (sl->allocated_size_row, GTK_IS_WIDGET (object));
|
||||
gtk_widget_set_visible (sl->bounds_row, GTK_IS_WIDGET (object));
|
||||
gtk_widget_set_visible (sl->baseline_row, GTK_IS_WIDGET (object));
|
||||
gtk_widget_set_visible (sl->measure_row, GTK_IS_WIDGET (object));
|
||||
gtk_widget_set_visible (sl->measure_info_row, GTK_IS_WIDGET (object));
|
||||
@ -610,8 +612,8 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, measure_expand_toggle);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, measure_picture);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, measure_graph);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, allocated_size_row);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, allocated_size);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, bounds_row);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, bounds);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, baseline_row);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, baseline);
|
||||
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, surface_row);
|
||||
|
@ -287,14 +287,14 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBoxRow" id="allocated_size_row">
|
||||
<object class="GtkListBoxRow" id="bounds_row">
|
||||
<property name="activatable">0</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="spacing">40</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="label" translatable="yes">Allocation</property>
|
||||
<property name="label" translatable="yes">Bounds</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="xalign">0</property>
|
||||
@ -302,7 +302,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="allocated_size">
|
||||
<object class="GtkLabel" id="bounds">
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">baseline</property>
|
||||
</object>
|
||||
|
@ -131,7 +131,7 @@ baseline_widget_snapshot (GtkWidget *widget,
|
||||
GskRoundedRect outline;
|
||||
|
||||
height = gtk_widget_get_height (widget);
|
||||
baseline = gtk_widget_get_allocated_baseline (widget);
|
||||
baseline = gtk_widget_get_baseline (widget);
|
||||
|
||||
gtk_snapshot_save (snapshot);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user