Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/core/gimpimage-sample-points.c * app/core/gimpimage-sample-points.h: new files * app/actions/view-actions.c * app/actions/view-commands.c * app/actions/view-commands.h * app/config/gimprc-blurbs.h * app/core/Makefile.am * app/core/core-enums.c * app/core/core-enums.h * app/core/core-types.h * app/core/gimp.c * app/core/gimp.h * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-rotate.c * app/core/gimpimage-scale.c * app/core/gimpimage-undo-push.c * app/core/gimpimage-undo-push.h * app/core/gimpimage.c * app/core/gimpimage.h * app/display/gimpdisplayoptions.c * app/display/gimpdisplayoptions.h * app/display/gimpdisplayshell-appearance.c * app/display/gimpdisplayshell-appearance.h * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-draw.h * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell.c * app/display/gimpdisplayshell.h * app/widgets/gimphelp-ids.h * menus/image-menu.xml.in: add support for a list of "sample points" in each image, coded and handled very similarly to guides, for use mainly in color correction. See bug #137776.
This commit is contained in:
39
ChangeLog
39
ChangeLog
@ -1,3 +1,42 @@
|
||||
2005-03-04 Bill Skaggs <weskaggs@primate.ucdavis.edu>
|
||||
|
||||
* app/core/gimpimage-sample-points.c
|
||||
* app/core/gimpimage-sample-points.h: new files
|
||||
|
||||
* app/actions/view-actions.c
|
||||
* app/actions/view-commands.c
|
||||
* app/actions/view-commands.h
|
||||
* app/config/gimprc-blurbs.h
|
||||
* app/core/Makefile.am
|
||||
* app/core/core-enums.c
|
||||
* app/core/core-enums.h
|
||||
* app/core/core-types.h
|
||||
* app/core/gimp.c
|
||||
* app/core/gimp.h
|
||||
* app/core/gimpimage-crop.c
|
||||
* app/core/gimpimage-duplicate.c
|
||||
* app/core/gimpimage-flip.c
|
||||
* app/core/gimpimage-rotate.c
|
||||
* app/core/gimpimage-scale.c
|
||||
* app/core/gimpimage-undo-push.c
|
||||
* app/core/gimpimage-undo-push.h
|
||||
* app/core/gimpimage.c
|
||||
* app/core/gimpimage.h
|
||||
* app/display/gimpdisplayoptions.c
|
||||
* app/display/gimpdisplayoptions.h
|
||||
* app/display/gimpdisplayshell-appearance.c
|
||||
* app/display/gimpdisplayshell-appearance.h
|
||||
* app/display/gimpdisplayshell-callbacks.c
|
||||
* app/display/gimpdisplayshell-draw.c
|
||||
* app/display/gimpdisplayshell-draw.h
|
||||
* app/display/gimpdisplayshell-handlers.c
|
||||
* app/display/gimpdisplayshell.c
|
||||
* app/display/gimpdisplayshell.h
|
||||
* app/widgets/gimphelp-ids.h
|
||||
* menus/image-menu.xml.in: add support for a list of "sample
|
||||
points" in each image, coded and handled very similarly to
|
||||
guides, for use mainly in color correction. See bug #137776.
|
||||
|
||||
2005-03-04 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/script-fu/script-fu-scripts.c (script_fu_find_scripts):
|
||||
|
@ -138,6 +138,12 @@ static GimpToggleActionEntry view_toggle_actions[] =
|
||||
TRUE,
|
||||
GIMP_HELP_VIEW_SHOW_GUIDES },
|
||||
|
||||
{ "view-show-sample-points", NULL,
|
||||
N_("Show Sample Points"), NULL, NULL,
|
||||
G_CALLBACK (view_toggle_sample_points_cmd_callback),
|
||||
TRUE,
|
||||
GIMP_HELP_VIEW_SHOW_SAMPLE_POINTS },
|
||||
|
||||
{ "view-show-grid", NULL,
|
||||
N_("S_how Grid"), NULL, NULL,
|
||||
G_CALLBACK (view_toggle_grid_cmd_callback),
|
||||
@ -522,6 +528,7 @@ view_actions_update (GimpActionGroup *group,
|
||||
SET_SENSITIVE ("view-show-layer-boundary", gdisp);
|
||||
SET_ACTIVE ("view-show-layer-boundary", gdisp && options->show_layer_boundary);
|
||||
SET_ACTIVE ("view-show-guides", gdisp && options->show_guides);
|
||||
SET_ACTIVE ("view-show-sample-points", gdisp && options->show_sample_points);
|
||||
SET_ACTIVE ("view-show-grid", gdisp && options->show_grid);
|
||||
SET_ACTIVE ("view-snap-to-guides", gdisp && shell->snap_to_guides);
|
||||
SET_ACTIVE ("view-snap-to-grid", gdisp && shell->snap_to_grid);
|
||||
|
@ -472,6 +472,22 @@ view_toggle_guides_cmd_callback (GtkAction *action,
|
||||
gimp_display_shell_set_show_guides (shell, active);
|
||||
}
|
||||
|
||||
void
|
||||
view_toggle_sample_points_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
{
|
||||
GimpDisplay *gdisp;
|
||||
GimpDisplayShell *shell;
|
||||
gboolean active;
|
||||
return_if_no_display (gdisp, data);
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
||||
|
||||
gimp_display_shell_set_show_sample_points (shell, active);
|
||||
}
|
||||
|
||||
void
|
||||
view_toggle_grid_cmd_callback (GtkAction *action,
|
||||
gpointer data)
|
||||
|
@ -67,6 +67,8 @@ void view_toggle_statusbar_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
void view_toggle_guides_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
void view_toggle_sample_points_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
void view_toggle_grid_cmd_callback (GtkAction *action,
|
||||
gpointer data);
|
||||
|
||||
|
@ -318,6 +318,10 @@ N_("When enabled, the layer boundary is visible by default. This can also " \
|
||||
N_("When enabled, the guides are visible by default. This can also be " \
|
||||
"toggled with the \"View->Show Guides\" command.")
|
||||
|
||||
#define SHOW_SAMPLE_POINTS_BLURB \
|
||||
N_("When enabled, the sample points are visible by default. This can also be " \
|
||||
"toggled with the \"View->Show Sample Points\" command.")
|
||||
|
||||
#define SHOW_GRID_BLURB \
|
||||
N_("When enabled, the grid is visible by default. This can also be toggled " \
|
||||
"with the \"View->Show Grid\" command.")
|
||||
|
@ -148,6 +148,8 @@ libappcore_a_sources = \
|
||||
gimpimage-resize.h \
|
||||
gimpimage-rotate.c \
|
||||
gimpimage-rotate.h \
|
||||
gimpimage-sample-points.c \
|
||||
gimpimage-sample-points.h \
|
||||
gimpimage-scale.c \
|
||||
gimpimage-scale.h \
|
||||
gimpimage-snap.c \
|
||||
|
@ -691,6 +691,7 @@ gimp_undo_type_get_type (void)
|
||||
{ GIMP_UNDO_GROUP_IMAGE_QMASK, "GIMP_UNDO_GROUP_IMAGE_QMASK", "group-image-qmask" },
|
||||
{ GIMP_UNDO_GROUP_IMAGE_GRID, "GIMP_UNDO_GROUP_IMAGE_GRID", "group-image-grid" },
|
||||
{ GIMP_UNDO_GROUP_IMAGE_GUIDE, "GIMP_UNDO_GROUP_IMAGE_GUIDE", "group-image-guide" },
|
||||
{ GIMP_UNDO_GROUP_IMAGE_SAMPLE_POINT, "GIMP_UNDO_GROUP_IMAGE_SAMPLE_POINT", "group-image-sample-point" },
|
||||
{ GIMP_UNDO_GROUP_DRAWABLE, "GIMP_UNDO_GROUP_DRAWABLE", "group-drawable" },
|
||||
{ GIMP_UNDO_GROUP_DRAWABLE_MOD, "GIMP_UNDO_GROUP_DRAWABLE_MOD", "group-drawable-mod" },
|
||||
{ GIMP_UNDO_GROUP_MASK, "GIMP_UNDO_GROUP_MASK", "group-mask" },
|
||||
@ -720,6 +721,7 @@ gimp_undo_type_get_type (void)
|
||||
{ GIMP_UNDO_IMAGE_RESOLUTION, "GIMP_UNDO_IMAGE_RESOLUTION", "image-resolution" },
|
||||
{ GIMP_UNDO_IMAGE_GRID, "GIMP_UNDO_IMAGE_GRID", "image-grid" },
|
||||
{ GIMP_UNDO_IMAGE_GUIDE, "GIMP_UNDO_IMAGE_GUIDE", "image-guide" },
|
||||
{ GIMP_UNDO_IMAGE_SAMPLE_POINT, "GIMP_UNDO_IMAGE_SAMPLE_POINT", "image-sample-point" },
|
||||
{ GIMP_UNDO_IMAGE_COLORMAP, "GIMP_UNDO_IMAGE_COLORMAP", "image-colormap" },
|
||||
{ GIMP_UNDO_DRAWABLE, "GIMP_UNDO_DRAWABLE", "drawable" },
|
||||
{ GIMP_UNDO_DRAWABLE_MOD, "GIMP_UNDO_DRAWABLE_MOD", "drawable-mod" },
|
||||
@ -772,6 +774,7 @@ gimp_undo_type_get_type (void)
|
||||
{ GIMP_UNDO_GROUP_IMAGE_QMASK, N_("Quick Mask"), NULL },
|
||||
{ GIMP_UNDO_GROUP_IMAGE_GRID, N_("Grid"), NULL },
|
||||
{ GIMP_UNDO_GROUP_IMAGE_GUIDE, N_("Guide"), NULL },
|
||||
{ GIMP_UNDO_GROUP_IMAGE_SAMPLE_POINT, N_("Sample Point"), NULL },
|
||||
{ GIMP_UNDO_GROUP_DRAWABLE, N_("Drawable"), NULL },
|
||||
{ GIMP_UNDO_GROUP_DRAWABLE_MOD, N_("Drawable mod"), NULL },
|
||||
{ GIMP_UNDO_GROUP_MASK, N_("Selection mask"), NULL },
|
||||
@ -801,6 +804,7 @@ gimp_undo_type_get_type (void)
|
||||
{ GIMP_UNDO_IMAGE_RESOLUTION, N_("Resolution change"), NULL },
|
||||
{ GIMP_UNDO_IMAGE_GRID, N_("Grid"), NULL },
|
||||
{ GIMP_UNDO_IMAGE_GUIDE, N_("Guide"), NULL },
|
||||
{ GIMP_UNDO_IMAGE_SAMPLE_POINT, N_("Sample Point"), NULL },
|
||||
{ GIMP_UNDO_IMAGE_COLORMAP, N_("Change indexed palette"), NULL },
|
||||
{ GIMP_UNDO_DRAWABLE, N_("Drawable"), NULL },
|
||||
{ GIMP_UNDO_DRAWABLE_MOD, N_("Drawable mod"), NULL },
|
||||
|
@ -336,6 +336,7 @@ typedef enum /*< pdb-skip >*/
|
||||
GIMP_UNDO_GROUP_IMAGE_QMASK, /*< desc="Quick Mask" >*/
|
||||
GIMP_UNDO_GROUP_IMAGE_GRID, /*< desc="Grid" >*/
|
||||
GIMP_UNDO_GROUP_IMAGE_GUIDE, /*< desc="Guide" >*/
|
||||
GIMP_UNDO_GROUP_IMAGE_SAMPLE_POINT, /*< desc="Sample Point" >*/
|
||||
GIMP_UNDO_GROUP_DRAWABLE, /*< desc="Drawable" >*/
|
||||
GIMP_UNDO_GROUP_DRAWABLE_MOD, /*< desc="Drawable mod" >*/
|
||||
GIMP_UNDO_GROUP_MASK, /*< desc="Selection mask" >*/
|
||||
@ -370,6 +371,7 @@ typedef enum /*< pdb-skip >*/
|
||||
GIMP_UNDO_IMAGE_RESOLUTION, /*< desc="Resolution change" >*/
|
||||
GIMP_UNDO_IMAGE_GRID, /*< desc="Grid" >*/
|
||||
GIMP_UNDO_IMAGE_GUIDE, /*< desc="Guide" >*/
|
||||
GIMP_UNDO_IMAGE_SAMPLE_POINT, /*< desc="Sample Point" >*/
|
||||
GIMP_UNDO_IMAGE_COLORMAP, /*< desc="Change indexed palette" >*/
|
||||
GIMP_UNDO_DRAWABLE, /*< desc="Drawable" >*/
|
||||
GIMP_UNDO_DRAWABLE_MOD, /*< desc="Drawable mod" >*/
|
||||
|
@ -133,6 +133,7 @@ typedef struct _GimpArea GimpArea;
|
||||
typedef struct _GimpCoords GimpCoords;
|
||||
typedef struct _GimpGradientSegment GimpGradientSegment;
|
||||
typedef struct _GimpGuide GimpGuide;
|
||||
typedef struct _GimpSamplePoint GimpSamplePoint;
|
||||
typedef guint32 GimpTattoo;
|
||||
typedef struct _GimpPaletteEntry GimpPaletteEntry;
|
||||
typedef struct _GimpPlugInDebug GimpPlugInDebug;
|
||||
|
@ -241,6 +241,7 @@ gimp_init (Gimp *gimp)
|
||||
|
||||
gimp->next_image_ID = 1;
|
||||
gimp->next_guide_ID = 1;
|
||||
gimp->next_sample_point_ID = 1;
|
||||
gimp->image_table = g_hash_table_new (g_direct_hash, NULL);
|
||||
|
||||
gimp->next_item_ID = 1;
|
||||
|
@ -88,6 +88,7 @@ struct _Gimp
|
||||
GimpContainer *images;
|
||||
gint next_image_ID;
|
||||
guint32 next_guide_ID;
|
||||
guint32 next_sample_point_ID;
|
||||
GHashTable *image_table;
|
||||
|
||||
gint next_item_ID;
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-crop.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimpimage-undo.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
#include "gimplayer.h"
|
||||
@ -229,6 +230,31 @@ gimp_image_crop (GimpImage *gimage,
|
||||
gimp_image_move_guide (gimage, guide, new_position, TRUE);
|
||||
}
|
||||
|
||||
/* Reposition or remove sample points */
|
||||
list = gimage->sample_points;
|
||||
while (list)
|
||||
{
|
||||
GimpSamplePoint *sample_point = list->data;
|
||||
gboolean remove_sample_point = FALSE;
|
||||
gint new_x = sample_point->x;
|
||||
gint new_y = sample_point->y;
|
||||
|
||||
list = g_list_next (list);
|
||||
|
||||
new_y -= y1;
|
||||
if ((sample_point->y < y1) || (sample_point->y > y2))
|
||||
remove_sample_point = TRUE;
|
||||
|
||||
new_x -= x1;
|
||||
if ((sample_point->x < x1) || (sample_point->x > x2))
|
||||
remove_sample_point = TRUE;
|
||||
|
||||
if (remove_sample_point)
|
||||
gimp_image_remove_sample_point (gimage, sample_point, TRUE);
|
||||
else if (new_x != sample_point->x || new_y != sample_point->y)
|
||||
gimp_image_move_sample_point (gimage, sample_point, new_x, new_y, TRUE);
|
||||
}
|
||||
|
||||
gimp_image_undo_group_end (gimage);
|
||||
|
||||
gimp_image_update (gimage, 0, 0, gimage->width, gimage->height);
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "gimpimage-duplicate.h"
|
||||
#include "gimpimage-grid.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimplayer.h"
|
||||
#include "gimplayer-floating-sel.h"
|
||||
#include "gimplist.h"
|
||||
@ -235,6 +236,17 @@ gimp_image_duplicate (GimpImage *gimage)
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy any sample points */
|
||||
for (list = gimage->sample_points; list; list = g_list_next (list))
|
||||
{
|
||||
GimpSamplePoint *sample_point = list->data;
|
||||
|
||||
gimp_image_add_sample_point_at_pos (new_gimage,
|
||||
sample_point->x,
|
||||
sample_point->y,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
/* Copy the grid */
|
||||
if (gimage->grid)
|
||||
gimp_image_set_grid (new_gimage, gimage->grid, FALSE);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-flip.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimpimage-undo.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
#include "gimpitem.h"
|
||||
@ -144,6 +145,24 @@ gimp_image_flip (GimpImage *gimage,
|
||||
}
|
||||
}
|
||||
|
||||
/* Flip all sample points */
|
||||
for (list = gimage->sample_points; list; list = g_list_next (list))
|
||||
{
|
||||
GimpSamplePoint *sample_point = list->data;
|
||||
|
||||
if (flip_type == GIMP_ORIENTATION_VERTICAL)
|
||||
gimp_image_move_sample_point (gimage, sample_point,
|
||||
sample_point->x,
|
||||
gimage->height - sample_point->y,
|
||||
TRUE);
|
||||
|
||||
if (flip_type == GIMP_ORIENTATION_HORIZONTAL)
|
||||
gimp_image_move_sample_point (gimage, sample_point,
|
||||
gimage->width - sample_point->x,
|
||||
sample_point->y,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
gimp_image_undo_group_end (gimage);
|
||||
|
||||
gimp_unset_busy (gimage->gimp);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-rotate.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimpimage-undo.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
#include "gimpitem.h"
|
||||
@ -34,13 +35,15 @@
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
static void gimp_image_rotate_item_offset (GimpImage *gimage,
|
||||
GimpRotationType rotate_type,
|
||||
GimpItem *item,
|
||||
gint off_x,
|
||||
gint off_y);
|
||||
static void gimp_image_rotate_guides (GimpImage *gimage,
|
||||
GimpRotationType rotate_type);
|
||||
static void gimp_image_rotate_item_offset (GimpImage *gimage,
|
||||
GimpRotationType rotate_type,
|
||||
GimpItem *item,
|
||||
gint off_x,
|
||||
gint off_y);
|
||||
static void gimp_image_rotate_guides (GimpImage *gimage,
|
||||
GimpRotationType rotate_type);
|
||||
static void gimp_image_rotate_sample_points (GimpImage *gimage,
|
||||
GimpRotationType rotate_type);
|
||||
|
||||
|
||||
void
|
||||
@ -169,6 +172,9 @@ gimp_image_rotate (GimpImage *gimage,
|
||||
/* Rotate all Guides */
|
||||
gimp_image_rotate_guides (gimage, rotate_type);
|
||||
|
||||
/* Rotate all sample points */
|
||||
gimp_image_rotate_sample_points (gimage, rotate_type);
|
||||
|
||||
/* Resize the image (if needed) */
|
||||
if (size_changed)
|
||||
{
|
||||
@ -308,3 +314,40 @@ gimp_image_rotate_guides (GimpImage *gimage,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_image_rotate_sample_points (GimpImage *gimage,
|
||||
GimpRotationType rotate_type)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
/* Rotate all sample points */
|
||||
for (list = gimage->sample_points; list; list = g_list_next (list))
|
||||
{
|
||||
GimpSamplePoint *sample_point = list->data;
|
||||
gint old_x;
|
||||
gint old_y;
|
||||
|
||||
old_x = sample_point->x;
|
||||
old_y = sample_point->y;
|
||||
|
||||
switch (rotate_type)
|
||||
{
|
||||
case GIMP_ROTATE_90:
|
||||
sample_point->x = old_y;
|
||||
sample_point->y = gimage->height - old_x;
|
||||
break;
|
||||
|
||||
case GIMP_ROTATE_180:
|
||||
sample_point->x = gimage->height - old_x;
|
||||
sample_point->y = gimage->width - old_y;
|
||||
break;
|
||||
|
||||
case GIMP_ROTATE_270:
|
||||
sample_point->x = gimage->width - old_y;
|
||||
sample_point->y = old_x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
188
app/core/gimpimage-sample-points.c
Normal file
188
app/core/gimpimage-sample-points.c
Normal file
@ -0,0 +1,188 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
GimpSamplePoint *
|
||||
gimp_image_add_sample_point_at_pos (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean push_undo)
|
||||
{
|
||||
GimpSamplePoint *sample_point;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (x >= 0 && x <= gimage->width, NULL);
|
||||
g_return_val_if_fail (y >= 0 && y <= gimage->height, NULL);
|
||||
|
||||
sample_point = g_new0 (GimpSamplePoint, 1);
|
||||
|
||||
sample_point->ref_count = 1;
|
||||
sample_point->x = -1;
|
||||
sample_point->y = -1;
|
||||
sample_point->sample_point_ID = gimage->gimp->next_sample_point_ID++;
|
||||
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_image_sample_point (gimage, _("Add Sample_Point"),
|
||||
sample_point);
|
||||
|
||||
gimp_image_add_sample_point (gimage, sample_point, x, y);
|
||||
gimp_image_sample_point_unref (sample_point);
|
||||
|
||||
return sample_point;
|
||||
}
|
||||
|
||||
GimpSamplePoint *
|
||||
gimp_image_sample_point_ref (GimpSamplePoint *sample_point)
|
||||
{
|
||||
g_return_val_if_fail (sample_point != NULL, NULL);
|
||||
|
||||
sample_point->ref_count++;
|
||||
|
||||
return sample_point;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_sample_point_unref (GimpSamplePoint *sample_point)
|
||||
{
|
||||
g_return_if_fail (sample_point != NULL);
|
||||
|
||||
sample_point->ref_count--;
|
||||
|
||||
if (sample_point->ref_count < 1)
|
||||
g_free (sample_point);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_add_sample_point (GimpImage *gimage,
|
||||
GimpSamplePoint *sample_point,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (sample_point != NULL);
|
||||
g_return_if_fail (x >= 0);
|
||||
g_return_if_fail (y >= 0);
|
||||
g_return_if_fail (x <= gimage->width);
|
||||
g_return_if_fail (y <= gimage->height);
|
||||
|
||||
gimage->sample_points = g_list_prepend (gimage->sample_points, sample_point);
|
||||
|
||||
sample_point->x = x;
|
||||
sample_point->y = y;
|
||||
gimp_image_sample_point_ref (sample_point);
|
||||
|
||||
gimp_image_update_sample_point (gimage, sample_point);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_remove_sample_point (GimpImage *gimage,
|
||||
GimpSamplePoint *sample_point,
|
||||
gboolean push_undo)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (sample_point != NULL);
|
||||
|
||||
gimp_image_update_sample_point (gimage, sample_point);
|
||||
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_image_sample_point (gimage, _("Remove Sample Point"), sample_point);
|
||||
|
||||
gimage->sample_points = g_list_remove (gimage->sample_points, sample_point);
|
||||
|
||||
sample_point->x = -1;
|
||||
sample_point->y = -1;
|
||||
gimp_image_sample_point_unref (sample_point);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_move_sample_point (GimpImage *gimage,
|
||||
GimpSamplePoint *sample_point,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean push_undo)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (sample_point != NULL);
|
||||
g_return_if_fail (x >= 0);
|
||||
g_return_if_fail (y >= 0);
|
||||
g_return_if_fail (x <= gimage->width);
|
||||
g_return_if_fail (y <= gimage->height);
|
||||
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_image_sample_point (gimage, _("Move Sample Point"), sample_point);
|
||||
|
||||
gimp_image_update_sample_point (gimage, sample_point);
|
||||
sample_point->x = x;
|
||||
sample_point->y = y;
|
||||
gimp_image_update_sample_point (gimage, sample_point);
|
||||
}
|
||||
|
||||
GimpSamplePoint *
|
||||
gimp_image_find_sample_point (GimpImage *gimage,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble epsilon_x,
|
||||
gdouble epsilon_y)
|
||||
{
|
||||
GList *list;
|
||||
GimpSamplePoint *sample_point;
|
||||
GimpSamplePoint *ret = NULL;
|
||||
gdouble dist;
|
||||
gdouble mindist = G_MAXDOUBLE;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
g_return_val_if_fail (epsilon_x > 0 && epsilon_y > 0, NULL);
|
||||
|
||||
if (x < 0 || x >= gimage->width ||
|
||||
y < 0 || y >= gimage->height)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (list = gimage->sample_points; list; list = g_list_next (list))
|
||||
{
|
||||
sample_point = (GimpSamplePoint *) list->data;
|
||||
|
||||
if (sample_point->x < 0 || sample_point->y < 0)
|
||||
continue;
|
||||
|
||||
dist = hypot ( sample_point->x - x, sample_point->y - y);
|
||||
if (dist < MIN (epsilon_y, mindist))
|
||||
{
|
||||
mindist = dist;
|
||||
ret = sample_point;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
60
app/core/gimpimage-sample-points.h
Normal file
60
app/core/gimpimage-sample-points.h
Normal file
@ -0,0 +1,60 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_IMAGE_SAMPLE_POINTS_H__
|
||||
#define __GIMP_IMAGE_SAMPLE_POINTS_H__
|
||||
|
||||
#define GIMP_SAMPLE_POINT_DRAW_SIZE 10
|
||||
|
||||
struct _GimpSamplePoint
|
||||
{
|
||||
gint ref_count;
|
||||
gint x;
|
||||
gint y;
|
||||
guint32 sample_point_ID;
|
||||
};
|
||||
|
||||
|
||||
GimpSamplePoint * gimp_image_add_sample_point_at_pos (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean push_undo);
|
||||
GimpSamplePoint * gimp_image_sample_point_ref (GimpSamplePoint *sample_point);
|
||||
void gimp_image_sample_point_unref (GimpSamplePoint *sample_point);
|
||||
|
||||
void gimp_image_add_sample_point (GimpImage *gimage,
|
||||
GimpSamplePoint *sample_point,
|
||||
gint x,
|
||||
gint y);
|
||||
void gimp_image_remove_sample_point (GimpImage *gimage,
|
||||
GimpSamplePoint *sample_point,
|
||||
gboolean push_undo);
|
||||
void gimp_image_move_sample_point (GimpImage *gimage,
|
||||
GimpSamplePoint *sample_point,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean push_undo);
|
||||
|
||||
GimpSamplePoint * gimp_image_find_sample_point (GimpImage *gimage,
|
||||
gdouble x,
|
||||
gdouble y,
|
||||
gdouble epsilon_x,
|
||||
gdouble epsilon_y);
|
||||
|
||||
|
||||
#endif /* __GIMP_IMAGE_SAMPLE_POINTS_H__ */
|
@ -27,6 +27,7 @@
|
||||
#include "gimp.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimpimage-scale.h"
|
||||
#include "gimpimage-undo.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
@ -181,6 +182,16 @@ gimp_image_scale (GimpImage *gimage,
|
||||
}
|
||||
}
|
||||
|
||||
/* Scale all sample points */
|
||||
for (list = gimage->sample_points; list; list = g_list_next (list))
|
||||
{
|
||||
GimpSamplePoint *sample_point = list->data;
|
||||
|
||||
gimp_image_undo_push_image_sample_point (gimage, NULL, sample_point);
|
||||
sample_point->x = sample_point->x * new_width / old_width;
|
||||
sample_point->y = sample_point->y * new_height / old_height;
|
||||
}
|
||||
|
||||
gimp_image_undo_group_end (gimage);
|
||||
|
||||
gimp_viewable_size_changed (GIMP_VIEWABLE (gimage));
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "gimpimage-colormap.h"
|
||||
#include "gimpimage-grid.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimpimage-undo.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpitemundo.h"
|
||||
@ -482,6 +483,105 @@ undo_free_image_guide (GimpUndo *undo,
|
||||
}
|
||||
|
||||
|
||||
/**********************/
|
||||
/* Sampe Point Undo */
|
||||
/**********************/
|
||||
|
||||
typedef struct _SamplePointUndo SamplePointUndo;
|
||||
|
||||
struct _SamplePointUndo
|
||||
{
|
||||
GimpSamplePoint *sample_point;
|
||||
gint x;
|
||||
gint y;
|
||||
};
|
||||
|
||||
static gboolean undo_pop_image_sample_point (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum);
|
||||
static void undo_free_image_sample_point (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode);
|
||||
|
||||
gboolean
|
||||
gimp_image_undo_push_image_sample_point (GimpImage *gimage,
|
||||
const gchar *undo_desc,
|
||||
GimpSamplePoint *sample_point)
|
||||
{
|
||||
GimpUndo *new;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (sample_point != NULL, FALSE);
|
||||
|
||||
if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_UNDO,
|
||||
sizeof (SamplePointUndo),
|
||||
sizeof (SamplePointUndo),
|
||||
GIMP_UNDO_IMAGE_SAMPLE_POINT, undo_desc,
|
||||
GIMP_DIRTY_IMAGE_META,
|
||||
undo_pop_image_sample_point,
|
||||
undo_free_image_sample_point,
|
||||
NULL)))
|
||||
{
|
||||
SamplePointUndo *gu = new->data;
|
||||
|
||||
gu->sample_point = gimp_image_sample_point_ref (sample_point);
|
||||
gu->x = sample_point->x;
|
||||
gu->y = sample_point->y;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
undo_pop_image_sample_point (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
GimpUndoAccumulator *accum)
|
||||
{
|
||||
SamplePointUndo *gu = undo->data;
|
||||
gint old_x;
|
||||
gint old_y;
|
||||
|
||||
old_x = gu->sample_point->x;
|
||||
old_y = gu->sample_point->y;
|
||||
|
||||
if (gu->sample_point->x == -1)
|
||||
{
|
||||
undo->gimage->sample_points = g_list_prepend (undo->gimage->sample_points, gu->sample_point);
|
||||
gu->sample_point->x = gu->x;
|
||||
gu->sample_point->y = gu->y;
|
||||
gimp_image_sample_point_ref (gu->sample_point);
|
||||
gimp_image_update_sample_point (undo->gimage, gu->sample_point);
|
||||
}
|
||||
else if (gu->x == -1)
|
||||
{
|
||||
gimp_image_remove_sample_point (undo->gimage, gu->sample_point, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_image_update_sample_point (undo->gimage, gu->sample_point);
|
||||
gu->sample_point->x = gu->x;
|
||||
gu->sample_point->y = gu->y;
|
||||
gimp_image_update_sample_point (undo->gimage, gu->sample_point);
|
||||
}
|
||||
|
||||
gu->x = old_x;
|
||||
gu->y = old_y;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
undo_free_image_sample_point (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode)
|
||||
{
|
||||
SamplePointUndo *gu = undo->data;
|
||||
|
||||
gimp_image_sample_point_unref (gu->sample_point);
|
||||
g_free (gu);
|
||||
}
|
||||
|
||||
|
||||
/*******************/
|
||||
/* Colormap Undo */
|
||||
/*******************/
|
||||
|
@ -34,6 +34,9 @@ gboolean gimp_image_undo_push_image_grid (GimpImage *gimage,
|
||||
gboolean gimp_image_undo_push_image_guide (GimpImage *gimage,
|
||||
const gchar *undo_desc,
|
||||
GimpGuide *guide);
|
||||
gboolean gimp_image_undo_push_image_sample_point (GimpImage *gimage,
|
||||
const gchar *undo_desc,
|
||||
GimpSamplePoint *sample_point);
|
||||
gboolean gimp_image_undo_push_image_colormap (GimpImage *gimage,
|
||||
const gchar *undo_desc);
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "gimpimage-colorhash.h"
|
||||
#include "gimpimage-colormap.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-sample-points.h"
|
||||
#include "gimpimage-preview.h"
|
||||
#include "gimpimage-qmask.h"
|
||||
#include "gimpimage-undo.h"
|
||||
@ -92,6 +93,7 @@ enum
|
||||
DIRTY,
|
||||
UPDATE,
|
||||
UPDATE_GUIDE,
|
||||
UPDATE_SAMPLE_POINT,
|
||||
COLORMAP_CHANGED,
|
||||
UNDO_EVENT,
|
||||
FLUSH,
|
||||
@ -398,6 +400,16 @@ gimp_image_class_init (GimpImageClass *klass)
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_POINTER);
|
||||
|
||||
gimp_image_signals[UPDATE_SAMPLE_POINT] =
|
||||
g_signal_new ("update_sample_point",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageClass, update_sample_point),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__POINTER,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_POINTER);
|
||||
|
||||
gimp_image_signals[COLORMAP_CHANGED] =
|
||||
g_signal_new ("colormap_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
@ -460,6 +472,7 @@ gimp_image_class_init (GimpImageClass *klass)
|
||||
klass->dirty = NULL;
|
||||
klass->update = NULL;
|
||||
klass->update_guide = NULL;
|
||||
klass->update_sample_point = NULL;
|
||||
klass->colormap_changed = gimp_image_real_colormap_changed;
|
||||
klass->undo_event = NULL;
|
||||
klass->flush = gimp_image_real_flush;
|
||||
@ -533,6 +546,8 @@ gimp_image_init (GimpImage *gimage)
|
||||
|
||||
gimage->grid = NULL;
|
||||
|
||||
gimage->sample_points = NULL;
|
||||
|
||||
gimage->layers = gimp_list_new (GIMP_TYPE_LAYER, TRUE);
|
||||
gimage->channels = gimp_list_new (GIMP_TYPE_CHANNEL, TRUE);
|
||||
gimage->vectors = gimp_list_new (GIMP_TYPE_VECTORS, TRUE);
|
||||
@ -858,6 +873,13 @@ gimp_image_finalize (GObject *object)
|
||||
gimage->grid = NULL;
|
||||
}
|
||||
|
||||
if (gimage->sample_points)
|
||||
{
|
||||
g_list_foreach (gimage->sample_points, (GFunc) gimp_image_sample_point_unref, NULL);
|
||||
g_list_free (gimage->sample_points);
|
||||
gimage->sample_points = NULL;
|
||||
}
|
||||
|
||||
if (gimage->undo_stack)
|
||||
{
|
||||
g_object_unref (gimage->undo_stack);
|
||||
@ -915,6 +937,8 @@ gimp_image_get_memsize (GimpObject *object,
|
||||
|
||||
memsize += gimp_g_list_get_memsize (gimage->guides, sizeof (GimpGuide));
|
||||
|
||||
memsize += gimp_g_list_get_memsize (gimage->sample_points, sizeof (GimpSamplePoint));
|
||||
|
||||
if (gimage->grid)
|
||||
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->grid), gui_size);
|
||||
|
||||
@ -1631,6 +1655,16 @@ gimp_image_update_guide (GimpImage *gimage,
|
||||
g_signal_emit (gimage, gimp_image_signals[UPDATE_GUIDE], 0, guide);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_update_sample_point (GimpImage *gimage,
|
||||
GimpSamplePoint *sample_point)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (sample_point != NULL);
|
||||
|
||||
g_signal_emit (gimage, gimp_image_signals[UPDATE_SAMPLE_POINT], 0, sample_point);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_colormap_changed (GimpImage *gimage,
|
||||
gint color_index)
|
||||
|
@ -129,6 +129,7 @@ struct _GimpImage
|
||||
|
||||
GList *guides; /* guides */
|
||||
GimpGrid *grid; /* grid */
|
||||
GList *sample_points; /* color sample points */
|
||||
|
||||
/* Layer/Channel attributes */
|
||||
GimpContainer *layers; /* the list of layers */
|
||||
@ -207,6 +208,8 @@ struct _GimpImageClass
|
||||
gint height);
|
||||
void (* update_guide) (GimpImage *gimage,
|
||||
GimpGuide *guide);
|
||||
void (* update_sample_point) (GimpImage *gimage,
|
||||
GimpSamplePoint *sample_point);
|
||||
void (* colormap_changed) (GimpImage *gimage,
|
||||
gint color_index);
|
||||
void (* undo_event) (GimpImage *gimage,
|
||||
@ -294,6 +297,8 @@ void gimp_image_update (GimpImage *gimage,
|
||||
gint height);
|
||||
void gimp_image_update_guide (GimpImage *gimage,
|
||||
GimpGuide *guide);
|
||||
void gimp_image_update_sample_point (GimpImage *gimage,
|
||||
GimpSamplePoint *sample_point);
|
||||
void gimp_image_colormap_changed (GimpImage *gimage,
|
||||
gint col);
|
||||
void gimp_image_selection_control (GimpImage *gimage,
|
||||
|
@ -48,6 +48,7 @@ enum
|
||||
PROP_SHOW_SELECTION,
|
||||
PROP_SHOW_LAYER_BOUNDARY,
|
||||
PROP_SHOW_GUIDES,
|
||||
PROP_SHOW_SAMPLE_POINTS,
|
||||
PROP_SHOW_GRID,
|
||||
PROP_PADDING_MODE,
|
||||
PROP_PADDING_COLOR
|
||||
@ -177,6 +178,10 @@ gimp_display_options_class_init (GimpDisplayOptionsClass *klass)
|
||||
"show-layer-boundary", SHOW_LAYER_BOUNDARY_BLURB,
|
||||
TRUE,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_SAMPLE_POINTS,
|
||||
"show-sample-points", SHOW_SAMPLE_POINTS_BLURB,
|
||||
TRUE,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_GUIDES,
|
||||
"show-guides", SHOW_GUIDES_BLURB,
|
||||
TRUE,
|
||||
@ -235,6 +240,10 @@ gimp_display_options_fs_class_init (GimpDisplayOptionsClass *klass)
|
||||
"show-guides", SHOW_GUIDES_BLURB,
|
||||
FALSE,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_SAMPLE_POINTS,
|
||||
"show-sample-points", SHOW_SAMPLE_POINTS_BLURB,
|
||||
FALSE,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_GRID,
|
||||
"show-grid", SHOW_GRID_BLURB,
|
||||
FALSE,
|
||||
@ -287,6 +296,9 @@ gimp_display_options_set_property (GObject *object,
|
||||
case PROP_SHOW_GUIDES:
|
||||
options->show_guides = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_SHOW_SAMPLE_POINTS:
|
||||
options->show_sample_points = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_SHOW_GRID:
|
||||
options->show_grid = g_value_get_boolean (value);
|
||||
break;
|
||||
@ -334,6 +346,9 @@ gimp_display_options_get_property (GObject *object,
|
||||
case PROP_SHOW_GUIDES:
|
||||
g_value_set_boolean (value, options->show_guides);
|
||||
break;
|
||||
case PROP_SHOW_SAMPLE_POINTS:
|
||||
g_value_set_boolean (value, options->show_sample_points);
|
||||
break;
|
||||
case PROP_SHOW_GRID:
|
||||
g_value_set_boolean (value, options->show_grid);
|
||||
break;
|
||||
|
@ -49,6 +49,7 @@ struct _GimpDisplayOptions
|
||||
gboolean show_selection;
|
||||
gboolean show_layer_boundary;
|
||||
gboolean show_guides;
|
||||
gboolean show_sample_points;
|
||||
gboolean show_grid;
|
||||
GimpCanvasPaddingMode padding_mode;
|
||||
GimpRGB padding_color;
|
||||
|
@ -402,6 +402,35 @@ gimp_display_shell_get_show_guides (GimpDisplayShell *shell)
|
||||
return GET_OPTIONS (shell)->show_guides;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_set_show_sample_points (GimpDisplayShell *shell,
|
||||
gboolean show)
|
||||
{
|
||||
GimpDisplayOptions *options;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
options = GET_OPTIONS (shell);
|
||||
|
||||
g_object_set (options, "show-sample-points", show, NULL);
|
||||
|
||||
if (shell->gdisp->gimage->sample_points)
|
||||
gimp_display_shell_expose_full (shell);
|
||||
|
||||
SET_ACTIVE (shell->menubar_manager, "view-show-sample-points", show);
|
||||
|
||||
if (IS_ACTIVE_DISPLAY (shell))
|
||||
SET_ACTIVE (shell->popup_manager, "view-show-sample-points", show);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_display_shell_get_show_sample_points (GimpDisplayShell *shell)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
|
||||
|
||||
return GET_OPTIONS (shell)->show_sample_points;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_set_snap_to_grid (GimpDisplayShell *shell,
|
||||
gboolean snap)
|
||||
|
@ -60,6 +60,10 @@ void gimp_display_shell_set_show_guides (GimpDisplayShell *shell,
|
||||
gboolean show);
|
||||
gboolean gimp_display_shell_get_show_guides (GimpDisplayShell *shell);
|
||||
|
||||
void gimp_display_shell_set_show_sample_points (GimpDisplayShell *shell,
|
||||
gboolean show);
|
||||
gboolean gimp_display_shell_get_show_sample_points (GimpDisplayShell *shell);
|
||||
|
||||
void gimp_display_shell_set_snap_to_grid (GimpDisplayShell *shell,
|
||||
gboolean snap);
|
||||
gboolean gimp_display_shell_get_snap_to_grid (GimpDisplayShell *shell);
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-guides.h"
|
||||
#include "core/gimpimage-sample-points.h"
|
||||
#include "core/gimpimage-qmask.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
@ -217,6 +218,8 @@ gimp_display_shell_events (GtkWidget *widget,
|
||||
options->show_layer_boundary);
|
||||
gimp_display_shell_set_show_guides (shell,
|
||||
options->show_guides);
|
||||
gimp_display_shell_set_show_sample_points (shell,
|
||||
options->show_sample_points);
|
||||
gimp_display_shell_set_show_grid (shell,
|
||||
options->show_grid);
|
||||
gimp_display_shell_set_padding (shell,
|
||||
@ -408,6 +411,9 @@ gimp_display_shell_canvas_expose (GtkWidget *widget,
|
||||
/* draw the guides */
|
||||
gimp_display_shell_draw_guides (shell);
|
||||
|
||||
/* draw the sample points */
|
||||
gimp_display_shell_draw_sample_points (shell);
|
||||
|
||||
/* draw the grid */
|
||||
gimp_display_shell_draw_grid (shell, &eevent->area);
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "core/gimpgrid.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-guides.h"
|
||||
#include "core/gimpimage-sample-points.h"
|
||||
#include "core/gimplist.h"
|
||||
|
||||
#include "vectors/gimpstroke.h"
|
||||
@ -123,6 +124,73 @@ gimp_display_shell_draw_guides (GimpDisplayShell *shell)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_draw_sample_point (GimpDisplayShell *shell,
|
||||
GimpSamplePoint *sample_point,
|
||||
gboolean active)
|
||||
{
|
||||
gint x1, x2;
|
||||
gint y1, y2;
|
||||
gint x, y;
|
||||
gint w, h;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
g_return_if_fail (sample_point != NULL);
|
||||
|
||||
if (sample_point->x < 0)
|
||||
return;
|
||||
|
||||
gimp_display_shell_transform_xy (shell,
|
||||
sample_point->x,
|
||||
sample_point->y,
|
||||
&x, &y, FALSE);
|
||||
|
||||
x1 = x - GIMP_SAMPLE_POINT_DRAW_SIZE;
|
||||
x2 = x + GIMP_SAMPLE_POINT_DRAW_SIZE;
|
||||
y1 = y - GIMP_SAMPLE_POINT_DRAW_SIZE;
|
||||
y2 = y + GIMP_SAMPLE_POINT_DRAW_SIZE;
|
||||
|
||||
|
||||
gdk_drawable_get_size (shell->canvas->window, &w, &h);
|
||||
|
||||
if (x < 0 || y < 0 || x >= w || y >= h)
|
||||
return;
|
||||
|
||||
if (x1 < 0) x1 = 0;
|
||||
if (y1 < 0) y1 = 0;
|
||||
if (x2 > w) x2 = w;
|
||||
if (y2 > h) y2 = h;
|
||||
|
||||
gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas),
|
||||
(active ?
|
||||
GIMP_CANVAS_STYLE_GUIDE_ACTIVE :
|
||||
GIMP_CANVAS_STYLE_GUIDE_NORMAL), x, y1, x, y2);
|
||||
gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas),
|
||||
(active ?
|
||||
GIMP_CANVAS_STYLE_GUIDE_ACTIVE :
|
||||
GIMP_CANVAS_STYLE_GUIDE_NORMAL), x1, y, x2, y);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_draw_sample_points (GimpDisplayShell *shell)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
if (gimp_display_shell_get_show_sample_points (shell))
|
||||
{
|
||||
GList *list;
|
||||
|
||||
for (list = shell->gdisp->gimage->sample_points;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
gimp_display_shell_draw_sample_point(shell,
|
||||
(GimpSamplePoint *) list->data,
|
||||
FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_draw_grid (GimpDisplayShell *shell,
|
||||
const GdkRectangle *area)
|
||||
|
@ -20,21 +20,25 @@
|
||||
#define __GIMP_DISPLAY_SHELL_DRAW_H__
|
||||
|
||||
|
||||
void gimp_display_shell_draw_guide (GimpDisplayShell *shell,
|
||||
GimpGuide *guide,
|
||||
gboolean active);
|
||||
void gimp_display_shell_draw_guides (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_draw_grid (GimpDisplayShell *shell,
|
||||
const GdkRectangle *area);
|
||||
void gimp_display_shell_draw_vector (GimpDisplayShell *shell,
|
||||
GimpVectors *vectors);
|
||||
void gimp_display_shell_draw_vectors (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_draw_cursor (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_draw_area (GimpDisplayShell *shell,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
void gimp_display_shell_draw_guide (GimpDisplayShell *shell,
|
||||
GimpGuide *guide,
|
||||
gboolean active);
|
||||
void gimp_display_shell_draw_guides (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_draw_sample_point (GimpDisplayShell *shell,
|
||||
GimpSamplePoint *sample_point,
|
||||
gboolean active);
|
||||
void gimp_display_shell_draw_sample_points (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_draw_grid (GimpDisplayShell *shell,
|
||||
const GdkRectangle *area);
|
||||
void gimp_display_shell_draw_vector (GimpDisplayShell *shell,
|
||||
GimpVectors *vectors);
|
||||
void gimp_display_shell_draw_vectors (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_draw_cursor (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_draw_area (GimpDisplayShell *shell,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h);
|
||||
|
||||
|
||||
#endif /* __GIMP_DISPLAY_SHELL_DRAW_H__ */
|
||||
|
@ -73,6 +73,9 @@ static void gimp_display_shell_qmask_changed_handler (GimpImage *g
|
||||
static void gimp_display_shell_update_guide_handler (GimpImage *gimage,
|
||||
GimpGuide *guide,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_update_sample_point_handler(GimpImage *gimage,
|
||||
GimpSamplePoint *sample_point,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_invalidate_preview_handler (GimpImage *gimage,
|
||||
GimpDisplayShell *shell);
|
||||
|
||||
@ -157,6 +160,9 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
|
||||
g_signal_connect (gimage, "update_guide",
|
||||
G_CALLBACK (gimp_display_shell_update_guide_handler),
|
||||
shell);
|
||||
g_signal_connect (gimage, "update_sample_point",
|
||||
G_CALLBACK (gimp_display_shell_update_sample_point_handler),
|
||||
shell);
|
||||
g_signal_connect (gimage, "invalidate_preview",
|
||||
G_CALLBACK (gimp_display_shell_invalidate_preview_handler),
|
||||
shell);
|
||||
@ -309,6 +315,9 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
|
||||
g_signal_handlers_disconnect_by_func (gimage,
|
||||
gimp_display_shell_update_guide_handler,
|
||||
shell);
|
||||
g_signal_handlers_disconnect_by_func (gimage,
|
||||
gimp_display_shell_update_sample_point_handler,
|
||||
shell);
|
||||
g_signal_handlers_disconnect_by_func (gimage,
|
||||
gimp_display_shell_qmask_changed_handler,
|
||||
shell);
|
||||
@ -444,6 +453,14 @@ gimp_display_shell_update_guide_handler (GimpImage *gimage,
|
||||
gimp_display_shell_expose_guide (shell, guide);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_update_sample_point_handler (GimpImage *gimage,
|
||||
GimpSamplePoint *sample_point,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
gimp_display_shell_expose_sample_point (shell, sample_point);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_invalidate_preview_handler (GimpImage *gimage,
|
||||
GimpDisplayShell *shell)
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-guides.h"
|
||||
#include "core/gimpimage-sample-points.h"
|
||||
#include "core/gimpimage-snap.h"
|
||||
#include "core/gimpmarshal.h"
|
||||
|
||||
@ -1263,6 +1264,33 @@ gimp_display_shell_expose_guide (GimpDisplayShell *shell,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_expose_sample_point (GimpDisplayShell *shell,
|
||||
GimpSamplePoint *sample_point)
|
||||
{
|
||||
gint x, y;
|
||||
gint xmin, xmax, ymin, ymax;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
g_return_if_fail (sample_point != NULL);
|
||||
|
||||
if (sample_point->x < 0)
|
||||
return;
|
||||
|
||||
gimp_display_shell_transform_xy (shell,
|
||||
sample_point->x,
|
||||
sample_point->y,
|
||||
&x, &y,
|
||||
FALSE);
|
||||
|
||||
xmin = MAX (0, x - GIMP_SAMPLE_POINT_DRAW_SIZE);
|
||||
xmax = MIN (shell->disp_width, x + GIMP_SAMPLE_POINT_DRAW_SIZE);
|
||||
ymin = MAX (0, y - GIMP_SAMPLE_POINT_DRAW_SIZE);
|
||||
ymax = MIN (shell->disp_height, y + GIMP_SAMPLE_POINT_DRAW_SIZE);
|
||||
|
||||
gimp_display_shell_expose_area (shell, xmin, ymin, xmax, ymax);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_display_shell_expose_full (GimpDisplayShell *shell)
|
||||
{
|
||||
|
@ -221,6 +221,8 @@ void gimp_display_shell_expose_area (GimpDisplayShell *shell,
|
||||
gint h);
|
||||
void gimp_display_shell_expose_guide (GimpDisplayShell *shell,
|
||||
GimpGuide *guide);
|
||||
void gimp_display_shell_expose_sample_point (GimpDisplayShell *shell,
|
||||
GimpSamplePoint *sample_point);
|
||||
void gimp_display_shell_expose_full (GimpDisplayShell *shell);
|
||||
|
||||
void gimp_display_shell_flush (GimpDisplayShell *shell,
|
||||
|
@ -80,6 +80,7 @@
|
||||
#define GIMP_HELP_VIEW_SHOW_LAYER_BOUNDARY "gimp-view-show-layer-boundary"
|
||||
#define GIMP_HELP_VIEW_SHOW_GUIDES "gimp-view-show-guides"
|
||||
#define GIMP_HELP_VIEW_SNAP_TO_GUIDES "gimp-view-snap-to-guides"
|
||||
#define GIMP_HELP_VIEW_SHOW_SAMPLE_POINTS "gimp-view-show-sample-points"
|
||||
#define GIMP_HELP_VIEW_SHOW_GRID "gimp-view-show-grid"
|
||||
#define GIMP_HELP_VIEW_SNAP_TO_GRID "gimp-view-snap-to-grid"
|
||||
#define GIMP_HELP_VIEW_SNAP_TO_CANVAS "gimp-view-snap-to-canvas"
|
||||
|
@ -238,6 +238,7 @@
|
||||
<menuitem action="view-show-selection" />
|
||||
<menuitem action="view-show-layer-boundary" />
|
||||
<menuitem action="view-show-guides" />
|
||||
<menuitem action="view-show-sample-points" />
|
||||
<menuitem action="view-show-grid" />
|
||||
<separator />
|
||||
<menuitem action="view-snap-to-guides" />
|
||||
|
Reference in New Issue
Block a user