Commit 9ecc8993 authored by ROOL's avatar ROOL 🤖

Colour handling enhancements

Detail:
  * Artist friendly colour ordering of 256 colour palette, and option to reorder pixel data for the remapped palette
  * Full 256 colour sprites can be created (as well as 64/16 entry VIDC compatible ones)
  * Colour indicator swatch in the bottom left corner of the sprite window
  * Adjust click on colours to paint with background colour
  * Shift-select as a shortcut to Paint > Select colour
  * Shift-adjust ditto for background colour
Admin:
  Submission for the Paint bounty.
parent eff0967c
...@@ -83,15 +83,14 @@ DFILES = \ ...@@ -83,15 +83,14 @@ DFILES = \
debug.${APP}.Sprites\ debug.${APP}.Sprites\
debug.${APP}.Templates debug.${APP}.Templates
OBJS = o.colours o.main o.menus o.psprite o.sprwindow o.tools o.toolwindow \ OBJS = o.colourpanel o.colours o.main o.menus o.psprite o.sprwindow o.tools o.toolwindow \
o.AltRename o.PaintLib o.CnPDrag o.Clipboard o.Drawfile o.AltRename o.PaintLib o.CnPDrag o.Clipboard o.Drawfile
OBJSZ = oz.colours oz.main oz.menus oz.psprite oz.sprwindow\ OBJSZ = oz.colourpanel oz.colours oz.main oz.menus oz.psprite oz.sprwindow\
oz.tools oz.toolwindow oz.AltRename oz.PaintLib oz.CnPDrag oz.Clipboard oz.Drawfile oz.tools oz.toolwindow oz.AltRename oz.PaintLib oz.CnPDrag oz.Clipboard oz.Drawfile
OBJSD = od.colours od.ftrace od.guard od.main od.menus\ OBJSD = od.colourpanel od.colours od.ftrace od.guard od.main od.menus\
od.psprite od.sprwindow od.tools od.toolwindow o.m\ od.psprite od.sprwindow od.tools od.toolwindow o.m\
od.AltRename od.PaintLib od.CnPDrag od.Clipboard od.Drawfile od.AltRename od.PaintLib od.CnPDrag od.Clipboard od.Drawfile
ASMS = s.colours s.main s.menus s.psprite s.sprwindow s.tools s.toolwindow ASMS = s.colourpanel s.colours s.main s.menus s.psprite s.sprwindow s.tools s.toolwindow
INCS = i.colours i.main i.menus i.psprite i.sprwindow i.tools i.toolwindow
# #
# Rule patterns # Rule patterns
......
No preview for this file type
...@@ -56,7 +56,7 @@ static void altrename_renamesprite (main_sprite *sprite, char *newname) ...@@ -56,7 +56,7 @@ static void altrename_renamesprite (main_sprite *sprite, char *newname)
/* rename must reset the titles of all the windows open on /* rename must reset the titles of all the windows open on
the sprite */ the sprite */
if (sprite->colourdialogue != NULL) if (sprite->colourdialogue != NULL)
{ char new_title [80]; { char new_title [128];
colourpicker_dialogue dialogue; colourpicker_dialogue dialogue;
dialogue.title = new_title; dialogue.title = new_title;
...@@ -88,6 +88,17 @@ static void altrename_renamesprite (main_sprite *sprite, char *newname) ...@@ -88,6 +88,17 @@ static void altrename_renamesprite (main_sprite *sprite, char *newname)
redraw_str.box.y0 = wstate.o.box.y1; redraw_str.box.y0 = wstate.o.box.y1;
wimpt_noerr (wimp_force_redraw (&redraw_str)); wimpt_noerr (wimp_force_redraw (&redraw_str));
} }
if (sprite->bgcolourdialogue != NULL)
{ char new_title [128];
colourpicker_dialogue dialogue;
dialogue.title = new_title;
sprintf (new_title, msgs_lookup ("PntWF"), newname);
ftracef0 ("ColourPicker_UpdateDialogue: setting new bgcolour title");
wimpt_complain (os_swix3 (ColourPicker_UpdateDialogue,
colourpicker_UPDATE_TITLE, sprite->bgcolourdialogue,
&dialogue));
}
} }
void altrename_delete (void) void altrename_delete (void)
......
This diff is collapsed.
This diff is collapsed.
...@@ -109,6 +109,7 @@ ...@@ -109,6 +109,7 @@
#include "ToolWindow.h" #include "ToolWindow.h"
#include "Tools.h" #include "Tools.h"
#include "Colours.h" #include "Colours.h"
#include "ColourPanel.h"
#include "AltRename.h" #include "AltRename.h"
#include "PaintLib.h" #include "PaintLib.h"
#include "CnPDrag.h" #include "CnPDrag.h"
...@@ -127,7 +128,7 @@ ...@@ -127,7 +128,7 @@
extern _kernel_ExtendProc flex_dont_budge; extern _kernel_ExtendProc flex_dont_budge;
#endif #endif
#define ICON_SPACE_SIZE 1200 /* For icons in the template */ #define ICON_SPACE_SIZE 1400 /* For icons in the template */
#define DISPLAY_MARGIN 0 #define DISPLAY_MARGIN 0
#define SPACE_FOR_HELP_TEXT (main_FILER_TextHeight+DISPLAY_MARGIN) #define SPACE_FOR_HELP_TEXT (main_FILER_TextHeight+DISPLAY_MARGIN)
...@@ -188,7 +189,9 @@ static ...@@ -188,7 +189,9 @@ static
{/*show tools?*/ TRUE}, {/*show tools?*/ TRUE},
{/*zoom*/ 1, 1}, {/*zoom*/ 1, 1},
{/*grid?*/ TRUE, /*colour*/ 7}, {/*grid?*/ TRUE, /*colour*/ 7},
{/*extended*/ TRUE /*always on in versions from Black onwards*/} {/*extended*/ TRUE /*always on in versions from Black onwards*/},
{/*h.lt. bgcolour?*/TRUE, /*art. friendly?*/TRUE,
/*ask remap pal?*/TRUE}
}; };
static static
...@@ -205,7 +208,7 @@ static ...@@ -205,7 +208,7 @@ static
/*timer*/ NULL /*timer*/ NULL
}; };
#define MAX_OPTIONS 80 #define MAX_OPTIONS 86
#if CATCH_SIGNALS #if CATCH_SIGNALS
static jmp_buf Buf; static jmp_buf Buf;
...@@ -1595,6 +1598,9 @@ int Load_File (main_window *window, char *filename, int merge, ...@@ -1595,6 +1598,9 @@ int Load_File (main_window *window, char *filename, int merge,
if (sprite->colourdialogue == 0) if (sprite->colourdialogue == 0)
colours_set_extent (sprite); /*was main_force_redraw colours_set_extent (sprite); /*was main_force_redraw
(sprite->colourhandle); JRC 4th Dec '89*/ (sprite->colourhandle); JRC 4th Dec '89*/
sprw = sprite->windows;
if (sprw != NULL)
colourpanel_redraw (sprw->window);
} }
ftracef0 ("Loaded file\n"); ftracef0 ("Loaded file\n");
...@@ -2601,6 +2607,8 @@ static void load_resources (void) ...@@ -2601,6 +2607,8 @@ static void load_resources (void)
load_template (&wt, "toolwind", &tools_tool_template.t); load_template (&wt, "toolwind", &tools_tool_template.t);
wt.work_free += 128; wt.work_free += 128;
load_template (&wt, "SpriteFile", &file_template.t); load_template (&wt, "SpriteFile", &file_template.t);
wt.work_free += 128;
load_template (&wt, "colourpanel", &colourpanel_template.t);
/*Use radioon, radiooff, opton, optoff from WIMP pool. JRC*/ /*Use radioon, radiooff, opton, optoff from WIMP pool. JRC*/
template_syshandle ("create")->spritearea = (void *) 1; template_syshandle ("create")->spritearea = (void *) 1;
...@@ -2859,6 +2867,16 @@ static char *write_options (void) ...@@ -2859,6 +2867,16 @@ static char *write_options (void)
if (memcmp (&opt->extended, &opt0->extended, sizeof opt->extended) != 0) if (memcmp (&opt->extended, &opt0->extended, sizeof opt->extended) != 0)
if (opt->extended.on) strcat (buffer, "X "); if (opt->extended.on) strcat (buffer, "X ");
if (memcmp (&opt->advanced, &opt0->advanced, sizeof opt->advanced) != 0)
{ char A [32];
sprintf (A, "A%c%c%c ",
opt->advanced.highlight_bgcolour? 'H': 'L',
opt->advanced.artist_friendly? 'F': 'U',
opt->advanced.ask_remap_palette? 'C': 'Q');
strcat (buffer, A);
}
if ((len = strlen (buffer)) > 0) if ((len = strlen (buffer)) > 0)
/*Overwrite the last space with '\0' for neatness*/ /*Overwrite the last space with '\0' for neatness*/
buffer [--len] = '\0'; buffer [--len] = '\0';
...@@ -3138,6 +3156,12 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -3138,6 +3156,12 @@ static void Background_Events (wimp_eventstr *e, void *handle)
if (sprite->colourhandle != 0 && sprite->colourdialogue == 0) if (sprite->colourhandle != 0 && sprite->colourdialogue == 0)
main_force_redraw (sprite->colourhandle); main_force_redraw (sprite->colourhandle);
if (sprite->bgcolourhandle != 0 && sprite->bgcolourdialogue == 0)
main_force_redraw (sprite->bgcolourhandle);
/*Redraw all colour panels.*/
colourpanel_redraw (window);
} }
for (window = main_windows; window != NULL; window = window->link) for (window = main_windows; window != NULL; window = window->link)
...@@ -3180,7 +3204,8 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -3180,7 +3204,8 @@ static void Background_Events (wimp_eventstr *e, void *handle)
window, if it's not just give generic 'This is paint' help */ window, if it's not just give generic 'This is paint' help */
for (window = main_windows; window != NULL; window = window->link) for (window = main_windows; window != NULL; window = window->link)
if (window->tag == main_window_is_sprite) if (window->tag == main_window_is_sprite)
{ if (window->data->sprite.sprite->colourhandle == e->data.msg.data.helprequest.m.w) { if (window->data->sprite.sprite->colourhandle == e->data.msg.data.helprequest.m.w ||
window->data->sprite.sprite->bgcolourhandle == e->data.msg.data.helprequest.m.w)
{ os_swix2 (ColourPicker_HelpReply, 0, &e->data); { os_swix2 (ColourPicker_HelpReply, 0, &e->data);
break; break;
} }
...@@ -3231,6 +3256,12 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -3231,6 +3256,12 @@ static void Background_Events (wimp_eventstr *e, void *handle)
sprite->colourhandle = 0; sprite->colourhandle = 0;
m_FREE (sprite->colourtitle, 23); m_FREE (sprite->colourtitle, 23);
} }
else if (sprite->bgcolourdialogue == d)
{ ftracef1 ("Found given picker %s\n", sprite->bgcolourtitle);
sprite->bgcolourdialogue = 0;
sprite->bgcolourhandle = 0;
m_FREE (sprite->bgcolourtitle, 34);
}
} }
os_swi2 (ColourPicker_CloseDialogue, 0, d); os_swi2 (ColourPicker_CloseDialogue, 0, d);
...@@ -3264,6 +3295,29 @@ static void Background_Events (wimp_eventstr *e, void *handle) ...@@ -3264,6 +3295,29 @@ static void Background_Events (wimp_eventstr *e, void *handle)
ftracef2 ("rgb is 0x%X => colour number 0x%X\n", ftracef2 ("rgb is 0x%X => colour number 0x%X\n",
e->data.msg.data.words [2], sprite->gcol.colour); e->data.msg.data.words [2], sprite->gcol.colour);
} }
/*Now redraw all colour panels*/
if (sprite->windows != NULL && sprite->windows->window != NULL)
colourpanel_redraw (sprite->windows->window);
}
else if (sprite->bgcolourdialogue == d)
{ ftracef1 ("Found given bg picker %s\n", sprite->bgcolourtitle);
if ((e->data.msg.data.words [1] &
colourpicker_COLOUR_TRANSPARENT) != 0)
sprite->gcol2.alpha = 0;
else
{
sprite_colour col;
os_swi3r (ColourTrans_ReturnColourNumberForMode,
e->data.msg.data.words [2],
psprite_address (sprite)->mode, 0,
&col.colour, NULL, NULL);
sprite->gcol2 = colours_unpack_colour(sprite, col);
ftracef2 ("rgb is 0x%X => colour number 0x%X\n",
e->data.msg.data.words [2], sprite->gcol2.colour);
}
/*Now redraw all colour panels*/
if (sprite->windows != NULL && sprite->windows->window != NULL)
colourpanel_redraw (sprite->windows->window);
} }
} }
} }
...@@ -3376,6 +3430,21 @@ static void read_options (void) ...@@ -3376,6 +3430,21 @@ static void read_options (void)
case 'X': /* X? */ case 'X': /* X? */
opt->extended.on = TRUE; opt->extended.on = TRUE;
break; break;
case 'A': /* A(H|L)?(F|U)?(C|Q)? */
{ char *cc;
for (cc = &token [1]; *cc != '\0'; cc++)
switch (toupper (*cc))
{ 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 'C': opt->advanced.ask_remap_palette = TRUE; break;
case 'Q': opt->advanced.ask_remap_palette = FALSE; break;
}
}
break;
} }
} }
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -38,11 +38,13 @@ ...@@ -38,11 +38,13 @@
#include "m.h" #include "m.h"
#include "main.h" #include "main.h"
#include "Menus.h" #include "Menus.h"
#include "MenuD.h"
#include "PSprite.h" #include "PSprite.h"
#include "SprWindow.h" #include "SprWindow.h"
#include "ToolWindow.h" #include "ToolWindow.h"
#include "Tools.h" #include "Tools.h"
#include "Colours.h" #include "Colours.h"
#include "ColourPanel.h"
#include "PaintLib.h" #include "PaintLib.h"
/************************************************************************** /**************************************************************************
...@@ -69,12 +71,24 @@ static int scrolltime = 0; ...@@ -69,12 +71,24 @@ static int scrolltime = 0;
void sprwindow_set_work_extent (main_window *window, BOOL open) void sprwindow_set_work_extent (main_window *window, BOOL open)
{ /* The open parameter avoid getting two open requests in some circumstances */
sprwindow_set_work_extent_custom (window, open, -1, -1);
}
/********************************************************
* *
* Set the extent of a file window to a custom size. *
* *
********************************************************/
void sprwindow_set_work_extent_custom (main_window *window, BOOL open, int minwidth, int minheight)
{ /* The open parameter avoid getting two open requests in some circumstances */ { /* The open parameter avoid getting two open requests in some circumstances */
wimp_wstate currinfo; wimp_wstate currinfo;
wimp_redrawstr newext; wimp_redrawstr newext;
sprite_info sinfo; sprite_info sinfo;
ftracef0 ("sprwindow_set_work_extent\n"); ftracef0 ("sprwindow_set_work_extent_custom\n");
wimpt_noerr (wimp_get_wind_state (window->handle, &currinfo)); wimpt_noerr (wimp_get_wind_state (window->handle, &currinfo));
psprite_read_size (window->data->sprite.sprite, &sinfo); psprite_read_size (window->data->sprite.sprite, &sinfo);
...@@ -85,6 +99,11 @@ void sprwindow_set_work_extent (main_window *window, BOOL open) ...@@ -85,6 +99,11 @@ void sprwindow_set_work_extent (main_window *window, BOOL open)
sinfo.height= sinfo.height * window->data->sprite.blobsize.scale_ymul / sinfo.height= sinfo.height * window->data->sprite.blobsize.scale_ymul /
window->data->sprite.blobsize.scale_ydiv; window->data->sprite.blobsize.scale_ydiv;
if (sinfo.width < minwidth)
sinfo.width = minwidth;
if (sinfo.height < minheight)
sinfo.height = minheight;
sinfo.width &= ~((1 << bbc_modevar (-1, bbc_XEigFactor)) - 1); sinfo.width &= ~((1 << bbc_modevar (-1, bbc_XEigFactor)) - 1);
sinfo.height &= ~((1 << bbc_modevar (-1, bbc_YEigFactor)) - 1); sinfo.height &= ~((1 << bbc_modevar (-1, bbc_YEigFactor)) - 1);
...@@ -167,6 +186,7 @@ void sprwindow_scroll (main_window *window, int scrollx, int scrolly) ...@@ -167,6 +186,7 @@ void sprwindow_scroll (main_window *window, int scrollx, int scrolly)
***********************************************************/ ***********************************************************/
void sprwindow_stop_scroll (void) void sprwindow_stop_scroll (void)
{ scrolltime = 0; { scrolltime = 0;
} }
...@@ -321,14 +341,12 @@ void sprwindow_redisplay (main_sprite *sprite, wimp_box *area) ...@@ -321,14 +341,12 @@ void sprwindow_redisplay (main_sprite *sprite, wimp_box *area)
int w, h, iconwidth, iconheight; int w, h, iconwidth, iconheight;
if (sprite->file->fullinfo) if (sprite->file->fullinfo)
{ { w = main_FILER_FullInfoWidth;
w = main_FILER_FullInfoWidth;
h = main_FILER_FullInfoHeight; h = main_FILER_FullInfoHeight;
iconwidth = iconheight = 3*main_FILER_TextHeight-main_FILER_Border; iconwidth = iconheight = 3*main_FILER_TextHeight-main_FILER_Border;
} }
else else
{ { w = main_FILER_TotalWidth;
w = main_FILER_TotalWidth;
h = main_FILER_TotalHeight; h = main_FILER_TotalHeight;
iconwidth = main_FILER_XSize; iconwidth = main_FILER_XSize;
iconheight = main_FILER_YSize; iconheight = main_FILER_YSize;
...@@ -451,10 +469,10 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle) ...@@ -451,10 +469,10 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle)
switch (e->e) switch (e->e)
{ case wimp_ENULL: { case wimp_ENULL:
if (!read_only) if (!read_only)
{ wimp_mousestr mouse; { main_sprite *sprite;
main_sprite *sprite = window->data->sprite.sprite; wimp_mousestr mouse;
wimpt_noerr (wimp_get_point_info (&mouse)); wimpt_noerr (wimp_get_point_info (&mouse));
sprite = window->data->sprite.sprite;
ftracef2 ("mouse located at w 0x%X, i 0x%X\n", mouse.w, mouse.i); ftracef2 ("mouse located at w 0x%X, i 0x%X\n", mouse.w, mouse.i);
if (mouse.w == window->handle && mouse.i == -1 && sprite->needsnull) if (mouse.w == window->handle && mouse.i == -1 && sprite->needsnull)
...@@ -463,7 +481,71 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle) ...@@ -463,7 +481,71 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle)
break; break;
case wimp_EOPEN: case wimp_EOPEN:
/*Make sure the window will not be too narrow to fit the colour *
* panel without squashing buttons. */
if (e->data.o.box.x1 - e->data.o.box.x0 <
window->data->sprite.minwidth)
{ e->data.o.box.x1 = e->data.o.box.x0 + window->data->sprite.minwidth;
}
wimpt_complain (wimp_open_wind (&e->data.o)); wimpt_complain (wimp_open_wind (&e->data.o));
/* Handle the colour panel in case the dimensions changed */
if (window->data->sprite.colourpanel != NULL)
{ int x_eig, y_eig, max_eig;
int colpanelwidth, colpanelheight, coloursize;
wimp_wstate sprite_w_state;
wimp_redrawstr sprite_redraw_str;
wimp_openstr colpanel_openstr;
wimp_redrawstr colpanel_redraw_str;
int linkage = 0x5550000;
x_eig = bbc_vduvar (bbc_XEigFactor);
y_eig = bbc_vduvar (bbc_YEigFactor);
if (x_eig > y_eig) max_eig = x_eig; else max_eig = y_eig;
colpanelheight = get_horizontal_scrollbar_height (window->handle);
ftracef2 ("Updated colour panel height: %d due to wimp_EOPEN Old height: %d\n",
colpanelheight, window->data->sprite.colourpanel->size);
window->data->sprite.colourpanel->size = colpanelheight;
coloursize = colpanelheight - (4 << y_eig);
/*Round DOWN to nearest whole number of pixels*/
coloursize = (coloursize >> max_eig) << max_eig;
colpanelwidth = coloursize * 2 + (4 << x_eig );
/* We will prevent the user from making the window narrow enough to
squash the buttons. With the colour panel present, this is possible
for very short sprite names */
window->data->sprite.minwidth =
(char)(get_horizontal_arrows_width (window->handle) +
colpanelwidth + (14 << x_eig));
/*Get the new state of the sprite window*/
wimpt_noerr (wimp_get_wind_state (window->handle,
&sprite_w_state));
/*And its outline*/
sprite_redraw_str.w = window->handle;
wimpt_noerr (wimp_getwindowoutline (&sprite_redraw_str));
colpanel_openstr.w = window->data->sprite.colourpanel->handle;
colpanel_openstr.behind = -1;
colpanel_openstr.x = 0;
colpanel_openstr.y = 0;
colpanel_openstr.box.x0 = sprite_redraw_str.box.x0;
colpanel_openstr.box.y1 = sprite_w_state.o.box.y0 - 2;
colpanel_openstr.box.x1 = colpanel_openstr.box.x0 + colpanelwidth;
colpanel_openstr.box.y0 = colpanel_openstr.box.y1 - colpanelheight + 4;
colpanel_redraw_str.w = colpanel_openstr.w;
colpanel_redraw_str.box.y1 = 0;
colpanel_redraw_str.box.y0 = -colpanelheight + 4;
colpanel_redraw_str.box.x0 = 0;
colpanel_redraw_str.box.x1 = colpanelwidth;
wimpt_complain (wimp_set_extent (&colpanel_redraw_str));
wimpt_complain (os_swix5 (Wimp_OpenWindow, 0, &colpanel_openstr, *(int*)"TASK", window->handle, linkage));
wimpt_noerr (wimp_force_redraw (&colpanel_redraw_str));
}
break; break;
case wimp_EREDRAW: case wimp_EREDRAW:
...@@ -577,6 +659,26 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle) ...@@ -577,6 +659,26 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle)
break; break;
case wimp_EBUT: case wimp_EBUT:
if ((e->data.but.m.bbits & 0x001) || (e->data.but.m.bbits & 0x004) ||
(e->data.but.m.bbits & (wimp_BDRAGLEFT | wimp_BDRAGRIGHT)))
{ /* Read keyboard state to detect Shift+click. */
int r1 = 0;
int r2 = 255;
os_byte (OsByte_RW_KeybStatus, &r1, &r2);
/* If Shift is pressed... */
if (r1 & 8)
{ if (e->data.but.m.bbits & 0x004)
{ /* Shift+Select click selects as foreground colour */
menus_select_colour (window, FALSE, TRUE);
break;
}
else if (e->data.but.m.bbits & 0x001)
{ /* Shift+Adjust click selects as background colour */
menus_select_colour (window, TRUE, TRUE);
break;
}
}
}
if (!read_only) if (!read_only)
toolwindow_current_tool->click_action (window, &e->data.but.m); toolwindow_current_tool->click_action (window, &e->data.but.m);
break; break;
...@@ -661,7 +763,7 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle) ...@@ -661,7 +763,7 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle)
if (eventCount >=5) if (eventCount >=5)
eventCount = 0; eventCount = 0;
} }
break; break;
case wimp_ECLOSE: case wimp_ECLOSE:
ftracef0 ("Window close event\n"); ftracef0 ("Window close event\n");
...@@ -841,6 +943,9 @@ void sprwindow_delete (main_window *window) ...@@ -841,6 +943,9 @@ void sprwindow_delete (main_window *window)
sprwindow_set_window_titles (us->sprite); /*there might not be any*/ sprwindow_set_window_titles (us->sprite); /*there might not be any*/
if (us->colourpanel != NULL)
m_FREE (us->colourpanel, sizeof (colour_panel));
main_window_delete (window); main_window_delete (window);
} }
...@@ -883,7 +988,9 @@ void sprwindow_new (main_sprite *sprite) ...@@ -883,7 +988,9 @@ void sprwindow_new (main_sprite *sprite)
main_allocate_position (&wind.box); main_allocate_position (&wind.box);
wind.colours [wimp_WCWKAREABACK] = '\377'; wind.colours [wimp_WCWKAREABACK] = '\377';
wind.titleflags = (wimp_iconflags) (wind.titleflags | wimp_INDIRECT); wind.titleflags = (wimp_iconflags) (wind.titleflags | wimp_INDIRECT);
wind.flags = (wimp_wflags) (wind.flags | wimp_WSCROLL_R1); /* Enable scroll requests for mouse wheel */ /*Enable scroll requests for mouse wheel.
C000 enables ignore window extent when adjust size (for ctrl + zoom)*/
wind.flags = (wimp_wflags) (wind.flags | wimp_WSCROLL_R1 | 0x00000C000 );
if ((wind.title.indirecttext.buffer = m_ALLOC (20)) == NULL) if ((wind.title.indirecttext.buffer = m_ALLOC (20)) == NULL)
{ m_FREE (sprite_window, sizeof (main_sprite_window)); { m_FREE (sprite_window, sizeof (main_sprite_window));
...@@ -911,6 +1018,7 @@ void sprwindow_new (main_sprite *sprite) ...@@ -911,6 +1018,7 @@ void sprwindow_new (main_sprite *sprite)
sprite_window->blobsize.scale_ymul = main_current_options.zoom.mul; sprite_window->blobsize.scale_ymul = main_current_options.zoom.mul;
sprite_window->blobsize.scale_xdiv = sprite_window->blobsize.scale_xdiv =
sprite_window->blobsize.scale_ydiv = main_current_options.zoom.div; sprite_window->blobsize.scale_ydiv = main_current_options.zoom.div;
sprite_window->minwidth = 0; /*Will be updated in colourpanel_new()*/
sprite_window->gridcol = main_current_options.grid.show? sprite_window->gridcol = main_current_options.grid.show?
main_current_options.grid.colour: 255; main_current_options.grid.colour: 255;
sprite_window->read_only = !main_current_options.extended.on && sprite_window->read_only = !main_current_options.extended.on &&
...@@ -940,7 +1048,16 @@ void sprwindow_new (main_sprite *sprite) ...@@ -940,7 +1048,16 @@ void sprwindow_new (main_sprite *sprite)
main_check_position (window); main_check_position (window);
if (main_current_options.colours.show_colours && !sprite_window->read_only) if (main_current_options.colours.show_colours && !sprite_window->read_only)
colours_create_window (sprite); colours_create_window (sprite, FALSE);
/*Create fore/background colour selection panel at bottom of window RO 3.8+*/
sprite_window->colourpanel = colourpanel_new (sprite_window);
/*For a small or zoomed-out sprite, it's possible the window was already
opened too narrow to fit the colour panel without squashing buttons.
If so, we have to reopen it.*/
if (open_str.box.x1 - open_str.box.x0 < sprite_window->minwidth)
menus_showmag (sprite_window);
/*Fix MED-xxxx: brush translation tables are only maintained for open /*Fix MED-xxxx: brush translation tables are only maintained for open
windows, so create one now if necessary. J R C 26th Jul 1994*/ windows, so create one now if necessary. J R C 26th Jul 1994*/
......
...@@ -1096,6 +1096,7 @@ static void rectangleoutlinepaint_redraw (main_window *window, ...@@ -1096,6 +1096,7 @@ static void rectangleoutlinepaint_redraw (main_window *window,
{ main_sprite *sprite = window->data->sprite.sprite; { main_sprite *sprite = window->data->sprite.sprite;
ftracef0 ("rectangleoutlinepaint_redraw\n"); ftracef0 ("rectangleoutlinepaint_redraw\n");
ftracef3 ("sprite is %d toolspace [0] is %d needsnull is %d\n", sprite, sprite->toolspace[0], sprite->needsnull);
if (sprite->needsnull) if (sprite->needsnull)
rectangle_drawEOR(&window->data->sprite,&sprite->toolspace [2], x0, y0); rectangle_drawEOR(&window->data->sprite,&sprite->toolspace [2], x0, y0);
} }
...@@ -2442,6 +2443,7 @@ static void brushpaint_splot (main_window *window, wimp_mousestr *mpos) ...@@ -2442,6 +2443,7 @@ static void brushpaint_splot (main_window *window, wimp_mousestr *mpos)
{ int x, y; { int x, y;
main_sprite *sprite = window->data->sprite.sprite; main_sprite *sprite = window->data->sprite.sprite;
tools_mouse_to_pixel (window, mpos, &x, &y); tools_mouse_to_pixel (window, mpos, &x, &y);
main_colour gcol = mpos->bbits == wimp_BRIGHT ? sprite->gcol2 : sprite->gcol;
ftracef0 ("brushpaint_splot\n"); ftracef0 ("brushpaint_splot\n");
...@@ -2482,8 +2484,7 @@ static void brushpaint_splot (main_window *window, wimp_mousestr *mpos) ...@@ -2482,8 +2484,7 @@ static void brushpaint_splot (main_window *window, wimp_mousestr *mpos)
sprwindow_swap_output_to_sprite (sprite); sprwindow_swap_output_to_sprite (sprite);
if (tools_brush_use_gcol) if (tools_brush_use_gcol)
{ colours_set_sprite_gcol (mpos->bbits & wimp_BRIGHT? sprite->gcol2: { colours_set_sprite_gcol (gcol, sprite, 1);
sprite->gcol, sprite, 1);
psprite_plot_scaled_m (x, y, tools_brushsprite_ptr, psprite_plot_scaled_m (x, y, tools_brushsprite_ptr,
&tools_brushscale, toolwindow_current_mode, 1); &tools_brushscale, toolwindow_current_mode, 1);
} }
...@@ -2493,7 +2494,7 @@ static void brushpaint_splot (main_window *window, wimp_mousestr *mpos) ...@@ -2493,7 +2494,7 @@ static void brushpaint_splot (main_window *window, wimp_mousestr *mpos)
if (sprwindow_swap_output_to_mask (sprite, 1)) if (sprwindow_swap_output_to_mask (sprite, 1))
{ BOOL c = tools_brush_use_gcol && { BOOL c = tools_brush_use_gcol &&
!sprite->gcol.alpha; !gcol.alpha;
os_swi2 (OS_SetColour, c? 0: 1 << 4, c? 0: -1); os_swi2 (OS_SetColour, c? 0: 1 << 4, c? 0: -1);
#if 0 #if 0
......
/* Copyright 2019 RISC OS Open Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef colourpanel_H
#define colourpanel_H
/* > colourpanel.h
*/
extern main_template colourpanel_template;
extern int get_horizontal_scrollbar_height (wimp_w);
extern int get_horizontal_arrows_width (wimp_w);
extern void colourpanel_redraw (main_window *);
extern void colourpanel_event_handler (wimp_eventstr *e, void *handle);
extern colour_panel *colourpanel_new (main_sprite_window *);
#endif
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
extern void colours_delete_window (main_sprite *); extern void colours_delete_window (main_sprite *);
extern void colours_create_window (main_sprite *); extern void colours_create_window (main_sprite *, BOOL);
extern void colours_set_gcol (int, int, int); extern void colours_set_gcol (int, int, int);
...@@ -28,6 +28,16 @@ extern void colours_set_sprite_gcol (main_colour, main_sprite *, int); ...@@ -28,6 +28,16 @@ extern void colours_set_sprite_gcol (main_colour, main_sprite *, int);
extern int colours_count (main_sprite *); extern int colours_count (main_sprite *);
extern BOOL colours_is_artist_friendly (main_sprite *sprite);
extern int colours_get_artist_friendly_colour (int index, main_sprite *sprite);
extern int colours_get_artist_friendly_index (int colour, main_sprite *sprite);
extern void colours_remap_to_artist_friendly (main_sprite *sprite);
extern BOOL colours_try_remap_from_artist_friendly (main_sprite *sprite);
extern void colours_event_handler (wimp_eventstr *, void *); extern void colours_event_handler (wimp_eventstr *, void *);
extern void colours_set_extent (main_sprite *); extern void colours_set_extent (main_sprite *);
......
...@@ -79,6 +79,12 @@ ...@@ -79,6 +79,12 @@
#define s_Paint_Show_Tool 4 #define s_Paint_Show_Tool 4
#define s_Paint_Small 5 #define s_Paint_Small 5
#define s_Paint_Edit_Pal 6 #define s_Paint_Edit_Pal 6
#define s_Paint_Adv_Opt 7
/* Advanced options menu */
#define s_Adv_HiBackCol 1
#define s_Adv_ArtFriend 2
#define s_Adv_AskRemapPal 3
/* Edit menu */ /* Edit menu */
#define s_Edit_FlipV 1 #define s_Edit_FlipV 1
...@@ -161,35 +167,30 @@ ...@@ -161,35 +167,30 @@
#define d_File_Size 3 #define d_File_Size 3
/* Create sprite */ /* Create sprite */
#define d_Create_Name 29 #define d_Create_Name 20
#define d_Create_Mask 15 #define d_Create_Mask 6