Added dirty rect to magic api.
Added 'release' event to magic api.
This commit is contained in:
parent
f61128527d
commit
c44cf54033
16 changed files with 354 additions and 56 deletions
|
|
@ -6,7 +6,7 @@
|
|||
bill@newbreedsoftware.com
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
July 5, 2007 - July 6, 2007
|
||||
July 5, 2007 - July 8, 2007
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -62,7 +62,8 @@ Interfaces
|
|||
'Magic' tool plugins must provide the functions listed below. Note: To
|
||||
avoid namespace collisions, each function's name must start with the
|
||||
shared object's filename (e.g., "blur.so" or "blur.dll" would have
|
||||
functions whose names begin with "blur_").
|
||||
functions whose names begin with "blur_"). This includes private
|
||||
functions, unless you declare those as 'static'.
|
||||
|
||||
Common arguments to plugin functions:
|
||||
|
||||
|
|
@ -127,20 +128,39 @@ Interfaces
|
|||
The plugin should do any cleanup here. This function is called
|
||||
once, at Tux Paint exit.
|
||||
* void click(magic_api * api, int which, SDL_Surface * snapshot,
|
||||
SDL_Surface * canvas, int x, int y)
|
||||
SDL_Surface * canvas, int x, int y, SDL_Rect * update_rect)
|
||||
The plugin should apply the appropriate 'Magic' tool on the
|
||||
'canvas' surface. The (x,y) coordinates are where the mouse was
|
||||
(within the canvas) when the mouse button was clicked.
|
||||
The plugin should report back what part of the canvas was
|
||||
affected, by filling in the (x,y) and (w,h) values in
|
||||
'update_rect'.
|
||||
The contents of the drawing canvas immediately prior to the mouse
|
||||
button click is stored within the 'snapshot' canvas.
|
||||
* void drag(magic_api * api, int which, SDL_Surface * snapshot,
|
||||
SDL_Surface * canvas, int ox, int oy, int x, int y)
|
||||
SDL_Surface * canvas, int ox, int oy, int x, int y, SDL_Rect *
|
||||
update_rect)
|
||||
The plugin should apply the appropriate 'Magic' tool on the
|
||||
'canvas' surface. The (ox,oy) and (x,y) coordinates are the
|
||||
location of the mouse at the beginning and end of the stroke.
|
||||
Typically, plugins that let the user "draw" effects onto the
|
||||
canvas call the Tux Paint 'Magic' tool plugin "line()" helper
|
||||
function. (See below).
|
||||
The plugin should report back what part of the canvas was
|
||||
affected, by filling in the (x,y) and (w,h) values in
|
||||
'update_rect'.
|
||||
Note: The contents of the drawing canvas immediately prior to the
|
||||
mouse button click remains as it was (when the plugin's "click()"
|
||||
function was called), and is still available in the 'snapshot'
|
||||
canvas.
|
||||
* void release(magic_api * api, int which, SDL_Surface * snapshot,
|
||||
SDL_Surface * canvas, int x, int y, SDL_Rect * update_rect)
|
||||
The plugin should apply the appropriate 'Magic' tool on the
|
||||
'canvas' surface. The (x,y) coordinates are where the mouse was
|
||||
(within the canvas) when the mouse button was released.
|
||||
The plugin should report back what part of the canvas was
|
||||
affected, by filling in the (x,y) and (w,h) values in
|
||||
'update_rect'.
|
||||
Note: The contents of the drawing canvas immediately prior to the
|
||||
mouse button click remains as it was (when the plugin's "click()"
|
||||
function was called), and is still available in the 'snapshot'
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ New Breed Software</p>
|
|||
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
||||
<a href="http://www.tuxpaint.org/">http://www.tuxpaint.org/</a></p>
|
||||
|
||||
<p>July 5, 2007 - July 6, 2007</p>
|
||||
<p>July 5, 2007 - July 8, 2007</p>
|
||||
</center>
|
||||
|
||||
<hr size=2 noshade>
|
||||
|
|
@ -84,7 +84,9 @@ of a "Tux Paint 'Magic' Tool Plugin Development package".)</p>
|
|||
<p>'Magic' tool plugins must provide the functions listed below.
|
||||
<b>Note:</b> To avoid namespace collisions, each function's name must
|
||||
start with the shared object's filename (e.g., "blur.so" or "blur.dll"
|
||||
would have functions whose names begin with "blur_").</p>
|
||||
would have functions whose names begin with "blur_"). <i>This
|
||||
includes private functions</i>, unless you declare those as
|
||||
'static'.</p>
|
||||
|
||||
<h4>Common arguments to plugin functions:</h4>
|
||||
|
||||
|
|
@ -160,20 +162,37 @@ would have functions whose names begin with "blur_").</p>
|
|||
at Tux Paint exit.
|
||||
|
||||
<li>void click(magic_api * api, int which, SDL_Surface * snapshot,
|
||||
SDL_Surface * canvas, int x, int y)<br>
|
||||
SDL_Surface * canvas, int x, int y, SDL_Rect * update_rect)<br>
|
||||
The plugin should apply the appropriate 'Magic' tool on the 'canvas'
|
||||
surface. The (x,y) coordinates are where the mouse was (within the canvas)
|
||||
when the mouse button was clicked.<br>
|
||||
The plugin should report back what part of the canvas was affected, by
|
||||
filling in the (x,y) and (w,h) values in 'update_rect'.<br>
|
||||
The contents of the drawing canvas immediately prior to the mouse button
|
||||
click is stored within the 'snapshot' canvas.
|
||||
|
||||
<li>void drag(magic_api * api, int which, SDL_Surface * snapshot,
|
||||
SDL_Surface * canvas, int ox, int oy, int x, int y)<br>
|
||||
SDL_Surface * canvas, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)<br>
|
||||
The plugin should apply the appropriate 'Magic' tool on the 'canvas'
|
||||
surface. The (ox,oy) and (x,y) coordinates are the location of the mouse
|
||||
at the beginning and end of the stroke. Typically, plugins that let the
|
||||
user "draw" effects onto the canvas call the Tux Paint 'Magic' tool
|
||||
plugin "line()" helper function. (See below).<br>
|
||||
The plugin should report back what part of the canvas was affected, by
|
||||
filling in the (x,y) and (w,h) values in 'update_rect'.<br>
|
||||
Note: The contents of the drawing canvas immediately prior to the mouse
|
||||
button click remains as it was (when the plugin's "click()" function was
|
||||
called), and is still available in the 'snapshot' canvas.
|
||||
|
||||
<li>void release(magic_api * api, int which, SDL_Surface * snapshot,
|
||||
SDL_Surface * canvas, int x, int y,
|
||||
SDL_Rect * update_rect)<br>
|
||||
The plugin should apply the appropriate 'Magic' tool on the 'canvas'
|
||||
surface. The (x,y) coordinates are where the mouse was (within the canvas)
|
||||
when the mouse button was released.<br>
|
||||
The plugin should report back what part of the canvas was affected, by
|
||||
filling in the (x,y) and (w,h) values in 'update_rect'.<br>
|
||||
Note: The contents of the drawing canvas immediately prior to the mouse
|
||||
button click remains as it was (when the plugin's "click()" function was
|
||||
called), and is still available in the 'snapshot' canvas.
|
||||
|
|
|
|||
|
|
@ -118,10 +118,19 @@ void do_example(void * ptr, int which, SDL_Surface * canvas, SDL_Surface * last,
|
|||
|
||||
// Affect the canvas on drag:
|
||||
void example_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y)
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
sDL_Rect * update_rect)
|
||||
{
|
||||
api->line(which, canvas, last, ox, oy, x, y, 1, do_example);
|
||||
|
||||
if (ox > x) { int tmp = ox; ox = x; x = tmp; }
|
||||
if (oy > y) { int tmp = oy; oy = y; y = tmp; }
|
||||
|
||||
update_rect->x = x - 4;
|
||||
update_rect->y = y - 4;
|
||||
update_rect->w = (ox + 4) - update_rect->x;
|
||||
update_rect->h = (oy + 4) - update_rect->h;
|
||||
|
||||
api->playsound(snd_effect[which],
|
||||
(x * 255) / canvas->w, (y * 255) / canvas->h);
|
||||
}
|
||||
|
|
@ -129,9 +138,16 @@ void example_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
// Affect the canvas on click:
|
||||
void example_click(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y)
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
example_drag(api, which, canvas, last, x, y, x, y, SDL_Rect * update_rect);
|
||||
}
|
||||
|
||||
// Affect the canvas on release:
|
||||
void example_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
example_drag(api, which, canvas, last, x, y, x, y);
|
||||
}
|
||||
|
||||
// No setup happened:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue