snapshot: Rename gtk_snapshot_translate_2d()

It's now called gtk_snapshot_offset().
This commit is contained in:
Benjamin Otte 2017-01-13 14:36:56 +01:00
parent fc94ee99e8
commit 87497ca2e1
16 changed files with 79 additions and 78 deletions

View File

@ -4463,7 +4463,8 @@ gtk_snapshot_push_blend
gtk_snapshot_pop
gtk_snapshot_set_transform
gtk_snapshot_transform
gtk_snapshot_translate_2d
gtk_snapshot_offset
gtk_snapshot_get_offset
gtk_snapshot_append_node
gtk_snapshot_append_cairo
gtk_snapshot_append_texture

View File

@ -137,12 +137,12 @@ gtk_builtin_icon_snapshot (GtkCssGadget *gadget,
{
GtkBuiltinIconPrivate *priv = gtk_builtin_icon_get_instance_private (GTK_BUILTIN_ICON (gadget));
gtk_snapshot_translate_2d (snapshot, x, y);
gtk_snapshot_offset (snapshot, x, y);
gtk_css_style_snapshot_icon (gtk_css_gadget_get_style (gadget),
snapshot,
width, height,
priv->image_type);
gtk_snapshot_translate_2d (snapshot, -x, -y);
gtk_snapshot_offset (snapshot, -x, -y);
return FALSE;
}

View File

@ -2158,7 +2158,7 @@ calendar_snapshot_header (GtkCalendar *calendar,
get_component_paddings (calendar, &padding, NULL, NULL, NULL);
context = gtk_widget_get_style_context (widget);
gtk_snapshot_translate_2d (snapshot, padding.left, padding.top);
gtk_snapshot_offset (snapshot, padding.left, padding.top);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
year_left = priv->year_before;
@ -2246,7 +2246,7 @@ calendar_snapshot_header (GtkCalendar *calendar,
g_object_unref (layout);
gtk_style_context_restore (context);
gtk_snapshot_translate_2d (snapshot, -padding.left, -padding.top);
gtk_snapshot_offset (snapshot, -padding.left, -padding.top);
}
static void
@ -2272,9 +2272,9 @@ calendar_snapshot_day_names (GtkCalendar *calendar,
get_component_paddings (calendar, &padding, NULL, &day_name_padding, NULL);
context = gtk_widget_get_style_context (widget);
gtk_snapshot_translate_2d (snapshot,
padding.left + inner_border,
priv->header_h + padding.top + inner_border);
gtk_snapshot_offset (snapshot,
padding.left + inner_border,
priv->header_h + padding.top + inner_border);
gtk_widget_get_allocation (widget, &allocation);
@ -2337,9 +2337,9 @@ calendar_snapshot_day_names (GtkCalendar *calendar,
g_object_unref (layout);
gtk_style_context_restore (context);
gtk_snapshot_translate_2d (snapshot,
- (padding.left + inner_border),
- (priv->header_h + padding.top + inner_border));
gtk_snapshot_offset (snapshot,
- (padding.left + inner_border),
- (priv->header_h + padding.top + inner_border));
}
static void
@ -2717,16 +2717,16 @@ calendar_snapshot_arrow (GtkCalendar *calendar,
else
image_type = GTK_CSS_IMAGE_BUILTIN_ARROW_RIGHT;
gtk_snapshot_translate_2d (snapshot,
rect.x + (rect.width - 8) / 2,
rect.y + (rect.height - 8) / 2);
gtk_snapshot_offset (snapshot,
rect.x + (rect.width - 8) / 2,
rect.y + (rect.height - 8) / 2);
gtk_css_style_snapshot_icon (gtk_style_context_lookup_style (context),
snapshot,
8, 8,
image_type);
gtk_snapshot_translate_2d (snapshot,
- rect.x - (rect.width - 8) / 2,
- rect.y - (rect.height - 8) / 2);
gtk_snapshot_offset (snapshot,
- rect.x - (rect.width - 8) / 2,
- rect.y - (rect.height - 8) / 2);
gtk_style_context_restore (context);
}

View File

@ -541,9 +541,9 @@ gtk_cell_renderer_pixbuf_snapshot (GtkCellRenderer *cell,
if (icon_helper == NULL)
icon_helper = create_icon_helper (cellpixbuf, widget);
gtk_snapshot_translate_2d (snapshot, pix_rect.x, pix_rect.y);
gtk_snapshot_offset (snapshot, pix_rect.x, pix_rect.y);
gtk_icon_helper_snapshot (icon_helper, snapshot);
gtk_snapshot_translate_2d (snapshot, - pix_rect.x, - pix_rect.y);
gtk_snapshot_offset (snapshot, - pix_rect.x, - pix_rect.y);
g_object_unref (icon_helper);

View File

@ -456,9 +456,9 @@ gtk_cell_renderer_toggle_snapshot (GtkCellRenderer *cell,
image_type = GTK_CSS_IMAGE_BUILTIN_NONE;
}
gtk_snapshot_translate_2d (snapshot,
cell_area->x + x_offset + xpad + padding.left + border.left,
cell_area->y + y_offset + ypad + padding.top + border.top);
gtk_snapshot_offset (snapshot,
cell_area->x + x_offset + xpad + padding.left + border.left,
cell_area->y + y_offset + ypad + padding.top + border.top);
gtk_css_style_snapshot_icon (gtk_style_context_lookup_style (context), snapshot,
width - padding.left - padding.right - border.left - border.right,
height - padding.top - padding.bottom - border.top - border.bottom,

View File

@ -861,7 +861,7 @@ gtk_css_gadget_snapshot (GtkCssGadget *gadget,
get_box_border (style, &border);
get_box_padding (style, &padding);
gtk_snapshot_translate_2d (snapshot, x + margin.left, y + margin.top);
gtk_snapshot_offset (snapshot, x + margin.left, y + margin.top);
gtk_css_style_snapshot_background (style,
snapshot,
width - margin.left - margin.right,
@ -870,7 +870,7 @@ gtk_css_gadget_snapshot (GtkCssGadget *gadget,
snapshot,
width - margin.left - margin.right,
height - margin.top - margin.bottom);
gtk_snapshot_translate_2d (snapshot, - x - margin.left, - y - margin.top);
gtk_snapshot_offset (snapshot, - x - margin.left, - y - margin.top);
contents_x = x + margin.left + border.left + padding.left;
contents_y = y + margin.top + border.top + padding.top;
@ -885,12 +885,12 @@ gtk_css_gadget_snapshot (GtkCssGadget *gadget,
if (draw_focus)
{
gtk_snapshot_translate_2d (snapshot, x + margin.left, y + margin.top);
gtk_snapshot_offset (snapshot, x + margin.left, y + margin.top);
gtk_css_style_snapshot_outline (style,
snapshot,
width - margin.left - margin.right,
height - margin.top - margin.bottom);
gtk_snapshot_translate_2d (snapshot, - x - margin.left, - y - margin.top);
gtk_snapshot_offset (snapshot, - x - margin.left, - y - margin.top);
}
}

View File

@ -143,13 +143,13 @@ gtk_icon_helper_real_snapshot (GtkCssGadget *gadget,
int icon_width, icon_height;
_gtk_icon_helper_get_size (self, &icon_width, &icon_height);
gtk_snapshot_translate_2d (snapshot,
x + (width - icon_width) / 2,
y + (height - icon_height) / 2);
gtk_snapshot_offset (snapshot,
x + (width - icon_width) / 2,
y + (height - icon_height) / 2);
gtk_icon_helper_snapshot (self, snapshot);
gtk_snapshot_translate_2d (snapshot,
- (x + (width - icon_width) / 2),
- (y + (height - icon_height) / 2));
gtk_snapshot_offset (snapshot,
- (x + (width - icon_width) / 2),
- (y + (height - icon_height) / 2));
return FALSE;
}

View File

@ -1766,9 +1766,9 @@ gtk_icon_view_snapshot (GtkWidget *widget,
),
"IconView Clip");
gtk_snapshot_translate_2d (snapshot,
- gtk_adjustment_get_value (icon_view->priv->hadjustment),
- gtk_adjustment_get_value (icon_view->priv->vadjustment));
gtk_snapshot_offset (snapshot,
- gtk_adjustment_get_value (icon_view->priv->hadjustment),
- gtk_adjustment_get_value (icon_view->priv->vadjustment));
gtk_icon_view_get_drag_dest_item (icon_view, &path, &dest_pos);

View File

@ -1463,9 +1463,9 @@ gtk_image_render_contents (GtkCssGadget *gadget,
}
else
{
gtk_snapshot_translate_2d (snapshot, x, y);
gtk_snapshot_offset (snapshot, x, y);
gtk_icon_helper_snapshot (priv->icon_helper, snapshot);
gtk_snapshot_translate_2d (snapshot, -x, -y);
gtk_snapshot_offset (snapshot, -x, -y);
}
return FALSE;

View File

@ -1715,14 +1715,14 @@ gtk_paned_render_handle (GtkCssGadget *gadget,
GtkStyleContext *context = gtk_widget_get_style_context (widget);
gtk_style_context_save_to_node (context, gtk_css_gadget_get_node (priv->handle_gadget));
gtk_snapshot_translate_2d (snapshot, x, y);
gtk_snapshot_offset (snapshot, x, y);
gtk_css_style_snapshot_icon (gtk_style_context_lookup_style (context),
snapshot,
width, height,
GTK_CSS_IMAGE_BUILTIN_PANE_SEPARATOR);
gtk_snapshot_translate_2d (snapshot, -x, -y);
gtk_snapshot_offset (snapshot, -x, -y);
gtk_style_context_restore (context);
return FALSE;

View File

@ -389,7 +389,7 @@ gtk_theming_background_snapshot_layer (GtkThemingBackground *bg,
gtk_snapshot_push_rounded_clip (snapshot, clip, "BackgroundLayerClip<%u>", idx);
gtk_snapshot_translate_2d (snapshot, origin->bounds.origin.x, origin->bounds.origin.y);
gtk_snapshot_offset (snapshot, origin->bounds.origin.x, origin->bounds.origin.y);
if (hrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT && vrepeat == GTK_CSS_REPEAT_STYLE_NO_REPEAT)
{
@ -399,11 +399,11 @@ gtk_theming_background_snapshot_layer (GtkThemingBackground *bg,
x = _gtk_css_position_value_get_x (pos, width - image_width);
y = _gtk_css_position_value_get_y (pos, height - image_height);
gtk_snapshot_translate_2d (snapshot, x, y);
gtk_snapshot_offset (snapshot, x, y);
gtk_css_image_snapshot (image, snapshot, image_width, image_height);
gtk_snapshot_translate_2d (snapshot, -x, -y);
gtk_snapshot_offset (snapshot, -x, -y);
}
else
{
@ -501,15 +501,15 @@ gtk_theming_background_snapshot_layer (GtkThemingBackground *bg,
),
"BackgroundLayerRepeat<%u>", idx);
gtk_snapshot_translate_2d (snapshot,
position_x + 0.5 * (repeat_width - image_width),
position_y + 0.5 * (repeat_height - image_height));
gtk_snapshot_offset (snapshot,
position_x + 0.5 * (repeat_width - image_width),
position_y + 0.5 * (repeat_height - image_height));
gtk_css_image_snapshot (image, snapshot, image_width, image_height);
gtk_snapshot_pop (snapshot);
}
gtk_snapshot_translate_2d (snapshot, - origin->bounds.origin.x, - origin->bounds.origin.y);
gtk_snapshot_offset (snapshot, - origin->bounds.origin.x, - origin->bounds.origin.y);
gtk_snapshot_pop (snapshot);
}

View File

@ -958,7 +958,7 @@ gtk_snapshot_get_renderer (const GtkSnapshot *snapshot)
}
/**
* gtk_snapshot_translate_2d:
* gtk_snapshot_offset:
* @snapshot: a $GtkSnapshot
* @x: horizontal translation
* @y: vertical translation
@ -968,9 +968,9 @@ gtk_snapshot_get_renderer (const GtkSnapshot *snapshot)
* Since: 3.90
*/
void
gtk_snapshot_translate_2d (GtkSnapshot *snapshot,
int x,
int y)
gtk_snapshot_offset (GtkSnapshot *snapshot,
int x,
int y)
{
snapshot->state->translate_x += x;
snapshot->state->translate_y += y;
@ -983,7 +983,7 @@ gtk_snapshot_translate_2d (GtkSnapshot *snapshot,
* @y: (out) (optional): return location for y offset
*
* Queries the offset managed by @snapshot. This offset is the
* accumulated sum of calls to gtk_snapshot_translate_2d().
* accumulated sum of calls to gtk_snapshot_offset().
*
* Use this offset to determine how to offset nodes that you
* manually add to the snapshot using
@ -1235,11 +1235,11 @@ gtk_snapshot_render_background (GtkSnapshot *snapshot,
g_return_if_fail (snapshot != NULL);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
gtk_snapshot_translate_2d (snapshot, x, y);
gtk_snapshot_offset (snapshot, x, y);
gtk_css_style_snapshot_background (gtk_style_context_lookup_style (context),
snapshot,
width, height);
gtk_snapshot_translate_2d (snapshot, -x, -y);
gtk_snapshot_offset (snapshot, -x, -y);
}
/**
@ -1268,11 +1268,11 @@ gtk_snapshot_render_frame (GtkSnapshot *snapshot,
g_return_if_fail (snapshot != NULL);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
gtk_snapshot_translate_2d (snapshot, x, y);
gtk_snapshot_offset (snapshot, x, y);
gtk_css_style_snapshot_border (gtk_style_context_lookup_style (context),
snapshot,
width, height);
gtk_snapshot_translate_2d (snapshot, -x, -y);
gtk_snapshot_offset (snapshot, -x, -y);
}
/**
@ -1301,11 +1301,11 @@ gtk_snapshot_render_focus (GtkSnapshot *snapshot,
g_return_if_fail (snapshot != NULL);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
gtk_snapshot_translate_2d (snapshot, x, y);
gtk_snapshot_offset (snapshot, x, y);
gtk_css_style_snapshot_outline (gtk_style_context_lookup_style (context),
snapshot,
width, height);
gtk_snapshot_translate_2d (snapshot, -x, -y);
gtk_snapshot_offset (snapshot, -x, -y);
}
/**
@ -1350,7 +1350,7 @@ gtk_snapshot_render_layout (GtkSnapshot *snapshot,
ink_rect.width + shadow_extents.left + shadow_extents.right,
ink_rect.height + shadow_extents.top + shadow_extents.bottom);
gtk_snapshot_translate_2d (snapshot, x, y);
gtk_snapshot_offset (snapshot, x, y);
cr = gtk_snapshot_append_cairo (snapshot, &bounds, "Text<%dchars>", pango_layout_get_character_count (layout));
@ -1360,7 +1360,7 @@ gtk_snapshot_render_layout (GtkSnapshot *snapshot,
pango_cairo_show_layout (cr, layout);
cairo_destroy (cr);
gtk_snapshot_translate_2d (snapshot, -x, -y);
gtk_snapshot_offset (snapshot, -x, -y);
}
/**
@ -1387,12 +1387,12 @@ gtk_snapshot_render_icon (GtkSnapshot *snapshot,
GskTexture *texture;
texture = gsk_texture_new_for_pixbuf (pixbuf);
gtk_snapshot_translate_2d (snapshot, x, y);
gtk_snapshot_offset (snapshot, x, y);
gtk_css_style_snapshot_icon_texture (gtk_style_context_lookup_style (context),
snapshot,
texture,
1);
gtk_snapshot_translate_2d (snapshot, -x, -y);
gtk_snapshot_offset (snapshot, -x, -y);
g_object_unref (texture);
}

View File

@ -93,7 +93,7 @@ GDK_AVAILABLE_IN_3_90
void gtk_snapshot_pop (GtkSnapshot *snapshot);
GDK_AVAILABLE_IN_3_90
void gtk_snapshot_translate_2d (GtkSnapshot *snapshot,
void gtk_snapshot_offset (GtkSnapshot *snapshot,
int x,
int y);
GDK_AVAILABLE_IN_3_90

View File

@ -2284,25 +2284,25 @@ gtk_snapshot_render_insertion_cursor (GtkSnapshot *snapshot,
cursor1 = &weak_pos;
}
gtk_snapshot_translate_2d (snapshot, x + PANGO_PIXELS (cursor1->x), y + PANGO_PIXELS (cursor1->y));
gtk_snapshot_offset (snapshot, x + PANGO_PIXELS (cursor1->x), y + PANGO_PIXELS (cursor1->y));
snapshot_insertion_cursor (snapshot,
context,
PANGO_PIXELS (cursor1->height),
TRUE,
direction,
direction2 != PANGO_DIRECTION_NEUTRAL);
gtk_snapshot_translate_2d (snapshot, - x - PANGO_PIXELS (cursor1->x), - y - PANGO_PIXELS (cursor1->y));
gtk_snapshot_offset (snapshot, - x - PANGO_PIXELS (cursor1->x), - y - PANGO_PIXELS (cursor1->y));
if (direction2 != PANGO_DIRECTION_NEUTRAL)
{
gtk_snapshot_translate_2d (snapshot, x + PANGO_PIXELS (cursor2->x), y + PANGO_PIXELS (cursor2->y));
gtk_snapshot_offset (snapshot, x + PANGO_PIXELS (cursor2->x), y + PANGO_PIXELS (cursor2->y));
snapshot_insertion_cursor (snapshot,
context,
PANGO_PIXELS (cursor2->height),
FALSE,
direction2,
TRUE);
gtk_snapshot_translate_2d (snapshot, - x - PANGO_PIXELS (cursor2->x), - y - PANGO_PIXELS (cursor2->y));
gtk_snapshot_offset (snapshot, - x - PANGO_PIXELS (cursor2->x), - y - PANGO_PIXELS (cursor2->y));
}
}

View File

@ -5393,13 +5393,13 @@ gtk_tree_view_snapshot (GtkWidget *widget,
),
"TreeViewContentClip");
gtk_snapshot_translate_2d (snapshot,
- (gint) gtk_adjustment_get_value (tree_view->priv->hadjustment),
gtk_tree_view_get_effective_header_height (tree_view));
gtk_snapshot_offset (snapshot,
- (gint) gtk_adjustment_get_value (tree_view->priv->hadjustment),
gtk_tree_view_get_effective_header_height (tree_view));
gtk_tree_view_bin_snapshot (widget, snapshot);
gtk_snapshot_translate_2d (snapshot,
(gint) gtk_adjustment_get_value (tree_view->priv->hadjustment),
- gtk_tree_view_get_effective_header_height (tree_view));
gtk_snapshot_offset (snapshot,
(gint) gtk_adjustment_get_value (tree_view->priv->hadjustment),
- gtk_tree_view_get_effective_header_height (tree_view));
/* We can't just chain up to Container::draw as it will try to send the
* event to the headers, so we handle propagating it to our children
@ -10052,10 +10052,10 @@ gtk_tree_view_snapshot_arrow (GtkTreeView *tree_view,
gtk_style_context_set_state (context, state);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_EXPANDER);
gtk_snapshot_translate_2d (snapshot, area.x, area.y);
gtk_snapshot_offset (snapshot, area.x, area.y);
gtk_css_style_snapshot_icon (gtk_style_context_lookup_style (context), snapshot,
area.width, area.height, image_type);
gtk_snapshot_translate_2d (snapshot, -area.x, -area.y);
gtk_snapshot_offset (snapshot, -area.x, -area.y);
gtk_style_context_restore (context);
}

View File

@ -15854,8 +15854,8 @@ gtk_widget_get_translation_to_child (GtkWidget *widget,
* gtk_widget_snapshot_child:
* @widget: a #GtkWidget
* @child: a child of @widget
* @snapshot: $GtkSnapshot as passed to the container. In particular, no
* calls to gtk_snapshot_translate_2d() should have been applied by the
* @snapshot: #GtkSnapshot as passed to the container. In particular, no
* calls to gtk_snapshot_offset() should have been applied by the
* parent.
*
* When a widget receives a call to the snapshot function, it must send
@ -15882,9 +15882,9 @@ gtk_widget_snapshot_child (GtkWidget *widget,
gtk_widget_get_translation_to_child (widget, child, &x, &y);
gtk_snapshot_translate_2d (snapshot, x, y);
gtk_snapshot_offset (snapshot, x, y);
gtk_widget_snapshot (child, snapshot);
gtk_snapshot_translate_2d (snapshot, -x, -y);
gtk_snapshot_offset (snapshot, -x, -y);
}
void