mirror of https://github.com/GNOME/gimp.git
Don't use gimpimage-private.h undoing guide/sample point removals
Instead, use the proper "add" APIs and remove checks for the guides / sample points being at the right positions (they might be out of image when an image resize or rotation is undone). Add comments to make clear that these functions are internal API, also add comments to the proper public APIs so it's clear which one to use in which situation.
This commit is contained in:
parent
8d652ba8cd
commit
004b96ac6c
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-private.h"
|
||||
#include "gimpguide.h"
|
||||
#include "gimpguideundo.h"
|
||||
|
||||
|
@ -158,21 +157,10 @@ gimp_guide_undo_pop (GimpUndo *undo,
|
|||
orientation = gimp_guide_get_orientation (guide_undo->guide);
|
||||
position = gimp_guide_get_position (guide_undo->guide);
|
||||
|
||||
/* add and move guides manually (nor using the gimp_image_guide
|
||||
* API), because we might be in the middle of an image resizing
|
||||
* undo group and the guide's position might be temporarily out of
|
||||
* image.
|
||||
*/
|
||||
|
||||
if (position == -1)
|
||||
{
|
||||
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (undo->image);
|
||||
|
||||
private->guides = g_list_prepend (private->guides,
|
||||
guide_undo->guide);
|
||||
gimp_guide_set_position (guide_undo->guide, guide_undo->position);
|
||||
g_object_ref (guide_undo->guide);
|
||||
gimp_image_update_guide (undo->image, guide_undo->guide);
|
||||
gimp_image_add_guide (undo->image,
|
||||
guide_undo->guide, guide_undo->position);
|
||||
}
|
||||
else if (guide_undo->position == -1)
|
||||
{
|
||||
|
|
|
@ -88,15 +88,9 @@ gimp_image_add_guide (GimpImage *image,
|
|||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (GIMP_IS_GUIDE (guide));
|
||||
g_return_if_fail (position >= 0);
|
||||
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
if (gimp_guide_get_orientation (guide) == GIMP_ORIENTATION_HORIZONTAL)
|
||||
g_return_if_fail (position <= gimp_image_get_height (image));
|
||||
else
|
||||
g_return_if_fail (position <= gimp_image_get_width (image));
|
||||
|
||||
private->guides = g_list_prepend (private->guides, guide);
|
||||
|
||||
gimp_guide_set_position (guide, position);
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#define __GIMP_IMAGE_GUIDES_H__
|
||||
|
||||
|
||||
/* public guide adding API
|
||||
*/
|
||||
GimpGuide * gimp_image_add_hguide (GimpImage *image,
|
||||
gint position,
|
||||
gboolean push_undo);
|
||||
|
@ -26,9 +28,13 @@ GimpGuide * gimp_image_add_vguide (GimpImage *image,
|
|||
gint position,
|
||||
gboolean push_undo);
|
||||
|
||||
/* internal guide adding API, does not check the guide's position and
|
||||
* is publically declared only to be used from undo
|
||||
*/
|
||||
void gimp_image_add_guide (GimpImage *image,
|
||||
GimpGuide *guide,
|
||||
gint position);
|
||||
|
||||
void gimp_image_remove_guide (GimpImage *image,
|
||||
GimpGuide *guide,
|
||||
gboolean push_undo);
|
||||
|
|
|
@ -69,10 +69,6 @@ gimp_image_add_sample_point (GimpImage *image,
|
|||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (sample_point != NULL);
|
||||
g_return_if_fail (x >= 0);
|
||||
g_return_if_fail (y >= 0);
|
||||
g_return_if_fail (x < gimp_image_get_width (image));
|
||||
g_return_if_fail (y < gimp_image_get_height (image));
|
||||
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
|
|
|
@ -19,14 +19,22 @@
|
|||
#define __GIMP_IMAGE_SAMPLE_POINTS_H__
|
||||
|
||||
|
||||
/* public sample point adding API
|
||||
*/
|
||||
GimpSamplePoint * gimp_image_add_sample_point_at_pos (GimpImage *image,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean push_undo);
|
||||
|
||||
/* internal sample point adding API, does not check the sample
|
||||
* point's position and is publically declared only to be used from
|
||||
* undo
|
||||
*/
|
||||
void gimp_image_add_sample_point (GimpImage *image,
|
||||
GimpSamplePoint *sample_point,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
void gimp_image_remove_sample_point (GimpImage *image,
|
||||
GimpSamplePoint *sample_point,
|
||||
gboolean push_undo);
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "core-types.h"
|
||||
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-private.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimpsamplepoint.h"
|
||||
#include "gimpsamplepointundo.h"
|
||||
|
@ -158,27 +157,12 @@ gimp_sample_point_undo_pop (GimpUndo *undo,
|
|||
x = sample_point_undo->sample_point->x;
|
||||
y = sample_point_undo->sample_point->y;
|
||||
|
||||
/* add and move sample points manually (nor using the
|
||||
* gimp_image_sample_point API), because we might be in the middle
|
||||
* of an image resizing undo group and the sample point's position
|
||||
* might be temporarily out of image.
|
||||
*/
|
||||
|
||||
if (x == -1)
|
||||
{
|
||||
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (undo->image);
|
||||
|
||||
private->sample_points = g_list_append (private->sample_points,
|
||||
sample_point_undo->sample_point);
|
||||
|
||||
sample_point_undo->sample_point->x = sample_point_undo->x;
|
||||
sample_point_undo->sample_point->y = sample_point_undo->y;
|
||||
gimp_sample_point_ref (sample_point_undo->sample_point);
|
||||
|
||||
gimp_image_sample_point_added (undo->image,
|
||||
sample_point_undo->sample_point);
|
||||
gimp_image_update_sample_point (undo->image,
|
||||
sample_point_undo->sample_point);
|
||||
gimp_image_add_sample_point (undo->image,
|
||||
sample_point_undo->sample_point,
|
||||
sample_point_undo->x,
|
||||
sample_point_undo->y);
|
||||
}
|
||||
else if (sample_point_undo->x == -1)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue