2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 14:05:25 -08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 14:05:25 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 14:05:25 -08:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 14:27:07 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 14:05:25 -08:00
|
|
|
*/
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2000-02-16 12:44:39 -08:00
|
|
|
#include "config.h"
|
|
|
|
|
|
1997-11-24 14:05:25 -08:00
|
|
|
#include <string.h>
|
2000-01-14 04:41:00 -08:00
|
|
|
|
2011-04-28 06:50:39 -07:00
|
|
|
#include <cairo.h>
|
2008-10-09 13:24:04 -07:00
|
|
|
#include <gegl.h>
|
2012-05-02 18:36:22 -07:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2001-05-09 15:34:59 -07:00
|
|
|
#include "core-types.h"
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
#include "gimp.h"
|
2001-02-01 10:44:22 -08:00
|
|
|
#include "gimpcontext.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
#include "gimpdrawable.h"
|
2001-04-18 12:14:20 -07:00
|
|
|
#include "gimpdrawable-offset.h"
|
2019-06-05 15:01:18 -07:00
|
|
|
#include "gimpdrawable-operation.h"
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
2003-02-14 06:14:29 -08:00
|
|
|
|
1997-11-24 14:05:25 -08:00
|
|
|
|
|
|
|
|
void
|
2001-04-18 13:41:15 -07:00
|
|
|
gimp_drawable_offset (GimpDrawable *drawable,
|
2004-04-14 16:37:34 -07:00
|
|
|
GimpContext *context,
|
2006-04-12 05:49:29 -07:00
|
|
|
gboolean wrap_around,
|
|
|
|
|
GimpOffsetType fill_type,
|
|
|
|
|
gint offset_x,
|
|
|
|
|
gint offset_y)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2019-06-05 15:01:18 -07:00
|
|
|
GeglNode *node;
|
2019-06-05 23:20:27 -07:00
|
|
|
gint width;
|
|
|
|
|
gint height;
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2003-05-08 06:12:46 -07:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2004-04-14 16:37:34 -07:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2003-05-08 06:12:46 -07:00
|
|
|
|
2019-06-05 23:20:27 -07:00
|
|
|
if (! gimp_item_mask_intersect (GIMP_ITEM (drawable),
|
|
|
|
|
NULL, NULL, &width, &height))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-14 16:03:07 -07:00
|
|
|
if (wrap_around)
|
2019-06-05 15:01:18 -07:00
|
|
|
fill_type = GIMP_OFFSET_WRAP_AROUND;
|
2012-03-14 16:03:07 -07:00
|
|
|
|
2019-06-05 23:20:27 -07:00
|
|
|
if (fill_type == GIMP_OFFSET_WRAP_AROUND)
|
|
|
|
|
{
|
|
|
|
|
offset_x %= width;
|
|
|
|
|
offset_y %= height;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-11 02:52:17 -07:00
|
|
|
if (offset_x == 0 && offset_y == 0)
|
2019-06-05 23:20:27 -07:00
|
|
|
return;
|
|
|
|
|
|
2019-06-05 15:01:18 -07:00
|
|
|
node = gegl_node_new_child (NULL,
|
|
|
|
|
"operation", "gimp:offset",
|
|
|
|
|
"context", context,
|
|
|
|
|
"type", fill_type,
|
|
|
|
|
"x", offset_x,
|
|
|
|
|
"y", offset_y,
|
|
|
|
|
NULL);
|
2006-04-12 05:49:29 -07:00
|
|
|
|
2019-06-05 15:01:18 -07:00
|
|
|
gimp_drawable_apply_operation (drawable, NULL,
|
|
|
|
|
C_("undo-type", "Offset Drawable"),
|
|
|
|
|
node);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2019-06-05 15:01:18 -07:00
|
|
|
g_object_unref (node);
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|