gimp/app/core/gimpimage-snap.c

704 lines
22 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
* (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, see <http://www.gnu.org/licenses/>.
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
*/
#include "config.h"
#include <gegl.h>
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
#include "libgimpmath/gimpmath.h"
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
#include "core-types.h"
#include "gimp.h"
#include "gimpguide.h"
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
#include "gimpimage.h"
#include "gimpimage-grid.h"
Treat changes to the selection like changes to any other drawable: 2003-10-06 Michael Natterer <mitch@gimp.org> Treat changes to the selection like changes to any other drawable: * app/core/gimpchannel.c * app/core/gimpchannel-combine.c: call gimp_drawable_update() after changing the channel. * app/core/gimpimage.[ch]: added struct GimpImageFlushAccumulator with one member "gboolean mask_changed". Connect to "update" of the selection and set accum.mask_changed to TRUE in the callback. Added default implementation for GimpImage::flush() and emit "mask_changed" there. Unrelated: * app/core/gimpimage.h: removed GimpGuide struct... * app/core/gimpimage-guides.h: ...and added it here. * app/core/gimpimage-undo-push.c (undo_pop_mask) (undo_pop_channel_mod): don't distinguish between selection and non-selection channels and just call gimp_drawable_update(). * app/core/gimpundo.h * app/core/gimpimage-undo.c: removed "gboolean mask_changed" from the GimpUndoAccumulator struct since we don't have to care about that signal explicitly any more. * app/display/gimpdisplay-foreach.[ch]: removed gimp_displays_flush(). * tools/pdbgen/pdb/display.pdb (displays_flush_invoker): call gimp_image_flush() on all images so the flush accumulator is honored. This generalization enables the removal of more special purpose code which was needed to treat the selection different: * app/core/gimpimage-mask-select.[ch]: removed... * app/core/gimpchannel-select.[ch]: ...and added under a new name because it's not selection specific any more. * app/core/gimpimage-mask.[ch]: removed... * app/core/gimpselection.[ch]: ...added the two remaining functions here. Removed all calls to gimp_image_mask_changed(). * app/core/Makefile.am * app/core/gimp-edit.c * app/core/gimpdrawable-transform.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/display/gimpdisplayshell.c * app/gui/channels-commands.c * app/gui/layers-commands.c * app/gui/select-commands.c * app/gui/vectors-commands.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpiscissorstool.c * app/tools/gimprectselecttool.c * app/tools/gimptransformtool.c * app/widgets/gimpchanneltreeview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/paths.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/selection_tools.pdb: changed accordingly. * app/core/gimpdrawable-bucket-fill.c * app/core/gimpimage-colormap.c * app/core/gimplayer-floating-sel.c * app/core/gimplayer.c * app/gui/image-menu.c * app/paint/gimppaintcore.c * app/tools/gimpcroptool.c * app/tools/gimpinkoptions.c * app/tools/gimpvectortool.c: removed useless and/or obsolete #includes. * app/pdb/display_cmds.c * app/pdb/paths_cmds.c * app/pdb/selection_cmds.c * app/pdb/selection_tools_cmds.c: regenerated.
2003-10-06 20:17:11 +08:00
#include "gimpimage-guides.h"
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
#include "gimpimage-snap.h"
#include "vectors/gimpstroke.h"
#include "vectors/gimpvectors.h"
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
#include "gimp-intl.h"
static gboolean gimp_image_snap_distance (const gdouble unsnapped,
const gdouble nearest,
const gdouble epsilon,
gdouble *mindist,
gdouble *target);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
/* public functions */
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
gboolean
gimp_image_snap_x (GimpImage *image,
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
gdouble x,
gdouble *tx,
gdouble epsilon_x,
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
gboolean snap_to_guides,
gboolean snap_to_grid,
gboolean snap_to_canvas)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
gdouble mindist = G_MAXDOUBLE;
gboolean snapped = FALSE;
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
g_return_val_if_fail (tx != NULL, FALSE);
*tx = x;
if (! gimp_image_get_guides (image)) snap_to_guides = FALSE;
if (! gimp_image_get_grid (image)) snap_to_grid = FALSE;
if (! (snap_to_guides || snap_to_grid || snap_to_canvas))
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
return FALSE;
app/actions/channels-commands.c app/actions/colormap-actions.c 2007-12-25 Michael Natterer <mitch@gimp.org> * app/actions/channels-commands.c * app/actions/colormap-actions.c * app/actions/colormap-commands.c * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpdrawable-preview.c * app/core/gimpimage-colorhash.c * app/core/gimpimage-colormap.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-quick-mask.c * app/core/gimpimage-resize.c * app/core/gimpimage-rotate.c * app/core/gimpimage-sample-points.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpimageundo.c * app/core/gimpitem-preview.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/core/gimpprojection-construct.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/core/gimpundo.c * app/dialogs/layer-options-dialog.c * app/dialogs/print-size-dialog.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/paint/gimppaintoptions.c * app/tools/gimpaligntool.c * app/tools/gimpcolortool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimprotatetool.c * app/vectors/gimpvectors-export.c * app/vectors/gimpvectors-import.c * app/vectors/gimpvectors.c * app/widgets/gimpimagepropview.c * app/widgets/gimpnavigationview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrendererimage.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: use accessors for many image properties. * app/pdb/guides_cmds.c * app/pdb/image_cmds.c: regenerated. svn path=/trunk/; revision=24432
2007-12-26 00:21:40 +08:00
if (x < -epsilon_x || x >= (gimp_image_get_width (image) + epsilon_x))
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
return FALSE;
if (snap_to_guides)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
GList *list;
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
GimpGuide *guide = list->data;
gint position = gimp_guide_get_position (guide);
if (position < 0)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
continue;
if (gimp_guide_get_orientation (guide) == GIMP_ORIENTATION_VERTICAL)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
snapped |= gimp_image_snap_distance (x, position,
epsilon_x,
&mindist, tx);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
}
}
}
if (snap_to_grid)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
GimpGrid *grid = gimp_image_get_grid (image);
gdouble xspacing;
gdouble xoffset;
gdouble i;
g_object_get (grid,
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
"xspacing", &xspacing,
"xoffset", &xoffset,
NULL);
/* the snap-to-grid part could probably be rewritten */
while (xoffset > xspacing)
xoffset -= xspacing;
app/actions/channels-commands.c app/actions/colormap-actions.c 2007-12-25 Michael Natterer <mitch@gimp.org> * app/actions/channels-commands.c * app/actions/colormap-actions.c * app/actions/colormap-commands.c * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpdrawable-preview.c * app/core/gimpimage-colorhash.c * app/core/gimpimage-colormap.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-quick-mask.c * app/core/gimpimage-resize.c * app/core/gimpimage-rotate.c * app/core/gimpimage-sample-points.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpimageundo.c * app/core/gimpitem-preview.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/core/gimpprojection-construct.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/core/gimpundo.c * app/dialogs/layer-options-dialog.c * app/dialogs/print-size-dialog.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/paint/gimppaintoptions.c * app/tools/gimpaligntool.c * app/tools/gimpcolortool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimprotatetool.c * app/vectors/gimpvectors-export.c * app/vectors/gimpvectors-import.c * app/vectors/gimpvectors.c * app/widgets/gimpimagepropview.c * app/widgets/gimpnavigationview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrendererimage.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: use accessors for many image properties. * app/pdb/guides_cmds.c * app/pdb/image_cmds.c: regenerated. svn path=/trunk/; revision=24432
2007-12-26 00:21:40 +08:00
for (i = xoffset; i <= gimp_image_get_width (image); i += xspacing)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
if (i < 0)
continue;
snapped |= gimp_image_snap_distance (x, i,
epsilon_x,
&mindist, tx);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
}
}
if (snap_to_canvas)
{
snapped |= gimp_image_snap_distance (x, 0,
epsilon_x,
&mindist, tx);
snapped |= gimp_image_snap_distance (x, gimp_image_get_width (image),
epsilon_x,
&mindist, tx);
}
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
return snapped;
}
gboolean
gimp_image_snap_y (GimpImage *image,
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
gdouble y,
gdouble *ty,
gdouble epsilon_y,
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
gboolean snap_to_guides,
gboolean snap_to_grid,
gboolean snap_to_canvas)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
gdouble mindist = G_MAXDOUBLE;
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
gboolean snapped = FALSE;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
g_return_val_if_fail (ty != NULL, FALSE);
*ty = y;
if (! gimp_image_get_guides (image)) snap_to_guides = FALSE;
if (! gimp_image_get_grid (image)) snap_to_grid = FALSE;
if (! (snap_to_guides || snap_to_grid || snap_to_canvas))
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
return FALSE;
app/actions/channels-commands.c app/actions/colormap-actions.c 2007-12-25 Michael Natterer <mitch@gimp.org> * app/actions/channels-commands.c * app/actions/colormap-actions.c * app/actions/colormap-commands.c * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpdrawable-preview.c * app/core/gimpimage-colorhash.c * app/core/gimpimage-colormap.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-quick-mask.c * app/core/gimpimage-resize.c * app/core/gimpimage-rotate.c * app/core/gimpimage-sample-points.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpimageundo.c * app/core/gimpitem-preview.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/core/gimpprojection-construct.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/core/gimpundo.c * app/dialogs/layer-options-dialog.c * app/dialogs/print-size-dialog.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/paint/gimppaintoptions.c * app/tools/gimpaligntool.c * app/tools/gimpcolortool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimprotatetool.c * app/vectors/gimpvectors-export.c * app/vectors/gimpvectors-import.c * app/vectors/gimpvectors.c * app/widgets/gimpimagepropview.c * app/widgets/gimpnavigationview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrendererimage.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: use accessors for many image properties. * app/pdb/guides_cmds.c * app/pdb/image_cmds.c: regenerated. svn path=/trunk/; revision=24432
2007-12-26 00:21:40 +08:00
if (y < -epsilon_y || y >= (gimp_image_get_height (image) + epsilon_y))
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
return FALSE;
if (snap_to_guides)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
GList *list;
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
GimpGuide *guide = list->data;
gint position = gimp_guide_get_position (guide);
if (position < 0)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
continue;
if (gimp_guide_get_orientation (guide) == GIMP_ORIENTATION_HORIZONTAL)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
snapped |= gimp_image_snap_distance (y, position,
epsilon_y,
&mindist, ty);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
}
}
}
if (snap_to_grid)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
GimpGrid *grid = gimp_image_get_grid (image);
gdouble yspacing;
gdouble yoffset;
gdouble i;
g_object_get (grid,
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
"yspacing", &yspacing,
"yoffset", &yoffset,
NULL);
while (yoffset > yspacing)
yoffset -= yspacing;
app/actions/channels-commands.c app/actions/colormap-actions.c 2007-12-25 Michael Natterer <mitch@gimp.org> * app/actions/channels-commands.c * app/actions/colormap-actions.c * app/actions/colormap-commands.c * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpdrawable-preview.c * app/core/gimpimage-colorhash.c * app/core/gimpimage-colormap.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-quick-mask.c * app/core/gimpimage-resize.c * app/core/gimpimage-rotate.c * app/core/gimpimage-sample-points.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpimageundo.c * app/core/gimpitem-preview.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/core/gimpprojection-construct.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/core/gimpundo.c * app/dialogs/layer-options-dialog.c * app/dialogs/print-size-dialog.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/paint/gimppaintoptions.c * app/tools/gimpaligntool.c * app/tools/gimpcolortool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimprotatetool.c * app/vectors/gimpvectors-export.c * app/vectors/gimpvectors-import.c * app/vectors/gimpvectors.c * app/widgets/gimpimagepropview.c * app/widgets/gimpnavigationview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrendererimage.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: use accessors for many image properties. * app/pdb/guides_cmds.c * app/pdb/image_cmds.c: regenerated. svn path=/trunk/; revision=24432
2007-12-26 00:21:40 +08:00
for (i = yoffset; i <= gimp_image_get_height (image); i += yspacing)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
if (i < 0)
continue;
snapped |= gimp_image_snap_distance (y, i,
epsilon_y,
&mindist, ty);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
}
}
if (snap_to_canvas)
{
snapped |= gimp_image_snap_distance (y, 0,
epsilon_y,
&mindist, ty);
snapped |= gimp_image_snap_distance (y, gimp_image_get_height (image),
epsilon_y,
&mindist, ty);
}
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
return snapped;
}
gboolean
gimp_image_snap_point (GimpImage *image,
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
gdouble x,
gdouble y,
gdouble *tx,
gdouble *ty,
gdouble epsilon_x,
gdouble epsilon_y,
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
gboolean snap_to_guides,
gboolean snap_to_grid,
gboolean snap_to_canvas,
gboolean snap_to_vectors)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
gdouble mindist_x = G_MAXDOUBLE;
gdouble mindist_y = G_MAXDOUBLE;
gboolean snapped = FALSE;
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
g_return_val_if_fail (tx != NULL, FALSE);
g_return_val_if_fail (ty != NULL, FALSE);
*tx = x;
*ty = y;
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
if (! gimp_image_get_guides (image)) snap_to_guides = FALSE;
app/actions/channels-commands.c app/actions/colormap-actions.c 2007-12-25 Michael Natterer <mitch@gimp.org> * app/actions/channels-commands.c * app/actions/colormap-actions.c * app/actions/colormap-commands.c * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpdrawable-preview.c * app/core/gimpimage-colorhash.c * app/core/gimpimage-colormap.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-quick-mask.c * app/core/gimpimage-resize.c * app/core/gimpimage-rotate.c * app/core/gimpimage-sample-points.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpimageundo.c * app/core/gimpitem-preview.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/core/gimpprojection-construct.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/core/gimpundo.c * app/dialogs/layer-options-dialog.c * app/dialogs/print-size-dialog.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/paint/gimppaintoptions.c * app/tools/gimpaligntool.c * app/tools/gimpcolortool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimprotatetool.c * app/vectors/gimpvectors-export.c * app/vectors/gimpvectors-import.c * app/vectors/gimpvectors.c * app/widgets/gimpimagepropview.c * app/widgets/gimpnavigationview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrendererimage.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: use accessors for many image properties. * app/pdb/guides_cmds.c * app/pdb/image_cmds.c: regenerated. svn path=/trunk/; revision=24432
2007-12-26 00:21:40 +08:00
if (! gimp_image_get_grid (image)) snap_to_grid = FALSE;
if (! gimp_image_get_active_vectors (image)) snap_to_vectors = FALSE;
if (! (snap_to_guides || snap_to_grid || snap_to_canvas || snap_to_vectors))
return FALSE;
app/actions/channels-commands.c app/actions/colormap-actions.c 2007-12-25 Michael Natterer <mitch@gimp.org> * app/actions/channels-commands.c * app/actions/colormap-actions.c * app/actions/colormap-commands.c * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpdrawable-preview.c * app/core/gimpimage-colorhash.c * app/core/gimpimage-colormap.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-quick-mask.c * app/core/gimpimage-resize.c * app/core/gimpimage-rotate.c * app/core/gimpimage-sample-points.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpimageundo.c * app/core/gimpitem-preview.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/core/gimpprojection-construct.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/core/gimpundo.c * app/dialogs/layer-options-dialog.c * app/dialogs/print-size-dialog.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/paint/gimppaintoptions.c * app/tools/gimpaligntool.c * app/tools/gimpcolortool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimprotatetool.c * app/vectors/gimpvectors-export.c * app/vectors/gimpvectors-import.c * app/vectors/gimpvectors.c * app/widgets/gimpimagepropview.c * app/widgets/gimpnavigationview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrendererimage.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: use accessors for many image properties. * app/pdb/guides_cmds.c * app/pdb/image_cmds.c: regenerated. svn path=/trunk/; revision=24432
2007-12-26 00:21:40 +08:00
if (x < -epsilon_x || x >= (gimp_image_get_width (image) + epsilon_x) ||
y < -epsilon_y || y >= (gimp_image_get_height (image) + epsilon_y))
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
return FALSE;
}
if (snap_to_guides)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
GList *list;
for (list = gimp_image_get_guides (image); list; list = g_list_next (list))
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
GimpGuide *guide = list->data;
gint position = gimp_guide_get_position (guide);
if (position < 0)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
continue;
switch (gimp_guide_get_orientation (guide))
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
case GIMP_ORIENTATION_HORIZONTAL:
snapped |= gimp_image_snap_distance (y, position,
epsilon_y,
&mindist_y, ty);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
break;
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
case GIMP_ORIENTATION_VERTICAL:
snapped |= gimp_image_snap_distance (x, position,
epsilon_x,
&mindist_x, tx);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
break;
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
default:
break;
}
}
}
if (snap_to_grid)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
GimpGrid *grid = gimp_image_get_grid (image);
gdouble xspacing, yspacing;
gdouble xoffset, yoffset;
gdouble i;
g_object_get (grid,
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
"xspacing", &xspacing,
"yspacing", &yspacing,
"xoffset", &xoffset,
"yoffset", &yoffset,
NULL);
while (xoffset > xspacing)
xoffset -= xspacing;
while (yoffset > yspacing)
yoffset -= yspacing;
app/actions/channels-commands.c app/actions/colormap-actions.c 2007-12-25 Michael Natterer <mitch@gimp.org> * app/actions/channels-commands.c * app/actions/colormap-actions.c * app/actions/colormap-commands.c * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpdrawable-preview.c * app/core/gimpimage-colorhash.c * app/core/gimpimage-colormap.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-quick-mask.c * app/core/gimpimage-resize.c * app/core/gimpimage-rotate.c * app/core/gimpimage-sample-points.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpimageundo.c * app/core/gimpitem-preview.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/core/gimpprojection-construct.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/core/gimpundo.c * app/dialogs/layer-options-dialog.c * app/dialogs/print-size-dialog.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/paint/gimppaintoptions.c * app/tools/gimpaligntool.c * app/tools/gimpcolortool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimprotatetool.c * app/vectors/gimpvectors-export.c * app/vectors/gimpvectors-import.c * app/vectors/gimpvectors.c * app/widgets/gimpimagepropview.c * app/widgets/gimpnavigationview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrendererimage.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: use accessors for many image properties. * app/pdb/guides_cmds.c * app/pdb/image_cmds.c: regenerated. svn path=/trunk/; revision=24432
2007-12-26 00:21:40 +08:00
for (i = xoffset; i <= gimp_image_get_width (image); i += xspacing)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
if (i < 0)
continue;
snapped |= gimp_image_snap_distance (x, i,
epsilon_x,
&mindist_x, tx);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
}
app/actions/channels-commands.c app/actions/colormap-actions.c 2007-12-25 Michael Natterer <mitch@gimp.org> * app/actions/channels-commands.c * app/actions/colormap-actions.c * app/actions/colormap-commands.c * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpdrawable-preview.c * app/core/gimpimage-colorhash.c * app/core/gimpimage-colormap.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-quick-mask.c * app/core/gimpimage-resize.c * app/core/gimpimage-rotate.c * app/core/gimpimage-sample-points.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpimageundo.c * app/core/gimpitem-preview.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/core/gimpprojection-construct.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/core/gimpundo.c * app/dialogs/layer-options-dialog.c * app/dialogs/print-size-dialog.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/paint/gimppaintoptions.c * app/tools/gimpaligntool.c * app/tools/gimpcolortool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimprotatetool.c * app/vectors/gimpvectors-export.c * app/vectors/gimpvectors-import.c * app/vectors/gimpvectors.c * app/widgets/gimpimagepropview.c * app/widgets/gimpnavigationview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrendererimage.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: use accessors for many image properties. * app/pdb/guides_cmds.c * app/pdb/image_cmds.c: regenerated. svn path=/trunk/; revision=24432
2007-12-26 00:21:40 +08:00
for (i = yoffset; i <= gimp_image_get_height (image); i += yspacing)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
if (i < 0)
continue;
snapped |= gimp_image_snap_distance (y, i,
epsilon_y,
&mindist_y, ty);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
}
}
if (snap_to_canvas)
{
snapped |= gimp_image_snap_distance (x, 0,
epsilon_x,
&mindist_x, tx);
snapped |= gimp_image_snap_distance (x, gimp_image_get_width (image),
epsilon_x,
&mindist_x, tx);
snapped |= gimp_image_snap_distance (y, 0,
epsilon_y,
&mindist_y, ty);
snapped |= gimp_image_snap_distance (y, gimp_image_get_height (image),
epsilon_y,
&mindist_y, ty);
}
if (snap_to_vectors)
{
GimpVectors *vectors = gimp_image_get_active_vectors (image);
GimpStroke *stroke = NULL;
GimpCoords coords = { 0, 0, 0, 0, 0 };
coords.x = x;
coords.y = y;
while ((stroke = gimp_vectors_stroke_get_next (vectors, stroke)))
{
GimpCoords nearest;
if (gimp_stroke_nearest_point_get (stroke, &coords, 1.0,
&nearest,
NULL, NULL, NULL) >= 0)
{
snapped |= gimp_image_snap_distance (x, nearest.x,
epsilon_x,
&mindist_x, tx);
snapped |= gimp_image_snap_distance (y, nearest.y,
epsilon_y,
&mindist_y, ty);
}
}
}
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
return snapped;
}
gboolean
gimp_image_snap_rectangle (GimpImage *image,
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gdouble *tx1,
gdouble *ty1,
gdouble epsilon_x,
gdouble epsilon_y,
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
gboolean snap_to_guides,
gboolean snap_to_grid,
gboolean snap_to_canvas,
gboolean snap_to_vectors)
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
gdouble nx, ny;
gdouble mindist_x = G_MAXDOUBLE;
gdouble mindist_y = G_MAXDOUBLE;
gdouble x_center = (x1 + x2) / 2.0;
gdouble y_center = (y1 + y2) / 2.0;
gboolean snapped = FALSE;
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
g_return_val_if_fail (tx1 != NULL, FALSE);
g_return_val_if_fail (ty1 != NULL, FALSE);
*tx1 = x1;
*ty1 = y1;
if (! gimp_image_get_guides (image)) snap_to_guides = FALSE;
app/actions/channels-commands.c app/actions/colormap-actions.c 2007-12-25 Michael Natterer <mitch@gimp.org> * app/actions/channels-commands.c * app/actions/colormap-actions.c * app/actions/colormap-commands.c * app/actions/image-commands.c * app/core/gimp-edit.c * app/core/gimpdrawable-preview.c * app/core/gimpimage-colorhash.c * app/core/gimpimage-colormap.c * app/core/gimpimage-convert.c * app/core/gimpimage-crop.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-flip.c * app/core/gimpimage-guides.c * app/core/gimpimage-merge.c * app/core/gimpimage-preview.c * app/core/gimpimage-quick-mask.c * app/core/gimpimage-resize.c * app/core/gimpimage-rotate.c * app/core/gimpimage-sample-points.c * app/core/gimpimage-scale.c * app/core/gimpimage-snap.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpimageundo.c * app/core/gimpitem-preview.c * app/core/gimpitem.c * app/core/gimplayer.c * app/core/gimppalette-import.c * app/core/gimpprojection-construct.c * app/core/gimpprojection.c * app/core/gimpselection.c * app/core/gimpundo.c * app/dialogs/layer-options-dialog.c * app/dialogs/print-size-dialog.c * app/display/gimpdisplay.c * app/display/gimpdisplayshell-draw.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-title.c * app/display/gimpdisplayshell-transform.c * app/display/gimpdisplayshell.c * app/display/gimpstatusbar.c * app/file/file-open.c * app/paint/gimppaintoptions.c * app/tools/gimpaligntool.c * app/tools/gimpcolortool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimprotatetool.c * app/vectors/gimpvectors-export.c * app/vectors/gimpvectors-import.c * app/vectors/gimpvectors.c * app/widgets/gimpimagepropview.c * app/widgets/gimpnavigationview.c * app/widgets/gimpselectioneditor.c * app/widgets/gimpviewrendererdrawable.c * app/widgets/gimpviewrendererimage.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: use accessors for many image properties. * app/pdb/guides_cmds.c * app/pdb/image_cmds.c: regenerated. svn path=/trunk/; revision=24432
2007-12-26 00:21:40 +08:00
if (! gimp_image_get_grid (image)) snap_to_grid = FALSE;
if (! gimp_image_get_active_vectors (image)) snap_to_vectors = FALSE;
if (! (snap_to_guides || snap_to_grid || snap_to_canvas || snap_to_vectors))
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
return FALSE;
/* left edge */
if (gimp_image_snap_x (image, x1, &nx,
MIN (epsilon_x, mindist_x),
snap_to_guides,
snap_to_grid,
snap_to_canvas))
{
mindist_x = ABS (nx - x1);
*tx1 = nx;
snapped = TRUE;
}
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
/* right edge */
if (gimp_image_snap_x (image, x2, &nx,
MIN (epsilon_x, mindist_x),
snap_to_guides,
snap_to_grid,
snap_to_canvas))
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
mindist_x = ABS (nx - x2);
*tx1 = RINT (x1 + (nx - x2));
snapped = TRUE;
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
}
/* center, vertical */
if (gimp_image_snap_x (image, x_center, &nx,
MIN (epsilon_x, mindist_x),
snap_to_guides,
snap_to_grid,
snap_to_canvas))
{
mindist_x = ABS (nx - x_center);
*tx1 = RINT (x1 + (nx - x_center));
snapped = TRUE;
}
/* top edge */
if (gimp_image_snap_y (image, y1, &ny,
MIN (epsilon_y, mindist_y),
snap_to_guides,
snap_to_grid,
snap_to_canvas))
{
mindist_y = ABS (ny - y1);
*ty1 = ny;
snapped = TRUE;
}
/* bottom edge */
if (gimp_image_snap_y (image, y2, &ny,
MIN (epsilon_y, mindist_y),
snap_to_guides,
snap_to_grid,
snap_to_canvas))
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
{
mindist_y = ABS (ny - y2);
*ty1 = RINT (y1 + (ny - y2));
snapped = TRUE;
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
}
/* center, horizontal */
if (gimp_image_snap_y (image, y_center, &ny,
MIN (epsilon_y, mindist_y),
snap_to_guides,
snap_to_grid,
snap_to_canvas))
{
mindist_y = ABS (ny - y_center);
*ty1 = RINT (y1 + (ny - y_center));
snapped = TRUE;
}
if (snap_to_vectors)
{
GimpVectors *vectors = gimp_image_get_active_vectors (image);
GimpStroke *stroke = NULL;
GimpCoords coords1 = GIMP_COORDS_DEFAULT_VALUES;
GimpCoords coords2 = GIMP_COORDS_DEFAULT_VALUES;
while ((stroke = gimp_vectors_stroke_get_next (vectors, stroke)))
{
GimpCoords nearest;
gdouble dist;
/* top edge */
coords1.x = x1;
coords1.y = y1;
coords2.x = x2;
coords2.y = y1;
if (gimp_stroke_nearest_tangent_get (stroke, &coords1, &coords2,
1.0, &nearest,
NULL, NULL, NULL) >= 0)
{
snapped |= gimp_image_snap_distance (y1, nearest.y,
epsilon_y,
&mindist_y, ty1);
}
if (gimp_stroke_nearest_intersection_get (stroke, &coords1, &coords2,
1.0, &nearest,
NULL, NULL, NULL) >= 0)
{
snapped |= gimp_image_snap_distance (x1, nearest.x,
epsilon_x,
&mindist_x, tx1);
}
if (gimp_stroke_nearest_intersection_get (stroke, &coords2, &coords1,
1.0, &nearest,
NULL, NULL, NULL) >= 0)
{
dist = ABS (nearest.x - x2);
if (dist < MIN (epsilon_x, mindist_x))
{
mindist_x = dist;
*tx1 = RINT (x1 + (nearest.x - x2));
snapped = TRUE;
}
}
/* bottom edge */
coords1.x = x1;
coords1.y = y2;
coords2.x = x2;
coords2.y = y2;
if (gimp_stroke_nearest_tangent_get (stroke, &coords1, &coords2,
1.0, &nearest,
NULL, NULL, NULL) >= 0)
{
dist = ABS (nearest.y - y2);
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
if (dist < MIN (epsilon_y, mindist_y))
{
mindist_y = dist;
*ty1 = RINT (y1 + (nearest.y - y2));
snapped = TRUE;
}
}
if (gimp_stroke_nearest_intersection_get (stroke, &coords1, &coords2,
1.0, &nearest,
NULL, NULL, NULL) >= 0)
{
snapped |= gimp_image_snap_distance (x1, nearest.x,
epsilon_x,
&mindist_x, tx1);
}
if (gimp_stroke_nearest_intersection_get (stroke, &coords2, &coords1,
1.0, &nearest,
NULL, NULL, NULL) >= 0)
{
dist = ABS (nearest.x - x2);
if (dist < MIN (epsilon_x, mindist_x))
{
mindist_x = dist;
*tx1 = RINT (x1 + (nearest.x - x2));
snapped = TRUE;
}
}
/* left edge */
coords1.x = x1;
coords1.y = y1;
coords2.x = x1;
coords2.y = y2;
if (gimp_stroke_nearest_tangent_get (stroke, &coords1, &coords2,
1.0, &nearest,
NULL, NULL, NULL) >= 0)
{
snapped |= gimp_image_snap_distance (x1, nearest.x,
epsilon_x,
&mindist_x, tx1);
}
if (gimp_stroke_nearest_intersection_get (stroke, &coords1, &coords2,
1.0, &nearest,
NULL, NULL, NULL) >= 0)
{
snapped |= gimp_image_snap_distance (y1, nearest.y,
epsilon_y,
&mindist_y, ty1);
}
if (gimp_stroke_nearest_intersection_get (stroke, &coords2, &coords1,
1.0, &nearest,
NULL, NULL, NULL) >= 0)
{
dist = ABS (nearest.y - y2);
if (dist < MIN (epsilon_y, mindist_y))
{
mindist_y = dist;
*ty1 = RINT (y1 + (nearest.y - y2));
snapped = TRUE;
}
}
/* right edge */
coords1.x = x2;
coords1.y = y1;
coords2.x = x2;
coords2.y = y2;
if (gimp_stroke_nearest_tangent_get (stroke, &coords1, &coords2,
1.0, &nearest,
NULL, NULL, NULL) >= 0)
{
dist = ABS (nearest.x - x2);
if (dist < MIN (epsilon_x, mindist_x))
{
mindist_x = dist;
*tx1 = RINT (x1 + (nearest.x - x2));
snapped = TRUE;
}
}
if (gimp_stroke_nearest_intersection_get (stroke, &coords1, &coords2,
1.0, &nearest,
NULL, NULL, NULL) >= 0)
{
snapped |= gimp_image_snap_distance (y1, nearest.y,
epsilon_y,
&mindist_y, ty1);
}
if (gimp_stroke_nearest_intersection_get (stroke, &coords2, &coords1,
1.0, &nearest,
NULL, NULL, NULL) >= 0)
{
dist = ABS (nearest.y - y2);
if (dist < MIN (epsilon_y, mindist_y))
{
mindist_y = dist;
*ty1 = RINT (y1 + (nearest.y - y2));
snapped = TRUE;
}
}
}
}
return snapped;
Added a per image configurable grid. This fixes bug #65198 * app/core/Makefile.am * app/core/core-types.h: * app/core/gimpgrid.[ch]: added new class GimpGrid. * app/core/core-enums.[ch]: added new enum GimpGridType. * app/core/gimpimage-guides.[ch]: removed the gimp_image_snap_*() functions... * app/core/gimpimage-snap.[ch]: ...and added them here since they are no longer guide specific. * app/core/gimpimage-undo-push.[ch]: added gimp_image_undo_push_image_grid() * app/display/gimpdisplayshell-handlers.c: * app/core/gimpimage.[ch]: added grid member to _GimpImage. Added new signal "grid_changed", added gimp_image_grid_changed(), gimp_image_get_grid() and gimp_image_set_grid(). * app/display/gimpdisplayshell-appearance.[ch]: added gimp_display_shell_set_show_grid(), gimp_display_shell_get_show_grid(), gimp_display_shell_set_snap_to_grid() and gimp_display_shell_get_snap_to_grid(). * app/display/gimpdisplayshell-callbacks.c: added call to gimp_display_shell_draw_grid() * app/display/gimpdisplayshell.[ch]: added grid member to _GimpDisplayShellVisibility, added snap_to_grid and grid_dialog members to _GimpDisplayShell, added gimp_display_shell_draw_grid(), modified gimp_display_shell_snap_coords() to use the new gimp_image_snap_*() functions. * app/gui/image-menu.c: added grid entries to image_menu_entries[]. * app/gui/view-commands.[ch]: added view_configure_grid_cmd_callback(), view_toggle_grid_cmd_callback() and view_snap_to_grid_cmd_callback(). * app/gui/Makefile.am * app/gui/grid-dialog.[ch]: added a grid dialog.
2003-06-24 03:34:48 +08:00
}
/* private functions */
/**
* gimp_image_snap_distance:
* @unsnapped: One coordinate of the unsnapped position
* @nearest: One coordinate of a snapping position candidate
* @epsilon: The snapping threshold
* @mindist: The distance to the currently closest snapping target
* @target: The currently closest snapping target
*
* Finds out if snapping occurs from position to a snapping candidate
* and sets the target accordingly.
*
* Return value: %TRUE if snapping occured, %FALSE otherwise
*/
static gboolean
gimp_image_snap_distance (const gdouble unsnapped,
const gdouble nearest,
const gdouble epsilon,
gdouble *mindist,
gdouble *target)
{
const gdouble dist = ABS (nearest - unsnapped);
if (dist < MIN (epsilon, *mindist))
{
*mindist = dist;
*target = nearest;
return TRUE;
}
return FALSE;
}