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:

committed by
Michael Natterer

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