2006-12-10 05:33:38 +08:00
|
|
|
/* 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
|
|
|
|
*
|
1997-11-25 06:05:25 +08:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-07-30 00:12:40 +08:00
|
|
|
|
2000-12-17 05:37:03 +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>
|
|
|
|
|
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>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2007-03-09 21:00:01 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-08-06 00:08:19 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpchannel.h"
|
2003-10-06 20:17:11 +08:00
|
|
|
#include "core/gimpchannel-select.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2002-02-22 06:19:45 +08:00
|
|
|
#include "core/gimplayer-floating-sel.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
#include "gimpfreeselecttool.h"
|
2003-02-09 05:12:03 +08:00
|
|
|
#include "gimpselectionoptions.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2001-03-10 01:39:18 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-03-10 01:39:18 +08:00
|
|
|
|
2000-07-30 00:12:40 +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
|
|
|
#define HANDLE_SIZE 10
|
|
|
|
#define POINT_GRAB_THRESHOLD_SQ SQR(HANDLE_SIZE / 2)
|
|
|
|
#define N_ITEMS_PER_ALLOC 1024
|
|
|
|
#define INVALID_INDEX (-1)
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_free_select_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_free_select_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_free_select_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_free_select_tool_motion (GimpTool *tool,
|
|
|
|
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_draw (GimpDrawTool *draw_tool);
|
|
|
|
static void gimp_free_select_tool_real_select (GimpFreeSelectTool *fst,
|
|
|
|
GimpDisplay *display);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
G_DEFINE_TYPE (GimpFreeSelectTool, gimp_free_select_tool,
|
|
|
|
GIMP_TYPE_SELECTION_TOOL);
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
#define parent_class gimp_free_select_tool_parent_class
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +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 };
|
|
|
|
|
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_free_select_tool_register (GimpToolRegisterCallback callback,
|
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,
|
2003-02-05 22:39:40 +08:00
|
|
|
GIMP_TYPE_SELECTION_OPTIONS,
|
|
|
|
gimp_selection_options_gui,
|
2003-06-28 19:20:37 +08:00
|
|
|
0,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-free-select-tool",
|
2001-11-21 07:00:47 +08:00
|
|
|
_("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"),
|
2004-04-29 21:19:28 +08:00
|
|
|
N_("_Free Select"), "F",
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_FREE_SELECT,
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_FREE_SELECT,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-03-10 01:39:18 +08:00
|
|
|
static void
|
|
|
|
gimp_free_select_tool_class_init (GimpFreeSelectToolClass *klass)
|
|
|
|
{
|
2004-06-05 07:08:29 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
2001-03-10 01:39:18 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
object_class->finalize = gimp_free_select_tool_finalize;
|
2001-03-10 01:39:18 +08:00
|
|
|
|
2005-08-01 02:29:10 +08:00
|
|
|
tool_class->control = gimp_free_select_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
|
|
|
tool_class->oper_update = gimp_free_select_tool_oper_update;
|
|
|
|
tool_class->cursor_update = gimp_free_select_tool_cursor_update;
|
2001-03-10 01:39:18 +08:00
|
|
|
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;
|
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
|
|
|
tool_class->key_press = gimp_free_select_tool_key_press;
|
2001-03-10 01:39:18 +08:00
|
|
|
|
|
|
|
draw_tool_class->draw = gimp_free_select_tool_draw;
|
2005-07-29 09:48:56 +08:00
|
|
|
|
2005-08-07 04:01:22 +08:00
|
|
|
klass->select = gimp_free_select_tool_real_select;
|
2001-03-10 01:39:18 +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_init (GimpFreeSelectTool *fst)
|
2001-03-10 01:39:18 +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
|
|
|
GimpTool *tool = GIMP_TOOL (fst);
|
2001-03-10 01:39:18 +08:00
|
|
|
|
2006-10-04 23:42:33 +08:00
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, FALSE);
|
2007-03-10 23:07:56 +08:00
|
|
|
gimp_tool_control_set_wants_click (tool->control, TRUE);
|
2004-06-05 07:08:29 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
|
|
|
GIMP_TOOL_CURSOR_FREE_SELECT);
|
2002-03-29 11:50:29 +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
|
|
|
fst->grabbed_segment_index = INVALID_INDEX;
|
|
|
|
|
|
|
|
fst->button1_down = FALSE;
|
|
|
|
|
|
|
|
fst->saved_points_lower_segment = NULL;
|
|
|
|
fst->saved_points_higher_segment = NULL;
|
|
|
|
fst->n_saved_points_lower_segment = 0;
|
|
|
|
fst->n_saved_points_higher_segment = 0;
|
|
|
|
|
|
|
|
fst->polygon_modified = FALSE;
|
|
|
|
|
|
|
|
fst->show_pending_point = FALSE;
|
|
|
|
|
|
|
|
fst->points = NULL;
|
|
|
|
fst->n_points = 0;
|
|
|
|
fst->max_n_points = 0;
|
|
|
|
|
|
|
|
fst->segment_indices = NULL;
|
|
|
|
fst->n_segment_indices = 0;
|
|
|
|
fst->max_n_segment_indices = 0;
|
2001-03-10 01:39:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-08-14 22:53:55 +08:00
|
|
|
gimp_free_select_tool_finalize (GObject *object)
|
2001-03-10 01:39:18 +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
|
|
|
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (object);
|
|
|
|
|
|
|
|
g_free (fst->points);
|
|
|
|
|
|
|
|
fst->points = NULL;
|
|
|
|
fst->n_points = 0;
|
|
|
|
fst->max_n_points = 0;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_get_segment (GimpFreeSelectTool *fst,
|
|
|
|
GimpVector2 **points,
|
|
|
|
gint *n_points,
|
|
|
|
gint segment_start,
|
|
|
|
gint segment_end)
|
|
|
|
{
|
|
|
|
*points = &fst->points[fst->segment_indices[segment_start]];
|
|
|
|
*n_points = fst->segment_indices[segment_end] -
|
|
|
|
fst->segment_indices[segment_start] +
|
|
|
|
1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpVector2
|
|
|
|
gimp_free_select_tool_get_grabbed_point (GimpFreeSelectTool *fst)
|
|
|
|
{
|
|
|
|
return fst->points[fst->segment_indices[fst->grabbed_segment_index]];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_cleanup_after_move (GimpFreeSelectTool *fst)
|
|
|
|
{
|
|
|
|
g_free (fst->saved_points_lower_segment);
|
|
|
|
fst->saved_points_lower_segment = NULL;
|
|
|
|
|
|
|
|
g_free (fst->saved_points_higher_segment);
|
|
|
|
fst->saved_points_higher_segment = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_free_select_tool_should_close (GimpFreeSelectTool *fst,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GimpCoords *coords)
|
|
|
|
{
|
|
|
|
gdouble dist;
|
|
|
|
|
2008-05-21 01:06:19 +08:00
|
|
|
if (fst->polygon_modified ||
|
|
|
|
fst->n_segment_indices <= 1 ||
|
|
|
|
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,
|
|
|
|
fst->points[0].x,
|
|
|
|
fst->points[0].y);
|
|
|
|
|
|
|
|
return dist < POINT_GRAB_THRESHOLD_SQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_select_closest_segment_point (GimpFreeSelectTool *fst,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GimpCoords *coords)
|
|
|
|
{
|
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (fst);
|
|
|
|
gdouble shortest_dist = POINT_GRAB_THRESHOLD_SQ;
|
|
|
|
gint grabbed_segment_index = INVALID_INDEX;
|
|
|
|
gint i;
|
2001-03-10 01:39:18 +08:00
|
|
|
|
2008-05-21 01:06:19 +08:00
|
|
|
if (GIMP_TOOL (fst)->display != NULL)
|
2001-08-14 22:53:55 +08:00
|
|
|
{
|
2008-05-21 01:06:19 +08:00
|
|
|
for (i = 0; i < fst->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
|
|
|
|
2008-05-21 01:06:19 +08:00
|
|
|
point = &fst->points[fst->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
|
|
|
|
2008-05-21 01:06:19 +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
|
|
|
}
|
2001-08-14 22:53:55 +08:00
|
|
|
}
|
2001-03-10 01:39:18 +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 (grabbed_segment_index != fst->grabbed_segment_index)
|
|
|
|
{
|
|
|
|
gimp_draw_tool_pause(draw_tool);
|
|
|
|
|
|
|
|
fst->grabbed_segment_index = grabbed_segment_index;
|
|
|
|
|
|
|
|
gimp_draw_tool_resume(draw_tool);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_halt (GimpFreeSelectTool *fst)
|
|
|
|
{
|
|
|
|
GimpTool *tool = GIMP_TOOL (fst);
|
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (fst);
|
|
|
|
|
|
|
|
if (gimp_draw_tool_is_active (draw_tool))
|
|
|
|
gimp_draw_tool_stop (draw_tool);
|
|
|
|
|
|
|
|
if (gimp_tool_control_is_active (tool->control))
|
|
|
|
gimp_tool_control_halt (tool->control);
|
|
|
|
|
|
|
|
fst->grabbed_segment_index = INVALID_INDEX;
|
|
|
|
fst->show_pending_point = FALSE;
|
|
|
|
fst->n_points = 0;
|
|
|
|
fst->n_segment_indices = 0;
|
|
|
|
|
|
|
|
tool->display = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_revert_to_last_segment (GimpFreeSelectTool *fst)
|
|
|
|
{
|
|
|
|
fst->n_points = fst->segment_indices[fst->n_segment_indices - 1] + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_update_button_state (GimpFreeSelectTool *fst,
|
|
|
|
GdkModifierType state)
|
|
|
|
{
|
|
|
|
fst->button1_down = state & GDK_BUTTON1_MASK ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_remove_last_segment (GimpFreeSelectTool *fst)
|
|
|
|
{
|
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (fst);
|
|
|
|
|
|
|
|
gimp_draw_tool_pause (draw_tool);
|
|
|
|
|
|
|
|
fst->n_segment_indices--;
|
|
|
|
|
|
|
|
if (fst->n_segment_indices == 0)
|
|
|
|
{
|
|
|
|
gimp_free_select_tool_halt (fst);
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
if (fst->n_points >= fst->max_n_points)
|
|
|
|
{
|
|
|
|
fst->max_n_points += N_ITEMS_PER_ALLOC;
|
|
|
|
|
|
|
|
fst->points = g_realloc (fst->points,
|
|
|
|
sizeof (GimpVector2) * fst->max_n_points);
|
|
|
|
}
|
|
|
|
|
|
|
|
fst->points[fst->n_points].x = x;
|
|
|
|
fst->points[fst->n_points].y = y;
|
|
|
|
|
|
|
|
fst->n_points++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_add_segment_index (GimpFreeSelectTool *fst,
|
|
|
|
gint index)
|
|
|
|
{
|
|
|
|
if (fst->n_segment_indices >= fst->max_n_segment_indices)
|
|
|
|
{
|
|
|
|
fst->max_n_segment_indices += N_ITEMS_PER_ALLOC;
|
|
|
|
|
|
|
|
fst->segment_indices = g_realloc (fst->segment_indices,
|
|
|
|
sizeof (GimpVector2) * fst->max_n_segment_indices);
|
|
|
|
}
|
|
|
|
|
|
|
|
fst->segment_indices[fst->n_segment_indices] = index;
|
|
|
|
|
|
|
|
fst->n_segment_indices++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_free_select_tool_is_point_grabbed (GimpFreeSelectTool *fst)
|
|
|
|
{
|
|
|
|
return fst->grabbed_segment_index != INVALID_INDEX;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_start (GimpFreeSelectTool *fst,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
GimpTool *tool = GIMP_TOOL (fst);
|
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
|
|
|
|
|
|
|
gimp_free_select_tool_halt (fst);
|
|
|
|
|
|
|
|
gimp_tool_control_activate (tool->control);
|
|
|
|
|
|
|
|
tool->display = display;
|
|
|
|
|
|
|
|
gimp_draw_tool_start (draw_tool, display);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
GimpVector2 cursor_point = { new_x, new_y };
|
|
|
|
GimpVector2 *dest;
|
|
|
|
GimpVector2 *dest_start_target;
|
|
|
|
GimpVector2 *dest_end_target;
|
|
|
|
gint n_points;
|
|
|
|
|
|
|
|
/* Handle the segment before the grabbed point */
|
|
|
|
if (segment_index > 0)
|
|
|
|
{
|
|
|
|
gimp_free_select_get_segment (fst,
|
|
|
|
&dest,
|
|
|
|
&n_points,
|
|
|
|
fst->grabbed_segment_index - 1,
|
|
|
|
fst->grabbed_segment_index);
|
|
|
|
|
|
|
|
dest_start_target = &dest[0];
|
|
|
|
dest_end_target = &cursor_point;
|
|
|
|
|
|
|
|
gimp_free_select_tool_fit_segment (fst,
|
|
|
|
dest,
|
|
|
|
*dest_start_target,
|
|
|
|
*dest_end_target,
|
|
|
|
fst->saved_points_lower_segment,
|
|
|
|
n_points);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle the segment after the grabbed point */
|
|
|
|
if (segment_index < fst->n_segment_indices - 1)
|
|
|
|
{
|
|
|
|
gimp_free_select_get_segment (fst,
|
|
|
|
&dest,
|
|
|
|
&n_points,
|
|
|
|
fst->grabbed_segment_index,
|
|
|
|
fst->grabbed_segment_index + 1);
|
|
|
|
|
|
|
|
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,
|
|
|
|
fst->saved_points_higher_segment,
|
|
|
|
n_points);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
/* The points are all setup, just make a segment */
|
|
|
|
gimp_free_select_tool_add_segment_index (fst,
|
|
|
|
fst->n_points - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_commit (GimpFreeSelectTool *fst,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
if (fst->n_points >= 3)
|
|
|
|
{
|
|
|
|
gimp_free_select_tool_select (fst, display);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_free_select_tool_halt (fst);
|
|
|
|
|
|
|
|
gimp_image_flush (display->image);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_handle_click (GimpFreeSelectTool *fst,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
/* 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, see if it's commiting time */
|
|
|
|
if (gimp_free_select_tool_should_close (fst,
|
|
|
|
display,
|
|
|
|
coords))
|
|
|
|
{
|
|
|
|
gimp_free_select_tool_commit (fst, display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_handle_normal_release (GimpFreeSelectTool *fst,
|
|
|
|
GimpCoords *coords,
|
|
|
|
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,
|
|
|
|
coords))
|
|
|
|
{
|
|
|
|
gimp_free_select_tool_commit (fst, display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_free_select_tool_revert_to_saved_state (GimpFreeSelectTool *fst)
|
|
|
|
{
|
|
|
|
GimpVector2 *source;
|
|
|
|
gint n_points;
|
|
|
|
|
|
|
|
if (fst->grabbed_segment_index > 0)
|
|
|
|
{
|
|
|
|
gimp_free_select_get_segment (fst,
|
|
|
|
&source,
|
|
|
|
&n_points,
|
|
|
|
fst->grabbed_segment_index - 1,
|
|
|
|
fst->grabbed_segment_index);
|
|
|
|
|
|
|
|
memcpy (source,
|
|
|
|
fst->saved_points_lower_segment,
|
|
|
|
sizeof (GimpVector2) * n_points);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fst->grabbed_segment_index < fst->n_segment_indices - 1)
|
|
|
|
{
|
|
|
|
gimp_free_select_get_segment (fst,
|
|
|
|
&source,
|
|
|
|
&n_points,
|
|
|
|
fst->grabbed_segment_index,
|
|
|
|
fst->grabbed_segment_index + 1);
|
|
|
|
|
|
|
|
memcpy (source,
|
|
|
|
fst->saved_points_higher_segment,
|
|
|
|
sizeof (GimpVector2) * n_points);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_free_select_tool_remove_last_segment (fst);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
GimpVector2 *source;
|
|
|
|
gint n_points;
|
|
|
|
|
|
|
|
if (fst->grabbed_segment_index > 0)
|
|
|
|
{
|
|
|
|
gimp_free_select_get_segment (fst,
|
|
|
|
&source,
|
|
|
|
&n_points,
|
|
|
|
fst->grabbed_segment_index - 1,
|
|
|
|
fst->grabbed_segment_index);
|
|
|
|
|
|
|
|
fst->saved_points_lower_segment = g_new0 (GimpVector2, n_points);
|
|
|
|
|
|
|
|
memcpy (fst->saved_points_lower_segment,
|
|
|
|
source,
|
|
|
|
sizeof (GimpVector2) * n_points);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fst->grabbed_segment_index < fst->n_segment_indices - 1)
|
|
|
|
{
|
|
|
|
gimp_free_select_get_segment (fst,
|
|
|
|
&source,
|
|
|
|
&n_points,
|
|
|
|
fst->grabbed_segment_index,
|
|
|
|
fst->grabbed_segment_index + 1);
|
|
|
|
|
|
|
|
fst->saved_points_higher_segment = g_new0 (GimpVector2, n_points);
|
|
|
|
|
|
|
|
memcpy (fst->saved_points_higher_segment,
|
|
|
|
source,
|
|
|
|
sizeof (GimpVector2) * n_points);
|
|
|
|
}
|
2001-03-10 01:39:18 +08:00
|
|
|
}
|
|
|
|
|
2008-05-21 01:06:19 +08:00
|
|
|
static void
|
|
|
|
gimp_free_select_tool_status_update (GimpFreeSelectTool *fst,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GimpCoords *coords,
|
|
|
|
gboolean proximity)
|
|
|
|
{
|
|
|
|
GimpTool *tool = GIMP_TOOL (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, coords))
|
|
|
|
{
|
|
|
|
status_text = _("Click to complete selection");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status_text = _("Click-Drag to move segment vertex");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (fst->n_points >= 3)
|
|
|
|
{
|
|
|
|
status_text = _("Return commits, Escape cancels, Backspace removes last segment");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status_text = _("Click-Drag creates free segment, Click creates polygonal segment");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status_text)
|
|
|
|
{
|
|
|
|
gimp_tool_push_status (tool, display, status_text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-01 02:29:10 +08:00
|
|
|
static void
|
|
|
|
gimp_free_select_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2005-08-01 02:29:10 +08:00
|
|
|
{
|
|
|
|
switch (action)
|
|
|
|
{
|
2006-05-22 05:12:01 +08:00
|
|
|
case GIMP_TOOL_ACTION_PAUSE:
|
|
|
|
case GIMP_TOOL_ACTION_RESUME:
|
2005-08-01 02:29:10 +08:00
|
|
|
break;
|
|
|
|
|
2006-05-22 05:12:01 +08:00
|
|
|
case GIMP_TOOL_ACTION_HALT:
|
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_halt (GIMP_FREE_SELECT_TOOL (tool));
|
2005-08-01 02:29:10 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
|
2005-08-01 02:29:10 +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 void
|
|
|
|
gimp_free_select_tool_oper_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
GimpFreeSelectTool *fst;
|
|
|
|
gboolean hovering_first_point;
|
|
|
|
|
|
|
|
fst = GIMP_FREE_SELECT_TOOL (tool);
|
|
|
|
|
|
|
|
gimp_free_select_tool_select_closest_segment_point (fst,
|
|
|
|
display,
|
|
|
|
coords);
|
|
|
|
hovering_first_point =
|
|
|
|
gimp_free_select_tool_should_close (fst,
|
|
|
|
display,
|
|
|
|
coords);
|
|
|
|
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
|
|
|
if (fst->n_points == 0 ||
|
|
|
|
(gimp_free_select_tool_is_point_grabbed (fst) &&
|
|
|
|
! hovering_first_point))
|
|
|
|
{
|
|
|
|
fst->show_pending_point = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fst->show_pending_point = TRUE;
|
|
|
|
|
|
|
|
if (hovering_first_point)
|
|
|
|
{
|
|
|
|
fst->pending_point = fst->points[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fst->pending_point.x = coords->x;
|
|
|
|
fst->pending_point.y = coords->y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
2008-05-21 01:06:19 +08:00
|
|
|
|
|
|
|
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,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (tool);
|
|
|
|
|
|
|
|
if (gimp_free_select_tool_is_point_grabbed (fst) &&
|
|
|
|
! gimp_free_select_tool_should_close (fst, display, coords))
|
|
|
|
{
|
|
|
|
gimp_tool_set_cursor (tool, display,
|
|
|
|
gimp_tool_control_get_cursor (tool->control),
|
|
|
|
gimp_tool_control_get_tool_cursor (tool->control),
|
|
|
|
GIMP_CURSOR_MODIFIER_MOVE);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
|
|
|
|
}
|
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_free_select_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
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
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
|
|
|
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (tool);
|
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_pause (draw_tool);
|
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
|
|
|
gimp_free_select_tool_update_button_state (fst, state);
|
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
|
|
|
if (display != tool->display)
|
|
|
|
{
|
|
|
|
gimp_free_select_tool_start (fst,
|
|
|
|
coords,
|
|
|
|
display);
|
|
|
|
}
|
2001-03-10 01:39:18 +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 (gimp_free_select_tool_is_point_grabbed (fst))
|
|
|
|
{
|
|
|
|
gimp_free_select_tool_prepare_for_move (fst);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* 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,
|
|
|
|
coords->x,
|
|
|
|
coords->y);
|
|
|
|
gimp_free_select_tool_add_segment_index (fst,
|
|
|
|
fst->n_points - 1);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
static void
|
2007-02-28 02:55:12 +08:00
|
|
|
gimp_free_select_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display)
|
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
|
|
|
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (tool);
|
2001-11-20 21:53:21 +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 (tool->display != display)
|
|
|
|
return;
|
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_pause (GIMP_DRAW_TOOL (fst));
|
|
|
|
|
|
|
|
gimp_free_select_tool_update_button_state (fst, state);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2007-03-10 23:07:56 +08:00
|
|
|
switch (release_type)
|
2005-07-29 08:16:45 +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
|
|
|
case GIMP_BUTTON_RELEASE_CLICK:
|
|
|
|
case GIMP_BUTTON_RELEASE_NO_MOTION:
|
|
|
|
/* If a click was made, we don't consider the polygon modified */
|
|
|
|
fst->polygon_modified = FALSE;
|
|
|
|
|
|
|
|
gimp_free_select_tool_handle_click (fst,
|
|
|
|
coords,
|
|
|
|
display);
|
2007-03-10 23:07:56 +08:00
|
|
|
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);
|
2007-03-10 23:07:56 +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
|
|
|
/* No need to be clever, we can cleanup even if no move was done */
|
|
|
|
if (fst->polygon_modified)
|
2005-07-29 09:48:56 +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_free_select_tool_cleanup_after_move (fst);
|
2005-07-29 09:48:56 +08:00
|
|
|
}
|
2007-03-10 23:07:56 +08:00
|
|
|
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
|
|
|
}
|
2005-07-29 08:16:45 +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 */
|
|
|
|
fst->polygon_modified = FALSE;
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (fst));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_free_select_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
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
|
|
|
GimpFreeSelectTool *fst;
|
|
|
|
GimpDrawTool *draw_tool;
|
|
|
|
|
|
|
|
if (tool->display != display)
|
|
|
|
return;
|
|
|
|
|
|
|
|
fst = GIMP_FREE_SELECT_TOOL (tool);
|
|
|
|
draw_tool = GIMP_DRAW_TOOL (tool);
|
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_pause (draw_tool);
|
|
|
|
|
|
|
|
if (gimp_free_select_tool_is_point_grabbed (fst))
|
2000-07-30 00:12:40 +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
|
|
|
fst->polygon_modified = TRUE;
|
|
|
|
|
|
|
|
gimp_free_select_tool_move_segment_vertex_to (fst,
|
|
|
|
fst->grabbed_segment_index,
|
|
|
|
coords->x,
|
|
|
|
coords->y);
|
|
|
|
|
|
|
|
/* We also must update the pending point if we are moving the
|
|
|
|
* first point
|
|
|
|
*/
|
|
|
|
if (fst->grabbed_segment_index == 0)
|
|
|
|
{
|
|
|
|
fst->pending_point.x = coords->x;
|
|
|
|
fst->pending_point.y = coords->y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Don't show the pending point while we are adding points */
|
|
|
|
fst->show_pending_point = FALSE;
|
2000-07-30 00:12:40 +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_free_select_tool_add_point (fst,
|
|
|
|
coords->x,
|
|
|
|
coords->y);
|
2000-07-30 00:12:40 +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);
|
|
|
|
}
|
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);
|
2003-05-27 19:52:03 +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
|
|
|
switch (kevent->keyval)
|
2003-05-27 19:52:03 +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
|
|
|
case GDK_BackSpace:
|
|
|
|
gimp_free_select_tool_remove_last_segment (fst);
|
|
|
|
return TRUE;
|
2003-05-27 19:52:03 +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
|
|
|
case GDK_Return:
|
|
|
|
case GDK_KP_Enter:
|
|
|
|
case GDK_ISO_Enter:
|
|
|
|
gimp_free_select_tool_commit (fst, display);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case GDK_Escape:
|
|
|
|
gimp_free_select_tool_halt (fst);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2003-05-27 19:52:03 +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
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-03-10 01:39:18 +08:00
|
|
|
gimp_free_select_tool_draw (GimpDrawTool *draw_tool)
|
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
|
|
|
GimpFreeSelectTool *fst = GIMP_FREE_SELECT_TOOL (draw_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-08-09 07:25:44 +08:00
|
|
|
gimp_draw_tool_draw_lines (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
|
|
|
fst->points, fst->n_points,
|
2006-08-09 07:25:44 +08:00
|
|
|
FALSE, FALSE);
|
2005-12-13 17:13:50 +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 (gimp_free_select_tool_is_point_grabbed (fst) &&
|
|
|
|
! fst->button1_down)
|
|
|
|
{
|
|
|
|
GimpVector2 grabbed_point;
|
2005-12-13 17:13:50 +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
|
|
|
grabbed_point = gimp_free_select_tool_get_grabbed_point (fst);
|
2005-12-13 17:13:50 +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_draw_handle (draw_tool, GIMP_HANDLE_CIRCLE,
|
|
|
|
grabbed_point.x,
|
|
|
|
grabbed_point.y,
|
|
|
|
HANDLE_SIZE, HANDLE_SIZE,
|
|
|
|
GTK_ANCHOR_CENTER, FALSE);
|
|
|
|
}
|
2005-12-13 17:13:50 +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 (fst->show_pending_point)
|
|
|
|
{
|
|
|
|
GimpVector2 last = fst->points[fst->n_points - 1];
|
2005-12-13 17:13:50 +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_draw_line (draw_tool,
|
|
|
|
last.x,
|
|
|
|
last.y,
|
|
|
|
fst->pending_point.x,
|
|
|
|
fst->pending_point.y,
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
}
|
2005-12-13 17:13:50 +08:00
|
|
|
|
2005-07-29 09:48:56 +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,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2005-07-29 09:48:56 +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
|
|
|
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (fst);
|
2005-07-29 09:48:56 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_channel_select_polygon (gimp_image_get_mask (display->image),
|
2006-06-28 03:39:48 +08:00
|
|
|
Q_("command|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
|
|
|
fst->n_points,
|
|
|
|
fst->points,
|
Separate selection tool function (select, move, cut, ...) from selection
2006-10-18 Michael Natterer <mitch@gimp.org>
Separate selection tool function (select, move, cut, ...) from
selection mode (replace, add, ...). Fixes bug #313634 (that bug
wasn't triggered any more in HEAD, but was still there).
* app/tools/tools-enums.h: renamed enum SelectOp to SelectFunction
and replaced the values REPLACE, ADD, SUBTRACT and INTERSECT by a
single value SELECT.
* app/tools/gimpselectiontool.h (struct GimpSelectionTool):
renamed member "op" to "function". Changed "SelectOps saved_op" to
"GimpChannelOps saved_operation".
* app/tools/gimpselectiontool.c: we always have the right
GimpChannelOps in the tool options, so simply use it instead of
mixing up unrelated stuff in one enum. Results is some medium-ugly
nested switches, but is generally much cleaner than before.
* app/tools/gimpforegroundselecttool.c
* app/tools/gimpfreeselecttool.c
* app/tools/gimpiscissorstool.c
* app/tools/gimpregionselecttool.c: changed accordingly. Use the
operation from the tool options instead of selection_tool->op when
making the actual selection.
2006-10-18 16:04:55 +08:00
|
|
|
options->operation,
|
2005-07-29 09:48:56 +08:00
|
|
|
options->antialias,
|
|
|
|
options->feather,
|
|
|
|
options->feather_radius,
|
2006-08-26 01:19:36 +08:00
|
|
|
options->feather_radius,
|
|
|
|
TRUE);
|
2005-07-29 09:48:56 +08:00
|
|
|
}
|
|
|
|
|