diff --git a/ChangeLog b/ChangeLog index f2ec49cf58..c5e3eb5fc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-02-18 Simon Budig + + * app/config/gimpguiconfig.[ch] + * app/config/gimprc-blurbs.h: Added new GUI option: snapping distance + + * app/gui/preferences-dialog.c: add a preferences widget + + * app/tools/gimpmovetool.c + * app/display/gimpdisplayshell.c: use it for snapping. + 2004-02-18 Simon Budig * app/display/gimpdisplayshell.c diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c index ffd97bda7a..f3f0cba206 100644 --- a/app/config/gimpguiconfig.c +++ b/app/config/gimpguiconfig.c @@ -64,6 +64,7 @@ enum PROP_0, PROP_TRANSPARENCY_SIZE, PROP_TRANSPARENCY_TYPE, + PROP_SNAP_DISTANCE, PROP_DEFAULT_THRESHOLD, PROP_INFO_WINDOW_PER_DISPLAY, PROP_TRUST_DIRTY_FLAG, @@ -139,6 +140,10 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass) "transparency-type", TRANSPARENCY_TYPE_BLURB, GIMP_TYPE_CHECK_TYPE, GIMP_GRAY_CHECKS, 0); + GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_SNAP_DISTANCE, + "snap-distance", DEFAULT_SNAP_DISTANCE_BLURB, + 1, 255, 8, + 0); GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_DEFAULT_THRESHOLD, "default-threshold", DEFAULT_THRESHOLD_BLURB, 0, 255, 15, @@ -265,6 +270,9 @@ gimp_gui_config_set_property (GObject *object, case PROP_TRANSPARENCY_TYPE: gui_config->transparency_type = g_value_get_enum (value); break; + case PROP_SNAP_DISTANCE: + gui_config->snap_distance = g_value_get_int (value); + break; case PROP_DEFAULT_THRESHOLD: gui_config->default_threshold = g_value_get_int (value); break; @@ -354,6 +362,9 @@ gimp_gui_config_get_property (GObject *object, case PROP_TRANSPARENCY_TYPE: g_value_set_enum (value, gui_config->transparency_type); break; + case PROP_SNAP_DISTANCE: + g_value_set_int (value, gui_config->snap_distance); + break; case PROP_DEFAULT_THRESHOLD: g_value_set_int (value, gui_config->default_threshold); break; diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h index 61c66cedc3..2bd5deb46d 100644 --- a/app/config/gimpguiconfig.h +++ b/app/config/gimpguiconfig.h @@ -42,6 +42,7 @@ struct _GimpGuiConfig GimpCheckSize transparency_size; GimpCheckType transparency_type; + gint snap_distance; gint default_threshold; gboolean info_window_per_display; gboolean trust_dirty_flag; diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h index caf4e7b769..b45ca79109 100644 --- a/app/config/gimprc-blurbs.h +++ b/app/config/gimprc-blurbs.h @@ -66,6 +66,10 @@ N_("When enabled, this will ensure that each pixel of an image gets " \ "Specify a default palette. The palette is searched for in the " \ "specified palette path." +#define DEFAULT_SNAP_DISTANCE_BLURB \ +N_("This is the distance in pixels where Guide and Grid snapping " \ + "activates.") + #define DEFAULT_THRESHOLD_BLURB \ N_("Tools such as fuzzy-select and bucket fill find regions based on a " \ "seed-fill algorithm. The seed fill starts at the intially selected " \ diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index c6f1802a9f..3f664c2050 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -1351,6 +1351,15 @@ prefs_dialog_new (Gimp *gimp, &child_iter, page_index++); + /* Snapping Distance */ + vbox2 = prefs_frame_new (_("Guide and Grid Snapping"), + GTK_CONTAINER (vbox), FALSE); + table = prefs_table_new (1, GTK_CONTAINER (vbox2), FALSE); + + prefs_spin_button_add (object, "snap-distance", 1.0, 5.0, 0, + _("_Snap Distance:"), + GTK_TABLE (table), 0); + /* Contiguous Regions */ vbox2 = prefs_frame_new (_("Finding Contiguous Regions"), GTK_CONTAINER (vbox), FALSE); diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 5b39abae7d..a791396165 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -34,6 +34,7 @@ #include "config/gimpconfig.h" #include "config/gimpconfig-utils.h" #include "config/gimpdisplayconfig.h" +#include "config/gimpguiconfig.h" #include "core/gimp.h" #include "core/gimpbuffer.h" @@ -94,9 +95,6 @@ enum }; -#define SNAP_WIDTH 8.0 - - /* local function prototypes */ static void gimp_display_shell_class_init (GimpDisplayShellClass *klass); @@ -1037,6 +1035,9 @@ gimp_display_shell_snap_coords (GimpDisplayShell *shell, { gboolean snapped; gint tx, ty; + gint snap_distance; + + snap_distance = GIMP_GUI_CONFIG (shell->gdisp->gimage->gimp->config)->snap_distance; if (snap_width > 0 && snap_height > 0) { @@ -1049,8 +1050,8 @@ gimp_display_shell_snap_coords (GimpDisplayShell *shell, snap_height, &tx, &ty, - FUNSCALEX (shell, SNAP_WIDTH), - FUNSCALEY (shell, SNAP_WIDTH), + FUNSCALEX (shell, snap_distance), + FUNSCALEY (shell, snap_distance), snap_to_guides, snap_to_grid); } @@ -1061,8 +1062,8 @@ gimp_display_shell_snap_coords (GimpDisplayShell *shell, coords->y + snap_offset_y, &tx, &ty, - FUNSCALEX (shell, SNAP_WIDTH), - FUNSCALEY (shell, SNAP_WIDTH), + FUNSCALEX (shell, snap_distance), + FUNSCALEY (shell, snap_distance), snap_to_guides, snap_to_grid); } diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index c6f1802a9f..3f664c2050 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -1351,6 +1351,15 @@ prefs_dialog_new (Gimp *gimp, &child_iter, page_index++); + /* Snapping Distance */ + vbox2 = prefs_frame_new (_("Guide and Grid Snapping"), + GTK_CONTAINER (vbox), FALSE); + table = prefs_table_new (1, GTK_CONTAINER (vbox2), FALSE); + + prefs_spin_button_add (object, "snap-distance", 1.0, 5.0, 0, + _("_Snap Distance:"), + GTK_TABLE (table), 0); + /* Contiguous Regions */ vbox2 = prefs_frame_new (_("Finding Contiguous Regions"), GTK_CONTAINER (vbox), FALSE); diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c index e7d8a6a432..35eb6cac37 100644 --- a/app/tools/gimpmovetool.c +++ b/app/tools/gimpmovetool.c @@ -26,6 +26,9 @@ #include "tools-types.h" +#include "config/gimpguiconfig.h" + +#include "core/gimp.h" #include "core/gimpimage.h" #include "core/gimpimage-guides.h" #include "core/gimplayer.h" @@ -51,9 +54,6 @@ #include "gimp-intl.h" -#define SNAP_WIDTH 8.0 - - /* local function prototypes */ static void gimp_move_tool_class_init (GimpMoveToolClass *klass); @@ -294,10 +294,14 @@ gimp_move_tool_button_press (GimpTool *tool, } else { + gint snap_distance; + + snap_distance = GIMP_GUI_CONFIG (gdisp->gimage->gimp->config)->snap_distance; + if (gimp_display_shell_get_show_guides (shell) && (guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y, - FUNSCALEX (shell, SNAP_WIDTH), - FUNSCALEY (shell, SNAP_WIDTH)))) + FUNSCALEX (shell, snap_distance), + FUNSCALEY (shell, snap_distance)))) { move->guide = guide; move->moving_guide = TRUE; @@ -569,9 +573,12 @@ gimp_move_tool_oper_update (GimpTool *tool, gimp_display_shell_get_show_guides (shell) && shell->proximity) { + gint snap_distance; + + snap_distance = GIMP_GUI_CONFIG (gdisp->gimage->gimp->config)->snap_distance; guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y, - FUNSCALEX (shell, SNAP_WIDTH), - FUNSCALEY (shell, SNAP_WIDTH)); + FUNSCALEX (shell, snap_distance), + FUNSCALEY (shell, snap_distance)); } if (move->guide && move->guide != guide) @@ -643,11 +650,14 @@ gimp_move_tool_cursor_update (GimpTool *tool, { GimpGuide *guide; GimpLayer *layer; + gint snap_distance; + + snap_distance = GIMP_GUI_CONFIG (gdisp->gimage->gimp->config)->snap_distance; if (gimp_display_shell_get_show_guides (shell) && (guide = gimp_image_find_guide (gdisp->gimage, coords->x, coords->y, - FUNSCALEX (shell, SNAP_WIDTH), - FUNSCALEY (shell, SNAP_WIDTH)))) + FUNSCALEX (shell, snap_distance), + FUNSCALEY (shell, snap_distance)))) { cursor = GDK_HAND2; tool_cursor = GIMP_HAND_TOOL_CURSOR;