mirror of https://github.com/GNOME/gimp.git
new bitmap files containing the new mouse cursors.
* pixmaps/mouse1*: new bitmap files containing the new mouse cursors. * app/parasitelist.c: use g_str_equal instead of parasite_compare_func. * app/paint_core.c: interpret perfectmouse right way round. * app/rect_select{P,}.[ch]: set custom cursors when the operation type changes. Centralize the calculation of op based on the modifier keys being held. * app/fuzzy_select.c, app/free_select.c: allow the rect_select functions calculate the operation type. * app/ellipse_select.c: use the SelectionOps typedefs. * app/edit_selection.c: convert MaskToLayerTranslate into FloatingSelTranslate if there is already a floating selection in init_edit_selection. * app/disp_callbacks.c: fixed the calculation of state. * app/gdisplay.[ch], app/cursorutil.[ch]: new functions to allow the loading of customized cursors. * app/paint_funcs.[ch], app/channel.c: border_region now accepts seperate xradius and yradius arguments.
This commit is contained in:
parent
4534223b5b
commit
18835a7657
29
ChangeLog
29
ChangeLog
|
@ -1,3 +1,32 @@
|
|||
1999-05-05 Jay Cox <jaycox@earthlink.net>
|
||||
|
||||
* pixmaps/mouse1*: new bitmap files containing the new mouse cursors.
|
||||
|
||||
* app/parasitelist.c: use g_str_equal instead of parasite_compare_func.
|
||||
|
||||
* app/paint_core.c: interpret perfectmouse right way round.
|
||||
|
||||
* app/rect_select{P,}.[ch]: set custom cursors when the operation type
|
||||
changes. Centralize the calculation of op based on the modifier
|
||||
keys being held.
|
||||
|
||||
* app/fuzzy_select.c, app/free_select.c: allow the rect_select
|
||||
functions calculate the operation type.
|
||||
|
||||
* app/ellipse_select.c: use the SelectionOps typedefs.
|
||||
|
||||
* app/edit_selection.c: convert MaskToLayerTranslate into
|
||||
FloatingSelTranslate if there is already a floating selection in
|
||||
init_edit_selection.
|
||||
|
||||
* app/disp_callbacks.c: fixed the calculation of state.
|
||||
|
||||
* app/gdisplay.[ch], app/cursorutil.[ch]: new functions to allow
|
||||
the loading of customized cursors.
|
||||
|
||||
* app/paint_funcs.[ch], app/channel.c: border_region now accepts
|
||||
seperate xradius and yradius arguments.
|
||||
|
||||
Tue May 4 15:51:16 PDT 1999 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* configure.in: use the sinclude bit again, since it works in
|
||||
|
|
|
@ -1308,7 +1308,7 @@ channel_border (Channel *mask, int radius)
|
|||
pixel_region_init (&bPR, GIMP_DRAWABLE(mask)->tiles, x1, y1,
|
||||
(x2-x1), (y2-y1), TRUE);
|
||||
|
||||
border_region(&bPR, radius);
|
||||
border_region(&bPR, radius, radius);
|
||||
|
||||
mask->bounds_known = FALSE;
|
||||
}
|
||||
|
|
|
@ -1308,7 +1308,7 @@ channel_border (Channel *mask, int radius)
|
|||
pixel_region_init (&bPR, GIMP_DRAWABLE(mask)->tiles, x1, y1,
|
||||
(x2-x1), (y2-y1), TRUE);
|
||||
|
||||
border_region(&bPR, radius);
|
||||
border_region(&bPR, radius, radius);
|
||||
|
||||
mask->bounds_known = FALSE;
|
||||
}
|
||||
|
|
|
@ -1308,7 +1308,7 @@ channel_border (Channel *mask, int radius)
|
|||
pixel_region_init (&bPR, GIMP_DRAWABLE(mask)->tiles, x1, y1,
|
||||
(x2-x1), (y2-y1), TRUE);
|
||||
|
||||
border_region(&bPR, radius);
|
||||
border_region(&bPR, radius, radius);
|
||||
|
||||
mask->bounds_known = FALSE;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ static guint parasite_list_signals[LAST_SIGNAL];
|
|||
static void parasite_list_destroy (GtkObject* list);
|
||||
static void parasite_list_init (ParasiteList* list);
|
||||
static void parasite_list_class_init (ParasiteListClass *klass);
|
||||
static int parasite_compare_func (gconstpointer n1, gconstpointer n2);
|
||||
static int free_a_parasite (void *key, void *parasite, void *unused);
|
||||
|
||||
static void
|
||||
|
@ -90,12 +89,6 @@ parasite_list_new()
|
|||
return list;
|
||||
}
|
||||
|
||||
static int
|
||||
parasite_compare_func(gconstpointer n1, gconstpointer n2)
|
||||
{
|
||||
return (!strcmp((char*)n1, (char*)n2));
|
||||
}
|
||||
|
||||
static int
|
||||
free_a_parasite(void *key, void *parasite, void *unused)
|
||||
{
|
||||
|
@ -143,7 +136,7 @@ parasite_list_add(ParasiteList *list, Parasite *p)
|
|||
{
|
||||
g_return_if_fail(list != NULL);
|
||||
if (list->table == NULL)
|
||||
list->table = g_hash_table_new(g_str_hash, parasite_compare_func);
|
||||
list->table = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
g_return_if_fail(p != NULL);
|
||||
g_return_if_fail(p->name != NULL);
|
||||
parasite_list_remove(list, p->name);
|
||||
|
|
|
@ -1473,14 +1473,31 @@ gdisplay_untransform_coords_f (GDisplay *gdisp,
|
|||
}
|
||||
|
||||
|
||||
/* install and remove tool gimp cursor from gdisplay... */
|
||||
void
|
||||
gdisplay_install_gimp_tool_cursor (GDisplay *gdisp,
|
||||
int cursor_type)
|
||||
{
|
||||
if (gdisp->current_cursor != (int)cursor_type || gdisp->cursor_type != 1)
|
||||
{
|
||||
gdisp->current_cursor = (int)cursor_type;
|
||||
gdisp->cursor_type = 1;
|
||||
if (!gdisp->using_override_cursor)
|
||||
{
|
||||
gimp_change_win_cursor (gdisp->canvas->window, cursor_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* install and remove tool cursor from gdisplay... */
|
||||
void
|
||||
gdisplay_install_tool_cursor (GDisplay *gdisp,
|
||||
GdkCursorType cursor_type)
|
||||
{
|
||||
if (gdisp->current_cursor != cursor_type)
|
||||
if (gdisp->current_cursor != (int)cursor_type || gdisp->cursor_type != 0)
|
||||
{
|
||||
gdisp->current_cursor = cursor_type;
|
||||
gdisp->current_cursor = (int)cursor_type;
|
||||
gdisp->cursor_type = 0;
|
||||
if (!gdisp->using_override_cursor)
|
||||
{
|
||||
change_win_cursor (gdisp->canvas->window, cursor_type);
|
||||
|
|
|
@ -137,7 +137,8 @@ struct _GDisplay
|
|||
GSList *update_areas; /* Update areas list */
|
||||
GSList *display_areas; /* Display areas list */
|
||||
|
||||
GdkCursorType current_cursor; /* Currently installed cursor */
|
||||
int current_cursor; /* Currently installed cursor */
|
||||
short cursor_type; /* Currently installed cursor type */
|
||||
GdkCursorType override_cursor; /* Overriding cursor (ie. hourglass) */
|
||||
|
||||
short draw_cursor; /* should we draw software cursor ? */
|
||||
|
@ -167,6 +168,7 @@ void gdisplay_transform_coords_f (GDisplay *, double, double, double *
|
|||
void gdisplay_untransform_coords_f (GDisplay *, double, double, double *,
|
||||
double *, int);
|
||||
void gdisplay_install_tool_cursor (GDisplay *, GdkCursorType);
|
||||
void gdisplay_install_gimp_tool_cursor (GDisplay *, int);
|
||||
void gdisplay_remove_tool_cursor (GDisplay *);
|
||||
void gdisplay_install_override_cursor(GDisplay *, GdkCursorType);
|
||||
void gdisplay_remove_override_cursor (GDisplay *);
|
||||
|
|
|
@ -19,12 +19,82 @@
|
|||
#include "cursorutil.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gdisplay.h" /* for gdisplay_*_override_cursor() */
|
||||
#include "../pixmaps/mouse1"
|
||||
#include "../pixmaps/mouse1msk"
|
||||
#include "../pixmaps/mouse1_p"
|
||||
#include "../pixmaps/mouse1_pmsk"
|
||||
#include "../pixmaps/mouse1_m"
|
||||
#include "../pixmaps/mouse1_mmsk"
|
||||
#include "../pixmaps/bigcirc"
|
||||
#include "../pixmaps/bigcircmsk"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char *bits;
|
||||
unsigned char *mask_bits;
|
||||
int width, height;
|
||||
int x_hot, y_hot;
|
||||
GdkCursor *cursor;
|
||||
} BM_Cursor;
|
||||
|
||||
static BM_Cursor gimp_cursors[] =
|
||||
/* these have to match up with the enum in cursorutil.h */
|
||||
{
|
||||
{ mouse1_bits, mouse1msk_bits, mouse1_width, mouse1_height,
|
||||
mouse1_x_hot, mouse1_y_hot, NULL},
|
||||
{ mouse1_p_bits, mouse1_pmsk_bits, mouse1_p_width, mouse1_p_height,
|
||||
mouse1_p_x_hot, mouse1_p_y_hot, NULL},
|
||||
{ mouse1_m_bits, mouse1_mmsk_bits, mouse1_m_width, mouse1_m_height,
|
||||
mouse1_m_x_hot, mouse1_m_y_hot, NULL},
|
||||
{ bigcirc_bits, bigcircmsk_bits, bigcirc_width, bigcirc_height,
|
||||
bigcirc_x_hot, bigcirc_y_hot, NULL},
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern GSList* display_list; /* It's in gdisplay.c, FYI */
|
||||
static gboolean pending_removebusy = FALSE;
|
||||
|
||||
|
||||
static void
|
||||
create_cursor(BM_Cursor *bmcursor)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkPixmap *pixmapmsk;
|
||||
GdkColor fg, bg;
|
||||
|
||||
/* should have a way to configure the mouse colors */
|
||||
gdk_color_parse("#FFFFFF", &bg);
|
||||
gdk_color_parse("#000000", &fg);
|
||||
|
||||
pixmap = gdk_bitmap_create_from_data (NULL, bmcursor->bits,
|
||||
bmcursor->width, bmcursor->height);
|
||||
g_return_if_fail(pixmap != NULL);
|
||||
|
||||
pixmapmsk = gdk_bitmap_create_from_data (NULL, bmcursor->mask_bits,
|
||||
bmcursor->width,
|
||||
bmcursor->height);
|
||||
g_return_if_fail(pixmapmsk != NULL);
|
||||
|
||||
bmcursor->cursor = gdk_cursor_new_from_pixmap(pixmap, pixmapmsk, &fg, &bg,
|
||||
bmcursor->x_hot,
|
||||
bmcursor->y_hot);
|
||||
g_return_if_fail(bmcursor->cursor != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_change_win_cursor(GdkWindow *win, GimpCursorType curtype)
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
g_return_if_fail (curtype < GIMP_LAST_CURSOR_ENTRY);
|
||||
if (!gimp_cursors[(int)curtype].cursor)
|
||||
create_cursor(&gimp_cursors[(int)curtype]);
|
||||
cursor = gimp_cursors[(int)curtype].cursor;
|
||||
gdk_window_set_cursor (win, cursor);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
change_win_cursor (win, cursortype)
|
||||
GdkWindow *win;
|
||||
|
|
|
@ -20,8 +20,18 @@
|
|||
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_MOUSE1_CURSOR,
|
||||
GIMP_MOUSE1P_CURSOR,
|
||||
GIMP_MOUSE1M_CURSOR,
|
||||
GIMP_BIGCIRC_CURSOR,
|
||||
GIMP_LAST_CURSOR_ENTRY
|
||||
} GimpCursorType;
|
||||
|
||||
void change_win_cursor (GdkWindow *, GdkCursorType);
|
||||
void unset_win_cursor (GdkWindow *);
|
||||
void gimp_change_win_cursor (GdkWindow *, GimpCursorType);
|
||||
|
||||
void gimp_add_busy_cursors_until_idle (void);
|
||||
void gimp_add_busy_cursors (void);
|
||||
|
|
|
@ -88,6 +88,22 @@ gdisplay_check_device_cursor (GDisplay *gdisp)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
key_to_state(int key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case GDK_Alt_L: case GDK_Alt_R:
|
||||
return GDK_MOD1_MASK;
|
||||
case GDK_Shift_L: case GDK_Shift_R:
|
||||
return GDK_SHIFT_MASK;
|
||||
case GDK_Control_L: case GDK_Control_R:
|
||||
return GDK_CONTROL_MASK;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
gdisplay_canvas_events (GtkWidget *canvas,
|
||||
GdkEvent *event)
|
||||
|
@ -183,6 +199,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
state |= GDK_BUTTON1_MASK;
|
||||
gtk_grab_add (canvas);
|
||||
|
||||
/* This is a hack to prevent other stuff being run in the middle of
|
||||
|
@ -234,12 +251,14 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
break;
|
||||
|
||||
case 2:
|
||||
state |= GDK_BUTTON2_MASK;
|
||||
scrolled = TRUE;
|
||||
gtk_grab_add (canvas);
|
||||
start_grab_and_scroll (gdisp, bevent);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
state |= GDK_BUTTON3_MASK;
|
||||
popup_shell = gdisp->shell;
|
||||
gdisplay_set_menu_sensitivity (gdisp);
|
||||
gtk_menu_popup (GTK_MENU (gdisp->popup), NULL, NULL, NULL, NULL, 3, bevent->time);
|
||||
|
@ -258,6 +277,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
state &= ~GDK_BUTTON1_MASK;
|
||||
|
||||
/* Lame hack. See above */
|
||||
if (key_signal_id)
|
||||
{
|
||||
|
@ -280,18 +301,21 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
update_cursor = TRUE;
|
||||
}
|
||||
|
||||
(* active_tool->button_release_func) (active_tool, bevent, gdisp);
|
||||
(* active_tool->button_release_func) (active_tool, bevent,
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
state &= ~GDK_BUTTON2_MASK;
|
||||
scrolled = FALSE;
|
||||
gtk_grab_remove (canvas);
|
||||
end_grab_and_scroll (gdisp, bevent);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
state &= ~GDK_BUTTON3_MASK;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -384,17 +408,15 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
|
||||
/* Update the state based on modifiers being pressed */
|
||||
case GDK_Alt_L: case GDK_Alt_R:
|
||||
state |= GDK_MOD1_MASK;
|
||||
case GDK_Shift_L: case GDK_Shift_R:
|
||||
state |= GDK_SHIFT_MASK;
|
||||
case GDK_Control_L: case GDK_Control_R:
|
||||
state |= GDK_CONTROL_MASK;
|
||||
state |= key_to_state(kevent->keyval);
|
||||
/* For all modifier keys: call the tools modifier_key_func */
|
||||
if (active_tool && !gimage_is_empty (gdisp->gimage))
|
||||
{
|
||||
(* active_tool->modifier_key_func) (active_tool, kevent, gdisp);
|
||||
gdk_input_window_get_pointer (canvas->window, current_device,
|
||||
&tx, &ty, NULL, NULL, NULL, NULL);
|
||||
&tx, &ty, NULL, NULL, NULL, NULL);
|
||||
return_val = TRUE;
|
||||
}
|
||||
break;
|
||||
|
@ -411,11 +433,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
switch (kevent->keyval)
|
||||
{
|
||||
case GDK_Alt_L: case GDK_Alt_R:
|
||||
state &= ~GDK_MOD1_MASK;
|
||||
case GDK_Shift_L: case GDK_Shift_R:
|
||||
kevent->state &= ~GDK_SHIFT_MASK;
|
||||
case GDK_Control_L: case GDK_Control_R:
|
||||
kevent->state &= ~GDK_CONTROL_MASK;
|
||||
state &= ~key_to_state(kevent->keyval);
|
||||
/* For all modifier keys: call the tools modifier_key_func */
|
||||
if (active_tool && !gimage_is_empty (gdisp->gimage))
|
||||
{
|
||||
|
|
|
@ -88,6 +88,22 @@ gdisplay_check_device_cursor (GDisplay *gdisp)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
key_to_state(int key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case GDK_Alt_L: case GDK_Alt_R:
|
||||
return GDK_MOD1_MASK;
|
||||
case GDK_Shift_L: case GDK_Shift_R:
|
||||
return GDK_SHIFT_MASK;
|
||||
case GDK_Control_L: case GDK_Control_R:
|
||||
return GDK_CONTROL_MASK;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
gdisplay_canvas_events (GtkWidget *canvas,
|
||||
GdkEvent *event)
|
||||
|
@ -183,6 +199,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
state |= GDK_BUTTON1_MASK;
|
||||
gtk_grab_add (canvas);
|
||||
|
||||
/* This is a hack to prevent other stuff being run in the middle of
|
||||
|
@ -234,12 +251,14 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
break;
|
||||
|
||||
case 2:
|
||||
state |= GDK_BUTTON2_MASK;
|
||||
scrolled = TRUE;
|
||||
gtk_grab_add (canvas);
|
||||
start_grab_and_scroll (gdisp, bevent);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
state |= GDK_BUTTON3_MASK;
|
||||
popup_shell = gdisp->shell;
|
||||
gdisplay_set_menu_sensitivity (gdisp);
|
||||
gtk_menu_popup (GTK_MENU (gdisp->popup), NULL, NULL, NULL, NULL, 3, bevent->time);
|
||||
|
@ -258,6 +277,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
state &= ~GDK_BUTTON1_MASK;
|
||||
|
||||
/* Lame hack. See above */
|
||||
if (key_signal_id)
|
||||
{
|
||||
|
@ -280,18 +301,21 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
update_cursor = TRUE;
|
||||
}
|
||||
|
||||
(* active_tool->button_release_func) (active_tool, bevent, gdisp);
|
||||
(* active_tool->button_release_func) (active_tool, bevent,
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
state &= ~GDK_BUTTON2_MASK;
|
||||
scrolled = FALSE;
|
||||
gtk_grab_remove (canvas);
|
||||
end_grab_and_scroll (gdisp, bevent);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
state &= ~GDK_BUTTON3_MASK;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -384,17 +408,15 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
|
||||
/* Update the state based on modifiers being pressed */
|
||||
case GDK_Alt_L: case GDK_Alt_R:
|
||||
state |= GDK_MOD1_MASK;
|
||||
case GDK_Shift_L: case GDK_Shift_R:
|
||||
state |= GDK_SHIFT_MASK;
|
||||
case GDK_Control_L: case GDK_Control_R:
|
||||
state |= GDK_CONTROL_MASK;
|
||||
state |= key_to_state(kevent->keyval);
|
||||
/* For all modifier keys: call the tools modifier_key_func */
|
||||
if (active_tool && !gimage_is_empty (gdisp->gimage))
|
||||
{
|
||||
(* active_tool->modifier_key_func) (active_tool, kevent, gdisp);
|
||||
gdk_input_window_get_pointer (canvas->window, current_device,
|
||||
&tx, &ty, NULL, NULL, NULL, NULL);
|
||||
&tx, &ty, NULL, NULL, NULL, NULL);
|
||||
return_val = TRUE;
|
||||
}
|
||||
break;
|
||||
|
@ -411,11 +433,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
switch (kevent->keyval)
|
||||
{
|
||||
case GDK_Alt_L: case GDK_Alt_R:
|
||||
state &= ~GDK_MOD1_MASK;
|
||||
case GDK_Shift_L: case GDK_Shift_R:
|
||||
kevent->state &= ~GDK_SHIFT_MASK;
|
||||
case GDK_Control_L: case GDK_Control_R:
|
||||
kevent->state &= ~GDK_CONTROL_MASK;
|
||||
state &= ~key_to_state(kevent->keyval);
|
||||
/* For all modifier keys: call the tools modifier_key_func */
|
||||
if (active_tool && !gimage_is_empty (gdisp->gimage))
|
||||
{
|
||||
|
|
|
@ -1473,14 +1473,31 @@ gdisplay_untransform_coords_f (GDisplay *gdisp,
|
|||
}
|
||||
|
||||
|
||||
/* install and remove tool gimp cursor from gdisplay... */
|
||||
void
|
||||
gdisplay_install_gimp_tool_cursor (GDisplay *gdisp,
|
||||
int cursor_type)
|
||||
{
|
||||
if (gdisp->current_cursor != (int)cursor_type || gdisp->cursor_type != 1)
|
||||
{
|
||||
gdisp->current_cursor = (int)cursor_type;
|
||||
gdisp->cursor_type = 1;
|
||||
if (!gdisp->using_override_cursor)
|
||||
{
|
||||
gimp_change_win_cursor (gdisp->canvas->window, cursor_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* install and remove tool cursor from gdisplay... */
|
||||
void
|
||||
gdisplay_install_tool_cursor (GDisplay *gdisp,
|
||||
GdkCursorType cursor_type)
|
||||
{
|
||||
if (gdisp->current_cursor != cursor_type)
|
||||
if (gdisp->current_cursor != (int)cursor_type || gdisp->cursor_type != 0)
|
||||
{
|
||||
gdisp->current_cursor = cursor_type;
|
||||
gdisp->current_cursor = (int)cursor_type;
|
||||
gdisp->cursor_type = 0;
|
||||
if (!gdisp->using_override_cursor)
|
||||
{
|
||||
change_win_cursor (gdisp->canvas->window, cursor_type);
|
||||
|
|
|
@ -137,7 +137,8 @@ struct _GDisplay
|
|||
GSList *update_areas; /* Update areas list */
|
||||
GSList *display_areas; /* Display areas list */
|
||||
|
||||
GdkCursorType current_cursor; /* Currently installed cursor */
|
||||
int current_cursor; /* Currently installed cursor */
|
||||
short cursor_type; /* Currently installed cursor type */
|
||||
GdkCursorType override_cursor; /* Overriding cursor (ie. hourglass) */
|
||||
|
||||
short draw_cursor; /* should we draw software cursor ? */
|
||||
|
@ -167,6 +168,7 @@ void gdisplay_transform_coords_f (GDisplay *, double, double, double *
|
|||
void gdisplay_untransform_coords_f (GDisplay *, double, double, double *,
|
||||
double *, int);
|
||||
void gdisplay_install_tool_cursor (GDisplay *, GdkCursorType);
|
||||
void gdisplay_install_gimp_tool_cursor (GDisplay *, int);
|
||||
void gdisplay_remove_tool_cursor (GDisplay *);
|
||||
void gdisplay_install_override_cursor(GDisplay *, GdkCursorType);
|
||||
void gdisplay_remove_override_cursor (GDisplay *);
|
||||
|
|
|
@ -88,6 +88,22 @@ gdisplay_check_device_cursor (GDisplay *gdisp)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
key_to_state(int key)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case GDK_Alt_L: case GDK_Alt_R:
|
||||
return GDK_MOD1_MASK;
|
||||
case GDK_Shift_L: case GDK_Shift_R:
|
||||
return GDK_SHIFT_MASK;
|
||||
case GDK_Control_L: case GDK_Control_R:
|
||||
return GDK_CONTROL_MASK;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
gint
|
||||
gdisplay_canvas_events (GtkWidget *canvas,
|
||||
GdkEvent *event)
|
||||
|
@ -183,6 +199,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
state |= GDK_BUTTON1_MASK;
|
||||
gtk_grab_add (canvas);
|
||||
|
||||
/* This is a hack to prevent other stuff being run in the middle of
|
||||
|
@ -234,12 +251,14 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
break;
|
||||
|
||||
case 2:
|
||||
state |= GDK_BUTTON2_MASK;
|
||||
scrolled = TRUE;
|
||||
gtk_grab_add (canvas);
|
||||
start_grab_and_scroll (gdisp, bevent);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
state |= GDK_BUTTON3_MASK;
|
||||
popup_shell = gdisp->shell;
|
||||
gdisplay_set_menu_sensitivity (gdisp);
|
||||
gtk_menu_popup (GTK_MENU (gdisp->popup), NULL, NULL, NULL, NULL, 3, bevent->time);
|
||||
|
@ -258,6 +277,8 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
switch (bevent->button)
|
||||
{
|
||||
case 1:
|
||||
state &= ~GDK_BUTTON1_MASK;
|
||||
|
||||
/* Lame hack. See above */
|
||||
if (key_signal_id)
|
||||
{
|
||||
|
@ -280,18 +301,21 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
update_cursor = TRUE;
|
||||
}
|
||||
|
||||
(* active_tool->button_release_func) (active_tool, bevent, gdisp);
|
||||
(* active_tool->button_release_func) (active_tool, bevent,
|
||||
gdisp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
state &= ~GDK_BUTTON2_MASK;
|
||||
scrolled = FALSE;
|
||||
gtk_grab_remove (canvas);
|
||||
end_grab_and_scroll (gdisp, bevent);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
state &= ~GDK_BUTTON3_MASK;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -384,17 +408,15 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
|
||||
/* Update the state based on modifiers being pressed */
|
||||
case GDK_Alt_L: case GDK_Alt_R:
|
||||
state |= GDK_MOD1_MASK;
|
||||
case GDK_Shift_L: case GDK_Shift_R:
|
||||
state |= GDK_SHIFT_MASK;
|
||||
case GDK_Control_L: case GDK_Control_R:
|
||||
state |= GDK_CONTROL_MASK;
|
||||
state |= key_to_state(kevent->keyval);
|
||||
/* For all modifier keys: call the tools modifier_key_func */
|
||||
if (active_tool && !gimage_is_empty (gdisp->gimage))
|
||||
{
|
||||
(* active_tool->modifier_key_func) (active_tool, kevent, gdisp);
|
||||
gdk_input_window_get_pointer (canvas->window, current_device,
|
||||
&tx, &ty, NULL, NULL, NULL, NULL);
|
||||
&tx, &ty, NULL, NULL, NULL, NULL);
|
||||
return_val = TRUE;
|
||||
}
|
||||
break;
|
||||
|
@ -411,11 +433,9 @@ gdisplay_canvas_events (GtkWidget *canvas,
|
|||
switch (kevent->keyval)
|
||||
{
|
||||
case GDK_Alt_L: case GDK_Alt_R:
|
||||
state &= ~GDK_MOD1_MASK;
|
||||
case GDK_Shift_L: case GDK_Shift_R:
|
||||
kevent->state &= ~GDK_SHIFT_MASK;
|
||||
case GDK_Control_L: case GDK_Control_R:
|
||||
kevent->state &= ~GDK_CONTROL_MASK;
|
||||
state &= ~key_to_state(kevent->keyval);
|
||||
/* For all modifier keys: call the tools modifier_key_func */
|
||||
if (active_tool && !gimage_is_empty (gdisp->gimage))
|
||||
{
|
||||
|
|
|
@ -118,6 +118,9 @@ init_edit_selection (Tool *tool,
|
|||
edit_select.cumly = 0;
|
||||
|
||||
/* Make a check to see if it should be a floating selection translation */
|
||||
if (edit_type == MaskToLayerTranslate && gimage_floating_sel (gdisp->gimage))
|
||||
edit_type = FloatingSelTranslate;
|
||||
|
||||
if (edit_type == LayerTranslate)
|
||||
{
|
||||
layer = gimage_get_active_layer (gdisp->gimage);
|
||||
|
|
|
@ -50,7 +50,7 @@ ellipse_select (GimpImage *gimage,
|
|||
Channel * new_mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == REPLACE)
|
||||
if (op == SELECTION_REPLACE)
|
||||
gimage_mask_clear (gimage);
|
||||
else
|
||||
gimage_mask_undo (gimage);
|
||||
|
@ -66,7 +66,7 @@ ellipse_select (GimpImage *gimage,
|
|||
feather_radius, op, 0, 0);
|
||||
channel_delete (new_mask);
|
||||
}
|
||||
else if (op == INTERSECT)
|
||||
else if (op == SELECTION_INTERSECT)
|
||||
{
|
||||
new_mask = channel_new_mask (gimage, gimage->width, gimage->height);
|
||||
channel_combine_ellipse (new_mask, ADD, x, y, w, h, antialias);
|
||||
|
@ -137,7 +137,8 @@ tools_new_ellipse_select (void)
|
|||
tool->button_press_func = rect_select_button_press;
|
||||
tool->button_release_func = rect_select_button_release;
|
||||
tool->motion_func = rect_select_motion;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func;
|
||||
tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->cursor_update_func = rect_select_cursor_update;
|
||||
tool->control_func = rect_select_control;
|
||||
tool->preserve = TRUE;
|
||||
|
|
|
@ -40,8 +40,10 @@ typedef struct _free_select FreeSelect;
|
|||
struct _free_select
|
||||
{
|
||||
DrawCore * core; /* Core select object */
|
||||
int num_pts; /* Number of points in the polygon */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
|
||||
int num_pts; /* Number of points in the polygon */
|
||||
};
|
||||
|
||||
struct _FreeSelectPoint
|
||||
|
@ -316,27 +318,15 @@ free_select_button_press (Tool *tool, GdkEventButton *bevent,
|
|||
tool->state = ACTIVE;
|
||||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
if (bevent->state & GDK_MOD1_MASK)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
}
|
||||
else if ((bevent->state & GDK_SHIFT_MASK) && !(bevent->state & GDK_CONTROL_MASK))
|
||||
free_sel->op = ADD;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && !(bevent->state & GDK_SHIFT_MASK))
|
||||
free_sel->op = SUB;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && (bevent->state & GDK_SHIFT_MASK))
|
||||
free_sel->op = INTERSECT;
|
||||
else
|
||||
{
|
||||
if (! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
gdisplay_mask_value (gdisp, bevent->x, bevent->y) > HALF_WAY)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
free_sel->op = REPLACE;
|
||||
}
|
||||
switch (free_sel->op)
|
||||
{
|
||||
case SELECTION_MOVE_MASK:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
case SELECTION_MOVE:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
add_point (0, bevent->x, bevent->y);
|
||||
free_sel->num_pts = 1;
|
||||
|
@ -470,6 +460,7 @@ tools_new_free_select (void)
|
|||
|
||||
private->core = draw_core_new (free_select_draw);
|
||||
private->num_pts = 0;
|
||||
private->op = SELECTION_REPLACE;
|
||||
|
||||
tool->type = FREE_SELECT;
|
||||
tool->state = INACTIVE;
|
||||
|
@ -477,10 +468,11 @@ tools_new_free_select (void)
|
|||
tool->auto_snap_to = TRUE;
|
||||
tool->private = (void *) private;
|
||||
|
||||
tool->button_press_func = free_select_button_press;
|
||||
tool->button_press_func = free_select_button_press;
|
||||
tool->button_release_func = free_select_button_release;
|
||||
tool->motion_func = free_select_motion;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func;
|
||||
tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->cursor_update_func = rect_select_cursor_update;
|
||||
tool->control_func = free_select_control;
|
||||
tool->preserve = TRUE;
|
||||
|
|
|
@ -39,12 +39,13 @@ struct _fuzzy_select
|
|||
{
|
||||
DrawCore * core; /* Core select object */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
|
||||
int x, y; /* Point from which to execute seed fill */
|
||||
int last_x; /* */
|
||||
int last_y; /* variables to keep track of sensitivity */
|
||||
int threshold; /* threshold value for soft seed fill */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
};
|
||||
|
||||
|
||||
|
@ -343,26 +344,15 @@ fuzzy_select_button_press (Tool *tool, GdkEventButton *bevent,
|
|||
tool->state = ACTIVE;
|
||||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
if (bevent->state & GDK_MOD1_MASK)
|
||||
if (fuzzy_sel->op == SELECTION_MOVE_MASK)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
}
|
||||
else if ((bevent->state & GDK_SHIFT_MASK) && !(bevent->state & GDK_CONTROL_MASK))
|
||||
fuzzy_sel->op = ADD;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && !(bevent->state & GDK_SHIFT_MASK))
|
||||
fuzzy_sel->op = SUB;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && (bevent->state & GDK_SHIFT_MASK))
|
||||
fuzzy_sel->op = INTERSECT;
|
||||
else
|
||||
else if (fuzzy_sel->op == SELECTION_MOVE)
|
||||
{
|
||||
if (! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
gdisplay_mask_value (gdisp, bevent->x, bevent->y) > HALF_WAY)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
fuzzy_sel->op = REPLACE;
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
/* calculate the region boundary */
|
||||
|
|
|
@ -1473,14 +1473,31 @@ gdisplay_untransform_coords_f (GDisplay *gdisp,
|
|||
}
|
||||
|
||||
|
||||
/* install and remove tool gimp cursor from gdisplay... */
|
||||
void
|
||||
gdisplay_install_gimp_tool_cursor (GDisplay *gdisp,
|
||||
int cursor_type)
|
||||
{
|
||||
if (gdisp->current_cursor != (int)cursor_type || gdisp->cursor_type != 1)
|
||||
{
|
||||
gdisp->current_cursor = (int)cursor_type;
|
||||
gdisp->cursor_type = 1;
|
||||
if (!gdisp->using_override_cursor)
|
||||
{
|
||||
gimp_change_win_cursor (gdisp->canvas->window, cursor_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* install and remove tool cursor from gdisplay... */
|
||||
void
|
||||
gdisplay_install_tool_cursor (GDisplay *gdisp,
|
||||
GdkCursorType cursor_type)
|
||||
{
|
||||
if (gdisp->current_cursor != cursor_type)
|
||||
if (gdisp->current_cursor != (int)cursor_type || gdisp->cursor_type != 0)
|
||||
{
|
||||
gdisp->current_cursor = cursor_type;
|
||||
gdisp->current_cursor = (int)cursor_type;
|
||||
gdisp->cursor_type = 0;
|
||||
if (!gdisp->using_override_cursor)
|
||||
{
|
||||
change_win_cursor (gdisp->canvas->window, cursor_type);
|
||||
|
|
|
@ -137,7 +137,8 @@ struct _GDisplay
|
|||
GSList *update_areas; /* Update areas list */
|
||||
GSList *display_areas; /* Display areas list */
|
||||
|
||||
GdkCursorType current_cursor; /* Currently installed cursor */
|
||||
int current_cursor; /* Currently installed cursor */
|
||||
short cursor_type; /* Currently installed cursor type */
|
||||
GdkCursorType override_cursor; /* Overriding cursor (ie. hourglass) */
|
||||
|
||||
short draw_cursor; /* should we draw software cursor ? */
|
||||
|
@ -167,6 +168,7 @@ void gdisplay_transform_coords_f (GDisplay *, double, double, double *
|
|||
void gdisplay_untransform_coords_f (GDisplay *, double, double, double *,
|
||||
double *, int);
|
||||
void gdisplay_install_tool_cursor (GDisplay *, GdkCursorType);
|
||||
void gdisplay_install_gimp_tool_cursor (GDisplay *, int);
|
||||
void gdisplay_remove_tool_cursor (GDisplay *);
|
||||
void gdisplay_install_override_cursor(GDisplay *, GdkCursorType);
|
||||
void gdisplay_remove_override_cursor (GDisplay *);
|
||||
|
|
|
@ -1308,7 +1308,7 @@ channel_border (Channel *mask, int radius)
|
|||
pixel_region_init (&bPR, GIMP_DRAWABLE(mask)->tiles, x1, y1,
|
||||
(x2-x1), (y2-y1), TRUE);
|
||||
|
||||
border_region(&bPR, radius);
|
||||
border_region(&bPR, radius, radius);
|
||||
|
||||
mask->bounds_known = FALSE;
|
||||
}
|
||||
|
|
|
@ -4425,7 +4425,7 @@ compute_transition(guchar *transition, guchar **buf, gint32 width)
|
|||
}
|
||||
|
||||
void
|
||||
border_region(PixelRegion *src, gint16 radius)
|
||||
border_region(PixelRegion *src, gint16 xradius, gint16 yradius)
|
||||
{
|
||||
/*
|
||||
This function has no bugs, but if you imagine some you can
|
||||
|
@ -4436,22 +4436,21 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
gint16 *max;
|
||||
guchar **density;
|
||||
guchar **transition;
|
||||
guint16 diameter = radius*2+1;
|
||||
guchar last_max;
|
||||
gint16 last_index;
|
||||
|
||||
if (radius < 0)
|
||||
if (xradius < 0 || yradius < 0)
|
||||
{
|
||||
g_warning (_("border_region: negative radius specified."));
|
||||
return;
|
||||
}
|
||||
if (radius == 0)
|
||||
if (xradius == 0 || yradius == 0)
|
||||
{
|
||||
unsigned char color[] = "\0\0\0\0";
|
||||
color_region(src, color);
|
||||
return;
|
||||
}
|
||||
if (radius == 1) /* optimize this case specifically */
|
||||
if (xradius == 1 && yradius == 1) /* optimize this case specifically */
|
||||
{
|
||||
guchar *transition;
|
||||
guchar *source[3];
|
||||
|
@ -4485,60 +4484,61 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
g_free(source[i]);
|
||||
g_free(transition);
|
||||
return;
|
||||
} /* end of if (radius == 1) */
|
||||
max = (gint16 *)g_malloc ((src->w+2*radius)*sizeof(gint16 *));
|
||||
for (i = 0; i < (src->w+2*radius); i++)
|
||||
max[i] = radius+2;
|
||||
max += radius;
|
||||
} /* end of if (xradius == 1 && yradius == 1) */
|
||||
max = (gint16 *)g_malloc ((src->w+2*xradius)*sizeof(gint16 *));
|
||||
for (i = 0; i < (src->w+2*xradius); i++)
|
||||
max[i] = yradius+2;
|
||||
max += xradius;
|
||||
|
||||
buf = (guchar **)g_malloc ((3)*sizeof(void *));
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
buf[i] = (guchar *)g_malloc ((src->w)*sizeof(guchar));
|
||||
}
|
||||
transition = (guchar **)g_malloc ((radius+1)*sizeof(void*));
|
||||
for (i = 0; i < radius +1; i++)
|
||||
transition = (guchar **)g_malloc ((yradius+1)*sizeof(void*));
|
||||
for (i = 0; i < yradius +1; i++)
|
||||
{
|
||||
transition[i] = (guchar *)g_malloc (src->w+2*radius);
|
||||
memset(transition[i], 0, src->w+2*radius);
|
||||
transition[i] += radius;
|
||||
transition[i] = (guchar *)g_malloc (src->w+2*xradius);
|
||||
memset(transition[i], 0, src->w+2*xradius);
|
||||
transition[i] += xradius;
|
||||
}
|
||||
out = (guchar *)g_malloc ((src->w)*sizeof(guchar));
|
||||
density = (guchar **)g_malloc (diameter*sizeof(void *));
|
||||
density += radius;
|
||||
density = (guchar **)g_malloc ((2*xradius + 1)*sizeof(void *));
|
||||
density += xradius;
|
||||
|
||||
for (x = 0; x < (radius+1); x++) /* allocate density[][] */
|
||||
for (x = 0; x < (xradius+1); x++) /* allocate density[][] */
|
||||
{
|
||||
density[x] = (guchar *)g_malloc (diameter);
|
||||
density[x] += radius;
|
||||
density[-x] = density[x];
|
||||
density[ x] = (guchar *)g_malloc (2*yradius +1);
|
||||
density[ x] += yradius;
|
||||
density[-x] = density[x];
|
||||
}
|
||||
for (x = 0; x < (radius+1); x++) /* compute density[][] */
|
||||
for (x = 0; x < (xradius+1); x++) /* compute density[][] */
|
||||
{
|
||||
register double tmpx, tmpy;
|
||||
register double tmpx, tmpy, dist;
|
||||
guchar a;
|
||||
for (y = 0; y < (radius+1); y++)
|
||||
if (x > 0)
|
||||
tmpx = x - 0.5;
|
||||
else if (x < 0)
|
||||
tmpx = x + 0.5;
|
||||
else
|
||||
tmpx = 0.0;
|
||||
for (y = 0; y < (yradius+1); y++)
|
||||
{
|
||||
if (x > 0)
|
||||
tmpx = x - 0.5;
|
||||
else if (x < 0)
|
||||
tmpx = x + 0.5;
|
||||
else
|
||||
tmpx = 0.0;
|
||||
if (y > 0)
|
||||
tmpy = y - 0.5;
|
||||
else if (y < 0)
|
||||
tmpy = y + 0.5;
|
||||
else
|
||||
tmpy = 0.0;
|
||||
if (tmpy*tmpy + tmpx*tmpx < (radius)*(radius))
|
||||
a = 255*(1.0 - sqrt ((tmpx*tmpx+tmpy*tmpy))/radius);
|
||||
dist = (tmpy*tmpy)/(yradius*yradius) + (tmpx*tmpx)/(xradius*xradius);
|
||||
if (dist < 1.0)
|
||||
a = 255*(1.0 - sqrt (dist));
|
||||
else
|
||||
a = 0;
|
||||
density[ x][ y] = a;
|
||||
density[ x][-y] = a;
|
||||
density[ y][ x] = a;
|
||||
density[ y][-x] = a;
|
||||
density[-x][ y] = a;
|
||||
density[-x][-y] = a;
|
||||
}
|
||||
}
|
||||
pixel_region_get_row (src, src->x, src->y + 0, src->w, buf[0], 1);
|
||||
|
@ -4549,7 +4549,7 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
memcpy (buf[2], buf[1], src->w);
|
||||
compute_transition (transition[1], buf, src->w);
|
||||
|
||||
for (y = 1; y < radius && y + 1< src->h; y++) /* set up top of image */
|
||||
for (y = 1; y < yradius && y + 1< src->h; y++) /* set up top of image */
|
||||
{
|
||||
rotate_pointers ((void **)buf, 3);
|
||||
pixel_region_get_row (src, src->x, src->y + y + 1, src->w, buf[2], 1);
|
||||
|
@ -4557,8 +4557,8 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
}
|
||||
for (x = 0; x < src->w; x++) /* set up max[] for top of image */
|
||||
{
|
||||
max[x] = -(radius+7);
|
||||
for (j = 1; j < radius+1; j++)
|
||||
max[x] = -(yradius+7);
|
||||
for (j = 1; j < yradius+1; j++)
|
||||
if (transition[j][x])
|
||||
{
|
||||
max[x] = j;
|
||||
|
@ -4568,24 +4568,24 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
for (y = 0; y < src->h; y++) /* main calculation loop */
|
||||
{
|
||||
rotate_pointers ((void **)buf, 3);
|
||||
rotate_pointers ((void **)transition, radius + 1);
|
||||
if (y < src->h - (radius+1))
|
||||
rotate_pointers ((void **)transition, yradius + 1);
|
||||
if (y < src->h - (yradius+1))
|
||||
{
|
||||
pixel_region_get_row (src, src->x, src->y + y + radius + 1, src->w,
|
||||
pixel_region_get_row (src, src->x, src->y + y + yradius + 1, src->w,
|
||||
buf[2], 1);
|
||||
compute_transition (transition[radius], buf, src->w);
|
||||
compute_transition (transition[yradius], buf, src->w);
|
||||
}
|
||||
else
|
||||
memcpy (transition[radius], transition[radius - 1], src->w);
|
||||
memcpy (transition[yradius], transition[yradius - 1], src->w);
|
||||
|
||||
for (x = 0; x < src->w; x++) /* update max array */
|
||||
{
|
||||
if (max[x] < 1)
|
||||
{
|
||||
if (max[x] <= -radius)
|
||||
if (max[x] <= -yradius)
|
||||
{
|
||||
if (transition[radius][x])
|
||||
max[x] = radius;
|
||||
if (transition[yradius][x])
|
||||
max[x] = yradius;
|
||||
else
|
||||
max[x]--;
|
||||
}
|
||||
|
@ -4599,8 +4599,8 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
}
|
||||
else
|
||||
max[x]--;
|
||||
if (max[x] < -radius - 1)
|
||||
max[x] = -radius -1;
|
||||
if (max[x] < -yradius - 1)
|
||||
max[x] = -yradius -1;
|
||||
}
|
||||
last_max = max[0][density[-1]];
|
||||
last_index = 1;
|
||||
|
@ -4610,8 +4610,8 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
if (last_index >= 0)
|
||||
{
|
||||
last_max = 0;
|
||||
for (i = radius; i >= 0; i--)
|
||||
if (max[x+i] <= radius && max[x+i] >= -radius &&
|
||||
for (i = xradius; i >= 0; i--)
|
||||
if (max[x+i] <= yradius && max[x+i] >= -yradius &&
|
||||
density[i][max[x+i]] > last_max)
|
||||
{
|
||||
last_max = density[i][max[x+i]];
|
||||
|
@ -4622,9 +4622,9 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
else
|
||||
{
|
||||
last_max = 0;
|
||||
for (i = radius; i >= -radius; i--)
|
||||
if (max[x+i] <= radius && max[x+i] >= -radius &&
|
||||
density[i][max[x+i]] > last_max)
|
||||
for (i = xradius; i >= -xradius; i--)
|
||||
if (max[x+i] <= yradius && max[x+i] >= -yradius &&
|
||||
density[i][max[x+i]] > last_max)
|
||||
{
|
||||
last_max = density[i][max[x+i]];
|
||||
last_index = i;
|
||||
|
@ -4635,16 +4635,16 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
{
|
||||
for (i = x+1; i < src->w; i++)
|
||||
{
|
||||
if (max[i] >= -radius)
|
||||
if (max[i] >= -yradius)
|
||||
break;
|
||||
}
|
||||
if (i - x > radius)
|
||||
if (i - x > xradius)
|
||||
{
|
||||
for (; x < i - radius; x++)
|
||||
for (; x < i - xradius; x++)
|
||||
out[x] = 0;
|
||||
x--;
|
||||
}
|
||||
last_index = radius;
|
||||
last_index = xradius;
|
||||
}
|
||||
}
|
||||
pixel_region_set_row (src, src->x, src->y + y, src->w, out);
|
||||
|
@ -4655,22 +4655,22 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
g_free(buf[i]);
|
||||
|
||||
g_free (buf);
|
||||
max -= radius;
|
||||
max -= xradius;
|
||||
g_free (max);
|
||||
|
||||
for (i = 0; i < radius +1; i++)
|
||||
for (i = 0; i < yradius +1; i++)
|
||||
{
|
||||
transition[i] -= radius;
|
||||
transition[i] -= xradius;
|
||||
g_free (transition[i]);
|
||||
}
|
||||
g_free (transition);
|
||||
|
||||
for (i = 0; i < radius +1 ; i++)
|
||||
for (i = 0; i < xradius +1 ; i++)
|
||||
{
|
||||
density[i]-= radius;
|
||||
density[i]-= yradius;
|
||||
g_free(density[i]);
|
||||
}
|
||||
density -= radius;
|
||||
density -= xradius;
|
||||
g_free(density);
|
||||
}
|
||||
|
||||
|
@ -4700,7 +4700,7 @@ swap_region (PixelRegion *src,
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
apply_mask_to_sub_region (int *opacityp,
|
||||
PixelRegion *src,
|
||||
PixelRegion *mask)
|
||||
|
@ -4731,7 +4731,7 @@ apply_mask_to_region (PixelRegion *src,
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
combine_mask_and_sub_region (int *opacityp,
|
||||
PixelRegion *src,
|
||||
PixelRegion *mask)
|
||||
|
|
|
@ -488,7 +488,7 @@ void separate_alpha_region (PixelRegion *);
|
|||
|
||||
void gaussian_blur_region (PixelRegion *, double);
|
||||
|
||||
void border_region (PixelRegion *, gint16);
|
||||
void border_region (PixelRegion *, gint16, gint16);
|
||||
|
||||
void scale_region (PixelRegion *, PixelRegion *);
|
||||
|
||||
|
|
|
@ -186,8 +186,8 @@ paint_core_button_press (tool, bevent, gdisp_ptr)
|
|||
/* pause the current selection and grab the pointer */
|
||||
gdisplays_selection_visibility (gdisp->gimage, SelectionPause);
|
||||
|
||||
/* add motion memory if you press mod1 first ^ perfectmouse */
|
||||
if (perfectmouse == 0)
|
||||
/* add motion memory if perfectmouse is set */
|
||||
if (perfectmouse != 0)
|
||||
gdk_pointer_grab (gdisp->canvas->window, FALSE,
|
||||
GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
|
||||
NULL, NULL, bevent->time);
|
||||
|
|
|
@ -4425,7 +4425,7 @@ compute_transition(guchar *transition, guchar **buf, gint32 width)
|
|||
}
|
||||
|
||||
void
|
||||
border_region(PixelRegion *src, gint16 radius)
|
||||
border_region(PixelRegion *src, gint16 xradius, gint16 yradius)
|
||||
{
|
||||
/*
|
||||
This function has no bugs, but if you imagine some you can
|
||||
|
@ -4436,22 +4436,21 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
gint16 *max;
|
||||
guchar **density;
|
||||
guchar **transition;
|
||||
guint16 diameter = radius*2+1;
|
||||
guchar last_max;
|
||||
gint16 last_index;
|
||||
|
||||
if (radius < 0)
|
||||
if (xradius < 0 || yradius < 0)
|
||||
{
|
||||
g_warning (_("border_region: negative radius specified."));
|
||||
return;
|
||||
}
|
||||
if (radius == 0)
|
||||
if (xradius == 0 || yradius == 0)
|
||||
{
|
||||
unsigned char color[] = "\0\0\0\0";
|
||||
color_region(src, color);
|
||||
return;
|
||||
}
|
||||
if (radius == 1) /* optimize this case specifically */
|
||||
if (xradius == 1 && yradius == 1) /* optimize this case specifically */
|
||||
{
|
||||
guchar *transition;
|
||||
guchar *source[3];
|
||||
|
@ -4485,60 +4484,61 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
g_free(source[i]);
|
||||
g_free(transition);
|
||||
return;
|
||||
} /* end of if (radius == 1) */
|
||||
max = (gint16 *)g_malloc ((src->w+2*radius)*sizeof(gint16 *));
|
||||
for (i = 0; i < (src->w+2*radius); i++)
|
||||
max[i] = radius+2;
|
||||
max += radius;
|
||||
} /* end of if (xradius == 1 && yradius == 1) */
|
||||
max = (gint16 *)g_malloc ((src->w+2*xradius)*sizeof(gint16 *));
|
||||
for (i = 0; i < (src->w+2*xradius); i++)
|
||||
max[i] = yradius+2;
|
||||
max += xradius;
|
||||
|
||||
buf = (guchar **)g_malloc ((3)*sizeof(void *));
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
buf[i] = (guchar *)g_malloc ((src->w)*sizeof(guchar));
|
||||
}
|
||||
transition = (guchar **)g_malloc ((radius+1)*sizeof(void*));
|
||||
for (i = 0; i < radius +1; i++)
|
||||
transition = (guchar **)g_malloc ((yradius+1)*sizeof(void*));
|
||||
for (i = 0; i < yradius +1; i++)
|
||||
{
|
||||
transition[i] = (guchar *)g_malloc (src->w+2*radius);
|
||||
memset(transition[i], 0, src->w+2*radius);
|
||||
transition[i] += radius;
|
||||
transition[i] = (guchar *)g_malloc (src->w+2*xradius);
|
||||
memset(transition[i], 0, src->w+2*xradius);
|
||||
transition[i] += xradius;
|
||||
}
|
||||
out = (guchar *)g_malloc ((src->w)*sizeof(guchar));
|
||||
density = (guchar **)g_malloc (diameter*sizeof(void *));
|
||||
density += radius;
|
||||
density = (guchar **)g_malloc ((2*xradius + 1)*sizeof(void *));
|
||||
density += xradius;
|
||||
|
||||
for (x = 0; x < (radius+1); x++) /* allocate density[][] */
|
||||
for (x = 0; x < (xradius+1); x++) /* allocate density[][] */
|
||||
{
|
||||
density[x] = (guchar *)g_malloc (diameter);
|
||||
density[x] += radius;
|
||||
density[-x] = density[x];
|
||||
density[ x] = (guchar *)g_malloc (2*yradius +1);
|
||||
density[ x] += yradius;
|
||||
density[-x] = density[x];
|
||||
}
|
||||
for (x = 0; x < (radius+1); x++) /* compute density[][] */
|
||||
for (x = 0; x < (xradius+1); x++) /* compute density[][] */
|
||||
{
|
||||
register double tmpx, tmpy;
|
||||
register double tmpx, tmpy, dist;
|
||||
guchar a;
|
||||
for (y = 0; y < (radius+1); y++)
|
||||
if (x > 0)
|
||||
tmpx = x - 0.5;
|
||||
else if (x < 0)
|
||||
tmpx = x + 0.5;
|
||||
else
|
||||
tmpx = 0.0;
|
||||
for (y = 0; y < (yradius+1); y++)
|
||||
{
|
||||
if (x > 0)
|
||||
tmpx = x - 0.5;
|
||||
else if (x < 0)
|
||||
tmpx = x + 0.5;
|
||||
else
|
||||
tmpx = 0.0;
|
||||
if (y > 0)
|
||||
tmpy = y - 0.5;
|
||||
else if (y < 0)
|
||||
tmpy = y + 0.5;
|
||||
else
|
||||
tmpy = 0.0;
|
||||
if (tmpy*tmpy + tmpx*tmpx < (radius)*(radius))
|
||||
a = 255*(1.0 - sqrt ((tmpx*tmpx+tmpy*tmpy))/radius);
|
||||
dist = (tmpy*tmpy)/(yradius*yradius) + (tmpx*tmpx)/(xradius*xradius);
|
||||
if (dist < 1.0)
|
||||
a = 255*(1.0 - sqrt (dist));
|
||||
else
|
||||
a = 0;
|
||||
density[ x][ y] = a;
|
||||
density[ x][-y] = a;
|
||||
density[ y][ x] = a;
|
||||
density[ y][-x] = a;
|
||||
density[-x][ y] = a;
|
||||
density[-x][-y] = a;
|
||||
}
|
||||
}
|
||||
pixel_region_get_row (src, src->x, src->y + 0, src->w, buf[0], 1);
|
||||
|
@ -4549,7 +4549,7 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
memcpy (buf[2], buf[1], src->w);
|
||||
compute_transition (transition[1], buf, src->w);
|
||||
|
||||
for (y = 1; y < radius && y + 1< src->h; y++) /* set up top of image */
|
||||
for (y = 1; y < yradius && y + 1< src->h; y++) /* set up top of image */
|
||||
{
|
||||
rotate_pointers ((void **)buf, 3);
|
||||
pixel_region_get_row (src, src->x, src->y + y + 1, src->w, buf[2], 1);
|
||||
|
@ -4557,8 +4557,8 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
}
|
||||
for (x = 0; x < src->w; x++) /* set up max[] for top of image */
|
||||
{
|
||||
max[x] = -(radius+7);
|
||||
for (j = 1; j < radius+1; j++)
|
||||
max[x] = -(yradius+7);
|
||||
for (j = 1; j < yradius+1; j++)
|
||||
if (transition[j][x])
|
||||
{
|
||||
max[x] = j;
|
||||
|
@ -4568,24 +4568,24 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
for (y = 0; y < src->h; y++) /* main calculation loop */
|
||||
{
|
||||
rotate_pointers ((void **)buf, 3);
|
||||
rotate_pointers ((void **)transition, radius + 1);
|
||||
if (y < src->h - (radius+1))
|
||||
rotate_pointers ((void **)transition, yradius + 1);
|
||||
if (y < src->h - (yradius+1))
|
||||
{
|
||||
pixel_region_get_row (src, src->x, src->y + y + radius + 1, src->w,
|
||||
pixel_region_get_row (src, src->x, src->y + y + yradius + 1, src->w,
|
||||
buf[2], 1);
|
||||
compute_transition (transition[radius], buf, src->w);
|
||||
compute_transition (transition[yradius], buf, src->w);
|
||||
}
|
||||
else
|
||||
memcpy (transition[radius], transition[radius - 1], src->w);
|
||||
memcpy (transition[yradius], transition[yradius - 1], src->w);
|
||||
|
||||
for (x = 0; x < src->w; x++) /* update max array */
|
||||
{
|
||||
if (max[x] < 1)
|
||||
{
|
||||
if (max[x] <= -radius)
|
||||
if (max[x] <= -yradius)
|
||||
{
|
||||
if (transition[radius][x])
|
||||
max[x] = radius;
|
||||
if (transition[yradius][x])
|
||||
max[x] = yradius;
|
||||
else
|
||||
max[x]--;
|
||||
}
|
||||
|
@ -4599,8 +4599,8 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
}
|
||||
else
|
||||
max[x]--;
|
||||
if (max[x] < -radius - 1)
|
||||
max[x] = -radius -1;
|
||||
if (max[x] < -yradius - 1)
|
||||
max[x] = -yradius -1;
|
||||
}
|
||||
last_max = max[0][density[-1]];
|
||||
last_index = 1;
|
||||
|
@ -4610,8 +4610,8 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
if (last_index >= 0)
|
||||
{
|
||||
last_max = 0;
|
||||
for (i = radius; i >= 0; i--)
|
||||
if (max[x+i] <= radius && max[x+i] >= -radius &&
|
||||
for (i = xradius; i >= 0; i--)
|
||||
if (max[x+i] <= yradius && max[x+i] >= -yradius &&
|
||||
density[i][max[x+i]] > last_max)
|
||||
{
|
||||
last_max = density[i][max[x+i]];
|
||||
|
@ -4622,9 +4622,9 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
else
|
||||
{
|
||||
last_max = 0;
|
||||
for (i = radius; i >= -radius; i--)
|
||||
if (max[x+i] <= radius && max[x+i] >= -radius &&
|
||||
density[i][max[x+i]] > last_max)
|
||||
for (i = xradius; i >= -xradius; i--)
|
||||
if (max[x+i] <= yradius && max[x+i] >= -yradius &&
|
||||
density[i][max[x+i]] > last_max)
|
||||
{
|
||||
last_max = density[i][max[x+i]];
|
||||
last_index = i;
|
||||
|
@ -4635,16 +4635,16 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
{
|
||||
for (i = x+1; i < src->w; i++)
|
||||
{
|
||||
if (max[i] >= -radius)
|
||||
if (max[i] >= -yradius)
|
||||
break;
|
||||
}
|
||||
if (i - x > radius)
|
||||
if (i - x > xradius)
|
||||
{
|
||||
for (; x < i - radius; x++)
|
||||
for (; x < i - xradius; x++)
|
||||
out[x] = 0;
|
||||
x--;
|
||||
}
|
||||
last_index = radius;
|
||||
last_index = xradius;
|
||||
}
|
||||
}
|
||||
pixel_region_set_row (src, src->x, src->y + y, src->w, out);
|
||||
|
@ -4655,22 +4655,22 @@ border_region(PixelRegion *src, gint16 radius)
|
|||
g_free(buf[i]);
|
||||
|
||||
g_free (buf);
|
||||
max -= radius;
|
||||
max -= xradius;
|
||||
g_free (max);
|
||||
|
||||
for (i = 0; i < radius +1; i++)
|
||||
for (i = 0; i < yradius +1; i++)
|
||||
{
|
||||
transition[i] -= radius;
|
||||
transition[i] -= xradius;
|
||||
g_free (transition[i]);
|
||||
}
|
||||
g_free (transition);
|
||||
|
||||
for (i = 0; i < radius +1 ; i++)
|
||||
for (i = 0; i < xradius +1 ; i++)
|
||||
{
|
||||
density[i]-= radius;
|
||||
density[i]-= yradius;
|
||||
g_free(density[i]);
|
||||
}
|
||||
density -= radius;
|
||||
density -= xradius;
|
||||
g_free(density);
|
||||
}
|
||||
|
||||
|
@ -4700,7 +4700,7 @@ swap_region (PixelRegion *src,
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
apply_mask_to_sub_region (int *opacityp,
|
||||
PixelRegion *src,
|
||||
PixelRegion *mask)
|
||||
|
@ -4731,7 +4731,7 @@ apply_mask_to_region (PixelRegion *src,
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
combine_mask_and_sub_region (int *opacityp,
|
||||
PixelRegion *src,
|
||||
PixelRegion *mask)
|
||||
|
|
|
@ -488,7 +488,7 @@ void separate_alpha_region (PixelRegion *);
|
|||
|
||||
void gaussian_blur_region (PixelRegion *, double);
|
||||
|
||||
void border_region (PixelRegion *, gint16);
|
||||
void border_region (PixelRegion *, gint16, gint16);
|
||||
|
||||
void scale_region (PixelRegion *, PixelRegion *);
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ static guint parasite_list_signals[LAST_SIGNAL];
|
|||
static void parasite_list_destroy (GtkObject* list);
|
||||
static void parasite_list_init (ParasiteList* list);
|
||||
static void parasite_list_class_init (ParasiteListClass *klass);
|
||||
static int parasite_compare_func (gconstpointer n1, gconstpointer n2);
|
||||
static int free_a_parasite (void *key, void *parasite, void *unused);
|
||||
|
||||
static void
|
||||
|
@ -90,12 +89,6 @@ parasite_list_new()
|
|||
return list;
|
||||
}
|
||||
|
||||
static int
|
||||
parasite_compare_func(gconstpointer n1, gconstpointer n2)
|
||||
{
|
||||
return (!strcmp((char*)n1, (char*)n2));
|
||||
}
|
||||
|
||||
static int
|
||||
free_a_parasite(void *key, void *parasite, void *unused)
|
||||
{
|
||||
|
@ -143,7 +136,7 @@ parasite_list_add(ParasiteList *list, Parasite *p)
|
|||
{
|
||||
g_return_if_fail(list != NULL);
|
||||
if (list->table == NULL)
|
||||
list->table = g_hash_table_new(g_str_hash, parasite_compare_func);
|
||||
list->table = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
g_return_if_fail(p != NULL);
|
||||
g_return_if_fail(p->name != NULL);
|
||||
parasite_list_remove(list, p->name);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
#include "appenv.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimage_mask.h"
|
||||
|
@ -24,6 +25,7 @@
|
|||
#include "rect_select.h"
|
||||
#include "rect_selectP.h"
|
||||
#include "selection_options.h"
|
||||
#include "cursorutil.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "libgimp/gimpunitmenu.h"
|
||||
|
@ -39,6 +41,8 @@ static SelectionOptions *rect_options = NULL;
|
|||
extern SelectionOptions *ellipse_options;
|
||||
extern void ellipse_select (GImage *, int, int, int, int, int, int, int, double);
|
||||
|
||||
static void selection_tool_update_op_state(RectSelect *rect_sel, int x, int y,
|
||||
int state, GDisplay *gdisp);
|
||||
|
||||
/*************************************/
|
||||
/* Rectangular selection apparatus */
|
||||
|
@ -56,7 +60,7 @@ rect_select (GimpImage *gimage,
|
|||
Channel * new_mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == REPLACE)
|
||||
if (op == SELECTION_REPLACE)
|
||||
gimage_mask_clear (gimage);
|
||||
else
|
||||
gimage_mask_undo (gimage);
|
||||
|
@ -72,7 +76,7 @@ rect_select (GimpImage *gimage,
|
|||
feather_radius, op, 0, 0);
|
||||
channel_delete (new_mask);
|
||||
}
|
||||
else if (op == INTERSECT)
|
||||
else if (op == SELECTION_INTERSECT)
|
||||
{
|
||||
new_mask = channel_new_mask (gimage, gimage->width, gimage->height);
|
||||
channel_combine_rect (new_mask, ADD, x, y, w, h);
|
||||
|
@ -154,43 +158,31 @@ rect_select_button_press (Tool *tool,
|
|||
tool->state = ACTIVE;
|
||||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
if (bevent->state & GDK_MOD1_MASK)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
}
|
||||
else if ((bevent->state & GDK_SHIFT_MASK) && !(bevent->state & GDK_CONTROL_MASK))
|
||||
rect_sel->op = ADD;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && !(bevent->state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = SUB;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && (bevent->state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = INTERSECT;
|
||||
else
|
||||
{
|
||||
if (! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
gdisplay_mask_value (gdisp, bevent->x, bevent->y) > HALF_WAY)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
rect_sel->op = REPLACE;
|
||||
}
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
case SELECTION_MOVE_MASK:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
case SELECTION_MOVE:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
/* initialize the statusbar display */
|
||||
rect_sel->context_id =
|
||||
gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "selection");
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
case ADD:
|
||||
case SELECTION_ADD:
|
||||
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: ADD"));
|
||||
break;
|
||||
case SUB:
|
||||
case SELECTION_SUB:
|
||||
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: SUBTRACT"));
|
||||
break;
|
||||
case INTERSECT:
|
||||
case SELECTION_INTERSECT:
|
||||
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: INTERSECT"));
|
||||
break;
|
||||
case REPLACE:
|
||||
case SELECTION_REPLACE:
|
||||
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: REPLACE"));
|
||||
break;
|
||||
default:
|
||||
|
@ -452,33 +444,70 @@ rect_select_draw (Tool *tool)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
static selection_tool_update_op_state(RectSelect *rect_sel, int x, int y, int state,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
if (active_tool->state == ACTIVE)
|
||||
return;
|
||||
|
||||
if (state & GDK_MOD1_MASK &&
|
||||
!(layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))))
|
||||
rect_sel->op = SELECTION_MOVE_MASK; /* move just the selection mask */
|
||||
else if (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage)) ||
|
||||
(!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
|
||||
gdisplay_mask_value (gdisp, x, y)))
|
||||
rect_sel->op = SELECTION_MOVE; /* move the selection */
|
||||
else if ((state & GDK_SHIFT_MASK) &&
|
||||
!(state & GDK_CONTROL_MASK))
|
||||
rect_sel->op = SELECTION_ADD; /* add to the selection */
|
||||
else if ((state & GDK_CONTROL_MASK) &&
|
||||
!(state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = SELECTION_SUB; /* subtract from the selection */
|
||||
else if ((state & GDK_CONTROL_MASK) &&
|
||||
(state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */
|
||||
else
|
||||
rect_sel->op = SELECTION_REPLACE; /* replace the selection */
|
||||
}
|
||||
|
||||
void
|
||||
rect_select_cursor_update (Tool *tool,
|
||||
GdkEventMotion *mevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
int active;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
RectSelect *rect_sel;
|
||||
GDisplay *gdisp;
|
||||
gdisp = (GDisplay *)gdisp_ptr;
|
||||
active = (active_tool->state == ACTIVE);
|
||||
rect_sel = (RectSelect*)tool->private;
|
||||
|
||||
/* if alt key is depressed, use the diamond cursor */
|
||||
if (mevent->state & GDK_MOD1_MASK && !active)
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_DIAMOND_CROSS);
|
||||
/* if the cursor is over the selected region, but no modifiers
|
||||
* are depressed, use a fleur cursor--for cutting and moving the selection
|
||||
*/
|
||||
else if (gdisplay_mask_value (gdisp, mevent->x, mevent->y) &&
|
||||
! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
! (mevent->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
|
||||
! active)
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
else
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
selection_tool_update_op_state(rect_sel, mevent->x, mevent->y,
|
||||
mevent->state, gdisp_ptr);
|
||||
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
case SELECTION_ADD:
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_MOUSE1P_CURSOR);
|
||||
break;
|
||||
case SELECTION_SUB:
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_MOUSE1M_CURSOR);
|
||||
break;
|
||||
case SELECTION_INTERSECT: /* need a real cursor for this one */
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_BIGCIRC_CURSOR);
|
||||
break;
|
||||
case SELECTION_REPLACE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
break;
|
||||
case SELECTION_MOVE_MASK:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_DIAMOND_CROSS);
|
||||
break;
|
||||
case SELECTION_MOVE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
rect_select_control (Tool *tool,
|
||||
int action,
|
||||
|
@ -528,6 +557,7 @@ tools_new_rect_select ()
|
|||
private->core = draw_core_new (rect_select_draw);
|
||||
private->x = private->y = 0;
|
||||
private->w = private->h = 0;
|
||||
private->op = SELECTION_REPLACE;
|
||||
|
||||
tool->type = RECT_SELECT;
|
||||
tool->state = INACTIVE;
|
||||
|
@ -538,7 +568,8 @@ tools_new_rect_select ()
|
|||
tool->button_press_func = rect_select_button_press;
|
||||
tool->button_release_func = rect_select_button_release;
|
||||
tool->motion_func = rect_select_motion;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func;
|
||||
tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->cursor_update_func = rect_select_cursor_update;
|
||||
tool->control_func = rect_select_control;
|
||||
tool->preserve = TRUE;
|
||||
|
|
|
@ -20,6 +20,17 @@
|
|||
|
||||
#include "gimpimageF.h"
|
||||
#include "tools.h"
|
||||
#include "channel.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SELECTION_ADD = ADD,
|
||||
SELECTION_SUB = SUB,
|
||||
SELECTION_REPLACE = REPLACE,
|
||||
SELECTION_INTERSECT = INTERSECT,
|
||||
SELECTION_MOVE_MASK,
|
||||
SELECTION_MOVE
|
||||
} SelectOps;
|
||||
|
||||
/* rect select action functions */
|
||||
void rect_select_button_press (Tool *, GdkEventButton *, gpointer);
|
||||
|
|
|
@ -9,11 +9,12 @@ struct _rect_select
|
|||
{
|
||||
DrawCore * core; /* Core select object */
|
||||
|
||||
int op; /* selection operation (SELECTION_ADD etc.) */
|
||||
|
||||
int x, y; /* upper left hand coordinate */
|
||||
int w, h; /* width and height */
|
||||
int center; /* is the selection being created from the center out? */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
int fixed_size;
|
||||
int fixed_width;
|
||||
int fixed_height;
|
||||
|
|
|
@ -118,6 +118,9 @@ init_edit_selection (Tool *tool,
|
|||
edit_select.cumly = 0;
|
||||
|
||||
/* Make a check to see if it should be a floating selection translation */
|
||||
if (edit_type == MaskToLayerTranslate && gimage_floating_sel (gdisp->gimage))
|
||||
edit_type = FloatingSelTranslate;
|
||||
|
||||
if (edit_type == LayerTranslate)
|
||||
{
|
||||
layer = gimage_get_active_layer (gdisp->gimage);
|
||||
|
|
|
@ -50,7 +50,7 @@ ellipse_select (GimpImage *gimage,
|
|||
Channel * new_mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == REPLACE)
|
||||
if (op == SELECTION_REPLACE)
|
||||
gimage_mask_clear (gimage);
|
||||
else
|
||||
gimage_mask_undo (gimage);
|
||||
|
@ -66,7 +66,7 @@ ellipse_select (GimpImage *gimage,
|
|||
feather_radius, op, 0, 0);
|
||||
channel_delete (new_mask);
|
||||
}
|
||||
else if (op == INTERSECT)
|
||||
else if (op == SELECTION_INTERSECT)
|
||||
{
|
||||
new_mask = channel_new_mask (gimage, gimage->width, gimage->height);
|
||||
channel_combine_ellipse (new_mask, ADD, x, y, w, h, antialias);
|
||||
|
@ -137,7 +137,8 @@ tools_new_ellipse_select (void)
|
|||
tool->button_press_func = rect_select_button_press;
|
||||
tool->button_release_func = rect_select_button_release;
|
||||
tool->motion_func = rect_select_motion;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func;
|
||||
tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->cursor_update_func = rect_select_cursor_update;
|
||||
tool->control_func = rect_select_control;
|
||||
tool->preserve = TRUE;
|
||||
|
|
|
@ -40,8 +40,10 @@ typedef struct _free_select FreeSelect;
|
|||
struct _free_select
|
||||
{
|
||||
DrawCore * core; /* Core select object */
|
||||
int num_pts; /* Number of points in the polygon */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
|
||||
int num_pts; /* Number of points in the polygon */
|
||||
};
|
||||
|
||||
struct _FreeSelectPoint
|
||||
|
@ -316,27 +318,15 @@ free_select_button_press (Tool *tool, GdkEventButton *bevent,
|
|||
tool->state = ACTIVE;
|
||||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
if (bevent->state & GDK_MOD1_MASK)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
}
|
||||
else if ((bevent->state & GDK_SHIFT_MASK) && !(bevent->state & GDK_CONTROL_MASK))
|
||||
free_sel->op = ADD;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && !(bevent->state & GDK_SHIFT_MASK))
|
||||
free_sel->op = SUB;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && (bevent->state & GDK_SHIFT_MASK))
|
||||
free_sel->op = INTERSECT;
|
||||
else
|
||||
{
|
||||
if (! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
gdisplay_mask_value (gdisp, bevent->x, bevent->y) > HALF_WAY)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
free_sel->op = REPLACE;
|
||||
}
|
||||
switch (free_sel->op)
|
||||
{
|
||||
case SELECTION_MOVE_MASK:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
case SELECTION_MOVE:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
add_point (0, bevent->x, bevent->y);
|
||||
free_sel->num_pts = 1;
|
||||
|
@ -470,6 +460,7 @@ tools_new_free_select (void)
|
|||
|
||||
private->core = draw_core_new (free_select_draw);
|
||||
private->num_pts = 0;
|
||||
private->op = SELECTION_REPLACE;
|
||||
|
||||
tool->type = FREE_SELECT;
|
||||
tool->state = INACTIVE;
|
||||
|
@ -477,10 +468,11 @@ tools_new_free_select (void)
|
|||
tool->auto_snap_to = TRUE;
|
||||
tool->private = (void *) private;
|
||||
|
||||
tool->button_press_func = free_select_button_press;
|
||||
tool->button_press_func = free_select_button_press;
|
||||
tool->button_release_func = free_select_button_release;
|
||||
tool->motion_func = free_select_motion;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func;
|
||||
tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->cursor_update_func = rect_select_cursor_update;
|
||||
tool->control_func = free_select_control;
|
||||
tool->preserve = TRUE;
|
||||
|
|
|
@ -39,12 +39,13 @@ struct _fuzzy_select
|
|||
{
|
||||
DrawCore * core; /* Core select object */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
|
||||
int x, y; /* Point from which to execute seed fill */
|
||||
int last_x; /* */
|
||||
int last_y; /* variables to keep track of sensitivity */
|
||||
int threshold; /* threshold value for soft seed fill */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
};
|
||||
|
||||
|
||||
|
@ -343,26 +344,15 @@ fuzzy_select_button_press (Tool *tool, GdkEventButton *bevent,
|
|||
tool->state = ACTIVE;
|
||||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
if (bevent->state & GDK_MOD1_MASK)
|
||||
if (fuzzy_sel->op == SELECTION_MOVE_MASK)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
}
|
||||
else if ((bevent->state & GDK_SHIFT_MASK) && !(bevent->state & GDK_CONTROL_MASK))
|
||||
fuzzy_sel->op = ADD;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && !(bevent->state & GDK_SHIFT_MASK))
|
||||
fuzzy_sel->op = SUB;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && (bevent->state & GDK_SHIFT_MASK))
|
||||
fuzzy_sel->op = INTERSECT;
|
||||
else
|
||||
else if (fuzzy_sel->op == SELECTION_MOVE)
|
||||
{
|
||||
if (! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
gdisplay_mask_value (gdisp, bevent->x, bevent->y) > HALF_WAY)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
fuzzy_sel->op = REPLACE;
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
/* calculate the region boundary */
|
||||
|
|
|
@ -118,6 +118,9 @@ init_edit_selection (Tool *tool,
|
|||
edit_select.cumly = 0;
|
||||
|
||||
/* Make a check to see if it should be a floating selection translation */
|
||||
if (edit_type == MaskToLayerTranslate && gimage_floating_sel (gdisp->gimage))
|
||||
edit_type = FloatingSelTranslate;
|
||||
|
||||
if (edit_type == LayerTranslate)
|
||||
{
|
||||
layer = gimage_get_active_layer (gdisp->gimage);
|
||||
|
|
|
@ -50,7 +50,7 @@ ellipse_select (GimpImage *gimage,
|
|||
Channel * new_mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == REPLACE)
|
||||
if (op == SELECTION_REPLACE)
|
||||
gimage_mask_clear (gimage);
|
||||
else
|
||||
gimage_mask_undo (gimage);
|
||||
|
@ -66,7 +66,7 @@ ellipse_select (GimpImage *gimage,
|
|||
feather_radius, op, 0, 0);
|
||||
channel_delete (new_mask);
|
||||
}
|
||||
else if (op == INTERSECT)
|
||||
else if (op == SELECTION_INTERSECT)
|
||||
{
|
||||
new_mask = channel_new_mask (gimage, gimage->width, gimage->height);
|
||||
channel_combine_ellipse (new_mask, ADD, x, y, w, h, antialias);
|
||||
|
@ -137,7 +137,8 @@ tools_new_ellipse_select (void)
|
|||
tool->button_press_func = rect_select_button_press;
|
||||
tool->button_release_func = rect_select_button_release;
|
||||
tool->motion_func = rect_select_motion;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func;
|
||||
tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->cursor_update_func = rect_select_cursor_update;
|
||||
tool->control_func = rect_select_control;
|
||||
tool->preserve = TRUE;
|
||||
|
|
|
@ -40,8 +40,10 @@ typedef struct _free_select FreeSelect;
|
|||
struct _free_select
|
||||
{
|
||||
DrawCore * core; /* Core select object */
|
||||
int num_pts; /* Number of points in the polygon */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
|
||||
int num_pts; /* Number of points in the polygon */
|
||||
};
|
||||
|
||||
struct _FreeSelectPoint
|
||||
|
@ -316,27 +318,15 @@ free_select_button_press (Tool *tool, GdkEventButton *bevent,
|
|||
tool->state = ACTIVE;
|
||||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
if (bevent->state & GDK_MOD1_MASK)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
}
|
||||
else if ((bevent->state & GDK_SHIFT_MASK) && !(bevent->state & GDK_CONTROL_MASK))
|
||||
free_sel->op = ADD;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && !(bevent->state & GDK_SHIFT_MASK))
|
||||
free_sel->op = SUB;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && (bevent->state & GDK_SHIFT_MASK))
|
||||
free_sel->op = INTERSECT;
|
||||
else
|
||||
{
|
||||
if (! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
gdisplay_mask_value (gdisp, bevent->x, bevent->y) > HALF_WAY)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
free_sel->op = REPLACE;
|
||||
}
|
||||
switch (free_sel->op)
|
||||
{
|
||||
case SELECTION_MOVE_MASK:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
case SELECTION_MOVE:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
add_point (0, bevent->x, bevent->y);
|
||||
free_sel->num_pts = 1;
|
||||
|
@ -470,6 +460,7 @@ tools_new_free_select (void)
|
|||
|
||||
private->core = draw_core_new (free_select_draw);
|
||||
private->num_pts = 0;
|
||||
private->op = SELECTION_REPLACE;
|
||||
|
||||
tool->type = FREE_SELECT;
|
||||
tool->state = INACTIVE;
|
||||
|
@ -477,10 +468,11 @@ tools_new_free_select (void)
|
|||
tool->auto_snap_to = TRUE;
|
||||
tool->private = (void *) private;
|
||||
|
||||
tool->button_press_func = free_select_button_press;
|
||||
tool->button_press_func = free_select_button_press;
|
||||
tool->button_release_func = free_select_button_release;
|
||||
tool->motion_func = free_select_motion;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func;
|
||||
tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->cursor_update_func = rect_select_cursor_update;
|
||||
tool->control_func = free_select_control;
|
||||
tool->preserve = TRUE;
|
||||
|
|
|
@ -39,12 +39,13 @@ struct _fuzzy_select
|
|||
{
|
||||
DrawCore * core; /* Core select object */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
|
||||
int x, y; /* Point from which to execute seed fill */
|
||||
int last_x; /* */
|
||||
int last_y; /* variables to keep track of sensitivity */
|
||||
int threshold; /* threshold value for soft seed fill */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
};
|
||||
|
||||
|
||||
|
@ -343,26 +344,15 @@ fuzzy_select_button_press (Tool *tool, GdkEventButton *bevent,
|
|||
tool->state = ACTIVE;
|
||||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
if (bevent->state & GDK_MOD1_MASK)
|
||||
if (fuzzy_sel->op == SELECTION_MOVE_MASK)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
}
|
||||
else if ((bevent->state & GDK_SHIFT_MASK) && !(bevent->state & GDK_CONTROL_MASK))
|
||||
fuzzy_sel->op = ADD;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && !(bevent->state & GDK_SHIFT_MASK))
|
||||
fuzzy_sel->op = SUB;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && (bevent->state & GDK_SHIFT_MASK))
|
||||
fuzzy_sel->op = INTERSECT;
|
||||
else
|
||||
else if (fuzzy_sel->op == SELECTION_MOVE)
|
||||
{
|
||||
if (! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
gdisplay_mask_value (gdisp, bevent->x, bevent->y) > HALF_WAY)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
fuzzy_sel->op = REPLACE;
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
/* calculate the region boundary */
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
#include "appenv.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimage_mask.h"
|
||||
|
@ -24,6 +25,7 @@
|
|||
#include "rect_select.h"
|
||||
#include "rect_selectP.h"
|
||||
#include "selection_options.h"
|
||||
#include "cursorutil.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "libgimp/gimpunitmenu.h"
|
||||
|
@ -39,6 +41,8 @@ static SelectionOptions *rect_options = NULL;
|
|||
extern SelectionOptions *ellipse_options;
|
||||
extern void ellipse_select (GImage *, int, int, int, int, int, int, int, double);
|
||||
|
||||
static void selection_tool_update_op_state(RectSelect *rect_sel, int x, int y,
|
||||
int state, GDisplay *gdisp);
|
||||
|
||||
/*************************************/
|
||||
/* Rectangular selection apparatus */
|
||||
|
@ -56,7 +60,7 @@ rect_select (GimpImage *gimage,
|
|||
Channel * new_mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == REPLACE)
|
||||
if (op == SELECTION_REPLACE)
|
||||
gimage_mask_clear (gimage);
|
||||
else
|
||||
gimage_mask_undo (gimage);
|
||||
|
@ -72,7 +76,7 @@ rect_select (GimpImage *gimage,
|
|||
feather_radius, op, 0, 0);
|
||||
channel_delete (new_mask);
|
||||
}
|
||||
else if (op == INTERSECT)
|
||||
else if (op == SELECTION_INTERSECT)
|
||||
{
|
||||
new_mask = channel_new_mask (gimage, gimage->width, gimage->height);
|
||||
channel_combine_rect (new_mask, ADD, x, y, w, h);
|
||||
|
@ -154,43 +158,31 @@ rect_select_button_press (Tool *tool,
|
|||
tool->state = ACTIVE;
|
||||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
if (bevent->state & GDK_MOD1_MASK)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
}
|
||||
else if ((bevent->state & GDK_SHIFT_MASK) && !(bevent->state & GDK_CONTROL_MASK))
|
||||
rect_sel->op = ADD;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && !(bevent->state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = SUB;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && (bevent->state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = INTERSECT;
|
||||
else
|
||||
{
|
||||
if (! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
gdisplay_mask_value (gdisp, bevent->x, bevent->y) > HALF_WAY)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
rect_sel->op = REPLACE;
|
||||
}
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
case SELECTION_MOVE_MASK:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
case SELECTION_MOVE:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
/* initialize the statusbar display */
|
||||
rect_sel->context_id =
|
||||
gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "selection");
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
case ADD:
|
||||
case SELECTION_ADD:
|
||||
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: ADD"));
|
||||
break;
|
||||
case SUB:
|
||||
case SELECTION_SUB:
|
||||
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: SUBTRACT"));
|
||||
break;
|
||||
case INTERSECT:
|
||||
case SELECTION_INTERSECT:
|
||||
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: INTERSECT"));
|
||||
break;
|
||||
case REPLACE:
|
||||
case SELECTION_REPLACE:
|
||||
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: REPLACE"));
|
||||
break;
|
||||
default:
|
||||
|
@ -452,33 +444,70 @@ rect_select_draw (Tool *tool)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
static selection_tool_update_op_state(RectSelect *rect_sel, int x, int y, int state,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
if (active_tool->state == ACTIVE)
|
||||
return;
|
||||
|
||||
if (state & GDK_MOD1_MASK &&
|
||||
!(layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))))
|
||||
rect_sel->op = SELECTION_MOVE_MASK; /* move just the selection mask */
|
||||
else if (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage)) ||
|
||||
(!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
|
||||
gdisplay_mask_value (gdisp, x, y)))
|
||||
rect_sel->op = SELECTION_MOVE; /* move the selection */
|
||||
else if ((state & GDK_SHIFT_MASK) &&
|
||||
!(state & GDK_CONTROL_MASK))
|
||||
rect_sel->op = SELECTION_ADD; /* add to the selection */
|
||||
else if ((state & GDK_CONTROL_MASK) &&
|
||||
!(state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = SELECTION_SUB; /* subtract from the selection */
|
||||
else if ((state & GDK_CONTROL_MASK) &&
|
||||
(state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */
|
||||
else
|
||||
rect_sel->op = SELECTION_REPLACE; /* replace the selection */
|
||||
}
|
||||
|
||||
void
|
||||
rect_select_cursor_update (Tool *tool,
|
||||
GdkEventMotion *mevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
int active;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
RectSelect *rect_sel;
|
||||
GDisplay *gdisp;
|
||||
gdisp = (GDisplay *)gdisp_ptr;
|
||||
active = (active_tool->state == ACTIVE);
|
||||
rect_sel = (RectSelect*)tool->private;
|
||||
|
||||
/* if alt key is depressed, use the diamond cursor */
|
||||
if (mevent->state & GDK_MOD1_MASK && !active)
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_DIAMOND_CROSS);
|
||||
/* if the cursor is over the selected region, but no modifiers
|
||||
* are depressed, use a fleur cursor--for cutting and moving the selection
|
||||
*/
|
||||
else if (gdisplay_mask_value (gdisp, mevent->x, mevent->y) &&
|
||||
! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
! (mevent->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
|
||||
! active)
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
else
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
selection_tool_update_op_state(rect_sel, mevent->x, mevent->y,
|
||||
mevent->state, gdisp_ptr);
|
||||
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
case SELECTION_ADD:
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_MOUSE1P_CURSOR);
|
||||
break;
|
||||
case SELECTION_SUB:
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_MOUSE1M_CURSOR);
|
||||
break;
|
||||
case SELECTION_INTERSECT: /* need a real cursor for this one */
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_BIGCIRC_CURSOR);
|
||||
break;
|
||||
case SELECTION_REPLACE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
break;
|
||||
case SELECTION_MOVE_MASK:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_DIAMOND_CROSS);
|
||||
break;
|
||||
case SELECTION_MOVE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
rect_select_control (Tool *tool,
|
||||
int action,
|
||||
|
@ -528,6 +557,7 @@ tools_new_rect_select ()
|
|||
private->core = draw_core_new (rect_select_draw);
|
||||
private->x = private->y = 0;
|
||||
private->w = private->h = 0;
|
||||
private->op = SELECTION_REPLACE;
|
||||
|
||||
tool->type = RECT_SELECT;
|
||||
tool->state = INACTIVE;
|
||||
|
@ -538,7 +568,8 @@ tools_new_rect_select ()
|
|||
tool->button_press_func = rect_select_button_press;
|
||||
tool->button_release_func = rect_select_button_release;
|
||||
tool->motion_func = rect_select_motion;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func;
|
||||
tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->cursor_update_func = rect_select_cursor_update;
|
||||
tool->control_func = rect_select_control;
|
||||
tool->preserve = TRUE;
|
||||
|
|
|
@ -20,6 +20,17 @@
|
|||
|
||||
#include "gimpimageF.h"
|
||||
#include "tools.h"
|
||||
#include "channel.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SELECTION_ADD = ADD,
|
||||
SELECTION_SUB = SUB,
|
||||
SELECTION_REPLACE = REPLACE,
|
||||
SELECTION_INTERSECT = INTERSECT,
|
||||
SELECTION_MOVE_MASK,
|
||||
SELECTION_MOVE
|
||||
} SelectOps;
|
||||
|
||||
/* rect select action functions */
|
||||
void rect_select_button_press (Tool *, GdkEventButton *, gpointer);
|
||||
|
|
|
@ -39,12 +39,13 @@ struct _fuzzy_select
|
|||
{
|
||||
DrawCore * core; /* Core select object */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
|
||||
int x, y; /* Point from which to execute seed fill */
|
||||
int last_x; /* */
|
||||
int last_y; /* variables to keep track of sensitivity */
|
||||
int threshold; /* threshold value for soft seed fill */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
};
|
||||
|
||||
|
||||
|
@ -343,26 +344,15 @@ fuzzy_select_button_press (Tool *tool, GdkEventButton *bevent,
|
|||
tool->state = ACTIVE;
|
||||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
if (bevent->state & GDK_MOD1_MASK)
|
||||
if (fuzzy_sel->op == SELECTION_MOVE_MASK)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
}
|
||||
else if ((bevent->state & GDK_SHIFT_MASK) && !(bevent->state & GDK_CONTROL_MASK))
|
||||
fuzzy_sel->op = ADD;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && !(bevent->state & GDK_SHIFT_MASK))
|
||||
fuzzy_sel->op = SUB;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && (bevent->state & GDK_SHIFT_MASK))
|
||||
fuzzy_sel->op = INTERSECT;
|
||||
else
|
||||
else if (fuzzy_sel->op == SELECTION_MOVE)
|
||||
{
|
||||
if (! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
gdisplay_mask_value (gdisp, bevent->x, bevent->y) > HALF_WAY)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
fuzzy_sel->op = REPLACE;
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
/* calculate the region boundary */
|
||||
|
|
|
@ -186,8 +186,8 @@ paint_core_button_press (tool, bevent, gdisp_ptr)
|
|||
/* pause the current selection and grab the pointer */
|
||||
gdisplays_selection_visibility (gdisp->gimage, SelectionPause);
|
||||
|
||||
/* add motion memory if you press mod1 first ^ perfectmouse */
|
||||
if (perfectmouse == 0)
|
||||
/* add motion memory if perfectmouse is set */
|
||||
if (perfectmouse != 0)
|
||||
gdk_pointer_grab (gdisp->canvas->window, FALSE,
|
||||
GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
|
||||
NULL, NULL, bevent->time);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
#include "appenv.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gimage_mask.h"
|
||||
|
@ -24,6 +25,7 @@
|
|||
#include "rect_select.h"
|
||||
#include "rect_selectP.h"
|
||||
#include "selection_options.h"
|
||||
#include "cursorutil.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "libgimp/gimpunitmenu.h"
|
||||
|
@ -39,6 +41,8 @@ static SelectionOptions *rect_options = NULL;
|
|||
extern SelectionOptions *ellipse_options;
|
||||
extern void ellipse_select (GImage *, int, int, int, int, int, int, int, double);
|
||||
|
||||
static void selection_tool_update_op_state(RectSelect *rect_sel, int x, int y,
|
||||
int state, GDisplay *gdisp);
|
||||
|
||||
/*************************************/
|
||||
/* Rectangular selection apparatus */
|
||||
|
@ -56,7 +60,7 @@ rect_select (GimpImage *gimage,
|
|||
Channel * new_mask;
|
||||
|
||||
/* if applicable, replace the current selection */
|
||||
if (op == REPLACE)
|
||||
if (op == SELECTION_REPLACE)
|
||||
gimage_mask_clear (gimage);
|
||||
else
|
||||
gimage_mask_undo (gimage);
|
||||
|
@ -72,7 +76,7 @@ rect_select (GimpImage *gimage,
|
|||
feather_radius, op, 0, 0);
|
||||
channel_delete (new_mask);
|
||||
}
|
||||
else if (op == INTERSECT)
|
||||
else if (op == SELECTION_INTERSECT)
|
||||
{
|
||||
new_mask = channel_new_mask (gimage, gimage->width, gimage->height);
|
||||
channel_combine_rect (new_mask, ADD, x, y, w, h);
|
||||
|
@ -154,43 +158,31 @@ rect_select_button_press (Tool *tool,
|
|||
tool->state = ACTIVE;
|
||||
tool->gdisp_ptr = gdisp_ptr;
|
||||
|
||||
if (bevent->state & GDK_MOD1_MASK)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
}
|
||||
else if ((bevent->state & GDK_SHIFT_MASK) && !(bevent->state & GDK_CONTROL_MASK))
|
||||
rect_sel->op = ADD;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && !(bevent->state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = SUB;
|
||||
else if ((bevent->state & GDK_CONTROL_MASK) && (bevent->state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = INTERSECT;
|
||||
else
|
||||
{
|
||||
if (! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
gdisplay_mask_value (gdisp, bevent->x, bevent->y) > HALF_WAY)
|
||||
{
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
rect_sel->op = REPLACE;
|
||||
}
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
case SELECTION_MOVE_MASK:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskTranslate);
|
||||
return;
|
||||
case SELECTION_MOVE:
|
||||
init_edit_selection (tool, gdisp_ptr, bevent, MaskToLayerTranslate);
|
||||
return;
|
||||
}
|
||||
|
||||
/* initialize the statusbar display */
|
||||
rect_sel->context_id =
|
||||
gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "selection");
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
case ADD:
|
||||
case SELECTION_ADD:
|
||||
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: ADD"));
|
||||
break;
|
||||
case SUB:
|
||||
case SELECTION_SUB:
|
||||
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: SUBTRACT"));
|
||||
break;
|
||||
case INTERSECT:
|
||||
case SELECTION_INTERSECT:
|
||||
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: INTERSECT"));
|
||||
break;
|
||||
case REPLACE:
|
||||
case SELECTION_REPLACE:
|
||||
g_snprintf (select_mode, STATUSBAR_SIZE, _("Selection: REPLACE"));
|
||||
break;
|
||||
default:
|
||||
|
@ -452,33 +444,70 @@ rect_select_draw (Tool *tool)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
static selection_tool_update_op_state(RectSelect *rect_sel, int x, int y, int state,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
if (active_tool->state == ACTIVE)
|
||||
return;
|
||||
|
||||
if (state & GDK_MOD1_MASK &&
|
||||
!(layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))))
|
||||
rect_sel->op = SELECTION_MOVE_MASK; /* move just the selection mask */
|
||||
else if (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage)) ||
|
||||
(!(state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
|
||||
gdisplay_mask_value (gdisp, x, y)))
|
||||
rect_sel->op = SELECTION_MOVE; /* move the selection */
|
||||
else if ((state & GDK_SHIFT_MASK) &&
|
||||
!(state & GDK_CONTROL_MASK))
|
||||
rect_sel->op = SELECTION_ADD; /* add to the selection */
|
||||
else if ((state & GDK_CONTROL_MASK) &&
|
||||
!(state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = SELECTION_SUB; /* subtract from the selection */
|
||||
else if ((state & GDK_CONTROL_MASK) &&
|
||||
(state & GDK_SHIFT_MASK))
|
||||
rect_sel->op = SELECTION_INTERSECT;/* intersect with selection */
|
||||
else
|
||||
rect_sel->op = SELECTION_REPLACE; /* replace the selection */
|
||||
}
|
||||
|
||||
void
|
||||
rect_select_cursor_update (Tool *tool,
|
||||
GdkEventMotion *mevent,
|
||||
gpointer gdisp_ptr)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
int active;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
RectSelect *rect_sel;
|
||||
GDisplay *gdisp;
|
||||
gdisp = (GDisplay *)gdisp_ptr;
|
||||
active = (active_tool->state == ACTIVE);
|
||||
rect_sel = (RectSelect*)tool->private;
|
||||
|
||||
/* if alt key is depressed, use the diamond cursor */
|
||||
if (mevent->state & GDK_MOD1_MASK && !active)
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_DIAMOND_CROSS);
|
||||
/* if the cursor is over the selected region, but no modifiers
|
||||
* are depressed, use a fleur cursor--for cutting and moving the selection
|
||||
*/
|
||||
else if (gdisplay_mask_value (gdisp, mevent->x, mevent->y) &&
|
||||
! (layer_is_floating_sel (gimage_get_active_layer (gdisp->gimage))) &&
|
||||
! (mevent->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) &&
|
||||
! active)
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
else
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
selection_tool_update_op_state(rect_sel, mevent->x, mevent->y,
|
||||
mevent->state, gdisp_ptr);
|
||||
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
case SELECTION_ADD:
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_MOUSE1P_CURSOR);
|
||||
break;
|
||||
case SELECTION_SUB:
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_MOUSE1M_CURSOR);
|
||||
break;
|
||||
case SELECTION_INTERSECT: /* need a real cursor for this one */
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_BIGCIRC_CURSOR);
|
||||
break;
|
||||
case SELECTION_REPLACE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
break;
|
||||
case SELECTION_MOVE_MASK:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_DIAMOND_CROSS);
|
||||
break;
|
||||
case SELECTION_MOVE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_FLEUR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
rect_select_control (Tool *tool,
|
||||
int action,
|
||||
|
@ -528,6 +557,7 @@ tools_new_rect_select ()
|
|||
private->core = draw_core_new (rect_select_draw);
|
||||
private->x = private->y = 0;
|
||||
private->w = private->h = 0;
|
||||
private->op = SELECTION_REPLACE;
|
||||
|
||||
tool->type = RECT_SELECT;
|
||||
tool->state = INACTIVE;
|
||||
|
@ -538,7 +568,8 @@ tools_new_rect_select ()
|
|||
tool->button_press_func = rect_select_button_press;
|
||||
tool->button_release_func = rect_select_button_release;
|
||||
tool->motion_func = rect_select_motion;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func; tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->arrow_keys_func = standard_arrow_keys_func;
|
||||
tool->modifier_key_func = standard_modifier_key_func;
|
||||
tool->cursor_update_func = rect_select_cursor_update;
|
||||
tool->control_func = rect_select_control;
|
||||
tool->preserve = TRUE;
|
||||
|
|
|
@ -20,6 +20,17 @@
|
|||
|
||||
#include "gimpimageF.h"
|
||||
#include "tools.h"
|
||||
#include "channel.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SELECTION_ADD = ADD,
|
||||
SELECTION_SUB = SUB,
|
||||
SELECTION_REPLACE = REPLACE,
|
||||
SELECTION_INTERSECT = INTERSECT,
|
||||
SELECTION_MOVE_MASK,
|
||||
SELECTION_MOVE
|
||||
} SelectOps;
|
||||
|
||||
/* rect select action functions */
|
||||
void rect_select_button_press (Tool *, GdkEventButton *, gpointer);
|
||||
|
|
|
@ -9,11 +9,12 @@ struct _rect_select
|
|||
{
|
||||
DrawCore * core; /* Core select object */
|
||||
|
||||
int op; /* selection operation (SELECTION_ADD etc.) */
|
||||
|
||||
int x, y; /* upper left hand coordinate */
|
||||
int w, h; /* width and height */
|
||||
int center; /* is the selection being created from the center out? */
|
||||
|
||||
int op; /* selection operation (ADD, SUB, etc) */
|
||||
int fixed_size;
|
||||
int fixed_width;
|
||||
int fixed_height;
|
||||
|
|
|
@ -19,12 +19,82 @@
|
|||
#include "cursorutil.h"
|
||||
#include "dialog_handler.h"
|
||||
#include "gdisplay.h" /* for gdisplay_*_override_cursor() */
|
||||
#include "../pixmaps/mouse1"
|
||||
#include "../pixmaps/mouse1msk"
|
||||
#include "../pixmaps/mouse1_p"
|
||||
#include "../pixmaps/mouse1_pmsk"
|
||||
#include "../pixmaps/mouse1_m"
|
||||
#include "../pixmaps/mouse1_mmsk"
|
||||
#include "../pixmaps/bigcirc"
|
||||
#include "../pixmaps/bigcircmsk"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char *bits;
|
||||
unsigned char *mask_bits;
|
||||
int width, height;
|
||||
int x_hot, y_hot;
|
||||
GdkCursor *cursor;
|
||||
} BM_Cursor;
|
||||
|
||||
static BM_Cursor gimp_cursors[] =
|
||||
/* these have to match up with the enum in cursorutil.h */
|
||||
{
|
||||
{ mouse1_bits, mouse1msk_bits, mouse1_width, mouse1_height,
|
||||
mouse1_x_hot, mouse1_y_hot, NULL},
|
||||
{ mouse1_p_bits, mouse1_pmsk_bits, mouse1_p_width, mouse1_p_height,
|
||||
mouse1_p_x_hot, mouse1_p_y_hot, NULL},
|
||||
{ mouse1_m_bits, mouse1_mmsk_bits, mouse1_m_width, mouse1_m_height,
|
||||
mouse1_m_x_hot, mouse1_m_y_hot, NULL},
|
||||
{ bigcirc_bits, bigcircmsk_bits, bigcirc_width, bigcirc_height,
|
||||
bigcirc_x_hot, bigcirc_y_hot, NULL},
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern GSList* display_list; /* It's in gdisplay.c, FYI */
|
||||
static gboolean pending_removebusy = FALSE;
|
||||
|
||||
|
||||
static void
|
||||
create_cursor(BM_Cursor *bmcursor)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkPixmap *pixmapmsk;
|
||||
GdkColor fg, bg;
|
||||
|
||||
/* should have a way to configure the mouse colors */
|
||||
gdk_color_parse("#FFFFFF", &bg);
|
||||
gdk_color_parse("#000000", &fg);
|
||||
|
||||
pixmap = gdk_bitmap_create_from_data (NULL, bmcursor->bits,
|
||||
bmcursor->width, bmcursor->height);
|
||||
g_return_if_fail(pixmap != NULL);
|
||||
|
||||
pixmapmsk = gdk_bitmap_create_from_data (NULL, bmcursor->mask_bits,
|
||||
bmcursor->width,
|
||||
bmcursor->height);
|
||||
g_return_if_fail(pixmapmsk != NULL);
|
||||
|
||||
bmcursor->cursor = gdk_cursor_new_from_pixmap(pixmap, pixmapmsk, &fg, &bg,
|
||||
bmcursor->x_hot,
|
||||
bmcursor->y_hot);
|
||||
g_return_if_fail(bmcursor->cursor != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_change_win_cursor(GdkWindow *win, GimpCursorType curtype)
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
g_return_if_fail (curtype < GIMP_LAST_CURSOR_ENTRY);
|
||||
if (!gimp_cursors[(int)curtype].cursor)
|
||||
create_cursor(&gimp_cursors[(int)curtype]);
|
||||
cursor = gimp_cursors[(int)curtype].cursor;
|
||||
gdk_window_set_cursor (win, cursor);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
change_win_cursor (win, cursortype)
|
||||
GdkWindow *win;
|
||||
|
|
|
@ -20,8 +20,18 @@
|
|||
|
||||
#include <gdk/gdktypes.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_MOUSE1_CURSOR,
|
||||
GIMP_MOUSE1P_CURSOR,
|
||||
GIMP_MOUSE1M_CURSOR,
|
||||
GIMP_BIGCIRC_CURSOR,
|
||||
GIMP_LAST_CURSOR_ENTRY
|
||||
} GimpCursorType;
|
||||
|
||||
void change_win_cursor (GdkWindow *, GdkCursorType);
|
||||
void unset_win_cursor (GdkWindow *);
|
||||
void gimp_change_win_cursor (GdkWindow *, GimpCursorType);
|
||||
|
||||
void gimp_add_busy_cursors_until_idle (void);
|
||||
void gimp_add_busy_cursors (void);
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#define bigcirc_width 50
|
||||
#define bigcirc_height 50
|
||||
#define bigcirc_x_hot 23
|
||||
#define bigcirc_y_hot 25
|
||||
static unsigned char bigcirc_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
|
||||
0x00, 0x00, 0x00, 0x80, 0x03, 0x80, 0x03, 0x00, 0x00, 0x00, 0x60, 0x00,
|
||||
0x00, 0x0c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x01,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x40, 0x00, 0x00, 0x00,
|
||||
0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x20, 0x00,
|
||||
0x00, 0x00, 0x00, 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x08, 0x00, 0xc0, 0x01, 0x00,
|
||||
0x20, 0x00, 0x04, 0x00, 0x38, 0x0e, 0x00, 0x40, 0x00, 0x04, 0x00, 0x06,
|
||||
0x30, 0x00, 0x40, 0x00, 0x02, 0x80, 0x01, 0xc0, 0x00, 0x80, 0x00, 0x02,
|
||||
0x40, 0x00, 0x00, 0x01, 0x80, 0x00, 0x02, 0x40, 0x00, 0x00, 0x01, 0x80,
|
||||
0x00, 0x01, 0x20, 0x00, 0x00, 0x02, 0x00, 0x01, 0x01, 0x20, 0x00, 0x00,
|
||||
0x02, 0x00, 0x01, 0x01, 0x10, 0x00, 0x00, 0x04, 0x00, 0x01, 0x01, 0x10,
|
||||
0x00, 0x00, 0x04, 0x00, 0x01, 0x01, 0x10, 0x00, 0x00, 0x04, 0x00, 0x01,
|
||||
0x01, 0x08, 0x00, 0x00, 0x08, 0x00, 0x01, 0x01, 0x08, 0x00, 0x00, 0x08,
|
||||
0x00, 0x01, 0x01, 0x08, 0x00, 0x00, 0x08, 0x00, 0x01, 0x01, 0x10, 0x00,
|
||||
0x00, 0x04, 0x00, 0x01, 0x01, 0x10, 0x00, 0x00, 0x04, 0x00, 0x01, 0x01,
|
||||
0x10, 0x00, 0x00, 0x04, 0x00, 0x01, 0x01, 0x20, 0x00, 0x00, 0x02, 0x00,
|
||||
0x01, 0x01, 0x20, 0x00, 0x00, 0x02, 0x00, 0x01, 0x02, 0x40, 0x00, 0x00,
|
||||
0x01, 0x80, 0x00, 0x02, 0x40, 0x00, 0x00, 0x01, 0x80, 0x00, 0x02, 0x80,
|
||||
0x01, 0xc0, 0x00, 0x80, 0x00, 0x04, 0x00, 0x06, 0x30, 0x00, 0x40, 0x00,
|
||||
0x04, 0x00, 0x38, 0x0e, 0x00, 0x40, 0x00, 0x08, 0x00, 0xc0, 0x01, 0x00,
|
||||
0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x10, 0x00, 0x00,
|
||||
0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x20,
|
||||
0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x04,
|
||||
0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00,
|
||||
0x80, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x18,
|
||||
0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x0c, 0x00, 0x00,
|
||||
0x00, 0x80, 0x03, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
|
||||
0x00, 0x00};
|
|
@ -0,0 +1,33 @@
|
|||
#define bigcircmsk_width 50
|
||||
#define bigcircmsk_height 50
|
||||
static unsigned char bigcircmsk_bits[] = {
|
||||
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
|
||||
0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xf0, 0x0f,
|
||||
0xe0, 0x0f, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00,
|
||||
0x3f, 0x00, 0x00, 0x78, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0xf0, 0x01,
|
||||
0x00, 0xc0, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00, 0xe0, 0x03, 0x00, 0x00,
|
||||
0x80, 0x07, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x78, 0x00,
|
||||
0x00, 0x00, 0x00, 0x0e, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00,
|
||||
0x3c, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x1c, 0x00, 0xf8, 0x0f, 0x00,
|
||||
0x30, 0x00, 0x1e, 0x00, 0xfe, 0x3f, 0x00, 0x70, 0x00, 0x0e, 0x00, 0x1f,
|
||||
0x7c, 0x00, 0x60, 0x00, 0x0e, 0xc0, 0x03, 0xe0, 0x01, 0xe0, 0x00, 0x07,
|
||||
0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x07, 0xe0, 0x00, 0x80, 0x03, 0xc0,
|
||||
0x00, 0x07, 0x70, 0x00, 0x00, 0x07, 0xc0, 0x01, 0x07, 0x30, 0x00, 0x00,
|
||||
0x06, 0xc0, 0x01, 0x03, 0x38, 0x00, 0x00, 0x0e, 0x80, 0x01, 0x03, 0x38,
|
||||
0x00, 0x00, 0x0e, 0x80, 0x01, 0x03, 0x18, 0x00, 0x00, 0x0c, 0x80, 0x01,
|
||||
0x03, 0x18, 0x00, 0x00, 0x0c, 0x80, 0x01, 0x03, 0x18, 0x00, 0x00, 0x0c,
|
||||
0x80, 0x01, 0x03, 0x18, 0x00, 0x00, 0x0c, 0x80, 0x01, 0x03, 0x18, 0x00,
|
||||
0x00, 0x0c, 0x80, 0x01, 0x03, 0x38, 0x00, 0x00, 0x0e, 0x80, 0x01, 0x03,
|
||||
0x38, 0x00, 0x00, 0x0e, 0x80, 0x01, 0x07, 0x30, 0x00, 0x00, 0x06, 0xc0,
|
||||
0x01, 0x07, 0x70, 0x00, 0x00, 0x07, 0xc0, 0x01, 0x07, 0xe0, 0x00, 0x80,
|
||||
0x03, 0xc0, 0x00, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x00, 0x0f, 0xc0,
|
||||
0x03, 0xe0, 0x01, 0xe0, 0x00, 0x0e, 0x00, 0x1f, 0x7c, 0x00, 0x60, 0x00,
|
||||
0x1e, 0x00, 0xfe, 0x3f, 0x00, 0x70, 0x00, 0x1c, 0x00, 0xf8, 0x0f, 0x00,
|
||||
0x30, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x38, 0x00, 0x00,
|
||||
0x00, 0x00, 0x1c, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xf0,
|
||||
0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x80, 0x07,
|
||||
0x00, 0xc0, 0x03, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x80, 0x07, 0x00, 0x00,
|
||||
0xe0, 0x01, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x7c,
|
||||
0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0xe0, 0x0f, 0x00, 0x00,
|
||||
0x00, 0xc0, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
|
||||
0x00, 0x00};
|
|
@ -0,0 +1,8 @@
|
|||
#define mouse1_width 14
|
||||
#define mouse1_height 17
|
||||
#define mouse1_x_hot 1
|
||||
#define mouse1_y_hot 1
|
||||
static unsigned char mouse1_bits[] = {
|
||||
0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x1e, 0x00, 0x3e, 0x00,
|
||||
0x7e, 0x00, 0xfe, 0x00, 0xfe, 0x01, 0x3e, 0x00, 0x06, 0x00, 0x02, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
@ -0,0 +1,8 @@
|
|||
#define mouse1_m_width 14
|
||||
#define mouse1_m_height 17
|
||||
#define mouse1_m_x_hot 1
|
||||
#define mouse1_m_y_hot 1
|
||||
static unsigned char mouse1_m_bits[] = {
|
||||
0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x1e, 0x00, 0x3e, 0x00,
|
||||
0x7e, 0x00, 0xfe, 0x00, 0xfe, 0x01, 0x3e, 0x00, 0x06, 0x00, 0x02, 0x00,
|
||||
0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
@ -0,0 +1,6 @@
|
|||
#define mouse1_mmsk_width 14
|
||||
#define mouse1_mmsk_height 17
|
||||
static unsigned char mouse1_mmsk_bits[] = {
|
||||
0x03, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00, 0x3f, 0x00, 0x7f, 0x00,
|
||||
0xff, 0x00, 0xff, 0x01, 0xff, 0x03, 0xff, 0x01, 0x3f, 0x00, 0x07, 0x00,
|
||||
0x83, 0x3f, 0x80, 0x3f, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00};
|
|
@ -0,0 +1,8 @@
|
|||
#define mouse1_p_width 14
|
||||
#define mouse1_p_height 17
|
||||
#define mouse1_p_x_hot 1
|
||||
#define mouse1_p_y_hot 1
|
||||
static unsigned char mouse1_p_bits[] = {
|
||||
0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x1e, 0x00, 0x3e, 0x00,
|
||||
0x7e, 0x00, 0xfe, 0x00, 0xfe, 0x01, 0x3e, 0x00, 0x06, 0x00, 0x02, 0x04,
|
||||
0x00, 0x04, 0x00, 0x1f, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00};
|
|
@ -0,0 +1,6 @@
|
|||
#define mouse1_pmsk_width 14
|
||||
#define mouse1_pmsk_height 17
|
||||
static unsigned char mouse1_pmsk_bits[] = {
|
||||
0x03, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00, 0x3f, 0x00, 0x7f, 0x00,
|
||||
0xff, 0x00, 0xff, 0x01, 0xff, 0x03, 0xff, 0x01, 0x3f, 0x0e, 0x07, 0x0e,
|
||||
0x83, 0x3f, 0x80, 0x3f, 0x80, 0x3f, 0x00, 0x0e, 0x00, 0x0e};
|
|
@ -0,0 +1,6 @@
|
|||
#define mouse1msk_width 14
|
||||
#define mouse1msk_height 17
|
||||
static unsigned char mouse1msk_bits[] = {
|
||||
0x03, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, 0x00, 0x3f, 0x00, 0x7f, 0x00,
|
||||
0xff, 0x00, 0xff, 0x01, 0xff, 0x03, 0xff, 0x01, 0x3f, 0x00, 0x07, 0x00,
|
||||
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
Loading…
Reference in New Issue