Commit 6a84fc4e authored by ROOL's avatar ROOL 🤖

Zoom resize, focus, and keyboard shortcuts

Detail:
  * Sprite editor windows gain input focus on first click (there's an option to disable this behaviour too)
  * Zoom with Ctrl+resize window (in addition to Ctrl+Scrollwheel already implemented)
  * Key shortcuts in Sprite editor windows
Admin:
  Submission for the Paint bounty.

Version 2.27. Tagged as 'Paint-2_27'
parent 18f461a5
No preview for this file type
......@@ -9,12 +9,12 @@
GBLS Module_ApplicationDate
GBLS Module_HelpVersion
GBLS Module_ComponentName
Module_MajorVersion SETS "2.26"
Module_Version SETA 226
Module_MajorVersion SETS "2.27"
Module_Version SETA 227
Module_MinorVersion SETS ""
Module_Date SETS "25 Aug 2019"
Module_ApplicationDate SETS "25-Aug-19"
Module_Date SETS "22 Sep 2019"
Module_ApplicationDate SETS "22-Sep-19"
Module_ComponentName SETS "Paint"
Module_FullVersion SETS "2.26"
Module_HelpVersion SETS "2.26 (25 Aug 2019)"
Module_FullVersion SETS "2.27"
Module_HelpVersion SETS "2.27 (22 Sep 2019)"
END
/* (2.26)
/* (2.27)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 2.26
#define Module_MajorVersion_CMHG 2.27
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 25 Aug 2019
#define Module_Date_CMHG 22 Sep 2019
#define Module_MajorVersion "2.26"
#define Module_Version 226
#define Module_MajorVersion "2.27"
#define Module_Version 227
#define Module_MinorVersion ""
#define Module_Date "25 Aug 2019"
#define Module_Date "22 Sep 2019"
#define Module_ApplicationDate "25-Aug-19"
#define Module_ApplicationDate "22-Sep-19"
#define Module_ComponentName "Paint"
#define Module_FullVersion "2.26"
#define Module_HelpVersion "2.26 (25 Aug 2019)"
#define Module_LibraryVersionInfo "2:26"
#define Module_FullVersion "2.27"
#define Module_HelpVersion "2.27 (22 Sep 2019)"
#define Module_LibraryVersionInfo "2:27"
......@@ -190,8 +190,8 @@ static
{/*zoom*/ 1, 1},
{/*grid?*/ TRUE, /*colour*/ 7},
{/*extended*/ TRUE /*always on in versions from Black onwards*/},
{/*h.lt. bgcolour?*/TRUE, /*art. friendly?*/TRUE,
/*ask remap pal?*/TRUE}
{/*extra click focus?*/TRUE, /*h.lt. bgcolour?*/TRUE,
/*art. friendly?*/TRUE, /*ask remap pal?*/TRUE}
};
static
......@@ -208,6 +208,8 @@ static
/*timer*/ NULL
};
static wimp_w snapshot_dbox_handle = NULL;
#define MAX_OPTIONS 86
#if CATCH_SIGNALS
......@@ -837,6 +839,9 @@ void main_snapshot_show (void)
dbox_show (d);
open = TRUE;
/*This is only needed to track the input focus.*/
snapshot_dbox_handle = dbox_syshandle (d);
while (open)
{ wimp_i i = dbox_fillin (d);
......@@ -873,6 +878,108 @@ void main_snapshot_show (void)
dbox_dispose (&d);
}
/********************************************
* Gets the snapshot dbox window handle *
* Only to be used to check for input focus *
* because after disposal the last handle *
* is returned for comparison. *
********************************************/
wimp_w main_get_snapshot_dbox_handle (void)
{ return snapshot_dbox_handle;
}
/*******************************************************************
* Get whether any of Paint's windows match the handle, used for *
* checking the input focus. *
*******************************************************************/
BOOL main_has_window (wimp_w handle)
{ main_window *window;
main_sprite_window *win, *thiswin;
main_sprite *sprite;
ftracef0 ("main_has_window\n");
if (handle == NULL) return FALSE;
for (window = main_windows; window != NULL; window = window->link)
{ if (window->handle == handle) return TRUE;
if (window->tag == main_window_is_file) continue;
if (window->data == NULL) continue;
thiswin = &window->data->sprite;
if (thiswin == NULL) continue;
/* Check the tools window */
if (toolwindow_handle == handle) return TRUE;
/* Check all the sprite windows */
win = thiswin->sprite->windows;
ftracef5(
"main_has_window() sprite_window: %d sprite_windows: %d main_window: %d main_windows: %d data %d\n",
thiswin, win, window, main_windows, window->data);
while (win != NULL)
{ if (win->window != NULL && win->window->handle == handle)
return TRUE;
win = win->link;
}
/* Check all the colour windows */
if (thiswin->sprite->file->sprites == NULL)
{ ftracef0("file.sprites is NULL!\n");
continue;
}
else
ftracef0("Examining file.sprites.\n");
for (sprite = thiswin->sprite->file->sprites;
sprite != NULL; sprite = sprite->link)
{ if ((wimp_w)sprite->colourhandle == handle ||
(wimp_w)sprite->bgcolourhandle == handle ||
(wimp_w)sprite->bgcolourdialogue == handle ||
(wimp_w)sprite->colourdialogue == handle) return TRUE;
}
/* Check for the create new sprite window...*/
if (psprite_get_create_handle () == handle)
return TRUE;
/* Check the Snapshot dialogue */
if (main_get_snapshot_dbox_handle () == handle)
return TRUE;
ftracef2("main_has_window() - snapshot dbox handle: 0x%X handle: 0x%X\n", main_get_snapshot_dbox_handle (), handle);
}
return FALSE;
}
/****************************************************************
* Returns the sprite window, if any, that matches the supplied *
* window handle, used for checking the input focus. *
****************************************************************/
main_sprite_window *main_get_sprite_window (wimp_w handle)
{ ftracef0 ("main_get_sprite_window\n");
for (main_window *window = main_windows; window != NULL;
window = window->link)
{ if (window->tag == main_window_is_file) continue;
for (main_sprite *sprite = window->data->sprite.sprite->file->sprites;
sprite != NULL; sprite = sprite->link)
{ if (sprite != NULL)
{ /* Check all the sprite windows */
main_sprite_window *win = sprite->windows;
while (win != NULL)
{
if (win->window->handle == handle) return win;
win = win->link;
}
}
}
}
return NULL;
}
/* Claim idle events */
/* From RISCOSlib on (rather than cwimp, when we claim idle events, we must
change the wimp's event mask
......@@ -2870,7 +2977,7 @@ static char *write_options (void)
if (memcmp (&opt->advanced, &opt0->advanced, sizeof opt->advanced) != 0)
{ char A [32];
sprintf (A, "A%c%c%c ",
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.ask_remap_palette? 'C': 'Q');
......@@ -3431,12 +3538,14 @@ static void read_options (void)
opt->extended.on = TRUE;
break;
case 'A': /* A(H|L)?(F|U)?(C|Q)? */
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 '+': 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;
......@@ -3571,6 +3680,10 @@ int main (int argc, char *argv[])
wimpt_messages (Messages);
wimpt_init (msgs_lookup ("Pnt00"));
/* Track caret for keyboard shortcuts */
event_setmask ((wimp_emask) (event_getmask () | wimp_EMLOSECARET |
wimp_EMGAINCARET));
flex_init ();
heap_init (FALSE /* non-compacting */);
......
This diff is collapsed.
......@@ -3739,3 +3739,11 @@ transparency_type psprite_transparency_type(main_sprite *spr)
return transparency_type_alphachannel;
return transparency_type_none;
}
/* Gets window handle of the Create New Sprite dialogue, *
* or NULL if not present. */
wimp_w psprite_get_create_handle (void)
{ if (Create == NULL) return NULL;
return dbox_syshandle (Create);
}
This diff is collapsed.
......@@ -82,9 +82,10 @@
#define s_Paint_Adv_Opt 7
/* Advanced options menu */
#define s_Adv_HiBackCol 1
#define s_Adv_ArtFriend 2
#define s_Adv_AskRemapPal 3
#define s_Adv_ExtraClick 1
#define s_Adv_HiBackCol 2
#define s_Adv_ArtFriend 3
#define s_Adv_AskRemapPal 4
/* Edit menu */
#define s_Edit_FlipV 1
......@@ -137,13 +138,26 @@
#define d_ECF_4 7
/* Adjust sprite size */
#define d_Adjust_Ok 0
#define d_Adjust_RowDown 2
#define d_Adjust_ColDown 3
#define d_Adjust_RowUp 4
#define d_Adjust_ColUp 5
#define d_Adjust_Cols 6
#define d_Adjust_Rows 7
#define d_Adjust_Ok 0
#define d_Adjust_RowDown 1
#define d_Adjust_ColDown 4
#define d_Adjust_RowUp 3
#define d_Adjust_ColUp 2
#define d_Adjust_Cols 5
#define d_Adjust_Rows 6
#define d_Adjust_Top 20
#define d_Adjust_Bottom 21
#define d_Adjust_Left 23
#define d_Adjust_Right 22
#define d_Adjust_TopUp 13
#define d_Adjust_TopDown 11
#define d_Adjust_BottomUp 18
#define d_Adjust_BottomDown 17
#define d_Adjust_LeftLeft 15
#define d_Adjust_LeftRight 16
#define d_Adjust_RightLeft 12
#define d_Adjust_RightRight 14
#define d_Adjust_Cancel 24
/* Print */
#define d_Print_Print 0
......
......@@ -33,6 +33,8 @@ extern void menus_file_handler (void *, char *);
extern void menus_sprite_handler (void *, char *);
extern void menus_transform_dbox (main_window *, int);
extern void menus_select_colour (main_window *, BOOL, BOOL);
extern menu menus_file_maker (void *);
......@@ -51,6 +53,8 @@ extern void menus_restart_tool (void);
extern void menus_insdel_frig (void);
extern void menus_insdel (main_window *, BOOL, BOOL, BOOL, BOOL);
extern void menus_file_has_changed (main_window *);
extern void menus_save_sprite (main_sprite *);
......@@ -73,4 +77,14 @@ extern int menus_sprite_exists (sprite_area *, char *);
extern void menus_showmag (void *);
extern wimp_wstate menus_showmag_getstate (void *, int, int);
extern void menus_adjust_size (main_sprite *);
/* Adjust Size / Edge Adjustment IDs used to sort the adjustment amounts */
#define ADJUST_TOP 0
#define ADJUST_RIGHT 1
#define ADJUST_BOTTOM 2
#define ADJUST_LEFT 3
#endif
......@@ -126,6 +126,8 @@ extern BOOL psprite_close_createbox (wimp_w);
extern char *psprite_get_colours(int mode);
extern wimp_w psprite_get_create_handle (void);
typedef enum
{
transparency_type_none,
......
......@@ -88,6 +88,22 @@ typedef
}
main_ttab;
typedef struct zoom_resize_start
{
int mx;
int my;
int swidth;
int sheight;
int sprite_width;
int sprite_height;
int window_width;
int window_height;
int offsetx; /* zoom-independent x scroll offset in OS units */
int offsety; /* zoom-independent y scroll offset in OS units */
unsigned long long zoommul;
unsigned long long zoomdiv;
} zoom_resize_start;
typedef struct main_sprite_window
{
struct main_sprite_window *link;
......@@ -95,6 +111,7 @@ typedef struct main_sprite_window
struct main_sprite *sprite;
char *title;
main_scaling_block blobsize;
zoom_resize_start resizestart;
struct colour_panel *colourpanel;
char minwidth;
char gridcol;
......@@ -204,7 +221,7 @@ typedef
struct {int mul, div;} zoom;
struct {BOOL show; int colour;} grid;
struct {BOOL on;} extended;
struct {BOOL highlight_bgcolour, artist_friendly, ask_remap_palette;} advanced;
struct {BOOL extra_click_focus, highlight_bgcolour, artist_friendly, ask_remap_palette;} advanced;
}
main_options;
......@@ -277,6 +294,16 @@ extern BOOL main_get_all_sprite_bboxes (main_window *,main_sprite *,
wimp_box *,wimp_box *,
wimp_box *);
extern wimp_w main_get_snapshot_dbox_handle (void);
/* Get whether any of Paint's windows match the handle, used for */
/* checking the input focus. */
extern BOOL main_has_window (wimp_w handle);
/* Returns the sprite window, if any, that matches the supplied */
/* window handle, used for checking the input focus. */
extern main_sprite_window *main_get_sprite_window (wimp_w handle);
/*************************************************************
* Manifests for the size sprites appear in the file window *
*************************************************************/
......
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