Commit 93577a2e authored by Martin Nordholts's avatar Martin Nordholts
Browse files

Moved the shift_node from GimpLayer to GimpItem, and call it offset_node.

* app/core/gimpitem.[ch]: Moved the shift_node from GimpLayer to
GimpItem, and call it offset_node. Also added
gimp_item_get_offset_node() meant to be used in the same way as
gimp_item_offsets().

(gimp_item_real_translate): Keep the offset_node up to date.

* app/core/gimplayer.[ch]: Don't manage the offset_node, get it
from GimpItem instead.

svn path=/trunk/; revision=27527
parent a748e3f5
2008-11-02 Martin Nordholts <martinn@svn.gnome.org>
* app/core/gimpitem.[ch]: Moved the shift_node from GimpLayer to
GimpItem, and call it offset_node. Also added
gimp_item_get_offset_node() meant to be used in the same way as
gimp_item_offsets().
(gimp_item_real_translate): Keep the offset_node up to date.
* app/core/gimplayer.[ch]: Don't manage the offset_node, get it
from GimpItem instead.
2008-11-02 Michael Natterer <mitch@gimp.org>
* app/core/gimp.[ch]: add new functions gimp_get_image_iter(),
......
......@@ -205,18 +205,19 @@ gimp_item_init (GimpItem *item)
{
g_object_force_floating (G_OBJECT (item));
item->ID = 0;
item->tattoo = 0;
item->image = NULL;
item->parasites = gimp_parasite_list_new ();
item->width = 0;
item->height = 0;
item->offset_x = 0;
item->offset_y = 0;
item->visible = TRUE;
item->linked = FALSE;
item->removed = FALSE;
item->node = NULL;
item->ID = 0;
item->tattoo = 0;
item->image = NULL;
item->parasites = gimp_parasite_list_new ();
item->width = 0;
item->height = 0;
item->offset_x = 0;
item->offset_y = 0;
item->visible = TRUE;
item->linked = FALSE;
item->removed = FALSE;
item->node = NULL;
item->offset_node = NULL;
}
static void
......@@ -408,6 +409,12 @@ gimp_item_real_translate (GimpItem *item,
{
item->offset_x += offset_x;
item->offset_y += offset_y;
if (item->offset_node)
gegl_node_set (item->offset_node,
"x", (gdouble) item->offset_x,
"y", (gdouble) item->offset_y,
NULL);
}
static void
......@@ -450,6 +457,11 @@ gimp_item_real_get_node (GimpItem *item)
{
item->node = gegl_node_new ();
item->offset_node = gegl_node_new_child (item->node,
"operation", "gegl:shift",
"x", (gdouble) item->offset_x,
"y", (gdouble) item->offset_y,
NULL);
return item->node;
}
......@@ -1103,6 +1115,17 @@ gimp_item_get_node (GimpItem *item)
return GIMP_ITEM_GET_CLASS (item)->get_node (item);
}
GeglNode *
gimp_item_get_offset_node (GimpItem *item)
{
g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
if (! item->offset_node)
gimp_item_get_node (item);
return item->offset_node;
}
gint
gimp_item_get_ID (GimpItem *item)
{
......
......@@ -54,6 +54,7 @@ struct _GimpItem
GeglNode *node; /* the GEGL node to plug
into the graph */
GeglNode *offset_node; /* the offset as a node */
};
struct _GimpItemClass
......@@ -226,6 +227,7 @@ gboolean gimp_item_stroke (GimpItem *item,
GError **error);
GeglNode * gimp_item_get_node (GimpItem *item);
GeglNode * gimp_item_get_offset_node (GimpItem *item);
gint gimp_item_get_ID (GimpItem *item);
......
......@@ -514,9 +514,9 @@ gimp_layer_get_node (GimpItem *item)
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GimpLayer *layer = GIMP_LAYER (item);
GeglNode *node;
GeglNode *offset_node;
GeglNode *source;
GeglNode *mode_node;
gint off_x, off_y;
node = GIMP_ITEM_CLASS (parent_class)->get_node (item);
......@@ -540,15 +540,10 @@ gimp_layer_get_node (GimpItem *item)
layer->opacity_node, "aux");
}
gimp_item_offsets (GIMP_ITEM (layer), &off_x, &off_y);
layer->shift_node = gegl_node_new_child (node,
"operation", "gegl:shift",
"x", (gdouble) off_x,
"y", (gdouble) off_y,
NULL);
offset_node = gimp_item_get_offset_node (GIMP_ITEM (layer));
gegl_node_connect_to (layer->opacity_node, "output",
layer->shift_node, "input");
offset_node, "input");
mode_node = gimp_drawable_get_mode_node (drawable);
......@@ -557,8 +552,8 @@ gimp_layer_get_node (GimpItem *item)
"blend-mode", layer->mode,
NULL);
gegl_node_connect_to (layer->shift_node, "output",
mode_node, "aux");
gegl_node_connect_to (offset_node, "output",
mode_node, "aux");
return node;
}
......@@ -765,12 +760,6 @@ gimp_layer_translate (GimpItem *item,
if (gimp_layer_is_floating_sel (layer))
floating_sel_rigor (layer, FALSE);
if (layer->shift_node)
gegl_node_set (layer->shift_node,
"x", (gdouble) item->offset_x,
"y", (gdouble) item->offset_y,
NULL);
/* update the new region */
gimp_drawable_update (GIMP_DRAWABLE (layer),
0, 0,
......@@ -1992,7 +1981,7 @@ gimp_layer_set_mode (GimpLayer *layer,
g_signal_emit (layer, layer_signals[MODE_CHANGED], 0);
g_object_notify (G_OBJECT (layer), "mode");
if (layer->shift_node)
if (layer->opacity_node)
{
GeglNode *mode_node;
......
......@@ -43,7 +43,6 @@ struct _GimpLayer
GimpLayerMask *mask; /* possible layer mask */
GeglNode *shift_node;
GeglNode *opacity_node;
/* Floating selections */
......
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