app/convolve.c app/dodgeburn.c app/eraser.c app/paint_core.c fixed my tool

2000-06-14  Michael Natterer  <mitch@gimp.org>

	* app/convolve.c
	* app/dodgeburn.c
	* app/eraser.c
	* app/paint_core.c
	* app/tools.[ch]: fixed my tool toggle braino: the paint_core
	cannot decide which cursor to show from the state of the modifier
	keys.

	Added a boolean "toggled" variable to the Tool structure,
	set it in the toggleable paint tools and evaluate it in the
	paint_core.
This commit is contained in:
Michael Natterer 2000-06-14 14:22:47 +00:00 committed by Michael Natterer
parent 1693242a7d
commit 35e55cf16d
18 changed files with 122 additions and 40 deletions

View File

@ -219,10 +219,14 @@ convolve_modifier_key_func (Tool *tool,
switch (convolve_options->type)
{
case BLUR_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]),
TRUE);
break;
case SHARPEN_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]),
TRUE);
break;
default:
break;
@ -236,10 +240,14 @@ convolve_modifier_key_func (Tool *tool,
switch (convolve_options->type)
{
case BLUR_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]),
TRUE);
break;
case SHARPEN_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]),
TRUE);
break;
default:
break;
@ -247,6 +255,8 @@ convolve_modifier_key_func (Tool *tool,
}
break;
}
tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE);
}
Tool *

View File

@ -296,10 +296,12 @@ dodgeburn_modifier_key_func (Tool *tool,
switch (dodgeburn_options->type)
{
case BURN:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
break;
case DODGE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
break;
default:
break;
@ -313,10 +315,12 @@ dodgeburn_modifier_key_func (Tool *tool,
switch (dodgeburn_options->type)
{
case BURN:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
break;
case DODGE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
break;
default:
break;
@ -324,6 +328,8 @@ dodgeburn_modifier_key_func (Tool *tool,
}
break;
}
tool->toggled = (dodgeburn_options->type == BURN);
}
Tool *

View File

@ -146,12 +146,14 @@ eraser_modifier_key_func (Tool *tool,
break;
case GDK_Control_L:
case GDK_Control_R:
if ( !(kevent->state & GDK_SHIFT_MASK) ) /* shift enables line draw mode */
if (!(kevent->state & GDK_SHIFT_MASK)) /* shift enables line draw mode */
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (eraser_options->anti_erase_w),
! eraser_options->anti_erase);
break;
}
tool->toggled = eraser_options->anti_erase;
}

View File

@ -219,10 +219,14 @@ convolve_modifier_key_func (Tool *tool,
switch (convolve_options->type)
{
case BLUR_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]),
TRUE);
break;
case SHARPEN_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]),
TRUE);
break;
default:
break;
@ -236,10 +240,14 @@ convolve_modifier_key_func (Tool *tool,
switch (convolve_options->type)
{
case BLUR_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]),
TRUE);
break;
case SHARPEN_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]),
TRUE);
break;
default:
break;
@ -247,6 +255,8 @@ convolve_modifier_key_func (Tool *tool,
}
break;
}
tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE);
}
Tool *

View File

@ -296,10 +296,12 @@ dodgeburn_modifier_key_func (Tool *tool,
switch (dodgeburn_options->type)
{
case BURN:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
break;
case DODGE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
break;
default:
break;
@ -313,10 +315,12 @@ dodgeburn_modifier_key_func (Tool *tool,
switch (dodgeburn_options->type)
{
case BURN:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
break;
case DODGE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
break;
default:
break;
@ -324,6 +328,8 @@ dodgeburn_modifier_key_func (Tool *tool,
}
break;
}
tool->toggled = (dodgeburn_options->type == BURN);
}
Tool *

View File

@ -146,12 +146,14 @@ eraser_modifier_key_func (Tool *tool,
break;
case GDK_Control_L:
case GDK_Control_R:
if ( !(kevent->state & GDK_SHIFT_MASK) ) /* shift enables line draw mode */
if (!(kevent->state & GDK_SHIFT_MASK)) /* shift enables line draw mode */
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (eraser_options->anti_erase_w),
! eraser_options->anti_erase);
break;
}
tool->toggled = eraser_options->anti_erase;
}

View File

@ -565,8 +565,7 @@ paint_core_cursor_update (Tool *tool,
ctype = GIMP_COLOR_PICKER_CURSOR;
}
/* Set toggle cursors for various paint tools */
else if (!(mevent->state & GDK_SHIFT_MASK) &&
(mevent->state & GDK_CONTROL_MASK))
else if (tool->toggled)
{
switch (tool->type)
{

View File

@ -1464,6 +1464,8 @@ tools_new_tool (ToolType tool_type)
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->toggled = FALSE;
tool->private = NULL;
tool->button_press_func = standard_button_press_func;

View File

@ -72,6 +72,10 @@ struct _Tool
void *gdisp_ptr; /* pointer to currently active gdisp */
void *drawable; /* pointer to the tool's current drawable */
gboolean toggled; /* Bad hack to let the paint_core show the */
/* right toggle cursors */
void *private; /* Tool-specific information */
/* Action functions */

View File

@ -219,10 +219,14 @@ convolve_modifier_key_func (Tool *tool,
switch (convolve_options->type)
{
case BLUR_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]),
TRUE);
break;
case SHARPEN_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]),
TRUE);
break;
default:
break;
@ -236,10 +240,14 @@ convolve_modifier_key_func (Tool *tool,
switch (convolve_options->type)
{
case BLUR_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]),
TRUE);
break;
case SHARPEN_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]),
TRUE);
break;
default:
break;
@ -247,6 +255,8 @@ convolve_modifier_key_func (Tool *tool,
}
break;
}
tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE);
}
Tool *

View File

@ -296,10 +296,12 @@ dodgeburn_modifier_key_func (Tool *tool,
switch (dodgeburn_options->type)
{
case BURN:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
break;
case DODGE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
break;
default:
break;
@ -313,10 +315,12 @@ dodgeburn_modifier_key_func (Tool *tool,
switch (dodgeburn_options->type)
{
case BURN:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
break;
case DODGE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
break;
default:
break;
@ -324,6 +328,8 @@ dodgeburn_modifier_key_func (Tool *tool,
}
break;
}
tool->toggled = (dodgeburn_options->type == BURN);
}
Tool *

View File

@ -146,12 +146,14 @@ eraser_modifier_key_func (Tool *tool,
break;
case GDK_Control_L:
case GDK_Control_R:
if ( !(kevent->state & GDK_SHIFT_MASK) ) /* shift enables line draw mode */
if (!(kevent->state & GDK_SHIFT_MASK)) /* shift enables line draw mode */
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (eraser_options->anti_erase_w),
! eraser_options->anti_erase);
break;
}
tool->toggled = eraser_options->anti_erase;
}

View File

@ -219,10 +219,14 @@ convolve_modifier_key_func (Tool *tool,
switch (convolve_options->type)
{
case BLUR_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]),
TRUE);
break;
case SHARPEN_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]),
TRUE);
break;
default:
break;
@ -236,10 +240,14 @@ convolve_modifier_key_func (Tool *tool,
switch (convolve_options->type)
{
case BLUR_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[SHARPEN_CONVOLVE]),
TRUE);
break;
case SHARPEN_CONVOLVE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (convolve_options->type_w[BLUR_CONVOLVE]),
TRUE);
break;
default:
break;
@ -247,6 +255,8 @@ convolve_modifier_key_func (Tool *tool,
}
break;
}
tool->toggled = (convolve_options->type == SHARPEN_CONVOLVE);
}
Tool *

View File

@ -296,10 +296,12 @@ dodgeburn_modifier_key_func (Tool *tool,
switch (dodgeburn_options->type)
{
case BURN:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
break;
case DODGE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
break;
default:
break;
@ -313,10 +315,12 @@ dodgeburn_modifier_key_func (Tool *tool,
switch (dodgeburn_options->type)
{
case BURN:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[DODGE]), TRUE);
break;
case DODGE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (dodgeburn_options->type_w[BURN]), TRUE);
break;
default:
break;
@ -324,6 +328,8 @@ dodgeburn_modifier_key_func (Tool *tool,
}
break;
}
tool->toggled = (dodgeburn_options->type == BURN);
}
Tool *

View File

@ -146,12 +146,14 @@ eraser_modifier_key_func (Tool *tool,
break;
case GDK_Control_L:
case GDK_Control_R:
if ( !(kevent->state & GDK_SHIFT_MASK) ) /* shift enables line draw mode */
if (!(kevent->state & GDK_SHIFT_MASK)) /* shift enables line draw mode */
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (eraser_options->anti_erase_w),
! eraser_options->anti_erase);
break;
}
tool->toggled = eraser_options->anti_erase;
}

View File

@ -565,8 +565,7 @@ paint_core_cursor_update (Tool *tool,
ctype = GIMP_COLOR_PICKER_CURSOR;
}
/* Set toggle cursors for various paint tools */
else if (!(mevent->state & GDK_SHIFT_MASK) &&
(mevent->state & GDK_CONTROL_MASK))
else if (tool->toggled)
{
switch (tool->type)
{

View File

@ -1464,6 +1464,8 @@ tools_new_tool (ToolType tool_type)
tool->gdisp_ptr = NULL;
tool->drawable = NULL;
tool->toggled = FALSE;
tool->private = NULL;
tool->button_press_func = standard_button_press_func;

View File

@ -72,6 +72,10 @@ struct _Tool
void *gdisp_ptr; /* pointer to currently active gdisp */
void *drawable; /* pointer to the tool's current drawable */
gboolean toggled; /* Bad hack to let the paint_core show the */
/* right toggle cursors */
void *private; /* Tool-specific information */
/* Action functions */