More work on Magic size support
Set default, pass current size to plugin when tool changes.
This commit is contained in:
parent
9b74f2a25e
commit
bb12be2518
2 changed files with 68 additions and 3 deletions
|
|
@ -34,9 +34,12 @@
|
||||||
|
|
||||||
/* Our globals: */
|
/* Our globals: */
|
||||||
|
|
||||||
|
#define KAL_MAX_SIZE 6
|
||||||
|
#define KAL_DEF_SIZE 4
|
||||||
|
|
||||||
static Mix_Chunk *kalidescope_snd;
|
static Mix_Chunk *kalidescope_snd;
|
||||||
static Uint8 kalidescope_r, kalidescope_g, kalidescope_b;
|
static Uint8 kalidescope_r, kalidescope_g, kalidescope_b;
|
||||||
static Uint8 kalidescope_sz = 8; // FIXME: Not necessary
|
static Uint8 kalidescope_sz = (KAL_DEF_SIZE * 2);
|
||||||
static int square_size = 128;
|
static int square_size = 128;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -307,13 +310,13 @@ void kalidescope_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE
|
||||||
Uint8 kalidescope_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED,
|
Uint8 kalidescope_accepted_sizes(magic_api * api ATTRIBUTE_UNUSED,
|
||||||
int which ATTRIBUTE_UNUSED)
|
int which ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
return 6;
|
return KAL_MAX_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8 kalidescope_default_size(magic_api * api ATTRIBUTE_UNUSED,
|
Uint8 kalidescope_default_size(magic_api * api ATTRIBUTE_UNUSED,
|
||||||
int which ATTRIBUTE_UNUSED)
|
int which ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
return 4;
|
return KAL_DEF_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record the size from Tux Paint:
|
// Record the size from Tux Paint:
|
||||||
|
|
|
||||||
|
|
@ -2249,6 +2249,7 @@ static void render_color_button(int the_color, SDL_Surface * decoration,
|
||||||
SDL_Surface * icon);
|
SDL_Surface * icon);
|
||||||
static void handle_color_changed(void);
|
static void handle_color_changed(void);
|
||||||
static void magic_set_color(void);
|
static void magic_set_color(void);
|
||||||
|
static void magic_set_size(void);
|
||||||
|
|
||||||
static void do_quick_eraser(void);
|
static void do_quick_eraser(void);
|
||||||
|
|
||||||
|
|
@ -3835,6 +3836,8 @@ static void mainloop(void)
|
||||||
|
|
||||||
if (magics[magic_group][cur_thing].colors)
|
if (magics[magic_group][cur_thing].colors)
|
||||||
magic_set_color();
|
magic_set_color();
|
||||||
|
if (magics[magic_group][cur_thing].sizes)
|
||||||
|
magic_set_size();
|
||||||
}
|
}
|
||||||
else if (cur_tool == TOOL_ERASER)
|
else if (cur_tool == TOOL_ERASER)
|
||||||
{
|
{
|
||||||
|
|
@ -4498,6 +4501,8 @@ static void mainloop(void)
|
||||||
|
|
||||||
if (magics[magic_group][cur_thing].colors)
|
if (magics[magic_group][cur_thing].colors)
|
||||||
magic_set_color();
|
magic_set_color();
|
||||||
|
if (magics[magic_group][cur_thing].sizes)
|
||||||
|
magic_set_size();
|
||||||
|
|
||||||
magic_switchin(canvas);
|
magic_switchin(canvas);
|
||||||
|
|
||||||
|
|
@ -5259,6 +5264,8 @@ static void mainloop(void)
|
||||||
|
|
||||||
if (magics[grp][cur].colors)
|
if (magics[grp][cur].colors)
|
||||||
magic_set_color();
|
magic_set_color();
|
||||||
|
if (magics[grp][cur].sizes)
|
||||||
|
magic_set_size();
|
||||||
|
|
||||||
magic_switchin(canvas);
|
magic_switchin(canvas);
|
||||||
}
|
}
|
||||||
|
|
@ -22762,6 +22769,22 @@ static void load_magic_plugins(void)
|
||||||
magics[group][idx].colors =
|
magics[group][idx].colors =
|
||||||
magic_funcs[num_plugin_files].requires_colors
|
magic_funcs[num_plugin_files].requires_colors
|
||||||
(magic_api_struct, i);
|
(magic_api_struct, i);
|
||||||
|
magics[group][idx].sizes =
|
||||||
|
magic_funcs[num_plugin_files].accepted_sizes
|
||||||
|
(magic_api_struct, i);
|
||||||
|
if (magic_funcs[num_plugin_files].accepted_sizes) {
|
||||||
|
magics[group][idx].default_size =
|
||||||
|
magic_funcs[num_plugin_files].default_size
|
||||||
|
(magic_api_struct, i);
|
||||||
|
if (magics[group][idx].default_size < 1 ||
|
||||||
|
magics[group][idx].default_size > magics[group][idx].sizes) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Warning: plugin %s mode # %d default size (%d) out of range (1-%d)\n",
|
||||||
|
fname, i, magics[group][idx].default_size, magics[group][idx].sizes);
|
||||||
|
magics[group][idx].default_size = 1;
|
||||||
|
}
|
||||||
|
magics[group][idx].size = magics[group][idx].default_size;
|
||||||
|
}
|
||||||
if (magics[group][idx].avail_modes & MODE_PAINT)
|
if (magics[group][idx].avail_modes & MODE_PAINT)
|
||||||
magics[group][idx].mode = MODE_PAINT;
|
magics[group][idx].mode = MODE_PAINT;
|
||||||
else if (magics[group][idx].avail_modes & MODE_ONECLICK)
|
else if (magics[group][idx].avail_modes & MODE_ONECLICK)
|
||||||
|
|
@ -27133,6 +27156,45 @@ static void magic_set_color(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the [new] size choice for a given Magic tool to
|
||||||
|
* the tool's plugin.
|
||||||
|
*
|
||||||
|
* We expect that `magics[magic_group][cur_magic[magic_group]].size`
|
||||||
|
* has been set prior to calling this.
|
||||||
|
*/
|
||||||
|
static void magic_set_size() {
|
||||||
|
int undo_ctr;
|
||||||
|
SDL_Surface *last;
|
||||||
|
SDL_Rect update_rect;
|
||||||
|
|
||||||
|
update_rect.x = 0;
|
||||||
|
update_rect.y = 0;
|
||||||
|
update_rect.w = 0;
|
||||||
|
update_rect.h = 0;
|
||||||
|
|
||||||
|
if (cur_undo > 0)
|
||||||
|
undo_ctr = cur_undo - 1;
|
||||||
|
else
|
||||||
|
undo_ctr = NUM_UNDO_BUFS - 1;
|
||||||
|
|
||||||
|
last = undo_bufs[undo_ctr];
|
||||||
|
|
||||||
|
magic_funcs[magics[magic_group][cur_magic[magic_group]].handle_idx].
|
||||||
|
set_size(magic_api_struct,
|
||||||
|
magics[magic_group][cur_magic[magic_group]].idx,
|
||||||
|
canvas,
|
||||||
|
last,
|
||||||
|
magics[magic_group][cur_magic[magic_group]].size,
|
||||||
|
&update_rect);
|
||||||
|
|
||||||
|
if (update_rect.w > 0 && update_rect.h > 0) {
|
||||||
|
update_canvas(update_rect.x, update_rect.y,
|
||||||
|
update_rect.x + update_rect.w,
|
||||||
|
update_rect.y + update_rect.h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME
|
* FIXME
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue