Commit b886fe56 authored by ROOL's avatar ROOL 🤖

Colour handling fixes

Detail:
  * Menus rearranged so "Advanced" is renamed "Palette options"; "Extra click for input focus" moved to the Paint menu.
  * The "Highlight background colour" menu option has been removed to simplify the interface.
  * To address all the differences of opinion around the artist-friendly palette arrangement, the default behaviour is to not show the confirmation dialogue box plus a further menu option "Rearrange user palettes" (ticked by default).
    If the latter's unticked, the remapping to artist-friendly (upon Edit palette) will never take place; if it's ticked, the remapping will always take place except when the confirmation box is enabled and the user clicks Default.
  * Greyed out palette options when there's not a full/default 256-colour palette, as appropriate.
  * Help text updated to reflect these changes.
Admin:
  Submission for the Paint bounty.

Version 2.28. Tagged as 'Paint-2_28'
parent 6a84fc4e
No preview for this file type
......@@ -9,12 +9,12 @@
GBLS Module_ApplicationDate
GBLS Module_HelpVersion
GBLS Module_ComponentName
Module_MajorVersion SETS "2.27"
Module_Version SETA 227
Module_MajorVersion SETS "2.28"
Module_Version SETA 228
Module_MinorVersion SETS ""
Module_Date SETS "22 Sep 2019"
Module_ApplicationDate SETS "22-Sep-19"
Module_Date SETS "26 Sep 2019"
Module_ApplicationDate SETS "26-Sep-19"
Module_ComponentName SETS "Paint"
Module_FullVersion SETS "2.27"
Module_HelpVersion SETS "2.27 (22 Sep 2019)"
Module_FullVersion SETS "2.28"
Module_HelpVersion SETS "2.28 (26 Sep 2019)"
END
/* (2.27)
/* (2.28)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 2.27
#define Module_MajorVersion_CMHG 2.28
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 22 Sep 2019
#define Module_Date_CMHG 26 Sep 2019
#define Module_MajorVersion "2.27"
#define Module_Version 227
#define Module_MajorVersion "2.28"
#define Module_Version 228
#define Module_MinorVersion ""
#define Module_Date "22 Sep 2019"
#define Module_Date "26 Sep 2019"
#define Module_ApplicationDate "22-Sep-19"
#define Module_ApplicationDate "26-Sep-19"
#define Module_ComponentName "Paint"
#define Module_FullVersion "2.27"
#define Module_HelpVersion "2.27 (22 Sep 2019)"
#define Module_LibraryVersionInfo "2:27"
#define Module_FullVersion "2.28"
#define Module_HelpVersion "2.28 (26 Sep 2019)"
#define Module_LibraryVersionInfo "2:28"
......@@ -554,7 +554,7 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
1 << 0 /*R1 is sprite*/);
else
os_swi6 (ColourTrans_GenerateTable, psprite_address (sprite)->mode,
psprite_std_palettes [sprite->file->use_current_palette? 0: 1][lb_bpp],
psprite_std_palettes [sprite->file->use_current_palette? 0: 1][lb_bpp],
0, (int) mono_palette, (int) mono_ttab, 0);
#ifdef XTRACE
......@@ -660,26 +660,24 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
/*Now see if it's the selected background colour, which we'll
indicate with a dotted black and white border.*/
if (main_current_options.advanced.highlight_bgcolour)
{ if (ECF)
bgselected = sprite->gcol2.ecf && (sprite->gcol2.colour == ECF-1);
else if(i == nc)
bgselected = !sprite->gcol2.ecf && !sprite->gcol2.alpha;
else
bgselected = !sprite->gcol2.ecf && sprite->gcol2.alpha && (sprite->gcol2.colour == i);
/*Draw a dotted white line around the selected background
colour.*/
if (bgselected)
{ wimpt_noerr (wimp_setcolour (0));
int w = coloursize - (1 << x_eig);
int h = coloursize - (1 << y_eig);
bbc_move (x, y);
bbc_plot (bbc_DottedExFinal + bbc_DrawRelFore, 0, h);
bbc_plot (bbc_DottedExFinal + bbc_DrawRelFore, w, 0);
bbc_plot (bbc_DottedExFinal + bbc_DrawRelFore, 0, -h);
bbc_plot (bbc_DottedExFinal + bbc_DrawRelFore, -w, 0);
}
if (ECF)
bgselected = sprite->gcol2.ecf && (sprite->gcol2.colour == ECF-1);
else if(i == nc)
bgselected = !sprite->gcol2.ecf && !sprite->gcol2.alpha;
else
bgselected = !sprite->gcol2.ecf && sprite->gcol2.alpha && (sprite->gcol2.colour == i);
/*Draw a dotted white line around the selected background
colour.*/
if (bgselected)
{ wimpt_noerr (wimp_setcolour (0));
int w = coloursize - (1 << x_eig);
int h = coloursize - (1 << y_eig);
bbc_move (x, y);
bbc_plot (bbc_DottedExFinal + bbc_DrawRelFore, 0, h);
bbc_plot (bbc_DottedExFinal + bbc_DrawRelFore, w, 0);
bbc_plot (bbc_DottedExFinal + bbc_DrawRelFore, 0, -h);
bbc_plot (bbc_DottedExFinal + bbc_DrawRelFore, -w, 0);
}
/*Fill in the number (full size only).*/
if
......
......@@ -190,8 +190,8 @@ static
{/*zoom*/ 1, 1},
{/*grid?*/ TRUE, /*colour*/ 7},
{/*extended*/ TRUE /*always on in versions from Black onwards*/},
{/*extra click focus?*/TRUE, /*h.lt. bgcolour?*/TRUE,
/*art. friendly?*/TRUE, /*ask remap pal?*/TRUE}
{/*extra click focus?*/TRUE, /*art. friendly?*/TRUE,
/*remap pal?*/TRUE, /*ask remap pal?*/FALSE}
};
static
......@@ -971,7 +971,7 @@ main_sprite_window *main_get_sprite_window (wimp_w handle)
main_sprite_window *win = sprite->windows;
while (win != NULL)
{
if (win->window->handle == handle) return win;
if (win->window->handle == handle) return win;
win = win->link;
}
}
......@@ -2978,8 +2978,8 @@ static char *write_options (void)
{ char A [32];
sprintf (A, "A%c%c%c%c ", opt->advanced.extra_click_focus? '+': '-',
opt->advanced.highlight_bgcolour? 'H': 'L',
opt->advanced.artist_friendly? 'F': 'U',
opt->advanced.remap_palette? 'R': 'D',
opt->advanced.ask_remap_palette? 'C': 'Q');
strcat (buffer, A);
}
......@@ -3538,17 +3538,17 @@ static void read_options (void)
opt->extended.on = TRUE;
break;
case 'A': /* A(+|-)?(H|L)?(F|U)?(C|Q)? */
case 'A': /* A(+|-)?(F|U)?(R|D)?(C|Q)? */
{ char *cc;
for (cc = &token [1]; *cc != '\0'; cc++)
switch (toupper (*cc))
{ case '+': opt->advanced.extra_click_focus = TRUE; break;
case '-': opt->advanced.extra_click_focus = FALSE; break;
case 'H': opt->advanced.highlight_bgcolour = TRUE; break;
case 'L': opt->advanced.highlight_bgcolour = FALSE; break;
case 'F': opt->advanced.artist_friendly = TRUE; break;
case 'U': opt->advanced.artist_friendly = FALSE; break;
case 'R': opt->advanced.remap_palette = TRUE; break;
case 'D': opt->advanced.remap_palette = FALSE; break;
case 'C': opt->advanced.ask_remap_palette = TRUE; break;
case 'Q': opt->advanced.ask_remap_palette = FALSE; break;
}
......
......@@ -2034,15 +2034,19 @@ void menus_sprite_handler (void *handle, char *hit)
if (hit [2])
{ wimp_eventstr ev = {0}, *ev2;
int mx = 0, my = 0;
BOOL askToRemap = main_current_options.advanced.artist_friendly
BOOL couldRemap = main_current_options.advanced.artist_friendly
&& main_current_options.advanced.remap_palette
&& colours_is_artist_friendly (sprite);
if (askToRemap)
{ /* Save coordinates from the menu. We'll need them for dboxtcol */
if (couldRemap)
{ int dboxResult;
BOOL inMenu = FALSE;
/* Save coordinates from the menu. We'll need them for dboxtcol */
ev2 = wimpt_last_event ();
if (ev2 && (ev2->e == wimp_EMENU || ev2->e == wimp_ESEND) &&
ev2->data.msg.hdr.action == wimp_MMENUWARN)
{ mx = ev2->data.msg.data.menuwarn.x;
{ inMenu = TRUE;
mx = ev2->data.msg.data.menuwarn.x;
my = ev2->data.msg.data.menuwarn.y;
}
else
......@@ -2051,43 +2055,44 @@ void menus_sprite_handler (void *handle, char *hit)
mx = mouse_str.x;
my = mouse_str.y;
}
int dboxResult;
/* dbox can be disabled in the options. If so, the remap
will just go ahead without asking. */
if (main_current_options.advanced.ask_remap_palette)
dboxResult = remap_to_artistfriendly_dbox ();
else
dboxResult = 0;
if (dboxResult == 0) /* if Rearrange */
{ colours_remap_to_artist_friendly (sprite);
/* Don't forget to remap the currently selected colours too! */
sprite->gcol.colour = colours_get_artist_friendly_index (sprite->gcol.colour, sprite);
sprite->gcol2.colour = colours_get_artist_friendly_index (sprite->gcol2.colour, sprite);
sprite_palette_has_changed (sprite);
}
if (dboxResult == -1)
{ /* They cancelled the operation. We'll just ask again next time */
destroy_artistfriendly_dbox ();
break;
}
{ dboxResult = remap_to_artistfriendly_dbox ();
if (dboxResult == 0) /* if Rearrange */
{ colours_remap_to_artist_friendly (sprite);
/* Don't forget to remap the currently selected colours too! */
sprite->gcol.colour = colours_get_artist_friendly_index (sprite->gcol.colour, sprite);
sprite->gcol2.colour = colours_get_artist_friendly_index (sprite->gcol2.colour, sprite);
sprite_palette_has_changed (sprite);
}
if (dboxResult == -1)
{ /* They cancelled the operation. We'll just ask again next time */
destroy_artistfriendly_dbox ();
break;
}
sprite->artistfriendly = artist_unfriendly;
sprite->artistfriendly = artist_unfriendly;
/* Hide this dialogue box but keep the menus open */
if (main_current_options.advanced.ask_remap_palette &&
artistfriendly_dbox != NULL)
{ int dboxhandle = dbox_syshandle (artistfriendly_dbox);
if (dboxhandle != NULL)
wimpt_noerr (wimp_close_wind (dbox_syshandle (artistfriendly_dbox)));
/* Hide this dialogue box but keep the menus open */
if (main_current_options.advanced.ask_remap_palette &&
artistfriendly_dbox != NULL)
{ int dboxhandle = dbox_syshandle (artistfriendly_dbox);
if (dboxhandle != NULL)
wimpt_noerr (wimp_close_wind (dbox_syshandle (artistfriendly_dbox)));
}
/*if (inMenu)*/
{ /* Now we have to make dboxtcol think it was opened from the menu */
ev.e = wimp_ESEND;
ev.data.msg.hdr.action = wimp_MMENUWARN;
ev.data.msg.data.menuwarn.x = mx;
ev.data.msg.data.menuwarn.y = my;
wimpt_fake_event (&ev);
wimpt_poll ((wimp_emask)0, &ev);
}
}
/* Now we have to make dboxtcol think it was opened from the menu */
ev.e = wimp_ESEND;
ev.data.msg.hdr.action = wimp_MMENUWARN;
ev.data.msg.data.menuwarn.x = mx;
ev.data.msg.data.menuwarn.y = my;
wimpt_fake_event (&ev);
wimpt_poll ((wimp_emask)0, &ev);
}
else if (!main_current_options.advanced.artist_friendly)
{ /* Make sure artist-friendly logic will be re-run if the
......@@ -2103,31 +2108,32 @@ void menus_sprite_handler (void *handle, char *hit)
/* Enable nulls, so slider drags work */
event_setmask ((wimp_emask) (((emask = event_getmask ()) & ~wimp_EMNULL)));
dboxtcol (colour, /*allow transparent?*/ FALSE,
BOOL chosen = dboxtcol (colour, /*allow transparent?*/ FALSE,
msgs_lookup ("PntW8"), &Apply_Colour, (void *) sprite);
event_setmask (emask);
/* If we need to remap the palette layout to artist-friendly
without showing the confirmation dbox, then we must do it AFTER
the user has edited the colour, so it's on a click rather than
just a menu hit */
if (chosen && couldRemap &&
!main_current_options.advanced.ask_remap_palette)
{ colours_remap_to_artist_friendly (sprite);
/* Don't forget to remap the currently selected colours too! */
sprite->gcol.colour = colours_get_artist_friendly_index (sprite->gcol.colour, sprite);
sprite->gcol2.colour = colours_get_artist_friendly_index (sprite->gcol2.colour, sprite);
sprite_palette_has_changed (sprite);
sprite->artistfriendly = artist_unfriendly;
}
destroy_artistfriendly_dbox ();
}
break;
case s_Paint_Adv_Opt:
switch (hit [2])
{ case s_Adv_ExtraClick:
main_current_options.advanced.extra_click_focus =
!main_current_options.advanced.extra_click_focus;
break;
case s_Adv_HiBackCol:
main_current_options.advanced.highlight_bgcolour =
!main_current_options.advanced.highlight_bgcolour;
for (main_sprite *spr = sprite->file->sprites; spr != NULL;
spr = spr->link)
{ /* Redraw all colour selectors */
if (spr->colourdialogue == 0) colours_set_extent (spr);
}
break;
case s_Adv_ArtFriend:
{ case s_Adv_ArtFriend:
main_current_options.advanced.artist_friendly =
!main_current_options.advanced.artist_friendly;
......@@ -2142,12 +2148,21 @@ void menus_sprite_handler (void *handle, char *hit)
if (spr->colourdialogue == 0) colours_set_extent (spr);
}
break;
case s_Adv_RemapPal:
main_current_options.advanced.remap_palette =
!main_current_options.advanced.remap_palette;
break;
case s_Adv_AskRemapPal:
main_current_options.advanced.ask_remap_palette =
!main_current_options.advanced.ask_remap_palette;
break;
}
break;
case s_Paint_Extra_Click:
main_current_options.advanced.extra_click_focus =
!main_current_options.advanced.extra_click_focus;
break;
}
break;
......@@ -3943,19 +3958,29 @@ menu menus_sprite_maker (void *handle)
/*tick?*/ FALSE, /*grey?*/ !(psprite_hastruecolpal (sprite) &&
!sprite->gcol.ecf && sprite->gcol.colour < no_colours));
menu_setflags (sprite_advopts_menu, s_Adv_ExtraClick,
/*tick?*/ main_current_options.advanced.extra_click_focus,
/*grey?*/ FALSE);
menu_setflags (sprite_advopts_menu, s_Adv_HiBackCol,
/*tick?*/ main_current_options.advanced.highlight_bgcolour,
/*grey?*/ no_colours > 256);
/* We'll grey out all artist-friendly options if the palette doesn't */
/* support the artist-friendly layout. */
BOOL friendly = no_colours == 256 && colours_is_artist_friendly (sprite);
menu_setflags (sprite_paint_menu, s_Paint_Adv_Opt,
/*tick?*/ FALSE, /*grey?*/!friendly);
menu_setflags (sprite_advopts_menu, s_Adv_ArtFriend,
/*tick?*/ main_current_options.advanced.artist_friendly,
/*grey?*/ no_colours != 256);
/*grey?*/ !friendly);
menu_setflags (sprite_advopts_menu, s_Adv_RemapPal,
/*tick?*/ main_current_options.advanced.remap_palette,
/*grey?*/ !friendly || !(psprite_hastruecolpal (sprite)) ||
!main_current_options.advanced.artist_friendly);
menu_setflags (sprite_advopts_menu, s_Adv_AskRemapPal,
/*tick?*/ main_current_options.advanced.ask_remap_palette,
/*grey?*/ no_colours != 256 || !(psprite_hastruecolpal (sprite)) ||
!main_current_options.advanced.artist_friendly);
/*grey?*/ !friendly || !(psprite_hastruecolpal (sprite)) ||
!main_current_options.advanced.artist_friendly ||
!main_current_options.advanced.remap_palette);
menu_setflags (sprite_paint_menu, s_Paint_Extra_Click,
/*tick?*/ main_current_options.advanced.extra_click_focus,
/*grey?*/ FALSE);
/*strcpy (rotatebuffer, "90");
strcpy (scalebuffer, "1");
......
......@@ -1050,7 +1050,7 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle)
break;
case 'P' - 64: /* Ctrl-P to edit palette */
if (psprite_haspal (window->data->sprite.sprite))
{ fake_menu_hit[0] = s_Edit;
{ fake_menu_hit[0] = s_Paint;
fake_menu_hit[1] = s_Paint_Edit_Pal;
fake_menu_hit[2] = 1;
menus_sprite_handler (window, fake_menu_hit);
......
......@@ -73,19 +73,19 @@
#define s_Save_Palette 2
/* Paint menu */
#define s_Paint_ECF 1
#define s_Paint_Sel_Col 2
#define s_Paint_Show_Col 3
#define s_Paint_Show_Tool 4
#define s_Paint_Small 5
#define s_Paint_Edit_Pal 6
#define s_Paint_Adv_Opt 7
#define s_Paint_ECF 1
#define s_Paint_Sel_Col 2
#define s_Paint_Show_Col 3
#define s_Paint_Show_Tool 4
#define s_Paint_Small 5
#define s_Paint_Edit_Pal 6
#define s_Paint_Adv_Opt 7
#define s_Paint_Extra_Click 8
/* Advanced options menu */
#define s_Adv_ExtraClick 1
#define s_Adv_HiBackCol 2
#define s_Adv_ArtFriend 3
#define s_Adv_AskRemapPal 4
#define s_Adv_ArtFriend 1
#define s_Adv_RemapPal 2
#define s_Adv_AskRemapPal 3
/* Edit menu */
#define s_Edit_FlipV 1
......
......@@ -138,7 +138,7 @@ typedef struct colour_panel
{
wimp_w handle;
struct main_window *window;
char size;
int size;
char state;
} colour_panel;
......@@ -221,7 +221,7 @@ typedef
struct {int mul, div;} zoom;
struct {BOOL show; int colour;} grid;
struct {BOOL on;} extended;
struct {BOOL extra_click_focus, highlight_bgcolour, artist_friendly, ask_remap_palette;} advanced;
struct {BOOL extra_click_focus, artist_friendly, remap_palette, ask_remap_palette;} advanced;
}
main_options;
......
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