Commit 18f461a5 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.

Version 2.26. Tagged as 'Paint-2_26'
parent eff0967c
......@@ -83,15 +83,14 @@ DFILES = \
debug.${APP}.Sprites\
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
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
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.AltRename od.PaintLib od.CnPDrag od.Clipboard od.Drawfile
ASMS = 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
ASMS = s.colourpanel s.colours s.main s.menus s.psprite s.sprwindow s.tools s.toolwindow
#
# Rule patterns
......
No preview for this file type
......@@ -9,12 +9,12 @@
GBLS Module_ApplicationDate
GBLS Module_HelpVersion
GBLS Module_ComponentName
Module_MajorVersion SETS "2.25"
Module_Version SETA 225
Module_MajorVersion SETS "2.26"
Module_Version SETA 226
Module_MinorVersion SETS ""
Module_Date SETS "17 Aug 2019"
Module_ApplicationDate SETS "17-Aug-19"
Module_Date SETS "25 Aug 2019"
Module_ApplicationDate SETS "25-Aug-19"
Module_ComponentName SETS "Paint"
Module_FullVersion SETS "2.25"
Module_HelpVersion SETS "2.25 (17 Aug 2019)"
Module_FullVersion SETS "2.26"
Module_HelpVersion SETS "2.26 (25 Aug 2019)"
END
/* (2.25)
/* (2.26)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 2.25
#define Module_MajorVersion_CMHG 2.26
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 17 Aug 2019
#define Module_Date_CMHG 25 Aug 2019
#define Module_MajorVersion "2.25"
#define Module_Version 225
#define Module_MajorVersion "2.26"
#define Module_Version 226
#define Module_MinorVersion ""
#define Module_Date "17 Aug 2019"
#define Module_Date "25 Aug 2019"
#define Module_ApplicationDate "17-Aug-19"
#define Module_ApplicationDate "25-Aug-19"
#define Module_ComponentName "Paint"
#define Module_FullVersion "2.25"
#define Module_HelpVersion "2.25 (17 Aug 2019)"
#define Module_LibraryVersionInfo "2:25"
#define Module_FullVersion "2.26"
#define Module_HelpVersion "2.26 (25 Aug 2019)"
#define Module_LibraryVersionInfo "2:26"
......@@ -56,7 +56,7 @@ static void altrename_renamesprite (main_sprite *sprite, char *newname)
/* rename must reset the titles of all the windows open on
the sprite */
if (sprite->colourdialogue != NULL)
{ char new_title [80];
{ char new_title [128];
colourpicker_dialogue dialogue;
dialogue.title = new_title;
......@@ -88,6 +88,17 @@ static void altrename_renamesprite (main_sprite *sprite, char *newname)
redraw_str.box.y0 = wstate.o.box.y1;
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)
......
This diff is collapsed.
This diff is collapsed.
......@@ -109,6 +109,7 @@
#include "ToolWindow.h"
#include "Tools.h"
#include "Colours.h"
#include "ColourPanel.h"
#include "AltRename.h"
#include "PaintLib.h"
#include "CnPDrag.h"
......@@ -127,7 +128,7 @@
extern _kernel_ExtendProc flex_dont_budge;
#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 SPACE_FOR_HELP_TEXT (main_FILER_TextHeight+DISPLAY_MARGIN)
......@@ -188,7 +189,9 @@ static
{/*show tools?*/ TRUE},
{/*zoom*/ 1, 1},
{/*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
......@@ -205,7 +208,7 @@ static
/*timer*/ NULL
};
#define MAX_OPTIONS 80
#define MAX_OPTIONS 86
#if CATCH_SIGNALS
static jmp_buf Buf;
......@@ -1595,6 +1598,9 @@ int Load_File (main_window *window, char *filename, int merge,
if (sprite->colourdialogue == 0)
colours_set_extent (sprite); /*was main_force_redraw
(sprite->colourhandle); JRC 4th Dec '89*/
sprw = sprite->windows;
if (sprw != NULL)
colourpanel_redraw (sprw->window);
}
ftracef0 ("Loaded file\n");
......@@ -2601,6 +2607,8 @@ static void load_resources (void)
load_template (&wt, "toolwind", &tools_tool_template.t);
wt.work_free += 128;
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*/
template_syshandle ("create")->spritearea = (void *) 1;
......@@ -2859,6 +2867,16 @@ static char *write_options (void)
if (memcmp (&opt->extended, &opt0->extended, sizeof opt->extended) != 0)
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)
/*Overwrite the last space with '\0' for neatness*/
buffer [--len] = '\0';
......@@ -3138,6 +3156,12 @@ static void Background_Events (wimp_eventstr *e, void *handle)
if (sprite->colourhandle != 0 && sprite->colourdialogue == 0)
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)
......@@ -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 */
for (window = main_windows; window != NULL; window = window->link)
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);
break;
}
......@@ -3231,6 +3256,12 @@ static void Background_Events (wimp_eventstr *e, void *handle)
sprite->colourhandle = 0;
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);
......@@ -3264,6 +3295,29 @@ static void Background_Events (wimp_eventstr *e, void *handle)
ftracef2 ("rgb is 0x%X => colour number 0x%X\n",
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)
case 'X': /* X? */
opt->extended.on = TRUE;
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 @@
#include "m.h"
#include "main.h"
#include "Menus.h"
#include "MenuD.h"
#include "PSprite.h"
#include "SprWindow.h"
#include "ToolWindow.h"
#include "Tools.h"
#include "Colours.h"
#include "ColourPanel.h"
#include "PaintLib.h"
/**************************************************************************
......@@ -69,12 +71,24 @@ static int scrolltime = 0;
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 */
wimp_wstate currinfo;
wimp_redrawstr newext;
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));
psprite_read_size (window->data->sprite.sprite, &sinfo);
......@@ -85,6 +99,11 @@ void sprwindow_set_work_extent (main_window *window, BOOL open)
sinfo.height= sinfo.height * window->data->sprite.blobsize.scale_ymul /
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.height &= ~((1 << bbc_modevar (-1, bbc_YEigFactor)) - 1);
......@@ -167,6 +186,7 @@ void sprwindow_scroll (main_window *window, int scrollx, int scrolly)
***********************************************************/
void sprwindow_stop_scroll (void)
{ scrolltime = 0;
}
......@@ -321,14 +341,12 @@ void sprwindow_redisplay (main_sprite *sprite, wimp_box *area)
int w, h, iconwidth, iconheight;
if (sprite->file->fullinfo)
{
w = main_FILER_FullInfoWidth;
{ w = main_FILER_FullInfoWidth;
h = main_FILER_FullInfoHeight;
iconwidth = iconheight = 3*main_FILER_TextHeight-main_FILER_Border;
}
else
{
w = main_FILER_TotalWidth;
{ w = main_FILER_TotalWidth;
h = main_FILER_TotalHeight;
iconwidth = main_FILER_XSize;
iconheight = main_FILER_YSize;
......@@ -451,10 +469,10 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle)
switch (e->e)
{ case wimp_ENULL:
if (!read_only)
{ wimp_mousestr mouse;
main_sprite *sprite = window->data->sprite.sprite;
{ main_sprite *sprite;
wimp_mousestr 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);
if (mouse.w == window->handle && mouse.i == -1 && sprite->needsnull)
......@@ -463,7 +481,71 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle)
break;
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));
/* 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;
case wimp_EREDRAW:
......@@ -577,6 +659,26 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle)
break;
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)
toolwindow_current_tool->click_action (window, &e->data.but.m);
break;
......@@ -661,7 +763,7 @@ void sprwindow_event_handler (wimp_eventstr *e, void *handle)
if (eventCount >=5)
eventCount = 0;
}
break;
break;
case wimp_ECLOSE:
ftracef0 ("Window close event\n");
......@@ -841,6 +943,9 @@ void sprwindow_delete (main_window *window)
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);
}
......@@ -883,7 +988,9 @@ void sprwindow_new (main_sprite *sprite)
main_allocate_position (&wind.box);
wind.colours [wimp_WCWKAREABACK] = '\377';
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)
{ m_FREE (sprite_window, sizeof (main_sprite_window));
......@@ -911,6 +1018,7 @@ void sprwindow_new (main_sprite *sprite)
sprite_window->blobsize.scale_ymul = main_current_options.zoom.mul;
sprite_window->blobsize.scale_xdiv =
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?
main_current_options.grid.colour: 255;
sprite_window->read_only = !main_current_options.extended.on &&
......@@ -940,7 +1048,16 @@ void sprwindow_new (main_sprite *sprite)
main_check_position (window);
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
windows, so create one now if necessary. J R C 26th Jul 1994*/
......
......@@ -1096,6 +1096,7 @@ static void rectangleoutlinepaint_redraw (main_window *window,
{ main_sprite *sprite = window->data->sprite.sprite;
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)
rectangle_drawEOR(&window->data->sprite,&sprite->toolspace [2], x0, y0);
}
......@@ -2442,6 +2443,7 @@ static void brushpaint_splot (main_window *window, wimp_mousestr *mpos)
{ int x, y;
main_sprite *sprite = window->data->sprite.sprite;
tools_mouse_to_pixel (window, mpos, &x, &y);
main_colour gcol = mpos->bbits == wimp_BRIGHT ? sprite->gcol2 : sprite->gcol;
ftracef0 ("brushpaint_splot\n");
......@@ -2482,8 +2484,7 @@ static void brushpaint_splot (main_window *window, wimp_mousestr *mpos)
sprwindow_swap_output_to_sprite (sprite);
if (tools_brush_use_gcol)
{ colours_set_sprite_gcol (mpos->bbits & wimp_BRIGHT? sprite->gcol2:
sprite->gcol, sprite, 1);
{ colours_set_sprite_gcol (gcol, sprite, 1);
psprite_plot_scaled_m (x, y, tools_brushsprite_ptr,
&tools_brushscale, toolwindow_current_mode, 1);
}
......@@ -2493,7 +2494,7 @@ static void brushpaint_splot (main_window *window, wimp_mousestr *mpos)
if (sprwindow_swap_output_to_mask (sprite, 1))
{ BOOL c = tools_brush_use_gcol &&
!sprite->gcol.alpha;
!gcol.alpha;
os_swi2 (OS_SetColour, c? 0: 1 << 4, c? 0: -1);
#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 @@
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);
......@@ -28,6 +28,16 @@ extern void colours_set_sprite_gcol (main_colour, main_sprite *, int);
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_set_extent (main_sprite *);
......
......@@ -79,6 +79,12 @@
#define s_Paint_Show_Tool 4
#define s_Paint_Small 5
#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 */
#define s_Edit_FlipV 1
......@@ -161,35 +167,30 @@
#define d_File_Size 3
/* Create sprite */
#define d_Create_Name 29
#define d_Create_Mask 15
#define d_Create_Width 26
#define d_Create_XEIG_2 19
#define d_Create_XEIG_1 20
#define d_Create_XEIG_0 21
#define d_Create_Height 31
#define d_Create_YEIG_2 22
#define d_Create_YEIG_1 23
#define d_Create_YEIG_0 24
#define d_Create_Palette_Colour 1
#define d_Create_Palette_Mono 2
#define d_Create_Palette_None 3
#define d_Create_Colours_2 8
#define d_Create_Colours_4 9
#define d_Create_Colours_16 10
#define d_Create_Colours_256 11
#define d_Create_Colours_4k 33
#define d_Create_Colours_32k 12
#define d_Create_Colours_64k 32
#define d_Create_Colours_16M 13
#define d_Create_Mode_LabelL 6
#define d_Create_Mode 30
#define d_Create_Mode_LabelR 27
#define d_Create_Up 16
#define d_Create_Down 7
#define d_Create_Left 18
#define d_Create_Right 25
#define d_Create_Cancel 28
#define d_Create_Name 20
#define d_Create_Mask 6
#define d_Create_Width 17
#define d_Create_XEIG_2 10
#define d_Create_XEIG_1 11
#define d_Create_XEIG_0 12
#define d_Create_Height 22
#define d_Create_YEIG_2 13
#define d_Create_YEIG_1 14
#define d_Create_YEIG_0 15
#define d_Create_Palette 27
#define d_Create_Palette_Button 26
#define d_Create_Palette_Label 28
#define d_Create_Colours 24
#define d_Create_Colours_Button 23
#define d_Create_Colours_Label 25
#define d_Create_Mode_LabelL 3
#define d_Create_Mode 21
#define d_Create_Mode_LabelR 18
#define d_Create_Up 7
#define d_Create_Down 4
#define d_Create_Left 9
#define d_Create_Right 16
#define d_Create_Cancel 19
#define d_Create_Ok 0
/* snapshot control */
......
......@@ -33,6 +33,8 @@ extern void menus_file_handler (void *, char *);
extern void menus_sprite_handler (void *, char *);
extern void menus_select_colour (main_window *, BOOL, BOOL);
extern menu menus_file_maker (void *);
extern menu menus_sprite_maker (void *);
......
......@@ -98,6 +98,8 @@ extern void psprite_set_ecf (main_sprite *, int, int);
extern os_error *psprite_plot_ecf_sprite (main_sprite *, int, int, int);
extern os_error *psprite_plot_ecf_sprite_sized (main_sprite *, int, int, int, int);
extern BOOL psprite_merge_area (main_window *, main_file *, sprite_area **);
extern void psprite_rotate (main_sprite *, int);
......@@ -134,4 +136,25 @@ typedef enum
extern transparency_type psprite_transparency_type(main_sprite *spr);
typedef enum
{
palette_type_none,
palette_type_colour,
palette_type_greyscale,
palette_type_64fixed,
palette_type_16fixed
} palette_type;
/*-- dummy menu structure --*/
typedef struct main__menu_str
{
wimp_menuhdr *m;
int nitems;
void *entryspace;
int nbytes;
int maxentrywidth;
} main__menu_str;
#endif
......@@ -25,7 +25,8 @@ extern main_template sprwindow_template;
extern void sprwindow_new (main_sprite *);
extern void sprwindow_delete (main_window *);
extern void sprwindow_set_work_extent(main_window *, BOOL);
extern void sprwindow_scroll (main_window *window, int scrollx, int scrolly);
extern void sprwindow_set_work_extent_custom (main_window *, BOOL, int, int);
extern void sprwindow_scroll (main_window *, int, int);
extern void sprwindow_stop_scroll (void);
extern void sprwindow_swap_output_to_sprite (main_sprite *);
extern void sprwindow_remove_wastage (main_sprite *);
......@@ -37,6 +38,8 @@ extern void sprwindow_claim_idle_events (main_window *);
extern void sprwindow_release_idle_events (main_sprite *);
extern void sprwindow_event_handler (wimp_eventstr *, void *);
extern void sprwindow_set_window_titles (main_sprite *);
extern void colourpanel_redraw (main_window *);
extern void colourpanel_event_handler (wimp_eventstr *, void *);
#define sprwindow_MIN_GRID 4
......
......@@ -95,6 +95,8 @@ typedef struct main_sprite_window
struct main_sprite *sprite;
char *title;
main_scaling_block blobsize;
struct colour_panel *colourpanel;
char minwidth;
char gridcol;
BOOL read_only;
} main_sprite_window;
......@@ -106,6 +108,23 @@ typedef struct main_colour
BOOL ecf; /* True if colour is actually ECF index */
} main_colour;
/* Whether sprite has standard 256 colour palette suitable for sorting into */
/* an "artist friendly" order for display on the Colours window */
typedef enum
{
artist_unknown,
artist_friendly,
artist_unfriendly