gimp r27848 - in trunk: . app/core app/tools



Author: martinn
Date: Sun Dec 28 12:43:07 2008
New Revision: 27848
URL: http://svn.gnome.org/viewvc/gimp?rev=27848&view=rev

Log:
* app/core/gimpitem.c
(gimp_item_get_offset_x)
(gimp_item_get_offset_y): New offset getters for inline use.

* app/core/gimpchannel.c
* app/core/gimpdrawable.c
* app/core/gimpimage-merge.c
* app/core/gimpimage-resize.c
* app/tools/gimptexttool.c: Don't access GimpItem offset members
directly, use gimp_item_set_offset() and
gimp_item_get_offset_[xy]() instead.


Modified:
   trunk/ChangeLog
   trunk/app/core/gimpchannel.c
   trunk/app/core/gimpdrawable.c
   trunk/app/core/gimpimage-merge.c
   trunk/app/core/gimpimage-resize.c
   trunk/app/core/gimpitem.c
   trunk/app/core/gimpitem.h
   trunk/app/tools/gimptexttool.c

Modified: trunk/app/core/gimpchannel.c
==============================================================================
--- trunk/app/core/gimpchannel.c	(original)
+++ trunk/app/core/gimpchannel.c	Sun Dec 28 12:43:07 2008
@@ -465,8 +465,8 @@
 
       gimp_drawable_set_tiles_full (drawable, FALSE, NULL,
                                     new_tiles, GIMP_GRAY_IMAGE,
-                                    item->offset_x,
-                                    item->offset_y);
+                                    gimp_item_get_offset_x (item),
+                                    gimp_item_get_offset_y (item));
       tile_manager_unref (new_tiles);
     }
 

Modified: trunk/app/core/gimpdrawable.c
==============================================================================
--- trunk/app/core/gimpdrawable.c	(original)
+++ trunk/app/core/gimpdrawable.c	Sun Dec 28 12:43:07 2008
@@ -468,16 +468,21 @@
       offset_y   == 0)
     return;
 
-  new_offset_x = item->offset_x - offset_x;
-  new_offset_y = item->offset_y - offset_y;
+  new_offset_x = gimp_item_get_offset_x (item) - offset_x;
+  new_offset_y = gimp_item_get_offset_y (item) - offset_y;
 
-  gimp_rectangle_intersect (item->offset_x, item->offset_y,
-                            gimp_item_get_width  (item),
+  gimp_rectangle_intersect (gimp_item_get_offset_x (item),
+                            gimp_item_get_offset_y (item),
+                            gimp_item_get_width (item),
                             gimp_item_get_height (item),
-                            new_offset_x, new_offset_y,
-                            new_width, new_height,
-                            &copy_x, &copy_y,
-                            &copy_width, &copy_height);
+                            new_offset_x,
+                            new_offset_y,
+                            new_width,
+                            new_height,
+                            &copy_x,
+                            &copy_y,
+                            &copy_width,
+                            &copy_height);
 
   new_tiles = tile_manager_new (new_width, new_height, drawable->bytes);
 
@@ -502,9 +507,12 @@
   /*  Determine whether anything needs to be copied  */
   if (copy_width && copy_height)
     {
-      pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
-                         copy_x - item->offset_x, copy_y - item->offset_y,
-                         copy_width, copy_height,
+      pixel_region_init (&srcPR,
+                         gimp_drawable_get_tiles (drawable),
+                         copy_x - gimp_item_get_offset_x (item),
+                         copy_y - gimp_item_get_offset_y (item),
+                         copy_width,
+                         copy_height,
                          FALSE);
 
       pixel_region_init (&destPR, new_tiles,
@@ -1192,10 +1200,10 @@
   if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
     push_undo = FALSE;
 
-  if (gimp_item_get_width  (item) != tile_manager_width (tiles)  ||
-      gimp_item_get_height (item) != tile_manager_height (tiles) ||
-      item->offset_x              != offset_x                    ||
-      item->offset_y              != offset_y)
+  if (gimp_item_get_width  (item)   != tile_manager_width (tiles)  ||
+      gimp_item_get_height (item)   != tile_manager_height (tiles) ||
+      gimp_item_get_offset_x (item) != offset_x                    ||
+      gimp_item_get_offset_y (item) != offset_y)
     {
       gimp_drawable_update (drawable,
                             0, 0,

Modified: trunk/app/core/gimpimage-merge.c
==============================================================================
--- trunk/app/core/gimpimage-merge.c	(original)
+++ trunk/app/core/gimpimage-merge.c	Sun Dec 28 12:43:07 2008
@@ -432,8 +432,7 @@
           return NULL;
         }
 
-      GIMP_ITEM (merge_layer)->offset_x = x1;
-      GIMP_ITEM (merge_layer)->offset_y = y1;
+      gimp_item_set_offset (GIMP_ITEM (merge_layer), x1, y1);
 
       /*  get the background for compositing  */
       gimp_image_get_background (image, context,
@@ -470,8 +469,7 @@
           return NULL;
         }
 
-      GIMP_ITEM (merge_layer)->offset_x = x1;
-      GIMP_ITEM (merge_layer)->offset_y = y1;
+      gimp_item_set_offset (GIMP_ITEM (merge_layer), x1, y1);
 
       /*  clear the layer  */
       pixel_region_init (&src1PR,

Modified: trunk/app/core/gimpimage-resize.c
==============================================================================
--- trunk/app/core/gimpimage-resize.c	(original)
+++ trunk/app/core/gimpimage-resize.c	Sun Dec 28 12:43:07 2008
@@ -251,10 +251,10 @@
 
   /* figure out starting values */
   item = list->data;
-  min_x = item->offset_x;
-  min_y = item->offset_y;
-  max_x = item->offset_x + gimp_item_get_width  (item);
-  max_y = item->offset_y + gimp_item_get_height (item);
+  min_x = gimp_item_get_offset_x (item);
+  min_y = gimp_item_get_offset_y (item);
+  max_x = gimp_item_get_offset_x (item) + gimp_item_get_width  (item);
+  max_y = gimp_item_get_offset_y (item) + gimp_item_get_height (item);
 
   /*  Respect all layers  */
   for (list = g_list_next (list);
@@ -263,10 +263,10 @@
     {
       item = list->data;
 
-      min_x = MIN (min_x, item->offset_x);
-      min_y = MIN (min_y, item->offset_y);
-      max_x = MAX (max_x, item->offset_x + gimp_item_get_width  (item));
-      max_y = MAX (max_y, item->offset_y + gimp_item_get_height (item));
+      min_x = MIN (min_x, gimp_item_get_offset_x (item));
+      min_y = MIN (min_y, gimp_item_get_offset_y (item));
+      max_x = MAX (max_x, gimp_item_get_offset_x (item) + gimp_item_get_width  (item));
+      max_y = MAX (max_y, gimp_item_get_offset_y (item) + gimp_item_get_height (item));
     }
 
   gimp_image_resize (image, context,

Modified: trunk/app/core/gimpitem.c
==============================================================================
--- trunk/app/core/gimpitem.c	(original)
+++ trunk/app/core/gimpitem.c	Sun Dec 28 12:43:07 2008
@@ -790,6 +790,22 @@
   g_object_thaw_notify (G_OBJECT (item));
 }
 
+gint
+gimp_item_get_offset_x (GimpItem *item)
+{
+  g_return_val_if_fail (GIMP_IS_ITEM (item), 0);
+
+  return item->offset_x;
+}
+
+gint
+gimp_item_get_offset_y (GimpItem *item)
+{
+  g_return_val_if_fail (GIMP_IS_ITEM (item), 0);
+
+  return item->offset_y;
+}
+
 /**
  * gimp_item_translate:
  * @item:      The #GimpItem to move.

Modified: trunk/app/core/gimpitem.h
==============================================================================
--- trunk/app/core/gimpitem.h	(original)
+++ trunk/app/core/gimpitem.h	Sun Dec 28 12:43:07 2008
@@ -166,6 +166,8 @@
 void            gimp_item_set_offset       (GimpItem           *item,
                                             gint                offset_x,
                                             gint                offset_y);
+gint            gimp_item_get_offset_x     (GimpItem           *item);
+gint            gimp_item_get_offset_y     (GimpItem           *item);
 
 void            gimp_item_translate        (GimpItem           *item,
                                             gint                offset_x,

Modified: trunk/app/tools/gimptexttool.c
==============================================================================
--- trunk/app/tools/gimptexttool.c	(original)
+++ trunk/app/tools/gimptexttool.c	Sun Dec 28 12:43:07 2008
@@ -452,8 +452,8 @@
       GIMP_RECTANGLE_TOOL_CREATING)
     {
       GimpItem *item = GIMP_ITEM (text_tool->layer);
-      gdouble   x    = coords->x - item->offset_x;
-      gdouble   y    = coords->y - item->offset_y;
+      gdouble   x    = coords->x - gimp_item_get_offset_x (item);
+      gdouble   y    = coords->y - gimp_item_get_offset_y (item);
 
       if (x < 0 || x > item->width ||
           y < 0 || y > item->height)
@@ -472,8 +472,8 @@
   if (GIMP_IS_LAYER (drawable))
     {
       GimpItem *item = GIMP_ITEM (drawable);
-      gdouble   x    = coords->x - item->offset_x;
-      gdouble   y    = coords->y - item->offset_y;
+      gdouble   x    = coords->x - gimp_item_get_offset_x (item);
+      gdouble   y    = coords->y - gimp_item_get_offset_y (item);
 
       if (x > 0 && x < gimp_item_get_width (item) &&
           y > 0 && y < gimp_item_get_height (item))
@@ -600,8 +600,8 @@
           if (text_tool->layout && text_tool->text_cursor_changing)
             {
               GimpItem   *item = GIMP_ITEM (text_tool->layer);
-              gdouble     x    = coords->x - item->offset_x;
-              gdouble     y    = coords->y - item->offset_y;
+              gdouble     x    = coords->x - gimp_item_get_offset_x (item);
+              gdouble     y    = coords->y - gimp_item_get_offset_y (item);
               GtkTextIter cursor;
               gint        offset;
 
@@ -656,8 +656,8 @@
       if (text_tool->layout)
         {
           GimpItem    *item = GIMP_ITEM (text_tool->layer);
-          gdouble      x    = coords->x - item->offset_x;
-          gdouble      y    = coords->y - item->offset_y;
+          gdouble      x    = coords->x - gimp_item_get_offset_x (item);
+          gdouble      y    = coords->y - gimp_item_get_offset_y (item);
           GtkTextIter  cursor;
           GtkTextIter  old_selection_bound;
           GtkTextMark *selection_mark;
@@ -1361,8 +1361,8 @@
                                    _("Reshape Text Layer"));
 
       gimp_item_translate (item,
-                           x1 - item->offset_x,
-                           y1 - item->offset_y,
+                           x1 - gimp_item_get_offset_x (item),
+                           y1 - gimp_item_get_offset_y (item),
                            TRUE);
       gimp_text_tool_apply (text_tool);
 
@@ -1767,8 +1767,7 @@
                 "y2", &y2,
                 NULL);
 
-  GIMP_ITEM (layer)->offset_x = x1;
-  GIMP_ITEM (layer)->offset_y = y1;
+  gimp_item_set_offset (GIMP_ITEM (layer), x1, y1);
 
   gimp_image_add_layer (image, layer, -1, TRUE);
 
@@ -1782,8 +1781,8 @@
                     "box-height", (gdouble) (y2 - y1),
                     NULL);
       gimp_item_translate (item,
-                           x1 - item->offset_x,
-                           y1 - item->offset_y,
+                           x1 - gimp_item_get_offset_x (item),
+                           y1 - gimp_item_get_offset_y (item),
                            TRUE);
     }
   else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]