mirror of https://github.com/GNOME/gimp.git
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:
parent
b7940e1ebf
commit
c497d9c140
18
ChangeLog
18
ChangeLog
|
@ -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>
|
||||
|
||||
* app/gimpui.[ch]: (gimp_dialog_hide) new function that calls
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
|
||||
#include "toolsF.h"
|
||||
|
||||
typedef struct _bezier_point BezierPoint;
|
||||
typedef struct _bezier_select BezierSelect;
|
||||
typedef struct _BezierPoint BezierPoint;
|
||||
typedef struct _BezierSelect BezierSelect;
|
||||
|
||||
/* bezier select functions */
|
||||
|
||||
void bezier_select_dialog (void);
|
||||
Tool * tools_new_bezier_select (void);
|
||||
void tools_free_bezier_select (Tool *);
|
||||
gboolean bezier_tool_selected (void);
|
||||
Tool * tools_new_bezier_select (void);
|
||||
void tools_free_bezier_select (Tool *tool);
|
||||
|
||||
gboolean bezier_tool_selected (void);
|
||||
|
||||
#endif /* __BEZIER_SELECT_H__ */
|
||||
|
|
|
@ -37,57 +37,76 @@
|
|||
|
||||
enum { EXTEND_EDIT, EXTEND_ADD, EXTEND_REMOVE, EXTEND_NEW };
|
||||
|
||||
struct _bezier_point
|
||||
struct _BezierPoint
|
||||
{
|
||||
int type; /* type of point (anchor/control/move) */
|
||||
double x, y; /* location of point in image space */
|
||||
int sx, sy; /* location of point in screen space */
|
||||
gint type; /* type of point (anchor/control/move) */
|
||||
gdouble x, y; /* location of point in image space */
|
||||
gint sx, sy; /* location of point in screen space */
|
||||
BezierPoint *next; /* next point on curve */
|
||||
BezierPoint *prev; /* prev point on curve */
|
||||
BezierPoint *next_curve; /* Next curve segment */
|
||||
gint pointflags; /* Status of point 0 = not selected
|
||||
gint pointflags; /* Status of point 0 = not selected
|
||||
* 1 = selected
|
||||
*/
|
||||
};
|
||||
|
||||
struct _bezier_select
|
||||
struct _BezierSelect
|
||||
{
|
||||
int state; /* start, add, edit or drag */
|
||||
int draw; /* all or part */
|
||||
int closed; /* is the last curve closed */
|
||||
DrawCore *core; /* Core drawing object */
|
||||
BezierPoint *points; /* the curve */
|
||||
BezierPoint *cur_anchor; /* the current active anchor point */
|
||||
BezierPoint *cur_control; /* the current active control point */
|
||||
BezierPoint *last_point; /* the last point on the curve */
|
||||
int num_points; /* number of points in the curve */
|
||||
Channel *mask; /* null if the curve is open */
|
||||
GSList **scanlines; /* used in converting a curve */
|
||||
gint state; /* start, add, edit or drag */
|
||||
gint draw; /* all or part */
|
||||
gint closed; /* is the last curve closed */
|
||||
DrawCore *core; /* Core drawing object */
|
||||
BezierPoint *points; /* the curve */
|
||||
BezierPoint *cur_anchor; /* the current active anchor point */
|
||||
BezierPoint *cur_control; /* the current active control point */
|
||||
BezierPoint *last_point; /* the last point on the curve */
|
||||
gint num_points; /* number of points in the curve */
|
||||
Channel *mask; /* null if the curve is open */
|
||||
GSList **scanlines; /* used in converting a curve */
|
||||
};
|
||||
|
||||
/* All udata that are passed to the bezier_draw_curve must
|
||||
* have this structure as the first element.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
gint count;
|
||||
} CountCurves;
|
||||
|
||||
typedef void (*BezierPointsFunc) (BezierSelect *, GdkPoint *, int,gpointer);
|
||||
typedef void (* BezierPointsFunc) (BezierSelect *, GdkPoint *, int,gpointer);
|
||||
|
||||
/* Functions */
|
||||
int bezier_select_load (void *, BezierPoint *, int, int);
|
||||
void bezier_draw_curve (BezierSelect *,BezierPointsFunc, int,gpointer);
|
||||
void bezier_select_reset (BezierSelect *);
|
||||
int bezier_select_load (void *,
|
||||
BezierPoint *,
|
||||
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_add_point (BezierSelect *, int, gdouble, gdouble);
|
||||
void bezier_paste_bezierselect_to_current (GDisplay *,BezierSelect *);
|
||||
void bezier_add_point (BezierSelect *,
|
||||
gint,
|
||||
gdouble,
|
||||
gdouble);
|
||||
void bezier_paste_bezierselect_to_current (GDisplay *gdisp,
|
||||
BezierSelect *bezier_sel);
|
||||
void bezier_select_mode (gint);
|
||||
void bezier_stroke (BezierSelect *, GDisplay *, int, int);
|
||||
void bezier_to_selection (BezierSelect *, GDisplay *);
|
||||
gint bezier_distance_along (BezierSelect *, gint, gdouble,gint *,gint *,gdouble *);
|
||||
void bezier_draw (GDisplay *,BezierSelect *);
|
||||
void bezier_stroke (BezierSelect *bezier_sel,
|
||||
GDisplay *gdisp,
|
||||
gint,
|
||||
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__ */
|
||||
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ typedef struct _ByColorSelect ByColorSelect;
|
|||
|
||||
struct _ByColorSelect
|
||||
{
|
||||
gint x, y; /* Point from which to execute seed fill */
|
||||
gint operation; /* add, subtract, normal color selection */
|
||||
gint x, y; /* Point from which to execute seed fill */
|
||||
SelectOps operation; /* add, subtract, normal color selection */
|
||||
};
|
||||
|
||||
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) /
|
||||
sizeof (by_color_select_targets[0]));
|
||||
|
||||
static void by_color_select_color_drop (GtkWidget *, guchar, guchar, guchar,
|
||||
gpointer);
|
||||
static void by_color_select_color_drop (GtkWidget *widget,
|
||||
guchar r,
|
||||
guchar g,
|
||||
guchar b,
|
||||
gpointer data);
|
||||
|
||||
/* 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 *,
|
||||
GdkEventButton *,
|
||||
ByColorDialog *);
|
||||
static void by_color_select_type_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_fuzzy_update (GtkAdjustment *, gpointer);
|
||||
static void by_color_select_preview_button_press (ByColorDialog *,
|
||||
GdkEventButton *);
|
||||
|
||||
|
@ -169,9 +170,9 @@ static Channel *
|
|||
by_color_select_color (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
guchar *color,
|
||||
gint antialias,
|
||||
gboolean antialias,
|
||||
gint threshold,
|
||||
gint sample_merged)
|
||||
gboolean sample_merged)
|
||||
{
|
||||
/* Scan over the gimage's active layer, finding pixels within the specified
|
||||
* threshold from the given R, G, & B values. If antialiasing is on,
|
||||
|
@ -279,11 +280,11 @@ by_color_select (GImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
guchar *color,
|
||||
gint threshold,
|
||||
gint op,
|
||||
gint antialias,
|
||||
gint feather,
|
||||
SelectOps op,
|
||||
gboolean antialias,
|
||||
gboolean feather,
|
||||
gdouble feather_radius,
|
||||
gint sample_merged)
|
||||
gboolean sample_merged)
|
||||
{
|
||||
Channel *new_mask;
|
||||
gint off_x, off_y;
|
||||
|
@ -295,7 +296,7 @@ by_color_select (GImage *gimage,
|
|||
antialias, threshold, sample_merged);
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == REPLACE)
|
||||
if (op == SELECTION_REPLACE)
|
||||
gimage_mask_clear (gimage);
|
||||
else
|
||||
gimage_mask_undo (gimage);
|
||||
|
@ -454,30 +455,30 @@ by_color_select_cursor_update (Tool *tool,
|
|||
if (by_color_options->sample_merged ||
|
||||
((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y)) &&
|
||||
layer == gdisp->gimage->active_layer))
|
||||
{
|
||||
switch (by_col_sel->operation)
|
||||
{
|
||||
case SELECTION_ADD:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_ADD_CURSOR);
|
||||
break;
|
||||
case SELECTION_SUB:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_SUBTRACT_CURSOR);
|
||||
break;
|
||||
case SELECTION_INTERSECT:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_INTERSECT_CURSOR);
|
||||
break;
|
||||
case SELECTION_REPLACE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
break;
|
||||
case SELECTION_MOVE_MASK:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR);
|
||||
break;
|
||||
case SELECTION_MOVE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
}
|
||||
{
|
||||
switch (by_col_sel->operation)
|
||||
{
|
||||
case SELECTION_ADD:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_ADD_CURSOR);
|
||||
break;
|
||||
case SELECTION_SUB:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_SUBTRACT_CURSOR);
|
||||
break;
|
||||
case SELECTION_INTERSECT:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_INTERSECT_CURSOR);
|
||||
break;
|
||||
case SELECTION_REPLACE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
break;
|
||||
case SELECTION_MOVE_MASK:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR);
|
||||
break;
|
||||
case SELECTION_MOVE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_BAD_CURSOR);
|
||||
}
|
||||
|
@ -675,7 +676,7 @@ by_color_select_dialog_new (void)
|
|||
|
||||
bcd = g_new (ByColorDialog, 1);
|
||||
bcd->gimage = NULL;
|
||||
bcd->operation = REPLACE;
|
||||
bcd->operation = SELECTION_REPLACE;
|
||||
bcd->threshold = DEFAULT_FUZZINESS;
|
||||
|
||||
/* The shell and main vbox */
|
||||
|
@ -743,16 +744,15 @@ by_color_select_dialog_new (void)
|
|||
|
||||
/* Create the selection mode radio box */
|
||||
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,
|
||||
(gpointer) SELECTION_REPLACE, NULL, NULL, TRUE,
|
||||
_("Add"), by_color_select_type_callback,
|
||||
(gpointer) SELECTION_ADD, NULL, NULL, FALSE,
|
||||
_("Subtract"), by_color_select_type_callback,
|
||||
(gpointer) SELECTION_SUB, NULL, NULL, FALSE,
|
||||
_("Intersect"), by_color_select_type_callback,
|
||||
(gpointer) SELECTION_INTERSECT, NULL, NULL, FALSE,
|
||||
_("Replace"), (gpointer) SELECTION_REPLACE, NULL,
|
||||
_("Add"), (gpointer) SELECTION_ADD, NULL,
|
||||
_("Subtract"), (gpointer) SELECTION_SUB, NULL,
|
||||
_("Intersect"), (gpointer) SELECTION_INTERSECT, NULL,
|
||||
|
||||
NULL);
|
||||
|
||||
|
@ -776,8 +776,8 @@ by_color_select_dialog_new (void)
|
|||
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (by_color_select_fuzzy_update),
|
||||
bcd);
|
||||
GTK_SIGNAL_FUNC (gimp_int_adjustment_update),
|
||||
&bcd->threshold);
|
||||
|
||||
gtk_widget_show (slider);
|
||||
|
||||
|
@ -800,7 +800,7 @@ by_color_select_render (ByColorDialog *bcd,
|
|||
MaskBuf * scaled_buf = NULL;
|
||||
guchar *buf;
|
||||
PixelRegion srcPR, destPR;
|
||||
guchar * src;
|
||||
guchar *src;
|
||||
gint subsample;
|
||||
gint width, height;
|
||||
gint srcwidth;
|
||||
|
@ -936,14 +936,6 @@ by_color_select_preview_events (GtkWidget *widget,
|
|||
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
|
||||
by_color_select_reset_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
@ -987,26 +979,16 @@ 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
|
||||
by_color_select_preview_button_press (ByColorDialog *bcd,
|
||||
GdkEventButton *bevent)
|
||||
{
|
||||
gint x, y;
|
||||
gint replace, operation;
|
||||
gint x, y;
|
||||
gboolean replace;
|
||||
SelectOps operation;
|
||||
GimpDrawable *drawable;
|
||||
Tile *tile;
|
||||
guchar *col;
|
||||
Tile *tile;
|
||||
guchar *col;
|
||||
|
||||
if (!bcd->gimage)
|
||||
return;
|
||||
|
@ -1019,7 +1001,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
|
|||
|
||||
/* Defaults */
|
||||
replace = FALSE;
|
||||
operation = REPLACE;
|
||||
operation = SELECTION_REPLACE;
|
||||
|
||||
/* Based on modifiers, and the "by color" dialog's selection mode */
|
||||
if ((bevent->state & GDK_SHIFT_MASK) &&
|
||||
|
@ -1049,7 +1031,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
|
|||
}
|
||||
else
|
||||
{
|
||||
int offx, offy;
|
||||
gint offx, offy;
|
||||
|
||||
drawable_offsets (drawable, &offx, &offy);
|
||||
x = drawable_width (drawable) * bevent->x / bcd->preview->requisition.width - offx;
|
||||
|
|
|
@ -32,10 +32,10 @@ void by_color_select (GimpImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
guchar *color,
|
||||
gint threshold,
|
||||
gint op,
|
||||
gint antialias,
|
||||
gint feather,
|
||||
SelectOps op,
|
||||
gboolean antialias,
|
||||
gboolean feather,
|
||||
gdouble feather_radius,
|
||||
gint sample_merged);
|
||||
gboolean sample_merged);
|
||||
|
||||
#endif /* __BY_COLOR_SELECT_H__ */
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "appenv.h"
|
||||
#include "edit_selection.h"
|
||||
#include "ellipse_select.h"
|
||||
|
@ -36,16 +37,16 @@ SelectionOptions * ellipse_options = NULL;
|
|||
|
||||
void
|
||||
ellipse_select (GimpImage *gimage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int op,
|
||||
int antialias,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h,
|
||||
SelectOps op,
|
||||
gboolean antialias,
|
||||
gboolean feather,
|
||||
gdouble feather_radius)
|
||||
{
|
||||
Channel * new_mask;
|
||||
Channel *new_mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == SELECTION_REPLACE)
|
||||
|
@ -74,15 +75,17 @@ ellipse_select (GimpImage *gimage,
|
|||
channel_delete (new_mask);
|
||||
}
|
||||
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
|
||||
ellipse_select_draw (Tool *tool)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
EllipseSelect * ellipse_sel;
|
||||
int x1, y1, x2, y2;
|
||||
GDisplay *gdisp;
|
||||
EllipseSelect *ellipse_sel;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
gdisp = (GDisplay *) tool->gdisp_ptr;
|
||||
ellipse_sel = (EllipseSelect *) tool->private;
|
||||
|
@ -109,7 +112,7 @@ ellipse_select_options_reset (void)
|
|||
Tool *
|
||||
tools_new_ellipse_select (void)
|
||||
{
|
||||
Tool *tool;
|
||||
Tool *tool;
|
||||
EllipseSelect *private;
|
||||
|
||||
/* The tool options */
|
||||
|
|
|
@ -23,11 +23,18 @@
|
|||
|
||||
/* ellipse select functions */
|
||||
|
||||
void ellipse_select_draw (Tool *);
|
||||
void ellipse_select (GimpImage *, int, int, int, int, int,
|
||||
int, int, double);
|
||||
void ellipse_select (GimpImage *gimage,
|
||||
gint x,
|
||||
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);
|
||||
void tools_free_ellipse_select (Tool *);
|
||||
Tool * tools_new_ellipse_select (void);
|
||||
void tools_free_ellipse_select (Tool *tool);
|
||||
|
||||
#endif /* __ELLIPSE_SELECT_H__ */
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "appenv.h"
|
||||
#include "draw_core.h"
|
||||
#include "edit_selection.h"
|
||||
|
@ -39,9 +40,9 @@
|
|||
typedef struct _FreeSelect FreeSelect;
|
||||
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_y; /* (enables immediate cursor updating on modifier
|
||||
|
@ -56,16 +57,16 @@ struct _FreeSelect
|
|||
static SelectionOptions * free_options = NULL;
|
||||
|
||||
/* The global array of XPoints for drawing the polygon... */
|
||||
static GdkPoint * global_pts = NULL;
|
||||
static int max_segs = 0;
|
||||
static GdkPoint *global_pts = NULL;
|
||||
static gint max_segs = 0;
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
static int
|
||||
add_point (int num_pts,
|
||||
int x,
|
||||
int y)
|
||||
static gint
|
||||
add_point (gint num_pts,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
if (num_pts >= max_segs)
|
||||
{
|
||||
|
@ -85,17 +86,17 @@ add_point (int num_pts,
|
|||
|
||||
|
||||
static Channel *
|
||||
scan_convert (GimpImage *gimage,
|
||||
int num_pts,
|
||||
scan_convert (GimpImage *gimage,
|
||||
gint num_pts,
|
||||
ScanConvertPoint *pts,
|
||||
int width,
|
||||
int height,
|
||||
int antialias)
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean antialias)
|
||||
{
|
||||
Channel * mask;
|
||||
Channel *mask;
|
||||
ScanConverter *sc;
|
||||
|
||||
sc = scan_converter_new (width, height, antialias? SUPERSAMPLE : 1);
|
||||
sc = scan_converter_new (width, height, antialias ? SUPERSAMPLE : 1);
|
||||
scan_converter_add_points (sc, num_pts, pts);
|
||||
|
||||
mask = scan_converter_to_channel (sc, gimage);
|
||||
|
@ -109,24 +110,25 @@ scan_convert (GimpImage *gimage,
|
|||
/* Polygonal selection apparatus */
|
||||
|
||||
void
|
||||
free_select (GImage *gimage,
|
||||
int num_pts,
|
||||
free_select (GImage *gimage,
|
||||
gint num_pts,
|
||||
ScanConvertPoint *pts,
|
||||
int op,
|
||||
int antialias,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
SelectOps op,
|
||||
gboolean antialias,
|
||||
gboolean feather,
|
||||
gdouble feather_radius)
|
||||
{
|
||||
Channel *mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
/* or insure that a floating selection is anchored down... */
|
||||
if (op == REPLACE)
|
||||
if (op == SELECTION_REPLACE)
|
||||
gimage_mask_clear (gimage);
|
||||
else
|
||||
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)
|
||||
{
|
||||
|
@ -147,7 +149,7 @@ free_select_button_press (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
GDisplay *gdisp;
|
||||
FreeSelect *free_sel;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
|
@ -163,14 +165,14 @@ free_select_button_press (Tool *tool,
|
|||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
switch (free_sel->op)
|
||||
{
|
||||
case SELECTION_MOVE_MASK:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
case SELECTION_MOVE:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
{
|
||||
case SELECTION_MOVE_MASK:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
case SELECTION_MOVE:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
add_point (0, bevent->x, bevent->y);
|
||||
free_sel->num_pts = 1;
|
||||
|
@ -185,10 +187,10 @@ free_select_button_release (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
FreeSelect *free_sel;
|
||||
FreeSelect *free_sel;
|
||||
ScanConvertPoint *pts;
|
||||
GDisplay *gdisp;
|
||||
int i;
|
||||
GDisplay *gdisp;
|
||||
gint i;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
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 */
|
||||
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++)
|
||||
{
|
||||
|
@ -227,7 +229,7 @@ free_select_motion (Tool *tool,
|
|||
gpointer gdisp_ptr)
|
||||
{
|
||||
FreeSelect *free_sel;
|
||||
GDisplay *gdisp;
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
free_sel = (FreeSelect *) tool->private;
|
||||
|
@ -256,21 +258,21 @@ free_select_control (Tool *tool,
|
|||
ToolAction action,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
FreeSelect * free_sel;
|
||||
FreeSelect *free_sel;
|
||||
|
||||
free_sel = (FreeSelect *) tool->private;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case PAUSE :
|
||||
case PAUSE:
|
||||
draw_core_pause (free_sel->core, tool);
|
||||
break;
|
||||
|
||||
case RESUME :
|
||||
case RESUME:
|
||||
draw_core_resume (free_sel->core, tool);
|
||||
break;
|
||||
|
||||
case HALT :
|
||||
case HALT:
|
||||
draw_core_stop (free_sel->core, tool);
|
||||
break;
|
||||
|
||||
|
@ -282,8 +284,8 @@ free_select_control (Tool *tool,
|
|||
void
|
||||
free_select_draw (Tool *tool)
|
||||
{
|
||||
FreeSelect * free_sel;
|
||||
int i;
|
||||
FreeSelect *free_sel;
|
||||
gint i;
|
||||
|
||||
free_sel = (FreeSelect *) tool->private;
|
||||
|
||||
|
@ -294,7 +296,7 @@ free_select_draw (Tool *tool)
|
|||
}
|
||||
|
||||
static void
|
||||
free_select_options_reset ()
|
||||
free_select_options_reset (void)
|
||||
{
|
||||
selection_options_reset (free_options);
|
||||
}
|
||||
|
@ -302,8 +304,8 @@ free_select_options_reset ()
|
|||
Tool *
|
||||
tools_new_free_select (void)
|
||||
{
|
||||
Tool * tool;
|
||||
FreeSelect * private;
|
||||
Tool *tool;
|
||||
FreeSelect *private;
|
||||
|
||||
/* The tool options */
|
||||
if (!free_options)
|
||||
|
@ -316,9 +318,9 @@ tools_new_free_select (void)
|
|||
tool = tools_new_tool (FREE_SELECT);
|
||||
private = g_new (FreeSelect, 1);
|
||||
|
||||
private->core = draw_core_new (free_select_draw);
|
||||
private->core = draw_core_new (free_select_draw);
|
||||
private->num_pts = 0;
|
||||
private->op = SELECTION_REPLACE;
|
||||
private->op = SELECTION_REPLACE;
|
||||
|
||||
tool->scroll_lock = TRUE; /* Do not allow scrolling */
|
||||
|
||||
|
@ -338,7 +340,7 @@ tools_new_free_select (void)
|
|||
void
|
||||
tools_free_free_select (Tool *tool)
|
||||
{
|
||||
FreeSelect * free_sel;
|
||||
FreeSelect *free_sel;
|
||||
|
||||
free_sel = (FreeSelect *) tool->private;
|
||||
|
||||
|
|
|
@ -21,21 +21,25 @@
|
|||
#include "gimpimageF.h"
|
||||
#include "scan_convert.h"
|
||||
|
||||
void free_select (GimpImage *, int, ScanConvertPoint *, int, int, int,
|
||||
double);
|
||||
|
||||
/* free select action functions */
|
||||
|
||||
void free_select_button_press (Tool *, GdkEventButton *, gpointer);
|
||||
void free_select_button_release (Tool *, GdkEventButton *, gpointer);
|
||||
void free_select_motion (Tool *, GdkEventMotion *, gpointer);
|
||||
void free_select_button_press (Tool *, GdkEventButton *, gpointer);
|
||||
void free_select_button_release (Tool *, GdkEventButton *, gpointer);
|
||||
void free_select_motion (Tool *, GdkEventMotion *, gpointer);
|
||||
|
||||
|
||||
/* free select functions */
|
||||
|
||||
void free_select_dialog (void);
|
||||
void free_select_draw (Tool *);
|
||||
Tool * tools_new_free_select (void);
|
||||
void tools_free_free_select (Tool *);
|
||||
void free_select (GimpImage *gimage,
|
||||
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);
|
||||
void tools_free_free_select (Tool *tool);
|
||||
|
||||
#endif /* __FREE_SELECT_H__ */
|
||||
|
|
184
app/move.c
184
app/move.c
|
@ -21,7 +21,6 @@
|
|||
#include "cursorutil.h"
|
||||
#include "draw_core.h"
|
||||
#include "edit_selection.h"
|
||||
#include "errors.h"
|
||||
#include "floating_sel.h"
|
||||
#include "gimage_mask.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_control (Tool *, ToolAction, gpointer);
|
||||
|
||||
static void move_create_gc (GDisplay *);
|
||||
static void move_create_gc (GDisplay *gdisp);
|
||||
|
||||
|
||||
/* move action functions */
|
||||
|
@ -67,11 +66,11 @@ move_tool_button_press (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
MoveTool * move;
|
||||
Layer * layer;
|
||||
Guide * guide;
|
||||
int x, y;
|
||||
GDisplay *gdisp;
|
||||
MoveTool *move;
|
||||
Layer *layer;
|
||||
Guide *guide;
|
||||
gint x, y;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
move = (MoveTool *) tool->private;
|
||||
|
@ -82,8 +81,9 @@ move_tool_button_press (Tool *tool,
|
|||
move->disp = NULL;
|
||||
|
||||
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);
|
||||
tool->state = ACTIVE;
|
||||
|
@ -95,7 +95,8 @@ move_tool_button_press (Tool *tool,
|
|||
}
|
||||
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);
|
||||
|
||||
|
@ -105,18 +106,23 @@ move_tool_button_press (Tool *tool,
|
|||
gimage_add_guide (gdisp->gimage, guide);
|
||||
|
||||
move->guide = guide;
|
||||
move->disp = gdisp;
|
||||
move->disp = gdisp;
|
||||
|
||||
tool->scroll_lock = TRUE;
|
||||
tool->state = ACTIVE;
|
||||
tool->state = ACTIVE;
|
||||
|
||||
move_tool_motion (tool, NULL, gdisp);
|
||||
}
|
||||
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 (gimage_floating_sel (gdisp->gimage) && !layer_is_floating_sel (layer))
|
||||
move->layer = gimage_floating_sel (gdisp->gimage);
|
||||
/* If there is a floating selection, and this aint it,
|
||||
* use the move tool
|
||||
*/
|
||||
if (gimage_floating_sel (gdisp->gimage) &&
|
||||
!layer_is_floating_sel (layer))
|
||||
{
|
||||
move->layer = gimage_floating_sel (gdisp->gimage);
|
||||
}
|
||||
/* Otherwise, init the edit selection */
|
||||
else
|
||||
{
|
||||
|
@ -131,21 +137,21 @@ move_tool_button_press (Tool *tool,
|
|||
if (tool->state == ACTIVE)
|
||||
{
|
||||
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,
|
||||
NULL, NULL, bevent->time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
move_draw_guide (GDisplay *gdisp,
|
||||
Guide *guide)
|
||||
{
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
int w, h;
|
||||
int x, y;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
gint w, h;
|
||||
gint x, y;
|
||||
|
||||
if (!move_gc)
|
||||
move_create_gc (gdisp);
|
||||
|
@ -158,24 +164,27 @@ move_draw_guide (GDisplay *gdisp,
|
|||
|
||||
gdk_window_get_size (gdisp->canvas->window, &w, &h);
|
||||
|
||||
switch (guide->orientation) {
|
||||
case ORIENTATION_HORIZONTAL:
|
||||
gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE);
|
||||
if (x1 < 0) x1 = 0;
|
||||
if (x2 > w) x2 = w;
|
||||
switch (guide->orientation)
|
||||
{
|
||||
case ORIENTATION_HORIZONTAL:
|
||||
gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE);
|
||||
if (x1 < 0) x1 = 0;
|
||||
if (x2 > w) x2 = w;
|
||||
|
||||
gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y);
|
||||
break;
|
||||
case ORIENTATION_VERTICAL:
|
||||
gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE);
|
||||
if (y1 < 0) y1 = 0;
|
||||
if (y2 > h) y2 = h;
|
||||
gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y);
|
||||
break;
|
||||
|
||||
gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2);
|
||||
break;
|
||||
default:
|
||||
g_warning ("mdg / BAD FALLTHROUGH");
|
||||
}
|
||||
case ORIENTATION_VERTICAL:
|
||||
gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE);
|
||||
if (y1 < 0) y1 = 0;
|
||||
if (y2 > h) y2 = h;
|
||||
|
||||
gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("mdg / BAD FALLTHROUGH");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -183,11 +192,11 @@ move_tool_button_release (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
MoveTool * move;
|
||||
GDisplay * gdisp;
|
||||
int delete_guide;
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
MoveTool *move;
|
||||
GDisplay *gdisp;
|
||||
gboolean delete_guide;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
move = (MoveTool *) tool->private;
|
||||
|
@ -203,11 +212,12 @@ move_tool_button_release (Tool *tool,
|
|||
|
||||
delete_guide = 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 (y1 < 0) y1 = 0;
|
||||
if (x2 > gdisp->gimage->width) x2 = gdisp->gimage->width;
|
||||
if (x2 > gdisp->gimage->width) x2 = gdisp->gimage->width;
|
||||
if (y2 > gdisp->gimage->height) y2 = gdisp->gimage->height;
|
||||
|
||||
switch (move->guide->orientation)
|
||||
|
@ -262,20 +272,20 @@ move_tool_motion (Tool *tool,
|
|||
gpointer gdisp_ptr)
|
||||
|
||||
{
|
||||
MoveTool *move;
|
||||
GDisplay *gdisp;
|
||||
MoveTool *private;
|
||||
int x, y;
|
||||
gint x, y;
|
||||
|
||||
gdisp = gdisp_ptr;
|
||||
private = tool->private;
|
||||
move = (MoveTool *) 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;
|
||||
}
|
||||
|
||||
|
@ -283,13 +293,13 @@ move_tool_motion (Tool *tool,
|
|||
{
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
|
||||
&x, &y, TRUE, FALSE);
|
||||
|
||||
if (private->guide->orientation == ORIENTATION_HORIZONTAL)
|
||||
private->guide->position = y;
|
||||
|
||||
if (move->guide->orientation == ORIENTATION_HORIZONTAL)
|
||||
move->guide->position = y;
|
||||
else
|
||||
private->guide->position = x;
|
||||
move->guide->position = x;
|
||||
|
||||
move_draw_guide (gdisp, private->guide);
|
||||
move_draw_guide (gdisp, move->guide);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -301,21 +311,29 @@ move_tool_cursor_update (Tool *tool,
|
|||
{
|
||||
MoveTool *move;
|
||||
GDisplay *gdisp;
|
||||
Guide *guide;
|
||||
Layer *layer;
|
||||
int x, y;
|
||||
Guide *guide;
|
||||
Layer *layer;
|
||||
gint x, y;
|
||||
|
||||
move = tool->private;
|
||||
move = (MoveTool *) tool->private;
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE);
|
||||
|
||||
if (mevent->state & GDK_MOD1_MASK)
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR);
|
||||
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);
|
||||
}
|
||||
else if (mevent->state & GDK_SHIFT_MASK)
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
{
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
}
|
||||
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;
|
||||
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)))
|
||||
{
|
||||
/* 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);
|
||||
else if (layer == gdisp->gimage->active_layer)
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
|
@ -346,7 +365,9 @@ move_tool_cursor_update (Tool *tool,
|
|||
gdisplay_install_tool_cursor (gdisp, GDK_HAND2);
|
||||
}
|
||||
else
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
|
||||
{
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,19 +408,16 @@ move_create_gc (GDisplay *gdisp)
|
|||
|
||||
values.foreground.pixel = gdisplay_white_pixel (gdisp);
|
||||
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
|
||||
move_tool_start_hguide (Tool *tool,
|
||||
void *data)
|
||||
move_tool_start_hguide (Tool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
MoveTool *private;
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = data;
|
||||
|
||||
selection_pause (gdisp->select);
|
||||
|
||||
|
@ -420,13 +438,10 @@ move_tool_start_hguide (Tool *tool,
|
|||
}
|
||||
|
||||
void
|
||||
move_tool_start_vguide (Tool *tool,
|
||||
void *data)
|
||||
move_tool_start_vguide (Tool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
MoveTool *private;
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = data;
|
||||
|
||||
selection_pause (gdisp->select);
|
||||
|
||||
|
@ -449,8 +464,8 @@ move_tool_start_vguide (Tool *tool,
|
|||
Tool *
|
||||
tools_new_move_tool (void)
|
||||
{
|
||||
Tool * tool;
|
||||
MoveTool * private;
|
||||
Tool *tool;
|
||||
MoveTool *private;
|
||||
|
||||
/* The tool options */
|
||||
if (! move_options)
|
||||
|
@ -464,7 +479,7 @@ tools_new_move_tool (void)
|
|||
|
||||
private->layer = NULL;
|
||||
private->guide = NULL;
|
||||
private->disp = NULL;
|
||||
private->disp = NULL;
|
||||
|
||||
tool->auto_snap_to = FALSE; /* Don't snap to guides */
|
||||
|
||||
|
@ -480,11 +495,10 @@ tools_new_move_tool (void)
|
|||
return tool;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tools_free_move_tool (Tool *tool)
|
||||
{
|
||||
MoveTool * move;
|
||||
MoveTool *move;
|
||||
|
||||
move = (MoveTool *) tool->private;
|
||||
|
||||
|
|
11
app/move.h
11
app/move.h
|
@ -22,10 +22,13 @@
|
|||
|
||||
/* move functions */
|
||||
|
||||
void move_tool_start_hguide (Tool *, void *);
|
||||
void move_tool_start_vguide (Tool *, void *);
|
||||
Tool * tools_new_move_tool (void);
|
||||
void tools_free_move_tool (Tool *);
|
||||
void move_tool_start_hguide (Tool *tool,
|
||||
GDisplay *gdisp);
|
||||
void move_tool_start_vguide (Tool *tool,
|
||||
GDisplay *gdisp);
|
||||
|
||||
Tool * tools_new_move_tool (void);
|
||||
void tools_free_move_tool (Tool *tool);
|
||||
|
||||
|
||||
#endif /* __MOVE_H__ */
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
#include <stdlib.h>
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimage_mask.h"
|
||||
|
@ -39,7 +40,15 @@ static SelectionOptions *rect_options = NULL;
|
|||
|
||||
/* in gimp, ellipses are rectangular, too ;) */
|
||||
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,
|
||||
gint x,
|
||||
|
@ -52,15 +61,15 @@ static void selection_tool_update_op_state (RectSelect *rect_sel,
|
|||
|
||||
void
|
||||
rect_select (GimpImage *gimage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int op,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h,
|
||||
SelectOps op,
|
||||
gboolean feather,
|
||||
gdouble feather_radius)
|
||||
{
|
||||
Channel * new_mask;
|
||||
Channel *new_mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == SELECTION_REPLACE)
|
||||
|
@ -114,14 +123,14 @@ rect_select_button_press (Tool *tool,
|
|||
switch (tool->type)
|
||||
{
|
||||
case RECT_SELECT:
|
||||
rect_sel->fixed_size = rect_options->fixed_size;
|
||||
rect_sel->fixed_width = rect_options->fixed_width;
|
||||
rect_sel->fixed_size = rect_options->fixed_size;
|
||||
rect_sel->fixed_width = rect_options->fixed_width;
|
||||
rect_sel->fixed_height = rect_options->fixed_height;
|
||||
unit = rect_options->fixed_unit;
|
||||
break;
|
||||
case ELLIPSE_SELECT:
|
||||
rect_sel->fixed_size = ellipse_options->fixed_size;
|
||||
rect_sel->fixed_width = ellipse_options->fixed_width;
|
||||
rect_sel->fixed_size = ellipse_options->fixed_size;
|
||||
rect_sel->fixed_width = ellipse_options->fixed_width;
|
||||
rect_sel->fixed_height = ellipse_options->fixed_height;
|
||||
unit = ellipse_options->fixed_unit;
|
||||
break;
|
||||
|
@ -148,7 +157,7 @@ rect_select_button_press (Tool *tool,
|
|||
break;
|
||||
}
|
||||
|
||||
rect_sel->fixed_width = MAX (1, rect_sel->fixed_width);
|
||||
rect_sel->fixed_width = MAX (1, rect_sel->fixed_width);
|
||||
rect_sel->fixed_height = MAX (1, rect_sel->fixed_height);
|
||||
|
||||
rect_sel->w = 0;
|
||||
|
@ -208,9 +217,11 @@ rect_select_button_release (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
RectSelect * rect_sel;
|
||||
GDisplay * gdisp;
|
||||
int x1, y1, x2, y2, w, h;
|
||||
RectSelect *rect_sel;
|
||||
GDisplay *gdisp;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
gint w, h;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
|
@ -279,14 +290,14 @@ rect_select_motion (Tool *tool,
|
|||
GdkEventMotion *mevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
RectSelect * rect_sel;
|
||||
GDisplay * gdisp;
|
||||
gchar size[STATUSBAR_SIZE];
|
||||
int ox, oy;
|
||||
int x, y;
|
||||
int w, h, s;
|
||||
int tw, th;
|
||||
double ratio;
|
||||
RectSelect *rect_sel;
|
||||
GDisplay *gdisp;
|
||||
gchar size[STATUSBAR_SIZE];
|
||||
gint ox, oy;
|
||||
gint x, y;
|
||||
gint w, h, s;
|
||||
gint tw, th;
|
||||
gdouble ratio;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
|
@ -362,14 +373,14 @@ rect_select_motion (Tool *tool,
|
|||
s = MAX (abs (w), abs (h));
|
||||
|
||||
if (w < 0)
|
||||
w = -s;
|
||||
w = -s;
|
||||
else
|
||||
w = s;
|
||||
w = s;
|
||||
|
||||
if (h < 0)
|
||||
h = -s;
|
||||
h = -s;
|
||||
else
|
||||
h = s;
|
||||
h = s;
|
||||
}
|
||||
|
||||
/* If the control key is down, create the selection from the center out */
|
||||
|
@ -441,9 +452,10 @@ rect_select_motion (Tool *tool,
|
|||
void
|
||||
rect_select_draw (Tool *tool)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
RectSelect * rect_sel;
|
||||
int x1, y1, x2, y2;
|
||||
GDisplay *gdisp;
|
||||
RectSelect *rect_sel;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
gdisp = (GDisplay *) tool->gdisp_ptr;
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
|
@ -468,27 +480,50 @@ selection_tool_update_op_state (RectSelect *rect_sel,
|
|||
gint state,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
Layer *layer;
|
||||
Layer *floating_sel;
|
||||
gint tx, ty;
|
||||
|
||||
if (active_tool->state == ACTIVE)
|
||||
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 &&
|
||||
!(layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))))
|
||||
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)) &&
|
||||
gdisplay_mask_value (gdisp, x, y)))
|
||||
rect_sel->op = SELECTION_MOVE; /* move the selection */
|
||||
!gimage_mask_is_empty (gdisp->gimage))
|
||||
{
|
||||
rect_sel->op = SELECTION_MOVE_MASK; /* move just the selection mask */
|
||||
}
|
||||
else if (!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
|
||||
layer &&
|
||||
(layer == floating_sel ||
|
||||
(gdisplay_mask_value (gdisp, x, y) &&
|
||||
!floating_sel)))
|
||||
{
|
||||
rect_sel->op = SELECTION_MOVE; /* move the selection */
|
||||
}
|
||||
else if ((state & GDK_SHIFT_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) &&
|
||||
!(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) &&
|
||||
(state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */
|
||||
{
|
||||
rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */
|
||||
}
|
||||
else
|
||||
rect_sel->op = SELECTION_REPLACE; /* replace the selection */
|
||||
{
|
||||
rect_sel->op = SELECTION_REPLACE; /* replace the selection */
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -548,12 +583,11 @@ rect_select_cursor_update (Tool *tool,
|
|||
GdkEventMotion *mevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
int active;
|
||||
RectSelect *rect_sel;
|
||||
GDisplay *gdisp;
|
||||
gdisp = (GDisplay *)gdisp_ptr;
|
||||
active = (active_tool->state == ACTIVE);
|
||||
rect_sel = (RectSelect*)tool->private;
|
||||
GDisplay *gdisp;
|
||||
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
|
@ -574,6 +608,7 @@ rect_select_cursor_update (Tool *tool,
|
|||
break;
|
||||
case SELECTION_MOVE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -582,21 +617,21 @@ rect_select_control (Tool *tool,
|
|||
ToolAction action,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
RectSelect * rect_sel;
|
||||
RectSelect *rect_sel;
|
||||
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case PAUSE :
|
||||
case PAUSE:
|
||||
draw_core_pause (rect_sel->core, tool);
|
||||
break;
|
||||
|
||||
case RESUME :
|
||||
case RESUME:
|
||||
draw_core_resume (rect_sel->core, tool);
|
||||
break;
|
||||
|
||||
case HALT :
|
||||
case HALT:
|
||||
draw_core_stop (rect_sel->core, tool);
|
||||
break;
|
||||
|
||||
|
@ -606,13 +641,13 @@ rect_select_control (Tool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
rect_select_options_reset ()
|
||||
rect_select_options_reset (void)
|
||||
{
|
||||
selection_options_reset (rect_options);
|
||||
}
|
||||
|
||||
Tool *
|
||||
tools_new_rect_select ()
|
||||
tools_new_rect_select (void)
|
||||
{
|
||||
Tool * tool;
|
||||
RectSelect * private;
|
||||
|
|
|
@ -31,11 +31,17 @@ void rect_select_oper_update (Tool *, GdkEventMotion *, gpointer);
|
|||
void rect_select_control (Tool *, ToolAction, gpointer);
|
||||
|
||||
/* rect select functions */
|
||||
void rect_select_draw (Tool *);
|
||||
void rect_select (GimpImage *, int, int, int, int, int, int,
|
||||
double);
|
||||
void rect_select_draw (Tool *tool);
|
||||
void rect_select (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint g,
|
||||
SelectOps op,
|
||||
gboolean feather,
|
||||
gdouble feather_radius);
|
||||
|
||||
Tool * tools_new_rect_select (void);
|
||||
void tools_free_rect_select (Tool *);
|
||||
Tool * tools_new_rect_select (void);
|
||||
void tools_free_rect_select (Tool *tool);
|
||||
|
||||
#endif /* __RECT_SELECT_H__ */
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
|
||||
#include "toolsF.h"
|
||||
|
||||
typedef struct _bezier_point BezierPoint;
|
||||
typedef struct _bezier_select BezierSelect;
|
||||
typedef struct _BezierPoint BezierPoint;
|
||||
typedef struct _BezierSelect BezierSelect;
|
||||
|
||||
/* bezier select functions */
|
||||
|
||||
void bezier_select_dialog (void);
|
||||
Tool * tools_new_bezier_select (void);
|
||||
void tools_free_bezier_select (Tool *);
|
||||
gboolean bezier_tool_selected (void);
|
||||
Tool * tools_new_bezier_select (void);
|
||||
void tools_free_bezier_select (Tool *tool);
|
||||
|
||||
gboolean bezier_tool_selected (void);
|
||||
|
||||
#endif /* __BEZIER_SELECT_H__ */
|
||||
|
|
|
@ -37,57 +37,76 @@
|
|||
|
||||
enum { EXTEND_EDIT, EXTEND_ADD, EXTEND_REMOVE, EXTEND_NEW };
|
||||
|
||||
struct _bezier_point
|
||||
struct _BezierPoint
|
||||
{
|
||||
int type; /* type of point (anchor/control/move) */
|
||||
double x, y; /* location of point in image space */
|
||||
int sx, sy; /* location of point in screen space */
|
||||
gint type; /* type of point (anchor/control/move) */
|
||||
gdouble x, y; /* location of point in image space */
|
||||
gint sx, sy; /* location of point in screen space */
|
||||
BezierPoint *next; /* next point on curve */
|
||||
BezierPoint *prev; /* prev point on curve */
|
||||
BezierPoint *next_curve; /* Next curve segment */
|
||||
gint pointflags; /* Status of point 0 = not selected
|
||||
gint pointflags; /* Status of point 0 = not selected
|
||||
* 1 = selected
|
||||
*/
|
||||
};
|
||||
|
||||
struct _bezier_select
|
||||
struct _BezierSelect
|
||||
{
|
||||
int state; /* start, add, edit or drag */
|
||||
int draw; /* all or part */
|
||||
int closed; /* is the last curve closed */
|
||||
DrawCore *core; /* Core drawing object */
|
||||
BezierPoint *points; /* the curve */
|
||||
BezierPoint *cur_anchor; /* the current active anchor point */
|
||||
BezierPoint *cur_control; /* the current active control point */
|
||||
BezierPoint *last_point; /* the last point on the curve */
|
||||
int num_points; /* number of points in the curve */
|
||||
Channel *mask; /* null if the curve is open */
|
||||
GSList **scanlines; /* used in converting a curve */
|
||||
gint state; /* start, add, edit or drag */
|
||||
gint draw; /* all or part */
|
||||
gint closed; /* is the last curve closed */
|
||||
DrawCore *core; /* Core drawing object */
|
||||
BezierPoint *points; /* the curve */
|
||||
BezierPoint *cur_anchor; /* the current active anchor point */
|
||||
BezierPoint *cur_control; /* the current active control point */
|
||||
BezierPoint *last_point; /* the last point on the curve */
|
||||
gint num_points; /* number of points in the curve */
|
||||
Channel *mask; /* null if the curve is open */
|
||||
GSList **scanlines; /* used in converting a curve */
|
||||
};
|
||||
|
||||
/* All udata that are passed to the bezier_draw_curve must
|
||||
* have this structure as the first element.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
gint count;
|
||||
} CountCurves;
|
||||
|
||||
typedef void (*BezierPointsFunc) (BezierSelect *, GdkPoint *, int,gpointer);
|
||||
typedef void (* BezierPointsFunc) (BezierSelect *, GdkPoint *, int,gpointer);
|
||||
|
||||
/* Functions */
|
||||
int bezier_select_load (void *, BezierPoint *, int, int);
|
||||
void bezier_draw_curve (BezierSelect *,BezierPointsFunc, int,gpointer);
|
||||
void bezier_select_reset (BezierSelect *);
|
||||
int bezier_select_load (void *,
|
||||
BezierPoint *,
|
||||
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_add_point (BezierSelect *, int, gdouble, gdouble);
|
||||
void bezier_paste_bezierselect_to_current (GDisplay *,BezierSelect *);
|
||||
void bezier_add_point (BezierSelect *,
|
||||
gint,
|
||||
gdouble,
|
||||
gdouble);
|
||||
void bezier_paste_bezierselect_to_current (GDisplay *gdisp,
|
||||
BezierSelect *bezier_sel);
|
||||
void bezier_select_mode (gint);
|
||||
void bezier_stroke (BezierSelect *, GDisplay *, int, int);
|
||||
void bezier_to_selection (BezierSelect *, GDisplay *);
|
||||
gint bezier_distance_along (BezierSelect *, gint, gdouble,gint *,gint *,gdouble *);
|
||||
void bezier_draw (GDisplay *,BezierSelect *);
|
||||
void bezier_stroke (BezierSelect *bezier_sel,
|
||||
GDisplay *gdisp,
|
||||
gint,
|
||||
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__ */
|
||||
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ typedef struct _ByColorSelect ByColorSelect;
|
|||
|
||||
struct _ByColorSelect
|
||||
{
|
||||
gint x, y; /* Point from which to execute seed fill */
|
||||
gint operation; /* add, subtract, normal color selection */
|
||||
gint x, y; /* Point from which to execute seed fill */
|
||||
SelectOps operation; /* add, subtract, normal color selection */
|
||||
};
|
||||
|
||||
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) /
|
||||
sizeof (by_color_select_targets[0]));
|
||||
|
||||
static void by_color_select_color_drop (GtkWidget *, guchar, guchar, guchar,
|
||||
gpointer);
|
||||
static void by_color_select_color_drop (GtkWidget *widget,
|
||||
guchar r,
|
||||
guchar g,
|
||||
guchar b,
|
||||
gpointer data);
|
||||
|
||||
/* 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 *,
|
||||
GdkEventButton *,
|
||||
ByColorDialog *);
|
||||
static void by_color_select_type_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_fuzzy_update (GtkAdjustment *, gpointer);
|
||||
static void by_color_select_preview_button_press (ByColorDialog *,
|
||||
GdkEventButton *);
|
||||
|
||||
|
@ -169,9 +170,9 @@ static Channel *
|
|||
by_color_select_color (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
guchar *color,
|
||||
gint antialias,
|
||||
gboolean antialias,
|
||||
gint threshold,
|
||||
gint sample_merged)
|
||||
gboolean sample_merged)
|
||||
{
|
||||
/* Scan over the gimage's active layer, finding pixels within the specified
|
||||
* threshold from the given R, G, & B values. If antialiasing is on,
|
||||
|
@ -279,11 +280,11 @@ by_color_select (GImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
guchar *color,
|
||||
gint threshold,
|
||||
gint op,
|
||||
gint antialias,
|
||||
gint feather,
|
||||
SelectOps op,
|
||||
gboolean antialias,
|
||||
gboolean feather,
|
||||
gdouble feather_radius,
|
||||
gint sample_merged)
|
||||
gboolean sample_merged)
|
||||
{
|
||||
Channel *new_mask;
|
||||
gint off_x, off_y;
|
||||
|
@ -295,7 +296,7 @@ by_color_select (GImage *gimage,
|
|||
antialias, threshold, sample_merged);
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == REPLACE)
|
||||
if (op == SELECTION_REPLACE)
|
||||
gimage_mask_clear (gimage);
|
||||
else
|
||||
gimage_mask_undo (gimage);
|
||||
|
@ -454,30 +455,30 @@ by_color_select_cursor_update (Tool *tool,
|
|||
if (by_color_options->sample_merged ||
|
||||
((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y)) &&
|
||||
layer == gdisp->gimage->active_layer))
|
||||
{
|
||||
switch (by_col_sel->operation)
|
||||
{
|
||||
case SELECTION_ADD:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_ADD_CURSOR);
|
||||
break;
|
||||
case SELECTION_SUB:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_SUBTRACT_CURSOR);
|
||||
break;
|
||||
case SELECTION_INTERSECT:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_INTERSECT_CURSOR);
|
||||
break;
|
||||
case SELECTION_REPLACE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
break;
|
||||
case SELECTION_MOVE_MASK:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR);
|
||||
break;
|
||||
case SELECTION_MOVE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
}
|
||||
{
|
||||
switch (by_col_sel->operation)
|
||||
{
|
||||
case SELECTION_ADD:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_ADD_CURSOR);
|
||||
break;
|
||||
case SELECTION_SUB:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_SUBTRACT_CURSOR);
|
||||
break;
|
||||
case SELECTION_INTERSECT:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_INTERSECT_CURSOR);
|
||||
break;
|
||||
case SELECTION_REPLACE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
break;
|
||||
case SELECTION_MOVE_MASK:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR);
|
||||
break;
|
||||
case SELECTION_MOVE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_BAD_CURSOR);
|
||||
}
|
||||
|
@ -675,7 +676,7 @@ by_color_select_dialog_new (void)
|
|||
|
||||
bcd = g_new (ByColorDialog, 1);
|
||||
bcd->gimage = NULL;
|
||||
bcd->operation = REPLACE;
|
||||
bcd->operation = SELECTION_REPLACE;
|
||||
bcd->threshold = DEFAULT_FUZZINESS;
|
||||
|
||||
/* The shell and main vbox */
|
||||
|
@ -743,16 +744,15 @@ by_color_select_dialog_new (void)
|
|||
|
||||
/* Create the selection mode radio box */
|
||||
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,
|
||||
(gpointer) SELECTION_REPLACE, NULL, NULL, TRUE,
|
||||
_("Add"), by_color_select_type_callback,
|
||||
(gpointer) SELECTION_ADD, NULL, NULL, FALSE,
|
||||
_("Subtract"), by_color_select_type_callback,
|
||||
(gpointer) SELECTION_SUB, NULL, NULL, FALSE,
|
||||
_("Intersect"), by_color_select_type_callback,
|
||||
(gpointer) SELECTION_INTERSECT, NULL, NULL, FALSE,
|
||||
_("Replace"), (gpointer) SELECTION_REPLACE, NULL,
|
||||
_("Add"), (gpointer) SELECTION_ADD, NULL,
|
||||
_("Subtract"), (gpointer) SELECTION_SUB, NULL,
|
||||
_("Intersect"), (gpointer) SELECTION_INTERSECT, NULL,
|
||||
|
||||
NULL);
|
||||
|
||||
|
@ -776,8 +776,8 @@ by_color_select_dialog_new (void)
|
|||
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (by_color_select_fuzzy_update),
|
||||
bcd);
|
||||
GTK_SIGNAL_FUNC (gimp_int_adjustment_update),
|
||||
&bcd->threshold);
|
||||
|
||||
gtk_widget_show (slider);
|
||||
|
||||
|
@ -800,7 +800,7 @@ by_color_select_render (ByColorDialog *bcd,
|
|||
MaskBuf * scaled_buf = NULL;
|
||||
guchar *buf;
|
||||
PixelRegion srcPR, destPR;
|
||||
guchar * src;
|
||||
guchar *src;
|
||||
gint subsample;
|
||||
gint width, height;
|
||||
gint srcwidth;
|
||||
|
@ -936,14 +936,6 @@ by_color_select_preview_events (GtkWidget *widget,
|
|||
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
|
||||
by_color_select_reset_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
@ -987,26 +979,16 @@ 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
|
||||
by_color_select_preview_button_press (ByColorDialog *bcd,
|
||||
GdkEventButton *bevent)
|
||||
{
|
||||
gint x, y;
|
||||
gint replace, operation;
|
||||
gint x, y;
|
||||
gboolean replace;
|
||||
SelectOps operation;
|
||||
GimpDrawable *drawable;
|
||||
Tile *tile;
|
||||
guchar *col;
|
||||
Tile *tile;
|
||||
guchar *col;
|
||||
|
||||
if (!bcd->gimage)
|
||||
return;
|
||||
|
@ -1019,7 +1001,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
|
|||
|
||||
/* Defaults */
|
||||
replace = FALSE;
|
||||
operation = REPLACE;
|
||||
operation = SELECTION_REPLACE;
|
||||
|
||||
/* Based on modifiers, and the "by color" dialog's selection mode */
|
||||
if ((bevent->state & GDK_SHIFT_MASK) &&
|
||||
|
@ -1049,7 +1031,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
|
|||
}
|
||||
else
|
||||
{
|
||||
int offx, offy;
|
||||
gint offx, offy;
|
||||
|
||||
drawable_offsets (drawable, &offx, &offy);
|
||||
x = drawable_width (drawable) * bevent->x / bcd->preview->requisition.width - offx;
|
||||
|
|
|
@ -32,10 +32,10 @@ void by_color_select (GimpImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
guchar *color,
|
||||
gint threshold,
|
||||
gint op,
|
||||
gint antialias,
|
||||
gint feather,
|
||||
SelectOps op,
|
||||
gboolean antialias,
|
||||
gboolean feather,
|
||||
gdouble feather_radius,
|
||||
gint sample_merged);
|
||||
gboolean sample_merged);
|
||||
|
||||
#endif /* __BY_COLOR_SELECT_H__ */
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "appenv.h"
|
||||
#include "edit_selection.h"
|
||||
#include "ellipse_select.h"
|
||||
|
@ -36,16 +37,16 @@ SelectionOptions * ellipse_options = NULL;
|
|||
|
||||
void
|
||||
ellipse_select (GimpImage *gimage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int op,
|
||||
int antialias,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h,
|
||||
SelectOps op,
|
||||
gboolean antialias,
|
||||
gboolean feather,
|
||||
gdouble feather_radius)
|
||||
{
|
||||
Channel * new_mask;
|
||||
Channel *new_mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == SELECTION_REPLACE)
|
||||
|
@ -74,15 +75,17 @@ ellipse_select (GimpImage *gimage,
|
|||
channel_delete (new_mask);
|
||||
}
|
||||
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
|
||||
ellipse_select_draw (Tool *tool)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
EllipseSelect * ellipse_sel;
|
||||
int x1, y1, x2, y2;
|
||||
GDisplay *gdisp;
|
||||
EllipseSelect *ellipse_sel;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
gdisp = (GDisplay *) tool->gdisp_ptr;
|
||||
ellipse_sel = (EllipseSelect *) tool->private;
|
||||
|
@ -109,7 +112,7 @@ ellipse_select_options_reset (void)
|
|||
Tool *
|
||||
tools_new_ellipse_select (void)
|
||||
{
|
||||
Tool *tool;
|
||||
Tool *tool;
|
||||
EllipseSelect *private;
|
||||
|
||||
/* The tool options */
|
||||
|
|
|
@ -23,11 +23,18 @@
|
|||
|
||||
/* ellipse select functions */
|
||||
|
||||
void ellipse_select_draw (Tool *);
|
||||
void ellipse_select (GimpImage *, int, int, int, int, int,
|
||||
int, int, double);
|
||||
void ellipse_select (GimpImage *gimage,
|
||||
gint x,
|
||||
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);
|
||||
void tools_free_ellipse_select (Tool *);
|
||||
Tool * tools_new_ellipse_select (void);
|
||||
void tools_free_ellipse_select (Tool *tool);
|
||||
|
||||
#endif /* __ELLIPSE_SELECT_H__ */
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "appenv.h"
|
||||
#include "draw_core.h"
|
||||
#include "edit_selection.h"
|
||||
|
@ -39,9 +40,9 @@
|
|||
typedef struct _FreeSelect FreeSelect;
|
||||
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_y; /* (enables immediate cursor updating on modifier
|
||||
|
@ -56,16 +57,16 @@ struct _FreeSelect
|
|||
static SelectionOptions * free_options = NULL;
|
||||
|
||||
/* The global array of XPoints for drawing the polygon... */
|
||||
static GdkPoint * global_pts = NULL;
|
||||
static int max_segs = 0;
|
||||
static GdkPoint *global_pts = NULL;
|
||||
static gint max_segs = 0;
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
static int
|
||||
add_point (int num_pts,
|
||||
int x,
|
||||
int y)
|
||||
static gint
|
||||
add_point (gint num_pts,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
if (num_pts >= max_segs)
|
||||
{
|
||||
|
@ -85,17 +86,17 @@ add_point (int num_pts,
|
|||
|
||||
|
||||
static Channel *
|
||||
scan_convert (GimpImage *gimage,
|
||||
int num_pts,
|
||||
scan_convert (GimpImage *gimage,
|
||||
gint num_pts,
|
||||
ScanConvertPoint *pts,
|
||||
int width,
|
||||
int height,
|
||||
int antialias)
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean antialias)
|
||||
{
|
||||
Channel * mask;
|
||||
Channel *mask;
|
||||
ScanConverter *sc;
|
||||
|
||||
sc = scan_converter_new (width, height, antialias? SUPERSAMPLE : 1);
|
||||
sc = scan_converter_new (width, height, antialias ? SUPERSAMPLE : 1);
|
||||
scan_converter_add_points (sc, num_pts, pts);
|
||||
|
||||
mask = scan_converter_to_channel (sc, gimage);
|
||||
|
@ -109,24 +110,25 @@ scan_convert (GimpImage *gimage,
|
|||
/* Polygonal selection apparatus */
|
||||
|
||||
void
|
||||
free_select (GImage *gimage,
|
||||
int num_pts,
|
||||
free_select (GImage *gimage,
|
||||
gint num_pts,
|
||||
ScanConvertPoint *pts,
|
||||
int op,
|
||||
int antialias,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
SelectOps op,
|
||||
gboolean antialias,
|
||||
gboolean feather,
|
||||
gdouble feather_radius)
|
||||
{
|
||||
Channel *mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
/* or insure that a floating selection is anchored down... */
|
||||
if (op == REPLACE)
|
||||
if (op == SELECTION_REPLACE)
|
||||
gimage_mask_clear (gimage);
|
||||
else
|
||||
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)
|
||||
{
|
||||
|
@ -147,7 +149,7 @@ free_select_button_press (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
GDisplay *gdisp;
|
||||
FreeSelect *free_sel;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
|
@ -163,14 +165,14 @@ free_select_button_press (Tool *tool,
|
|||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
switch (free_sel->op)
|
||||
{
|
||||
case SELECTION_MOVE_MASK:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
case SELECTION_MOVE:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
{
|
||||
case SELECTION_MOVE_MASK:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
case SELECTION_MOVE:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
add_point (0, bevent->x, bevent->y);
|
||||
free_sel->num_pts = 1;
|
||||
|
@ -185,10 +187,10 @@ free_select_button_release (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
FreeSelect *free_sel;
|
||||
FreeSelect *free_sel;
|
||||
ScanConvertPoint *pts;
|
||||
GDisplay *gdisp;
|
||||
int i;
|
||||
GDisplay *gdisp;
|
||||
gint i;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
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 */
|
||||
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++)
|
||||
{
|
||||
|
@ -227,7 +229,7 @@ free_select_motion (Tool *tool,
|
|||
gpointer gdisp_ptr)
|
||||
{
|
||||
FreeSelect *free_sel;
|
||||
GDisplay *gdisp;
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
free_sel = (FreeSelect *) tool->private;
|
||||
|
@ -256,21 +258,21 @@ free_select_control (Tool *tool,
|
|||
ToolAction action,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
FreeSelect * free_sel;
|
||||
FreeSelect *free_sel;
|
||||
|
||||
free_sel = (FreeSelect *) tool->private;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case PAUSE :
|
||||
case PAUSE:
|
||||
draw_core_pause (free_sel->core, tool);
|
||||
break;
|
||||
|
||||
case RESUME :
|
||||
case RESUME:
|
||||
draw_core_resume (free_sel->core, tool);
|
||||
break;
|
||||
|
||||
case HALT :
|
||||
case HALT:
|
||||
draw_core_stop (free_sel->core, tool);
|
||||
break;
|
||||
|
||||
|
@ -282,8 +284,8 @@ free_select_control (Tool *tool,
|
|||
void
|
||||
free_select_draw (Tool *tool)
|
||||
{
|
||||
FreeSelect * free_sel;
|
||||
int i;
|
||||
FreeSelect *free_sel;
|
||||
gint i;
|
||||
|
||||
free_sel = (FreeSelect *) tool->private;
|
||||
|
||||
|
@ -294,7 +296,7 @@ free_select_draw (Tool *tool)
|
|||
}
|
||||
|
||||
static void
|
||||
free_select_options_reset ()
|
||||
free_select_options_reset (void)
|
||||
{
|
||||
selection_options_reset (free_options);
|
||||
}
|
||||
|
@ -302,8 +304,8 @@ free_select_options_reset ()
|
|||
Tool *
|
||||
tools_new_free_select (void)
|
||||
{
|
||||
Tool * tool;
|
||||
FreeSelect * private;
|
||||
Tool *tool;
|
||||
FreeSelect *private;
|
||||
|
||||
/* The tool options */
|
||||
if (!free_options)
|
||||
|
@ -316,9 +318,9 @@ tools_new_free_select (void)
|
|||
tool = tools_new_tool (FREE_SELECT);
|
||||
private = g_new (FreeSelect, 1);
|
||||
|
||||
private->core = draw_core_new (free_select_draw);
|
||||
private->core = draw_core_new (free_select_draw);
|
||||
private->num_pts = 0;
|
||||
private->op = SELECTION_REPLACE;
|
||||
private->op = SELECTION_REPLACE;
|
||||
|
||||
tool->scroll_lock = TRUE; /* Do not allow scrolling */
|
||||
|
||||
|
@ -338,7 +340,7 @@ tools_new_free_select (void)
|
|||
void
|
||||
tools_free_free_select (Tool *tool)
|
||||
{
|
||||
FreeSelect * free_sel;
|
||||
FreeSelect *free_sel;
|
||||
|
||||
free_sel = (FreeSelect *) tool->private;
|
||||
|
||||
|
|
|
@ -21,21 +21,25 @@
|
|||
#include "gimpimageF.h"
|
||||
#include "scan_convert.h"
|
||||
|
||||
void free_select (GimpImage *, int, ScanConvertPoint *, int, int, int,
|
||||
double);
|
||||
|
||||
/* free select action functions */
|
||||
|
||||
void free_select_button_press (Tool *, GdkEventButton *, gpointer);
|
||||
void free_select_button_release (Tool *, GdkEventButton *, gpointer);
|
||||
void free_select_motion (Tool *, GdkEventMotion *, gpointer);
|
||||
void free_select_button_press (Tool *, GdkEventButton *, gpointer);
|
||||
void free_select_button_release (Tool *, GdkEventButton *, gpointer);
|
||||
void free_select_motion (Tool *, GdkEventMotion *, gpointer);
|
||||
|
||||
|
||||
/* free select functions */
|
||||
|
||||
void free_select_dialog (void);
|
||||
void free_select_draw (Tool *);
|
||||
Tool * tools_new_free_select (void);
|
||||
void tools_free_free_select (Tool *);
|
||||
void free_select (GimpImage *gimage,
|
||||
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);
|
||||
void tools_free_free_select (Tool *tool);
|
||||
|
||||
#endif /* __FREE_SELECT_H__ */
|
||||
|
|
|
@ -50,8 +50,8 @@ typedef struct _ByColorSelect ByColorSelect;
|
|||
|
||||
struct _ByColorSelect
|
||||
{
|
||||
gint x, y; /* Point from which to execute seed fill */
|
||||
gint operation; /* add, subtract, normal color selection */
|
||||
gint x, y; /* Point from which to execute seed fill */
|
||||
SelectOps operation; /* add, subtract, normal color selection */
|
||||
};
|
||||
|
||||
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) /
|
||||
sizeof (by_color_select_targets[0]));
|
||||
|
||||
static void by_color_select_color_drop (GtkWidget *, guchar, guchar, guchar,
|
||||
gpointer);
|
||||
static void by_color_select_color_drop (GtkWidget *widget,
|
||||
guchar r,
|
||||
guchar g,
|
||||
guchar b,
|
||||
gpointer data);
|
||||
|
||||
/* 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 *,
|
||||
GdkEventButton *,
|
||||
ByColorDialog *);
|
||||
static void by_color_select_type_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_fuzzy_update (GtkAdjustment *, gpointer);
|
||||
static void by_color_select_preview_button_press (ByColorDialog *,
|
||||
GdkEventButton *);
|
||||
|
||||
|
@ -169,9 +170,9 @@ static Channel *
|
|||
by_color_select_color (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
guchar *color,
|
||||
gint antialias,
|
||||
gboolean antialias,
|
||||
gint threshold,
|
||||
gint sample_merged)
|
||||
gboolean sample_merged)
|
||||
{
|
||||
/* Scan over the gimage's active layer, finding pixels within the specified
|
||||
* threshold from the given R, G, & B values. If antialiasing is on,
|
||||
|
@ -279,11 +280,11 @@ by_color_select (GImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
guchar *color,
|
||||
gint threshold,
|
||||
gint op,
|
||||
gint antialias,
|
||||
gint feather,
|
||||
SelectOps op,
|
||||
gboolean antialias,
|
||||
gboolean feather,
|
||||
gdouble feather_radius,
|
||||
gint sample_merged)
|
||||
gboolean sample_merged)
|
||||
{
|
||||
Channel *new_mask;
|
||||
gint off_x, off_y;
|
||||
|
@ -295,7 +296,7 @@ by_color_select (GImage *gimage,
|
|||
antialias, threshold, sample_merged);
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == REPLACE)
|
||||
if (op == SELECTION_REPLACE)
|
||||
gimage_mask_clear (gimage);
|
||||
else
|
||||
gimage_mask_undo (gimage);
|
||||
|
@ -454,30 +455,30 @@ by_color_select_cursor_update (Tool *tool,
|
|||
if (by_color_options->sample_merged ||
|
||||
((layer = gimage_pick_correlate_layer (gdisp->gimage, x, y)) &&
|
||||
layer == gdisp->gimage->active_layer))
|
||||
{
|
||||
switch (by_col_sel->operation)
|
||||
{
|
||||
case SELECTION_ADD:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_ADD_CURSOR);
|
||||
break;
|
||||
case SELECTION_SUB:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_SUBTRACT_CURSOR);
|
||||
break;
|
||||
case SELECTION_INTERSECT:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_INTERSECT_CURSOR);
|
||||
break;
|
||||
case SELECTION_REPLACE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
break;
|
||||
case SELECTION_MOVE_MASK:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR);
|
||||
break;
|
||||
case SELECTION_MOVE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
}
|
||||
{
|
||||
switch (by_col_sel->operation)
|
||||
{
|
||||
case SELECTION_ADD:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_ADD_CURSOR);
|
||||
break;
|
||||
case SELECTION_SUB:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_SUBTRACT_CURSOR);
|
||||
break;
|
||||
case SELECTION_INTERSECT:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_INTERSECT_CURSOR);
|
||||
break;
|
||||
case SELECTION_REPLACE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
break;
|
||||
case SELECTION_MOVE_MASK:
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR);
|
||||
break;
|
||||
case SELECTION_MOVE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_BAD_CURSOR);
|
||||
}
|
||||
|
@ -675,7 +676,7 @@ by_color_select_dialog_new (void)
|
|||
|
||||
bcd = g_new (ByColorDialog, 1);
|
||||
bcd->gimage = NULL;
|
||||
bcd->operation = REPLACE;
|
||||
bcd->operation = SELECTION_REPLACE;
|
||||
bcd->threshold = DEFAULT_FUZZINESS;
|
||||
|
||||
/* The shell and main vbox */
|
||||
|
@ -743,16 +744,15 @@ by_color_select_dialog_new (void)
|
|||
|
||||
/* Create the selection mode radio box */
|
||||
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,
|
||||
(gpointer) SELECTION_REPLACE, NULL, NULL, TRUE,
|
||||
_("Add"), by_color_select_type_callback,
|
||||
(gpointer) SELECTION_ADD, NULL, NULL, FALSE,
|
||||
_("Subtract"), by_color_select_type_callback,
|
||||
(gpointer) SELECTION_SUB, NULL, NULL, FALSE,
|
||||
_("Intersect"), by_color_select_type_callback,
|
||||
(gpointer) SELECTION_INTERSECT, NULL, NULL, FALSE,
|
||||
_("Replace"), (gpointer) SELECTION_REPLACE, NULL,
|
||||
_("Add"), (gpointer) SELECTION_ADD, NULL,
|
||||
_("Subtract"), (gpointer) SELECTION_SUB, NULL,
|
||||
_("Intersect"), (gpointer) SELECTION_INTERSECT, NULL,
|
||||
|
||||
NULL);
|
||||
|
||||
|
@ -776,8 +776,8 @@ by_color_select_dialog_new (void)
|
|||
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (data), "value_changed",
|
||||
GTK_SIGNAL_FUNC (by_color_select_fuzzy_update),
|
||||
bcd);
|
||||
GTK_SIGNAL_FUNC (gimp_int_adjustment_update),
|
||||
&bcd->threshold);
|
||||
|
||||
gtk_widget_show (slider);
|
||||
|
||||
|
@ -800,7 +800,7 @@ by_color_select_render (ByColorDialog *bcd,
|
|||
MaskBuf * scaled_buf = NULL;
|
||||
guchar *buf;
|
||||
PixelRegion srcPR, destPR;
|
||||
guchar * src;
|
||||
guchar *src;
|
||||
gint subsample;
|
||||
gint width, height;
|
||||
gint srcwidth;
|
||||
|
@ -936,14 +936,6 @@ by_color_select_preview_events (GtkWidget *widget,
|
|||
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
|
||||
by_color_select_reset_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
@ -987,26 +979,16 @@ 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
|
||||
by_color_select_preview_button_press (ByColorDialog *bcd,
|
||||
GdkEventButton *bevent)
|
||||
{
|
||||
gint x, y;
|
||||
gint replace, operation;
|
||||
gint x, y;
|
||||
gboolean replace;
|
||||
SelectOps operation;
|
||||
GimpDrawable *drawable;
|
||||
Tile *tile;
|
||||
guchar *col;
|
||||
Tile *tile;
|
||||
guchar *col;
|
||||
|
||||
if (!bcd->gimage)
|
||||
return;
|
||||
|
@ -1019,7 +1001,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
|
|||
|
||||
/* Defaults */
|
||||
replace = FALSE;
|
||||
operation = REPLACE;
|
||||
operation = SELECTION_REPLACE;
|
||||
|
||||
/* Based on modifiers, and the "by color" dialog's selection mode */
|
||||
if ((bevent->state & GDK_SHIFT_MASK) &&
|
||||
|
@ -1049,7 +1031,7 @@ by_color_select_preview_button_press (ByColorDialog *bcd,
|
|||
}
|
||||
else
|
||||
{
|
||||
int offx, offy;
|
||||
gint offx, offy;
|
||||
|
||||
drawable_offsets (drawable, &offx, &offy);
|
||||
x = drawable_width (drawable) * bevent->x / bcd->preview->requisition.width - offx;
|
||||
|
|
|
@ -32,10 +32,10 @@ void by_color_select (GimpImage *gimage,
|
|||
GimpDrawable *drawable,
|
||||
guchar *color,
|
||||
gint threshold,
|
||||
gint op,
|
||||
gint antialias,
|
||||
gint feather,
|
||||
SelectOps op,
|
||||
gboolean antialias,
|
||||
gboolean feather,
|
||||
gdouble feather_radius,
|
||||
gint sample_merged);
|
||||
gboolean sample_merged);
|
||||
|
||||
#endif /* __BY_COLOR_SELECT_H__ */
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "appenv.h"
|
||||
#include "edit_selection.h"
|
||||
#include "ellipse_select.h"
|
||||
|
@ -36,16 +37,16 @@ SelectionOptions * ellipse_options = NULL;
|
|||
|
||||
void
|
||||
ellipse_select (GimpImage *gimage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int op,
|
||||
int antialias,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h,
|
||||
SelectOps op,
|
||||
gboolean antialias,
|
||||
gboolean feather,
|
||||
gdouble feather_radius)
|
||||
{
|
||||
Channel * new_mask;
|
||||
Channel *new_mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == SELECTION_REPLACE)
|
||||
|
@ -74,15 +75,17 @@ ellipse_select (GimpImage *gimage,
|
|||
channel_delete (new_mask);
|
||||
}
|
||||
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
|
||||
ellipse_select_draw (Tool *tool)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
EllipseSelect * ellipse_sel;
|
||||
int x1, y1, x2, y2;
|
||||
GDisplay *gdisp;
|
||||
EllipseSelect *ellipse_sel;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
gdisp = (GDisplay *) tool->gdisp_ptr;
|
||||
ellipse_sel = (EllipseSelect *) tool->private;
|
||||
|
@ -109,7 +112,7 @@ ellipse_select_options_reset (void)
|
|||
Tool *
|
||||
tools_new_ellipse_select (void)
|
||||
{
|
||||
Tool *tool;
|
||||
Tool *tool;
|
||||
EllipseSelect *private;
|
||||
|
||||
/* The tool options */
|
||||
|
|
|
@ -23,11 +23,18 @@
|
|||
|
||||
/* ellipse select functions */
|
||||
|
||||
void ellipse_select_draw (Tool *);
|
||||
void ellipse_select (GimpImage *, int, int, int, int, int,
|
||||
int, int, double);
|
||||
void ellipse_select (GimpImage *gimage,
|
||||
gint x,
|
||||
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);
|
||||
void tools_free_ellipse_select (Tool *);
|
||||
Tool * tools_new_ellipse_select (void);
|
||||
void tools_free_ellipse_select (Tool *tool);
|
||||
|
||||
#endif /* __ELLIPSE_SELECT_H__ */
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "appenv.h"
|
||||
#include "draw_core.h"
|
||||
#include "edit_selection.h"
|
||||
|
@ -39,9 +40,9 @@
|
|||
typedef struct _FreeSelect FreeSelect;
|
||||
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_y; /* (enables immediate cursor updating on modifier
|
||||
|
@ -56,16 +57,16 @@ struct _FreeSelect
|
|||
static SelectionOptions * free_options = NULL;
|
||||
|
||||
/* The global array of XPoints for drawing the polygon... */
|
||||
static GdkPoint * global_pts = NULL;
|
||||
static int max_segs = 0;
|
||||
static GdkPoint *global_pts = NULL;
|
||||
static gint max_segs = 0;
|
||||
|
||||
|
||||
/* functions */
|
||||
|
||||
static int
|
||||
add_point (int num_pts,
|
||||
int x,
|
||||
int y)
|
||||
static gint
|
||||
add_point (gint num_pts,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
if (num_pts >= max_segs)
|
||||
{
|
||||
|
@ -85,17 +86,17 @@ add_point (int num_pts,
|
|||
|
||||
|
||||
static Channel *
|
||||
scan_convert (GimpImage *gimage,
|
||||
int num_pts,
|
||||
scan_convert (GimpImage *gimage,
|
||||
gint num_pts,
|
||||
ScanConvertPoint *pts,
|
||||
int width,
|
||||
int height,
|
||||
int antialias)
|
||||
gint width,
|
||||
gint height,
|
||||
gboolean antialias)
|
||||
{
|
||||
Channel * mask;
|
||||
Channel *mask;
|
||||
ScanConverter *sc;
|
||||
|
||||
sc = scan_converter_new (width, height, antialias? SUPERSAMPLE : 1);
|
||||
sc = scan_converter_new (width, height, antialias ? SUPERSAMPLE : 1);
|
||||
scan_converter_add_points (sc, num_pts, pts);
|
||||
|
||||
mask = scan_converter_to_channel (sc, gimage);
|
||||
|
@ -109,24 +110,25 @@ scan_convert (GimpImage *gimage,
|
|||
/* Polygonal selection apparatus */
|
||||
|
||||
void
|
||||
free_select (GImage *gimage,
|
||||
int num_pts,
|
||||
free_select (GImage *gimage,
|
||||
gint num_pts,
|
||||
ScanConvertPoint *pts,
|
||||
int op,
|
||||
int antialias,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
SelectOps op,
|
||||
gboolean antialias,
|
||||
gboolean feather,
|
||||
gdouble feather_radius)
|
||||
{
|
||||
Channel *mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
/* or insure that a floating selection is anchored down... */
|
||||
if (op == REPLACE)
|
||||
if (op == SELECTION_REPLACE)
|
||||
gimage_mask_clear (gimage);
|
||||
else
|
||||
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)
|
||||
{
|
||||
|
@ -147,7 +149,7 @@ free_select_button_press (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
GDisplay *gdisp;
|
||||
FreeSelect *free_sel;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
|
@ -163,14 +165,14 @@ free_select_button_press (Tool *tool,
|
|||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
switch (free_sel->op)
|
||||
{
|
||||
case SELECTION_MOVE_MASK:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
case SELECTION_MOVE:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
{
|
||||
case SELECTION_MOVE_MASK:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
case SELECTION_MOVE:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
add_point (0, bevent->x, bevent->y);
|
||||
free_sel->num_pts = 1;
|
||||
|
@ -185,10 +187,10 @@ free_select_button_release (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
FreeSelect *free_sel;
|
||||
FreeSelect *free_sel;
|
||||
ScanConvertPoint *pts;
|
||||
GDisplay *gdisp;
|
||||
int i;
|
||||
GDisplay *gdisp;
|
||||
gint i;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
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 */
|
||||
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++)
|
||||
{
|
||||
|
@ -227,7 +229,7 @@ free_select_motion (Tool *tool,
|
|||
gpointer gdisp_ptr)
|
||||
{
|
||||
FreeSelect *free_sel;
|
||||
GDisplay *gdisp;
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
free_sel = (FreeSelect *) tool->private;
|
||||
|
@ -256,21 +258,21 @@ free_select_control (Tool *tool,
|
|||
ToolAction action,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
FreeSelect * free_sel;
|
||||
FreeSelect *free_sel;
|
||||
|
||||
free_sel = (FreeSelect *) tool->private;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case PAUSE :
|
||||
case PAUSE:
|
||||
draw_core_pause (free_sel->core, tool);
|
||||
break;
|
||||
|
||||
case RESUME :
|
||||
case RESUME:
|
||||
draw_core_resume (free_sel->core, tool);
|
||||
break;
|
||||
|
||||
case HALT :
|
||||
case HALT:
|
||||
draw_core_stop (free_sel->core, tool);
|
||||
break;
|
||||
|
||||
|
@ -282,8 +284,8 @@ free_select_control (Tool *tool,
|
|||
void
|
||||
free_select_draw (Tool *tool)
|
||||
{
|
||||
FreeSelect * free_sel;
|
||||
int i;
|
||||
FreeSelect *free_sel;
|
||||
gint i;
|
||||
|
||||
free_sel = (FreeSelect *) tool->private;
|
||||
|
||||
|
@ -294,7 +296,7 @@ free_select_draw (Tool *tool)
|
|||
}
|
||||
|
||||
static void
|
||||
free_select_options_reset ()
|
||||
free_select_options_reset (void)
|
||||
{
|
||||
selection_options_reset (free_options);
|
||||
}
|
||||
|
@ -302,8 +304,8 @@ free_select_options_reset ()
|
|||
Tool *
|
||||
tools_new_free_select (void)
|
||||
{
|
||||
Tool * tool;
|
||||
FreeSelect * private;
|
||||
Tool *tool;
|
||||
FreeSelect *private;
|
||||
|
||||
/* The tool options */
|
||||
if (!free_options)
|
||||
|
@ -316,9 +318,9 @@ tools_new_free_select (void)
|
|||
tool = tools_new_tool (FREE_SELECT);
|
||||
private = g_new (FreeSelect, 1);
|
||||
|
||||
private->core = draw_core_new (free_select_draw);
|
||||
private->core = draw_core_new (free_select_draw);
|
||||
private->num_pts = 0;
|
||||
private->op = SELECTION_REPLACE;
|
||||
private->op = SELECTION_REPLACE;
|
||||
|
||||
tool->scroll_lock = TRUE; /* Do not allow scrolling */
|
||||
|
||||
|
@ -338,7 +340,7 @@ tools_new_free_select (void)
|
|||
void
|
||||
tools_free_free_select (Tool *tool)
|
||||
{
|
||||
FreeSelect * free_sel;
|
||||
FreeSelect *free_sel;
|
||||
|
||||
free_sel = (FreeSelect *) tool->private;
|
||||
|
||||
|
|
|
@ -21,21 +21,25 @@
|
|||
#include "gimpimageF.h"
|
||||
#include "scan_convert.h"
|
||||
|
||||
void free_select (GimpImage *, int, ScanConvertPoint *, int, int, int,
|
||||
double);
|
||||
|
||||
/* free select action functions */
|
||||
|
||||
void free_select_button_press (Tool *, GdkEventButton *, gpointer);
|
||||
void free_select_button_release (Tool *, GdkEventButton *, gpointer);
|
||||
void free_select_motion (Tool *, GdkEventMotion *, gpointer);
|
||||
void free_select_button_press (Tool *, GdkEventButton *, gpointer);
|
||||
void free_select_button_release (Tool *, GdkEventButton *, gpointer);
|
||||
void free_select_motion (Tool *, GdkEventMotion *, gpointer);
|
||||
|
||||
|
||||
/* free select functions */
|
||||
|
||||
void free_select_dialog (void);
|
||||
void free_select_draw (Tool *);
|
||||
Tool * tools_new_free_select (void);
|
||||
void tools_free_free_select (Tool *);
|
||||
void free_select (GimpImage *gimage,
|
||||
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);
|
||||
void tools_free_free_select (Tool *tool);
|
||||
|
||||
#endif /* __FREE_SELECT_H__ */
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "cursorutil.h"
|
||||
#include "draw_core.h"
|
||||
#include "edit_selection.h"
|
||||
#include "errors.h"
|
||||
#include "floating_sel.h"
|
||||
#include "gimage_mask.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_control (Tool *, ToolAction, gpointer);
|
||||
|
||||
static void move_create_gc (GDisplay *);
|
||||
static void move_create_gc (GDisplay *gdisp);
|
||||
|
||||
|
||||
/* move action functions */
|
||||
|
@ -67,11 +66,11 @@ move_tool_button_press (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
MoveTool * move;
|
||||
Layer * layer;
|
||||
Guide * guide;
|
||||
int x, y;
|
||||
GDisplay *gdisp;
|
||||
MoveTool *move;
|
||||
Layer *layer;
|
||||
Guide *guide;
|
||||
gint x, y;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
move = (MoveTool *) tool->private;
|
||||
|
@ -82,8 +81,9 @@ move_tool_button_press (Tool *tool,
|
|||
move->disp = NULL;
|
||||
|
||||
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);
|
||||
tool->state = ACTIVE;
|
||||
|
@ -95,7 +95,8 @@ move_tool_button_press (Tool *tool,
|
|||
}
|
||||
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);
|
||||
|
||||
|
@ -105,18 +106,23 @@ move_tool_button_press (Tool *tool,
|
|||
gimage_add_guide (gdisp->gimage, guide);
|
||||
|
||||
move->guide = guide;
|
||||
move->disp = gdisp;
|
||||
move->disp = gdisp;
|
||||
|
||||
tool->scroll_lock = TRUE;
|
||||
tool->state = ACTIVE;
|
||||
tool->state = ACTIVE;
|
||||
|
||||
move_tool_motion (tool, NULL, gdisp);
|
||||
}
|
||||
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 (gimage_floating_sel (gdisp->gimage) && !layer_is_floating_sel (layer))
|
||||
move->layer = gimage_floating_sel (gdisp->gimage);
|
||||
/* If there is a floating selection, and this aint it,
|
||||
* use the move tool
|
||||
*/
|
||||
if (gimage_floating_sel (gdisp->gimage) &&
|
||||
!layer_is_floating_sel (layer))
|
||||
{
|
||||
move->layer = gimage_floating_sel (gdisp->gimage);
|
||||
}
|
||||
/* Otherwise, init the edit selection */
|
||||
else
|
||||
{
|
||||
|
@ -131,21 +137,21 @@ move_tool_button_press (Tool *tool,
|
|||
if (tool->state == ACTIVE)
|
||||
{
|
||||
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,
|
||||
NULL, NULL, bevent->time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
move_draw_guide (GDisplay *gdisp,
|
||||
Guide *guide)
|
||||
{
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
int w, h;
|
||||
int x, y;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
gint w, h;
|
||||
gint x, y;
|
||||
|
||||
if (!move_gc)
|
||||
move_create_gc (gdisp);
|
||||
|
@ -158,24 +164,27 @@ move_draw_guide (GDisplay *gdisp,
|
|||
|
||||
gdk_window_get_size (gdisp->canvas->window, &w, &h);
|
||||
|
||||
switch (guide->orientation) {
|
||||
case ORIENTATION_HORIZONTAL:
|
||||
gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE);
|
||||
if (x1 < 0) x1 = 0;
|
||||
if (x2 > w) x2 = w;
|
||||
switch (guide->orientation)
|
||||
{
|
||||
case ORIENTATION_HORIZONTAL:
|
||||
gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE);
|
||||
if (x1 < 0) x1 = 0;
|
||||
if (x2 > w) x2 = w;
|
||||
|
||||
gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y);
|
||||
break;
|
||||
case ORIENTATION_VERTICAL:
|
||||
gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE);
|
||||
if (y1 < 0) y1 = 0;
|
||||
if (y2 > h) y2 = h;
|
||||
gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y);
|
||||
break;
|
||||
|
||||
gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2);
|
||||
break;
|
||||
default:
|
||||
g_warning ("mdg / BAD FALLTHROUGH");
|
||||
}
|
||||
case ORIENTATION_VERTICAL:
|
||||
gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE);
|
||||
if (y1 < 0) y1 = 0;
|
||||
if (y2 > h) y2 = h;
|
||||
|
||||
gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("mdg / BAD FALLTHROUGH");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -183,11 +192,11 @@ move_tool_button_release (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
MoveTool * move;
|
||||
GDisplay * gdisp;
|
||||
int delete_guide;
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
MoveTool *move;
|
||||
GDisplay *gdisp;
|
||||
gboolean delete_guide;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
move = (MoveTool *) tool->private;
|
||||
|
@ -203,11 +212,12 @@ move_tool_button_release (Tool *tool,
|
|||
|
||||
delete_guide = 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 (y1 < 0) y1 = 0;
|
||||
if (x2 > gdisp->gimage->width) x2 = gdisp->gimage->width;
|
||||
if (x2 > gdisp->gimage->width) x2 = gdisp->gimage->width;
|
||||
if (y2 > gdisp->gimage->height) y2 = gdisp->gimage->height;
|
||||
|
||||
switch (move->guide->orientation)
|
||||
|
@ -262,20 +272,20 @@ move_tool_motion (Tool *tool,
|
|||
gpointer gdisp_ptr)
|
||||
|
||||
{
|
||||
MoveTool *move;
|
||||
GDisplay *gdisp;
|
||||
MoveTool *private;
|
||||
int x, y;
|
||||
gint x, y;
|
||||
|
||||
gdisp = gdisp_ptr;
|
||||
private = tool->private;
|
||||
move = (MoveTool *) 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;
|
||||
}
|
||||
|
||||
|
@ -283,13 +293,13 @@ move_tool_motion (Tool *tool,
|
|||
{
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
|
||||
&x, &y, TRUE, FALSE);
|
||||
|
||||
if (private->guide->orientation == ORIENTATION_HORIZONTAL)
|
||||
private->guide->position = y;
|
||||
|
||||
if (move->guide->orientation == ORIENTATION_HORIZONTAL)
|
||||
move->guide->position = y;
|
||||
else
|
||||
private->guide->position = x;
|
||||
move->guide->position = x;
|
||||
|
||||
move_draw_guide (gdisp, private->guide);
|
||||
move_draw_guide (gdisp, move->guide);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -301,21 +311,29 @@ move_tool_cursor_update (Tool *tool,
|
|||
{
|
||||
MoveTool *move;
|
||||
GDisplay *gdisp;
|
||||
Guide *guide;
|
||||
Layer *layer;
|
||||
int x, y;
|
||||
Guide *guide;
|
||||
Layer *layer;
|
||||
gint x, y;
|
||||
|
||||
move = tool->private;
|
||||
move = (MoveTool *) tool->private;
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE);
|
||||
|
||||
if (mevent->state & GDK_MOD1_MASK)
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR);
|
||||
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);
|
||||
}
|
||||
else if (mevent->state & GDK_SHIFT_MASK)
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
{
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
}
|
||||
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;
|
||||
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)))
|
||||
{
|
||||
/* 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);
|
||||
else if (layer == gdisp->gimage->active_layer)
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
|
@ -346,7 +365,9 @@ move_tool_cursor_update (Tool *tool,
|
|||
gdisplay_install_tool_cursor (gdisp, GDK_HAND2);
|
||||
}
|
||||
else
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
|
||||
{
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,19 +408,16 @@ move_create_gc (GDisplay *gdisp)
|
|||
|
||||
values.foreground.pixel = gdisplay_white_pixel (gdisp);
|
||||
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
|
||||
move_tool_start_hguide (Tool *tool,
|
||||
void *data)
|
||||
move_tool_start_hguide (Tool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
MoveTool *private;
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = data;
|
||||
|
||||
selection_pause (gdisp->select);
|
||||
|
||||
|
@ -420,13 +438,10 @@ move_tool_start_hguide (Tool *tool,
|
|||
}
|
||||
|
||||
void
|
||||
move_tool_start_vguide (Tool *tool,
|
||||
void *data)
|
||||
move_tool_start_vguide (Tool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
MoveTool *private;
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = data;
|
||||
|
||||
selection_pause (gdisp->select);
|
||||
|
||||
|
@ -449,8 +464,8 @@ move_tool_start_vguide (Tool *tool,
|
|||
Tool *
|
||||
tools_new_move_tool (void)
|
||||
{
|
||||
Tool * tool;
|
||||
MoveTool * private;
|
||||
Tool *tool;
|
||||
MoveTool *private;
|
||||
|
||||
/* The tool options */
|
||||
if (! move_options)
|
||||
|
@ -464,7 +479,7 @@ tools_new_move_tool (void)
|
|||
|
||||
private->layer = NULL;
|
||||
private->guide = NULL;
|
||||
private->disp = NULL;
|
||||
private->disp = NULL;
|
||||
|
||||
tool->auto_snap_to = FALSE; /* Don't snap to guides */
|
||||
|
||||
|
@ -480,11 +495,10 @@ tools_new_move_tool (void)
|
|||
return tool;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tools_free_move_tool (Tool *tool)
|
||||
{
|
||||
MoveTool * move;
|
||||
MoveTool *move;
|
||||
|
||||
move = (MoveTool *) tool->private;
|
||||
|
||||
|
|
|
@ -22,10 +22,13 @@
|
|||
|
||||
/* move functions */
|
||||
|
||||
void move_tool_start_hguide (Tool *, void *);
|
||||
void move_tool_start_vguide (Tool *, void *);
|
||||
Tool * tools_new_move_tool (void);
|
||||
void tools_free_move_tool (Tool *);
|
||||
void move_tool_start_hguide (Tool *tool,
|
||||
GDisplay *gdisp);
|
||||
void move_tool_start_vguide (Tool *tool,
|
||||
GDisplay *gdisp);
|
||||
|
||||
Tool * tools_new_move_tool (void);
|
||||
void tools_free_move_tool (Tool *tool);
|
||||
|
||||
|
||||
#endif /* __MOVE_H__ */
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
#include <stdlib.h>
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimage_mask.h"
|
||||
|
@ -39,7 +40,15 @@ static SelectionOptions *rect_options = NULL;
|
|||
|
||||
/* in gimp, ellipses are rectangular, too ;) */
|
||||
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,
|
||||
gint x,
|
||||
|
@ -52,15 +61,15 @@ static void selection_tool_update_op_state (RectSelect *rect_sel,
|
|||
|
||||
void
|
||||
rect_select (GimpImage *gimage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int op,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h,
|
||||
SelectOps op,
|
||||
gboolean feather,
|
||||
gdouble feather_radius)
|
||||
{
|
||||
Channel * new_mask;
|
||||
Channel *new_mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == SELECTION_REPLACE)
|
||||
|
@ -114,14 +123,14 @@ rect_select_button_press (Tool *tool,
|
|||
switch (tool->type)
|
||||
{
|
||||
case RECT_SELECT:
|
||||
rect_sel->fixed_size = rect_options->fixed_size;
|
||||
rect_sel->fixed_width = rect_options->fixed_width;
|
||||
rect_sel->fixed_size = rect_options->fixed_size;
|
||||
rect_sel->fixed_width = rect_options->fixed_width;
|
||||
rect_sel->fixed_height = rect_options->fixed_height;
|
||||
unit = rect_options->fixed_unit;
|
||||
break;
|
||||
case ELLIPSE_SELECT:
|
||||
rect_sel->fixed_size = ellipse_options->fixed_size;
|
||||
rect_sel->fixed_width = ellipse_options->fixed_width;
|
||||
rect_sel->fixed_size = ellipse_options->fixed_size;
|
||||
rect_sel->fixed_width = ellipse_options->fixed_width;
|
||||
rect_sel->fixed_height = ellipse_options->fixed_height;
|
||||
unit = ellipse_options->fixed_unit;
|
||||
break;
|
||||
|
@ -148,7 +157,7 @@ rect_select_button_press (Tool *tool,
|
|||
break;
|
||||
}
|
||||
|
||||
rect_sel->fixed_width = MAX (1, rect_sel->fixed_width);
|
||||
rect_sel->fixed_width = MAX (1, rect_sel->fixed_width);
|
||||
rect_sel->fixed_height = MAX (1, rect_sel->fixed_height);
|
||||
|
||||
rect_sel->w = 0;
|
||||
|
@ -208,9 +217,11 @@ rect_select_button_release (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
RectSelect * rect_sel;
|
||||
GDisplay * gdisp;
|
||||
int x1, y1, x2, y2, w, h;
|
||||
RectSelect *rect_sel;
|
||||
GDisplay *gdisp;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
gint w, h;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
|
@ -279,14 +290,14 @@ rect_select_motion (Tool *tool,
|
|||
GdkEventMotion *mevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
RectSelect * rect_sel;
|
||||
GDisplay * gdisp;
|
||||
gchar size[STATUSBAR_SIZE];
|
||||
int ox, oy;
|
||||
int x, y;
|
||||
int w, h, s;
|
||||
int tw, th;
|
||||
double ratio;
|
||||
RectSelect *rect_sel;
|
||||
GDisplay *gdisp;
|
||||
gchar size[STATUSBAR_SIZE];
|
||||
gint ox, oy;
|
||||
gint x, y;
|
||||
gint w, h, s;
|
||||
gint tw, th;
|
||||
gdouble ratio;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
|
@ -362,14 +373,14 @@ rect_select_motion (Tool *tool,
|
|||
s = MAX (abs (w), abs (h));
|
||||
|
||||
if (w < 0)
|
||||
w = -s;
|
||||
w = -s;
|
||||
else
|
||||
w = s;
|
||||
w = s;
|
||||
|
||||
if (h < 0)
|
||||
h = -s;
|
||||
h = -s;
|
||||
else
|
||||
h = s;
|
||||
h = s;
|
||||
}
|
||||
|
||||
/* If the control key is down, create the selection from the center out */
|
||||
|
@ -441,9 +452,10 @@ rect_select_motion (Tool *tool,
|
|||
void
|
||||
rect_select_draw (Tool *tool)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
RectSelect * rect_sel;
|
||||
int x1, y1, x2, y2;
|
||||
GDisplay *gdisp;
|
||||
RectSelect *rect_sel;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
gdisp = (GDisplay *) tool->gdisp_ptr;
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
|
@ -468,27 +480,50 @@ selection_tool_update_op_state (RectSelect *rect_sel,
|
|||
gint state,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
Layer *layer;
|
||||
Layer *floating_sel;
|
||||
gint tx, ty;
|
||||
|
||||
if (active_tool->state == ACTIVE)
|
||||
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 &&
|
||||
!(layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))))
|
||||
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)) &&
|
||||
gdisplay_mask_value (gdisp, x, y)))
|
||||
rect_sel->op = SELECTION_MOVE; /* move the selection */
|
||||
!gimage_mask_is_empty (gdisp->gimage))
|
||||
{
|
||||
rect_sel->op = SELECTION_MOVE_MASK; /* move just the selection mask */
|
||||
}
|
||||
else if (!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
|
||||
layer &&
|
||||
(layer == floating_sel ||
|
||||
(gdisplay_mask_value (gdisp, x, y) &&
|
||||
!floating_sel)))
|
||||
{
|
||||
rect_sel->op = SELECTION_MOVE; /* move the selection */
|
||||
}
|
||||
else if ((state & GDK_SHIFT_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) &&
|
||||
!(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) &&
|
||||
(state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */
|
||||
{
|
||||
rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */
|
||||
}
|
||||
else
|
||||
rect_sel->op = SELECTION_REPLACE; /* replace the selection */
|
||||
{
|
||||
rect_sel->op = SELECTION_REPLACE; /* replace the selection */
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -548,12 +583,11 @@ rect_select_cursor_update (Tool *tool,
|
|||
GdkEventMotion *mevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
int active;
|
||||
RectSelect *rect_sel;
|
||||
GDisplay *gdisp;
|
||||
gdisp = (GDisplay *)gdisp_ptr;
|
||||
active = (active_tool->state == ACTIVE);
|
||||
rect_sel = (RectSelect*)tool->private;
|
||||
GDisplay *gdisp;
|
||||
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
|
@ -574,6 +608,7 @@ rect_select_cursor_update (Tool *tool,
|
|||
break;
|
||||
case SELECTION_MOVE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -582,21 +617,21 @@ rect_select_control (Tool *tool,
|
|||
ToolAction action,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
RectSelect * rect_sel;
|
||||
RectSelect *rect_sel;
|
||||
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case PAUSE :
|
||||
case PAUSE:
|
||||
draw_core_pause (rect_sel->core, tool);
|
||||
break;
|
||||
|
||||
case RESUME :
|
||||
case RESUME:
|
||||
draw_core_resume (rect_sel->core, tool);
|
||||
break;
|
||||
|
||||
case HALT :
|
||||
case HALT:
|
||||
draw_core_stop (rect_sel->core, tool);
|
||||
break;
|
||||
|
||||
|
@ -606,13 +641,13 @@ rect_select_control (Tool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
rect_select_options_reset ()
|
||||
rect_select_options_reset (void)
|
||||
{
|
||||
selection_options_reset (rect_options);
|
||||
}
|
||||
|
||||
Tool *
|
||||
tools_new_rect_select ()
|
||||
tools_new_rect_select (void)
|
||||
{
|
||||
Tool * tool;
|
||||
RectSelect * private;
|
||||
|
|
|
@ -31,11 +31,17 @@ void rect_select_oper_update (Tool *, GdkEventMotion *, gpointer);
|
|||
void rect_select_control (Tool *, ToolAction, gpointer);
|
||||
|
||||
/* rect select functions */
|
||||
void rect_select_draw (Tool *);
|
||||
void rect_select (GimpImage *, int, int, int, int, int, int,
|
||||
double);
|
||||
void rect_select_draw (Tool *tool);
|
||||
void rect_select (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint g,
|
||||
SelectOps op,
|
||||
gboolean feather,
|
||||
gdouble feather_radius);
|
||||
|
||||
Tool * tools_new_rect_select (void);
|
||||
void tools_free_rect_select (Tool *);
|
||||
Tool * tools_new_rect_select (void);
|
||||
void tools_free_rect_select (Tool *tool);
|
||||
|
||||
#endif /* __RECT_SELECT_H__ */
|
||||
|
|
184
app/tools/move.c
184
app/tools/move.c
|
@ -21,7 +21,6 @@
|
|||
#include "cursorutil.h"
|
||||
#include "draw_core.h"
|
||||
#include "edit_selection.h"
|
||||
#include "errors.h"
|
||||
#include "floating_sel.h"
|
||||
#include "gimage_mask.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_control (Tool *, ToolAction, gpointer);
|
||||
|
||||
static void move_create_gc (GDisplay *);
|
||||
static void move_create_gc (GDisplay *gdisp);
|
||||
|
||||
|
||||
/* move action functions */
|
||||
|
@ -67,11 +66,11 @@ move_tool_button_press (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
MoveTool * move;
|
||||
Layer * layer;
|
||||
Guide * guide;
|
||||
int x, y;
|
||||
GDisplay *gdisp;
|
||||
MoveTool *move;
|
||||
Layer *layer;
|
||||
Guide *guide;
|
||||
gint x, y;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
move = (MoveTool *) tool->private;
|
||||
|
@ -82,8 +81,9 @@ move_tool_button_press (Tool *tool,
|
|||
move->disp = NULL;
|
||||
|
||||
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);
|
||||
tool->state = ACTIVE;
|
||||
|
@ -95,7 +95,8 @@ move_tool_button_press (Tool *tool,
|
|||
}
|
||||
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);
|
||||
|
||||
|
@ -105,18 +106,23 @@ move_tool_button_press (Tool *tool,
|
|||
gimage_add_guide (gdisp->gimage, guide);
|
||||
|
||||
move->guide = guide;
|
||||
move->disp = gdisp;
|
||||
move->disp = gdisp;
|
||||
|
||||
tool->scroll_lock = TRUE;
|
||||
tool->state = ACTIVE;
|
||||
tool->state = ACTIVE;
|
||||
|
||||
move_tool_motion (tool, NULL, gdisp);
|
||||
}
|
||||
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 (gimage_floating_sel (gdisp->gimage) && !layer_is_floating_sel (layer))
|
||||
move->layer = gimage_floating_sel (gdisp->gimage);
|
||||
/* If there is a floating selection, and this aint it,
|
||||
* use the move tool
|
||||
*/
|
||||
if (gimage_floating_sel (gdisp->gimage) &&
|
||||
!layer_is_floating_sel (layer))
|
||||
{
|
||||
move->layer = gimage_floating_sel (gdisp->gimage);
|
||||
}
|
||||
/* Otherwise, init the edit selection */
|
||||
else
|
||||
{
|
||||
|
@ -131,21 +137,21 @@ move_tool_button_press (Tool *tool,
|
|||
if (tool->state == ACTIVE)
|
||||
{
|
||||
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,
|
||||
NULL, NULL, bevent->time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
move_draw_guide (GDisplay *gdisp,
|
||||
Guide *guide)
|
||||
{
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
int w, h;
|
||||
int x, y;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
gint w, h;
|
||||
gint x, y;
|
||||
|
||||
if (!move_gc)
|
||||
move_create_gc (gdisp);
|
||||
|
@ -158,24 +164,27 @@ move_draw_guide (GDisplay *gdisp,
|
|||
|
||||
gdk_window_get_size (gdisp->canvas->window, &w, &h);
|
||||
|
||||
switch (guide->orientation) {
|
||||
case ORIENTATION_HORIZONTAL:
|
||||
gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE);
|
||||
if (x1 < 0) x1 = 0;
|
||||
if (x2 > w) x2 = w;
|
||||
switch (guide->orientation)
|
||||
{
|
||||
case ORIENTATION_HORIZONTAL:
|
||||
gdisplay_transform_coords (gdisp, 0, guide->position, &x1, &y, FALSE);
|
||||
if (x1 < 0) x1 = 0;
|
||||
if (x2 > w) x2 = w;
|
||||
|
||||
gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y);
|
||||
break;
|
||||
case ORIENTATION_VERTICAL:
|
||||
gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE);
|
||||
if (y1 < 0) y1 = 0;
|
||||
if (y2 > h) y2 = h;
|
||||
gdk_draw_line (gdisp->canvas->window, move_gc, x1, y, x2, y);
|
||||
break;
|
||||
|
||||
gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2);
|
||||
break;
|
||||
default:
|
||||
g_warning ("mdg / BAD FALLTHROUGH");
|
||||
}
|
||||
case ORIENTATION_VERTICAL:
|
||||
gdisplay_transform_coords (gdisp, guide->position, 0, &x, &y1, FALSE);
|
||||
if (y1 < 0) y1 = 0;
|
||||
if (y2 > h) y2 = h;
|
||||
|
||||
gdk_draw_line (gdisp->canvas->window, move_gc, x, y1, x, y2);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("mdg / BAD FALLTHROUGH");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -183,11 +192,11 @@ move_tool_button_release (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
MoveTool * move;
|
||||
GDisplay * gdisp;
|
||||
int delete_guide;
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
MoveTool *move;
|
||||
GDisplay *gdisp;
|
||||
gboolean delete_guide;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
move = (MoveTool *) tool->private;
|
||||
|
@ -203,11 +212,12 @@ move_tool_button_release (Tool *tool,
|
|||
|
||||
delete_guide = 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 (y1 < 0) y1 = 0;
|
||||
if (x2 > gdisp->gimage->width) x2 = gdisp->gimage->width;
|
||||
if (x2 > gdisp->gimage->width) x2 = gdisp->gimage->width;
|
||||
if (y2 > gdisp->gimage->height) y2 = gdisp->gimage->height;
|
||||
|
||||
switch (move->guide->orientation)
|
||||
|
@ -262,20 +272,20 @@ move_tool_motion (Tool *tool,
|
|||
gpointer gdisp_ptr)
|
||||
|
||||
{
|
||||
MoveTool *move;
|
||||
GDisplay *gdisp;
|
||||
MoveTool *private;
|
||||
int x, y;
|
||||
gint x, y;
|
||||
|
||||
gdisp = gdisp_ptr;
|
||||
private = tool->private;
|
||||
move = (MoveTool *) 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;
|
||||
}
|
||||
|
||||
|
@ -283,13 +293,13 @@ move_tool_motion (Tool *tool,
|
|||
{
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
|
||||
&x, &y, TRUE, FALSE);
|
||||
|
||||
if (private->guide->orientation == ORIENTATION_HORIZONTAL)
|
||||
private->guide->position = y;
|
||||
|
||||
if (move->guide->orientation == ORIENTATION_HORIZONTAL)
|
||||
move->guide->position = y;
|
||||
else
|
||||
private->guide->position = x;
|
||||
move->guide->position = x;
|
||||
|
||||
move_draw_guide (gdisp, private->guide);
|
||||
move_draw_guide (gdisp, move->guide);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -301,21 +311,29 @@ move_tool_cursor_update (Tool *tool,
|
|||
{
|
||||
MoveTool *move;
|
||||
GDisplay *gdisp;
|
||||
Guide *guide;
|
||||
Layer *layer;
|
||||
int x, y;
|
||||
Guide *guide;
|
||||
Layer *layer;
|
||||
gint x, y;
|
||||
|
||||
move = tool->private;
|
||||
move = (MoveTool *) tool->private;
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE);
|
||||
|
||||
if (mevent->state & GDK_MOD1_MASK)
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_SELECTION_MOVE_CURSOR);
|
||||
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);
|
||||
}
|
||||
else if (mevent->state & GDK_SHIFT_MASK)
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
{
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
}
|
||||
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;
|
||||
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)))
|
||||
{
|
||||
/* 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);
|
||||
else if (layer == gdisp->gimage->active_layer)
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
|
@ -346,7 +365,9 @@ move_tool_cursor_update (Tool *tool,
|
|||
gdisplay_install_tool_cursor (gdisp, GDK_HAND2);
|
||||
}
|
||||
else
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
|
||||
{
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,19 +408,16 @@ move_create_gc (GDisplay *gdisp)
|
|||
|
||||
values.foreground.pixel = gdisplay_white_pixel (gdisp);
|
||||
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
|
||||
move_tool_start_hguide (Tool *tool,
|
||||
void *data)
|
||||
move_tool_start_hguide (Tool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
MoveTool *private;
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = data;
|
||||
|
||||
selection_pause (gdisp->select);
|
||||
|
||||
|
@ -420,13 +438,10 @@ move_tool_start_hguide (Tool *tool,
|
|||
}
|
||||
|
||||
void
|
||||
move_tool_start_vguide (Tool *tool,
|
||||
void *data)
|
||||
move_tool_start_vguide (Tool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
MoveTool *private;
|
||||
GDisplay *gdisp;
|
||||
|
||||
gdisp = data;
|
||||
|
||||
selection_pause (gdisp->select);
|
||||
|
||||
|
@ -449,8 +464,8 @@ move_tool_start_vguide (Tool *tool,
|
|||
Tool *
|
||||
tools_new_move_tool (void)
|
||||
{
|
||||
Tool * tool;
|
||||
MoveTool * private;
|
||||
Tool *tool;
|
||||
MoveTool *private;
|
||||
|
||||
/* The tool options */
|
||||
if (! move_options)
|
||||
|
@ -464,7 +479,7 @@ tools_new_move_tool (void)
|
|||
|
||||
private->layer = NULL;
|
||||
private->guide = NULL;
|
||||
private->disp = NULL;
|
||||
private->disp = NULL;
|
||||
|
||||
tool->auto_snap_to = FALSE; /* Don't snap to guides */
|
||||
|
||||
|
@ -480,11 +495,10 @@ tools_new_move_tool (void)
|
|||
return tool;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tools_free_move_tool (Tool *tool)
|
||||
{
|
||||
MoveTool * move;
|
||||
MoveTool *move;
|
||||
|
||||
move = (MoveTool *) tool->private;
|
||||
|
||||
|
|
|
@ -22,10 +22,13 @@
|
|||
|
||||
/* move functions */
|
||||
|
||||
void move_tool_start_hguide (Tool *, void *);
|
||||
void move_tool_start_vguide (Tool *, void *);
|
||||
Tool * tools_new_move_tool (void);
|
||||
void tools_free_move_tool (Tool *);
|
||||
void move_tool_start_hguide (Tool *tool,
|
||||
GDisplay *gdisp);
|
||||
void move_tool_start_vguide (Tool *tool,
|
||||
GDisplay *gdisp);
|
||||
|
||||
Tool * tools_new_move_tool (void);
|
||||
void tools_free_move_tool (Tool *tool);
|
||||
|
||||
|
||||
#endif /* __MOVE_H__ */
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
#include <stdlib.h>
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimage_mask.h"
|
||||
|
@ -39,7 +40,15 @@ static SelectionOptions *rect_options = NULL;
|
|||
|
||||
/* in gimp, ellipses are rectangular, too ;) */
|
||||
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,
|
||||
gint x,
|
||||
|
@ -52,15 +61,15 @@ static void selection_tool_update_op_state (RectSelect *rect_sel,
|
|||
|
||||
void
|
||||
rect_select (GimpImage *gimage,
|
||||
int x,
|
||||
int y,
|
||||
int w,
|
||||
int h,
|
||||
int op,
|
||||
int feather,
|
||||
double feather_radius)
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint h,
|
||||
SelectOps op,
|
||||
gboolean feather,
|
||||
gdouble feather_radius)
|
||||
{
|
||||
Channel * new_mask;
|
||||
Channel *new_mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == SELECTION_REPLACE)
|
||||
|
@ -114,14 +123,14 @@ rect_select_button_press (Tool *tool,
|
|||
switch (tool->type)
|
||||
{
|
||||
case RECT_SELECT:
|
||||
rect_sel->fixed_size = rect_options->fixed_size;
|
||||
rect_sel->fixed_width = rect_options->fixed_width;
|
||||
rect_sel->fixed_size = rect_options->fixed_size;
|
||||
rect_sel->fixed_width = rect_options->fixed_width;
|
||||
rect_sel->fixed_height = rect_options->fixed_height;
|
||||
unit = rect_options->fixed_unit;
|
||||
break;
|
||||
case ELLIPSE_SELECT:
|
||||
rect_sel->fixed_size = ellipse_options->fixed_size;
|
||||
rect_sel->fixed_width = ellipse_options->fixed_width;
|
||||
rect_sel->fixed_size = ellipse_options->fixed_size;
|
||||
rect_sel->fixed_width = ellipse_options->fixed_width;
|
||||
rect_sel->fixed_height = ellipse_options->fixed_height;
|
||||
unit = ellipse_options->fixed_unit;
|
||||
break;
|
||||
|
@ -148,7 +157,7 @@ rect_select_button_press (Tool *tool,
|
|||
break;
|
||||
}
|
||||
|
||||
rect_sel->fixed_width = MAX (1, rect_sel->fixed_width);
|
||||
rect_sel->fixed_width = MAX (1, rect_sel->fixed_width);
|
||||
rect_sel->fixed_height = MAX (1, rect_sel->fixed_height);
|
||||
|
||||
rect_sel->w = 0;
|
||||
|
@ -208,9 +217,11 @@ rect_select_button_release (Tool *tool,
|
|||
GdkEventButton *bevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
RectSelect * rect_sel;
|
||||
GDisplay * gdisp;
|
||||
int x1, y1, x2, y2, w, h;
|
||||
RectSelect *rect_sel;
|
||||
GDisplay *gdisp;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
gint w, h;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
|
@ -279,14 +290,14 @@ rect_select_motion (Tool *tool,
|
|||
GdkEventMotion *mevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
RectSelect * rect_sel;
|
||||
GDisplay * gdisp;
|
||||
gchar size[STATUSBAR_SIZE];
|
||||
int ox, oy;
|
||||
int x, y;
|
||||
int w, h, s;
|
||||
int tw, th;
|
||||
double ratio;
|
||||
RectSelect *rect_sel;
|
||||
GDisplay *gdisp;
|
||||
gchar size[STATUSBAR_SIZE];
|
||||
gint ox, oy;
|
||||
gint x, y;
|
||||
gint w, h, s;
|
||||
gint tw, th;
|
||||
gdouble ratio;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
|
@ -362,14 +373,14 @@ rect_select_motion (Tool *tool,
|
|||
s = MAX (abs (w), abs (h));
|
||||
|
||||
if (w < 0)
|
||||
w = -s;
|
||||
w = -s;
|
||||
else
|
||||
w = s;
|
||||
w = s;
|
||||
|
||||
if (h < 0)
|
||||
h = -s;
|
||||
h = -s;
|
||||
else
|
||||
h = s;
|
||||
h = s;
|
||||
}
|
||||
|
||||
/* If the control key is down, create the selection from the center out */
|
||||
|
@ -441,9 +452,10 @@ rect_select_motion (Tool *tool,
|
|||
void
|
||||
rect_select_draw (Tool *tool)
|
||||
{
|
||||
GDisplay * gdisp;
|
||||
RectSelect * rect_sel;
|
||||
int x1, y1, x2, y2;
|
||||
GDisplay *gdisp;
|
||||
RectSelect *rect_sel;
|
||||
gint x1, y1;
|
||||
gint x2, y2;
|
||||
|
||||
gdisp = (GDisplay *) tool->gdisp_ptr;
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
|
@ -468,27 +480,50 @@ selection_tool_update_op_state (RectSelect *rect_sel,
|
|||
gint state,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
Layer *layer;
|
||||
Layer *floating_sel;
|
||||
gint tx, ty;
|
||||
|
||||
if (active_tool->state == ACTIVE)
|
||||
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 &&
|
||||
!(layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))))
|
||||
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)) &&
|
||||
gdisplay_mask_value (gdisp, x, y)))
|
||||
rect_sel->op = SELECTION_MOVE; /* move the selection */
|
||||
!gimage_mask_is_empty (gdisp->gimage))
|
||||
{
|
||||
rect_sel->op = SELECTION_MOVE_MASK; /* move just the selection mask */
|
||||
}
|
||||
else if (!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
|
||||
layer &&
|
||||
(layer == floating_sel ||
|
||||
(gdisplay_mask_value (gdisp, x, y) &&
|
||||
!floating_sel)))
|
||||
{
|
||||
rect_sel->op = SELECTION_MOVE; /* move the selection */
|
||||
}
|
||||
else if ((state & GDK_SHIFT_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) &&
|
||||
!(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) &&
|
||||
(state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */
|
||||
{
|
||||
rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */
|
||||
}
|
||||
else
|
||||
rect_sel->op = SELECTION_REPLACE; /* replace the selection */
|
||||
{
|
||||
rect_sel->op = SELECTION_REPLACE; /* replace the selection */
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -548,12 +583,11 @@ rect_select_cursor_update (Tool *tool,
|
|||
GdkEventMotion *mevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
int active;
|
||||
RectSelect *rect_sel;
|
||||
GDisplay *gdisp;
|
||||
gdisp = (GDisplay *)gdisp_ptr;
|
||||
active = (active_tool->state == ACTIVE);
|
||||
rect_sel = (RectSelect*)tool->private;
|
||||
GDisplay *gdisp;
|
||||
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
|
@ -574,6 +608,7 @@ rect_select_cursor_update (Tool *tool,
|
|||
break;
|
||||
case SELECTION_MOVE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -582,21 +617,21 @@ rect_select_control (Tool *tool,
|
|||
ToolAction action,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
RectSelect * rect_sel;
|
||||
RectSelect *rect_sel;
|
||||
|
||||
rect_sel = (RectSelect *) tool->private;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case PAUSE :
|
||||
case PAUSE:
|
||||
draw_core_pause (rect_sel->core, tool);
|
||||
break;
|
||||
|
||||
case RESUME :
|
||||
case RESUME:
|
||||
draw_core_resume (rect_sel->core, tool);
|
||||
break;
|
||||
|
||||
case HALT :
|
||||
case HALT:
|
||||
draw_core_stop (rect_sel->core, tool);
|
||||
break;
|
||||
|
||||
|
@ -606,13 +641,13 @@ rect_select_control (Tool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
rect_select_options_reset ()
|
||||
rect_select_options_reset (void)
|
||||
{
|
||||
selection_options_reset (rect_options);
|
||||
}
|
||||
|
||||
Tool *
|
||||
tools_new_rect_select ()
|
||||
tools_new_rect_select (void)
|
||||
{
|
||||
Tool * tool;
|
||||
RectSelect * private;
|
||||
|
|
|
@ -31,11 +31,17 @@ void rect_select_oper_update (Tool *, GdkEventMotion *, gpointer);
|
|||
void rect_select_control (Tool *, ToolAction, gpointer);
|
||||
|
||||
/* rect select functions */
|
||||
void rect_select_draw (Tool *);
|
||||
void rect_select (GimpImage *, int, int, int, int, int, int,
|
||||
double);
|
||||
void rect_select_draw (Tool *tool);
|
||||
void rect_select (GimpImage *gimage,
|
||||
gint x,
|
||||
gint y,
|
||||
gint w,
|
||||
gint g,
|
||||
SelectOps op,
|
||||
gboolean feather,
|
||||
gdouble feather_radius);
|
||||
|
||||
Tool * tools_new_rect_select (void);
|
||||
void tools_free_rect_select (Tool *);
|
||||
Tool * tools_new_rect_select (void);
|
||||
void tools_free_rect_select (Tool *tool);
|
||||
|
||||
#endif /* __RECT_SELECT_H__ */
|
||||
|
|
Loading…
Reference in New Issue