gimp/app/tools/gimpfreeselecttool.c

1633 lines
56 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
1997-11-25 06:05:25 +08:00
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
* Major improvement to support polygonal segments
* Copyright (C) 2008 Martin Nordholts
*
* This program is free software: you can redistribute it and/or modify
1997-11-25 06:05:25 +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
1997-11-25 06:05:25 +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/>.
1997-11-25 06:05:25 +08:00
*/
#include "config.h"
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
#include <string.h>
#include <gegl.h>
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include <gtk/gtk.h>
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
#include <gdk/gdkkeysyms.h>
#include "libgimpmath/gimpmath.h"
2001-08-06 00:08:19 +08:00
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "core/gimp-utils.h"
#include "core/gimpchannel.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 "core/gimpchannel-select.h"
#include "core/gimpimage.h"
#include "core/gimplayer-floating-sel.h"
Makefile.am configure.in added the new library below. 2001-01-24 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added the new library below. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.[ch] * libgimpwidgets/gimpcolorbutton.[ch] * libgimpwidgets/gimpdialog.[ch] * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimphelpui.[ch] * libgimpwidgets/gimppatheditor.[ch] * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpquerybox.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch] * libgimpwidgets/gimpwidgets.[ch] * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgetstypes.h: new shared library. Currently there are some ugly dependencies into libgimp. These will be removed and go to a "libgimpglue" library which will be a library for functions which share a common interface between plug-ins and the app but have different implementations. Include "libgimp/gimpunit.h" from "libgimpwidgets/gimpwidgetstypes.h" to simulate this upcoming separation. * libgimp/Makefile.am * libgimp/gimpchainbutton.[ch] * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimppixmap.[ch] * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: removed from here. * libgimp/gimpui.h * libgimp/gimpuitypes.h * libgimp/makefile.mingw.in * libgimp/makefile.msc: changed accordingly. * app/[all ui files] * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: #include "libgimpwidgets/gimpwidgets.h" and removed useless includes. * app/apptypes.h: #include "libgimpwidgets/gimpwidgetstypes.h" * app/Makefile.am * plug-ins/[all makefiles which link against libgimpui]: link against libgimpwidgets.la * po-libgimp/POTFILES.in: changed file locations.
2001-01-25 06:36:18 +08:00
#include "widgets/gimphelp-ids.h"
#include "display/gimpcanvasgroup.h"
#include "display/gimpdisplay.h"
#include "gimpfreeselecttool.h"
#include "gimpselectionoptions.h"
#include "gimptoolcontrol.h"
#include "gimp-intl.h"
#define POINT_GRAB_THRESHOLD_SQ SQR (GIMP_TOOL_HANDLE_SIZE_CIRCLE / 2)
#define POINT_SHOW_THRESHOLD_SQ SQR (GIMP_TOOL_HANDLE_SIZE_CIRCLE * 7)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
#define N_ITEMS_PER_ALLOC 1024
#define INVALID_INDEX (-1)
#define NO_CLICK_TIME_AVAILABLE 0
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
#define GET_PRIVATE(fst) \
(G_TYPE_INSTANCE_GET_PRIVATE ((fst), \
GIMP_TYPE_FREE_SELECT_TOOL, GimpFreeSelectToolPrivate))
typedef struct
{
/* Index of grabbed segment index. */
gint grabbed_segment_index;
/* We need to keep track of a number of points when we move a
* segment vertex
*/
GimpVector2 *saved_points_lower_segment;
GimpVector2 *saved_points_higher_segment;
gint max_n_saved_points_lower_segment;
gint max_n_saved_points_higher_segment;
/* Keeps track wether or not a modification of the polygon has been
* made between _button_press and _button_release
*/
gboolean polygon_modified;
/* Point which is used to draw the polygon but which is not part of
* it yet
*/
GimpVector2 pending_point;
gboolean show_pending_point;
/* The points of the polygon */
GimpVector2 *points;
gint max_n_points;
/* The number of points actually in use */
gint n_points;
/* Any int array containing the indices for the points in the
* polygon that connects different segments together
*/
gint *segment_indices;
gint max_n_segment_indices;
/* The number of segment indices actually in use */
gint n_segment_indices;
/* The selection operation active when the tool was started */
GimpChannelOps operation_at_start;
/* Wether or not to constrain the angle for newly created polygonal
* segments.
*/
gboolean constrain_angle;
/* Wether or not to supress handles (so that new segments can be
* created immediately after an existing segment vertex.
*/
gboolean supress_handles;
/* Last _oper_update or _motion coords */
GimpVector2 last_coords;
/* A double-click commits the selection, keep track of last
* click-time and click-position.
*/
guint32 last_click_time;
GimpCoords last_click_coord;
} GimpFreeSelectToolPrivate;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
static void gimp_free_select_tool_finalize (GObject *object);
static void gimp_free_select_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
static void gimp_free_select_tool_oper_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
static void gimp_free_select_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_free_select_tool_button_press (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonPressType press_type,
GimpDisplay *display);
static void gimp_free_select_tool_button_release (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display);
static void gimp_free_select_tool_motion (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static gboolean gimp_free_select_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *display);
static void gimp_free_select_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_free_select_tool_active_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_free_select_tool_draw (GimpDrawTool *draw_tool);
static void gimp_free_select_tool_real_select (GimpFreeSelectTool *fst,
GimpDisplay *display);
1997-11-25 06:05:25 +08:00
G_DEFINE_TYPE (GimpFreeSelectTool, gimp_free_select_tool,
GIMP_TYPE_SELECTION_TOOL);
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
#define parent_class gimp_free_select_tool_parent_class
1997-11-25 06:05:25 +08:00
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
static const GimpVector2 vector2_zero = { 0.0, 0.0 };
void
2002-03-29 11:50:29 +08:00
gimp_free_select_tool_register (GimpToolRegisterCallback callback,
app/tools/gimpairbrushtool.[ch] app/tools/gimpbezierselecttool.[ch] 2002-05-03 Sven Neumann <sven@gimp.org> * app/tools/gimpairbrushtool.[ch] * app/tools/gimpbezierselecttool.[ch] * app/tools/gimpblendtool.[ch] * app/tools/gimpbrightnesscontrasttool.[ch] * app/tools/gimpbucketfilltool[.ch] * app/tools/gimpbycolorselecttool[.ch] * app/tools/gimpclonetool[.ch] * app/tools/gimpcolorbalancetool[.ch] * app/tools/gimpcolorpickertool[.ch] * app/tools/gimpconvolvetool[.ch] * app/tools/gimpcroptool[.ch] * app/tools/gimpcurvestool[.ch] * app/tools/gimpdodgeburntool[.ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool[.ch] * app/tools/gimperasertool[.ch] * app/tools/gimpfliptool[.ch] * app/tools/gimpfreeselecttool[.ch] * app/tools/gimpfuzzyselecttool[.ch] * app/tools/gimphistogramtool[.ch] * app/tools/gimphuesaturationtool[.ch] * app/tools/gimpinktool[.ch] * app/tools/gimpiscissorstool[.ch] * app/tools/gimplevelstool[.ch] * app/tools/gimpmagnifytool[.ch] * app/tools/gimpmeasuretool[.ch] * app/tools/gimpmovetool[.ch] * app/tools/gimppaintbrushtool[.ch] * app/tools/gimppainttool.c * app/tools/gimppathtool[.ch] * app/tools/gimppenciltool[.ch] * app/tools/gimpperspectivetool[.ch] * app/tools/gimpposterizetool[.ch] * app/tools/gimprectselecttool[.ch] * app/tools/gimprotatetool[.ch] * app/tools/gimpscaletool[.ch] * app/tools/gimpselectiontool.c * app/tools/gimpsheartool[.ch] * app/tools/gimpsmudgetool[.ch] * app/tools/gimptexttool[.ch] * app/tools/gimpthresholdtool[.ch] * app/tools/gimptool.c * app/tools/gimptoolcontrol.h * app/tools/gimptoolmodule[.ch] * app/tools/gimptransformtool.c * app/tools/gimpvectortool[.ch] * app/tools/path_tool.c * app/tools/tool_manager[.ch] * app/tools/tools.c * libgimptool/gimptool.c * libgimptool/gimptoolcontrol.h * libgimptool/gimptoolmodule.h: removed tons of warnings. Do we need to add -Werror to the CFLAGS to avoid such a mess in the future ?! Also had to enforce the GIMP coding style in lots of places :-( * libgimp/gimppixelrgn.c: got sick and tired of debugging plug-ins, so I've added checks for most parameters passed to the GimpPixelRgn functions. This will slow down plug-in execution a little bit but should help to find bugs early.
2002-05-03 19:31:08 +08:00
gpointer data)
1997-11-25 06:05:25 +08:00
{
2002-03-29 11:50:29 +08:00
(* callback) (GIMP_TYPE_FREE_SELECT_TOOL,
Made GimpToolOptions a GimpContext subclass and objectified all tool 2003-02-05 Michael Natterer <mitch@gimp.org> Made GimpToolOptions a GimpContext subclass and objectified all tool options types. * app/core/core-types.h: replaced GimpToolOptionsNewFunc by GimpToolOptionsGUIFunc. * libgimpproxy/gimpproxytypes.h: regenerated. * app/core/gimppaintinfo.[ch]: added "GType paint_options_type". * app/core/gimptoolinfo.[ch]: added "GType tool_options_type", removed tool_info->context since GimpToolOptions are a GimpContext now. Added "gboolean use_context" as a temp_hack. * libgimptool/gimptooltypes.h: added the tool_options_type to the tool registering callback. * app/tools/tool_options.[ch]: is a real GimpContext subclass now. * app/paint/paint-types.h * app/paint/paint.c: added the paint_options_type to the paint registering stuff. * app/paint/gimppaintoptions.[ch]: is a real GimpToolOptions subclass now. * app/paint/Makefile.am * app/paint/gimpairbrushoptions.[ch] * app/paint/gimpcloneoptions.[ch] * app/paint/gimpconvolveoptions.[ch] * app/paint/gimpdodgeburnoptions.[ch] * app/paint/gimperaseroptions.[ch] * app/paint/gimpsmudgeoptions.[ch]: new files holding GimpPaintOptions subclasses. * app/paint/gimpairbrush.[ch] * app/paint/gimpclone.[ch] * app/paint/gimpconvolve.[ch] * app/paint/gimpdodgeburn.[ch] * app/paint/gimperaser.[ch] * app/paint/gimppaintbrush.c * app/paint/gimppaintcore.c * app/paint/gimppencil.[ch] * app/paint/gimpsmudge.[ch]: removed paint options stuff, lots of related changed & cleanups. * tools/pdbgen/pdb/paint_tools.pdb: changed accordingly. * app/pdb/paint_tools_cmds.c: regenerated. * app/tools/Makefile.am * app/tools/gimpblendoptions.[ch] * app/tools/gimpbucketfilloptions.[ch] * app/tools/gimpcolorpickeroptions.[ch] * app/tools/gimpcropoptions.[ch] * app/tools/gimpflipoptions.[ch] * app/tools/gimpinkoptions.[ch] * app/tools/gimpmagnifyoptions.[ch] * app/tools/gimpmeasureoptions.[ch] * app/tools/gimpmoveoptions.[ch] * app/tools/gimptextoptions.[ch] * app/tools/gimpvectoroptions.[ch]: new files holding the various tool options classes. * app/tools/selection_options.[ch] * app/tools/transform_options.[ch]: made them objects. * app/tools/paint_options.[ch]: contains only the paint_options GUI and reset stuff. * app/tools/tools-types.h: removed SelectionOptions typedef for now. * app/tools/[all tools]: removed the tool options stuff except some GUI constructors. Tons of related changes. * app/tools/tool_manager.[ch]: changed tool registration / restore / switching accordingly. * app/widgets/gimpdrawablelistview.c * app/widgets/gimpselectioneditor.c: changed accordingly.
2003-02-05 22:39:40 +08:00
GIMP_TYPE_SELECTION_OPTIONS,
gimp_selection_options_gui,
0,
./mitch --sanitize-identifier-namespace 2002-03-20 Michael Natterer <mitch@gimp.org> ./mitch --sanitize-identifier-namespace * app/core/gimpcontext.c * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-dnd.c * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/dialogs.c * app/gui/edit-commands.c * app/gui/gui.c * app/gui/menus.c * app/gui/vectors-commands.c * app/gui/view-commands.c * app/tools/gimpairbrushtool.c * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpellipseselecttool.c * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimphistogramtool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimplevelstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppaintbrushtool.c * app/tools/gimppathtool.c * app/tools/gimppenciltool.c * app/tools/gimpperspectivetool.c * app/tools/gimpposterizetool.c * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpscaletool.c * app/tools/gimpsheartool.c * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimpthresholdtool.c * app/tools/gimpvectortool.c * app/widgets/gimpdnd.c * app/widgets/gimptoolbox-indicator-area.c * app/widgets/gimptoolbox.c: s/gimp:/gimp-/g and s/_/-/g for all identifier strings (e.g. gimp:eraser_tool -> gimp-eraser-tool, gimp:layer-list -> gimp-layer-list, ...) * plug-ins/tools/common/gimpbrushselecttool.c: s/gimp:brush_select_tool/gimp-brush-select-tool-module/ Don't quite remember why I introduced the "gimp:" prefix in the first place, but we can always add it back if we need it (for whatever reason) You may want to edit your ~/.gimp-1.3/sessionrc and devicerc or all session settings will be lost due to parse errors.
2002-03-21 20:17:17 +08:00
"gimp-free-select-tool",
_("Free Select"),
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
_("Free Select Tool: Select a hand-drawn region with free and polygonal segments"),
N_("_Free Select"), "F",
NULL, GIMP_HELP_TOOL_FREE_SELECT,
2002-03-29 11:50:29 +08:00
GIMP_STOCK_TOOL_FREE_SELECT,
app/tools/gimpairbrushtool.[ch] app/tools/gimpbezierselecttool.[ch] 2002-05-03 Sven Neumann <sven@gimp.org> * app/tools/gimpairbrushtool.[ch] * app/tools/gimpbezierselecttool.[ch] * app/tools/gimpblendtool.[ch] * app/tools/gimpbrightnesscontrasttool.[ch] * app/tools/gimpbucketfilltool[.ch] * app/tools/gimpbycolorselecttool[.ch] * app/tools/gimpclonetool[.ch] * app/tools/gimpcolorbalancetool[.ch] * app/tools/gimpcolorpickertool[.ch] * app/tools/gimpconvolvetool[.ch] * app/tools/gimpcroptool[.ch] * app/tools/gimpcurvestool[.ch] * app/tools/gimpdodgeburntool[.ch] * app/tools/gimpeditselectiontool.c * app/tools/gimpellipseselecttool[.ch] * app/tools/gimperasertool[.ch] * app/tools/gimpfliptool[.ch] * app/tools/gimpfreeselecttool[.ch] * app/tools/gimpfuzzyselecttool[.ch] * app/tools/gimphistogramtool[.ch] * app/tools/gimphuesaturationtool[.ch] * app/tools/gimpinktool[.ch] * app/tools/gimpiscissorstool[.ch] * app/tools/gimplevelstool[.ch] * app/tools/gimpmagnifytool[.ch] * app/tools/gimpmeasuretool[.ch] * app/tools/gimpmovetool[.ch] * app/tools/gimppaintbrushtool[.ch] * app/tools/gimppainttool.c * app/tools/gimppathtool[.ch] * app/tools/gimppenciltool[.ch] * app/tools/gimpperspectivetool[.ch] * app/tools/gimpposterizetool[.ch] * app/tools/gimprectselecttool[.ch] * app/tools/gimprotatetool[.ch] * app/tools/gimpscaletool[.ch] * app/tools/gimpselectiontool.c * app/tools/gimpsheartool[.ch] * app/tools/gimpsmudgetool[.ch] * app/tools/gimptexttool[.ch] * app/tools/gimpthresholdtool[.ch] * app/tools/gimptool.c * app/tools/gimptoolcontrol.h * app/tools/gimptoolmodule[.ch] * app/tools/gimptransformtool.c * app/tools/gimpvectortool[.ch] * app/tools/path_tool.c * app/tools/tool_manager[.ch] * app/tools/tools.c * libgimptool/gimptool.c * libgimptool/gimptoolcontrol.h * libgimptool/gimptoolmodule.h: removed tons of warnings. Do we need to add -Werror to the CFLAGS to avoid such a mess in the future ?! Also had to enforce the GIMP coding style in lots of places :-( * libgimp/gimppixelrgn.c: got sick and tired of debugging plug-ins, so I've added checks for most parameters passed to the GimpPixelRgn functions. This will slow down plug-in execution a little bit but should help to find bugs early.
2002-05-03 19:31:08 +08:00
data);
1997-11-25 06:05:25 +08:00
}
static void
gimp_free_select_tool_class_init (GimpFreeSelectToolClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
object_class->finalize = gimp_free_select_tool_finalize;
tool_class->control = gimp_free_select_tool_control;
tool_class->oper_update = gimp_free_select_tool_oper_update;
tool_class->cursor_update = gimp_free_select_tool_cursor_update;
tool_class->button_press = gimp_free_select_tool_button_press;
tool_class->button_release = gimp_free_select_tool_button_release;
tool_class->motion = gimp_free_select_tool_motion;
tool_class->key_press = gimp_free_select_tool_key_press;
tool_class->modifier_key = gimp_free_select_tool_modifier_key;
tool_class->active_modifier_key = gimp_free_select_tool_active_modifier_key;
draw_tool_class->draw = gimp_free_select_tool_draw;
klass->select = gimp_free_select_tool_real_select;
g_type_class_add_private (klass, sizeof (GimpFreeSelectToolPrivate));
}
static void
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_free_select_tool_init (GimpFreeSelectTool *fst)
{
GimpTool *tool = GIMP_TOOL (fst);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
gimp_tool_control_set_scroll_lock (tool->control, FALSE);
gimp_tool_control_set_wants_click (tool->control, TRUE);
Bug 496772 – Position shown in the statusbar needs more precision (for 2008-08-20 Michael Natterer <mitch@gimp.org> Bug 496772 – Position shown in the statusbar needs more precision (for some tools) * app/display/display-enums.[ch]: add enum GimpCursorPrecision which can be one of { PIXEL_CENTER, PIXEL_BORDER, SUBPIXEL }. * app/display/gimpdisplayshell-cursor.[ch]: add "precision" parameter to gimp_display_shell_update_cursor() and pass it on to the statusbar. * app/display/gimpstatusbar.[ch]: add "precision" parameters to the cursor coordinates APIs, offset the passed coords accordingly and display them with one decimal point if SUBPIXEL is requested and the display's unit is PIXEL. Keep a second floating-point format string around at any time. * app/tools/gimptoolcontrol.[ch]: add a "precision" member and API so tools can configure the precision they need. Defalt to PIXEL_CENTER since that's right for almost all tools. * app/display/gimpdisplayshell-callbacks.c: pass the tool's precision to gimp_display_shell_update_cursor(). * app/tools/gimptool.[ch]: add "precision" parameter to gimp_tool_push_status_coords() and pass it on to the statusbar. * app/tools/gimpaligntool.c * app/tools/gimpblendtool.c * app/tools/gimpcolortool.c * app/tools/gimpcroptool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfliptool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimpperspectiveclonetool.c * app/tools/gimprectangleselecttool.c * app/tools/gimprectangletool.c * app/tools/gimptransformtool.c * app/tools/gimpvectortool.c: set precision in init() where needed. Adjust the precision in the fly when needed, e.g. while moving guides or when toggling hard-edge on paint tools. Also pass an appropriate precision to gimp_tool_push_status_coords(), which is not always the tool's precision as used for cursor display. svn path=/trunk/; revision=26681
2008-08-21 00:22:09 +08:00
gimp_tool_control_set_precision (tool->control,
GIMP_CURSOR_PRECISION_SUBPIXEL);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_FREE_SELECT);
2002-03-29 11:50:29 +08:00
priv->grabbed_segment_index = INVALID_INDEX;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
priv->saved_points_lower_segment = NULL;
priv->saved_points_higher_segment = NULL;
priv->max_n_saved_points_lower_segment = 0;
priv->max_n_saved_points_higher_segment = 0;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
priv->polygon_modified = FALSE;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
priv->show_pending_point = FALSE;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
priv->points = NULL;
priv->n_points = 0;
priv->max_n_points = 0;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
priv->segment_indices = NULL;
priv->n_segment_indices = 0;
priv->max_n_segment_indices = 0;
priv->constrain_angle = FALSE;
priv->supress_handles = FALSE;
priv->last_click_time = NO_CLICK_TIME_AVAILABLE;
}
static void
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
gimp_free_select_tool_finalize (GObject *object)
{
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (object);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
g_free (priv->points);
g_free (priv->segment_indices);
g_free (priv->saved_points_lower_segment);
g_free (priv->saved_points_higher_segment);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_free_select_tool_get_segment (GimpFreeSelectTool *fst,
GimpVector2 **points,
gint *n_points,
gint segment_start,
gint segment_end)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
*points = &priv->points[priv->segment_indices[segment_start]];
*n_points = priv->segment_indices[segment_end] -
priv->segment_indices[segment_start] +
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
1;
}
static void
gimp_free_select_tool_get_segment_point (GimpFreeSelectTool *fst,
gdouble *start_point_x,
gdouble *start_point_y,
gint segment_index)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
*start_point_x = priv->points[priv->segment_indices[segment_index]].x;
*start_point_y = priv->points[priv->segment_indices[segment_index]].y;
}
static void
gimp_free_select_tool_get_last_point (GimpFreeSelectTool *fst,
gdouble *start_point_x,
gdouble *start_point_y)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
gimp_free_select_tool_get_segment_point (fst,
start_point_x,
start_point_y,
priv->n_segment_indices - 1);
}
static void
gimp_free_select_tool_get_double_click_settings (gint *double_click_time,
gint *double_click_distance)
{
GdkScreen *screen = gdk_screen_get_default ();
if (screen != NULL)
{
GtkSettings *settings = gtk_settings_get_for_screen (screen);
g_object_get (settings,
"gtk-double-click-time", double_click_time,
"gtk-double-click-distance", double_click_distance,
NULL);
}
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
static gboolean
gimp_free_select_tool_should_close (GimpFreeSelectTool *fst,
GimpDisplay *display,
guint32 time,
const GimpCoords *coords)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
gboolean double_click = FALSE;
gdouble dist = G_MAXDOUBLE;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
if (priv->polygon_modified ||
priv->n_segment_indices <= 0 ||
GIMP_TOOL (fst)->display == NULL)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
return FALSE;
dist = gimp_draw_tool_calc_distance_square (GIMP_DRAW_TOOL (fst),
display,
coords->x,
coords->y,
priv->points[0].x,
priv->points[0].y);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
/* Handle double-click. It must be within GTK+ global double-click
* time since last click, and it must be within GTK+ global
* double-click distance away from the last point
*/
if (time != NO_CLICK_TIME_AVAILABLE)
{
gint double_click_time;
gint double_click_distance;
gint click_time_passed;
gdouble dist_from_last_point;
click_time_passed = time - priv->last_click_time;
dist_from_last_point =
gimp_draw_tool_calc_distance_square (GIMP_DRAW_TOOL (fst),
display,
coords->x,
coords->y,
priv->last_click_coord.x,
priv->last_click_coord.y);
gimp_free_select_tool_get_double_click_settings (&double_click_time,
&double_click_distance);
double_click = click_time_passed < double_click_time &&
dist_from_last_point < double_click_distance;
}
return ((! priv->supress_handles && dist < POINT_GRAB_THRESHOLD_SQ) ||
double_click);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
static void
gimp_free_select_tool_handle_segment_selection (GimpFreeSelectTool *fst,
GimpDisplay *display,
const GimpCoords *coords)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (fst);
gdouble shortest_dist = POINT_GRAB_THRESHOLD_SQ;
gint grabbed_segment_index = INVALID_INDEX;
gint i;
if (GIMP_TOOL (fst)->display != NULL &&
! priv->supress_handles)
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
{
for (i = 0; i < priv->n_segment_indices; i++)
{
gdouble dist;
GimpVector2 *point;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
point = &priv->points[priv->segment_indices[i]];
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
dist = gimp_draw_tool_calc_distance_square (draw_tool,
display,
coords->x,
coords->y,
point->x,
point->y);
if (dist < shortest_dist)
{
grabbed_segment_index = i;
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
an evil temp_hack which lets GimpContext managing the active display 2001-08-14 Michael Natterer <mitch@gimp.org> * app/gdisplay.h: an evil temp_hack which lets GimpContext managing the active display withoug including "gdisplay.h". Will go away as soon ad context properties are registered dynamically. * app/module_db.c: cleaned up the object code in preparation of moving it to core/. * app/path.c: connect to GimpImage's * app/core/gimpobject.[ch]: derive it from GObject, not from GtkObject any more (yeah :-) * app/core/*.c: #include <glib-object.h> instead of <gtk/gtk.h>, removed some remaining GtkObject-isms. (left in a few #include <gtk/gtk.h> where bigger changes are needed to get rid of the UI dependency). * app/core/core-types.h: #include <gdk-pixbuf/gdk-pixbuf.h> here temporarily. * app/core/gimp.c (gimp_create_display): unref the image after creating it's first display. * app/core/gimpbrush.[ch]: disabled the parts of the code which depend on GimpPaintTool. * app/core/gimpbrushgenerated.c * app/core/gimpbrushpipe.c: changed accordingly. * app/core/gimpcontext.[ch]: evil hack (see above) to manage the active display without including "gdisplay.h" * app/core/gimpimage-mask.[ch]: pass a context to gimage_mask_stroke() and get the current tool's PDB string from there. * app/core/gimpedit.c: changed accordingly. * app/core/gimpimage.c: use gimp_image_update() instead of gdisplays_update_full(). * app/gui/color-area.c * app/gui/colormap-dialog.c * app/gui/dialogs-constructors.c * app/gui/edit-commands.c * app/gui/image-commands.c * app/gui/toolbox.c: changed accordingly (don't use Gtk methods on GObjects). * app/gui/menus.c: fix some const warnings by explicit casting. * app/tools/*.[ch]: ported all tools to GObject, some minor cleanup while i was on it. * app/widgets/gimpdialogfactory.[ch]: ported to GObject. * app/widgets/gimplayerlistview.h: added FOO_GET_CLASS() macro. * tools/pdbgen/app.pl: added a "widgets_eek" hack like "tools_eek" which inserts #include "widgets/widgets-types.h" before ordinary includes. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * app/pdb/brush_select_cmds.c * app/pdb/edit_cmds.c: changed according to the stuff above.
2001-08-14 22:53:55 +08:00
}
if (grabbed_segment_index != priv->grabbed_segment_index)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
gimp_draw_tool_pause (draw_tool);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
priv->grabbed_segment_index = grabbed_segment_index;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_draw_tool_resume (draw_tool);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
}
static void
gimp_free_select_tool_revert_to_last_segment (GimpFreeSelectTool *fst)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
priv->n_points = priv->segment_indices[priv->n_segment_indices - 1] + 1;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
static void
gimp_free_select_tool_remove_last_segment (GimpFreeSelectTool *fst)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (fst);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_draw_tool_pause (draw_tool);
if (priv->n_segment_indices > 0)
priv->n_segment_indices--;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
if (priv->n_segment_indices <= 0)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
gimp_tool_control (GIMP_TOOL (fst), GIMP_TOOL_ACTION_HALT,
GIMP_TOOL (fst)->display);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
else
{
gimp_free_select_tool_revert_to_last_segment (fst);
}
gimp_draw_tool_resume (draw_tool);
}
static void
gimp_free_select_tool_add_point (GimpFreeSelectTool *fst,
gdouble x,
gdouble y)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
if (priv->n_points >= priv->max_n_points)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
priv->max_n_points += N_ITEMS_PER_ALLOC;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
priv->points = g_realloc (priv->points,
sizeof (GimpVector2) * priv->max_n_points);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
priv->points[priv->n_points].x = x;
priv->points[priv->n_points].y = y;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
priv->n_points++;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
static void
gimp_free_select_tool_add_segment_index (GimpFreeSelectTool *fst,
gint index)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
if (priv->n_segment_indices >= priv->max_n_segment_indices)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
priv->max_n_segment_indices += N_ITEMS_PER_ALLOC;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
priv->segment_indices = g_realloc (priv->segment_indices,
sizeof (GimpVector2) *
priv->max_n_segment_indices);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
priv->segment_indices[priv->n_segment_indices] = index;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
priv->n_segment_indices++;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
static gboolean
gimp_free_select_tool_is_point_grabbed (GimpFreeSelectTool *fst)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
return priv->grabbed_segment_index != INVALID_INDEX;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
static void
gimp_free_select_tool_start (GimpFreeSelectTool *fst,
const GimpCoords *coords,
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
GimpDisplay *display)
{
GimpTool *tool = GIMP_TOOL (fst);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (fst);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_tool_control_activate (tool->control);
tool->display = display;
gimp_draw_tool_start (draw_tool, display);
/* We want to apply the selection operation that was current when
* the tool was started, so we save this information */
priv->operation_at_start = options->operation;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_selection_tool_start_edit (GIMP_SELECTION_TOOL (fst),
coords);
}
static void
gimp_free_select_tool_fit_segment (GimpFreeSelectTool *fst,
GimpVector2 *dest_points,
GimpVector2 dest_start_target,
GimpVector2 dest_end_target,
const GimpVector2 *source_points,
gint n_points)
{
GimpVector2 origo_translation_offset;
GimpVector2 untranslation_offset;
gdouble rotation;
gdouble scale;
/* Handle some quick special cases */
if (n_points <= 0)
{
return;
}
else if (n_points == 1)
{
dest_points[0] = dest_end_target;
return;
}
else if (n_points == 2)
{
dest_points[0] = dest_start_target;
dest_points[1] = dest_end_target;
return;
}
/* Copy from source to dest; we work on the dest data */
memcpy (dest_points, source_points, sizeof (GimpVector2) * n_points);
/* Transform the destination end point */
{
GimpVector2 *dest_end;
GimpVector2 origo_translated_end_target;
gdouble target_rotation;
gdouble current_rotation;
gdouble target_length;
gdouble current_length;
dest_end = &dest_points[n_points - 1];
/* Transate to origin */
gimp_vector2_sub (&origo_translation_offset,
&vector2_zero,
&dest_points[0]);
gimp_vector2_add (dest_end,
dest_end,
&origo_translation_offset);
/* Calculate origo_translated_end_target */
gimp_vector2_sub (&origo_translated_end_target,
&dest_end_target,
&dest_start_target);
/* Rotate */
target_rotation = atan2 (vector2_zero.y - origo_translated_end_target.y,
vector2_zero.x - origo_translated_end_target.x);
current_rotation = atan2 (vector2_zero.y - dest_end->y,
vector2_zero.x - dest_end->x);
rotation = current_rotation - target_rotation;
gimp_vector2_rotate (dest_end, rotation);
/* Scale */
target_length = gimp_vector2_length (&origo_translated_end_target);
current_length = gimp_vector2_length (dest_end);
scale = target_length / current_length;
gimp_vector2_mul (dest_end, scale);
/* Untranslate */
gimp_vector2_sub (&untranslation_offset,
&dest_end_target,
dest_end);
gimp_vector2_add (dest_end,
dest_end,
&untranslation_offset);
}
/* Do the same transformation for the rest of the points */
{
gint i;
for (i = 0; i < n_points - 1; i++)
{
/* Translate */
gimp_vector2_add (&dest_points[i],
&origo_translation_offset,
&dest_points[i]);
/* Rotate */
gimp_vector2_rotate (&dest_points[i],
rotation);
/* Scale */
gimp_vector2_mul (&dest_points[i],
scale);
/* Untranslate */
gimp_vector2_add (&dest_points[i],
&dest_points[i],
&untranslation_offset);
}
}
}
static void
gimp_free_select_tool_move_segment_vertex_to (GimpFreeSelectTool *fst,
gint segment_index,
gdouble new_x,
gdouble new_y)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
GimpVector2 cursor_point = { new_x, new_y };
GimpVector2 *dest;
GimpVector2 *dest_start_target;
GimpVector2 *dest_end_target;
gint n_points;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
/* Handle the segment before the grabbed point */
if (segment_index > 0)
{
gimp_free_select_tool_get_segment (fst,
&dest,
&n_points,
priv->grabbed_segment_index - 1,
priv->grabbed_segment_index);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
dest_start_target = &dest[0];
dest_end_target = &cursor_point;
gimp_free_select_tool_fit_segment (fst,
dest,
*dest_start_target,
*dest_end_target,
priv->saved_points_lower_segment,
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
n_points);
}
/* Handle the segment after the grabbed point */
if (segment_index < priv->n_segment_indices - 1)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
gimp_free_select_tool_get_segment (fst,
&dest,
&n_points,
priv->grabbed_segment_index,
priv->grabbed_segment_index + 1);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
dest_start_target = &cursor_point;
dest_end_target = &dest[n_points - 1];
gimp_free_select_tool_fit_segment (fst,
dest,
*dest_start_target,
*dest_end_target,
priv->saved_points_higher_segment,
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
n_points);
}
/* Handle when there only is one point */
if (segment_index == 0 &&
priv->n_segment_indices == 1)
{
priv->points[0].x = new_x;
priv->points[0].y = new_y;
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
/**
* gimp_free_select_tool_finish_line_segment:
* @free_ploy_sel_tool:
* @end_x:
* @end_y:
*
* Adds a line segment. Also cancels a pending free segment if any.
**/
static void
gimp_free_select_tool_finish_line_segment (GimpFreeSelectTool *fst)
{
/* Revert any free segment points that might have been added */
gimp_free_select_tool_revert_to_last_segment (fst);
}
/**
* gimp_free_select_tool_finish_free_segment:
* @fst:
*
* Finnishes off the creation of a free segment.
**/
static void
gimp_free_select_tool_finish_free_segment (GimpFreeSelectTool *fst)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
/* The points are all setup, just make a segment */
gimp_free_select_tool_add_segment_index (fst,
priv->n_points - 1);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
static void
gimp_free_select_tool_commit (GimpFreeSelectTool *fst,
GimpDisplay *display)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
if (priv->n_points >= 3)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
gimp_free_select_tool_select (fst, display);
}
gimp_image_flush (gimp_display_get_image (display));
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
static void
gimp_free_select_tool_revert_to_saved_state (GimpFreeSelectTool *fst)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
GimpVector2 *dest;
gint n_points;
/* Without a point grab we have no sensible information to fall back
* on, bail out
*/
if (! gimp_free_select_tool_is_point_grabbed (fst))
{
return;
}
if (priv->grabbed_segment_index > 0)
{
gimp_free_select_tool_get_segment (fst,
&dest,
&n_points,
priv->grabbed_segment_index - 1,
priv->grabbed_segment_index);
memcpy (dest,
priv->saved_points_lower_segment,
sizeof (GimpVector2) * n_points);
}
if (priv->grabbed_segment_index < priv->n_segment_indices - 1)
{
gimp_free_select_tool_get_segment (fst,
&dest,
&n_points,
priv->grabbed_segment_index,
priv->grabbed_segment_index + 1);
memcpy (dest,
priv->saved_points_higher_segment,
sizeof (GimpVector2) * n_points);
}
if (priv->grabbed_segment_index == 0 &&
priv->n_segment_indices == 1)
{
priv->points[0] = *priv->saved_points_lower_segment;
}
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
static void
gimp_free_select_tool_handle_click (GimpFreeSelectTool *fst,
const GimpCoords *coords,
guint32 time,
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
GimpDisplay *display)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
GimpImage *image = gimp_display_get_image (display);
/* If there is a floating selection, anchor it */
if (gimp_image_get_floating_selection (image))
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
floating_sel_anchor (gimp_image_get_floating_selection (image));
gimp_tool_control (GIMP_TOOL (fst), GIMP_TOOL_ACTION_HALT, display);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
else
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
/* First finish of the line segment if no point was grabbed */
if (! gimp_free_select_tool_is_point_grabbed (fst))
{
gimp_free_select_tool_finish_line_segment (fst);
}
/* After the segments are up to date and we have handled
* double-click, see if it's commiting time
*/
if (gimp_free_select_tool_should_close (fst,
display,
time,
coords))
{
/* We can get a click notification even though the end point
* has been moved a few pixels. Since a move will change the
* free selection, revert it before doing the commit.
*/
gimp_free_select_tool_revert_to_saved_state (fst);
gimp_free_select_tool_commit (fst, display);
}
priv->last_click_time = time;
priv->last_click_coord = *coords;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
}
static void
gimp_free_select_tool_handle_normal_release (GimpFreeSelectTool *fst,
const GimpCoords *coords,
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
GimpDisplay *display)
{
/* First finish of the free segment if no point was grabbed */
if (! gimp_free_select_tool_is_point_grabbed (fst))
{
gimp_free_select_tool_finish_free_segment (fst);
}
/* After the segments are up to date, see if it's commiting time */
if (gimp_free_select_tool_should_close (fst,
display,
NO_CLICK_TIME_AVAILABLE,
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
coords))
{
gimp_free_select_tool_commit (fst, display);
}
}
static void
gimp_free_select_tool_handle_cancel (GimpFreeSelectTool *fst)
{
if (gimp_free_select_tool_is_point_grabbed (fst))
{
gimp_free_select_tool_revert_to_saved_state (fst);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
else
{
gimp_free_select_tool_remove_last_segment (fst);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
}
void
gimp_free_select_tool_select (GimpFreeSelectTool *fst,
GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_FREE_SELECT_TOOL (fst));
g_return_if_fail (GIMP_IS_DISPLAY (display));
GIMP_FREE_SELECT_TOOL_GET_CLASS (fst)->select (fst,
display);
}
static void
gimp_free_select_tool_prepare_for_move (GimpFreeSelectTool *fst)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
GimpVector2 *source;
gint n_points;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
if (priv->grabbed_segment_index > 0)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
gimp_free_select_tool_get_segment (fst,
&source,
&n_points,
priv->grabbed_segment_index - 1,
priv->grabbed_segment_index);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
if (n_points > priv->max_n_saved_points_lower_segment)
{
priv->max_n_saved_points_lower_segment = n_points;
priv->saved_points_lower_segment = g_realloc (priv->saved_points_lower_segment,
sizeof (GimpVector2) *
n_points);
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
memcpy (priv->saved_points_lower_segment,
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
source,
sizeof (GimpVector2) * n_points);
}
if (priv->grabbed_segment_index < priv->n_segment_indices - 1)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
gimp_free_select_tool_get_segment (fst,
&source,
&n_points,
priv->grabbed_segment_index,
priv->grabbed_segment_index + 1);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
if (n_points > priv->max_n_saved_points_higher_segment)
{
priv->max_n_saved_points_higher_segment = n_points;
priv->saved_points_higher_segment = g_realloc (priv->saved_points_higher_segment,
sizeof (GimpVector2) * n_points);
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
memcpy (priv->saved_points_higher_segment,
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
source,
sizeof (GimpVector2) * n_points);
}
/* A special-case when there only is one point */
if (priv->grabbed_segment_index == 0 &&
priv->n_segment_indices == 1)
{
if (priv->max_n_saved_points_lower_segment == 0)
{
priv->max_n_saved_points_lower_segment = 1;
priv->saved_points_lower_segment = g_new0 (GimpVector2, 1);
}
*priv->saved_points_lower_segment = priv->points[0];
}
}
static gboolean
gimp_free_select_tool_delegate_button_press (GimpFreeSelectTool *fst,
const GimpCoords *coords,
GimpDisplay *display)
{
GimpTool *tool = GIMP_TOOL (fst);
gboolean button_press_delegated = FALSE;
/* Only consider delegating if the tool is not active */
if (tool->display == NULL)
{
tool->display = display;
gimp_tool_control_activate (tool->control);
button_press_delegated =
gimp_selection_tool_start_edit (GIMP_SELECTION_TOOL (fst), coords);
if (! button_press_delegated)
{
/* Nope, the selection mask edit stuff was not interested, reset
* the situation
*/
gimp_tool_control_halt (tool->control);
tool->display = NULL;
}
}
return button_press_delegated;
}
static void
gimp_free_select_tool_update_motion (GimpFreeSelectTool *fst,
gdouble new_x,
gdouble new_y)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
if (gimp_free_select_tool_is_point_grabbed (fst))
{
priv->polygon_modified = TRUE;
if (priv->constrain_angle &&
priv->n_segment_indices > 1 )
{
gdouble start_point_x;
gdouble start_point_y;
gint segment_index;
/* Base constraints on the last segment vertex if we move
* the first one, otherwise base on the previous segment
* vertex
*/
if (priv->grabbed_segment_index == 0)
{
segment_index = priv->n_segment_indices - 1;
}
else
{
segment_index = priv->grabbed_segment_index - 1;
}
gimp_free_select_tool_get_segment_point (fst,
&start_point_x,
&start_point_y,
segment_index);
gimp_constrain_line (start_point_x,
start_point_y,
&new_x,
&new_y,
GIMP_CONSTRAIN_LINE_15_DEGREES);
}
gimp_free_select_tool_move_segment_vertex_to (fst,
priv->grabbed_segment_index,
new_x,
new_y);
/* We also must update the pending point if we are moving the
* first point
*/
if (priv->grabbed_segment_index == 0)
{
priv->pending_point.x = new_x;
priv->pending_point.y = new_y;
}
}
else
{
/* Don't show the pending point while we are adding points */
priv->show_pending_point = FALSE;
gimp_free_select_tool_add_point (fst,
new_x,
new_y);
}
}
static void
gimp_free_select_tool_status_update (GimpFreeSelectTool *fst,
GimpDisplay *display,
const GimpCoords *coords,
gboolean proximity)
{
GimpTool *tool = GIMP_TOOL (fst);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
gimp_tool_pop_status (tool, display);
if (proximity)
{
const gchar *status_text = NULL;
if (gimp_free_select_tool_is_point_grabbed (fst))
{
if (gimp_free_select_tool_should_close (fst,
display,
NO_CLICK_TIME_AVAILABLE,
coords))
{
status_text = _("Click to complete selection");
}
else
{
status_text = _("Click-Drag to move segment vertex");
}
}
else if (priv->n_segment_indices >= 3)
{
status_text = _("Return commits, Escape cancels, Backspace removes last segment");
}
else
{
status_text = _("Click-Drag adds a free segment, Click adds a polygonal segment");
}
if (status_text)
{
bumped minimum required version of GLib to 2.18.0. 2008-11-04 Sven Neumann <sven@sven> * configure.in: bumped minimum required version of GLib to 2.18.0. * INSTALL: document the updated dependency. * app/core/gimp.[ch]: introduced gimp_message_literal(), a variant of gimp_message() that takes a literal string. * app/errors.[ch]: removed format arguments from gimp_fatal_error() and gimp_terminate() and let them take a literal string instead. * app/tools/gimptool.[ch]: introduced gimp_tool_message_literal(), a variant of gimp_tool_message() that takes a literal string. * app/actions/documents-commands.c * app/actions/drawable-commands.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/gradients-commands.c * app/actions/image-commands.c * app/actions/layers-commands.c * app/actions/palettes-commands.c * app/actions/plug-in-commands.c * app/actions/select-commands.c * app/actions/vectors-commands.c * app/config/gimprc.c * app/core/gimp-modules.c * app/core/gimp-parasites.c * app/core/gimp-templates.c * app/core/gimp-units.c * app/core/gimpchannel.c * app/core/gimpcontainer-filter.c * app/core/gimpdrawable-bucket-fill.c * app/core/gimpimage-convert.c * app/core/gimpimage-merge.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimplayer-floating-sel.c * app/core/gimplayer.c * app/core/gimpselection.c * app/dialogs/convert-dialog.c * app/dialogs/dialogs.c * app/dialogs/palette-import-dialog.c * app/dialogs/preferences-dialog.c * app/dialogs/quit-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/file/file-open.c * app/file/file-procedure.c * app/file/file-save.c * app/file/file-utils.c * app/gegl/gimpcurvesconfig.c * app/gegl/gimplevelsconfig.c * app/gui/gui-message.c * app/gui/gui.c * app/gui/session.c * app/paint/gimpbrushcore.c * app/paint/gimpclone.c * app/paint/gimpheal.c * app/paint/gimpperspectiveclone.c * app/paint/gimpsourcecore.c * app/pdb/gimppdb-utils.c * app/pdb/gimpprocedure.c * app/plug-in/gimpplugin-message.c * app/plug-in/gimpplugin.c * app/plug-in/gimppluginmanager-restore.c * app/plug-in/gimppluginprocedure.c * app/text/gimptextlayer.c * app/tools/gimp-tools.c * app/tools/gimpaligntool.c * app/tools/gimpblendtool.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcurvestool.c * app/tools/gimpdesaturatetool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpforegroundselecttool.c * app/tools/gimpfreeselecttool.c * app/tools/gimpgegltool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpimagemaptool-settings.c * app/tools/gimpiscissorstool.c * app/tools/gimplevelstool.c * app/tools/gimpmeasuretool.c * app/tools/gimppainttool.c * app/tools/gimpposterizetool.c * app/tools/gimpselectiontool.c * app/tools/gimpsourcetool.c * app/tools/gimpthresholdtool.c * app/tools/gimptransformtool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimpcontrollers.c * app/widgets/gimpdataeditor.c * app/widgets/gimpdevices.c * app/widgets/gimpdnd-xds.c * app/widgets/gimperrordialog.c * app/widgets/gimphelp.c * app/widgets/gimpitemtreeview.c * app/widgets/gimppdbdialog.c * app/widgets/gimpsettingsbox.c * app/widgets/gimpvectorstreeview.c * app/widgets/gimpwidgets-utils.c * app/xcf/xcf-load.c * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/image.pdb: use the _literal variants for g_set_error(), gimp_message() and gimp_tool_message(). * app/pdb/convert-cmds.c * app/pdb/edit-cmds.c * app/pdb/floating-sel-cmds.c * app/pdb/image-cmds.c: regenerated. svn path=/trunk/; revision=27548
2008-11-04 20:33:09 +08:00
gimp_tool_push_status (tool, display, "%s", status_text);
}
}
}
static void
gimp_free_select_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display)
{
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (tool);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
switch (action)
{
case GIMP_TOOL_ACTION_PAUSE:
case GIMP_TOOL_ACTION_RESUME:
break;
case GIMP_TOOL_ACTION_HALT:
priv->grabbed_segment_index = INVALID_INDEX;
priv->show_pending_point = FALSE;
priv->n_points = 0;
priv->n_segment_indices = 0;
break;
}
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
static void
gimp_free_select_tool_oper_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (tool);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
gboolean hovering_first_point;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_free_select_tool_handle_segment_selection (fst,
display,
coords);
hovering_first_point =
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_free_select_tool_should_close (fst,
display,
NO_CLICK_TIME_AVAILABLE,
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
coords);
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
priv->last_coords.x = coords->x;
priv->last_coords.y = coords->y;
if (priv->n_points == 0 ||
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
(gimp_free_select_tool_is_point_grabbed (fst) &&
! hovering_first_point) ||
! proximity)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
priv->show_pending_point = FALSE;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
else
{
priv->show_pending_point = TRUE;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
if (hovering_first_point)
{
priv->pending_point = priv->points[0];
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
else
{
priv->pending_point.x = coords->x;
priv->pending_point.y = coords->y;
if (priv->constrain_angle && priv->n_points > 0)
{
gdouble start_point_x;
gdouble start_point_y;
gimp_free_select_tool_get_last_point (fst,
&start_point_x,
&start_point_y);
gimp_constrain_line (start_point_x, start_point_y,
&priv->pending_point.x,
&priv->pending_point.y,
GIMP_CONSTRAIN_LINE_15_DEGREES);
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
}
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
if (tool->display == NULL)
{
GIMP_TOOL_CLASS (parent_class)->oper_update (tool,
coords,
state,
proximity,
display);
}
else
{
gimp_free_select_tool_status_update (fst, display, coords, proximity);
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
static void
gimp_free_select_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (tool);
if (tool->display == NULL)
{
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool,
coords,
state,
display);
}
else
{
GimpCursorModifier modifier;
if (gimp_free_select_tool_is_point_grabbed (fst) &&
! gimp_free_select_tool_should_close (fst,
display,
NO_CLICK_TIME_AVAILABLE,
coords))
{
modifier = GIMP_CURSOR_MODIFIER_MOVE;
}
else
{
modifier = GIMP_CURSOR_MODIFIER_NONE;
}
gimp_tool_set_cursor (tool, display,
gimp_tool_control_get_cursor (tool->control),
gimp_tool_control_get_tool_cursor (tool->control),
modifier);
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
static void
gimp_free_select_tool_button_press (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonPressType press_type,
GimpDisplay *display)
1997-11-25 06:05:25 +08:00
{
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (tool);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
1997-11-25 06:05:25 +08:00
/* First of all handle delegation to the selection mask edit logic
* if appropriate
*/
if (gimp_free_select_tool_delegate_button_press (fst,
coords,
display))
{
return;
}
gimp_tool_control_activate (tool->control);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_draw_tool_pause (draw_tool);
build display/ before tools/. 2001-11-08 Michael Natterer <mitch@gimp.org> * app/Makefile.am: build display/ before tools/. * app/devices.c: devices_check_change(): added all events which have a GdkDevice pointer. * app/gimpprogress.c: include "display-types.h" instead of "core-types.h". * app/core/Makefile.am * app/core/gimpdrawable-bucket-fill.[ch]: new files: the bucket_fill stuff taken from tools/gimpbucketfilltool.[ch]. * app/core/core-types.h: added "BucketFillMode". * app/core/gimpimage-mask-select.[ch]: cleanup. * app/core/gimpmarshal.list: added more marshallers for GimpTool's new signal signatures. * app/core/gimpmarshal.[ch]: regenerated. * app/display/Makefile.am * app/display/gimpdisplayshell-dnd.[ch] * app/display/gimpdisplayshell-layer-select.[ch]: new files: the canvas drop callbacks from gimpdisplayshell-callbacks.[ch] and the stuff formerly knows as gui/layer-select.[ch]. * app/display/gimpdisplay.h: don't include "gui/gui-types.h". * app/display/gximage.c: include "display-types.h". * app/display/gimpdisplay-foreach.c * app/display/gimpdisplayshell.[ch]: call gdsplay_delete(), don't destroy the shell widget. * app/gui/Makefile.am * app/gui/layer-select.[ch]: removed. * app/gui/gradients-commands.c: fixed "Save as POV" fprintf()s. * app/gui/preferences-dialog.c: removed the layer_select stuff because it is useless with the new preview system. * app/gui/tool-options-dialog.c: send the correct data to the close_callback. * app/gui/tools-commands.c: changed to follow the new gimp_tool_initialize() semantics (see below). Tool & canvas event handling chainsawing: * app/tools/tools-types.h: new struct GimpCoords which contains x, y, pressure, tilt etc. * app/display/gimpdisplayshell-callbacks.[ch]: added utility functions which transparently retreive the current event's GimpCoords or take it from the device directly if the event has none. Pass GimpCoords _in_image_coordinates_ to all tool functions. Most important: don't pass GdkEvents and display coordinates to tools any more. * app/tools/gimptool.[ch]: changed virtual functions to take GimpCoords, time and state separately instead of GdkEvents. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.[ch] * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.[ch] * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimpfreeselecttool.[ch] * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.[ch] * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpselectiontool.[ch] * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimptransformtool.[ch] * app/tools/path_tool.[ch] * app/tools/selection_options.c: tons and tons of changes: - changed to use the new virtual function parameters. - removed zillions of gdisplay_untransform_coords(). - get the active drawable's offsets manually in many cases. (questionable, but IMHO ok because it's obvious and not simply a "TRUE" passed to some function) - reordered some functions to be consistent across tools. - some tools had to be changed to work on image coords, not display ones (esp. crop). - fixed strange rotate tool behaviour which should be backported to stable. - some stuff i came across. - indentation and other paranoia. - rounding of coordinated may be broken in some tools. - new bugs guaranteed. * app/tools/tool_manager.[ch]: new semantic of tool_manager_initialize_active() (looked at the places where it was used from and put common code together). Should be a bit better now :) * app/tools/gimpblendtool.c * app/tools/transform_options.c: use the new GTK+ feature that a widget (toggle button) can be a frame's title for this tools' tool options. * app/widgets/widgets-types.h: stuff. * themes/Default/gtkrc: s/GtkDialog/GimpDialog/. * tools/pdbgen/Makefile.am: don't scan tools/gimpbucketfilltool.h any more. * tools/pdbgen/enums.pl: regenerated. * tools/pdbgen/pdb/tools.pdb: changed bucket_fill wrapper. * app/pdb/tools_cmds.c: regenerated.
2001-11-09 03:14:51 +08:00
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
if (display != tool->display)
{
gimp_free_select_tool_start (fst,
coords,
display);
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
if (gimp_free_select_tool_is_point_grabbed (fst))
{
gimp_free_select_tool_prepare_for_move (fst);
}
else
{
GimpVector2 point_to_add;
/* Note that we add the pending point (unless it is the first
* point we add) because the pending point is setup correctly
* with regards to angle constraints.
*/
if (priv->n_points > 0)
{
point_to_add = priv->pending_point;
}
else
{
point_to_add.x = coords->x;
point_to_add.y = coords->y;
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
/* No point was grabbed, add a new point and mark this as a
* segment divider. For a line segment, this will be the only
* new point. For a free segment, this will be the first point
* of the free segment.
*/
gimp_free_select_tool_add_point (fst,
point_to_add.x,
point_to_add.y);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_free_select_tool_add_segment_index (fst,
priv->n_points - 1);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
1997-11-25 06:05:25 +08:00
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_draw_tool_resume (draw_tool);
1997-11-25 06:05:25 +08:00
}
static void
gimp_free_select_tool_button_release (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display)
1997-11-25 06:05:25 +08:00
{
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (tool);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
gimp_tool_control_halt (tool->control);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_draw_tool_pause (GIMP_DRAW_TOOL (fst));
switch (release_type)
{
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
case GIMP_BUTTON_RELEASE_CLICK:
case GIMP_BUTTON_RELEASE_NO_MOTION:
/* If a click was made, we don't consider the polygon modified */
priv->polygon_modified = FALSE;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_free_select_tool_handle_click (fst,
coords,
time,
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
display);
break;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
case GIMP_BUTTON_RELEASE_NORMAL:
gimp_free_select_tool_handle_normal_release (fst,
coords,
display);
break;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
case GIMP_BUTTON_RELEASE_CANCEL:
gimp_free_select_tool_handle_cancel (fst);
break;
default:
break;
1997-11-25 06:05:25 +08:00
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
/* Reset */
priv->polygon_modified = FALSE;
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_draw_tool_resume (GIMP_DRAW_TOOL (fst));
1997-11-25 06:05:25 +08:00
}
static void
gimp_free_select_tool_motion (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
1997-11-25 06:05:25 +08:00
{
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (tool);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_draw_tool_pause (draw_tool);
priv->last_coords.x = coords->x;
priv->last_coords.y = coords->y;
gimp_free_select_tool_update_motion (fst,
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
coords->x,
coords->y);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_draw_tool_resume (draw_tool);
}
build display/ before tools/. 2001-11-08 Michael Natterer <mitch@gimp.org> * app/Makefile.am: build display/ before tools/. * app/devices.c: devices_check_change(): added all events which have a GdkDevice pointer. * app/gimpprogress.c: include "display-types.h" instead of "core-types.h". * app/core/Makefile.am * app/core/gimpdrawable-bucket-fill.[ch]: new files: the bucket_fill stuff taken from tools/gimpbucketfilltool.[ch]. * app/core/core-types.h: added "BucketFillMode". * app/core/gimpimage-mask-select.[ch]: cleanup. * app/core/gimpmarshal.list: added more marshallers for GimpTool's new signal signatures. * app/core/gimpmarshal.[ch]: regenerated. * app/display/Makefile.am * app/display/gimpdisplayshell-dnd.[ch] * app/display/gimpdisplayshell-layer-select.[ch]: new files: the canvas drop callbacks from gimpdisplayshell-callbacks.[ch] and the stuff formerly knows as gui/layer-select.[ch]. * app/display/gimpdisplay.h: don't include "gui/gui-types.h". * app/display/gximage.c: include "display-types.h". * app/display/gimpdisplay-foreach.c * app/display/gimpdisplayshell.[ch]: call gdsplay_delete(), don't destroy the shell widget. * app/gui/Makefile.am * app/gui/layer-select.[ch]: removed. * app/gui/gradients-commands.c: fixed "Save as POV" fprintf()s. * app/gui/preferences-dialog.c: removed the layer_select stuff because it is useless with the new preview system. * app/gui/tool-options-dialog.c: send the correct data to the close_callback. * app/gui/tools-commands.c: changed to follow the new gimp_tool_initialize() semantics (see below). Tool & canvas event handling chainsawing: * app/tools/tools-types.h: new struct GimpCoords which contains x, y, pressure, tilt etc. * app/display/gimpdisplayshell-callbacks.[ch]: added utility functions which transparently retreive the current event's GimpCoords or take it from the device directly if the event has none. Pass GimpCoords _in_image_coordinates_ to all tool functions. Most important: don't pass GdkEvents and display coordinates to tools any more. * app/tools/gimptool.[ch]: changed virtual functions to take GimpCoords, time and state separately instead of GdkEvents. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.[ch] * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.[ch] * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimpfreeselecttool.[ch] * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.[ch] * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpselectiontool.[ch] * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimptransformtool.[ch] * app/tools/path_tool.[ch] * app/tools/selection_options.c: tons and tons of changes: - changed to use the new virtual function parameters. - removed zillions of gdisplay_untransform_coords(). - get the active drawable's offsets manually in many cases. (questionable, but IMHO ok because it's obvious and not simply a "TRUE" passed to some function) - reordered some functions to be consistent across tools. - some tools had to be changed to work on image coords, not display ones (esp. crop). - fixed strange rotate tool behaviour which should be backported to stable. - some stuff i came across. - indentation and other paranoia. - rounding of coordinated may be broken in some tools. - new bugs guaranteed. * app/tools/tool_manager.[ch]: new semantic of tool_manager_initialize_active() (looked at the places where it was used from and put common code together). Should be a bit better now :) * app/tools/gimpblendtool.c * app/tools/transform_options.c: use the new GTK+ feature that a widget (toggle button) can be a frame's title for this tools' tool options. * app/widgets/widgets-types.h: stuff. * themes/Default/gtkrc: s/GtkDialog/GimpDialog/. * tools/pdbgen/Makefile.am: don't scan tools/gimpbucketfilltool.h any more. * tools/pdbgen/enums.pl: regenerated. * tools/pdbgen/pdb/tools.pdb: changed bucket_fill wrapper. * app/pdb/tools_cmds.c: regenerated.
2001-11-09 03:14:51 +08:00
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
static gboolean
gimp_free_select_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *display)
{
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (tool);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
switch (kevent->keyval)
{
case GDK_KEY_BackSpace:
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_free_select_tool_remove_last_segment (fst);
return TRUE;
case GDK_KEY_Return:
case GDK_KEY_KP_Enter:
case GDK_KEY_ISO_Enter:
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_free_select_tool_commit (fst, display);
return TRUE;
case GDK_KEY_Escape:
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
return TRUE;
default:
break;
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
return FALSE;
1997-11-25 06:05:25 +08:00
}
static void
gimp_free_select_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display)
{
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (tool);
if (tool->display == display)
{
gimp_draw_tool_pause (draw_tool);
priv->constrain_angle = state & GDK_CONTROL_MASK ? TRUE : FALSE;
priv->supress_handles = state & GDK_SHIFT_MASK ? TRUE : FALSE;
gimp_draw_tool_resume (draw_tool);
}
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool,
key,
press,
state,
display);
}
static void
gimp_free_select_tool_active_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display)
{
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (tool);
if (tool->display != display)
return;
gimp_draw_tool_pause (draw_tool);
priv->constrain_angle = state & GDK_CONTROL_MASK ? TRUE : FALSE;
/* If we didn't came here due to a mouse release, immediately update
* the position of the thing we move.
*/
if (state & GDK_BUTTON1_MASK)
{
gimp_free_select_tool_update_motion (GIMP_FREE_SELECT_TOOL (tool),
priv->last_coords.x,
priv->last_coords.y);
}
gimp_draw_tool_resume (draw_tool);
GIMP_TOOL_CLASS (parent_class)->active_modifier_key (tool,
key,
press,
state,
display);
}
/**
* gimp_free_select_tool_draw:
* @draw_tool:
*
* Draw the line segments and handles around segment vertices, the
* latter if the they are in proximity to cursor.
**/
1997-11-25 06:05:25 +08:00
static void
gimp_free_select_tool_draw (GimpDrawTool *draw_tool)
1997-11-25 06:05:25 +08:00
{
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (draw_tool);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
GimpTool *tool = GIMP_TOOL (draw_tool);
GimpCanvasGroup *stroke_group;
gboolean hovering_first_point = FALSE;
gboolean handles_wants_to_show = FALSE;
GimpCoords coords = { priv->last_coords.x,
priv->last_coords.y,
/* pad with 0 */ };
if (! tool->display)
return;
1997-11-25 06:05:25 +08:00
hovering_first_point =
gimp_free_select_tool_should_close (fst,
tool->display,
NO_CLICK_TIME_AVAILABLE,
&coords);
stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);
gimp_draw_tool_push_group (draw_tool, stroke_group);
gimp_draw_tool_add_lines (draw_tool,
priv->points, priv->n_points,
FALSE);
gimp_draw_tool_pop_group (draw_tool);
/* We always show the handle for the first point, even with button1
* down, since releasing the button on the first point will close
* the polygon, so it's a significant state which we must give
* feedback for
*/
handles_wants_to_show = (hovering_first_point ||
! gimp_tool_control_is_active (tool->control));
if (handles_wants_to_show &&
! priv->supress_handles)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
gint i = 0;
gint n = 0;
/* If the first point is hovered while button1 is held down,
* only draw the first handle, the other handles are not
* relevant (see comment a few lines up)
*/
if (gimp_tool_control_is_active (tool->control) && hovering_first_point)
n = MIN (priv->n_segment_indices, 1);
else
n = priv->n_segment_indices;
for (i = 0; i < n; i++)
{
GimpVector2 *point = NULL;
gdouble dist = 0.0;
GimpHandleType handle_type = -1;
point = &priv->points[priv->segment_indices[i]];
dist = gimp_draw_tool_calc_distance_square (draw_tool,
tool->display,
priv->last_coords.x,
priv->last_coords.y,
point->x,
point->y);
/* If the cursor is over the point, fill, if it's just
* close, draw an outline
*/
if (dist < POINT_GRAB_THRESHOLD_SQ)
handle_type = GIMP_HANDLE_FILLED_CIRCLE;
else if (dist < POINT_SHOW_THRESHOLD_SQ)
handle_type = GIMP_HANDLE_CIRCLE;
if (handle_type != -1)
{
GimpCanvasItem *item;
item = gimp_draw_tool_add_handle (draw_tool, handle_type,
point->x,
point->y,
GIMP_TOOL_HANDLE_SIZE_CIRCLE,
GIMP_TOOL_HANDLE_SIZE_CIRCLE,
GIMP_HANDLE_ANCHOR_CENTER);
if (dist < POINT_GRAB_THRESHOLD_SQ)
gimp_canvas_item_set_highlight (item, TRUE);
}
}
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
if (priv->show_pending_point)
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
{
GimpVector2 last = priv->points[priv->n_points - 1];
gimp_draw_tool_push_group (draw_tool, stroke_group);
gimp_draw_tool_add_line (draw_tool,
last.x,
last.y,
priv->pending_point.x,
priv->pending_point.y);
gimp_draw_tool_pop_group (draw_tool);
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
}
}
static void
Merged the Polygon Select Tool capabilities with the Free Select Tool. 2008-05-18 Martin Nordholts <martinn@svn.gnome.org> Merged the Polygon Select Tool capabilities with the Free Select Tool. Among the things still to do is improved help texts, more suitable graphics, and cursor mangement, but the core functionality is in place. Thanks to Alexia Death for initial testing. It will also be neccesary to do some work to adapt the Foreground Select Tool to the new Free Select Tool implementation. Quick instructions on how the tool works: o A click adds a polygonal segment, a drag adds a free-hand segment o Return-key commits, Escape-key cancels, Backspace-key removes last segment o You can grab and move segment vertices o You can cancel both a move, and the creation of a segment * app/tools/gimpfreeselecttool.[ch]: More or less reimplemented. We keep a sequential array of all the points in the polygon (including the free segments), and we have another array with point indices that we use to represent the segments. On top of this we have a few helper functions that tries to abstract away the pretty raw nature of the implementation. * app/tools/gimpforegroundselecttool.[ch]: Keep track on its own last_coord, and adjust to the new implementation of the Free Select Tool. Still needs some work, for example handling that the Free Select Tool now resets GimpTool::display. (gimp_foreground_select_tool_key_press): Pass on key event to parent class when appropriate. (Bails out too early though...) svn path=/trunk/; revision=25693
2008-05-18 19:39:17 +08:00
gimp_free_select_tool_real_select (GimpFreeSelectTool *fst,
GimpDisplay *display)
{
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (fst);
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
GimpImage *image = gimp_display_get_image (display);
gimp_channel_select_polygon (gimp_image_get_mask (image),
C_("command", "Free Select"),
priv->n_points,
priv->points,
priv->operation_at_start,
options->antialias,
options->feather,
options->feather_radius,
options->feather_radius,
TRUE);
gimp_tool_control (GIMP_TOOL (fst), GIMP_TOOL_ACTION_HALT, display);
}
void
gimp_free_select_tool_get_points (GimpFreeSelectTool *fst,
const GimpVector2 **points,
gint *n_points)
{
GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst);
g_return_if_fail (points != NULL && n_points != NULL);
*points = priv->points;
*n_points = priv->n_points;
}