set the fg or bg color if ctrl or alt is held. use the new dropper cursor.
* app/paint_core.[ch]: set the fg or bg color if ctrl or alt is held. use the new dropper cursor. * app/cursorutil.[ch], app/gdisplay.[ch], app/rect_select.c: Use GimpCursorType enum values > GDK_CURSOR_LAST instead of seperate functions to choose between cursor types. * app/color_picker.c: use the new dropper cursor. * app/paintbrush.c, app/airbrush.c, app/paintbrush.c: use the new color picking feature of paint_core. * cursors/dropper, cursors/droppermsk: new cursor for the color picker tool. (this cursor is REALLY ugly, someone should fix it)
This commit is contained in:
@ -178,6 +178,7 @@ tools_new_airbrush ()
|
||||
|
||||
private = (PaintCore *) tool->private;
|
||||
private->paint_func = airbrush_paint_func;
|
||||
private->pick_colors = TRUE;
|
||||
|
||||
return tool;
|
||||
}
|
||||
@ -198,10 +199,10 @@ airbrush_paint_func (PaintCore *paint_core,
|
||||
case INIT_PAINT :
|
||||
/* timer_state = OFF; */
|
||||
if (timer_state == ON)
|
||||
{
|
||||
g_warning (_("killing stray timer, please report to lewing@gimp.org"));
|
||||
gtk_timeout_remove (timer);
|
||||
}
|
||||
{
|
||||
g_warning (_("killing stray timer, please report to lewing@gimp.org"));
|
||||
gtk_timeout_remove (timer);
|
||||
}
|
||||
timer_state = OFF;
|
||||
break;
|
||||
|
||||
@ -213,13 +214,13 @@ airbrush_paint_func (PaintCore *paint_core,
|
||||
airbrush_motion (paint_core, drawable, airbrush_options->pressure);
|
||||
|
||||
if (airbrush_options->rate != 0.0)
|
||||
{
|
||||
airbrush_timeout.paint_core = paint_core;
|
||||
airbrush_timeout.drawable = drawable;
|
||||
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
|
||||
airbrush_time_out, NULL);
|
||||
timer_state = ON;
|
||||
}
|
||||
{
|
||||
airbrush_timeout.paint_core = paint_core;
|
||||
airbrush_timeout.drawable = drawable;
|
||||
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
|
||||
airbrush_time_out, NULL);
|
||||
timer_state = ON;
|
||||
}
|
||||
break;
|
||||
|
||||
case FINISH_PAINT :
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "draw_core.h"
|
||||
#include "drawable.h"
|
||||
#include "gdisplay.h"
|
||||
#include "cursorutil.h"
|
||||
#include "info_dialog.h"
|
||||
#include "palette.h"
|
||||
#include "tool_options_ui.h"
|
||||
@ -371,7 +372,7 @@ color_picker_cursor_update (Tool *tool,
|
||||
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE);
|
||||
if (gimage_pick_correlate_layer (gdisp->gimage, x, y))
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_COLOR_PICKER_CURSOR);
|
||||
else
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
|
||||
}
|
||||
|
@ -1473,31 +1473,14 @@ 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 != (int)cursor_type || gdisp->cursor_type != 0)
|
||||
if (gdisp->current_cursor != (int)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);
|
||||
|
@ -138,7 +138,7 @@ struct _GDisplay
|
||||
GSList *display_areas; /* Display areas list */
|
||||
|
||||
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 ? */
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "../cursors/mouse1_mmsk"
|
||||
#include "../cursors/bigcirc"
|
||||
#include "../cursors/bigcircmsk"
|
||||
#include "../cursors/dropper"
|
||||
#include "../cursors/droppermsk"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -48,6 +50,8 @@ static BM_Cursor gimp_cursors[] =
|
||||
mouse1_m_x_hot, mouse1_m_y_hot, NULL},
|
||||
{ bigcirc_bits, bigcircmsk_bits, bigcirc_width, bigcirc_height,
|
||||
bigcirc_x_hot, bigcirc_y_hot, NULL},
|
||||
{ dropper_bits, droppermsk_bits, dropper_width, dropper_height,
|
||||
dropper_x_hot, dropper_y_hot, NULL},
|
||||
};
|
||||
|
||||
|
||||
@ -82,12 +86,13 @@ create_cursor(BM_Cursor *bmcursor)
|
||||
g_return_if_fail (bmcursor->cursor != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
gimp_change_win_cursor(GdkWindow *win, GimpCursorType curtype)
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
g_return_if_fail (curtype < GIMP_LAST_CURSOR_ENTRY);
|
||||
curtype -= GIMP_MOUSE1_CURSOR;
|
||||
if (!gimp_cursors[(int)curtype].cursor)
|
||||
create_cursor (&gimp_cursors[(int)curtype]);
|
||||
cursor = gimp_cursors[(int)curtype].cursor;
|
||||
@ -101,7 +106,12 @@ change_win_cursor (win, cursortype)
|
||||
GdkCursorType cursortype;
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
|
||||
if (cursortype > GDK_LAST_CURSOR)
|
||||
{
|
||||
gimp_change_win_cursor(win, (GimpCursorType)cursortype);
|
||||
return;
|
||||
}
|
||||
cursor = gdk_cursor_new (cursortype);
|
||||
gdk_window_set_cursor (win, cursor);
|
||||
gdk_cursor_destroy (cursor);
|
||||
|
@ -22,16 +22,16 @@
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_MOUSE1_CURSOR,
|
||||
GIMP_MOUSE1_CURSOR = (GDK_LAST_CURSOR + 2),
|
||||
GIMP_MOUSE1P_CURSOR,
|
||||
GIMP_MOUSE1M_CURSOR,
|
||||
GIMP_BIGCIRC_CURSOR,
|
||||
GIMP_COLOR_PICKER_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);
|
||||
|
@ -1473,31 +1473,14 @@ 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 != (int)cursor_type || gdisp->cursor_type != 0)
|
||||
if (gdisp->current_cursor != (int)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);
|
||||
|
@ -138,7 +138,7 @@ struct _GDisplay
|
||||
GSList *display_areas; /* Display areas list */
|
||||
|
||||
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 ? */
|
||||
|
@ -1473,31 +1473,14 @@ 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 != (int)cursor_type || gdisp->cursor_type != 0)
|
||||
if (gdisp->current_cursor != (int)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);
|
||||
|
@ -138,7 +138,7 @@ struct _GDisplay
|
||||
GSList *display_areas; /* Display areas list */
|
||||
|
||||
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 ? */
|
||||
|
@ -178,6 +178,7 @@ tools_new_airbrush ()
|
||||
|
||||
private = (PaintCore *) tool->private;
|
||||
private->paint_func = airbrush_paint_func;
|
||||
private->pick_colors = TRUE;
|
||||
|
||||
return tool;
|
||||
}
|
||||
@ -198,10 +199,10 @@ airbrush_paint_func (PaintCore *paint_core,
|
||||
case INIT_PAINT :
|
||||
/* timer_state = OFF; */
|
||||
if (timer_state == ON)
|
||||
{
|
||||
g_warning (_("killing stray timer, please report to lewing@gimp.org"));
|
||||
gtk_timeout_remove (timer);
|
||||
}
|
||||
{
|
||||
g_warning (_("killing stray timer, please report to lewing@gimp.org"));
|
||||
gtk_timeout_remove (timer);
|
||||
}
|
||||
timer_state = OFF;
|
||||
break;
|
||||
|
||||
@ -213,13 +214,13 @@ airbrush_paint_func (PaintCore *paint_core,
|
||||
airbrush_motion (paint_core, drawable, airbrush_options->pressure);
|
||||
|
||||
if (airbrush_options->rate != 0.0)
|
||||
{
|
||||
airbrush_timeout.paint_core = paint_core;
|
||||
airbrush_timeout.drawable = drawable;
|
||||
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
|
||||
airbrush_time_out, NULL);
|
||||
timer_state = ON;
|
||||
}
|
||||
{
|
||||
airbrush_timeout.paint_core = paint_core;
|
||||
airbrush_timeout.drawable = drawable;
|
||||
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
|
||||
airbrush_time_out, NULL);
|
||||
timer_state = ON;
|
||||
}
|
||||
break;
|
||||
|
||||
case FINISH_PAINT :
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "selection.h"
|
||||
#include "tools.h"
|
||||
#include "undo.h"
|
||||
#include "cursorutil.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
@ -129,6 +130,23 @@ static const int subsample[5][5][9] = {
|
||||
},
|
||||
};
|
||||
|
||||
static void
|
||||
paint_core_sample_color(GimpDrawable *drawable, int x, int y, int state)
|
||||
{
|
||||
unsigned char *color;
|
||||
if ((color = gimp_drawable_get_color_at(drawable, x, y)))
|
||||
{
|
||||
if ((state & GDK_CONTROL_MASK))
|
||||
palette_set_foreground (color[RED_PIX], color[GREEN_PIX],
|
||||
color [BLUE_PIX]);
|
||||
else
|
||||
palette_set_background (color[RED_PIX], color[GREEN_PIX],
|
||||
color [BLUE_PIX]);
|
||||
g_free(color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
paint_core_button_press (tool, bevent, gdisp_ptr)
|
||||
Tool *tool;
|
||||
@ -200,6 +218,16 @@ paint_core_button_press (tool, bevent, gdisp_ptr)
|
||||
/* Let the specific painting function initialize itself */
|
||||
(* paint_core->paint_func) (paint_core, drawable, INIT_PAINT);
|
||||
|
||||
if (paint_core->pick_colors
|
||||
&& (bevent->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
{
|
||||
paint_core_sample_color(drawable, x, y, bevent->state);
|
||||
paint_core->pick_state = TRUE;
|
||||
return;
|
||||
}
|
||||
else
|
||||
paint_core->pick_state = FALSE;
|
||||
|
||||
/* Paint to the image */
|
||||
if (draw_line)
|
||||
{
|
||||
@ -242,6 +270,8 @@ paint_core_button_release (tool, bevent, gdisp_ptr)
|
||||
/* Set tool state to inactive -- no longer painting */
|
||||
tool->state = INACTIVE;
|
||||
|
||||
paint_core->pick_state = FALSE;
|
||||
|
||||
paint_core_finish (paint_core, gimage_active_drawable (gdisp->gimage), tool->ID);
|
||||
gdisplays_flush ();
|
||||
}
|
||||
@ -260,6 +290,15 @@ paint_core_motion (tool, mevent, gdisp_ptr)
|
||||
|
||||
gdisplay_untransform_coords_f (gdisp, (double) mevent->x, (double) mevent->y,
|
||||
&paint_core->curx, &paint_core->cury, TRUE);
|
||||
|
||||
if (paint_core->pick_state)
|
||||
{
|
||||
paint_core_sample_color(gimage_active_drawable (gdisp->gimage),
|
||||
paint_core->curx, paint_core->cury, mevent->state);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
paint_core->curpressure = mevent->pressure;
|
||||
paint_core->curxtilt = mevent->xtilt;
|
||||
paint_core->curytilt = mevent->ytilt;
|
||||
@ -284,17 +323,26 @@ paint_core_cursor_update (tool, mevent, gdisp_ptr)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
Layer *layer;
|
||||
PaintCore * paint_core;
|
||||
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
|
||||
int x, y;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
paint_core = (PaintCore *) tool->private;
|
||||
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE);
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y,
|
||||
FALSE, FALSE);
|
||||
if ((layer = gimage_get_active_layer (gdisp->gimage)))
|
||||
{
|
||||
int off_x, off_y;
|
||||
drawable_offsets (GIMP_DRAWABLE(layer), &off_x, &off_y);
|
||||
if (x >= off_x && y >= off_y &&
|
||||
|
||||
if (paint_core->pick_colors
|
||||
&& (mevent->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
{
|
||||
ctype = GIMP_COLOR_PICKER_CURSOR;
|
||||
}
|
||||
else if (x >= off_x && y >= off_y &&
|
||||
x < (off_x + drawable_width (GIMP_DRAWABLE(layer))) &&
|
||||
y < (off_y + drawable_height (GIMP_DRAWABLE(layer))))
|
||||
{
|
||||
@ -357,6 +405,7 @@ paint_core_new (type)
|
||||
private = (PaintCore *) g_malloc (sizeof (PaintCore));
|
||||
|
||||
private->core = draw_core_new (paint_core_no_draw);
|
||||
private->pick_colors = FALSE;
|
||||
|
||||
tool->type = type;
|
||||
tool->state = INACTIVE;
|
||||
|
@ -89,6 +89,9 @@ struct _paint_core
|
||||
GimpBrush * brush; /* current brush */
|
||||
|
||||
PaintFunc paint_func; /* painting function */
|
||||
|
||||
int pick_colors; /* pick color if ctl or alt is pressed */
|
||||
int pick_state; /* was ctl or alt pressed when clicked? */
|
||||
};
|
||||
|
||||
extern PaintCore non_gui_paint_core;
|
||||
|
@ -296,46 +296,15 @@ paintbrush_paint_func (PaintCore *paint_core,
|
||||
timer = g_timer_new();
|
||||
g_timer_start(timer);
|
||||
#endif /* TIMED_BRUSH */
|
||||
if ((paint_core->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
{
|
||||
unsigned char *color;
|
||||
if ((color = gimp_drawable_get_color_at(drawable, paint_core->curx,
|
||||
paint_core->cury)))
|
||||
{
|
||||
if ((paint_core->state & GDK_CONTROL_MASK))
|
||||
palette_set_foreground (color[RED_PIX], color[GREEN_PIX],
|
||||
color [BLUE_PIX]);
|
||||
else
|
||||
palette_set_background (color[RED_PIX], color[GREEN_PIX],
|
||||
color [BLUE_PIX]);
|
||||
g_free(color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MOTION_PAINT :
|
||||
if ((paint_core->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
{
|
||||
unsigned char *color;
|
||||
if ((color = gimp_drawable_get_color_at(drawable, paint_core->curx,
|
||||
paint_core->cury)))
|
||||
{
|
||||
if ((paint_core->state & GDK_CONTROL_MASK))
|
||||
palette_set_foreground (color[RED_PIX], color[GREEN_PIX],
|
||||
color [BLUE_PIX]);
|
||||
else
|
||||
palette_set_background (color[RED_PIX], color[GREEN_PIX],
|
||||
color [BLUE_PIX]);
|
||||
g_free(color);
|
||||
}
|
||||
}
|
||||
else
|
||||
paintbrush_motion (paint_core, drawable,
|
||||
paintbrush_options->fade_out,
|
||||
paintbrush_options->use_gradient ?
|
||||
exp(paintbrush_options->gradient_length/10) : 0,
|
||||
paintbrush_options->incremental,
|
||||
paintbrush_options->gradient_type);
|
||||
paintbrush_motion (paint_core, drawable,
|
||||
paintbrush_options->fade_out,
|
||||
paintbrush_options->use_gradient ?
|
||||
exp(paintbrush_options->gradient_length/10) : 0,
|
||||
paintbrush_options->incremental,
|
||||
paintbrush_options->gradient_type);
|
||||
break;
|
||||
|
||||
case FINISH_PAINT :
|
||||
@ -378,6 +347,7 @@ tools_new_paintbrush ()
|
||||
|
||||
private = (PaintCore *) tool->private;
|
||||
private->paint_func = paintbrush_paint_func;
|
||||
private->pick_colors = TRUE;
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -491,13 +491,13 @@ rect_select_cursor_update (Tool *tool,
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
case SELECTION_ADD:
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_MOUSE1P_CURSOR);
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE1P_CURSOR);
|
||||
break;
|
||||
case SELECTION_SUB:
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_MOUSE1M_CURSOR);
|
||||
gdisplay_install_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);
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_BIGCIRC_CURSOR);
|
||||
break;
|
||||
case SELECTION_REPLACE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
|
@ -178,6 +178,7 @@ tools_new_airbrush ()
|
||||
|
||||
private = (PaintCore *) tool->private;
|
||||
private->paint_func = airbrush_paint_func;
|
||||
private->pick_colors = TRUE;
|
||||
|
||||
return tool;
|
||||
}
|
||||
@ -198,10 +199,10 @@ airbrush_paint_func (PaintCore *paint_core,
|
||||
case INIT_PAINT :
|
||||
/* timer_state = OFF; */
|
||||
if (timer_state == ON)
|
||||
{
|
||||
g_warning (_("killing stray timer, please report to lewing@gimp.org"));
|
||||
gtk_timeout_remove (timer);
|
||||
}
|
||||
{
|
||||
g_warning (_("killing stray timer, please report to lewing@gimp.org"));
|
||||
gtk_timeout_remove (timer);
|
||||
}
|
||||
timer_state = OFF;
|
||||
break;
|
||||
|
||||
@ -213,13 +214,13 @@ airbrush_paint_func (PaintCore *paint_core,
|
||||
airbrush_motion (paint_core, drawable, airbrush_options->pressure);
|
||||
|
||||
if (airbrush_options->rate != 0.0)
|
||||
{
|
||||
airbrush_timeout.paint_core = paint_core;
|
||||
airbrush_timeout.drawable = drawable;
|
||||
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
|
||||
airbrush_time_out, NULL);
|
||||
timer_state = ON;
|
||||
}
|
||||
{
|
||||
airbrush_timeout.paint_core = paint_core;
|
||||
airbrush_timeout.drawable = drawable;
|
||||
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
|
||||
airbrush_time_out, NULL);
|
||||
timer_state = ON;
|
||||
}
|
||||
break;
|
||||
|
||||
case FINISH_PAINT :
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "draw_core.h"
|
||||
#include "drawable.h"
|
||||
#include "gdisplay.h"
|
||||
#include "cursorutil.h"
|
||||
#include "info_dialog.h"
|
||||
#include "palette.h"
|
||||
#include "tool_options_ui.h"
|
||||
@ -371,7 +372,7 @@ color_picker_cursor_update (Tool *tool,
|
||||
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE);
|
||||
if (gimage_pick_correlate_layer (gdisp->gimage, x, y))
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_COLOR_PICKER_CURSOR);
|
||||
else
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
|
||||
}
|
||||
|
@ -178,6 +178,7 @@ tools_new_airbrush ()
|
||||
|
||||
private = (PaintCore *) tool->private;
|
||||
private->paint_func = airbrush_paint_func;
|
||||
private->pick_colors = TRUE;
|
||||
|
||||
return tool;
|
||||
}
|
||||
@ -198,10 +199,10 @@ airbrush_paint_func (PaintCore *paint_core,
|
||||
case INIT_PAINT :
|
||||
/* timer_state = OFF; */
|
||||
if (timer_state == ON)
|
||||
{
|
||||
g_warning (_("killing stray timer, please report to lewing@gimp.org"));
|
||||
gtk_timeout_remove (timer);
|
||||
}
|
||||
{
|
||||
g_warning (_("killing stray timer, please report to lewing@gimp.org"));
|
||||
gtk_timeout_remove (timer);
|
||||
}
|
||||
timer_state = OFF;
|
||||
break;
|
||||
|
||||
@ -213,13 +214,13 @@ airbrush_paint_func (PaintCore *paint_core,
|
||||
airbrush_motion (paint_core, drawable, airbrush_options->pressure);
|
||||
|
||||
if (airbrush_options->rate != 0.0)
|
||||
{
|
||||
airbrush_timeout.paint_core = paint_core;
|
||||
airbrush_timeout.drawable = drawable;
|
||||
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
|
||||
airbrush_time_out, NULL);
|
||||
timer_state = ON;
|
||||
}
|
||||
{
|
||||
airbrush_timeout.paint_core = paint_core;
|
||||
airbrush_timeout.drawable = drawable;
|
||||
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
|
||||
airbrush_time_out, NULL);
|
||||
timer_state = ON;
|
||||
}
|
||||
break;
|
||||
|
||||
case FINISH_PAINT :
|
||||
|
@ -491,13 +491,13 @@ rect_select_cursor_update (Tool *tool,
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
case SELECTION_ADD:
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_MOUSE1P_CURSOR);
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE1P_CURSOR);
|
||||
break;
|
||||
case SELECTION_SUB:
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_MOUSE1M_CURSOR);
|
||||
gdisplay_install_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);
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_BIGCIRC_CURSOR);
|
||||
break;
|
||||
case SELECTION_REPLACE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "selection.h"
|
||||
#include "tools.h"
|
||||
#include "undo.h"
|
||||
#include "cursorutil.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
@ -129,6 +130,23 @@ static const int subsample[5][5][9] = {
|
||||
},
|
||||
};
|
||||
|
||||
static void
|
||||
paint_core_sample_color(GimpDrawable *drawable, int x, int y, int state)
|
||||
{
|
||||
unsigned char *color;
|
||||
if ((color = gimp_drawable_get_color_at(drawable, x, y)))
|
||||
{
|
||||
if ((state & GDK_CONTROL_MASK))
|
||||
palette_set_foreground (color[RED_PIX], color[GREEN_PIX],
|
||||
color [BLUE_PIX]);
|
||||
else
|
||||
palette_set_background (color[RED_PIX], color[GREEN_PIX],
|
||||
color [BLUE_PIX]);
|
||||
g_free(color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
paint_core_button_press (tool, bevent, gdisp_ptr)
|
||||
Tool *tool;
|
||||
@ -200,6 +218,16 @@ paint_core_button_press (tool, bevent, gdisp_ptr)
|
||||
/* Let the specific painting function initialize itself */
|
||||
(* paint_core->paint_func) (paint_core, drawable, INIT_PAINT);
|
||||
|
||||
if (paint_core->pick_colors
|
||||
&& (bevent->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
{
|
||||
paint_core_sample_color(drawable, x, y, bevent->state);
|
||||
paint_core->pick_state = TRUE;
|
||||
return;
|
||||
}
|
||||
else
|
||||
paint_core->pick_state = FALSE;
|
||||
|
||||
/* Paint to the image */
|
||||
if (draw_line)
|
||||
{
|
||||
@ -242,6 +270,8 @@ paint_core_button_release (tool, bevent, gdisp_ptr)
|
||||
/* Set tool state to inactive -- no longer painting */
|
||||
tool->state = INACTIVE;
|
||||
|
||||
paint_core->pick_state = FALSE;
|
||||
|
||||
paint_core_finish (paint_core, gimage_active_drawable (gdisp->gimage), tool->ID);
|
||||
gdisplays_flush ();
|
||||
}
|
||||
@ -260,6 +290,15 @@ paint_core_motion (tool, mevent, gdisp_ptr)
|
||||
|
||||
gdisplay_untransform_coords_f (gdisp, (double) mevent->x, (double) mevent->y,
|
||||
&paint_core->curx, &paint_core->cury, TRUE);
|
||||
|
||||
if (paint_core->pick_state)
|
||||
{
|
||||
paint_core_sample_color(gimage_active_drawable (gdisp->gimage),
|
||||
paint_core->curx, paint_core->cury, mevent->state);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
paint_core->curpressure = mevent->pressure;
|
||||
paint_core->curxtilt = mevent->xtilt;
|
||||
paint_core->curytilt = mevent->ytilt;
|
||||
@ -284,17 +323,26 @@ paint_core_cursor_update (tool, mevent, gdisp_ptr)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
Layer *layer;
|
||||
PaintCore * paint_core;
|
||||
GdkCursorType ctype = GDK_TOP_LEFT_ARROW;
|
||||
int x, y;
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
paint_core = (PaintCore *) tool->private;
|
||||
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y, FALSE, FALSE);
|
||||
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y,
|
||||
FALSE, FALSE);
|
||||
if ((layer = gimage_get_active_layer (gdisp->gimage)))
|
||||
{
|
||||
int off_x, off_y;
|
||||
drawable_offsets (GIMP_DRAWABLE(layer), &off_x, &off_y);
|
||||
if (x >= off_x && y >= off_y &&
|
||||
|
||||
if (paint_core->pick_colors
|
||||
&& (mevent->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
{
|
||||
ctype = GIMP_COLOR_PICKER_CURSOR;
|
||||
}
|
||||
else if (x >= off_x && y >= off_y &&
|
||||
x < (off_x + drawable_width (GIMP_DRAWABLE(layer))) &&
|
||||
y < (off_y + drawable_height (GIMP_DRAWABLE(layer))))
|
||||
{
|
||||
@ -357,6 +405,7 @@ paint_core_new (type)
|
||||
private = (PaintCore *) g_malloc (sizeof (PaintCore));
|
||||
|
||||
private->core = draw_core_new (paint_core_no_draw);
|
||||
private->pick_colors = FALSE;
|
||||
|
||||
tool->type = type;
|
||||
tool->state = INACTIVE;
|
||||
|
@ -89,6 +89,9 @@ struct _paint_core
|
||||
GimpBrush * brush; /* current brush */
|
||||
|
||||
PaintFunc paint_func; /* painting function */
|
||||
|
||||
int pick_colors; /* pick color if ctl or alt is pressed */
|
||||
int pick_state; /* was ctl or alt pressed when clicked? */
|
||||
};
|
||||
|
||||
extern PaintCore non_gui_paint_core;
|
||||
|
@ -296,46 +296,15 @@ paintbrush_paint_func (PaintCore *paint_core,
|
||||
timer = g_timer_new();
|
||||
g_timer_start(timer);
|
||||
#endif /* TIMED_BRUSH */
|
||||
if ((paint_core->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
{
|
||||
unsigned char *color;
|
||||
if ((color = gimp_drawable_get_color_at(drawable, paint_core->curx,
|
||||
paint_core->cury)))
|
||||
{
|
||||
if ((paint_core->state & GDK_CONTROL_MASK))
|
||||
palette_set_foreground (color[RED_PIX], color[GREEN_PIX],
|
||||
color [BLUE_PIX]);
|
||||
else
|
||||
palette_set_background (color[RED_PIX], color[GREEN_PIX],
|
||||
color [BLUE_PIX]);
|
||||
g_free(color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MOTION_PAINT :
|
||||
if ((paint_core->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
{
|
||||
unsigned char *color;
|
||||
if ((color = gimp_drawable_get_color_at(drawable, paint_core->curx,
|
||||
paint_core->cury)))
|
||||
{
|
||||
if ((paint_core->state & GDK_CONTROL_MASK))
|
||||
palette_set_foreground (color[RED_PIX], color[GREEN_PIX],
|
||||
color [BLUE_PIX]);
|
||||
else
|
||||
palette_set_background (color[RED_PIX], color[GREEN_PIX],
|
||||
color [BLUE_PIX]);
|
||||
g_free(color);
|
||||
}
|
||||
}
|
||||
else
|
||||
paintbrush_motion (paint_core, drawable,
|
||||
paintbrush_options->fade_out,
|
||||
paintbrush_options->use_gradient ?
|
||||
exp(paintbrush_options->gradient_length/10) : 0,
|
||||
paintbrush_options->incremental,
|
||||
paintbrush_options->gradient_type);
|
||||
paintbrush_motion (paint_core, drawable,
|
||||
paintbrush_options->fade_out,
|
||||
paintbrush_options->use_gradient ?
|
||||
exp(paintbrush_options->gradient_length/10) : 0,
|
||||
paintbrush_options->incremental,
|
||||
paintbrush_options->gradient_type);
|
||||
break;
|
||||
|
||||
case FINISH_PAINT :
|
||||
@ -378,6 +347,7 @@ tools_new_paintbrush ()
|
||||
|
||||
private = (PaintCore *) tool->private;
|
||||
private->paint_func = paintbrush_paint_func;
|
||||
private->pick_colors = TRUE;
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -491,13 +491,13 @@ rect_select_cursor_update (Tool *tool,
|
||||
switch (rect_sel->op)
|
||||
{
|
||||
case SELECTION_ADD:
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_MOUSE1P_CURSOR);
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE1P_CURSOR);
|
||||
break;
|
||||
case SELECTION_SUB:
|
||||
gdisplay_install_gimp_tool_cursor (gdisp, GIMP_MOUSE1M_CURSOR);
|
||||
gdisplay_install_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);
|
||||
gdisplay_install_tool_cursor (gdisp, GIMP_BIGCIRC_CURSOR);
|
||||
break;
|
||||
case SELECTION_REPLACE:
|
||||
gdisplay_install_tool_cursor (gdisp, GDK_TCROSS);
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "../cursors/mouse1_mmsk"
|
||||
#include "../cursors/bigcirc"
|
||||
#include "../cursors/bigcircmsk"
|
||||
#include "../cursors/dropper"
|
||||
#include "../cursors/droppermsk"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -48,6 +50,8 @@ static BM_Cursor gimp_cursors[] =
|
||||
mouse1_m_x_hot, mouse1_m_y_hot, NULL},
|
||||
{ bigcirc_bits, bigcircmsk_bits, bigcirc_width, bigcirc_height,
|
||||
bigcirc_x_hot, bigcirc_y_hot, NULL},
|
||||
{ dropper_bits, droppermsk_bits, dropper_width, dropper_height,
|
||||
dropper_x_hot, dropper_y_hot, NULL},
|
||||
};
|
||||
|
||||
|
||||
@ -82,12 +86,13 @@ create_cursor(BM_Cursor *bmcursor)
|
||||
g_return_if_fail (bmcursor->cursor != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
gimp_change_win_cursor(GdkWindow *win, GimpCursorType curtype)
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
g_return_if_fail (curtype < GIMP_LAST_CURSOR_ENTRY);
|
||||
curtype -= GIMP_MOUSE1_CURSOR;
|
||||
if (!gimp_cursors[(int)curtype].cursor)
|
||||
create_cursor (&gimp_cursors[(int)curtype]);
|
||||
cursor = gimp_cursors[(int)curtype].cursor;
|
||||
@ -101,7 +106,12 @@ change_win_cursor (win, cursortype)
|
||||
GdkCursorType cursortype;
|
||||
{
|
||||
GdkCursor *cursor;
|
||||
|
||||
|
||||
if (cursortype > GDK_LAST_CURSOR)
|
||||
{
|
||||
gimp_change_win_cursor(win, (GimpCursorType)cursortype);
|
||||
return;
|
||||
}
|
||||
cursor = gdk_cursor_new (cursortype);
|
||||
gdk_window_set_cursor (win, cursor);
|
||||
gdk_cursor_destroy (cursor);
|
||||
|
@ -22,16 +22,16 @@
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GIMP_MOUSE1_CURSOR,
|
||||
GIMP_MOUSE1_CURSOR = (GDK_LAST_CURSOR + 2),
|
||||
GIMP_MOUSE1P_CURSOR,
|
||||
GIMP_MOUSE1M_CURSOR,
|
||||
GIMP_BIGCIRC_CURSOR,
|
||||
GIMP_COLOR_PICKER_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);
|
||||
|
11
cursors/dropper
Normal file
11
cursors/dropper
Normal file
@ -0,0 +1,11 @@
|
||||
#define dropper_width 22
|
||||
#define dropper_height 22
|
||||
#define dropper_x_hot 2
|
||||
#define dropper_y_hot 20
|
||||
static unsigned char dropper_bits[] = {
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc,
|
||||
0xff, 0x3f, 0xf8, 0xff, 0x3f, 0xf4, 0xff, 0x87, 0xf7, 0xff, 0x6f, 0xf7,
|
||||
0xff, 0x97, 0xf8, 0xff, 0x8b, 0xfe, 0xff, 0x65, 0xfe, 0xff, 0xb2, 0xfe,
|
||||
0x7f, 0xd9, 0xff, 0xbf, 0xec, 0xff, 0x5f, 0xf6, 0xff, 0x2f, 0xfb, 0xff,
|
||||
0x97, 0xfd, 0xff, 0xcb, 0xfe, 0xff, 0x6b, 0xff, 0xff, 0xbd, 0xff, 0xff,
|
||||
0xc7, 0xff, 0xff, 0xf7, 0xff, 0xff};
|
9
cursors/droppermsk
Normal file
9
cursors/droppermsk
Normal file
@ -0,0 +1,9 @@
|
||||
#define droppermsk_width 22
|
||||
#define droppermsk_height 22
|
||||
static unsigned char droppermsk_bits[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03,
|
||||
0x00, 0xc0, 0x07, 0x00, 0xc0, 0x0f, 0x00, 0xf8, 0x0f, 0x00, 0xf0, 0x0f,
|
||||
0x00, 0xf8, 0x07, 0x00, 0xfc, 0x01, 0x00, 0xfe, 0x01, 0x00, 0x7f, 0x01,
|
||||
0x80, 0x3f, 0x00, 0xc0, 0x1f, 0x00, 0xe0, 0x0f, 0x00, 0xf0, 0x07, 0x00,
|
||||
0xf8, 0x03, 0x00, 0xfc, 0x01, 0x00, 0xfc, 0x00, 0x00, 0x7e, 0x00, 0x00,
|
||||
0x3c, 0x00, 0x00, 0x08, 0x00, 0x00};
|
Reference in New Issue
Block a user