Commit e2862590 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

renamed gimp_image_coords_in_active_drawable() to

2006-06-03  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage.[ch]: renamed
	gimp_image_coords_in_active_drawable() to
	gimp_image_coords_in_active_pickable() and added boolean
	"sample_merged" and "selected_only" parameters. Use floor()
	instead of ROUND(), we want to round to the actual pixel, not to
	the nearest pixel boundary.

	* app/tools/gimpbucketfilltool.c
	* app/tools/gimpclonetool.c
	* app/tools/gimpcolortool.c
	* app/tools/gimpfliptool.c
	* app/tools/gimptransformtool.c: changed accordingly. Removed
	quite some duplicated code which checked sample_merged and the
	mask value at the cursor location.

	* app/tools/gimpbycolorselecttool.c: use the hand tool cursor,
	there's also a hand in the toolbox icon. Fixed cursor_update()
	function to set the bad modifier when there is no pickable pixel
	at the cursor loction.

	* app/tools/gimpfuzzyselecttool.c: added cursor_update()
	implementation which does the same as by_color_select's one.

	* app/tools/gimpselectiontool.c
	(gimp_selection_tool_cursor_update): don't override the bad
	modifier which was set by a subclass' cursor_update().
parent 6216c99b
2006-06-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage.[ch]: renamed
gimp_image_coords_in_active_drawable() to
gimp_image_coords_in_active_pickable() and added boolean
"sample_merged" and "selected_only" parameters. Use floor()
instead of ROUND(), we want to round to the actual pixel, not to
the nearest pixel boundary.
* app/tools/gimpbucketfilltool.c
* app/tools/gimpclonetool.c
* app/tools/gimpcolortool.c
* app/tools/gimpfliptool.c
* app/tools/gimptransformtool.c: changed accordingly. Removed
quite some duplicated code which checked sample_merged and the
mask value at the cursor location.
* app/tools/gimpbycolorselecttool.c: use the hand tool cursor,
there's also a hand in the toolbox icon. Fixed cursor_update()
function to set the bad modifier when there is no pickable pixel
at the cursor loction.
* app/tools/gimpfuzzyselecttool.c: added cursor_update()
implementation which does the same as by_color_select's one.
* app/tools/gimpselectiontool.c
(gimp_selection_tool_cursor_update): don't override the bad
modifier which was set by a subclass' cursor_update().
2006-06-03 Michael Natterer <mitch@gimp.org>
Make better use of the available 32x32 pixels so the cursors look
......
......@@ -3563,35 +3563,59 @@ gimp_image_pick_correlate_layer (const GimpImage *image,
}
gboolean
gimp_image_coords_in_active_drawable (GimpImage *image,
const GimpCoords *coords)
gimp_image_coords_in_active_pickable (GimpImage *image,
const GimpCoords *coords,
gboolean sample_merged,
gboolean selected_only)
{
GimpDrawable *drawable;
gint x, y;
gboolean in_pickable = FALSE;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
drawable = gimp_image_active_drawable (image);
x = floor (coords->x);
y = floor (coords->y);
if (drawable)
if (sample_merged)
{
GimpItem *item = GIMP_ITEM (drawable);
gint x, y;
if (x >= 0 && x < image->width &&
y >= 0 && y < image->height)
in_pickable = TRUE;
}
else
{
GimpDrawable *drawable = gimp_image_active_drawable (image);
gimp_item_offsets (item, &x, &y);
if (drawable)
{
GimpItem *item = GIMP_ITEM (drawable);
gint off_x, off_y;
gint d_x, d_y;
gimp_item_offsets (item, &off_x, &off_y);
x = ROUND (coords->x) - x;
y = ROUND (coords->y) - y;
d_x = x - off_x;
d_y = y - off_y;
if (x < 0 || x > gimp_item_width (item))
return FALSE;
if (d_x >= 0 && d_x < gimp_item_width (item) &&
d_y >= 0 && d_y < gimp_item_height (item))
in_pickable = TRUE;
}
}
if (y < 0 || y > gimp_item_height (item))
return FALSE;
if (in_pickable && selected_only)
{
GimpChannel *selection = gimp_image_get_mask (image);
return TRUE;
if (! gimp_channel_is_empty (selection) &&
! gimp_pickable_get_opacity_at (GIMP_PICKABLE (selection),
x, y))
{
in_pickable = FALSE;
}
}
return FALSE;
return in_pickable;
}
void
......
......@@ -504,8 +504,10 @@ gboolean gimp_image_layer_boundary (const GimpImage *image,
GimpLayer * gimp_image_pick_correlate_layer (const GimpImage *image,
gint x,
gint y);
gboolean gimp_image_coords_in_active_drawable (GimpImage *image,
const GimpCoords *coords);
gboolean gimp_image_coords_in_active_pickable (GimpImage *image,
const GimpCoords *coords,
gboolean sample_merged,
gboolean selected_only);
void gimp_image_invalidate_layer_previews (GimpImage *image);
void gimp_image_invalidate_channel_previews (GimpImage *image);
......
......@@ -224,39 +224,30 @@ gimp_bucket_fill_tool_cursor_update (GimpTool *tool,
GimpDisplay *display)
{
GimpBucketFillOptions *options;
GimpCursorModifier cmodifier = GIMP_CURSOR_MODIFIER_NONE;
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_BAD;
options = GIMP_BUCKET_FILL_OPTIONS (tool->tool_info->tool_options);
if (gimp_image_coords_in_active_drawable (display->image, coords))
if (gimp_image_coords_in_active_pickable (display->image, coords,
options->sample_merged, TRUE))
{
GimpChannel *selection = gimp_image_get_mask (display->image);
/* One more test--is there a selected region?
* if so, is cursor inside?
*/
if (gimp_channel_is_empty (selection) ||
gimp_pickable_get_opacity_at (GIMP_PICKABLE (selection),
coords->x, coords->y))
switch (options->fill_mode)
{
switch (options->fill_mode)
{
case GIMP_FG_BUCKET_FILL:
cmodifier = GIMP_CURSOR_MODIFIER_FOREGROUND;
break;
case GIMP_BG_BUCKET_FILL:
cmodifier = GIMP_CURSOR_MODIFIER_BACKGROUND;
break;
case GIMP_PATTERN_BUCKET_FILL:
cmodifier = GIMP_CURSOR_MODIFIER_PATTERN;
break;
}
case GIMP_FG_BUCKET_FILL:
modifier = GIMP_CURSOR_MODIFIER_FOREGROUND;
break;
case GIMP_BG_BUCKET_FILL:
modifier = GIMP_CURSOR_MODIFIER_BACKGROUND;
break;
case GIMP_PATTERN_BUCKET_FILL:
modifier = GIMP_CURSOR_MODIFIER_PATTERN;
break;
}
}
gimp_tool_control_set_cursor_modifier (tool->control, cmodifier);
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
}
......@@ -102,7 +102,8 @@ gimp_by_color_select_tool_init (GimpByColorSelectTool *by_color_select)
{
GimpTool *tool = GIMP_TOOL (by_color_select);
gimp_tool_control_set_cursor (tool->control, GIMP_CURSOR_MOUSE);
gimp_tool_control_set_cursor (tool->control, GIMP_CURSOR_MOUSE);
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_HAND);
by_color_select->x = 0;
by_color_select->y = 0;
......@@ -243,23 +244,15 @@ gimp_by_color_select_tool_cursor_update (GimpTool *tool,
GimpDisplay *display)
{
GimpSelectionOptions *options;
GimpLayer *layer;
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options);
layer = gimp_image_pick_correlate_layer (display->image, coords->x, coords->y);
if (! gimp_image_coords_in_active_pickable (display->image, coords,
options->sample_merged, FALSE))
modifier = GIMP_CURSOR_MODIFIER_BAD;
if (! options->sample_merged &&
layer && layer != display->image->active_layer)
{
gimp_tool_control_set_cursor_modifier (tool->control,
GIMP_CURSOR_MODIFIER_BAD);
}
else
{
gimp_tool_control_set_cursor_modifier (tool->control,
GIMP_CURSOR_MODIFIER_NONE);
}
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
}
......@@ -215,19 +215,10 @@ gimp_clone_tool_cursor_update (GimpTool *tool,
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
if (gimp_image_coords_in_active_drawable (display->image, coords))
if (gimp_image_coords_in_active_pickable (display->image, coords,
FALSE, TRUE))
{
GimpChannel *selection = gimp_image_get_mask (display->image);
/* One more test--is there a selected region?
* if so, is cursor inside?
*/
if (gimp_channel_is_empty (selection) ||
gimp_pickable_get_opacity_at (GIMP_PICKABLE (selection),
coords->x, coords->y))
{
cursor = GIMP_CURSOR_MOUSE;
}
cursor = GIMP_CURSOR_MOUSE;
}
if (options->clone_type == GIMP_IMAGE_CLONE)
......
......@@ -506,11 +506,9 @@ gimp_color_tool_cursor_update (GimpTool *tool,
{
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_BAD;
if (coords->x > 0 && coords->x < display->image->width &&
coords->y > 0 && coords->y < display->image->height &&
(color_tool->options->sample_merged ||
gimp_image_coords_in_active_drawable (display->image, coords)))
if (gimp_image_coords_in_active_pickable (display->image, coords,
color_tool->options->sample_merged,
FALSE))
{
switch (color_tool->pick_mode)
{
......
......@@ -154,17 +154,10 @@ gimp_flip_tool_cursor_update (GimpTool *tool,
options = GIMP_FLIP_OPTIONS (tool->tool_info->tool_options);
if (gimp_image_coords_in_active_drawable (display->image, coords))
if (gimp_image_coords_in_active_pickable (display->image, coords,
FALSE, TRUE))
{
GimpChannel *selection = gimp_image_get_mask (display->image);
/* Is there a selected region? If so, is cursor inside? */
if (gimp_channel_is_empty (selection) ||
gimp_pickable_get_opacity_at (GIMP_PICKABLE (selection),
coords->x, coords->y))
{
modifier = GIMP_CURSOR_MODIFIER_NONE;
}
modifier = GIMP_CURSOR_MODIFIER_NONE;
}
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
......
......@@ -70,6 +70,10 @@ static void gimp_fuzzy_select_tool_motion (GimpTool *tool,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_fuzzy_select_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_fuzzy_select_tool_draw (GimpDrawTool *draw_tool);
......@@ -114,6 +118,7 @@ gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass)
tool_class->button_press = gimp_fuzzy_select_tool_button_press;
tool_class->button_release = gimp_fuzzy_select_tool_button_release;
tool_class->motion = gimp_fuzzy_select_tool_motion;
tool_class->cursor_update = gimp_fuzzy_select_tool_cursor_update;
draw_tool_class->draw = gimp_fuzzy_select_tool_draw;
}
......@@ -319,6 +324,26 @@ gimp_fuzzy_select_tool_motion (GimpTool *tool,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
static void
gimp_fuzzy_select_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display)
{
GimpSelectionOptions *options;
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options);
if (! gimp_image_coords_in_active_pickable (display->image, coords,
options->sample_merged, TRUE))
modifier = GIMP_CURSOR_MODIFIER_BAD;
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
}
static void
gimp_fuzzy_select_tool_draw (GimpDrawTool *draw_tool)
{
......
......@@ -70,6 +70,10 @@ static void gimp_fuzzy_select_tool_motion (GimpTool *tool,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_fuzzy_select_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_fuzzy_select_tool_draw (GimpDrawTool *draw_tool);
......@@ -114,6 +118,7 @@ gimp_fuzzy_select_tool_class_init (GimpFuzzySelectToolClass *klass)
tool_class->button_press = gimp_fuzzy_select_tool_button_press;
tool_class->button_release = gimp_fuzzy_select_tool_button_release;
tool_class->motion = gimp_fuzzy_select_tool_motion;
tool_class->cursor_update = gimp_fuzzy_select_tool_cursor_update;
draw_tool_class->draw = gimp_fuzzy_select_tool_draw;
}
......@@ -319,6 +324,26 @@ gimp_fuzzy_select_tool_motion (GimpTool *tool,
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
static void
gimp_fuzzy_select_tool_cursor_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display)
{
GimpSelectionOptions *options;
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options);
if (! gimp_image_coords_in_active_pickable (display->image, coords,
options->sample_merged, TRUE))
modifier = GIMP_CURSOR_MODIFIER_BAD;
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
}
static void
gimp_fuzzy_select_tool_draw (GimpDrawTool *draw_tool)
{
......
......@@ -313,6 +313,16 @@ gimp_selection_tool_cursor_update (GimpTool *tool,
break;
}
/* we don't set the bad modifier ourselves, so a subclass has set
* it, always leave it there since it's more important than what we
* have to say.
*/
if (gimp_tool_control_get_cursor_modifier (tool->control) ==
GIMP_CURSOR_MODIFIER_BAD)
{
modifier = GIMP_CURSOR_MODIFIER_BAD;
}
gimp_tool_set_cursor (tool, display,
gimp_tool_control_get_cursor (tool->control),
tool_cursor,
......
......@@ -215,19 +215,10 @@ gimp_clone_tool_cursor_update (GimpTool *tool,
options = GIMP_CLONE_OPTIONS (tool->tool_info->tool_options);
if (gimp_image_coords_in_active_drawable (display->image, coords))
if (gimp_image_coords_in_active_pickable (display->image, coords,
FALSE, TRUE))
{
GimpChannel *selection = gimp_image_get_mask (display->image);
/* One more test--is there a selected region?
* if so, is cursor inside?
*/
if (gimp_channel_is_empty (selection) ||
gimp_pickable_get_opacity_at (GIMP_PICKABLE (selection),
coords->x, coords->y))
{
cursor = GIMP_CURSOR_MOUSE;
}
cursor = GIMP_CURSOR_MOUSE;
}
if (options->clone_type == GIMP_IMAGE_CLONE)
......
......@@ -622,14 +622,10 @@ gimp_transform_tool_cursor_update (GimpTool *tool,
switch (options->type)
{
case GIMP_TRANSFORM_TYPE_LAYER:
if (gimp_image_coords_in_active_drawable (display->image, coords))
if (gimp_image_coords_in_active_pickable (display->image, coords,
FALSE, TRUE))
{
if (gimp_channel_is_empty (selection) ||
gimp_pickable_get_opacity_at (GIMP_PICKABLE (selection),
coords->x, coords->y))
{
cursor = GIMP_CURSOR_MOUSE;
}
cursor = GIMP_CURSOR_MOUSE;
}
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment