Commit 5ddfba1a authored by Robert Sprowson's avatar Robert Sprowson Committed by ROOL
Browse files

Add choices dialogue, don't set Paint$Options

Messages/Templates: Extra interactive help, new menu templates, new choices dialogue.
PaintChoice.c/h: New source file to handle the choices dialogue, also added to Makefile.

Main.c/h: Transfer ownership of initial_options to PaintChoice.c. Delete setting & parsing of Paint$Options. Export - and constify - Matches() for use elsewhere. Define MAXZOOMFACTOR and replace 999's elsewhere.
Menus.c: Remove advanced options menu, these are now in choices.
MenuD.h: Defines for the iconbar menu, remove advanced options menu.

Version 2.35. Tagged as 'Paint-2_35'
parent 420bdd39
......@@ -84,13 +84,12 @@ DFILES = \
debug.${APP}.Templates
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.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
o.AltRename o.PaintLib o.CnPDrag o.Clipboard o.Drawfile o.PaintChoice
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.PaintChoice
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.colourpanel s.colours s.main s.menus s.psprite s.sprwindow s.tools s.toolwindow
od.AltRename od.PaintLib od.CnPDrag od.Clipboard od.Drawfile od.PaintChoice
#
# 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.34"
Module_Version SETA 234
Module_MajorVersion SETS "2.35"
Module_Version SETA 235
Module_MinorVersion SETS ""
Module_Date SETS "09 May 2020"
Module_ApplicationDate SETS "09-May-20"
Module_Date SETS "23 May 2020"
Module_ApplicationDate SETS "23-May-20"
Module_ComponentName SETS "Paint"
Module_FullVersion SETS "2.34"
Module_HelpVersion SETS "2.34 (09 May 2020)"
Module_FullVersion SETS "2.35"
Module_HelpVersion SETS "2.35 (23 May 2020)"
END
/* (2.34)
/* (2.35)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 2.34
#define Module_MajorVersion_CMHG 2.35
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 09 May 2020
#define Module_Date_CMHG 23 May 2020
#define Module_MajorVersion "2.34"
#define Module_Version 234
#define Module_MajorVersion "2.35"
#define Module_Version 235
#define Module_MinorVersion ""
#define Module_Date "09 May 2020"
#define Module_Date "23 May 2020"
#define Module_ApplicationDate "09-May-20"
#define Module_ApplicationDate "23-May-20"
#define Module_ComponentName "Paint"
#define Module_FullVersion "2.34"
#define Module_HelpVersion "2.34 (09 May 2020)"
#define Module_LibraryVersionInfo "2:34"
#define Module_FullVersion "2.35"
#define Module_HelpVersion "2.35 (23 May 2020)"
#define Module_LibraryVersionInfo "2:35"
......@@ -112,6 +112,7 @@
#include "ColourPanel.h"
#include "AltRename.h"
#include "PaintLib.h"
#include "PaintChoice.h"
#include "CnPDrag.h"
#include "Clipboard.h"
......@@ -181,19 +182,6 @@ static void init_statics (void)
main_windows = &fudgewindow;
}
static
main_options
initial_options =
{ {/*full info?*/ FALSE, /*use desktop colours?*/ TRUE},
{/*show colours?*/ TRUE, /*small colours?*/ FALSE},
{/*show tools?*/ TRUE},
{/*zoom*/ 1, 1},
{/*grid?*/ TRUE, /*colour*/ 7},
{/*extended*/ TRUE /*always on in versions from Black onwards*/},
{/*extra click focus?*/TRUE, /*art. friendly?*/TRUE,
/*remap pal?*/FALSE, /*ask remap pal?*/FALSE}
};
static
snapshotstr
sshot =
......@@ -210,8 +198,6 @@ static
static wimp_w snapshot_dbox_handle = NULL;
#define MAX_OPTIONS 86
#if CATCH_SIGNALS
static jmp_buf Buf;
static void Signal_Handler (int signal) {longjmp (Buf, signal);}
......@@ -2921,76 +2907,6 @@ static void main_iconclick (wimp_i iconno)
* *
***************************************************************************/
static char *write_options (void)
{ /*Translate main_current_options to string (in static space).*/
static char buffer [MAX_OPTIONS + 1];
int len;
main_options *opt = &main_current_options;
main_options *opt0 = &initial_options;
/*name equivalence to save typing.*/
ftracef0 ("write_options\n");
buffer [0] = '\0';
if (memcmp (&opt->display, &opt0->display, sizeof opt->display) != 0)
{ char D [32];
sprintf (D, "D%c%c ", opt->display.full_info? 'F': 'D',
opt->display.use_desktop_colours? 'W': 'B');
strcat (buffer, D);
}
if (memcmp (&opt->colours, &opt0->colours, sizeof opt->colours) != 0)
{ char C [32];
sprintf (C, "C%c%s ", opt->colours.show_colours? '+': '-',
opt->colours.small_colours? "S": "");
strcat (buffer, C);
}
if (memcmp (&opt->tools, &opt0->tools, sizeof opt->tools) != 0)
{ char T [32];
sprintf (T, "T%c ", opt->tools.show_tools? '+': '-');
strcat (buffer, T);
}
if (memcmp (&opt->zoom, &opt0->zoom, sizeof opt->zoom) != 0)
{ char Z [32];
sprintf (Z, "Z%d:%d ", opt->zoom.mul, opt->zoom.div);
strcat (buffer, Z);
}
if (memcmp (&opt->grid, &opt0->grid, sizeof opt->grid) != 0)
{ char G [32];
sprintf (G, "G%d ", opt->grid.colour);
if (opt->grid.show) strcat (buffer, G);
/*Stupid fix because G<n> => grid on*/
}
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%c ", opt->advanced.extra_click_focus? '+': '-',
opt->advanced.artist_friendly? 'F': 'U',
opt->advanced.remap_palette? 'R': 'D',
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';
return buffer;
}
static void New_File (char *name)
{ main_window *w = New_Window (TRUE);
......@@ -3327,10 +3243,9 @@ static void Background_Events (wimp_eventstr *e, void *handle)
case wimp_SAVEDESK:
if (strlen (Paint_Dir) > 0) /*save if we know where we started*/
{ os_gbpbstr gbpb_str;
char lines [19 + MAX_OPTIONS + 3 + FILENAME_MAX + 2];
char lines [1 + FILENAME_MAX + 2];
sprintf (lines, "Set Paint$Options \"%s\"\n/%s\n",
write_options (), Paint_Dir);
sprintf (lines, "/%s\n", Paint_Dir);
gbpb_str.action = 2; /* write at current position */
gbpb_str.file_handle = e->data.msg.data.savedesk.filehandle;
......@@ -3446,118 +3361,6 @@ static void Background_Events (wimp_eventstr *e, void *handle)
}
}
static void read_options (void)
{ /*Sets main_current_options. Called only once, at startup. JRC*/
char buffer [MAX_OPTIONS + 1], *token, *options;
main_options *opt = &main_current_options;
/*name equivalence to save typing.*/
ftracef0 ("read_options\n");
if ((options = getenv ("Paint$Options")) != NULL)
sprintf (buffer, "%.*s", MAX_OPTIONS, options);
else
buffer [0] = '\0';
ftracef1 ("paint options are '%s'\n", buffer);
/* Set defaults */
*opt = initial_options;
ftracef0 ("read_options: set defaults\n");
/* Get tokens separated by spaces */
for (token = strtok (buffer, " "); token != NULL;
token = strtok (NULL, " "))
{ switch (toupper (token [0]))
{ case 'D': /* D(D|F)?(W|B)? */
{ char *cc;
for (cc = &token [1]; *cc != NULL; cc++)
switch (toupper (*cc))
{ case 'D': opt->display.full_info = FALSE; break;
case 'F': opt->display.full_info = TRUE; break;
case 'W': opt->display.use_desktop_colours = TRUE; break;
case 'B': opt->display.use_desktop_colours = FALSE; break;
}
}
break;
case 'G': /* G(+|-)?<n>? */
{ char *cc, *rest;
for (cc = &token [1]; *cc != '\0';)
if (isdigit (*cc))
{ opt->grid.colour = (int) strtol (cc, &rest, 10);
if (rest == cc) break;
cc = rest;
}
else
{ if (*cc == '+')
opt->grid.show = TRUE;
else if (*cc == '-')
opt->grid.show = FALSE;
cc++;
} }
break;
case 'Z': /* Z<a>:<b> */
{ int mul, div;
char *rest;
mul = (int) strtol (token + 1, &rest, 10);
if (rest != token && toupper (*rest) != ':') break;
div = (int) strtol (rest + 1, &rest, 10);
if (rest == token) break;
if (mul < 1) mul = 1;
if (div < 1) div = 1;
opt->zoom.mul = mul;
opt->zoom.div = div;
}
break;
case 'T': /* T(+|-)? */
if (token [1] == '+')
opt->tools.show_tools = TRUE;
else if (token [1] == '-')
opt->tools.show_tools = FALSE;
break;
case 'C': /* C(+|-)?(S|L)? */
{ char *cc;
for (cc = &token [1]; *cc != '\0'; cc++)
switch (toupper (*cc))
{ case '+': opt->colours.show_colours = TRUE; break;
case '-': opt->colours.show_colours = FALSE; break;
case 'S': opt->colours.small_colours = TRUE; break;
case 'L': opt->colours.small_colours = FALSE; break;
} }
break;
case 'X': /* X? */
opt->extended.on = TRUE;
break;
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 '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;
}
}
break;
}
}
}
static menu main_iconmenumaker (void *handle)
{ ftracef0 ("main_iconmenumaker\n");
......@@ -3573,9 +3376,9 @@ static menu main_iconmenumaker (void *handle)
* *
***************************************************************************/
static BOOL Matches (char *a, char *b)
BOOL main_matches (const char *a, const char *b)
{ ftracef0 ("Matches\n");
{ ftracef0 ("main_matches\n");
while (*a || *b)
if (tolower (*a++) != tolower (*b++)) return 0;
......@@ -3734,8 +3537,7 @@ int main (int argc, char *argv[])
/* Read Paint$Dir for desksaving */
os_read_var_val ("Paint$Dir", Paint_Dir, FILENAME_MAX);
read_options ();
ftracef1 ("Options are \"%s\"\n", write_options ());
paint_choice_read ();
menus_init ();
......@@ -3855,7 +3657,7 @@ int main (int argc, char *argv[])
while (--argc)
{ ftracef1 ("process arg '%s'\n", * (argv + 1));
if (Matches (*++argv, "-print"))
if (main_matches (*++argv, "-print"))
{ if (--argc)
print_file (*++argv);
else
......
......@@ -82,6 +82,7 @@
#include "ftrace.h"
#include "main.h"
#include "PSprite.h"
#include "PaintChoice.h"
#include "Menus.h"
#include "SprWindow.h"
#include "ToolWindow.h"
......@@ -2134,39 +2135,6 @@ void menus_sprite_handler (void *handle, char *hit)
destroy_artistfriendly_dbox ();
}
break;
case s_Paint_Adv_Opt:
switch (hit [2])
{ case s_Adv_ArtFriend:
main_current_options.advanced.artist_friendly =
!main_current_options.advanced.artist_friendly;
for (main_sprite *spr = sprite->file->sprites; spr != NULL;
spr = spr->link)
{ if (!main_current_options.advanced.artist_friendly)
{ /* Clear artist-friendly status of sprites so it won't get
out of sync while the feature is disabled */
spr->artistfriendly = artist_unknown;
}
/* Redraw all colour selectors */
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;
......@@ -2373,7 +2341,7 @@ void menus_sprite_handler (void *handle, char *hit)
case s_Zoom:
if (hit [1])
magnify_select (&sprw->blobsize.scale_xmul,
&sprw->blobsize.scale_xdiv, 999, 999, menus_showmag, sprw);
&sprw->blobsize.scale_xdiv, MAXZOOMFACTOR, MAXZOOMFACTOR, menus_showmag, sprw);
break;
case s_Grid:
......@@ -3760,6 +3728,11 @@ void menus_icon_proc (void *handle, char *hit)
main_snapshot_show ();
break;
case i_Choices:
ftracef0 ("Show choices\n");
paint_choice_display ();
break;
case i_Quit:
if (menus_files_modified () == 0 ||
menus_quit_okayed (menus_files_modified ()))
......@@ -3962,30 +3935,6 @@ menu menus_sprite_maker (void *handle)
/*tick?*/ FALSE, /*grey?*/ !(psprite_hastruecolpal (sprite) &&
!sprite->gcol.ecf && sprite->gcol.colour < no_colours));
/* 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?*/ !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?*/ !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");
strcpy (shearbuffer, "0")*/
......@@ -4048,8 +3997,6 @@ void menus_init (void)
sprite_paint_menu = make_menu2 ("Pnt00", "PntMD");
sprite_advopts_menu = make_menu2 ("PntMO", "PntMP");
menu_submenu (sprite_paint_menu, s_Paint_Adv_Opt, sprite_advopts_menu);
menu_submenu (sprite_main_menu, s_Paint, sprite_paint_menu);
sprite_edit_menu = make_menu2 ("PntME", "PntMF");
......
/* Copyright 2020 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.
*/
/* -> PaintChoice.c
*
* Choices dialogue, loading and saving
*/
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include "Global/FileTypes.h"
#include "Interface/HighFSI.h"
#include "msgs.h"
#include "os.h"
#include "wimp.h"
#include "wimpt.h"
#include "help.h"
#include "werr.h"
#include "xferrecv.h"
#include "colourmenu.h"
#include "main.h"
#include "MenuD.h"
#include "PaintChoice.h"
static dbox choicedb;
static menu gridpop, gridcol;
static menu lastpop; /*Last shown popup*/
static main_options opt, opt2; /*Options, and backup set*/
#define choicedb_set 0
#define choicedb_cancel 20
#define choicedb_zoomden 15
#define choicedb_zoomdenup 18
#define choicedb_zoomdendown 19
#define choicedb_zoomnum 14
#define choicedb_zoomnumup 16
#define choicedb_zoomnumdown 17
#define choicedb_showdetails 21
#define choicedb_deskcolours 4
#define choicedb_showcolours 5
#define choicedb_smallcolours 6
#define choicedb_artistic 7
#define choicedb_rearrange 8
#define choicedb_prompt 9
#define choicedb_showtools 10
#define choicedb_twoclicks 11
#define choicedb_gridpop 13
#define choicedb_griddisplay 12
static void paint_choice_menufillin (void)
{ int i;
char desc[50];
/*Ticks in the grid menu*/
menu_setflags (gridpop, s_Grid_Show, opt.grid.show, FALSE);
for (i = 0; i <= 15; i++)
menu_setflags (gridcol, i + 1, i == opt.grid.colour, FALSE);
/*Grid display field*/
strcpy (desc, msgs_lookup (opt.grid.show ? "PntGrS" : "PntGrO"));
dbox_setfield (choicedb, choicedb_griddisplay, desc);
}
static int paint_choice_sat (int value, int low, int high)
{ if (value < low) return low;
if (value > high) return high;
return value;
}
static void paint_choice_fillin (void)
{ /*Fill current values*/
dbox_setnumeric (choicedb, choicedb_showcolours, opt.colours.show_colours);
dbox_setnumeric (choicedb, choicedb_smallcolours, opt.colours.small_colours);
dbox_setnumeric (choicedb, choicedb_artistic, opt.advanced.artist_friendly);
dbox_setnumeric (choicedb, choicedb_rearrange, opt.advanced.remap_palette);
if (opt.advanced.remap_palette)
dbox_unfadefield (choicedb, choicedb_prompt);
else
dbox_fadefield (choicedb, choicedb_prompt);
dbox_setnumeric (choicedb, choicedb_prompt, opt.advanced.ask_remap_palette);
dbox_setnumeric (choicedb, choicedb_showtools, opt.tools.show_tools);
dbox_setnumeric (choicedb, choicedb_twoclicks, opt.advanced.extra_click_focus);
dbox_setnumeric (choicedb, choicedb_zoomnum, opt.zoom.mul);
dbox_setnumeric (choicedb, choicedb_zoomden, opt.zoom.div);
dbox_setnumeric (choicedb, choicedb_showdetails, opt.display.full_info);
dbox_setnumeric (choicedb, choicedb_deskcolours, opt.display.use_desktop_colours);
paint_choice_menufillin ();
}
static menu paint_choice_popup (void *handle)
{ int x, y;
wimp_wstate state;
wimp_icon icon;
wimp_w w = dbox_syshandle (choicedb);
wimp_eventstr *e = wimpt_last_event ();
dbox_field f;
wimp_mousestr m;
if (handle == NULL)
{ /*Came here from the menumaker, need to figure out which icon it was*/
if (event_is_menu_being_recreated ())
return lastpop;
wimp_get_point_info (&m);
f = (dbox_field) m.i;
}
else
{ /*Came here from clicking on the popup icon*/
f = (dbox_field) handle;
}
switch (f)
{ case choicedb_gridpop:
lastpop = gridpop;
help_register_handler (&help_simplehandler, (void *) "CHG");
break;
default:
return NULL;
}
/*Find where the popup icon is*/
wimpt_complain (wimp_get_icon_info (w, f, &icon));
/*Find where the window is*/
wimp_get_wind_state (w, &state);
/*Offset the menu to open popup per Style Guide*/
x = state.o.x + state.o.box.x0 + icon.box.x1 + 64;
y = -state.o.y + state.o.box.y1 + icon.box.y1 - 4;
if (e->data.but.m.x != x || e->data.but.m.y != y)
{ wimp_eventstr fake;
/*Force it to be on point, we'll back back in a moment to do it again with x/y correct*/
fake.e = wimp_EBUT;
fake.data.but.m.bbits = wimp_BMID;
fake.data.but.m.w = w;
fake.data.but.m.i = (wimp_i)f;
fake.data.but.m.x = x;
fake.data.but.m.y = y;
wimpt_fake_event (&fake);
}
return lastpop;
}
static void paint_choice_menuhit (void *handle, char *hit)
{ handle = handle;
if (lastpop == gridpop)
{ switch (hit[0])
{ case s_Grid_Show:
opt.grid.show = !opt.grid.show; /*Toggle*/
break;
case s_Grid_Colour:
if (hit[1]) opt.grid.colour = hit[1] - 1; /*Store it*/
break;
}