From f556b503b9cf858b94ee7839db1b2cb1be4c09e7 Mon Sep 17 00:00:00 2001
From: William Kendrick
Date: Thu, 10 Jul 2008 20:26:38 +0000
Subject: [PATCH] switchin() and switchout() now accept mode.
---
docs/CHANGES.txt | 3 ++-
magic/docs/README.txt | 11 ++++++++---
magic/docs/html/README.html | 11 ++++++++---
magic/docs/tp_magic_example.c | 18 +++++++++++++-----
magic/src/blackAndWhite.c | 4 ++--
magic/src/blocks_chalk_drip.c | 4 ++--
magic/src/blur.c | 4 ++--
magic/src/blurAll.c | 4 ++--
magic/src/bricks.c | 4 ++--
magic/src/calligraphy.c | 4 ++--
magic/src/cartoon.c | 4 ++--
magic/src/confetti.c | 6 ++----
magic/src/distortion.c | 4 ++--
magic/src/emboss.c | 4 ++--
magic/src/fade_darken.c | 4 ++--
magic/src/fill.c | 4 ++--
magic/src/flower.c | 4 ++--
magic/src/foam.c | 4 ++--
magic/src/fold.c | 6 ++----
magic/src/glasstile.c | 4 ++--
magic/src/grass.c | 4 ++--
magic/src/kalidescope.c | 4 ++--
magic/src/light.c | 4 ++--
magic/src/metalpaint.c | 4 ++--
magic/src/mirror_flip.c | 4 ++--
magic/src/negative.c | 4 ++--
magic/src/rainbow.c | 4 ++--
magic/src/ripples.c | 4 ++--
magic/src/sharpen.c | 4 ++--
magic/src/shift.c | 4 ++--
magic/src/smudge.c | 4 ++--
magic/src/tint.c | 4 ++--
magic/src/waves.c | 4 ++--
src/tuxpaint.c | 22 ++++++++++++++--------
34 files changed, 103 insertions(+), 82 deletions(-)
diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt
index 6e714fa4f..844fcd018 100644
--- a/docs/CHANGES.txt
+++ b/docs/CHANGES.txt
@@ -33,7 +33,8 @@ $Id$
* Magic Tool Improvememnts:
--------------------------
* Added "_switchin()" and "_switchout()" functions to Magic tool API,
- to tell Magic tools when they are selected or deselected.
+ to tell Magic tools when they are selected or deselected, or when
+ their mode changes..
* Added "_modes()" function to Magic tool API, so Magic tool plugins
can tell Tux Paint what modes it accepts, 'paint' or 'fullscreen'.
diff --git a/magic/docs/README.txt b/magic/docs/README.txt
index 044817d83..5193b21c7 100644
--- a/magic/docs/README.txt
+++ b/magic/docs/README.txt
@@ -6,7 +6,7 @@
bill@newbreedsoftware.com
http://www.tuxpaint.org/
- July 5, 2007 - July 8, 2008
+ July 5, 2007 - July 10, 2008
----------------------------------------------------------------------
@@ -271,9 +271,9 @@ Interfaces
Plugin event functions:
- * void switchin(magic_api * api, int which,
+ * void switchin(magic_api * api, int which, int mode,
SDL_Surface * snapshot, SDL_Surface * canvas)
- void switchout(magic_api * api, int which,
+ void switchout(magic_api * api, int which, int mode,
SDL_Surface * snapshot, SDL_Surface * canvas)
switchin() is called whenever one of the plugin's Magic tools
becomes active, and switchout() is called whenever one becomes
@@ -290,6 +290,11 @@ Interfaces
tool is first 'switched-out', and then 'switched-back-in',
usually moments later.
+ Finally, it can also happen when the user changes the 'mode' of
+ a tool (i.e., from paint mode to full-image mode). First
+ switchout() is called for the old mode, then switchin() is
+ called for the new mode.
+
These functions allow users to interact in complicated was with
Magic tools (for example, a tool that lets the user draw
multiple freehand strokes, and then uses that as input such as
diff --git a/magic/docs/html/README.html b/magic/docs/html/README.html
index 98cbe9a87..68d799f3e 100644
--- a/magic/docs/html/README.html
+++ b/magic/docs/html/README.html
@@ -15,7 +15,7 @@ New Breed Software
bill@newbreedsoftware.com
http://www.tuxpaint.org/
-July 5, 2007 - July 8, 2008
+July 5, 2007 - July 10, 2008
@@ -352,11 +352,11 @@ then the names of your functions must begin with "zoom_"
void switchin(magic_api * api,
- int which,
+ int which, int mode,
SDL_Surface * snapshot, SDL_Surface * canvas)
void switchout(magic_api * api,
- int which,
+ int which, int mode,
SDL_Surface * snapshot, SDL_Surface * canvas)
switchin() is called whenever one of the plugin's Magic
@@ -374,6 +374,11 @@ then the names of your functions must begin with "zoom_"
Magic tool is first 'switched-out', and then 'switched-back-in', usually
moments later.
+ Finally, it can also happen when the user changes the 'mode' of a tool
+ (i.e., from paint mode to full-image mode). First
+ switchout() is called for the old mode, then
+ switchin() is called for the new mode.
+
These functions allow users to interact in complicated was with Magic
tools (for example, a tool that lets the user draw multiple
freehand strokes, and then uses that as input such as handwriting —
diff --git a/magic/docs/tp_magic_example.c b/magic/docs/tp_magic_example.c
index f0e8067ea..415b9693a 100644
--- a/magic/docs/tp_magic_example.c
+++ b/magic/docs/tp_magic_example.c
@@ -1,7 +1,7 @@
/* tp_magic_example.c
An example of a "Magic" tool plugin for Tux Paint
- Last modified: 2008.07.09
+ Last modified: 2008.07.10
*/
@@ -489,13 +489,18 @@ void example_line_callback(void * ptr, int which,
// This happens whenever a Magic tool is enabled, either because the
// user just selected it, or they just came back to "Magic" after using
// another tool (e.g., Brush or Text), and this was the most-recently
-// selected Magic tool. (This also applies to momentary tools, like
+// selected Magic tool.
+//
+// (This also applies to momentary tools, like
// Undo and Redo, and image-changing tools such as New and Open.)
//
+// It also happens when a Magic tool's mode changes (it first
+// receives a 'switchout()', below, for the old mode).
+//
// Our example doesn't do anything when we switch to, or away from, our
// Magic tools, so we just do nothing here.
-void example_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void example_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
@@ -504,14 +509,17 @@ void example_switchin(magic_api * api, int which, SDL_Surface * canvas)
// This happens whenever a Magic tool is disabled, either because the
// user selected a different Magic tool, or they selected a completely
// different tool (e.g., Brush or Text).
+//
// (This also applies to momentary tools, like Undo and Redo, and
// image-changing tools such as New and Open, in which case the
// switchin() function will be called moments later.)
+//
+// It also happens when a Magic tool's mode changes (it then
+// receives a 'switchin()', above, for the new mode).
//
// Our example doesn't do anything when we switch to, or away from, our
// Magic tools, so we just do nothing here.
-void example_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void example_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-
diff --git a/magic/src/blackAndWhite.c b/magic/src/blackAndWhite.c
index 0e5b40642..4d5769e09 100644
--- a/magic/src/blackAndWhite.c
+++ b/magic/src/blackAndWhite.c
@@ -205,11 +205,11 @@ int blackAndWhite_requires_colors(magic_api * api, int which)
return 0;
}
-void blackAndWhite_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void blackAndWhite_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void blackAndWhite_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void blackAndWhite_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/blocks_chalk_drip.c b/magic/src/blocks_chalk_drip.c
index 3aab3daed..a7aa70448 100644
--- a/magic/src/blocks_chalk_drip.c
+++ b/magic/src/blocks_chalk_drip.c
@@ -321,11 +321,11 @@ int blocks_chalk_drip_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int whic
return 0;
}
-void blocks_chalk_drip_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void blocks_chalk_drip_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void blocks_chalk_drip_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void blocks_chalk_drip_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/blur.c b/magic/src/blur.c
index 23f355815..c031cba1b 100644
--- a/magic/src/blur.c
+++ b/magic/src/blur.c
@@ -222,11 +222,11 @@ int blur_requires_colors(magic_api * api, int which)
return 0;
}
-void blur_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void blur_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void blur_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void blur_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/blurAll.c b/magic/src/blurAll.c
index 9c2b58522..5bf3bb5ae 100644
--- a/magic/src/blurAll.c
+++ b/magic/src/blurAll.c
@@ -188,11 +188,11 @@ int blurAll_requires_colors(magic_api * api, int which)
return 0;
}
-void blurAll_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void blurAll_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void blurAll_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void blurAll_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/bricks.c b/magic/src/bricks.c
index c20e88ca8..fbf8f7791 100644
--- a/magic/src/bricks.c
+++ b/magic/src/bricks.c
@@ -294,11 +294,11 @@ static void do_brick(magic_api * api, SDL_Surface * canvas,
api->playsound(brick_snd, (x * 255) / canvas->w, 255);
}
-void bricks_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void bricks_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void bricks_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void bricks_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/calligraphy.c b/magic/src/calligraphy.c
index 3e356b536..dfd6a89c7 100644
--- a/magic/src/calligraphy.c
+++ b/magic/src/calligraphy.c
@@ -420,11 +420,11 @@ static float calligraphy_dist(float x1, float y1, float x2, float y2)
return d;
}
-void calligraphy_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void calligraphy_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void calligraphy_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void calligraphy_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/cartoon.c b/magic/src/cartoon.c
index 812f09994..42230601a 100644
--- a/magic/src/cartoon.c
+++ b/magic/src/cartoon.c
@@ -223,11 +223,11 @@ int cartoon_requires_colors(magic_api * api, int which)
return 0;
}
-void cartoon_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void cartoon_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void cartoon_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void cartoon_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/confetti.c b/magic/src/confetti.c
index 981efed57..a0dfe7670 100644
--- a/magic/src/confetti.c
+++ b/magic/src/confetti.c
@@ -172,14 +172,12 @@ void confetti_drag(magic_api * api, int which, SDL_Surface * canvas,
confetti_click(api, which, MODE_PAINT, canvas, snapshot, x, y, update_rect);
}
-void confetti_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void confetti_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
-
}
-void confetti_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void confetti_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
-
}
int confetti_modes(magic_api * api, int which)
diff --git a/magic/src/distortion.c b/magic/src/distortion.c
index 438d7e54d..3d0ce6d09 100644
--- a/magic/src/distortion.c
+++ b/magic/src/distortion.c
@@ -226,11 +226,11 @@ static void distortion_line_callback(void * ptr, int which,
}
}
-void distortion_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void distortion_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void distortion_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void distortion_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/emboss.c b/magic/src/emboss.c
index 42ba642fd..0240624e1 100644
--- a/magic/src/emboss.c
+++ b/magic/src/emboss.c
@@ -179,11 +179,11 @@ int emboss_requires_colors(magic_api * api, int which)
return 0;
}
-void emboss_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void emboss_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void emboss_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void emboss_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/fade_darken.c b/magic/src/fade_darken.c
index fcb7fb93d..4a7e4f840 100644
--- a/magic/src/fade_darken.c
+++ b/magic/src/fade_darken.c
@@ -268,11 +268,11 @@ int fade_darken_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTR
return 0;
}
-void fade_darken_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void fade_darken_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void fade_darken_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void fade_darken_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/fill.c b/magic/src/fill.c
index bce4d2f02..2ad06570f 100644
--- a/magic/src/fill.c
+++ b/magic/src/fill.c
@@ -246,11 +246,11 @@ static void do_flood_fill(magic_api * api, SDL_Surface * canvas, int x, int y,
}
}
-void fill_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void fill_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void fill_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void fill_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/flower.c b/magic/src/flower.c
index 1b7cdf576..313255c15 100644
--- a/magic/src/flower.c
+++ b/magic/src/flower.c
@@ -594,11 +594,11 @@ static void flower_colorize_petals(magic_api * api)
SDL_UnlockSurface(flower_petals);
}
-void flower_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void flower_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void flower_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void flower_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/foam.c b/magic/src/foam.c
index d463644ea..0fdc0baa7 100644
--- a/magic/src/foam.c
+++ b/magic/src/foam.c
@@ -417,11 +417,11 @@ int foam_requires_colors(magic_api * api, int which)
return 0; /* FIXME: Would be nice to tint the bubbles */
}
-void foam_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void foam_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void foam_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void foam_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/fold.c b/magic/src/fold.c
index d8e84c76a..cd6c34e3e 100644
--- a/magic/src/fold.c
+++ b/magic/src/fold.c
@@ -252,14 +252,12 @@ void fold_drag(magic_api * api, int which, SDL_Surface * canvas,
}
-void fold_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void fold_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
-
}
-void fold_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void fold_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
-
}
int fold_modes(magic_api * api, int which)
diff --git a/magic/src/glasstile.c b/magic/src/glasstile.c
index d632c676b..8a15dc89d 100644
--- a/magic/src/glasstile.c
+++ b/magic/src/glasstile.c
@@ -296,11 +296,11 @@ int glasstile_requires_colors(magic_api * api, int which)
return 0;
}
-void glasstile_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void glasstile_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void glasstile_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void glasstile_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/grass.c b/magic/src/grass.c
index c1a4b7b8d..843c15b8f 100644
--- a/magic/src/grass.c
+++ b/magic/src/grass.c
@@ -244,11 +244,11 @@ static int log2int(int x)
return y;
}
-void grass_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void grass_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void grass_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void grass_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/kalidescope.c b/magic/src/kalidescope.c
index e117ba73c..b718a20bd 100644
--- a/magic/src/kalidescope.c
+++ b/magic/src/kalidescope.c
@@ -164,11 +164,11 @@ int kalidescope_requires_colors(magic_api * api, int which)
return 1;
}
-void kalidescope_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void kalidescope_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void kalidescope_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void kalidescope_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/light.c b/magic/src/light.c
index b349ec08e..cdfa54334 100644
--- a/magic/src/light.c
+++ b/magic/src/light.c
@@ -207,11 +207,11 @@ int light_requires_colors(magic_api * api, int which)
return 1;
}
-void light_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void light_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void light_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void light_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/metalpaint.c b/magic/src/metalpaint.c
index 434713598..5ad7da48d 100644
--- a/magic/src/metalpaint.c
+++ b/magic/src/metalpaint.c
@@ -173,11 +173,11 @@ int metalpaint_requires_colors(magic_api * api, int which)
return 1;
}
-void metalpaint_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void metalpaint_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void metalpaint_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void metalpaint_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/mirror_flip.c b/magic/src/mirror_flip.c
index 7f1f26910..e2aad1807 100644
--- a/magic/src/mirror_flip.c
+++ b/magic/src/mirror_flip.c
@@ -198,11 +198,11 @@ int mirror_flip_requires_colors(magic_api * api, int which)
return 0;
}
-void mirror_flip_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void mirror_flip_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void mirror_flip_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void mirror_flip_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/negative.c b/magic/src/negative.c
index d204164b8..94ed34f24 100644
--- a/magic/src/negative.c
+++ b/magic/src/negative.c
@@ -195,11 +195,11 @@ int negative_requires_colors(magic_api * api, int which)
return 0;
}
-void negative_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void negative_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void negative_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void negative_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/rainbow.c b/magic/src/rainbow.c
index 89e3219f0..9d9c166d2 100644
--- a/magic/src/rainbow.c
+++ b/magic/src/rainbow.c
@@ -193,11 +193,11 @@ int rainbow_requires_colors(magic_api * api, int which)
return 0;
}
-void rainbow_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void rainbow_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void rainbow_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void rainbow_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/ripples.c b/magic/src/ripples.c
index 329900cce..13e75208f 100644
--- a/magic/src/ripples.c
+++ b/magic/src/ripples.c
@@ -177,11 +177,11 @@ int ripples_requires_colors(magic_api * api, int which)
return 0;
}
-void ripples_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void ripples_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void ripples_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void ripples_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/sharpen.c b/magic/src/sharpen.c
index fc4512d7b..a5f7bf2a8 100644
--- a/magic/src/sharpen.c
+++ b/magic/src/sharpen.c
@@ -268,11 +268,11 @@ int sharpen_requires_colors(magic_api * api, int which)
return 0;
}
-void sharpen_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void sharpen_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void sharpen_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void sharpen_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/shift.c b/magic/src/shift.c
index 8b0f21e5c..efd58f4c2 100644
--- a/magic/src/shift.c
+++ b/magic/src/shift.c
@@ -323,11 +323,11 @@ int shift_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_
return 0;
}
-void shift_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void shift_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void shift_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void shift_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/smudge.c b/magic/src/smudge.c
index 92a578ac2..ea56a2cde 100644
--- a/magic/src/smudge.c
+++ b/magic/src/smudge.c
@@ -172,11 +172,11 @@ int smudge_requires_colors(magic_api * api, int which)
return 0;
}
-void smudge_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void smudge_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void smudge_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void smudge_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/tint.c b/magic/src/tint.c
index e9191bfda..2caa3aef4 100644
--- a/magic/src/tint.c
+++ b/magic/src/tint.c
@@ -204,11 +204,11 @@ int tint_requires_colors(magic_api * api, int which)
return 1;
}
-void tint_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void tint_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void tint_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void tint_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/magic/src/waves.c b/magic/src/waves.c
index 44239a9d9..b3e84e97a 100644
--- a/magic/src/waves.c
+++ b/magic/src/waves.c
@@ -154,11 +154,11 @@ int waves_requires_colors(magic_api * api, int which)
return 0;
}
-void waves_switchin(magic_api * api, int which, SDL_Surface * canvas)
+void waves_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
-void waves_switchout(magic_api * api, int which, SDL_Surface * canvas)
+void waves_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
{
}
diff --git a/src/tuxpaint.c b/src/tuxpaint.c
index ff6606710..050d5014f 100644
--- a/src/tuxpaint.c
+++ b/src/tuxpaint.c
@@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
- June 14, 2002 - July 8, 2008
+ June 14, 2002 - July 10, 2008
$Id$
*/
@@ -905,8 +905,8 @@ typedef struct magic_funcs_s {
void (*click)(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *);
void (*drag)(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, int, int, SDL_Rect *);
void (*release)(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *);
- void (*switchin)(magic_api *, int, SDL_Surface *, SDL_Surface *);
- void (*switchout)(magic_api *, int, SDL_Surface *, SDL_Surface *);
+ void (*switchin)(magic_api *, int, int, SDL_Surface *, SDL_Surface *);
+ void (*switchout)(magic_api *, int, int, SDL_Surface *, SDL_Surface *);
} magic_funcs_t;
@@ -2905,13 +2905,17 @@ static void mainloop(void)
/* Magic controls! */
if (which == 1 && magics[cur_magic].avail_modes & MODE_FULLSCREEN)
{
- magics[cur_magic].mode = MODE_FULLSCREEN;
+ magic_switchout(canvas);
+ magics[cur_magic].mode = MODE_FULLSCREEN;
+ magic_switchin(canvas);
draw_magic();
update_screen_rect(&r_toolopt);
}
else if (which == 0 && magics[cur_magic].avail_modes & MODE_PAINT)
{
+ magic_switchout(canvas);
magics[cur_magic].mode = MODE_PAINT;
+ magic_switchin(canvas);
draw_magic();
update_screen_rect(&r_toolopt);
}
@@ -3171,10 +3175,10 @@ static void mainloop(void)
}
else if (cur_tool == TOOL_MAGIC)
{
- magic_switchout(canvas);
-
if (cur_thing != cur_magic)
{
+ magic_switchout(canvas);
+
cur_magic = cur_thing;
draw_colors(magics[cur_magic].colors);
@@ -3184,14 +3188,14 @@ static void mainloop(void)
color_hexes[cur_color][0],
color_hexes[cur_color][1],
color_hexes[cur_color][2]);
+
+ magic_switchin(canvas);
}
draw_tux_text(TUX_GREAT, magics[cur_magic].tip[magic_modeint(magics[cur_magic].mode)], 1);
if (do_draw)
draw_magic();
-
- magic_switchin(canvas);
}
/* Update the screen: */
@@ -18965,6 +18969,7 @@ void magic_switchout(SDL_Surface * last)
if (cur_tool == TOOL_MAGIC)
magic_funcs[magics[cur_magic].handle_idx].switchout(magic_api_struct,
magics[cur_magic].idx,
+ magics[cur_magic].mode,
canvas, last);
}
@@ -18973,6 +18978,7 @@ void magic_switchin(SDL_Surface * last)
if (cur_tool == TOOL_MAGIC)
magic_funcs[magics[cur_magic].handle_idx].switchin(magic_api_struct,
magics[cur_magic].idx,
+ magics[cur_magic].mode,
canvas, last);
}