From 472692fbab59cca187e94967d5680489e0f46cdf Mon Sep 17 00:00:00 2001 From: William Kendrick Date: Wed, 9 Jul 2008 02:46:54 +0000 Subject: [PATCH] Magic tools can now be both painted and full-image. Negative tool now does this. --- data/images/ui/magic_fullscreen.png | Bin 0 -> 1292 bytes data/images/ui/magic_paint.png | Bin 0 -> 544 bytes docs/CHANGES.txt | 16 ++- docs/OPTIONS.txt | 10 +- docs/html/OPTIONS.html | 12 ++- magic/docs/README.txt | 20 +++- magic/docs/html/README.html | 26 ++++- magic/docs/tp_magic_example.c | 13 ++- magic/src/blackAndWhite.c | 10 +- magic/src/blocks_chalk_drip.c | 10 +- magic/src/blur.c | 8 +- magic/src/blurAll.c | 10 +- magic/src/bricks.c | 8 +- magic/src/calligraphy.c | 8 +- magic/src/cartoon.c | 8 +- magic/src/distortion.c | 8 +- magic/src/emboss.c | 8 +- magic/src/fade_darken.c | 10 +- magic/src/fill.c | 8 +- magic/src/flower.c | 8 +- magic/src/foam.c | 8 +- magic/src/glasstile.c | 8 +- magic/src/grass.c | 8 +- magic/src/kalidescope.c | 8 +- magic/src/light.c | 8 +- magic/src/metalpaint.c | 8 +- magic/src/mirror_flip.c | 8 +- magic/src/negative.c | 38 ++++++- magic/src/rainbow.c | 8 +- magic/src/ripples.c | 8 +- magic/src/sharpen.c | 10 +- magic/src/shift.c | 10 +- magic/src/smudge.c | 8 +- magic/src/tint.c | 8 +- magic/src/waves.c | 9 +- src/manpage/tuxpaint.1 | 15 ++- src/tp_magic_api.h.in | 7 +- src/tuxpaint.c | 154 ++++++++++++++++++++++++++-- 38 files changed, 453 insertions(+), 79 deletions(-) create mode 100644 data/images/ui/magic_fullscreen.png create mode 100644 data/images/ui/magic_paint.png diff --git a/data/images/ui/magic_fullscreen.png b/data/images/ui/magic_fullscreen.png new file mode 100644 index 0000000000000000000000000000000000000000..db214172d8e177232c34c96d601231dd295dc41f GIT binary patch literal 1292 zcmV+n1@roeP)X00001b5ch_0Itp) z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iOM* z0R}Gt*jJDM000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}000DMNkly^kD45XFDhJ+pi4-ucdmz!C(G`6Cbs2{OXi5t2_r1SE+60m%sg2|~nJoO2T) zGAG0&7DNc0gaaE4HXLiuOm$ZibkB#+mhbi~p+lmjQP=i-)Z16}UN`(do^Qw`UI7hA z3#mb9Nz#ll4bb3Ri_zd{F>8RvIa)KdvzO zx=E~n3Me9hL?>kpMEm>BOu_PR=kjcMc8=gMjh^9oK&h(G$BOE_#9Lb{J&M66047pL zN}WJRq?{n7uD@>sP!uzDxRTt|%&Fm(h{i}4%d=GoN}c05Xj|3~4qjXzAP_Rp%%DI3 z=@|&l^+2ub=RRhb`|o7tLtQIc4;5O1vb`O6Ww9PWDd2J}Ar+v=khC*nDCaPj81Dnb z4AP@iK>@8%ogoVI(C~t;K$*?-_1m}C1DK!#Q6z&KdN1YK;ezWy846C#=v?_zKK3Bd zYW!0wI@69$H#S;@M|u6XZM~UNI6;Y1?l~#3bHNRwFg2W75k)T+v56pJ)QTz)P(m(i zSMD_pLkoP&6=^|vHe ze*k*+ECC4V7^Qs@U>d7Y{v#bp;F?wB&UGX(~7K2TC&0H3Q#|J!$_j|w{;1cj1*mdB823u@B9N$YR*@*yx z1nHIMidrYWI9#q6v!TS8%{b<`%3oYiac|E2SKw>tb`L<$pI@)EPw7E4fr=2Ep@ymD z-Yei-25i zUTnwv5IstT5<-P@mu549_gusACJ!IJ4SWJz06r6u&65Kx+nE_1MGVfYSL|3?&^UTt z_RD|*=PTa2u^!sKYy9)h2qRx&uPsefSR_i5(} z3+2p87Yp78_thldMG@H(k)7iLtPbxahIP0ig1)R)W}j`vN3Rf-st8ExpsL-xLtBcK z{PmKqxOV{dA#et`Sn^yc^X_^Kx(O@xc;T*tv~A-qiQ3ulbGXBPAh=6v z`sfhIi@@i==2{FooPtxF3pVtfOl-vms-ge7$2_uJckjNcDWy0~lu~+-QrgYlIE*8O z^TcV!oQ;0hv*uAhVK9U$gQ@F*?d5U`^2cXwXS=|)Lrm@gJDj4i3ETkEjW~mODHE0000| zgW!U_%O?XxI14-?iy0WWg+Z8+Vb&Z8pdfpRr>`sf4R%gOHko}KW^F(r$r9Iy66gHf z+|;}h2Ir#G#FEq$h4Rdj3w>yLY!Ik}&^)7^c{;%>%2RA{z;yS@JU}}&TZqF;MjBdGs~aJg+>Vh zg+JI&9bRwCu(xNiS}p4}UVF~x2R46uV0>QBLVEdn)_NxWP4jpXk{=xYptNpP&K!{) z<_$8;oEIJJ02XYs@&t`hV g(Eg}##jP*Q>b%7 literal 0 HcmV?d00001 diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 4a106e49f..b66f9f3e3 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -19,10 +19,18 @@ $Id$ * BlurAll, Sharpen and BlackandWhite Andrew Corcoran - * Magic Tool Plug-in API Updates: - ------------------------------- - * Added "_switchin()" and "_switchout()" functions, to tell Magic tools - when they are selected or deselected. + * Magic Tool Improvememnts: + -------------------------- + * Added "_switchin()" and "_switchout()" functions to Magic tool API, + to tell Magic tools when they are selected or deselected. + + * Added "_modes()" function to Magic tool API, so Magic tool plugins + can tell Tux Paint what modes it accepts, 'paint' or 'fullscreen'. + + * "Paint" and "Fullscreen" control buttons added to Magic tool + selector UI. Can be disabled with "--nomagiccontrols". + + * "Negative" tool can now affect the entire image. * Build System Improvements ------------------------- diff --git a/docs/OPTIONS.txt b/docs/OPTIONS.txt index 9d426789d..fb0f66758 100644 --- a/docs/OPTIONS.txt +++ b/docs/OPTIONS.txt @@ -9,7 +9,7 @@ Options Documentation bill@newbreedsoftware.com http://www.tuxpaint.org/ - July 7, 2008 + July 8, 2008 ---------------------------------------------------------------------- @@ -324,6 +324,12 @@ Windows Users have their size changed. This option disables the controls, and only provides the basic stamps. + nomagiccontrols=yes + Some Magic tools have the option of acting like a paintbrush, or + affecting the entire canvas at once. This option disables the + controls, and only provides the default functionality (usually + paint-mode). + mirrorstamps=yes For stamps that can be mirrored, this option sets them to their @@ -701,6 +707,7 @@ Windows Users --nooutlines --nostamps --nostampcontrols + --nomagiccontrols --sysfonts --mirrorstamps --stampsize=SIZE @@ -741,6 +748,7 @@ Windows Users --outlines --stamps --stampcontrols + --magiccontrols --nosysfonts --dontmirrorstamps --stampsize=default diff --git a/docs/html/OPTIONS.html b/docs/html/OPTIONS.html index 96b0f908a..e0b49ee56 100644 --- a/docs/html/OPTIONS.html +++ b/docs/html/OPTIONS.html @@ -23,7 +23,7 @@ New Breed Software

http://www.tuxpaint.org/

-

July 7, 2008

+

July 8, 2008

@@ -407,6 +407,14 @@ New Breed Software

and only provides the basic stamps. +
nomagiccontrols=yes
+
+ Some Magic tools have the option of acting like a paintbrush, + or affecting the entire canvas at once. + This option disables the controls, and only provides the default + functionality (usually paint-mode). +
+
mirrorstamps=yes

For stamps that can be mirrored, this option sets them to their @@ -1076,6 +1084,7 @@ New Breed Software

--nooutlines
--nostamps
--nostampcontrols
+ --nomagiccontrols
--sysfonts
--mirrorstamps
--stampsize=SIZE
@@ -1119,6 +1128,7 @@ New Breed Software

--outlines
--stamps
--stampcontrols
+ --magiccontrols
--nosysfonts
--dontmirrorstamps
--stampsize=default
diff --git a/magic/docs/README.txt b/magic/docs/README.txt index 7c89ed647..4288d1220 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 7, 2008 + July 5, 2007 - July 8, 2008 ---------------------------------------------------------------------- @@ -236,6 +236,24 @@ Interfaces Note: Called once for each Magic tool your plugin claims to contain (by your "get_tool_count()"). + * int modes(magic_api * api, int which) + This lets you tell Tux Paint what modes your tool can be used in + (either as a tool the user can paint with, or a tool that + affects the entire drawing at once) + + You must return a value that's some combination of one or more + of available modes: + * MODE_PAINT + * MODE_FULLSCREEN + e.g., if your tool is only one that the user can paint with, + return "MODE_PAINT". If the user can do both, return + "MODE_PAINT | MODE_FULLSCREEN" to tell Tux Paint it can do both. + + Note: Called once for each Magic tool your plugin claims to + contain (by your "get_tool_count()"). + + Note: Added to Tux Paint 0.9.21; Magic API version '0x00000002' + * void shutdown(magic_api * api) The plugin should do any cleanup here. If you allocated any memory or used SDL_Mixer to load any sounds during init(), for diff --git a/magic/docs/html/README.html b/magic/docs/html/README.html index 918a7ed5a..8da0b5205 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 7, 2008

+

July 5, 2007 - July 8, 2008


@@ -305,6 +305,30 @@ then the names of your functions must begin with "zoom_" contain (by your "get_tool_count()").

+
  • int modes(magic_api * api, + int which)
    + This lets you tell Tux Paint what modes your tool can be used in + (either as a tool the user can paint with, or a tool that affects + the entire drawing at once)
    +
    + You must return a value that's some combination of one or more of + available modes: +
      +
    • MODE_PAINT +
    • MODE_FULLSCREEN +
    + e.g., if your tool is only one that the user can paint with, + return "MODE_PAINT". If the user can do both, + return "MODE_PAINT | MODE_FULLSCREEN" + to tell Tux Paint it can do both.
    +
    + Note: Called once for each Magic tool your plugin claims to + contain (by your "get_tool_count()").
    +
    + Note: Added to Tux Paint 0.9.21; Magic API version + '0x00000002'
    +
    +
  • void shutdown(magic_api * api)
    The plugin should do any cleanup here. If you allocated any memory or used SDL_Mixer to load any sounds during init(), diff --git a/magic/docs/tp_magic_example.c b/magic/docs/tp_magic_example.c index 0d1eab9c0..b88151098 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.07 + Last modified: 2008.07.08 */ @@ -282,6 +282,17 @@ int example_requires_colors(magic_api * api, int which) } +// Report what modes we work in + +int example_modes(magic_api * api, int which) +{ + // Both of our tools are painted (neither affect the full-screen), + // so we're always returning 'MODE_PAINT' + + return MODE_PAINT; +} + + // Shut down // // Tux Paint is quitting. When it quits, it asks all of the plugins diff --git a/magic/src/blackAndWhite.c b/magic/src/blackAndWhite.c index 62f978b6a..135b6bbf2 100644 --- a/magic/src/blackAndWhite.c +++ b/magic/src/blackAndWhite.c @@ -4,6 +4,8 @@ blackAndWhite, Convert the image to greyscale or threshold it into pure black and pure white Tux Paint - A simple drawing program for children. + FIXME: Credits + Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt bill@newbreedsoftware.com http://www.tuxpaint.org/ @@ -23,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -162,7 +164,7 @@ void blackAndWhite_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void blackAndWhite_click(magic_api * api, int which, +void blackAndWhite_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect){ update_rect->x = 0; @@ -211,3 +213,7 @@ void blackAndWhite_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int blackAndWhite_modes(magic_api * api, int which) +{ + return(MODE_FULLSCREEN); /* FIXME - Can also be turned into a painted effect */ +} diff --git a/magic/src/blocks_chalk_drip.c b/magic/src/blocks_chalk_drip.c index 4225969e8..070c65f0a 100644 --- a/magic/src/blocks_chalk_drip.c +++ b/magic/src/blocks_chalk_drip.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -62,7 +62,7 @@ static void blocks_chalk_drip_linecb(void * ptr, int which, void blocks_chalk_drip_drag(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect); -void blocks_chalk_drip_click(magic_api * api, int which, +void blocks_chalk_drip_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void blocks_chalk_drip_release(magic_api * api, int which, @@ -285,7 +285,7 @@ void blocks_chalk_drip_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void blocks_chalk_drip_click(magic_api * api, int which, +void blocks_chalk_drip_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -329,3 +329,7 @@ void blocks_chalk_drip_switchout(magic_api * api, int which, SDL_Surface * canva { } +int blocks_chalk_drip_modes(magic_api * api, int which) +{ + return(MODE_PAINT); /* FIXME - Blocks and Chalk, at least, can also be turned into a full-image effect */ +} diff --git a/magic/src/blur.c b/magic/src/blur.c index d93d8334a..15c5b5379 100644 --- a/magic/src/blur.c +++ b/magic/src/blur.c @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -174,7 +174,7 @@ void blur_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void blur_click(magic_api * api, int which, +void blur_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -213,3 +213,7 @@ void blur_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int blur_modes(magic_api * api, int which) +{ + return(MODE_PAINT); /* FIXME - Can also be turned into a full-image effect */ /* FIXME: Merge with blurAll */ +} diff --git a/magic/src/blurAll.c b/magic/src/blurAll.c index 3fda160ea..41d474c24 100644 --- a/magic/src/blurAll.c +++ b/magic/src/blurAll.c @@ -4,6 +4,8 @@ blurAll, Blur the whole image Tux Paint - A simple drawing program for children. + FIXME: Credits + Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt bill@newbreedsoftware.com http://www.tuxpaint.org/ @@ -23,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -145,7 +147,7 @@ void blurAll_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void blurAll_click(magic_api * api, int which, +void blurAll_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect){ update_rect->x = 0; @@ -194,3 +196,7 @@ void blurAll_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int blurAll_modes(magic_api * api, int which) +{ + return(MODE_FULLSCREEN); /* FIXME - Can also be turned into a painted effect */ /* FIXME: Merge with blur */ +} diff --git a/magic/src/bricks.c b/magic/src/bricks.c index c28714a11..2236a5baa 100644 --- a/magic/src/bricks.c +++ b/magic/src/bricks.c @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -224,7 +224,7 @@ void bricks_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void bricks_click(magic_api * api, int which, +void bricks_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -302,3 +302,7 @@ void bricks_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int bricks_modes(magic_api * api, int which) +{ + return(MODE_PAINT); +} diff --git a/magic/src/calligraphy.c b/magic/src/calligraphy.c index b1d5534e3..fa61de74b 100644 --- a/magic/src/calligraphy.c +++ b/magic/src/calligraphy.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -252,7 +252,7 @@ void calligraphy_drag(magic_api * api, int which, SDL_Surface * canvas, api->playsound(calligraphy_snd, (x * 255) / canvas->w, 255); } -void calligraphy_click(magic_api * api, int which, +void calligraphy_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -428,3 +428,7 @@ void calligraphy_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int calligraphy_modes(magic_api * api, int which) +{ + return(MODE_FULLSCREEN); +} diff --git a/magic/src/cartoon.c b/magic/src/cartoon.c index e69077715..aa17e95e5 100644 --- a/magic/src/cartoon.c +++ b/magic/src/cartoon.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -191,7 +191,7 @@ void cartoon_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void cartoon_click(magic_api * api, int which, +void cartoon_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -231,3 +231,7 @@ void cartoon_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int cartoon_modes(magic_api * api, int which) +{ + return(MODE_PAINT); /* FIXME - Can also be turned into a full-image effect */ +} diff --git a/magic/src/distortion.c b/magic/src/distortion.c index 077d0e122..f15ce49a0 100644 --- a/magic/src/distortion.c +++ b/magic/src/distortion.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -150,7 +150,7 @@ void distortion_shutdown(magic_api * api) // Affect the canvas on click: -void distortion_click(magic_api * api, int which, +void distortion_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect) { @@ -234,3 +234,7 @@ void distortion_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int distortion_modes(magic_api * api, int which) +{ + return(MODE_PAINT); +} diff --git a/magic/src/emboss.c b/magic/src/emboss.c index 92220a3e0..0c2616c4e 100644 --- a/magic/src/emboss.c +++ b/magic/src/emboss.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -147,7 +147,7 @@ void emboss_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void emboss_click(magic_api * api, int which, +void emboss_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -187,3 +187,7 @@ void emboss_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int emboss_modes(magic_api * api, int which) +{ + return(MODE_PAINT); /* FIXME - Can also be turned into a full-image effect */ +} diff --git a/magic/src/fade_darken.c b/magic/src/fade_darken.c index db04759c6..cd63ae416 100644 --- a/magic/src/fade_darken.c +++ b/magic/src/fade_darken.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -56,7 +56,7 @@ static void do_fade_darken(void * ptr, int which, void fade_darken_drag(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect); -void fade_darken_click(magic_api * api, int which, +void fade_darken_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void fade_darken_release(magic_api * api, int which, @@ -195,7 +195,7 @@ void fade_darken_drag(magic_api * api, int which, SDL_Surface * canvas, } // Ask Tux Paint to call our 'do_fade_darken()' callback at a single point -void fade_darken_click(magic_api * api, int which, +void fade_darken_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -239,3 +239,7 @@ void fade_darken_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int fade_darken_modes(magic_api * api, int which) +{ + return(MODE_PAINT); /* FIXME - Can also be turned into a full-image effect */ +} diff --git a/magic/src/fill.c b/magic/src/fill.c index b54445c4f..ef76e2385 100644 --- a/magic/src/fill.c +++ b/magic/src/fill.c @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -103,7 +103,7 @@ void fill_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void fill_click(magic_api * api, int which, +void fill_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -254,3 +254,7 @@ void fill_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int fill_modes(magic_api * api, int which) +{ + return(MODE_PAINT); +} diff --git a/magic/src/flower.c b/magic/src/flower.c index ee830f264..bfad2462b 100644 --- a/magic/src/flower.c +++ b/magic/src/flower.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -192,7 +192,7 @@ void flower_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void flower_click(magic_api * api, int which, +void flower_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -602,3 +602,7 @@ void flower_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int flower_modes(magic_api * api, int which) +{ + return(MODE_PAINT); +} diff --git a/magic/src/foam.c b/magic/src/foam.c index b35800520..40ddc02a6 100644 --- a/magic/src/foam.c +++ b/magic/src/foam.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -161,7 +161,7 @@ void foam_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void foam_click(magic_api * api, int which, +void foam_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -425,3 +425,7 @@ void foam_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int foam_modes(magic_api * api, int which) +{ + return(MODE_PAINT); +} diff --git a/magic/src/glasstile.c b/magic/src/glasstile.c index 0dbba00c2..944a9e739 100644 --- a/magic/src/glasstile.c +++ b/magic/src/glasstile.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -218,7 +218,7 @@ void glasstile_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void glasstile_click(magic_api * api, int which, +void glasstile_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -287,3 +287,7 @@ void glasstile_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int glasstile_modes(magic_api * api, int which) +{ + return(MODE_PAINT); /* FIXME - Can also be turned into a full-image effect */ +} diff --git a/magic/src/grass.c b/magic/src/grass.c index 77ce67613..5975935bb 100644 --- a/magic/src/grass.c +++ b/magic/src/grass.c @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -119,7 +119,7 @@ void grass_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void grass_click(magic_api * api, int which, +void grass_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -252,3 +252,7 @@ void grass_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int grass_modes(magic_api * api, int which) +{ + return(MODE_PAINT); +} diff --git a/magic/src/kalidescope.c b/magic/src/kalidescope.c index 0b0d7bc14..987be7e8d 100644 --- a/magic/src/kalidescope.c +++ b/magic/src/kalidescope.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -128,7 +128,7 @@ void kalidescope_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void kalidescope_click(magic_api * api, int which, +void kalidescope_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -172,3 +172,7 @@ void kalidescope_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int kalidescope_modes(magic_api * api, int which) +{ + return(MODE_PAINT); +} diff --git a/magic/src/light.c b/magic/src/light.c index 6ccac06a0..5c502e54b 100644 --- a/magic/src/light.c +++ b/magic/src/light.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -171,7 +171,7 @@ void light_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void light_click(magic_api * api, int which, +void light_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -215,3 +215,7 @@ void light_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int light_modes(magic_api * api, int which) +{ + return(MODE_PAINT); +} diff --git a/magic/src/metalpaint.c b/magic/src/metalpaint.c index f12204ffb..46ae03d5f 100644 --- a/magic/src/metalpaint.c +++ b/magic/src/metalpaint.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -138,7 +138,7 @@ void metalpaint_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void metalpaint_click(magic_api * api, int which, +void metalpaint_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -181,3 +181,7 @@ void metalpaint_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int metalpaint_modes(magic_api * api, int which) +{ + return(MODE_PAINT); +} diff --git a/magic/src/mirror_flip.c b/magic/src/mirror_flip.c index 6e2cb709c..1a26f2b6a 100644 --- a/magic/src/mirror_flip.c +++ b/magic/src/mirror_flip.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -127,7 +127,7 @@ void mirror_flip_release(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void mirror_flip_click(magic_api * api, int which, +void mirror_flip_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) @@ -206,3 +206,7 @@ void mirror_flip_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int mirror_flip_modes(magic_api * api, int which) +{ + return(MODE_FULLSCREEN); +} diff --git a/magic/src/negative.c b/magic/src/negative.c index 60776ac22..07f0e8e0e 100644 --- a/magic/src/negative.c +++ b/magic/src/negative.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -125,17 +125,43 @@ void negative_drag(magic_api * api, int which, SDL_Surface * canvas, update_rect->h = (y + 16) - update_rect->h; api->playsound(negative_snd, (x * 255) / canvas->w, 255); - + + SDL_UnlockSurface(canvas); SDL_UnlockSurface(last); } // Ask Tux Paint to call our 'do_negative()' callback at a single point -void negative_click(magic_api * api, int which, +void negative_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { - negative_drag(api, which, canvas, last, x, y, x, y, update_rect); + if (mode == MODE_PAINT) + negative_drag(api, which, canvas, last, x, y, x, y, update_rect); + else + { + int xx, yy; + Uint8 r, g, b; + + for (yy = 0; yy < canvas->h; yy++) + { + for (xx = 0; xx < canvas->w; xx++) + { + SDL_GetRGB(api->getpixel(last, xx, yy), last->format, &r, &g, &b); + + r = 0xFF - r; + g = 0xFF - g; + b = 0xFF - b; + + api->putpixel(canvas, xx, yy, SDL_MapRGB(canvas->format, r, g, b)); + } + } + + update_rect->x = 0; + update_rect->y = 0; + update_rect->w = canvas->w; + update_rect->h = canvas->h; + } } @@ -171,3 +197,7 @@ void negative_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int negative_modes(magic_api * api, int which) +{ + return(MODE_PAINT | MODE_FULLSCREEN); +} diff --git a/magic/src/rainbow.c b/magic/src/rainbow.c index f689c3176..d5c337dea 100644 --- a/magic/src/rainbow.c +++ b/magic/src/rainbow.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -160,7 +160,7 @@ void rainbow_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void rainbow_click(magic_api * api, int which, +void rainbow_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) @@ -201,3 +201,7 @@ void rainbow_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int rainbow_modes(magic_api * api, int which) +{ + return(MODE_PAINT); +} diff --git a/magic/src/ripples.c b/magic/src/ripples.c index fc5a49675..95ead49b8 100644 --- a/magic/src/ripples.c +++ b/magic/src/ripples.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -113,7 +113,7 @@ static void ripples_linecb(void * ptr, int which, } // Affect the canvas on click: -void ripples_click(magic_api * api, int which, +void ripples_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -185,3 +185,7 @@ void ripples_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int ripples_modes(magic_api * api, int which) +{ + return(MODE_PAINT); +} diff --git a/magic/src/sharpen.c b/magic/src/sharpen.c index 760c5f9c3..4bd5c6645 100644 --- a/magic/src/sharpen.c +++ b/magic/src/sharpen.c @@ -4,6 +4,8 @@ Sharpen, Trace Contour and Silhouette Magic Tool Plugin Tux Paint - A simple drawing program for children. + FIXME: Credits + Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt bill@newbreedsoftware.com http://www.tuxpaint.org/ @@ -23,7 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -223,7 +225,7 @@ void sharpen_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void sharpen_click(magic_api * api, int which, +void sharpen_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -274,3 +276,7 @@ void sharpen_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int sharpen_modes(magic_api * api, int which) +{ + return(MODE_FULLSCREEN); /* FIXME - Can also be turned into a painted effect */ +} diff --git a/magic/src/shift.c b/magic/src/shift.c index 5ec41684b..fab1ce767 100644 --- a/magic/src/shift.c +++ b/magic/src/shift.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -55,7 +55,7 @@ char * shift_get_description(magic_api * api, int which); void shift_drag(magic_api * api, int which, SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect); -void shift_click(magic_api * api, int which, +void shift_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect); void shift_release(magic_api * api, int which, @@ -284,7 +284,7 @@ static void shift_doit(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNU } // Affect the canvas on click: -void shift_click(magic_api * api, int which, +void shift_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -331,3 +331,7 @@ void shift_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int shift_modes(magic_api * api, int which) +{ + return(MODE_FULLSCREEN); +} diff --git a/magic/src/smudge.c b/magic/src/smudge.c index 26ffdc999..e98f4ed52 100644 --- a/magic/src/smudge.c +++ b/magic/src/smudge.c @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -140,7 +140,7 @@ void smudge_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void smudge_click(magic_api * api, int which, +void smudge_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -180,3 +180,7 @@ void smudge_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int smudge_modes(magic_api * api, int which) +{ + return(MODE_PAINT); +} diff --git a/magic/src/tint.c b/magic/src/tint.c index 14480978d..d9d4edb9e 100644 --- a/magic/src/tint.c +++ b/magic/src/tint.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -143,7 +143,7 @@ void tint_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void tint_click(magic_api * api, int which, +void tint_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -186,3 +186,7 @@ void tint_switchout(magic_api * api, int which, SDL_Surface * canvas) { } +int tint_modes(magic_api * api, int which) +{ + return(MODE_PAINT); /* FIXME - Can also be turned into a full-image effect */ +} diff --git a/magic/src/waves.c b/magic/src/waves.c index b4c982523..affd1e598 100644 --- a/magic/src/waves.c +++ b/magic/src/waves.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last updated: July 7, 2008 + Last updated: July 8, 2008 $Id$ */ @@ -121,7 +121,7 @@ void waves_drag(magic_api * api, int which, SDL_Surface * canvas, } // Affect the canvas on click: -void waves_click(magic_api * api, int which, +void waves_click(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect) { @@ -161,3 +161,8 @@ void waves_switchin(magic_api * api, int which, SDL_Surface * canvas) void waves_switchout(magic_api * api, int which, SDL_Surface * canvas) { } + +int waves_modes(magic_api * api, int which) +{ + return(MODE_FULLSCREEN); +} diff --git a/src/manpage/tuxpaint.1 b/src/manpage/tuxpaint.1 index 0ac06abeb..bd48bf8e2 100644 --- a/src/manpage/tuxpaint.1 +++ b/src/manpage/tuxpaint.1 @@ -1,5 +1,5 @@ -.\" tuxpaint.1 - 2008.06.19 -.TH TUXPAINT 1 "19 June 2008" "0.9.20" "Tux Paint" +.\" tuxpaint.1 - 2008.07.08 +.TH TUXPAINT 1 "8 July 2008" "0.9.21" "Tux Paint" .SH NAME tuxpaint -- "Tux Paint", a drawing program for young children. @@ -55,6 +55,8 @@ tuxpaint -- "Tux Paint", a drawing program for young children. .br [\-\-nostampcontrols] .br +[\-\-nomagiccontrols] +.br [\-\-mirrorstamps] .br [\-\-stampsize=\fISIZE\fP] @@ -121,6 +123,8 @@ tuxpaint -- "Tux Paint", a drawing program for young children. .br [\-\-stampcontrols] .br +[\-\-magiccontrols] +.br [\-\-dontmirrorstamps] .br [\-\-stampsize=default] @@ -323,6 +327,13 @@ Disable or enable (default) buttons to control stamps. Controls include mirror, flip, shrink and grow. (Note: Not all stamps will be controllable in all ways.) +.TP 8 +.B \-\-nomagiccontrols \-\-magiccontrols +Disable or enable (default) buttons to control Magic tools. Controls include +controlling whether a Magic tool is used like a paint brush, or if it +affects the entire image at once. (Note: Not all Magic tools will be +controllable.) + .TP 8 .B \-\-mirrorstamps \-\-dontmirrorstamps With \fImirrorstamps\fP set, stamps which can be mirrored will appear diff --git a/src/tp_magic_api.h.in b/src/tp_magic_api.h.in index 9dcec42b8..0a91f60e5 100644 --- a/src/tp_magic_api.h.in +++ b/src/tp_magic_api.h.in @@ -39,7 +39,6 @@ /* The image has been mirrored (so starter should be, too) */ /* (as of API version 0x00000001) */ - #define SPECIAL_MIRROR 0x0001 /* The image has been flipped (so starter should be, too) */ @@ -47,6 +46,12 @@ #define SPECIAL_FLIP 0x0002 +/* Flags you return when asked what modes you work in */ +/* (as of API version 0x00000002) */ +#define MODE_PAINT 0x0001 /* User can paint the tool, freehand */ +#define MODE_FULLSCREEN 0x0002 /* User can apply effect to entire canvas at once */ + + typedef struct magic_api_t { /* A string containing the current version of Tux Paint (e.g., "0.9.18") */ char * tp_version; diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 9242befff..cdfee56c7 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -875,7 +875,9 @@ static int dont_do_xor, dont_load_stamps, mirrorstamps, disable_stamp_controls, stamp_size_override, - simple_shapes, only_uppercase; + simple_shapes, only_uppercase, + + disable_magic_controls; static int starter_mirrored, starter_flipped, starter_personal; static Uint8 canvas_color_r, canvas_color_g, canvas_color_b; @@ -895,11 +897,12 @@ typedef struct magic_funcs_s { SDL_Surface * (*get_icon)(magic_api *, int); char * (*get_description)(magic_api *, int); int (*requires_colors)(magic_api *, int); + int (*modes)(magic_api *, int); void (*set_color)(magic_api *, Uint8, Uint8, Uint8); int (*init)(magic_api *); Uint32 (*api_version)(void); void (*shutdown)(magic_api *); - void (*click)(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *); + 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 *); @@ -911,6 +914,8 @@ typedef struct magic_s { int place; int handle_idx; // Index to magic funcs for each magic tool (shared objs may report more than 1 tool) int idx; // Index to magic tools within shared objects (shared objs may report more than 1 tool) + int mode; // Current mode (paint or fullscreen) + int avail_modes; // Available modes (paint &/or fullscreen) int colors; // Whether magic tool accepts colors char * name; // Name of magic tool char * tip; // Description of magic tool @@ -985,6 +990,7 @@ static SDL_Surface *img_cursor_starter_up, *img_cursor_starter_down; static SDL_Surface *img_scroll_up, *img_scroll_down; static SDL_Surface *img_scroll_up_off, *img_scroll_down_off; static SDL_Surface *img_grow, *img_shrink; +static SDL_Surface *img_magic_paint, *img_magic_fullscreen; static SDL_Surface *img_bold, *img_italic; static SDL_Surface *img_color_picker, *img_color_picker_thumb, *img_paintwell; int color_picker_x, color_picker_y; @@ -2720,6 +2726,13 @@ static void mainloop(void) { 2, 2}; } + else if (cur_tool == TOOL_MAGIC) + { + if (!disable_magic_controls) + gd_controls = (grid_dims) + { + 1, 2}; + } // number of whole or partial rows that will be needed // (can make this per-tool if variable columns needed) @@ -2886,7 +2899,24 @@ static void mainloop(void) update_stamp_xor(); } } - else // not TOOL_STAMP, so must be TOOL_TEXT + else if (cur_tool == TOOL_MAGIC) + { + /* Magic controls! */ + if (which == 1 && magics[cur_magic].avail_modes & MODE_FULLSCREEN) + { + magics[cur_magic].mode = MODE_FULLSCREEN; + draw_magic(); + update_screen_rect(&r_toolopt); + } + else if (which == 0 && magics[cur_magic].avail_modes & MODE_PAINT) + { + magics[cur_magic].mode = MODE_PAINT; + draw_magic(); + update_screen_rect(&r_toolopt); + } + /* FIXME: Sfx */ + } + else if (cur_tool == TOOL_TEXT) { /* Text controls! */ int control_sound = -1; @@ -3362,6 +3392,7 @@ static void mainloop(void) magic_funcs[magics[cur_magic].handle_idx].click(magic_api_struct, magics[cur_magic].idx, + magics[cur_magic].mode, canvas, last, old_x, old_y, &update_rect); @@ -3473,6 +3504,13 @@ static void mainloop(void) { 2, 2}; } + else if (cur_tool == TOOL_MAGIC) + { + if (!disable_magic_controls) + gd_controls = (grid_dims) + { + 1, 2}; + } // number of whole or partial rows that will be needed // (can make this per-tool if variable columns needed) @@ -3798,6 +3836,8 @@ static void mainloop(void) max = 8; // was 10 before left/right group buttons -bjk 2007.05.03 if (cur_tool == TOOL_TEXT && !disable_stamp_controls) max = 10; + if (cur_tool == TOOL_MAGIC && !disable_magic_controls) + max = 12; if (num_things > max + TOOLOFFSET) @@ -5025,6 +5065,7 @@ static void show_usage(FILE * f, char *prg) " %s [--stamps | --nostamps]\n" " %s [--sysfonts | --nosysfonts]\n" " %s [--nostampcontrols | --stampcontrols]\n" + " %s [--nomagiccontrols | --magiccontrols]\n" " %s [--mirrorstamps | --dontmirrorstamps]\n" " %s [--stampsize=[0-10] | --stampsize=default]\n" " %s [--saveoverask | --saveover | --saveovernew]\n" @@ -6180,6 +6221,7 @@ static void setup(int argc, char *argv[]) no_system_fonts = 1; mirrorstamps = 0; disable_stamp_controls = 0; + disable_magic_controls = 0; #ifndef WINDOW_WIDTH WINDOW_WIDTH = 800; @@ -6371,6 +6413,14 @@ static void setup(int argc, char *argv[]) { disable_stamp_controls = 0; } + else if (strcmp(argv[i], "--nomagiccontrols") == 0) + { + disable_magic_controls = 1; + } + else if (strcmp(argv[i], "--magiccontrols") == 0) + { + disable_magic_controls = 0; + } else if (strcmp(argv[i], "--noshortcuts") == 0) { noshortcuts = 1; @@ -7543,6 +7593,9 @@ static void setup(int argc, char *argv[]) img_grow = loadimage(DATA_PREFIX "images/ui/grow.png"); img_shrink = loadimage(DATA_PREFIX "images/ui/shrink.png"); + img_magic_paint = loadimage(DATA_PREFIX "images/ui/magic_paint.png"); + img_magic_fullscreen = loadimage(DATA_PREFIX "images/ui/magic_fullscreen.png"); + img_bold = loadimage(DATA_PREFIX "images/ui/bold.png"); img_italic = loadimage(DATA_PREFIX "images/ui/italic.png"); @@ -8151,14 +8204,21 @@ static void draw_magic(void) { int magic, i, max, off_y; SDL_Rect dest; + int most; draw_image_title(TITLE_MAGIC, r_ttoolopt); - if (num_magics > 14 + TOOLOFFSET) + /* How many can we show? */ + + most = 12; + if (disable_magic_controls) + most = 14; + + if (num_magics > most + TOOLOFFSET) { off_y = 24; - max = 12 + TOOLOFFSET; + max = (most - 2) + TOOLOFFSET; dest.x = WINDOW_WIDTH - 96; dest.y = 40; @@ -8173,9 +8233,9 @@ static void draw_magic(void) } dest.x = WINDOW_WIDTH - 96; - dest.y = 40 + 24 + ((6 + TOOLOFFSET / 2) * 48); + dest.y = 40 + 24 + ((((most - 2) / 2) + TOOLOFFSET / 2) * 48); - if (magic_scroll < num_magics - 12 - TOOLOFFSET) + if (magic_scroll < num_magics - (most - 2) - TOOLOFFSET) { SDL_BlitSurface(img_scroll_down, NULL, screen, &dest); } @@ -8187,7 +8247,7 @@ static void draw_magic(void) else { off_y = 0; - max = 14 + TOOLOFFSET; + max = most + TOOLOFFSET; } @@ -8227,6 +8287,53 @@ static void draw_magic(void) SDL_BlitSurface(img_btn_off, NULL, screen, &dest); } } + + + /* Draw text controls: */ + + if (!disable_magic_controls) + { + SDL_Surface *button_color; + + /* Show paint button: */ + + if (magics[cur_magic].mode == MODE_PAINT) + button_color = img_btn_down; // Active + else if (magics[cur_magic].avail_modes & MODE_PAINT) + button_color = img_btn_up; // Available, but not active + else + button_color = img_btn_off; // Unavailable + + dest.x = WINDOW_WIDTH - 96; + dest.y = 40 + ((6 + TOOLOFFSET / 2) * 48); + + SDL_BlitSurface(button_color, NULL, screen, &dest); + + dest.x = WINDOW_WIDTH - 96 + (48 - img_magic_paint->w) / 2; + dest.y = (40 + ((6 + TOOLOFFSET / 2) * 48) + (48 - img_magic_paint->h) / 2); + + SDL_BlitSurface(img_magic_paint, NULL, screen, &dest); + + + /* Show fullscreen button: */ + + if (magics[cur_magic].mode == MODE_FULLSCREEN) + button_color = img_btn_down; // Active + else if (magics[cur_magic].avail_modes & MODE_FULLSCREEN) + button_color = img_btn_up; // Available, but not active + else + button_color = img_btn_off; // Unavailable + + dest.x = WINDOW_WIDTH - 48; + dest.y = 40 + ((6 + TOOLOFFSET / 2) * 48); + + SDL_BlitSurface(button_color, NULL, screen, &dest); + + dest.x = WINDOW_WIDTH - 48 + (48 - img_magic_fullscreen->w) / 2; + dest.y = (40 + ((6 + TOOLOFFSET / 2) * 48) + (48 - img_magic_fullscreen->h) / 2); + + SDL_BlitSurface(img_magic_fullscreen, NULL, screen, &dest); + } } @@ -11906,6 +12013,9 @@ static void cleanup(void) free_surface(&img_grow); free_surface(&img_shrink); + free_surface(&img_magic_paint); + free_surface(&img_magic_fullscreen); + free_surface(&img_bold); free_surface(&img_italic); @@ -15625,6 +15735,15 @@ static void parse_options(FILE * fi) { disable_stamp_controls = 0; } + else if (strcmp(str, "nomagiccontrols=yes") == 0) + { + disable_magic_controls = 1; + } + else if (strcmp(str, "nomagiccontrols=no") == 0 || + strcmp(str, "magiccontrols=yes") == 0) + { + disable_magic_controls = 0; + } else if (strcmp(str, "mirrorstamps=yes") == 0) { mirrorstamps = 1; @@ -16881,6 +17000,11 @@ void load_magic_plugins(void) magic_funcs[num_plugin_files].requires_colors = SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + snprintf(funcname, sizeof(funcname), "%s_%s", objname, + "modes"); + magic_funcs[num_plugin_files].modes= + SDL_LoadFunction(magic_handle[num_plugin_files], funcname); + snprintf(funcname, sizeof(funcname), "%s_%s", objname, "set_color"); magic_funcs[num_plugin_files].set_color = @@ -16937,6 +17061,8 @@ void load_magic_plugins(void) (int) magic_funcs[num_plugin_files].get_description); printf("requires_colors = 0x%x\n", (int) magic_funcs[num_plugin_files].requires_colors); + printf("modes = 0x%x\n", + (int) magic_funcs[num_plugin_files].modes); printf("set_color = 0x%x\n", (int) magic_funcs[num_plugin_files].set_color); printf("init = 0x%x\n", @@ -16989,6 +17115,12 @@ void load_magic_plugins(void) fname); err = 1; } + if (magic_funcs[num_plugin_files].modes == NULL) + { + fprintf(stderr, "Error: plugin %s is missing modes\n", + fname); + err = 1; + } if (magic_funcs[num_plugin_files].set_color == NULL) { fprintf(stderr, "Error: plugin %s is missing set_color\n", @@ -17083,11 +17215,17 @@ void load_magic_plugins(void) magics[num_magics].name = magic_funcs[num_plugin_files].get_name(magic_api_struct, i); magics[num_magics].tip = magic_funcs[num_plugin_files].get_description(magic_api_struct, i); magics[num_magics].colors = magic_funcs[num_plugin_files].requires_colors(magic_api_struct, i); + magics[num_magics].avail_modes = magic_funcs[num_plugin_files].modes(magic_api_struct, i); + if (magics[num_magics].avail_modes & MODE_PAINT) + magics[num_magics].mode = MODE_PAINT; + else + magics[num_magics].mode = MODE_FULLSCREEN; magics[num_magics].img_icon = magic_funcs[num_plugin_files].get_icon(magic_api_struct, i); #ifdef DEBUG printf("-- %s\n", magics[num_magics].name); + printf("avail_modes = %d\n", magics[num_magics].avail_modes); #endif num_magics++;