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

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.
parent 1693242a
......@@ -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 *
......
......@@ -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 *
......
......@@ -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;
}
......
......@@ -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 *
......
......@@ -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 *
......
......@@ -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;
}
......
......@@ -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)
{
......
......@@ -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;
......
......@@ -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 */
......
......@@ -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 *
......
......@@ -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 *
......
......@@ -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;
}
......
......@@ -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 *
......
......@@ -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 *
......
......@@ -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;
}
......
......@@ -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)
{
......
......@@ -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;
......
......@@ -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 */
......
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