app/bezier_select.h app/bezier_selectP.h app/by_color_select.[ch]

2000-03-29  Michael Natterer  <mitch@gimp.org>

	* app/bezier_select.h
	* app/bezier_selectP.h
	* app/by_color_select.[ch]
	* app/ellipse_select.[ch]
	* app/free_select.[ch]
	* app/move.[ch]
	* app/rect_select.[ch]: kindof selection tools code review:

	- use SelectOps instead of int.
	- removed some unused prototyped and callbacks.
	- don't show the SELECTION_MOVE_MASK cursor if there is no
	  selection and don't try to move the mask in that case.
	- re(?)-enabled moving the selection mask even if there is a
	  floating selection.
	- usual bunch of cleanups.
This commit is contained in:
Michael Natterer
2000-03-28 23:39:32 +00:00
committed by Michael Natterer
parent b7940e1ebf
commit c497d9c140
35 changed files with 1205 additions and 981 deletions

View File

@ -1,3 +1,21 @@
2000-03-29 Michael Natterer <mitch@gimp.org>
* app/bezier_select.h
* app/bezier_selectP.h
* app/by_color_select.[ch]
* app/ellipse_select.[ch]
* app/free_select.[ch]
* app/move.[ch]
* app/rect_select.[ch]: kindof selection tools code review:
- use SelectOps instead of int.
- removed some unused prototyped and callbacks.
- don't show the SELECTION_MOVE_MASK cursor if there is no
selection and don't try to move the mask in that case.
- re(?)-enabled moving the selection mask even if there is a
floating selection.
- usual bunch of cleanups.
2000-03-29 Sven Neumann <sven@gimp.org> 2000-03-29 Sven Neumann <sven@gimp.org>
* app/gimpui.[ch]: (gimp_dialog_hide) new function that calls * app/gimpui.[ch]: (gimp_dialog_hide) new function that calls

View File

@ -20,14 +20,14 @@
#include "toolsF.h" #include "toolsF.h"
typedef struct _bezier_point BezierPoint; typedef struct _BezierPoint BezierPoint;
typedef struct _bezier_select BezierSelect; typedef struct _BezierSelect BezierSelect;
/* bezier select functions */ /* bezier select functions */
void bezier_select_dialog (void);
Tool * tools_new_bezier_select (void); Tool * tools_new_bezier_select (void);
void tools_free_bezier_select (Tool *); void tools_free_bezier_select (Tool *tool);
gboolean bezier_tool_selected (void); gboolean bezier_tool_selected (void);
#endif /* __BEZIER_SELECT_H__ */ #endif /* __BEZIER_SELECT_H__ */

View File

@ -37,11 +37,11 @@
enum { EXTEND_EDIT, EXTEND_ADD, EXTEND_REMOVE, EXTEND_NEW }; enum { EXTEND_EDIT, EXTEND_ADD, EXTEND_REMOVE, EXTEND_NEW };
struct _bezier_point struct _BezierPoint
{ {
int type; /* type of point (anchor/control/move) */ gint type; /* type of point (anchor/control/move) */
double x, y; /* location of point in image space */ gdouble x, y; /* location of point in image space */
int sx, sy; /* location of point in screen space */ gint sx, sy; /* location of point in screen space */
BezierPoint *next; /* next point on curve */ BezierPoint *next; /* next point on curve */
BezierPoint *prev; /* prev point on curve */ BezierPoint *prev; /* prev point on curve */
BezierPoint *next_curve; /* Next curve segment */ BezierPoint *next_curve; /* Next curve segment */
@ -50,17 +50,17 @@ struct _bezier_point
*/ */
}; };
struct _bezier_select struct _BezierSelect
{ {
int state; /* start, add, edit or drag */ gint state; /* start, add, edit or drag */
int draw; /* all or part */ gint draw; /* all or part */
int closed; /* is the last curve closed */ gint closed; /* is the last curve closed */
DrawCore *core; /* Core drawing object */ DrawCore *core; /* Core drawing object */
BezierPoint *points; /* the curve */ BezierPoint *points; /* the curve */
BezierPoint *cur_anchor; /* the current active anchor point */ BezierPoint *cur_anchor; /* the current active anchor point */
BezierPoint *cur_control; /* the current active control point */ BezierPoint *cur_control; /* the current active control point */
BezierPoint *last_point; /* the last point on the curve */ BezierPoint *last_point; /* the last point on the curve */
int num_points; /* number of points in the curve */ gint num_points; /* number of points in the curve */
Channel *mask; /* null if the curve is open */ Channel *mask; /* null if the curve is open */
GSList **scanlines; /* used in converting a curve */ GSList **scanlines; /* used in converting a curve */
}; };
@ -69,25 +69,44 @@ struct _bezier_select
* have this structure as the first element. * have this structure as the first element.
*/ */
typedef struct { typedef struct
{
gint count; gint count;
} CountCurves; } CountCurves;
typedef void (* BezierPointsFunc) (BezierSelect *, GdkPoint *, int,gpointer); typedef void (* BezierPointsFunc) (BezierSelect *, GdkPoint *, int,gpointer);
/* Functions */ /* Functions */
int bezier_select_load (void *, BezierPoint *, int, int); int bezier_select_load (void *,
void bezier_draw_curve (BezierSelect *,BezierPointsFunc, int,gpointer); BezierPoint *,
void bezier_select_reset (BezierSelect *); gint,
gint);
void bezier_draw_curve (BezierSelect *,
BezierPointsFunc,
gint,
gpointer);
void bezier_select_reset (BezierSelect *bezier_sel);
void bezier_select_free (BezierSelect *bezier_sel); void bezier_select_free (BezierSelect *bezier_sel);
void bezier_add_point (BezierSelect *, int, gdouble, gdouble); void bezier_add_point (BezierSelect *,
void bezier_paste_bezierselect_to_current (GDisplay *,BezierSelect *); gint,
gdouble,
gdouble);
void bezier_paste_bezierselect_to_current (GDisplay *gdisp,
BezierSelect *bezier_sel);
void bezier_select_mode (gint); void bezier_select_mode (gint);
void bezier_stroke (BezierSelect *, GDisplay *, int, int); void bezier_stroke (BezierSelect *bezier_sel,
void bezier_to_selection (BezierSelect *, GDisplay *); GDisplay *gdisp,
gint bezier_distance_along (BezierSelect *, gint, gdouble,gint *,gint *,gdouble *); gint,
void bezier_draw (GDisplay *,BezierSelect *); gint);
void bezier_to_selection (BezierSelect *bezier_sel,
GDisplay *gdisp);
gint bezier_distance_along (BezierSelect *bezier_sel,
gint,
gdouble,
gint *,
gint *,
gdouble *);
void bezier_draw (GDisplay *gdisp,
BezierSelect *bezier_sel);
#endif /* __BEZIER_SELECTP_H__ */ #endif /* __BEZIER_SELECTP_H__ */

View File

@ -51,7 +51,7 @@ typedef struct _ByColorSelect ByColorSelect;
struct _ByColorSelect struct _ByColorSelect
{ {
gint x, y; /* Point from which to execute seed fill */ gint x, y; /* Point from which to execute seed fill */
gint operation; /* add, subtract, normal color selection */ SelectOps operation; /* add, subtract, normal color selection */
}; };
typedef struct _ByColorDialog ByColorDialog; typedef struct _ByColorDialog ByColorDialog;
@ -82,8 +82,11 @@ static GtkTargetEntry by_color_select_targets[] =
static guint n_by_color_select_targets = (sizeof (by_color_select_targets) / static guint n_by_color_select_targets = (sizeof (by_color_select_targets) /
sizeof (by_color_select_targets[0])); sizeof (by_color_select_targets[0]));
static void by_color_select_color_drop (GtkWidget *, guchar, guchar, guchar, static void by_color_select_color_drop (GtkWidget *widget,
gpointer); guchar r,
guchar g,
guchar b,
gpointer data);
/* by_color select action functions */ /* by_color select action functions */
@ -101,10 +104,8 @@ static void by_color_select_draw (ByColorDialog *, GImage *);
static gint by_color_select_preview_events (GtkWidget *, static gint by_color_select_preview_events (GtkWidget *,
GdkEventButton *, GdkEventButton *,
ByColorDialog *); ByColorDialog *);
static void by_color_select_type_callback (GtkWidget *, gpointer);
static void by_color_select_reset_callback (GtkWidget *, gpointer); static void by_color_select_reset_callback (GtkWidget *, gpointer);
static void by_color_select_close_callback (GtkWidget *, gpointer); static void by_color_select_close_callback (GtkWidget *, gpointer);
static void by_color_select_fuzzy_update (GtkAdjustment *, gpointer);
static void by_color_select_preview_button_press (ByColorDialog *, static void by_color_select_preview_button_press (ByColorDialog *,
GdkEventButton *); GdkEventButton *);
@ -169,9 +170,9 @@ static Channel *
by_color_select_color (GImage *gimage, by_color_select_color (GImage *gimage,
GimpDrawable *drawable, GimpDrawable *drawable,
guchar *color, guchar *color,
gint antialias, gboolean antialias,
gint threshold, gint threshold,
gint sample_merged) gboolean sample_merged)
{ {
/* Scan over the gimage's active layer, finding pixels within the specified /* Scan over the gimage's active layer, finding pixels within the specified
* threshold from the given R, G, & B values. If antialiasing is on, * threshold from the given R, G, & B values. If antialiasing is on,
@ -279,11 +280,11 @@ by_color_select (GImage *gimage,
GimpDrawable *drawable, GimpDrawable *drawable,
guchar *color, guchar *color,
gint threshold, gint threshold,
gint op, SelectOps op,
gint antialias, gboolean antialias,
gint feather, gboolean feather,
gdouble feather_radius, gdouble feather_radius,
gint sample_merged) gboolean sample_merged)
{ {
Channel *new_mask; Channel *new_mask;
gint off_x, off_y; gint off_x, off_y;
@ -295,7 +296,7 @@ by_color_select (GImage *gimage,
antialias, threshold, sample_merged); antialias, threshold, sample_merged);
/* if applicable, replace the current selection */ /* if applicable, replace the current selection */
if (op == REPLACE) if (op == SELECTION_REPLACE)
gimage_mask_clear (gimage); gimage_mask_clear (gimage);
else else
gimage_mask_undo (gimage); gimage_mask_undo (gimage);
@ -675,7 +676,7 @@ by_color_select_dialog_new (void)
bcd = g_new (ByColorDialog, 1); bcd = g_new (ByColorDialog, 1);
bcd->gimage = NULL; bcd->gimage = NULL;
bcd->operation = REPLACE; bcd->operation = SELECTION_REPLACE;
bcd->threshold = DEFAULT_FUZZINESS; bcd->threshold = DEFAULT_FUZZINESS;
/* The shell and main vbox */ /* The shell and main vbox */
@ -743,16 +744,15 @@ by_color_select_dialog_new (void)
/* Create the selection mode radio box */ /* Create the selection mode radio box */
frame = frame =
gimp_radio_group_new (TRUE, _("Selection Mode"), gimp_radio_group_new2 (TRUE, _("Selection Mode"),
gimp_radio_button_update,
&by_color_dialog->operation,
(gpointer) by_color_dialog->operation,
_("Replace"), by_color_select_type_callback, _("Replace"), (gpointer) SELECTION_REPLACE, NULL,
(gpointer) SELECTION_REPLACE, NULL, NULL, TRUE, _("Add"), (gpointer) SELECTION_ADD, NULL,
_("Add"), by_color_select_type_callback, _("Subtract"), (gpointer) SELECTION_SUB, NULL,
(gpointer) SELECTION_ADD, NULL, NULL, FALSE, _("Intersect"), (gpointer) SELECTION_INTERSECT, NULL,
_("Subtract"), by_color_select_type_callback,
(gpointer) SELECTION_SUB, NULL, NULL, FALSE,
_("Intersect"), by_color_select_type_callback,
(gpointer) SELECTION_INTERSECT, NULL, NULL, FALSE,
NULL); NULL);
@ -776,8 +776,8 @@ by_color_select_dialog_new (void)
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (data), "value_changed", gtk_signal_connect (GTK_OBJECT (data), "value_changed",
GTK_SIGNAL_FUNC (by_color_select_fuzzy_update), GTK_SIGNAL_FUNC (gimp_int_adjustment_update),
bcd); &bcd->threshold);
gtk_widget_show (slider); gtk_widget_show (slider);
@ -936,14 +936,6 @@ by_color_select_preview_events (GtkWidget *widget,
return FALSE; return FALSE;
} }
static void
by_color_select_type_callback (GtkWidget *widget,
gpointer data)
{
if (by_color_dialog)
by_color_dialog->operation = (long) data;
}
static void static void
by_color_select_reset_callback (GtkWidget *widget, by_color_select_reset_callback (GtkWidget *widget,
gpointer data) gpointer data)
@ -987,23 +979,13 @@ by_color_select_close_callback (GtkWidget *widget,
} }
} }
static void
by_color_select_fuzzy_update (GtkAdjustment *adjustment,
gpointer data)
{
ByColorDialog *bcd;
bcd = (ByColorDialog *) data;
bcd->threshold = (gint) (adjustment->value + 0.5);
}
static void static void
by_color_select_preview_button_press (ByColorDialog *bcd, by_color_select_preview_button_press (ByColorDialog *bcd,
GdkEventButton *bevent) GdkEventButton *bevent)
{ {
gint x, y; gint x, y;
gint replace, operation; gboolean replace;
SelectOps operation;
GimpDrawable *drawable; GimpDrawable *drawable;
Tile *tile; Tile *tile;
guchar *col; guchar *col;
@ -1019,7 +1001,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
/* Defaults */ /* Defaults */
replace = FALSE; replace = FALSE;
operation = REPLACE; operation = SELECTION_REPLACE;
/* Based on modifiers, and the "by color" dialog's selection mode */ /* Based on modifiers, and the "by color" dialog's selection mode */
if ((bevent->state & GDK_SHIFT_MASK) && if ((bevent->state & GDK_SHIFT_MASK) &&
@ -1049,7 +1031,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
} }
else else
{ {
int offx, offy; gint offx, offy;
drawable_offsets (drawable, &offx, &offy); drawable_offsets (drawable, &offx, &offy);
x = drawable_width (drawable) * bevent->x / bcd->preview->requisition.width - offx; x = drawable_width (drawable) * bevent->x / bcd->preview->requisition.width - offx;

View File

@ -32,10 +32,10 @@ void by_color_select (GimpImage *gimage,
GimpDrawable *drawable, GimpDrawable *drawable,
guchar *color, guchar *color,
gint threshold, gint threshold,
gint op, SelectOps op,
gint antialias, gboolean antialias,
gint feather, gboolean feather,
gdouble feather_radius, gdouble feather_radius,
gint sample_merged); gboolean sample_merged);
#endif /* __BY_COLOR_SELECT_H__ */ #endif /* __BY_COLOR_SELECT_H__ */

View File

@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "appenv.h" #include "appenv.h"
#include "edit_selection.h" #include "edit_selection.h"
#include "ellipse_select.h" #include "ellipse_select.h"
@ -36,14 +37,14 @@ SelectionOptions * ellipse_options = NULL;
void void
ellipse_select (GimpImage *gimage, ellipse_select (GimpImage *gimage,
int x, gint x,
int y, gint y,
int w, gint w,
int h, gint h,
int op, SelectOps op,
int antialias, gboolean antialias,
int feather, gboolean feather,
double feather_radius) gdouble feather_radius)
{ {
Channel *new_mask; Channel *new_mask;
@ -74,7 +75,8 @@ ellipse_select (GimpImage *gimage,
channel_delete (new_mask); channel_delete (new_mask);
} }
else else
channel_combine_ellipse (gimage_get_mask (gimage), op, x, y, w, h, antialias); channel_combine_ellipse (gimage_get_mask (gimage), op,
x, y, w, h, antialias);
} }
void void
@ -82,7 +84,8 @@ ellipse_select_draw (Tool *tool)
{ {
GDisplay *gdisp; GDisplay *gdisp;
EllipseSelect *ellipse_sel; EllipseSelect *ellipse_sel;
int x1, y1, x2, y2; gint x1, y1;
gint x2, y2;
gdisp = (GDisplay *) tool->gdisp_ptr; gdisp = (GDisplay *) tool->gdisp_ptr;
ellipse_sel = (EllipseSelect *) tool->private; ellipse_sel = (EllipseSelect *) tool->private;

View File

@ -23,11 +23,18 @@
/* ellipse select functions */ /* ellipse select functions */
void ellipse_select_draw (Tool *); void ellipse_select (GimpImage *gimage,
void ellipse_select (GimpImage *, int, int, int, int, int, gint x,
int, int, double); gint y,
gint w,
gint h,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
void ellipse_select_draw (Tool *tool);
Tool * tools_new_ellipse_select (void); Tool * tools_new_ellipse_select (void);
void tools_free_ellipse_select (Tool *); void tools_free_ellipse_select (Tool *tool);
#endif /* __ELLIPSE_SELECT_H__ */ #endif /* __ELLIPSE_SELECT_H__ */

View File

@ -17,6 +17,7 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "appenv.h" #include "appenv.h"
#include "draw_core.h" #include "draw_core.h"
#include "edit_selection.h" #include "edit_selection.h"
@ -41,7 +42,7 @@ struct _FreeSelect
{ {
DrawCore *core; /* Core select object */ DrawCore *core; /* Core select object */
gint op; /* selection operation (ADD, SUB, etc) */ SelectOps op; /* selection operation (ADD, SUB, etc) */
gint current_x; /* these values are updated on every motion event */ gint current_x; /* these values are updated on every motion event */
gint current_y; /* (enables immediate cursor updating on modifier gint current_y; /* (enables immediate cursor updating on modifier
@ -57,15 +58,15 @@ static SelectionOptions * free_options = NULL;
/* The global array of XPoints for drawing the polygon... */ /* The global array of XPoints for drawing the polygon... */
static GdkPoint *global_pts = NULL; static GdkPoint *global_pts = NULL;
static int max_segs = 0; static gint max_segs = 0;
/* functions */ /* functions */
static int static gint
add_point (int num_pts, add_point (gint num_pts,
int x, gint x,
int y) gint y)
{ {
if (num_pts >= max_segs) if (num_pts >= max_segs)
{ {
@ -86,11 +87,11 @@ add_point (int num_pts,
static Channel * static Channel *
scan_convert (GimpImage *gimage, scan_convert (GimpImage *gimage,
int num_pts, gint num_pts,
ScanConvertPoint *pts, ScanConvertPoint *pts,
int width, gint width,
int height, gint height,
int antialias) gboolean antialias)
{ {
Channel *mask; Channel *mask;
ScanConverter *sc; ScanConverter *sc;
@ -110,23 +111,24 @@ scan_convert (GimpImage *gimage,
void void
free_select (GImage *gimage, free_select (GImage *gimage,
int num_pts, gint num_pts,
ScanConvertPoint *pts, ScanConvertPoint *pts,
int op, SelectOps op,
int antialias, gboolean antialias,
int feather, gboolean feather,
double feather_radius) gdouble feather_radius)
{ {
Channel *mask; Channel *mask;
/* if applicable, replace the current selection */ /* if applicable, replace the current selection */
/* or insure that a floating selection is anchored down... */ /* or insure that a floating selection is anchored down... */
if (op == REPLACE) if (op == SELECTION_REPLACE)
gimage_mask_clear (gimage); gimage_mask_clear (gimage);
else else
gimage_mask_undo (gimage); gimage_mask_undo (gimage);
mask = scan_convert (gimage, num_pts, pts, gimage->width, gimage->height, antialias); mask = scan_convert (gimage, num_pts, pts,
gimage->width, gimage->height, antialias);
if (mask) if (mask)
{ {
@ -188,7 +190,7 @@ free_select_button_release (Tool *tool,
FreeSelect *free_sel; FreeSelect *free_sel;
ScanConvertPoint *pts; ScanConvertPoint *pts;
GDisplay *gdisp; GDisplay *gdisp;
int i; gint i;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
free_sel = (FreeSelect *) tool->private; free_sel = (FreeSelect *) tool->private;
@ -203,7 +205,7 @@ free_select_button_release (Tool *tool,
/* First take care of the case where the user "cancels" the action */ /* First take care of the case where the user "cancels" the action */
if (! (bevent->state & GDK_BUTTON3_MASK)) if (! (bevent->state & GDK_BUTTON3_MASK))
{ {
pts = (ScanConvertPoint *) g_malloc (sizeof (ScanConvertPoint) * free_sel->num_pts); pts = g_new (ScanConvertPoint, free_sel->num_pts);
for (i = 0; i < free_sel->num_pts; i++) for (i = 0; i < free_sel->num_pts; i++)
{ {
@ -283,7 +285,7 @@ void
free_select_draw (Tool *tool) free_select_draw (Tool *tool)
{ {
FreeSelect *free_sel; FreeSelect *free_sel;
int i; gint i;
free_sel = (FreeSelect *) tool->private; free_sel = (FreeSelect *) tool->private;
@ -294,7 +296,7 @@ free_select_draw (Tool *tool)
} }
static void static void
free_select_options_reset () free_select_options_reset (void)
{ {
selection_options_reset (free_options); selection_options_reset (free_options);
} }

View File

@ -21,9 +21,6 @@
#include "gimpimageF.h" #include "gimpimageF.h"
#include "scan_convert.h" #include "scan_convert.h"
void free_select (GimpImage *, int, ScanConvertPoint *, int, int, int,
double);
/* free select action functions */ /* free select action functions */
void free_select_button_press (Tool *, GdkEventButton *, gpointer); void free_select_button_press (Tool *, GdkEventButton *, gpointer);
@ -33,9 +30,16 @@ void free_select_motion (Tool *, GdkEventMotion *, gpointer)
/* free select functions */ /* free select functions */
void free_select_dialog (void); void free_select (GimpImage *gimage,
void free_select_draw (Tool *); gint num_pts,
ScanConvertPoint *pts,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
void free_select_draw (Tool *tool);
Tool * tools_new_free_select (void); Tool * tools_new_free_select (void);
void tools_free_free_select (Tool *); void tools_free_free_select (Tool *tool);
#endif /* __FREE_SELECT_H__ */ #endif /* __FREE_SELECT_H__ */

View File

@ -21,7 +21,6 @@
#include "cursorutil.h" #include "cursorutil.h"
#include "draw_core.h" #include "draw_core.h"
#include "edit_selection.h" #include "edit_selection.h"
#include "errors.h"
#include "floating_sel.h" #include "floating_sel.h"
#include "gimage_mask.h" #include "gimage_mask.h"
#include "gdisplay.h" #include "gdisplay.h"
@ -57,7 +56,7 @@ static void move_tool_motion (Tool *, GdkEventMotion *, gpointer);
static void move_tool_cursor_update (Tool *, GdkEventMotion *, gpointer); static void move_tool_cursor_update (Tool *, GdkEventMotion *, gpointer);
static void move_tool_control (Tool *, ToolAction, gpointer); static void move_tool_control (Tool *, ToolAction, gpointer);
static void move_create_gc (GDisplay *); static void move_create_gc (GDisplay *gdisp);
/* move action functions */ /* move action functions */
@ -71,7 +70,7 @@ move_tool_button_press (Tool *tool,
MoveTool *move; MoveTool *move;
Layer *layer; Layer *layer;
Guide *guide; Guide *guide;
int x, y; gint x, y;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
move = (MoveTool *) tool->private; move = (MoveTool *) tool->private;
@ -83,7 +82,8 @@ move_tool_button_press (Tool *tool,
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE); gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE);
if (bevent->state & GDK_MOD1_MASK) if (bevent->state & GDK_MOD1_MASK &&
!gimage_mask_is_empty (gdisp->gimage))
{ {
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate); init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
tool->state = ACTIVE; tool->state = ACTIVE;
@ -95,7 +95,8 @@ move_tool_button_press (Tool *tool,
} }
else else
{ {
if (gdisp->draw_guides && (guide = gdisplay_find_guide (gdisp, bevent->x, bevent->y))) if (gdisp->draw_guides &&
(guide = gdisplay_find_guide (gdisp, bevent->x, bevent->y)))
{ {
undo_push_guide (gdisp->gimage, guide); undo_push_guide (gdisp->gimage, guide);
@ -114,9 +115,14 @@ move_tool_button_press (Tool *tool,
} }
else if ((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y))) else if ((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y)))
{ {
/* If there is a floating selection, and this aint it, use the move tool */ /* If there is a floating selection, and this aint it,
if (gimage_floating_sel (gdisp->gimage) && !layer_is_floating_sel (layer)) * use the move tool
*/
if (gimage_floating_sel (gdisp->gimage) &&
!layer_is_floating_sel (layer))
{
move->layer = gimage_floating_sel (gdisp->gimage); move->layer = gimage_floating_sel (gdisp->gimage);
}
/* Otherwise, init the edit selection */ /* Otherwise, init the edit selection */
else else
{ {
@ -131,21 +137,21 @@ move_tool_button_press (Tool *tool,
if (tool->state == ACTIVE) if (tool->state == ACTIVE)
{ {
gdk_pointer_grab (gdisp->canvas->window, FALSE, gdk_pointer_grab (gdisp->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK, GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time); NULL, NULL, bevent->time);
} }
} }
static void static void
move_draw_guide (GDisplay *gdisp, move_draw_guide (GDisplay *gdisp,
Guide *guide) Guide *guide)
{ {
int x1, y1; gint x1, y1;
int x2, y2; gint x2, y2;
int w, h; gint w, h;
int x, y; gint x, y;
if (!move_gc) if (!move_gc)
move_create_gc (gdisp); move_create_gc (gdisp);
@ -158,7 +164,8 @@ move_draw_guide (GDisplay *gdisp,
gdk_window_get_size (gdisp->canvas->window, &w, &h); gdk_window_get_size (gdisp->canvas->window, &w, &h);
switch (guide->orientation) { switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL: case ORIENTATION_HORIZONTAL:
gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE); gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE);
if (x1 < 0) x1 = 0; if (x1 < 0) x1 = 0;
@ -166,6 +173,7 @@ move_draw_guide (GDisplay *gdisp,
gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y);
break; break;
case ORIENTATION_VERTICAL: case ORIENTATION_VERTICAL:
gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE); gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE);
if (y1 < 0) y1 = 0; if (y1 < 0) y1 = 0;
@ -173,6 +181,7 @@ move_draw_guide (GDisplay *gdisp,
gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2); gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2);
break; break;
default: default:
g_warning ("mdg / BAD FALLTHROUGH"); g_warning ("mdg / BAD FALLTHROUGH");
} }
@ -185,9 +194,9 @@ move_tool_button_release (Tool *tool,
{ {
MoveTool *move; MoveTool *move;
GDisplay *gdisp; GDisplay *gdisp;
int delete_guide; gboolean delete_guide;
int x1, y1; gint x1, y1;
int x2, y2; gint x2, y2;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
move = (MoveTool *) tool->private; move = (MoveTool *) tool->private;
@ -203,7 +212,8 @@ move_tool_button_release (Tool *tool,
delete_guide = FALSE; delete_guide = FALSE;
gdisplay_untransform_coords (gdisp, 0, 0, &x1, &y1, FALSE, FALSE); gdisplay_untransform_coords (gdisp, 0, 0, &x1, &y1, FALSE, FALSE);
gdisplay_untransform_coords (gdisp, gdisp->disp_width, gdisp->disp_height, &x2, &y2, FALSE, FALSE); gdisplay_untransform_coords (gdisp, gdisp->disp_width, gdisp->disp_height,
&x2, &y2, FALSE, FALSE);
if (x1 < 0) x1 = 0; if (x1 < 0) x1 = 0;
if (y1 < 0) y1 = 0; if (y1 < 0) y1 = 0;
@ -262,20 +272,20 @@ move_tool_motion (Tool *tool,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
MoveTool *move;
GDisplay *gdisp; GDisplay *gdisp;
MoveTool *private; gint x, y;
int x, y;
gdisp = gdisp_ptr; move = (MoveTool *) tool->private;
private = tool->private; gdisp = (GDisplay *) gdisp_ptr;
if (private->guide) if (move->guide)
{ {
move_draw_guide (gdisp, private->guide); move_draw_guide (gdisp, move->guide);
if (mevent && mevent->window != gdisp->canvas->window) if (mevent && mevent->window != gdisp->canvas->window)
{ {
private->guide->position = -1; move->guide->position = -1;
return; return;
} }
@ -284,12 +294,12 @@ move_tool_motion (Tool *tool,
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&x, &y, TRUE, FALSE); &x, &y, TRUE, FALSE);
if (private->guide->orientation == ORIENTATION_HORIZONTAL) if (move->guide->orientation == ORIENTATION_HORIZONTAL)
private->guide->position = y; move->guide->position = y;
else else
private->guide->position = x; move->guide->position = x;
move_draw_guide (gdisp, private->guide); move_draw_guide (gdisp, move->guide);
} }
} }
} }
@ -303,19 +313,27 @@ move_tool_cursor_update (Tool *tool,
GDisplay *gdisp; GDisplay *gdisp;
Guide *guide; Guide *guide;
Layer *layer; Layer *layer;
int x, y; gint x, y;
move = tool->private; move = (MoveTool *) tool->private;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE);
if (mevent->state & GDK_MOD1_MASK) gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y,
FALSE, FALSE);
if (mevent->state & GDK_MOD1_MASK &&
!gimage_mask_is_empty (gdisp->gimage))
{
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR); gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR);
}
else if (mevent->state & GDK_SHIFT_MASK) else if (mevent->state & GDK_SHIFT_MASK)
{
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR); gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
}
else else
{ {
if (gdisp->draw_guides && (guide = gdisplay_find_guide (gdisp, mevent->x, mevent->y))) if (gdisp->draw_guides &&
(guide = gdisplay_find_guide (gdisp, mevent->x, mevent->y)))
{ {
tool->gdisp_ptr = gdisp_ptr; tool->gdisp_ptr = gdisp_ptr;
gdisplay_install_tool_cursor (gdisp, GDK_HAND2); gdisplay_install_tool_cursor (gdisp, GDK_HAND2);
@ -338,7 +356,8 @@ move_tool_cursor_update (Tool *tool,
else if ((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y))) else if ((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y)))
{ {
/* if there is a floating selection, and this aint it... */ /* if there is a floating selection, and this aint it... */
if (gimage_floating_sel (gdisp->gimage) && !layer_is_floating_sel (layer)) if (gimage_floating_sel (gdisp->gimage) &&
!layer_is_floating_sel (layer))
gdisplay_install_tool_cursor (gdisp, GDK_SB_DOWN_ARROW); gdisplay_install_tool_cursor (gdisp, GDK_SB_DOWN_ARROW);
else if (layer == gdisp->gimage->active_layer) else if (layer == gdisp->gimage->active_layer)
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR); gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
@ -346,9 +365,11 @@ move_tool_cursor_update (Tool *tool,
gdisplay_install_tool_cursor (gdisp, GDK_HAND2); gdisplay_install_tool_cursor (gdisp, GDK_HAND2);
} }
else else
{
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW); gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
} }
} }
}
static void static void
@ -387,19 +408,16 @@ move_create_gc (GDisplay *gdisp)
values.foreground.pixel = gdisplay_white_pixel (gdisp); values.foreground.pixel = gdisplay_white_pixel (gdisp);
values.function = GDK_INVERT; values.function = GDK_INVERT;
move_gc = gdk_gc_new_with_values (gdisp->canvas->window, &values, GDK_GC_FUNCTION); move_gc = gdk_gc_new_with_values (gdisp->canvas->window, &values,
GDK_GC_FUNCTION);
} }
} }
void void
move_tool_start_hguide (Tool *tool, move_tool_start_hguide (Tool *tool,
void *data) GDisplay *gdisp)
{ {
MoveTool *private; MoveTool *private;
GDisplay *gdisp;
gdisp = data;
selection_pause (gdisp->select); selection_pause (gdisp->select);
@ -421,12 +439,9 @@ move_tool_start_hguide (Tool *tool,
void void
move_tool_start_vguide (Tool *tool, move_tool_start_vguide (Tool *tool,
void *data) GDisplay *gdisp)
{ {
MoveTool *private; MoveTool *private;
GDisplay *gdisp;
gdisp = data;
selection_pause (gdisp->select); selection_pause (gdisp->select);
@ -480,7 +495,6 @@ tools_new_move_tool (void)
return tool; return tool;
} }
void void
tools_free_move_tool (Tool *tool) tools_free_move_tool (Tool *tool)
{ {

View File

@ -22,10 +22,13 @@
/* move functions */ /* move functions */
void move_tool_start_hguide (Tool *, void *); void move_tool_start_hguide (Tool *tool,
void move_tool_start_vguide (Tool *, void *); GDisplay *gdisp);
void move_tool_start_vguide (Tool *tool,
GDisplay *gdisp);
Tool * tools_new_move_tool (void); Tool * tools_new_move_tool (void);
void tools_free_move_tool (Tool *); void tools_free_move_tool (Tool *tool);
#endif /* __MOVE_H__ */ #endif /* __MOVE_H__ */

View File

@ -17,6 +17,7 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include "appenv.h" #include "appenv.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "gimage_mask.h" #include "gimage_mask.h"
@ -39,7 +40,15 @@ static SelectionOptions *rect_options = NULL;
/* in gimp, ellipses are rectangular, too ;) */ /* in gimp, ellipses are rectangular, too ;) */
extern SelectionOptions *ellipse_options; extern SelectionOptions *ellipse_options;
extern void ellipse_select (GImage *, int, int, int, int, int, int, int, double); extern void ellipse_select (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
static void selection_tool_update_op_state (RectSelect *rect_sel, static void selection_tool_update_op_state (RectSelect *rect_sel,
gint x, gint x,
@ -52,13 +61,13 @@ static void selection_tool_update_op_state (RectSelect *rect_sel,
void void
rect_select (GimpImage *gimage, rect_select (GimpImage *gimage,
int x, gint x,
int y, gint y,
int w, gint w,
int h, gint h,
int op, SelectOps op,
int feather, gboolean feather,
double feather_radius) gdouble feather_radius)
{ {
Channel *new_mask; Channel *new_mask;
@ -210,7 +219,9 @@ rect_select_button_release (Tool *tool,
{ {
RectSelect *rect_sel; RectSelect *rect_sel;
GDisplay *gdisp; GDisplay *gdisp;
int x1, y1, x2, y2, w, h; gint x1, y1;
gint x2, y2;
gint w, h;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
rect_sel = (RectSelect *) tool->private; rect_sel = (RectSelect *) tool->private;
@ -282,11 +293,11 @@ rect_select_motion (Tool *tool,
RectSelect *rect_sel; RectSelect *rect_sel;
GDisplay *gdisp; GDisplay *gdisp;
gchar size[STATUSBAR_SIZE]; gchar size[STATUSBAR_SIZE];
int ox, oy; gint ox, oy;
int x, y; gint x, y;
int w, h, s; gint w, h, s;
int tw, th; gint tw, th;
double ratio; gdouble ratio;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
rect_sel = (RectSelect *) tool->private; rect_sel = (RectSelect *) tool->private;
@ -443,7 +454,8 @@ rect_select_draw (Tool *tool)
{ {
GDisplay *gdisp; GDisplay *gdisp;
RectSelect *rect_sel; RectSelect *rect_sel;
int x1, y1, x2, y2; gint x1, y1;
gint x2, y2;
gdisp = (GDisplay *) tool->gdisp_ptr; gdisp = (GDisplay *) tool->gdisp_ptr;
rect_sel = (RectSelect *) tool->private; rect_sel = (RectSelect *) tool->private;
@ -468,28 +480,51 @@ selection_tool_update_op_state (RectSelect *rect_sel,
gint state, gint state,
GDisplay *gdisp) GDisplay *gdisp)
{ {
Layer *layer;
Layer *floating_sel;
gint tx, ty;
if (active_tool->state == ACTIVE) if (active_tool->state == ACTIVE)
return; return;
gdisplay_untransform_coords (gdisp, x, y, &tx, &ty, FALSE, FALSE);
layer = gimage_pick_correlate_layer (gdisp->gimage, tx, ty);
floating_sel = gimage_floating_sel (gdisp->gimage);
if (state & GDK_MOD1_MASK && if (state & GDK_MOD1_MASK &&
!(layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage)))) !gimage_mask_is_empty (gdisp->gimage))
{
rect_sel->op = SELECTION_MOVE_MASK; /* move just the selection mask */ rect_sel->op = SELECTION_MOVE_MASK; /* move just the selection mask */
else if (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage)) || }
(!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) && else if (!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
gdisplay_mask_value (gdisp, x, y))) layer &&
(layer == floating_sel ||
(gdisplay_mask_value (gdisp, x, y) &&
!floating_sel)))
{
rect_sel->op = SELECTION_MOVE; /* move the selection */ rect_sel->op = SELECTION_MOVE; /* move the selection */
}
else if ((state & GDK_SHIFT_MASK) && else if ((state & GDK_SHIFT_MASK) &&
!(state & GDK_CONTROL_MASK)) !(state & GDK_CONTROL_MASK))
{
rect_sel->op = SELECTION_ADD; /* add to the selection */ rect_sel->op = SELECTION_ADD; /* add to the selection */
}
else if ((state & GDK_CONTROL_MASK) && else if ((state & GDK_CONTROL_MASK) &&
!(state & GDK_SHIFT_MASK)) !(state & GDK_SHIFT_MASK))
{
rect_sel->op = SELECTION_SUB; /* subtract from the selection */ rect_sel->op = SELECTION_SUB; /* subtract from the selection */
}
else if ((state & GDK_CONTROL_MASK) && else if ((state & GDK_CONTROL_MASK) &&
(state & GDK_SHIFT_MASK)) (state & GDK_SHIFT_MASK))
{
rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */ rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */
}
else else
{
rect_sel->op = SELECTION_REPLACE; /* replace the selection */ rect_sel->op = SELECTION_REPLACE; /* replace the selection */
} }
}
void void
rect_select_oper_update (Tool *tool, rect_select_oper_update (Tool *tool,
@ -548,12 +583,11 @@ rect_select_cursor_update (Tool *tool,
GdkEventMotion *mevent, GdkEventMotion *mevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
int active;
RectSelect *rect_sel; RectSelect *rect_sel;
GDisplay *gdisp; GDisplay *gdisp;
gdisp = (GDisplay *)gdisp_ptr;
active = (active_tool->state == ACTIVE);
rect_sel = (RectSelect *) tool->private; rect_sel = (RectSelect *) tool->private;
gdisp = (GDisplay *) gdisp_ptr;
switch (rect_sel->op) switch (rect_sel->op)
{ {
@ -574,6 +608,7 @@ rect_select_cursor_update (Tool *tool,
break; break;
case SELECTION_MOVE: case SELECTION_MOVE:
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR); gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
break;
} }
} }
@ -606,13 +641,13 @@ rect_select_control (Tool *tool,
} }
static void static void
rect_select_options_reset () rect_select_options_reset (void)
{ {
selection_options_reset (rect_options); selection_options_reset (rect_options);
} }
Tool * Tool *
tools_new_rect_select () tools_new_rect_select (void)
{ {
Tool * tool; Tool * tool;
RectSelect * private; RectSelect * private;

View File

@ -31,11 +31,17 @@ void rect_select_oper_update (Tool *, GdkEventMotion *, gpointer);
void rect_select_control (Tool *, ToolAction, gpointer); void rect_select_control (Tool *, ToolAction, gpointer);
/* rect select functions */ /* rect select functions */
void rect_select_draw (Tool *); void rect_select_draw (Tool *tool);
void rect_select (GimpImage *, int, int, int, int, int, int, void rect_select (GimpImage *gimage,
double); gint x,
gint y,
gint w,
gint g,
SelectOps op,
gboolean feather,
gdouble feather_radius);
Tool * tools_new_rect_select (void); Tool * tools_new_rect_select (void);
void tools_free_rect_select (Tool *); void tools_free_rect_select (Tool *tool);
#endif /* __RECT_SELECT_H__ */ #endif /* __RECT_SELECT_H__ */

View File

@ -20,14 +20,14 @@
#include "toolsF.h" #include "toolsF.h"
typedef struct _bezier_point BezierPoint; typedef struct _BezierPoint BezierPoint;
typedef struct _bezier_select BezierSelect; typedef struct _BezierSelect BezierSelect;
/* bezier select functions */ /* bezier select functions */
void bezier_select_dialog (void);
Tool * tools_new_bezier_select (void); Tool * tools_new_bezier_select (void);
void tools_free_bezier_select (Tool *); void tools_free_bezier_select (Tool *tool);
gboolean bezier_tool_selected (void); gboolean bezier_tool_selected (void);
#endif /* __BEZIER_SELECT_H__ */ #endif /* __BEZIER_SELECT_H__ */

View File

@ -37,11 +37,11 @@
enum { EXTEND_EDIT, EXTEND_ADD, EXTEND_REMOVE, EXTEND_NEW }; enum { EXTEND_EDIT, EXTEND_ADD, EXTEND_REMOVE, EXTEND_NEW };
struct _bezier_point struct _BezierPoint
{ {
int type; /* type of point (anchor/control/move) */ gint type; /* type of point (anchor/control/move) */
double x, y; /* location of point in image space */ gdouble x, y; /* location of point in image space */
int sx, sy; /* location of point in screen space */ gint sx, sy; /* location of point in screen space */
BezierPoint *next; /* next point on curve */ BezierPoint *next; /* next point on curve */
BezierPoint *prev; /* prev point on curve */ BezierPoint *prev; /* prev point on curve */
BezierPoint *next_curve; /* Next curve segment */ BezierPoint *next_curve; /* Next curve segment */
@ -50,17 +50,17 @@ struct _bezier_point
*/ */
}; };
struct _bezier_select struct _BezierSelect
{ {
int state; /* start, add, edit or drag */ gint state; /* start, add, edit or drag */
int draw; /* all or part */ gint draw; /* all or part */
int closed; /* is the last curve closed */ gint closed; /* is the last curve closed */
DrawCore *core; /* Core drawing object */ DrawCore *core; /* Core drawing object */
BezierPoint *points; /* the curve */ BezierPoint *points; /* the curve */
BezierPoint *cur_anchor; /* the current active anchor point */ BezierPoint *cur_anchor; /* the current active anchor point */
BezierPoint *cur_control; /* the current active control point */ BezierPoint *cur_control; /* the current active control point */
BezierPoint *last_point; /* the last point on the curve */ BezierPoint *last_point; /* the last point on the curve */
int num_points; /* number of points in the curve */ gint num_points; /* number of points in the curve */
Channel *mask; /* null if the curve is open */ Channel *mask; /* null if the curve is open */
GSList **scanlines; /* used in converting a curve */ GSList **scanlines; /* used in converting a curve */
}; };
@ -69,25 +69,44 @@ struct _bezier_select
* have this structure as the first element. * have this structure as the first element.
*/ */
typedef struct { typedef struct
{
gint count; gint count;
} CountCurves; } CountCurves;
typedef void (* BezierPointsFunc) (BezierSelect *, GdkPoint *, int,gpointer); typedef void (* BezierPointsFunc) (BezierSelect *, GdkPoint *, int,gpointer);
/* Functions */ /* Functions */
int bezier_select_load (void *, BezierPoint *, int, int); int bezier_select_load (void *,
void bezier_draw_curve (BezierSelect *,BezierPointsFunc, int,gpointer); BezierPoint *,
void bezier_select_reset (BezierSelect *); gint,
gint);
void bezier_draw_curve (BezierSelect *,
BezierPointsFunc,
gint,
gpointer);
void bezier_select_reset (BezierSelect *bezier_sel);
void bezier_select_free (BezierSelect *bezier_sel); void bezier_select_free (BezierSelect *bezier_sel);
void bezier_add_point (BezierSelect *, int, gdouble, gdouble); void bezier_add_point (BezierSelect *,
void bezier_paste_bezierselect_to_current (GDisplay *,BezierSelect *); gint,
gdouble,
gdouble);
void bezier_paste_bezierselect_to_current (GDisplay *gdisp,
BezierSelect *bezier_sel);
void bezier_select_mode (gint); void bezier_select_mode (gint);
void bezier_stroke (BezierSelect *, GDisplay *, int, int); void bezier_stroke (BezierSelect *bezier_sel,
void bezier_to_selection (BezierSelect *, GDisplay *); GDisplay *gdisp,
gint bezier_distance_along (BezierSelect *, gint, gdouble,gint *,gint *,gdouble *); gint,
void bezier_draw (GDisplay *,BezierSelect *); gint);
void bezier_to_selection (BezierSelect *bezier_sel,
GDisplay *gdisp);
gint bezier_distance_along (BezierSelect *bezier_sel,
gint,
gdouble,
gint *,
gint *,
gdouble *);
void bezier_draw (GDisplay *gdisp,
BezierSelect *bezier_sel);
#endif /* __BEZIER_SELECTP_H__ */ #endif /* __BEZIER_SELECTP_H__ */

View File

@ -51,7 +51,7 @@ typedef struct _ByColorSelect ByColorSelect;
struct _ByColorSelect struct _ByColorSelect
{ {
gint x, y; /* Point from which to execute seed fill */ gint x, y; /* Point from which to execute seed fill */
gint operation; /* add, subtract, normal color selection */ SelectOps operation; /* add, subtract, normal color selection */
}; };
typedef struct _ByColorDialog ByColorDialog; typedef struct _ByColorDialog ByColorDialog;
@ -82,8 +82,11 @@ static GtkTargetEntry by_color_select_targets[] =
static guint n_by_color_select_targets = (sizeof (by_color_select_targets) / static guint n_by_color_select_targets = (sizeof (by_color_select_targets) /
sizeof (by_color_select_targets[0])); sizeof (by_color_select_targets[0]));
static void by_color_select_color_drop (GtkWidget *, guchar, guchar, guchar, static void by_color_select_color_drop (GtkWidget *widget,
gpointer); guchar r,
guchar g,
guchar b,
gpointer data);
/* by_color select action functions */ /* by_color select action functions */
@ -101,10 +104,8 @@ static void by_color_select_draw (ByColorDialog *, GImage *);
static gint by_color_select_preview_events (GtkWidget *, static gint by_color_select_preview_events (GtkWidget *,
GdkEventButton *, GdkEventButton *,
ByColorDialog *); ByColorDialog *);
static void by_color_select_type_callback (GtkWidget *, gpointer);
static void by_color_select_reset_callback (GtkWidget *, gpointer); static void by_color_select_reset_callback (GtkWidget *, gpointer);
static void by_color_select_close_callback (GtkWidget *, gpointer); static void by_color_select_close_callback (GtkWidget *, gpointer);
static void by_color_select_fuzzy_update (GtkAdjustment *, gpointer);
static void by_color_select_preview_button_press (ByColorDialog *, static void by_color_select_preview_button_press (ByColorDialog *,
GdkEventButton *); GdkEventButton *);
@ -169,9 +170,9 @@ static Channel *
by_color_select_color (GImage *gimage, by_color_select_color (GImage *gimage,
GimpDrawable *drawable, GimpDrawable *drawable,
guchar *color, guchar *color,
gint antialias, gboolean antialias,
gint threshold, gint threshold,
gint sample_merged) gboolean sample_merged)
{ {
/* Scan over the gimage's active layer, finding pixels within the specified /* Scan over the gimage's active layer, finding pixels within the specified
* threshold from the given R, G, & B values. If antialiasing is on, * threshold from the given R, G, & B values. If antialiasing is on,
@ -279,11 +280,11 @@ by_color_select (GImage *gimage,
GimpDrawable *drawable, GimpDrawable *drawable,
guchar *color, guchar *color,
gint threshold, gint threshold,
gint op, SelectOps op,
gint antialias, gboolean antialias,
gint feather, gboolean feather,
gdouble feather_radius, gdouble feather_radius,
gint sample_merged) gboolean sample_merged)
{ {
Channel *new_mask; Channel *new_mask;
gint off_x, off_y; gint off_x, off_y;
@ -295,7 +296,7 @@ by_color_select (GImage *gimage,
antialias, threshold, sample_merged); antialias, threshold, sample_merged);
/* if applicable, replace the current selection */ /* if applicable, replace the current selection */
if (op == REPLACE) if (op == SELECTION_REPLACE)
gimage_mask_clear (gimage); gimage_mask_clear (gimage);
else else
gimage_mask_undo (gimage); gimage_mask_undo (gimage);
@ -675,7 +676,7 @@ by_color_select_dialog_new (void)
bcd = g_new (ByColorDialog, 1); bcd = g_new (ByColorDialog, 1);
bcd->gimage = NULL; bcd->gimage = NULL;
bcd->operation = REPLACE; bcd->operation = SELECTION_REPLACE;
bcd->threshold = DEFAULT_FUZZINESS; bcd->threshold = DEFAULT_FUZZINESS;
/* The shell and main vbox */ /* The shell and main vbox */
@ -743,16 +744,15 @@ by_color_select_dialog_new (void)
/* Create the selection mode radio box */ /* Create the selection mode radio box */
frame = frame =
gimp_radio_group_new (TRUE, _("Selection Mode"), gimp_radio_group_new2 (TRUE, _("Selection Mode"),
gimp_radio_button_update,
&by_color_dialog->operation,
(gpointer) by_color_dialog->operation,
_("Replace"), by_color_select_type_callback, _("Replace"), (gpointer) SELECTION_REPLACE, NULL,
(gpointer) SELECTION_REPLACE, NULL, NULL, TRUE, _("Add"), (gpointer) SELECTION_ADD, NULL,
_("Add"), by_color_select_type_callback, _("Subtract"), (gpointer) SELECTION_SUB, NULL,
(gpointer) SELECTION_ADD, NULL, NULL, FALSE, _("Intersect"), (gpointer) SELECTION_INTERSECT, NULL,
_("Subtract"), by_color_select_type_callback,
(gpointer) SELECTION_SUB, NULL, NULL, FALSE,
_("Intersect"), by_color_select_type_callback,
(gpointer) SELECTION_INTERSECT, NULL, NULL, FALSE,
NULL); NULL);
@ -776,8 +776,8 @@ by_color_select_dialog_new (void)
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (data), "value_changed", gtk_signal_connect (GTK_OBJECT (data), "value_changed",
GTK_SIGNAL_FUNC (by_color_select_fuzzy_update), GTK_SIGNAL_FUNC (gimp_int_adjustment_update),
bcd); &bcd->threshold);
gtk_widget_show (slider); gtk_widget_show (slider);
@ -936,14 +936,6 @@ by_color_select_preview_events (GtkWidget *widget,
return FALSE; return FALSE;
} }
static void
by_color_select_type_callback (GtkWidget *widget,
gpointer data)
{
if (by_color_dialog)
by_color_dialog->operation = (long) data;
}
static void static void
by_color_select_reset_callback (GtkWidget *widget, by_color_select_reset_callback (GtkWidget *widget,
gpointer data) gpointer data)
@ -987,23 +979,13 @@ by_color_select_close_callback (GtkWidget *widget,
} }
} }
static void
by_color_select_fuzzy_update (GtkAdjustment *adjustment,
gpointer data)
{
ByColorDialog *bcd;
bcd = (ByColorDialog *) data;
bcd->threshold = (gint) (adjustment->value + 0.5);
}
static void static void
by_color_select_preview_button_press (ByColorDialog *bcd, by_color_select_preview_button_press (ByColorDialog *bcd,
GdkEventButton *bevent) GdkEventButton *bevent)
{ {
gint x, y; gint x, y;
gint replace, operation; gboolean replace;
SelectOps operation;
GimpDrawable *drawable; GimpDrawable *drawable;
Tile *tile; Tile *tile;
guchar *col; guchar *col;
@ -1019,7 +1001,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
/* Defaults */ /* Defaults */
replace = FALSE; replace = FALSE;
operation = REPLACE; operation = SELECTION_REPLACE;
/* Based on modifiers, and the "by color" dialog's selection mode */ /* Based on modifiers, and the "by color" dialog's selection mode */
if ((bevent->state & GDK_SHIFT_MASK) && if ((bevent->state & GDK_SHIFT_MASK) &&
@ -1049,7 +1031,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
} }
else else
{ {
int offx, offy; gint offx, offy;
drawable_offsets (drawable, &offx, &offy); drawable_offsets (drawable, &offx, &offy);
x = drawable_width (drawable) * bevent->x / bcd->preview->requisition.width - offx; x = drawable_width (drawable) * bevent->x / bcd->preview->requisition.width - offx;

View File

@ -32,10 +32,10 @@ void by_color_select (GimpImage *gimage,
GimpDrawable *drawable, GimpDrawable *drawable,
guchar *color, guchar *color,
gint threshold, gint threshold,
gint op, SelectOps op,
gint antialias, gboolean antialias,
gint feather, gboolean feather,
gdouble feather_radius, gdouble feather_radius,
gint sample_merged); gboolean sample_merged);
#endif /* __BY_COLOR_SELECT_H__ */ #endif /* __BY_COLOR_SELECT_H__ */

View File

@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "appenv.h" #include "appenv.h"
#include "edit_selection.h" #include "edit_selection.h"
#include "ellipse_select.h" #include "ellipse_select.h"
@ -36,14 +37,14 @@ SelectionOptions * ellipse_options = NULL;
void void
ellipse_select (GimpImage *gimage, ellipse_select (GimpImage *gimage,
int x, gint x,
int y, gint y,
int w, gint w,
int h, gint h,
int op, SelectOps op,
int antialias, gboolean antialias,
int feather, gboolean feather,
double feather_radius) gdouble feather_radius)
{ {
Channel *new_mask; Channel *new_mask;
@ -74,7 +75,8 @@ ellipse_select (GimpImage *gimage,
channel_delete (new_mask); channel_delete (new_mask);
} }
else else
channel_combine_ellipse (gimage_get_mask (gimage), op, x, y, w, h, antialias); channel_combine_ellipse (gimage_get_mask (gimage), op,
x, y, w, h, antialias);
} }
void void
@ -82,7 +84,8 @@ ellipse_select_draw (Tool *tool)
{ {
GDisplay *gdisp; GDisplay *gdisp;
EllipseSelect *ellipse_sel; EllipseSelect *ellipse_sel;
int x1, y1, x2, y2; gint x1, y1;
gint x2, y2;
gdisp = (GDisplay *) tool->gdisp_ptr; gdisp = (GDisplay *) tool->gdisp_ptr;
ellipse_sel = (EllipseSelect *) tool->private; ellipse_sel = (EllipseSelect *) tool->private;

View File

@ -23,11 +23,18 @@
/* ellipse select functions */ /* ellipse select functions */
void ellipse_select_draw (Tool *); void ellipse_select (GimpImage *gimage,
void ellipse_select (GimpImage *, int, int, int, int, int, gint x,
int, int, double); gint y,
gint w,
gint h,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
void ellipse_select_draw (Tool *tool);
Tool * tools_new_ellipse_select (void); Tool * tools_new_ellipse_select (void);
void tools_free_ellipse_select (Tool *); void tools_free_ellipse_select (Tool *tool);
#endif /* __ELLIPSE_SELECT_H__ */ #endif /* __ELLIPSE_SELECT_H__ */

View File

@ -17,6 +17,7 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "appenv.h" #include "appenv.h"
#include "draw_core.h" #include "draw_core.h"
#include "edit_selection.h" #include "edit_selection.h"
@ -41,7 +42,7 @@ struct _FreeSelect
{ {
DrawCore *core; /* Core select object */ DrawCore *core; /* Core select object */
gint op; /* selection operation (ADD, SUB, etc) */ SelectOps op; /* selection operation (ADD, SUB, etc) */
gint current_x; /* these values are updated on every motion event */ gint current_x; /* these values are updated on every motion event */
gint current_y; /* (enables immediate cursor updating on modifier gint current_y; /* (enables immediate cursor updating on modifier
@ -57,15 +58,15 @@ static SelectionOptions * free_options = NULL;
/* The global array of XPoints for drawing the polygon... */ /* The global array of XPoints for drawing the polygon... */
static GdkPoint *global_pts = NULL; static GdkPoint *global_pts = NULL;
static int max_segs = 0; static gint max_segs = 0;
/* functions */ /* functions */
static int static gint
add_point (int num_pts, add_point (gint num_pts,
int x, gint x,
int y) gint y)
{ {
if (num_pts >= max_segs) if (num_pts >= max_segs)
{ {
@ -86,11 +87,11 @@ add_point (int num_pts,
static Channel * static Channel *
scan_convert (GimpImage *gimage, scan_convert (GimpImage *gimage,
int num_pts, gint num_pts,
ScanConvertPoint *pts, ScanConvertPoint *pts,
int width, gint width,
int height, gint height,
int antialias) gboolean antialias)
{ {
Channel *mask; Channel *mask;
ScanConverter *sc; ScanConverter *sc;
@ -110,23 +111,24 @@ scan_convert (GimpImage *gimage,
void void
free_select (GImage *gimage, free_select (GImage *gimage,
int num_pts, gint num_pts,
ScanConvertPoint *pts, ScanConvertPoint *pts,
int op, SelectOps op,
int antialias, gboolean antialias,
int feather, gboolean feather,
double feather_radius) gdouble feather_radius)
{ {
Channel *mask; Channel *mask;
/* if applicable, replace the current selection */ /* if applicable, replace the current selection */
/* or insure that a floating selection is anchored down... */ /* or insure that a floating selection is anchored down... */
if (op == REPLACE) if (op == SELECTION_REPLACE)
gimage_mask_clear (gimage); gimage_mask_clear (gimage);
else else
gimage_mask_undo (gimage); gimage_mask_undo (gimage);
mask = scan_convert (gimage, num_pts, pts, gimage->width, gimage->height, antialias); mask = scan_convert (gimage, num_pts, pts,
gimage->width, gimage->height, antialias);
if (mask) if (mask)
{ {
@ -188,7 +190,7 @@ free_select_button_release (Tool *tool,
FreeSelect *free_sel; FreeSelect *free_sel;
ScanConvertPoint *pts; ScanConvertPoint *pts;
GDisplay *gdisp; GDisplay *gdisp;
int i; gint i;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
free_sel = (FreeSelect *) tool->private; free_sel = (FreeSelect *) tool->private;
@ -203,7 +205,7 @@ free_select_button_release (Tool *tool,
/* First take care of the case where the user "cancels" the action */ /* First take care of the case where the user "cancels" the action */
if (! (bevent->state & GDK_BUTTON3_MASK)) if (! (bevent->state & GDK_BUTTON3_MASK))
{ {
pts = (ScanConvertPoint *) g_malloc (sizeof (ScanConvertPoint) * free_sel->num_pts); pts = g_new (ScanConvertPoint, free_sel->num_pts);
for (i = 0; i < free_sel->num_pts; i++) for (i = 0; i < free_sel->num_pts; i++)
{ {
@ -283,7 +285,7 @@ void
free_select_draw (Tool *tool) free_select_draw (Tool *tool)
{ {
FreeSelect *free_sel; FreeSelect *free_sel;
int i; gint i;
free_sel = (FreeSelect *) tool->private; free_sel = (FreeSelect *) tool->private;
@ -294,7 +296,7 @@ free_select_draw (Tool *tool)
} }
static void static void
free_select_options_reset () free_select_options_reset (void)
{ {
selection_options_reset (free_options); selection_options_reset (free_options);
} }

View File

@ -21,9 +21,6 @@
#include "gimpimageF.h" #include "gimpimageF.h"
#include "scan_convert.h" #include "scan_convert.h"
void free_select (GimpImage *, int, ScanConvertPoint *, int, int, int,
double);
/* free select action functions */ /* free select action functions */
void free_select_button_press (Tool *, GdkEventButton *, gpointer); void free_select_button_press (Tool *, GdkEventButton *, gpointer);
@ -33,9 +30,16 @@ void free_select_motion (Tool *, GdkEventMotion *, gpointer)
/* free select functions */ /* free select functions */
void free_select_dialog (void); void free_select (GimpImage *gimage,
void free_select_draw (Tool *); gint num_pts,
ScanConvertPoint *pts,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
void free_select_draw (Tool *tool);
Tool * tools_new_free_select (void); Tool * tools_new_free_select (void);
void tools_free_free_select (Tool *); void tools_free_free_select (Tool *tool);
#endif /* __FREE_SELECT_H__ */ #endif /* __FREE_SELECT_H__ */

View File

@ -51,7 +51,7 @@ typedef struct _ByColorSelect ByColorSelect;
struct _ByColorSelect struct _ByColorSelect
{ {
gint x, y; /* Point from which to execute seed fill */ gint x, y; /* Point from which to execute seed fill */
gint operation; /* add, subtract, normal color selection */ SelectOps operation; /* add, subtract, normal color selection */
}; };
typedef struct _ByColorDialog ByColorDialog; typedef struct _ByColorDialog ByColorDialog;
@ -82,8 +82,11 @@ static GtkTargetEntry by_color_select_targets[] =
static guint n_by_color_select_targets = (sizeof (by_color_select_targets) / static guint n_by_color_select_targets = (sizeof (by_color_select_targets) /
sizeof (by_color_select_targets[0])); sizeof (by_color_select_targets[0]));
static void by_color_select_color_drop (GtkWidget *, guchar, guchar, guchar, static void by_color_select_color_drop (GtkWidget *widget,
gpointer); guchar r,
guchar g,
guchar b,
gpointer data);
/* by_color select action functions */ /* by_color select action functions */
@ -101,10 +104,8 @@ static void by_color_select_draw (ByColorDialog *, GImage *);
static gint by_color_select_preview_events (GtkWidget *, static gint by_color_select_preview_events (GtkWidget *,
GdkEventButton *, GdkEventButton *,
ByColorDialog *); ByColorDialog *);
static void by_color_select_type_callback (GtkWidget *, gpointer);
static void by_color_select_reset_callback (GtkWidget *, gpointer); static void by_color_select_reset_callback (GtkWidget *, gpointer);
static void by_color_select_close_callback (GtkWidget *, gpointer); static void by_color_select_close_callback (GtkWidget *, gpointer);
static void by_color_select_fuzzy_update (GtkAdjustment *, gpointer);
static void by_color_select_preview_button_press (ByColorDialog *, static void by_color_select_preview_button_press (ByColorDialog *,
GdkEventButton *); GdkEventButton *);
@ -169,9 +170,9 @@ static Channel *
by_color_select_color (GImage *gimage, by_color_select_color (GImage *gimage,
GimpDrawable *drawable, GimpDrawable *drawable,
guchar *color, guchar *color,
gint antialias, gboolean antialias,
gint threshold, gint threshold,
gint sample_merged) gboolean sample_merged)
{ {
/* Scan over the gimage's active layer, finding pixels within the specified /* Scan over the gimage's active layer, finding pixels within the specified
* threshold from the given R, G, & B values. If antialiasing is on, * threshold from the given R, G, & B values. If antialiasing is on,
@ -279,11 +280,11 @@ by_color_select (GImage *gimage,
GimpDrawable *drawable, GimpDrawable *drawable,
guchar *color, guchar *color,
gint threshold, gint threshold,
gint op, SelectOps op,
gint antialias, gboolean antialias,
gint feather, gboolean feather,
gdouble feather_radius, gdouble feather_radius,
gint sample_merged) gboolean sample_merged)
{ {
Channel *new_mask; Channel *new_mask;
gint off_x, off_y; gint off_x, off_y;
@ -295,7 +296,7 @@ by_color_select (GImage *gimage,
antialias, threshold, sample_merged); antialias, threshold, sample_merged);
/* if applicable, replace the current selection */ /* if applicable, replace the current selection */
if (op == REPLACE) if (op == SELECTION_REPLACE)
gimage_mask_clear (gimage); gimage_mask_clear (gimage);
else else
gimage_mask_undo (gimage); gimage_mask_undo (gimage);
@ -675,7 +676,7 @@ by_color_select_dialog_new (void)
bcd = g_new (ByColorDialog, 1); bcd = g_new (ByColorDialog, 1);
bcd->gimage = NULL; bcd->gimage = NULL;
bcd->operation = REPLACE; bcd->operation = SELECTION_REPLACE;
bcd->threshold = DEFAULT_FUZZINESS; bcd->threshold = DEFAULT_FUZZINESS;
/* The shell and main vbox */ /* The shell and main vbox */
@ -743,16 +744,15 @@ by_color_select_dialog_new (void)
/* Create the selection mode radio box */ /* Create the selection mode radio box */
frame = frame =
gimp_radio_group_new (TRUE, _("Selection Mode"), gimp_radio_group_new2 (TRUE, _("Selection Mode"),
gimp_radio_button_update,
&by_color_dialog->operation,
(gpointer) by_color_dialog->operation,
_("Replace"), by_color_select_type_callback, _("Replace"), (gpointer) SELECTION_REPLACE, NULL,
(gpointer) SELECTION_REPLACE, NULL, NULL, TRUE, _("Add"), (gpointer) SELECTION_ADD, NULL,
_("Add"), by_color_select_type_callback, _("Subtract"), (gpointer) SELECTION_SUB, NULL,
(gpointer) SELECTION_ADD, NULL, NULL, FALSE, _("Intersect"), (gpointer) SELECTION_INTERSECT, NULL,
_("Subtract"), by_color_select_type_callback,
(gpointer) SELECTION_SUB, NULL, NULL, FALSE,
_("Intersect"), by_color_select_type_callback,
(gpointer) SELECTION_INTERSECT, NULL, NULL, FALSE,
NULL); NULL);
@ -776,8 +776,8 @@ by_color_select_dialog_new (void)
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED); gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (data), "value_changed", gtk_signal_connect (GTK_OBJECT (data), "value_changed",
GTK_SIGNAL_FUNC (by_color_select_fuzzy_update), GTK_SIGNAL_FUNC (gimp_int_adjustment_update),
bcd); &bcd->threshold);
gtk_widget_show (slider); gtk_widget_show (slider);
@ -936,14 +936,6 @@ by_color_select_preview_events (GtkWidget *widget,
return FALSE; return FALSE;
} }
static void
by_color_select_type_callback (GtkWidget *widget,
gpointer data)
{
if (by_color_dialog)
by_color_dialog->operation = (long) data;
}
static void static void
by_color_select_reset_callback (GtkWidget *widget, by_color_select_reset_callback (GtkWidget *widget,
gpointer data) gpointer data)
@ -987,23 +979,13 @@ by_color_select_close_callback (GtkWidget *widget,
} }
} }
static void
by_color_select_fuzzy_update (GtkAdjustment *adjustment,
gpointer data)
{
ByColorDialog *bcd;
bcd = (ByColorDialog *) data;
bcd->threshold = (gint) (adjustment->value + 0.5);
}
static void static void
by_color_select_preview_button_press (ByColorDialog *bcd, by_color_select_preview_button_press (ByColorDialog *bcd,
GdkEventButton *bevent) GdkEventButton *bevent)
{ {
gint x, y; gint x, y;
gint replace, operation; gboolean replace;
SelectOps operation;
GimpDrawable *drawable; GimpDrawable *drawable;
Tile *tile; Tile *tile;
guchar *col; guchar *col;
@ -1019,7 +1001,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
/* Defaults */ /* Defaults */
replace = FALSE; replace = FALSE;
operation = REPLACE; operation = SELECTION_REPLACE;
/* Based on modifiers, and the "by color" dialog's selection mode */ /* Based on modifiers, and the "by color" dialog's selection mode */
if ((bevent->state & GDK_SHIFT_MASK) && if ((bevent->state & GDK_SHIFT_MASK) &&
@ -1049,7 +1031,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
} }
else else
{ {
int offx, offy; gint offx, offy;
drawable_offsets (drawable, &offx, &offy); drawable_offsets (drawable, &offx, &offy);
x = drawable_width (drawable) * bevent->x / bcd->preview->requisition.width - offx; x = drawable_width (drawable) * bevent->x / bcd->preview->requisition.width - offx;

View File

@ -32,10 +32,10 @@ void by_color_select (GimpImage *gimage,
GimpDrawable *drawable, GimpDrawable *drawable,
guchar *color, guchar *color,
gint threshold, gint threshold,
gint op, SelectOps op,
gint antialias, gboolean antialias,
gint feather, gboolean feather,
gdouble feather_radius, gdouble feather_radius,
gint sample_merged); gboolean sample_merged);
#endif /* __BY_COLOR_SELECT_H__ */ #endif /* __BY_COLOR_SELECT_H__ */

View File

@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "appenv.h" #include "appenv.h"
#include "edit_selection.h" #include "edit_selection.h"
#include "ellipse_select.h" #include "ellipse_select.h"
@ -36,14 +37,14 @@ SelectionOptions * ellipse_options = NULL;
void void
ellipse_select (GimpImage *gimage, ellipse_select (GimpImage *gimage,
int x, gint x,
int y, gint y,
int w, gint w,
int h, gint h,
int op, SelectOps op,
int antialias, gboolean antialias,
int feather, gboolean feather,
double feather_radius) gdouble feather_radius)
{ {
Channel *new_mask; Channel *new_mask;
@ -74,7 +75,8 @@ ellipse_select (GimpImage *gimage,
channel_delete (new_mask); channel_delete (new_mask);
} }
else else
channel_combine_ellipse (gimage_get_mask (gimage), op, x, y, w, h, antialias); channel_combine_ellipse (gimage_get_mask (gimage), op,
x, y, w, h, antialias);
} }
void void
@ -82,7 +84,8 @@ ellipse_select_draw (Tool *tool)
{ {
GDisplay *gdisp; GDisplay *gdisp;
EllipseSelect *ellipse_sel; EllipseSelect *ellipse_sel;
int x1, y1, x2, y2; gint x1, y1;
gint x2, y2;
gdisp = (GDisplay *) tool->gdisp_ptr; gdisp = (GDisplay *) tool->gdisp_ptr;
ellipse_sel = (EllipseSelect *) tool->private; ellipse_sel = (EllipseSelect *) tool->private;

View File

@ -23,11 +23,18 @@
/* ellipse select functions */ /* ellipse select functions */
void ellipse_select_draw (Tool *); void ellipse_select (GimpImage *gimage,
void ellipse_select (GimpImage *, int, int, int, int, int, gint x,
int, int, double); gint y,
gint w,
gint h,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
void ellipse_select_draw (Tool *tool);
Tool * tools_new_ellipse_select (void); Tool * tools_new_ellipse_select (void);
void tools_free_ellipse_select (Tool *); void tools_free_ellipse_select (Tool *tool);
#endif /* __ELLIPSE_SELECT_H__ */ #endif /* __ELLIPSE_SELECT_H__ */

View File

@ -17,6 +17,7 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "appenv.h" #include "appenv.h"
#include "draw_core.h" #include "draw_core.h"
#include "edit_selection.h" #include "edit_selection.h"
@ -41,7 +42,7 @@ struct _FreeSelect
{ {
DrawCore *core; /* Core select object */ DrawCore *core; /* Core select object */
gint op; /* selection operation (ADD, SUB, etc) */ SelectOps op; /* selection operation (ADD, SUB, etc) */
gint current_x; /* these values are updated on every motion event */ gint current_x; /* these values are updated on every motion event */
gint current_y; /* (enables immediate cursor updating on modifier gint current_y; /* (enables immediate cursor updating on modifier
@ -57,15 +58,15 @@ static SelectionOptions * free_options = NULL;
/* The global array of XPoints for drawing the polygon... */ /* The global array of XPoints for drawing the polygon... */
static GdkPoint *global_pts = NULL; static GdkPoint *global_pts = NULL;
static int max_segs = 0; static gint max_segs = 0;
/* functions */ /* functions */
static int static gint
add_point (int num_pts, add_point (gint num_pts,
int x, gint x,
int y) gint y)
{ {
if (num_pts >= max_segs) if (num_pts >= max_segs)
{ {
@ -86,11 +87,11 @@ add_point (int num_pts,
static Channel * static Channel *
scan_convert (GimpImage *gimage, scan_convert (GimpImage *gimage,
int num_pts, gint num_pts,
ScanConvertPoint *pts, ScanConvertPoint *pts,
int width, gint width,
int height, gint height,
int antialias) gboolean antialias)
{ {
Channel *mask; Channel *mask;
ScanConverter *sc; ScanConverter *sc;
@ -110,23 +111,24 @@ scan_convert (GimpImage *gimage,
void void
free_select (GImage *gimage, free_select (GImage *gimage,
int num_pts, gint num_pts,
ScanConvertPoint *pts, ScanConvertPoint *pts,
int op, SelectOps op,
int antialias, gboolean antialias,
int feather, gboolean feather,
double feather_radius) gdouble feather_radius)
{ {
Channel *mask; Channel *mask;
/* if applicable, replace the current selection */ /* if applicable, replace the current selection */
/* or insure that a floating selection is anchored down... */ /* or insure that a floating selection is anchored down... */
if (op == REPLACE) if (op == SELECTION_REPLACE)
gimage_mask_clear (gimage); gimage_mask_clear (gimage);
else else
gimage_mask_undo (gimage); gimage_mask_undo (gimage);
mask = scan_convert (gimage, num_pts, pts, gimage->width, gimage->height, antialias); mask = scan_convert (gimage, num_pts, pts,
gimage->width, gimage->height, antialias);
if (mask) if (mask)
{ {
@ -188,7 +190,7 @@ free_select_button_release (Tool *tool,
FreeSelect *free_sel; FreeSelect *free_sel;
ScanConvertPoint *pts; ScanConvertPoint *pts;
GDisplay *gdisp; GDisplay *gdisp;
int i; gint i;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
free_sel = (FreeSelect *) tool->private; free_sel = (FreeSelect *) tool->private;
@ -203,7 +205,7 @@ free_select_button_release (Tool *tool,
/* First take care of the case where the user "cancels" the action */ /* First take care of the case where the user "cancels" the action */
if (! (bevent->state & GDK_BUTTON3_MASK)) if (! (bevent->state & GDK_BUTTON3_MASK))
{ {
pts = (ScanConvertPoint *) g_malloc (sizeof (ScanConvertPoint) * free_sel->num_pts); pts = g_new (ScanConvertPoint, free_sel->num_pts);
for (i = 0; i < free_sel->num_pts; i++) for (i = 0; i < free_sel->num_pts; i++)
{ {
@ -283,7 +285,7 @@ void
free_select_draw (Tool *tool) free_select_draw (Tool *tool)
{ {
FreeSelect *free_sel; FreeSelect *free_sel;
int i; gint i;
free_sel = (FreeSelect *) tool->private; free_sel = (FreeSelect *) tool->private;
@ -294,7 +296,7 @@ free_select_draw (Tool *tool)
} }
static void static void
free_select_options_reset () free_select_options_reset (void)
{ {
selection_options_reset (free_options); selection_options_reset (free_options);
} }

View File

@ -21,9 +21,6 @@
#include "gimpimageF.h" #include "gimpimageF.h"
#include "scan_convert.h" #include "scan_convert.h"
void free_select (GimpImage *, int, ScanConvertPoint *, int, int, int,
double);
/* free select action functions */ /* free select action functions */
void free_select_button_press (Tool *, GdkEventButton *, gpointer); void free_select_button_press (Tool *, GdkEventButton *, gpointer);
@ -33,9 +30,16 @@ void free_select_motion (Tool *, GdkEventMotion *, gpointer)
/* free select functions */ /* free select functions */
void free_select_dialog (void); void free_select (GimpImage *gimage,
void free_select_draw (Tool *); gint num_pts,
ScanConvertPoint *pts,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
void free_select_draw (Tool *tool);
Tool * tools_new_free_select (void); Tool * tools_new_free_select (void);
void tools_free_free_select (Tool *); void tools_free_free_select (Tool *tool);
#endif /* __FREE_SELECT_H__ */ #endif /* __FREE_SELECT_H__ */

View File

@ -21,7 +21,6 @@
#include "cursorutil.h" #include "cursorutil.h"
#include "draw_core.h" #include "draw_core.h"
#include "edit_selection.h" #include "edit_selection.h"
#include "errors.h"
#include "floating_sel.h" #include "floating_sel.h"
#include "gimage_mask.h" #include "gimage_mask.h"
#include "gdisplay.h" #include "gdisplay.h"
@ -57,7 +56,7 @@ static void move_tool_motion (Tool *, GdkEventMotion *, gpointer);
static void move_tool_cursor_update (Tool *, GdkEventMotion *, gpointer); static void move_tool_cursor_update (Tool *, GdkEventMotion *, gpointer);
static void move_tool_control (Tool *, ToolAction, gpointer); static void move_tool_control (Tool *, ToolAction, gpointer);
static void move_create_gc (GDisplay *); static void move_create_gc (GDisplay *gdisp);
/* move action functions */ /* move action functions */
@ -71,7 +70,7 @@ move_tool_button_press (Tool *tool,
MoveTool *move; MoveTool *move;
Layer *layer; Layer *layer;
Guide *guide; Guide *guide;
int x, y; gint x, y;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
move = (MoveTool *) tool->private; move = (MoveTool *) tool->private;
@ -83,7 +82,8 @@ move_tool_button_press (Tool *tool,
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE); gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE);
if (bevent->state & GDK_MOD1_MASK) if (bevent->state & GDK_MOD1_MASK &&
!gimage_mask_is_empty (gdisp->gimage))
{ {
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate); init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
tool->state = ACTIVE; tool->state = ACTIVE;
@ -95,7 +95,8 @@ move_tool_button_press (Tool *tool,
} }
else else
{ {
if (gdisp->draw_guides && (guide = gdisplay_find_guide (gdisp, bevent->x, bevent->y))) if (gdisp->draw_guides &&
(guide = gdisplay_find_guide (gdisp, bevent->x, bevent->y)))
{ {
undo_push_guide (gdisp->gimage, guide); undo_push_guide (gdisp->gimage, guide);
@ -114,9 +115,14 @@ move_tool_button_press (Tool *tool,
} }
else if ((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y))) else if ((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y)))
{ {
/* If there is a floating selection, and this aint it, use the move tool */ /* If there is a floating selection, and this aint it,
if (gimage_floating_sel (gdisp->gimage) && !layer_is_floating_sel (layer)) * use the move tool
*/
if (gimage_floating_sel (gdisp->gimage) &&
!layer_is_floating_sel (layer))
{
move->layer = gimage_floating_sel (gdisp->gimage); move->layer = gimage_floating_sel (gdisp->gimage);
}
/* Otherwise, init the edit selection */ /* Otherwise, init the edit selection */
else else
{ {
@ -131,21 +137,21 @@ move_tool_button_press (Tool *tool,
if (tool->state == ACTIVE) if (tool->state == ACTIVE)
{ {
gdk_pointer_grab (gdisp->canvas->window, FALSE, gdk_pointer_grab (gdisp->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK, GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time); NULL, NULL, bevent->time);
} }
} }
static void static void
move_draw_guide (GDisplay *gdisp, move_draw_guide (GDisplay *gdisp,
Guide *guide) Guide *guide)
{ {
int x1, y1; gint x1, y1;
int x2, y2; gint x2, y2;
int w, h; gint w, h;
int x, y; gint x, y;
if (!move_gc) if (!move_gc)
move_create_gc (gdisp); move_create_gc (gdisp);
@ -158,7 +164,8 @@ move_draw_guide (GDisplay *gdisp,
gdk_window_get_size (gdisp->canvas->window, &w, &h); gdk_window_get_size (gdisp->canvas->window, &w, &h);
switch (guide->orientation) { switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL: case ORIENTATION_HORIZONTAL:
gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE); gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE);
if (x1 < 0) x1 = 0; if (x1 < 0) x1 = 0;
@ -166,6 +173,7 @@ move_draw_guide (GDisplay *gdisp,
gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y);
break; break;
case ORIENTATION_VERTICAL: case ORIENTATION_VERTICAL:
gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE); gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE);
if (y1 < 0) y1 = 0; if (y1 < 0) y1 = 0;
@ -173,6 +181,7 @@ move_draw_guide (GDisplay *gdisp,
gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2); gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2);
break; break;
default: default:
g_warning ("mdg / BAD FALLTHROUGH"); g_warning ("mdg / BAD FALLTHROUGH");
} }
@ -185,9 +194,9 @@ move_tool_button_release (Tool *tool,
{ {
MoveTool *move; MoveTool *move;
GDisplay *gdisp; GDisplay *gdisp;
int delete_guide; gboolean delete_guide;
int x1, y1; gint x1, y1;
int x2, y2; gint x2, y2;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
move = (MoveTool *) tool->private; move = (MoveTool *) tool->private;
@ -203,7 +212,8 @@ move_tool_button_release (Tool *tool,
delete_guide = FALSE; delete_guide = FALSE;
gdisplay_untransform_coords (gdisp, 0, 0, &x1, &y1, FALSE, FALSE); gdisplay_untransform_coords (gdisp, 0, 0, &x1, &y1, FALSE, FALSE);
gdisplay_untransform_coords (gdisp, gdisp->disp_width, gdisp->disp_height, &x2, &y2, FALSE, FALSE); gdisplay_untransform_coords (gdisp, gdisp->disp_width, gdisp->disp_height,
&x2, &y2, FALSE, FALSE);
if (x1 < 0) x1 = 0; if (x1 < 0) x1 = 0;
if (y1 < 0) y1 = 0; if (y1 < 0) y1 = 0;
@ -262,20 +272,20 @@ move_tool_motion (Tool *tool,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
MoveTool *move;
GDisplay *gdisp; GDisplay *gdisp;
MoveTool *private; gint x, y;
int x, y;
gdisp = gdisp_ptr; move = (MoveTool *) tool->private;
private = tool->private; gdisp = (GDisplay *) gdisp_ptr;
if (private->guide) if (move->guide)
{ {
move_draw_guide (gdisp, private->guide); move_draw_guide (gdisp, move->guide);
if (mevent && mevent->window != gdisp->canvas->window) if (mevent && mevent->window != gdisp->canvas->window)
{ {
private->guide->position = -1; move->guide->position = -1;
return; return;
} }
@ -284,12 +294,12 @@ move_tool_motion (Tool *tool,
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&x, &y, TRUE, FALSE); &x, &y, TRUE, FALSE);
if (private->guide->orientation == ORIENTATION_HORIZONTAL) if (move->guide->orientation == ORIENTATION_HORIZONTAL)
private->guide->position = y; move->guide->position = y;
else else
private->guide->position = x; move->guide->position = x;
move_draw_guide (gdisp, private->guide); move_draw_guide (gdisp, move->guide);
} }
} }
} }
@ -303,19 +313,27 @@ move_tool_cursor_update (Tool *tool,
GDisplay *gdisp; GDisplay *gdisp;
Guide *guide; Guide *guide;
Layer *layer; Layer *layer;
int x, y; gint x, y;
move = tool->private; move = (MoveTool *) tool->private;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE);
if (mevent->state & GDK_MOD1_MASK) gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y,
FALSE, FALSE);
if (mevent->state & GDK_MOD1_MASK &&
!gimage_mask_is_empty (gdisp->gimage))
{
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR); gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR);
}
else if (mevent->state & GDK_SHIFT_MASK) else if (mevent->state & GDK_SHIFT_MASK)
{
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR); gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
}
else else
{ {
if (gdisp->draw_guides && (guide = gdisplay_find_guide (gdisp, mevent->x, mevent->y))) if (gdisp->draw_guides &&
(guide = gdisplay_find_guide (gdisp, mevent->x, mevent->y)))
{ {
tool->gdisp_ptr = gdisp_ptr; tool->gdisp_ptr = gdisp_ptr;
gdisplay_install_tool_cursor (gdisp, GDK_HAND2); gdisplay_install_tool_cursor (gdisp, GDK_HAND2);
@ -338,7 +356,8 @@ move_tool_cursor_update (Tool *tool,
else if ((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y))) else if ((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y)))
{ {
/* if there is a floating selection, and this aint it... */ /* if there is a floating selection, and this aint it... */
if (gimage_floating_sel (gdisp->gimage) && !layer_is_floating_sel (layer)) if (gimage_floating_sel (gdisp->gimage) &&
!layer_is_floating_sel (layer))
gdisplay_install_tool_cursor (gdisp, GDK_SB_DOWN_ARROW); gdisplay_install_tool_cursor (gdisp, GDK_SB_DOWN_ARROW);
else if (layer == gdisp->gimage->active_layer) else if (layer == gdisp->gimage->active_layer)
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR); gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
@ -346,9 +365,11 @@ move_tool_cursor_update (Tool *tool,
gdisplay_install_tool_cursor (gdisp, GDK_HAND2); gdisplay_install_tool_cursor (gdisp, GDK_HAND2);
} }
else else
{
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW); gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
} }
} }
}
static void static void
@ -387,19 +408,16 @@ move_create_gc (GDisplay *gdisp)
values.foreground.pixel = gdisplay_white_pixel (gdisp); values.foreground.pixel = gdisplay_white_pixel (gdisp);
values.function = GDK_INVERT; values.function = GDK_INVERT;
move_gc = gdk_gc_new_with_values (gdisp->canvas->window, &values, GDK_GC_FUNCTION); move_gc = gdk_gc_new_with_values (gdisp->canvas->window, &values,
GDK_GC_FUNCTION);
} }
} }
void void
move_tool_start_hguide (Tool *tool, move_tool_start_hguide (Tool *tool,
void *data) GDisplay *gdisp)
{ {
MoveTool *private; MoveTool *private;
GDisplay *gdisp;
gdisp = data;
selection_pause (gdisp->select); selection_pause (gdisp->select);
@ -421,12 +439,9 @@ move_tool_start_hguide (Tool *tool,
void void
move_tool_start_vguide (Tool *tool, move_tool_start_vguide (Tool *tool,
void *data) GDisplay *gdisp)
{ {
MoveTool *private; MoveTool *private;
GDisplay *gdisp;
gdisp = data;
selection_pause (gdisp->select); selection_pause (gdisp->select);
@ -480,7 +495,6 @@ tools_new_move_tool (void)
return tool; return tool;
} }
void void
tools_free_move_tool (Tool *tool) tools_free_move_tool (Tool *tool)
{ {

View File

@ -22,10 +22,13 @@
/* move functions */ /* move functions */
void move_tool_start_hguide (Tool *, void *); void move_tool_start_hguide (Tool *tool,
void move_tool_start_vguide (Tool *, void *); GDisplay *gdisp);
void move_tool_start_vguide (Tool *tool,
GDisplay *gdisp);
Tool * tools_new_move_tool (void); Tool * tools_new_move_tool (void);
void tools_free_move_tool (Tool *); void tools_free_move_tool (Tool *tool);
#endif /* __MOVE_H__ */ #endif /* __MOVE_H__ */

View File

@ -17,6 +17,7 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include "appenv.h" #include "appenv.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "gimage_mask.h" #include "gimage_mask.h"
@ -39,7 +40,15 @@ static SelectionOptions *rect_options = NULL;
/* in gimp, ellipses are rectangular, too ;) */ /* in gimp, ellipses are rectangular, too ;) */
extern SelectionOptions *ellipse_options; extern SelectionOptions *ellipse_options;
extern void ellipse_select (GImage *, int, int, int, int, int, int, int, double); extern void ellipse_select (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
static void selection_tool_update_op_state (RectSelect *rect_sel, static void selection_tool_update_op_state (RectSelect *rect_sel,
gint x, gint x,
@ -52,13 +61,13 @@ static void selection_tool_update_op_state (RectSelect *rect_sel,
void void
rect_select (GimpImage *gimage, rect_select (GimpImage *gimage,
int x, gint x,
int y, gint y,
int w, gint w,
int h, gint h,
int op, SelectOps op,
int feather, gboolean feather,
double feather_radius) gdouble feather_radius)
{ {
Channel *new_mask; Channel *new_mask;
@ -210,7 +219,9 @@ rect_select_button_release (Tool *tool,
{ {
RectSelect *rect_sel; RectSelect *rect_sel;
GDisplay *gdisp; GDisplay *gdisp;
int x1, y1, x2, y2, w, h; gint x1, y1;
gint x2, y2;
gint w, h;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
rect_sel = (RectSelect *) tool->private; rect_sel = (RectSelect *) tool->private;
@ -282,11 +293,11 @@ rect_select_motion (Tool *tool,
RectSelect *rect_sel; RectSelect *rect_sel;
GDisplay *gdisp; GDisplay *gdisp;
gchar size[STATUSBAR_SIZE]; gchar size[STATUSBAR_SIZE];
int ox, oy; gint ox, oy;
int x, y; gint x, y;
int w, h, s; gint w, h, s;
int tw, th; gint tw, th;
double ratio; gdouble ratio;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
rect_sel = (RectSelect *) tool->private; rect_sel = (RectSelect *) tool->private;
@ -443,7 +454,8 @@ rect_select_draw (Tool *tool)
{ {
GDisplay *gdisp; GDisplay *gdisp;
RectSelect *rect_sel; RectSelect *rect_sel;
int x1, y1, x2, y2; gint x1, y1;
gint x2, y2;
gdisp = (GDisplay *) tool->gdisp_ptr; gdisp = (GDisplay *) tool->gdisp_ptr;
rect_sel = (RectSelect *) tool->private; rect_sel = (RectSelect *) tool->private;
@ -468,28 +480,51 @@ selection_tool_update_op_state (RectSelect *rect_sel,
gint state, gint state,
GDisplay *gdisp) GDisplay *gdisp)
{ {
Layer *layer;
Layer *floating_sel;
gint tx, ty;
if (active_tool->state == ACTIVE) if (active_tool->state == ACTIVE)
return; return;
gdisplay_untransform_coords (gdisp, x, y, &tx, &ty, FALSE, FALSE);
layer = gimage_pick_correlate_layer (gdisp->gimage, tx, ty);
floating_sel = gimage_floating_sel (gdisp->gimage);
if (state & GDK_MOD1_MASK && if (state & GDK_MOD1_MASK &&
!(layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage)))) !gimage_mask_is_empty (gdisp->gimage))
{
rect_sel->op = SELECTION_MOVE_MASK; /* move just the selection mask */ rect_sel->op = SELECTION_MOVE_MASK; /* move just the selection mask */
else if (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage)) || }
(!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) && else if (!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
gdisplay_mask_value (gdisp, x, y))) layer &&
(layer == floating_sel ||
(gdisplay_mask_value (gdisp, x, y) &&
!floating_sel)))
{
rect_sel->op = SELECTION_MOVE; /* move the selection */ rect_sel->op = SELECTION_MOVE; /* move the selection */
}
else if ((state & GDK_SHIFT_MASK) && else if ((state & GDK_SHIFT_MASK) &&
!(state & GDK_CONTROL_MASK)) !(state & GDK_CONTROL_MASK))
{
rect_sel->op = SELECTION_ADD; /* add to the selection */ rect_sel->op = SELECTION_ADD; /* add to the selection */
}
else if ((state & GDK_CONTROL_MASK) && else if ((state & GDK_CONTROL_MASK) &&
!(state & GDK_SHIFT_MASK)) !(state & GDK_SHIFT_MASK))
{
rect_sel->op = SELECTION_SUB; /* subtract from the selection */ rect_sel->op = SELECTION_SUB; /* subtract from the selection */
}
else if ((state & GDK_CONTROL_MASK) && else if ((state & GDK_CONTROL_MASK) &&
(state & GDK_SHIFT_MASK)) (state & GDK_SHIFT_MASK))
{
rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */ rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */
}
else else
{
rect_sel->op = SELECTION_REPLACE; /* replace the selection */ rect_sel->op = SELECTION_REPLACE; /* replace the selection */
} }
}
void void
rect_select_oper_update (Tool *tool, rect_select_oper_update (Tool *tool,
@ -548,12 +583,11 @@ rect_select_cursor_update (Tool *tool,
GdkEventMotion *mevent, GdkEventMotion *mevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
int active;
RectSelect *rect_sel; RectSelect *rect_sel;
GDisplay *gdisp; GDisplay *gdisp;
gdisp = (GDisplay *)gdisp_ptr;
active = (active_tool->state == ACTIVE);
rect_sel = (RectSelect *) tool->private; rect_sel = (RectSelect *) tool->private;
gdisp = (GDisplay *) gdisp_ptr;
switch (rect_sel->op) switch (rect_sel->op)
{ {
@ -574,6 +608,7 @@ rect_select_cursor_update (Tool *tool,
break; break;
case SELECTION_MOVE: case SELECTION_MOVE:
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR); gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
break;
} }
} }
@ -606,13 +641,13 @@ rect_select_control (Tool *tool,
} }
static void static void
rect_select_options_reset () rect_select_options_reset (void)
{ {
selection_options_reset (rect_options); selection_options_reset (rect_options);
} }
Tool * Tool *
tools_new_rect_select () tools_new_rect_select (void)
{ {
Tool * tool; Tool * tool;
RectSelect * private; RectSelect * private;

View File

@ -31,11 +31,17 @@ void rect_select_oper_update (Tool *, GdkEventMotion *, gpointer);
void rect_select_control (Tool *, ToolAction, gpointer); void rect_select_control (Tool *, ToolAction, gpointer);
/* rect select functions */ /* rect select functions */
void rect_select_draw (Tool *); void rect_select_draw (Tool *tool);
void rect_select (GimpImage *, int, int, int, int, int, int, void rect_select (GimpImage *gimage,
double); gint x,
gint y,
gint w,
gint g,
SelectOps op,
gboolean feather,
gdouble feather_radius);
Tool * tools_new_rect_select (void); Tool * tools_new_rect_select (void);
void tools_free_rect_select (Tool *); void tools_free_rect_select (Tool *tool);
#endif /* __RECT_SELECT_H__ */ #endif /* __RECT_SELECT_H__ */

View File

@ -21,7 +21,6 @@
#include "cursorutil.h" #include "cursorutil.h"
#include "draw_core.h" #include "draw_core.h"
#include "edit_selection.h" #include "edit_selection.h"
#include "errors.h"
#include "floating_sel.h" #include "floating_sel.h"
#include "gimage_mask.h" #include "gimage_mask.h"
#include "gdisplay.h" #include "gdisplay.h"
@ -57,7 +56,7 @@ static void move_tool_motion (Tool *, GdkEventMotion *, gpointer);
static void move_tool_cursor_update (Tool *, GdkEventMotion *, gpointer); static void move_tool_cursor_update (Tool *, GdkEventMotion *, gpointer);
static void move_tool_control (Tool *, ToolAction, gpointer); static void move_tool_control (Tool *, ToolAction, gpointer);
static void move_create_gc (GDisplay *); static void move_create_gc (GDisplay *gdisp);
/* move action functions */ /* move action functions */
@ -71,7 +70,7 @@ move_tool_button_press (Tool *tool,
MoveTool *move; MoveTool *move;
Layer *layer; Layer *layer;
Guide *guide; Guide *guide;
int x, y; gint x, y;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
move = (MoveTool *) tool->private; move = (MoveTool *) tool->private;
@ -83,7 +82,8 @@ move_tool_button_press (Tool *tool,
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE); gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE);
if (bevent->state & GDK_MOD1_MASK) if (bevent->state & GDK_MOD1_MASK &&
!gimage_mask_is_empty (gdisp->gimage))
{ {
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate); init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
tool->state = ACTIVE; tool->state = ACTIVE;
@ -95,7 +95,8 @@ move_tool_button_press (Tool *tool,
} }
else else
{ {
if (gdisp->draw_guides && (guide = gdisplay_find_guide (gdisp, bevent->x, bevent->y))) if (gdisp->draw_guides &&
(guide = gdisplay_find_guide (gdisp, bevent->x, bevent->y)))
{ {
undo_push_guide (gdisp->gimage, guide); undo_push_guide (gdisp->gimage, guide);
@ -114,9 +115,14 @@ move_tool_button_press (Tool *tool,
} }
else if ((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y))) else if ((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y)))
{ {
/* If there is a floating selection, and this aint it, use the move tool */ /* If there is a floating selection, and this aint it,
if (gimage_floating_sel (gdisp->gimage) && !layer_is_floating_sel (layer)) * use the move tool
*/
if (gimage_floating_sel (gdisp->gimage) &&
!layer_is_floating_sel (layer))
{
move->layer = gimage_floating_sel (gdisp->gimage); move->layer = gimage_floating_sel (gdisp->gimage);
}
/* Otherwise, init the edit selection */ /* Otherwise, init the edit selection */
else else
{ {
@ -131,21 +137,21 @@ move_tool_button_press (Tool *tool,
if (tool->state == ACTIVE) if (tool->state == ACTIVE)
{ {
gdk_pointer_grab (gdisp->canvas->window, FALSE, gdk_pointer_grab (gdisp->canvas->window, FALSE,
GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK, GDK_BUTTON_RELEASE_MASK,
NULL, NULL, bevent->time); NULL, NULL, bevent->time);
} }
} }
static void static void
move_draw_guide (GDisplay *gdisp, move_draw_guide (GDisplay *gdisp,
Guide *guide) Guide *guide)
{ {
int x1, y1; gint x1, y1;
int x2, y2; gint x2, y2;
int w, h; gint w, h;
int x, y; gint x, y;
if (!move_gc) if (!move_gc)
move_create_gc (gdisp); move_create_gc (gdisp);
@ -158,7 +164,8 @@ move_draw_guide (GDisplay *gdisp,
gdk_window_get_size (gdisp->canvas->window, &w, &h); gdk_window_get_size (gdisp->canvas->window, &w, &h);
switch (guide->orientation) { switch (guide->orientation)
{
case ORIENTATION_HORIZONTAL: case ORIENTATION_HORIZONTAL:
gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE); gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE);
if (x1 < 0) x1 = 0; if (x1 < 0) x1 = 0;
@ -166,6 +173,7 @@ move_draw_guide (GDisplay *gdisp,
gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y); gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y);
break; break;
case ORIENTATION_VERTICAL: case ORIENTATION_VERTICAL:
gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE); gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE);
if (y1 < 0) y1 = 0; if (y1 < 0) y1 = 0;
@ -173,6 +181,7 @@ move_draw_guide (GDisplay *gdisp,
gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2); gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2);
break; break;
default: default:
g_warning ("mdg / BAD FALLTHROUGH"); g_warning ("mdg / BAD FALLTHROUGH");
} }
@ -185,9 +194,9 @@ move_tool_button_release (Tool *tool,
{ {
MoveTool *move; MoveTool *move;
GDisplay *gdisp; GDisplay *gdisp;
int delete_guide; gboolean delete_guide;
int x1, y1; gint x1, y1;
int x2, y2; gint x2, y2;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
move = (MoveTool *) tool->private; move = (MoveTool *) tool->private;
@ -203,7 +212,8 @@ move_tool_button_release (Tool *tool,
delete_guide = FALSE; delete_guide = FALSE;
gdisplay_untransform_coords (gdisp, 0, 0, &x1, &y1, FALSE, FALSE); gdisplay_untransform_coords (gdisp, 0, 0, &x1, &y1, FALSE, FALSE);
gdisplay_untransform_coords (gdisp, gdisp->disp_width, gdisp->disp_height, &x2, &y2, FALSE, FALSE); gdisplay_untransform_coords (gdisp, gdisp->disp_width, gdisp->disp_height,
&x2, &y2, FALSE, FALSE);
if (x1 < 0) x1 = 0; if (x1 < 0) x1 = 0;
if (y1 < 0) y1 = 0; if (y1 < 0) y1 = 0;
@ -262,20 +272,20 @@ move_tool_motion (Tool *tool,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
MoveTool *move;
GDisplay *gdisp; GDisplay *gdisp;
MoveTool *private; gint x, y;
int x, y;
gdisp = gdisp_ptr; move = (MoveTool *) tool->private;
private = tool->private; gdisp = (GDisplay *) gdisp_ptr;
if (private->guide) if (move->guide)
{ {
move_draw_guide (gdisp, private->guide); move_draw_guide (gdisp, move->guide);
if (mevent && mevent->window != gdisp->canvas->window) if (mevent && mevent->window != gdisp->canvas->window)
{ {
private->guide->position = -1; move->guide->position = -1;
return; return;
} }
@ -284,12 +294,12 @@ move_tool_motion (Tool *tool,
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&x, &y, TRUE, FALSE); &x, &y, TRUE, FALSE);
if (private->guide->orientation == ORIENTATION_HORIZONTAL) if (move->guide->orientation == ORIENTATION_HORIZONTAL)
private->guide->position = y; move->guide->position = y;
else else
private->guide->position = x; move->guide->position = x;
move_draw_guide (gdisp, private->guide); move_draw_guide (gdisp, move->guide);
} }
} }
} }
@ -303,19 +313,27 @@ move_tool_cursor_update (Tool *tool,
GDisplay *gdisp; GDisplay *gdisp;
Guide *guide; Guide *guide;
Layer *layer; Layer *layer;
int x, y; gint x, y;
move = tool->private; move = (MoveTool *) tool->private;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE);
if (mevent->state & GDK_MOD1_MASK) gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y,
FALSE, FALSE);
if (mevent->state & GDK_MOD1_MASK &&
!gimage_mask_is_empty (gdisp->gimage))
{
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR); gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR);
}
else if (mevent->state & GDK_SHIFT_MASK) else if (mevent->state & GDK_SHIFT_MASK)
{
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR); gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
}
else else
{ {
if (gdisp->draw_guides && (guide = gdisplay_find_guide (gdisp, mevent->x, mevent->y))) if (gdisp->draw_guides &&
(guide = gdisplay_find_guide (gdisp, mevent->x, mevent->y)))
{ {
tool->gdisp_ptr = gdisp_ptr; tool->gdisp_ptr = gdisp_ptr;
gdisplay_install_tool_cursor (gdisp, GDK_HAND2); gdisplay_install_tool_cursor (gdisp, GDK_HAND2);
@ -338,7 +356,8 @@ move_tool_cursor_update (Tool *tool,
else if ((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y))) else if ((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y)))
{ {
/* if there is a floating selection, and this aint it... */ /* if there is a floating selection, and this aint it... */
if (gimage_floating_sel (gdisp->gimage) && !layer_is_floating_sel (layer)) if (gimage_floating_sel (gdisp->gimage) &&
!layer_is_floating_sel (layer))
gdisplay_install_tool_cursor (gdisp, GDK_SB_DOWN_ARROW); gdisplay_install_tool_cursor (gdisp, GDK_SB_DOWN_ARROW);
else if (layer == gdisp->gimage->active_layer) else if (layer == gdisp->gimage->active_layer)
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR); gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
@ -346,9 +365,11 @@ move_tool_cursor_update (Tool *tool,
gdisplay_install_tool_cursor (gdisp, GDK_HAND2); gdisplay_install_tool_cursor (gdisp, GDK_HAND2);
} }
else else
{
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW); gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
} }
} }
}
static void static void
@ -387,19 +408,16 @@ move_create_gc (GDisplay *gdisp)
values.foreground.pixel = gdisplay_white_pixel (gdisp); values.foreground.pixel = gdisplay_white_pixel (gdisp);
values.function = GDK_INVERT; values.function = GDK_INVERT;
move_gc = gdk_gc_new_with_values (gdisp->canvas->window, &values, GDK_GC_FUNCTION); move_gc = gdk_gc_new_with_values (gdisp->canvas->window, &values,
GDK_GC_FUNCTION);
} }
} }
void void
move_tool_start_hguide (Tool *tool, move_tool_start_hguide (Tool *tool,
void *data) GDisplay *gdisp)
{ {
MoveTool *private; MoveTool *private;
GDisplay *gdisp;
gdisp = data;
selection_pause (gdisp->select); selection_pause (gdisp->select);
@ -421,12 +439,9 @@ move_tool_start_hguide (Tool *tool,
void void
move_tool_start_vguide (Tool *tool, move_tool_start_vguide (Tool *tool,
void *data) GDisplay *gdisp)
{ {
MoveTool *private; MoveTool *private;
GDisplay *gdisp;
gdisp = data;
selection_pause (gdisp->select); selection_pause (gdisp->select);
@ -480,7 +495,6 @@ tools_new_move_tool (void)
return tool; return tool;
} }
void void
tools_free_move_tool (Tool *tool) tools_free_move_tool (Tool *tool)
{ {

View File

@ -22,10 +22,13 @@
/* move functions */ /* move functions */
void move_tool_start_hguide (Tool *, void *); void move_tool_start_hguide (Tool *tool,
void move_tool_start_vguide (Tool *, void *); GDisplay *gdisp);
void move_tool_start_vguide (Tool *tool,
GDisplay *gdisp);
Tool * tools_new_move_tool (void); Tool * tools_new_move_tool (void);
void tools_free_move_tool (Tool *); void tools_free_move_tool (Tool *tool);
#endif /* __MOVE_H__ */ #endif /* __MOVE_H__ */

View File

@ -17,6 +17,7 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include "appenv.h" #include "appenv.h"
#include "gdisplay.h" #include "gdisplay.h"
#include "gimage_mask.h" #include "gimage_mask.h"
@ -39,7 +40,15 @@ static SelectionOptions *rect_options = NULL;
/* in gimp, ellipses are rectangular, too ;) */ /* in gimp, ellipses are rectangular, too ;) */
extern SelectionOptions *ellipse_options; extern SelectionOptions *ellipse_options;
extern void ellipse_select (GImage *, int, int, int, int, int, int, int, double); extern void ellipse_select (GimpImage *gimage,
gint x,
gint y,
gint w,
gint h,
SelectOps op,
gboolean antialias,
gboolean feather,
gdouble feather_radius);
static void selection_tool_update_op_state (RectSelect *rect_sel, static void selection_tool_update_op_state (RectSelect *rect_sel,
gint x, gint x,
@ -52,13 +61,13 @@ static void selection_tool_update_op_state (RectSelect *rect_sel,
void void
rect_select (GimpImage *gimage, rect_select (GimpImage *gimage,
int x, gint x,
int y, gint y,
int w, gint w,
int h, gint h,
int op, SelectOps op,
int feather, gboolean feather,
double feather_radius) gdouble feather_radius)
{ {
Channel *new_mask; Channel *new_mask;
@ -210,7 +219,9 @@ rect_select_button_release (Tool *tool,
{ {
RectSelect *rect_sel; RectSelect *rect_sel;
GDisplay *gdisp; GDisplay *gdisp;
int x1, y1, x2, y2, w, h; gint x1, y1;
gint x2, y2;
gint w, h;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
rect_sel = (RectSelect *) tool->private; rect_sel = (RectSelect *) tool->private;
@ -282,11 +293,11 @@ rect_select_motion (Tool *tool,
RectSelect *rect_sel; RectSelect *rect_sel;
GDisplay *gdisp; GDisplay *gdisp;
gchar size[STATUSBAR_SIZE]; gchar size[STATUSBAR_SIZE];
int ox, oy; gint ox, oy;
int x, y; gint x, y;
int w, h, s; gint w, h, s;
int tw, th; gint tw, th;
double ratio; gdouble ratio;
gdisp = (GDisplay *) gdisp_ptr; gdisp = (GDisplay *) gdisp_ptr;
rect_sel = (RectSelect *) tool->private; rect_sel = (RectSelect *) tool->private;
@ -443,7 +454,8 @@ rect_select_draw (Tool *tool)
{ {
GDisplay *gdisp; GDisplay *gdisp;
RectSelect *rect_sel; RectSelect *rect_sel;
int x1, y1, x2, y2; gint x1, y1;
gint x2, y2;
gdisp = (GDisplay *) tool->gdisp_ptr; gdisp = (GDisplay *) tool->gdisp_ptr;
rect_sel = (RectSelect *) tool->private; rect_sel = (RectSelect *) tool->private;
@ -468,28 +480,51 @@ selection_tool_update_op_state (RectSelect *rect_sel,
gint state, gint state,
GDisplay *gdisp) GDisplay *gdisp)
{ {
Layer *layer;
Layer *floating_sel;
gint tx, ty;
if (active_tool->state == ACTIVE) if (active_tool->state == ACTIVE)
return; return;
gdisplay_untransform_coords (gdisp, x, y, &tx, &ty, FALSE, FALSE);
layer = gimage_pick_correlate_layer (gdisp->gimage, tx, ty);
floating_sel = gimage_floating_sel (gdisp->gimage);
if (state & GDK_MOD1_MASK && if (state & GDK_MOD1_MASK &&
!(layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage)))) !gimage_mask_is_empty (gdisp->gimage))
{
rect_sel->op = SELECTION_MOVE_MASK; /* move just the selection mask */ rect_sel->op = SELECTION_MOVE_MASK; /* move just the selection mask */
else if (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage)) || }
(!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) && else if (!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
gdisplay_mask_value (gdisp, x, y))) layer &&
(layer == floating_sel ||
(gdisplay_mask_value (gdisp, x, y) &&
!floating_sel)))
{
rect_sel->op = SELECTION_MOVE; /* move the selection */ rect_sel->op = SELECTION_MOVE; /* move the selection */
}
else if ((state & GDK_SHIFT_MASK) && else if ((state & GDK_SHIFT_MASK) &&
!(state & GDK_CONTROL_MASK)) !(state & GDK_CONTROL_MASK))
{
rect_sel->op = SELECTION_ADD; /* add to the selection */ rect_sel->op = SELECTION_ADD; /* add to the selection */
}
else if ((state & GDK_CONTROL_MASK) && else if ((state & GDK_CONTROL_MASK) &&
!(state & GDK_SHIFT_MASK)) !(state & GDK_SHIFT_MASK))
{
rect_sel->op = SELECTION_SUB; /* subtract from the selection */ rect_sel->op = SELECTION_SUB; /* subtract from the selection */
}
else if ((state & GDK_CONTROL_MASK) && else if ((state & GDK_CONTROL_MASK) &&
(state & GDK_SHIFT_MASK)) (state & GDK_SHIFT_MASK))
{
rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */ rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */
}
else else
{
rect_sel->op = SELECTION_REPLACE; /* replace the selection */ rect_sel->op = SELECTION_REPLACE; /* replace the selection */
} }
}
void void
rect_select_oper_update (Tool *tool, rect_select_oper_update (Tool *tool,
@ -548,12 +583,11 @@ rect_select_cursor_update (Tool *tool,
GdkEventMotion *mevent, GdkEventMotion *mevent,
gpointer gdisp_ptr) gpointer gdisp_ptr)
{ {
int active;
RectSelect *rect_sel; RectSelect *rect_sel;
GDisplay *gdisp; GDisplay *gdisp;
gdisp = (GDisplay *)gdisp_ptr;
active = (active_tool->state == ACTIVE);
rect_sel = (RectSelect *) tool->private; rect_sel = (RectSelect *) tool->private;
gdisp = (GDisplay *) gdisp_ptr;
switch (rect_sel->op) switch (rect_sel->op)
{ {
@ -574,6 +608,7 @@ rect_select_cursor_update (Tool *tool,
break; break;
case SELECTION_MOVE: case SELECTION_MOVE:
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR); gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
break;
} }
} }
@ -606,13 +641,13 @@ rect_select_control (Tool *tool,
} }
static void static void
rect_select_options_reset () rect_select_options_reset (void)
{ {
selection_options_reset (rect_options); selection_options_reset (rect_options);
} }
Tool * Tool *
tools_new_rect_select () tools_new_rect_select (void)
{ {
Tool * tool; Tool * tool;
RectSelect * private; RectSelect * private;

View File

@ -31,11 +31,17 @@ void rect_select_oper_update (Tool *, GdkEventMotion *, gpointer);
void rect_select_control (Tool *, ToolAction, gpointer); void rect_select_control (Tool *, ToolAction, gpointer);
/* rect select functions */ /* rect select functions */
void rect_select_draw (Tool *); void rect_select_draw (Tool *tool);
void rect_select (GimpImage *, int, int, int, int, int, int, void rect_select (GimpImage *gimage,
double); gint x,
gint y,
gint w,
gint g,
SelectOps op,
gboolean feather,
gdouble feather_radius);
Tool * tools_new_rect_select (void); Tool * tools_new_rect_select (void);
void tools_free_rect_select (Tool *); void tools_free_rect_select (Tool *tool);
#endif /* __RECT_SELECT_H__ */ #endif /* __RECT_SELECT_H__ */