mirror of https://github.com/GNOME/gimp.git
added "position" and "push_undo" parameters to gimp_image_add_[vh]guide().
2003-03-28 Michael Natterer <mitch@gimp.org> * app/core/gimpimage-guides.[ch]: added "position" and "push_undo" parameters to gimp_image_add_[vh]guide(). Start with a refcount of 1, not 0 (EEK). Added gimp_image_guide_[un]ref(). Added "position" parameter to gimp_image_add_guide(). Added new function gimp_image_move_guide(). All functions push guide undos correctly and call gimp_image_update_guide() so this doesn't need to be done by callers. * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-resize.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/tools/gimpmeasuretool.c * app/xcf/xcf-load.c * tools/pdbgen/pdb/guides.pdb: greatly simplyfied all places which modify guides: don't fiddle with undo and guide properties manually but simply use the API provided. * app/tools/gimpmovetool.[ch]: ditto. Changed everything to create/move the guide on button_release, not button_press. Enable canceling the operation by clicking button3 before releasing button1. Keep the guide drawn at its old position until the move is finished (fixes bug #75349 and bug #109267). * app/pdb/guides_cmds.c: regenerated.
This commit is contained in:
parent
392bbd695c
commit
f13f80f04a
29
ChangeLog
29
ChangeLog
|
@ -1,3 +1,32 @@
|
|||
2003-03-28 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpimage-guides.[ch]: added "position" and "push_undo"
|
||||
parameters to gimp_image_add_[vh]guide(). Start with a refcount
|
||||
of 1, not 0 (EEK). Added gimp_image_guide_[un]ref(). Added
|
||||
"position" parameter to gimp_image_add_guide(). Added new
|
||||
function gimp_image_move_guide(). All functions push guide
|
||||
undos correctly and call gimp_image_update_guide() so this
|
||||
doesn't need to be done by callers.
|
||||
|
||||
* app/core/gimpimage-crop.c
|
||||
* app/core/gimpimage-duplicate.c
|
||||
* app/core/gimpimage-resize.c
|
||||
* app/core/gimpimage-undo-push.c
|
||||
* app/core/gimpimage.c
|
||||
* app/tools/gimpmeasuretool.c
|
||||
* app/xcf/xcf-load.c
|
||||
* tools/pdbgen/pdb/guides.pdb: greatly simplyfied all places which
|
||||
modify guides: don't fiddle with undo and guide properties
|
||||
manually but simply use the API provided.
|
||||
|
||||
* app/tools/gimpmovetool.[ch]: ditto. Changed everything to
|
||||
create/move the guide on button_release, not button_press. Enable
|
||||
canceling the operation by clicking button3 before releasing
|
||||
button1. Keep the guide drawn at its old position until the move
|
||||
is finished (fixes bug #75349 and bug #109267).
|
||||
|
||||
* app/pdb/guides_cmds.c: regenerated.
|
||||
|
||||
2003-03-28 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpimagefile.c (gimp_imagefile_save_thumbnail):
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "gimpdrawable.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-crop.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-mask.h"
|
||||
#include "gimpimage-projection.h"
|
||||
#include "gimpimage-undo.h"
|
||||
|
@ -215,20 +216,11 @@ gimp_image_crop (GimpImage *gimage,
|
|||
if (floating_layer)
|
||||
floating_sel_rigor (floating_layer, TRUE);
|
||||
|
||||
for (list = gimage->guides; list; list = g_list_next (list))
|
||||
{
|
||||
GimpGuide *guide;
|
||||
|
||||
guide = (GimpGuide *) list->data;
|
||||
|
||||
gimp_image_undo_push_image_guide (gimage, NULL, guide);
|
||||
}
|
||||
|
||||
gimp_image_undo_group_end (gimage);
|
||||
|
||||
/* Adjust any guides we might have laying about */
|
||||
gimp_image_crop_adjust_guides (gimage, x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
gimp_image_undo_group_end (gimage);
|
||||
}
|
||||
|
||||
gimp_image_update (gimage,
|
||||
0, 0,
|
||||
|
@ -431,15 +423,15 @@ gimp_image_crop_adjust_guides (GimpImage *gimage,
|
|||
|
||||
if (remove_guide)
|
||||
{
|
||||
guide->position = -1;
|
||||
gimp_image_remove_guide (gimage, guide, TRUE);
|
||||
guide = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (guide->orientation == GIMP_ORIENTATION_HORIZONTAL)
|
||||
guide->position -= y1;
|
||||
gimp_image_move_guide (gimage, guide, guide->position - y1, TRUE);
|
||||
else
|
||||
guide->position -= x1;
|
||||
gimp_image_move_guide (gimage, guide, guide->position - x1, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ gimp_image_duplicate (GimpImage *gimage)
|
|||
GimpLayer *floating_layer;
|
||||
GimpChannel *channel, *new_channel;
|
||||
GList *list;
|
||||
GimpGuide *guide = NULL;
|
||||
GimpLayer *active_layer = NULL;
|
||||
GimpChannel *active_channel = NULL;
|
||||
GimpDrawable *new_floating_sel_drawable = NULL;
|
||||
|
@ -195,20 +194,16 @@ gimp_image_duplicate (GimpImage *gimage)
|
|||
/* Copy any Guides */
|
||||
for (list = gimage->guides; list; list = g_list_next (list))
|
||||
{
|
||||
GimpGuide *new_guide;
|
||||
|
||||
guide = (GimpGuide *) list->data;
|
||||
GimpGuide *guide = list->data;
|
||||
|
||||
switch (guide->orientation)
|
||||
{
|
||||
case GIMP_ORIENTATION_HORIZONTAL:
|
||||
new_guide = gimp_image_add_hguide (new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
gimp_image_add_hguide (new_gimage, guide->position, FALSE);
|
||||
break;
|
||||
|
||||
case GIMP_ORIENTATION_VERTICAL:
|
||||
new_guide = gimp_image_add_vguide (new_gimage);
|
||||
new_guide->position = guide->position;
|
||||
gimp_image_add_vguide (new_gimage, guide->position, FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include "gimp.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
#define GUIDE_EPSILON 5
|
||||
|
@ -33,74 +36,142 @@
|
|||
/* public functions */
|
||||
|
||||
GimpGuide *
|
||||
gimp_image_add_hguide (GimpImage *gimage)
|
||||
gimp_image_add_hguide (GimpImage *gimage,
|
||||
gint position,
|
||||
gboolean push_undo)
|
||||
{
|
||||
GimpGuide *guide;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (position >= 0 && position < gimage->height, NULL);
|
||||
|
||||
guide = g_new (GimpGuide, 1);
|
||||
guide = g_new0 (GimpGuide, 1);
|
||||
|
||||
guide->ref_count = 0;
|
||||
guide->ref_count = 1;
|
||||
guide->position = -1;
|
||||
guide->guide_ID = gimage->gimp->next_guide_ID++;
|
||||
guide->orientation = GIMP_ORIENTATION_HORIZONTAL;
|
||||
guide->guide_ID = gimage->gimp->next_guide_ID++;
|
||||
|
||||
gimage->guides = g_list_prepend (gimage->guides, guide);
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_image_guide (gimage, _("Add Horizontal Guide"),
|
||||
guide);
|
||||
|
||||
gimp_image_add_guide (gimage, guide, position);
|
||||
gimp_image_guide_unref (guide);
|
||||
|
||||
return guide;
|
||||
}
|
||||
|
||||
GimpGuide *
|
||||
gimp_image_add_vguide (GimpImage *gimage)
|
||||
gimp_image_add_vguide (GimpImage *gimage,
|
||||
gint position,
|
||||
gboolean push_undo)
|
||||
{
|
||||
GimpGuide *guide;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (position >= 0 && position < gimage->width, NULL);
|
||||
|
||||
guide = g_new (GimpGuide, 1);
|
||||
guide = g_new0 (GimpGuide, 1);
|
||||
|
||||
guide->ref_count = 0;
|
||||
guide->ref_count = 1;
|
||||
guide->position = -1;
|
||||
guide->guide_ID = gimage->gimp->next_guide_ID++;
|
||||
guide->orientation = GIMP_ORIENTATION_VERTICAL;
|
||||
guide->guide_ID = gimage->gimp->next_guide_ID++;
|
||||
|
||||
gimage->guides = g_list_prepend (gimage->guides, guide);
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_image_guide (gimage, _("Add Vertical Guide"),
|
||||
guide);
|
||||
|
||||
gimp_image_add_guide (gimage, guide, position);
|
||||
gimp_image_guide_unref (guide);
|
||||
|
||||
return guide;
|
||||
}
|
||||
|
||||
GimpGuide *
|
||||
gimp_image_guide_ref (GimpGuide *guide)
|
||||
{
|
||||
g_return_val_if_fail (guide != NULL, NULL);
|
||||
|
||||
guide->ref_count++;
|
||||
|
||||
return guide;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_guide_unref (GimpGuide *guide)
|
||||
{
|
||||
g_return_if_fail (guide != NULL);
|
||||
|
||||
guide->ref_count--;
|
||||
|
||||
if (guide->ref_count < 1)
|
||||
g_free (guide);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_add_guide (GimpImage *gimage,
|
||||
GimpGuide *guide)
|
||||
GimpGuide *guide,
|
||||
gint position)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (guide != NULL);
|
||||
g_return_if_fail (position >= 0);
|
||||
|
||||
if (guide->orientation == GIMP_ORIENTATION_HORIZONTAL)
|
||||
g_return_if_fail (position < gimage->height);
|
||||
else
|
||||
g_return_if_fail (position < gimage->width);
|
||||
|
||||
gimage->guides = g_list_prepend (gimage->guides, guide);
|
||||
|
||||
guide->position = position;
|
||||
gimp_image_guide_ref (guide);
|
||||
|
||||
gimp_image_update_guide (gimage, guide);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_remove_guide (GimpImage *gimage,
|
||||
GimpGuide *guide)
|
||||
GimpGuide *guide,
|
||||
gboolean push_undo)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (guide != NULL);
|
||||
|
||||
gimp_image_update_guide (gimage, guide);
|
||||
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_image_guide (gimage, _("Remove Guide"), guide);
|
||||
|
||||
gimage->guides = g_list_remove (gimage->guides, guide);
|
||||
|
||||
guide->position = -1;
|
||||
gimp_image_guide_unref (guide);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_delete_guide (GimpImage *gimage,
|
||||
GimpGuide *guide)
|
||||
gimp_image_move_guide (GimpImage *gimage,
|
||||
GimpGuide *guide,
|
||||
gint position,
|
||||
gboolean push_undo)
|
||||
{
|
||||
guide->position = -1;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (guide != NULL);
|
||||
g_return_if_fail (position >= 0);
|
||||
|
||||
if (guide->ref_count <= 0)
|
||||
{
|
||||
gimage->guides = g_list_remove (gimage->guides, guide);
|
||||
g_free (guide);
|
||||
}
|
||||
if (guide->orientation == GIMP_ORIENTATION_HORIZONTAL)
|
||||
g_return_if_fail (position < gimage->height);
|
||||
else
|
||||
g_return_if_fail (position < gimage->width);
|
||||
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_image_guide (gimage, _("Move Guide"), guide);
|
||||
|
||||
gimp_image_update_guide (gimage, guide);
|
||||
guide->position = position;
|
||||
gimp_image_update_guide (gimage, guide);
|
||||
}
|
||||
|
||||
GimpGuide *
|
||||
|
@ -179,6 +250,9 @@ gimp_image_snap_point (GimpImage *gimage,
|
|||
{
|
||||
guide = (GimpGuide *) list->data;
|
||||
|
||||
if (guide->position < 0)
|
||||
continue;
|
||||
|
||||
switch (guide->orientation)
|
||||
{
|
||||
case GIMP_ORIENTATION_HORIZONTAL:
|
||||
|
@ -233,7 +307,7 @@ gimp_image_snap_rectangle (GimpImage *gimage,
|
|||
|
||||
snap1 = gimp_image_snap_point (gimage, x1, y1, &nx1, &ny1);
|
||||
snap2 = gimp_image_snap_point (gimage, x2, y2, &nx2, &ny2);
|
||||
|
||||
|
||||
if (snap1 || snap2)
|
||||
{
|
||||
if (x1 != nx1)
|
||||
|
|
|
@ -20,16 +20,26 @@
|
|||
#define __GIMP_IMAGE_GUIDES_H__
|
||||
|
||||
|
||||
GimpGuide * gimp_image_add_hguide (GimpImage *gimage);
|
||||
GimpGuide * gimp_image_add_vguide (GimpImage *gimage);
|
||||
GimpGuide * gimp_image_add_hguide (GimpImage *gimage,
|
||||
gint position,
|
||||
gboolean push_undo);
|
||||
GimpGuide * gimp_image_add_vguide (GimpImage *gimage,
|
||||
gint position,
|
||||
gboolean push_undo);
|
||||
|
||||
GimpGuide * gimp_image_guide_ref (GimpGuide *guide);
|
||||
void gimp_image_guide_unref (GimpGuide *guide);
|
||||
|
||||
void gimp_image_add_guide (GimpImage *gimage,
|
||||
GimpGuide *guide);
|
||||
GimpGuide *guide,
|
||||
gint position);
|
||||
void gimp_image_remove_guide (GimpImage *gimage,
|
||||
GimpGuide *guide);
|
||||
|
||||
void gimp_image_delete_guide (GimpImage *gimage,
|
||||
GimpGuide *guide);
|
||||
GimpGuide *guide,
|
||||
gboolean push_undo);
|
||||
void gimp_image_move_guide (GimpImage *gimage,
|
||||
GimpGuide *guide,
|
||||
gint position,
|
||||
gboolean push_undo);
|
||||
|
||||
GimpGuide * gimp_image_find_guide (GimpImage *gimage,
|
||||
gdouble x,
|
||||
|
|
|
@ -88,6 +88,7 @@ gimp_image_resize (GimpImage *gimage,
|
|||
while (guide_list)
|
||||
{
|
||||
GimpGuide *guide;
|
||||
gint new_position;
|
||||
|
||||
guide = (GimpGuide *) guide_list->data;
|
||||
guide_list = g_list_next (guide_list);
|
||||
|
@ -95,17 +96,21 @@ gimp_image_resize (GimpImage *gimage,
|
|||
switch (guide->orientation)
|
||||
{
|
||||
case GIMP_ORIENTATION_HORIZONTAL:
|
||||
gimp_image_undo_push_image_guide (gimage, NULL, guide);
|
||||
guide->position += offset_y;
|
||||
new_position = guide->position + offset_y;
|
||||
|
||||
if (guide->position < 0 || guide->position > new_height)
|
||||
gimp_image_delete_guide (gimage, guide);
|
||||
gimp_image_remove_guide (gimage, guide, TRUE);
|
||||
else
|
||||
gimp_image_move_guide (gimage, guide, new_position, TRUE);
|
||||
break;
|
||||
|
||||
case GIMP_ORIENTATION_VERTICAL:
|
||||
gimp_image_undo_push_image_guide (gimage, NULL, guide);
|
||||
guide->position += offset_x;
|
||||
new_position = guide->position + offset_x;
|
||||
|
||||
if (guide->position < 0 || guide->position > new_width)
|
||||
gimp_image_delete_guide (gimage, guide);
|
||||
gimp_image_remove_guide (gimage, guide, TRUE);
|
||||
else
|
||||
gimp_image_move_guide (gimage, guide, new_position, TRUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -630,7 +630,7 @@ typedef struct _GuideUndo GuideUndo;
|
|||
struct _GuideUndo
|
||||
{
|
||||
GimpGuide *guide;
|
||||
GimpGuide orig;
|
||||
gint position;
|
||||
};
|
||||
|
||||
static gboolean undo_pop_image_guide (GimpUndo *undo,
|
||||
|
@ -661,10 +661,8 @@ gimp_image_undo_push_image_guide (GimpImage *gimage,
|
|||
|
||||
gu = new->data;
|
||||
|
||||
guide->ref_count++;
|
||||
|
||||
gu->guide = guide;
|
||||
gu->orig = *guide;
|
||||
gu->guide = gimp_image_guide_ref (guide);
|
||||
gu->position = guide->position;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -678,22 +676,20 @@ undo_pop_image_guide (GimpUndo *undo,
|
|||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
GuideUndo *gu;
|
||||
GimpGuide tmp_guide;
|
||||
gint tmp_ref;
|
||||
gint old_position;
|
||||
|
||||
gu = (GuideUndo *) undo->data;
|
||||
|
||||
gimp_image_update_guide (undo->gimage, gu->guide);
|
||||
old_position = gu->guide->position;
|
||||
|
||||
tmp_ref = gu->guide->ref_count;
|
||||
tmp_guide = *(gu->guide);
|
||||
if (gu->guide->position == -1)
|
||||
gimp_image_add_guide (undo->gimage, gu->guide, gu->position);
|
||||
else if (gu->position == -1)
|
||||
gimp_image_remove_guide (undo->gimage, gu->guide, FALSE);
|
||||
else
|
||||
gimp_image_move_guide (undo->gimage, gu->guide, gu->position, FALSE);
|
||||
|
||||
*(gu->guide) = gu->orig;
|
||||
|
||||
gu->guide->ref_count = tmp_ref;
|
||||
gu->orig = tmp_guide;
|
||||
|
||||
gimp_image_update_guide (undo->gimage, gu->guide);
|
||||
gu->position = old_position;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -706,12 +702,7 @@ undo_free_image_guide (GimpUndo *undo,
|
|||
|
||||
gu = (GuideUndo *) undo->data;
|
||||
|
||||
gu->guide->ref_count--;
|
||||
if (gu->guide->position < 0 && gu->guide->ref_count <= 0)
|
||||
{
|
||||
gimp_image_remove_guide (undo->gimage, gu->guide);
|
||||
g_free (gu->guide);
|
||||
}
|
||||
gimp_image_guide_unref (gu->guide);
|
||||
g_free (gu);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "gimpimage.h"
|
||||
#include "gimpimage-colorhash.h"
|
||||
#include "gimpimage-colormap.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-mask.h"
|
||||
#include "gimpimage-preview.h"
|
||||
#include "gimpimage-projection.h"
|
||||
|
@ -568,7 +569,7 @@ gimp_image_finalize (GObject *object)
|
|||
|
||||
if (gimage->guides)
|
||||
{
|
||||
g_list_foreach (gimage->guides, (GFunc) g_free, NULL);
|
||||
g_list_foreach (gimage->guides, (GFunc) gimp_image_guide_unref, NULL);
|
||||
g_list_free (gimage->guides);
|
||||
gimage->guides = NULL;
|
||||
}
|
||||
|
|
|
@ -75,9 +75,7 @@ image_add_hguide_invoker (Gimp *gimp,
|
|||
{
|
||||
if (offset < gimage->height)
|
||||
{
|
||||
guide = gimp_image_add_hguide (gimage);
|
||||
gimp_image_undo_push_image_guide (gimage, _("Add Horizontal Guide"), guide);
|
||||
guide->position = offset;
|
||||
guide = gimp_image_add_hguide (gimage, offset, TRUE);
|
||||
guide_ID = guide->guide_ID;
|
||||
}
|
||||
else
|
||||
|
@ -154,9 +152,7 @@ image_add_vguide_invoker (Gimp *gimp,
|
|||
{
|
||||
if (offset < gimage->width)
|
||||
{
|
||||
guide = gimp_image_add_vguide (gimage);
|
||||
gimp_image_undo_push_image_guide (gimage, _("Add Vertical Guide"), guide);
|
||||
guide->position = offset;
|
||||
guide = gimp_image_add_vguide (gimage, offset, TRUE);
|
||||
guide_ID = guide->guide_ID;
|
||||
}
|
||||
else
|
||||
|
@ -235,9 +231,7 @@ image_delete_guide_invoker (Gimp *gimp,
|
|||
|
||||
if ((g->guide_ID == guide) && (g->position >= 0))
|
||||
{
|
||||
gimp_image_undo_push_image_guide (gimage, _("Remove Guide"), g);
|
||||
gimp_image_delete_guide (gimage, g);
|
||||
|
||||
gimp_image_remove_guide (gimage, g, TRUE);
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -263,9 +263,9 @@ gimp_measure_tool_button_press (GimpTool *tool,
|
|||
{
|
||||
if (state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
|
||||
{
|
||||
GimpGuide *guide;
|
||||
gboolean create_hguide;
|
||||
gboolean create_vguide;
|
||||
GimpGuide *guide;
|
||||
|
||||
create_hguide = ((state & GDK_CONTROL_MASK) &&
|
||||
(measure_tool->y[i] ==
|
||||
|
@ -286,23 +286,17 @@ gimp_measure_tool_button_press (GimpTool *tool,
|
|||
|
||||
if (create_hguide)
|
||||
{
|
||||
guide = gimp_image_add_hguide (gdisp->gimage);
|
||||
gimp_image_undo_push_image_guide (gdisp->gimage,
|
||||
_("Add Horizontal Guide"),
|
||||
guide);
|
||||
guide->position = measure_tool->y[i];
|
||||
|
||||
guide = gimp_image_add_hguide (gdisp->gimage,
|
||||
measure_tool->y[i],
|
||||
TRUE);
|
||||
gimp_image_update_guide (gdisp->gimage, guide);
|
||||
}
|
||||
|
||||
if (create_vguide)
|
||||
{
|
||||
guide = gimp_image_add_vguide (gdisp->gimage);
|
||||
gimp_image_undo_push_image_guide (gdisp->gimage,
|
||||
_("Add Vertical Guide"),
|
||||
guide);
|
||||
guide->position = measure_tool->x[i];
|
||||
|
||||
guide = gimp_image_add_vguide (gdisp->gimage,
|
||||
measure_tool->x[i],
|
||||
TRUE);
|
||||
gimp_image_update_guide (gdisp->gimage, guide);
|
||||
}
|
||||
|
||||
|
|
|
@ -166,9 +166,13 @@ gimp_move_tool_init (GimpMoveTool *move_tool)
|
|||
|
||||
tool = GIMP_TOOL (move_tool);
|
||||
|
||||
move_tool->layer = NULL;
|
||||
move_tool->guide = NULL;
|
||||
move_tool->disp = NULL;
|
||||
move_tool->layer = NULL;
|
||||
move_tool->guide = NULL;
|
||||
move_tool->guide_disp = NULL;
|
||||
|
||||
move_tool->moving_guide = FALSE;
|
||||
move_tool->guide_position = -1;
|
||||
move_tool->guide_orientation = GIMP_ORIENTATION_UNKNOWN;
|
||||
|
||||
gimp_tool_control_set_snap_to (tool->control, FALSE);
|
||||
gimp_tool_control_set_handles_empty_image (tool->control, TRUE);
|
||||
|
@ -228,9 +232,10 @@ gimp_move_tool_button_press (GimpTool *tool,
|
|||
|
||||
tool->gdisp = gdisp;
|
||||
|
||||
move->layer = NULL;
|
||||
move->guide = NULL;
|
||||
move->disp = NULL;
|
||||
move->layer = NULL;
|
||||
move->guide = NULL;
|
||||
move->guide_disp = NULL;
|
||||
move->moving_guide = FALSE;
|
||||
|
||||
if (options->move_mask && ! gimp_image_mask_is_empty (gdisp->gimage))
|
||||
{
|
||||
|
@ -247,17 +252,12 @@ gimp_move_tool_button_press (GimpTool *tool,
|
|||
if (gimp_display_shell_get_show_guides (shell) &&
|
||||
(guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y)))
|
||||
{
|
||||
gimp_image_undo_push_image_guide (gdisp->gimage,
|
||||
_("Guide"),
|
||||
guide);
|
||||
move->guide = guide;
|
||||
move->guide_disp = gdisp;
|
||||
|
||||
gimp_image_update_guide (gdisp->gimage, guide);
|
||||
gimp_image_remove_guide (gdisp->gimage, guide);
|
||||
gimp_display_flush (gdisp);
|
||||
gimp_image_add_guide (gdisp->gimage, guide);
|
||||
|
||||
move->guide = guide;
|
||||
move->disp = gdisp;
|
||||
move->moving_guide = TRUE;
|
||||
move->guide_position = guide->position;
|
||||
move->guide_orientation = guide->orientation;
|
||||
|
||||
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
||||
gimp_tool_control_activate (tool->control);
|
||||
|
@ -306,25 +306,29 @@ gimp_move_tool_button_release (GimpTool *tool,
|
|||
{
|
||||
GimpMoveTool *move;
|
||||
GimpDisplayShell *shell;
|
||||
gboolean delete_guide;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
move = GIMP_MOVE_TOOL (tool);
|
||||
|
||||
move = GIMP_MOVE_TOOL (tool);
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
gimp_tool_control_halt (tool->control);
|
||||
|
||||
if (move->guide)
|
||||
if (move->moving_guide)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
|
||||
gboolean delete_guide = FALSE;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
gimp_tool_control_set_scroll_lock (tool->control, FALSE);
|
||||
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
delete_guide = FALSE;
|
||||
if (state & GDK_BUTTON3_MASK)
|
||||
{
|
||||
move->moving_guide = FALSE;
|
||||
move->guide_position = -1;
|
||||
move->guide_orientation = GIMP_ORIENTATION_UNKNOWN;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_display_shell_untransform_xy (shell,
|
||||
0, 0,
|
||||
|
@ -340,15 +344,15 @@ gimp_move_tool_button_release (GimpTool *tool,
|
|||
if (x2 > gdisp->gimage->width) x2 = gdisp->gimage->width;
|
||||
if (y2 > gdisp->gimage->height) y2 = gdisp->gimage->height;
|
||||
|
||||
switch (move->guide->orientation)
|
||||
switch (move->guide_orientation)
|
||||
{
|
||||
case GIMP_ORIENTATION_HORIZONTAL:
|
||||
if ((move->guide->position < y1) || (move->guide->position > y2))
|
||||
if ((move->guide_position < y1) || (move->guide_position > y2))
|
||||
delete_guide = TRUE;
|
||||
break;
|
||||
|
||||
case GIMP_ORIENTATION_VERTICAL:
|
||||
if ((move->guide->position < x1) || (move->guide->position > x2))
|
||||
if ((move->guide_position < x1) || (move->guide_position > x2))
|
||||
delete_guide = TRUE;
|
||||
break;
|
||||
|
||||
|
@ -356,22 +360,55 @@ gimp_move_tool_button_release (GimpTool *tool,
|
|||
break;
|
||||
}
|
||||
|
||||
gimp_image_update_guide (gdisp->gimage, move->guide);
|
||||
|
||||
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
if (delete_guide)
|
||||
{
|
||||
gimp_image_delete_guide (gdisp->gimage, move->guide);
|
||||
move->guide = NULL;
|
||||
move->disp = NULL;
|
||||
if (move->guide)
|
||||
{
|
||||
gimp_image_remove_guide (gdisp->gimage, move->guide, TRUE);
|
||||
move->guide = NULL;
|
||||
move->guide_disp = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (move->guide)
|
||||
{
|
||||
gimp_image_move_guide (gdisp->gimage, move->guide,
|
||||
move->guide_position, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (move->guide_orientation)
|
||||
{
|
||||
case GIMP_ORIENTATION_HORIZONTAL:
|
||||
move->guide = gimp_image_add_hguide (gdisp->gimage,
|
||||
move->guide_position,
|
||||
TRUE);
|
||||
break;
|
||||
|
||||
case GIMP_ORIENTATION_VERTICAL:
|
||||
move->guide = gimp_image_add_vguide (gdisp->gimage,
|
||||
move->guide_position,
|
||||
TRUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
move->guide_disp = gdisp;
|
||||
}
|
||||
}
|
||||
|
||||
gimp_display_shell_selection_visibility (shell, GIMP_SELECTION_RESUME);
|
||||
gimp_image_flush (gdisp->gimage);
|
||||
|
||||
if (move->guide)
|
||||
gimp_display_shell_draw_guide (shell, move->guide, TRUE);
|
||||
|
||||
move->moving_guide = FALSE;
|
||||
move->guide_position = -1;
|
||||
move->guide_orientation = GIMP_ORIENTATION_UNKNOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -395,16 +432,15 @@ gimp_move_tool_motion (GimpTool *tool,
|
|||
GimpDisplay *gdisp)
|
||||
|
||||
{
|
||||
GimpMoveTool *move;
|
||||
GimpMoveTool *move;
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
move = GIMP_MOVE_TOOL (tool);
|
||||
move = GIMP_MOVE_TOOL (tool);
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
if (move->guide)
|
||||
if (move->moving_guide)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
gint tx, ty;
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
gint tx, ty;
|
||||
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
|
@ -413,19 +449,17 @@ gimp_move_tool_motion (GimpTool *tool,
|
|||
&tx, &ty,
|
||||
FALSE);
|
||||
|
||||
if (tx < 0 ||
|
||||
ty < 0 ||
|
||||
tx >= shell->disp_width ||
|
||||
ty >= shell->disp_height)
|
||||
if (tx < 0 || tx >= shell->disp_width ||
|
||||
ty < 0 || ty >= shell->disp_height)
|
||||
{
|
||||
move->guide->position = -1;
|
||||
move->guide_position = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (move->guide->orientation == GIMP_ORIENTATION_HORIZONTAL)
|
||||
move->guide->position = ROUND (coords->y);
|
||||
if (move->guide_orientation == GIMP_ORIENTATION_HORIZONTAL)
|
||||
move->guide_position = ROUND (coords->y);
|
||||
else
|
||||
move->guide->position = ROUND (coords->x);
|
||||
move->guide_position = ROUND (coords->x);
|
||||
}
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
|
@ -492,21 +526,20 @@ gimp_move_tool_cursor_update (GimpTool *tool,
|
|||
if (gimp_display_shell_get_show_guides (shell) &&
|
||||
(guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y)))
|
||||
{
|
||||
tool->gdisp = gdisp;
|
||||
|
||||
gimp_tool_set_cursor (tool, gdisp,
|
||||
GDK_HAND2,
|
||||
GIMP_TOOL_CURSOR_NONE,
|
||||
GIMP_CURSOR_MODIFIER_HAND);
|
||||
|
||||
if (!gimp_tool_control_is_active (tool->control))
|
||||
if (! gimp_tool_control_is_active (tool->control))
|
||||
{
|
||||
if (move->guide)
|
||||
{
|
||||
GimpDisplay *old_guide_gdisp;
|
||||
|
||||
old_guide_gdisp = gdisplays_check_valid (move->disp,
|
||||
move->disp->gimage);
|
||||
old_guide_gdisp =
|
||||
gdisplays_check_valid (move->guide_disp,
|
||||
move->guide_disp->gimage);
|
||||
|
||||
if (old_guide_gdisp)
|
||||
{
|
||||
|
@ -521,8 +554,8 @@ gimp_move_tool_cursor_update (GimpTool *tool,
|
|||
gimp_display_shell_draw_guide (GIMP_DISPLAY_SHELL (gdisp->shell),
|
||||
guide, TRUE);
|
||||
|
||||
move->guide = guide;
|
||||
move->disp = gdisp;
|
||||
move->guide = guide;
|
||||
move->guide_disp = gdisp;
|
||||
}
|
||||
}
|
||||
else if ((layer = gimp_image_pick_correlate_layer (gdisp->gimage,
|
||||
|
@ -567,34 +600,33 @@ gimp_move_tool_draw (GimpDrawTool *draw_tool)
|
|||
{
|
||||
GimpMoveTool *move;
|
||||
GimpTool *tool;
|
||||
GimpGuide *guide;
|
||||
|
||||
move = GIMP_MOVE_TOOL (draw_tool);
|
||||
tool = GIMP_TOOL (draw_tool);
|
||||
|
||||
guide = move->guide;
|
||||
|
||||
if (guide && guide->position != -1)
|
||||
if (move->moving_guide && move->guide_position != -1)
|
||||
{
|
||||
switch (guide->orientation)
|
||||
switch (move->guide_orientation)
|
||||
{
|
||||
case GIMP_ORIENTATION_HORIZONTAL:
|
||||
gimp_draw_tool_draw_line (draw_tool,
|
||||
0, guide->position,
|
||||
tool->gdisp->gimage->width, guide->position,
|
||||
0, move->guide_position,
|
||||
draw_tool->gdisp->gimage->width,
|
||||
move->guide_position,
|
||||
FALSE);
|
||||
break;
|
||||
|
||||
case GIMP_ORIENTATION_VERTICAL:
|
||||
gimp_draw_tool_draw_line (draw_tool,
|
||||
guide->position, 0,
|
||||
guide->position, tool->gdisp->gimage->height,
|
||||
move->guide_position, 0,
|
||||
move->guide_position,
|
||||
draw_tool->gdisp->gimage->height,
|
||||
FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -627,33 +659,20 @@ gimp_move_tool_start_guide (GimpTool *tool,
|
|||
gimp_display_shell_selection_visibility (GIMP_DISPLAY_SHELL (gdisp->shell),
|
||||
GIMP_SELECTION_PAUSE);
|
||||
|
||||
tool->gdisp = gdisp;
|
||||
tool->gdisp = gdisp;
|
||||
gimp_tool_control_activate (tool->control);
|
||||
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
||||
|
||||
if (move->guide && move->disp && move->disp->gimage)
|
||||
gimp_display_shell_draw_guide (GIMP_DISPLAY_SHELL (move->disp->shell),
|
||||
if (move->guide && move->guide_disp)
|
||||
gimp_display_shell_draw_guide (GIMP_DISPLAY_SHELL (move->guide_disp->shell),
|
||||
move->guide, FALSE);
|
||||
|
||||
switch (orientation)
|
||||
{
|
||||
case GIMP_ORIENTATION_HORIZONTAL:
|
||||
move->guide = gimp_image_add_hguide (gdisp->gimage);
|
||||
break;
|
||||
move->guide = NULL;
|
||||
move->guide_disp = NULL;
|
||||
|
||||
case GIMP_ORIENTATION_VERTICAL:
|
||||
move->guide = gimp_image_add_vguide (gdisp->gimage);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
move->disp = gdisp;
|
||||
|
||||
gimp_image_undo_push_image_guide (gdisp->gimage,
|
||||
_("Add Guide"),
|
||||
move->guide);
|
||||
move->moving_guide = TRUE;
|
||||
move->guide_position = -1;
|
||||
move->guide_orientation = orientation;
|
||||
|
||||
gimp_tool_set_cursor (tool, gdisp,
|
||||
GDK_HAND2,
|
||||
|
|
|
@ -36,11 +36,16 @@ typedef struct _GimpMoveToolClass GimpMoveToolClass;
|
|||
|
||||
struct _GimpMoveTool
|
||||
{
|
||||
GimpDrawTool parent_instance;
|
||||
GimpDrawTool parent_instance;
|
||||
|
||||
GimpLayer *layer;
|
||||
GimpGuide *guide;
|
||||
GimpDisplay *disp;
|
||||
GimpLayer *layer;
|
||||
|
||||
GimpGuide *guide;
|
||||
GimpDisplay *guide_disp;
|
||||
|
||||
gboolean moving_guide;
|
||||
gint guide_position;
|
||||
GimpOrientationType guide_orientation;
|
||||
};
|
||||
|
||||
struct _GimpMoveToolClass
|
||||
|
|
|
@ -441,10 +441,9 @@ xcf_load_image_props (XcfInfo *info,
|
|||
|
||||
case PROP_GUIDES:
|
||||
{
|
||||
GimpGuide *guide;
|
||||
gint32 position;
|
||||
gint8 orientation;
|
||||
gint i, nguides;
|
||||
gint32 position;
|
||||
gint8 orientation;
|
||||
gint i, nguides;
|
||||
|
||||
nguides = prop_size / (4 + 1);
|
||||
for (i = 0; i < nguides; i++)
|
||||
|
@ -457,19 +456,17 @@ xcf_load_image_props (XcfInfo *info,
|
|||
switch (orientation)
|
||||
{
|
||||
case XCF_ORIENTATION_HORIZONTAL:
|
||||
guide = gimp_image_add_hguide (gimage);
|
||||
gimp_image_add_hguide (gimage, position, FALSE);
|
||||
break;
|
||||
|
||||
case XCF_ORIENTATION_VERTICAL:
|
||||
guide = gimp_image_add_vguide (gimage);
|
||||
gimp_image_add_vguide (gimage, position, FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_message ("guide orientation out of range in XCF file");
|
||||
continue;
|
||||
}
|
||||
|
||||
guide->position = position;
|
||||
}
|
||||
|
||||
/* this is silly as the order of guides doesn't really matter,
|
||||
|
|
|
@ -23,7 +23,7 @@ sub pdb_misc {
|
|||
}
|
||||
|
||||
sub image_add_guide {
|
||||
my ($desc, $help_desc, $type, $max, $pos) = @_;
|
||||
my ($desc, $type, $max, $pos) = @_;
|
||||
|
||||
$blurb = "Add a $desc guide to an image.";
|
||||
|
||||
|
@ -54,9 +54,7 @@ HELP
|
|||
{
|
||||
if (offset < gimage->$max)
|
||||
{
|
||||
guide = gimp_image_add_${func}guide (gimage);
|
||||
gimp_image_undo_push_image_guide (gimage, _("${help_desc}"), guide);
|
||||
guide->position = offset;
|
||||
guide = gimp_image_add_${func}guide (gimage, offset, TRUE);
|
||||
guide_ID = guide->guide_ID;
|
||||
}
|
||||
else
|
||||
|
@ -69,11 +67,11 @@ CODE
|
|||
# The defs
|
||||
|
||||
sub image_add_hguide {
|
||||
&image_add_guide('horizontal', 'Add Horizontal Guide', 'y', 'height', 'top');
|
||||
&image_add_guide('horizontal', 'y', 'height', 'top');
|
||||
}
|
||||
|
||||
sub image_add_vguide {
|
||||
&image_add_guide('vertical', 'Add Vertical Guide', 'x', 'width', 'left');
|
||||
&image_add_guide('vertical', 'x', 'width', 'left');
|
||||
}
|
||||
|
||||
sub image_delete_guide {
|
||||
|
@ -104,9 +102,7 @@ HELP
|
|||
|
||||
if ((g->guide_ID == guide) && (g->position >= 0))
|
||||
{
|
||||
gimp_image_undo_push_image_guide (gimage, _("Remove Guide"), g);
|
||||
gimp_image_delete_guide (gimage, g);
|
||||
|
||||
gimp_image_remove_guide (gimage, g, TRUE);
|
||||
success = TRUE;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue