Commit 97539240 authored by Robert Sprowson's avatar Robert Sprowson

Fix crashes when dragging from the sprite filer to the filer to save sprite(s).

The use of DragASprite tended to cause an abort somewhere in the kernel's sprite handling code for some reason, changed this to instead create a temporary WIMP icon on the sprite filer in question which can than be referred to in a normal call to xfersend(). The rest of the save is then handled by the normal xfersend() handlers and the temporary icon destroyed since the WIMP takes a copy anyway.
Has the extra benefits
 * Dragging from the sprite filer now obeys the 'solid drag' flags.
 * Dragging from the sprite filer no longer crashes if dropping back on the originating filer window itself.
When dragging a selection from the filer the selection is cleared at the end of the drag, to match the behaviour of the desktop filer. When saving a selection from the 'Selection' menu, they are not deselected.
Changed to use the 'package' icon when dragging multiple sprites, or file_ff9 for singles.

Version 2.06. Tagged as 'Paint-2_06'
parent a0724eed
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
GBLS Module_HelpVersion GBLS Module_HelpVersion
GBLS Module_ComponentName GBLS Module_ComponentName
GBLS Module_ComponentPath GBLS Module_ComponentPath
Module_MajorVersion SETS "2.05" Module_MajorVersion SETS "2.06"
Module_Version SETA 205 Module_Version SETA 206
Module_MinorVersion SETS "" Module_MinorVersion SETS ""
Module_Date SETS "07 Dec 2010" Module_Date SETS "07 Dec 2010"
Module_ApplicationDate SETS "07-Dec-10" Module_ApplicationDate SETS "07-Dec-10"
Module_ComponentName SETS "Paint" Module_ComponentName SETS "Paint"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Paint" Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Paint"
Module_FullVersion SETS "2.05" Module_FullVersion SETS "2.06"
Module_HelpVersion SETS "2.05 (07 Dec 2010)" Module_HelpVersion SETS "2.06 (07 Dec 2010)"
END END
/* (2.05) /* (2.06)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1. * Last processed by srccommit version: 1.1.
* *
*/ */
#define Module_MajorVersion_CMHG 2.05 #define Module_MajorVersion_CMHG 2.06
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 07 Dec 2010 #define Module_Date_CMHG 07 Dec 2010
#define Module_MajorVersion "2.05" #define Module_MajorVersion "2.06"
#define Module_Version 205 #define Module_Version 206
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "07 Dec 2010" #define Module_Date "07 Dec 2010"
...@@ -18,6 +18,6 @@ ...@@ -18,6 +18,6 @@
#define Module_ComponentName "Paint" #define Module_ComponentName "Paint"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Paint" #define Module_ComponentPath "castle/RiscOS/Sources/Apps/Paint"
#define Module_FullVersion "2.05" #define Module_FullVersion "2.06"
#define Module_HelpVersion "2.05 (07 Dec 2010)" #define Module_HelpVersion "2.06 (07 Dec 2010)"
#define Module_LibraryVersionInfo "2:5" #define Module_LibraryVersionInfo "2:6"
...@@ -1855,7 +1855,9 @@ static void main_save_finished (int at, void *arg) ...@@ -1855,7 +1855,9 @@ static void main_save_finished (int at, void *arg)
{ main_window *window = (main_window *)arg; { main_window *window = (main_window *)arg;
at=at; at=at;
xfersend_clear_unknowns (); xfersend_clear_unknowns ();
window->selection.flags &= ~MW_SELSAVING; if (window->selection.flags & MW_SELSAVEBYDRAG)
main_clear_selection (window, 0, SI_CLEAR);
window->selection.flags &= ~(MW_SELSAVING | MW_SELSAVEBYDRAG);
} }
BOOL main_save_selection (char *filename, void *arg) BOOL main_save_selection (char *filename, void *arg)
...@@ -1908,15 +1910,6 @@ BOOL main_save_selection (char *filename, void *arg) ...@@ -1908,15 +1910,6 @@ BOOL main_save_selection (char *filename, void *arg)
return TRUE; return TRUE;
} }
static BOOL main_select_drag (wimp_eventstr *event, void *handle)
{ main_window *window = (main_window *)handle;
if (event->e != wimp_EUSERDRAG) return 0;
win_remove_unknown_event_processor (main_select_drag, handle);
xfersend (FileType_Sprite, 0, main_selection_file_size (window), main_save_selection, 0, 0, event, handle);
return 0;
}
/******************************************************** /********************************************************
* Pick a sprite in a file window, pointed at by mouse * * Pick a sprite in a file window, pointed at by mouse *
********************************************************/ ********************************************************/
...@@ -1929,12 +1922,12 @@ static main_sprite *main_pick_sprite_bbox (main_window *window, ...@@ -1929,12 +1922,12 @@ static main_sprite *main_pick_sprite_bbox (main_window *window,
main_sprite *sprite; main_sprite *sprite;
int x, y, width, height, mx, my; int x, y, width, height, mx, my;
wimp_box dummy; wimp_box dummy;
if (!bbox) bbox=&dummy; if (!bbox) bbox=&dummy;
ftracef2 ("main_pick sprite: (%d, %d)\n", mouse->x, mouse->y); ftracef2 ("main_pick sprite: (%d, %d)\n", mouse->x, mouse->y);
wimpt_noerr (wimp_get_wind_state (window->handle, &whereisit)); wimpt_noerr (wimp_get_wind_state (window->handle, &whereisit));
if (window->data->file.fullinfo) if (window->data->file.fullinfo)
{ width = main_FILER_FullInfoWidth; { width = main_FILER_FullInfoWidth;
height = main_FILER_FullInfoHeight; height = main_FILER_FullInfoHeight;
...@@ -1968,10 +1961,10 @@ static main_sprite *main_pick_sprite_bbox (main_window *window, ...@@ -1968,10 +1961,10 @@ static main_sprite *main_pick_sprite_bbox (main_window *window,
ftracef3 ("Sprite %d x %d, %d\n", x, y, spritenumber); ftracef3 ("Sprite %d x %d, %d\n", x, y, spritenumber);
bbox->x0=x*width; bbox->x0 = x*width;
bbox->x1=bbox->x0+width-1; bbox->x1 = bbox->x0+width-1;
bbox->y1=-y*height; bbox->y1 = -y*height;
bbox->y0=bbox->y1-height; bbox->y0 = bbox->y1-height;
for (sprite=window->data->file.sprites; for (sprite=window->data->file.sprites;
spritenumber>0 && sprite != NULL; spritenumber>0 && sprite != NULL;
...@@ -2245,7 +2238,8 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2245,7 +2238,8 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
main_sprite *sprite = main_pick_sprite_bbox (window, &e->data.but.m, &is_over_graphic, &rds.box); main_sprite *sprite = main_pick_sprite_bbox (window, &e->data.but.m, &is_over_graphic, &rds.box);
if (e->data.but.m.bbits & wimp_BCLICKLEFT) if (e->data.but.m.bbits & wimp_BCLICKLEFT)
{ if (sprite && is_over_graphic && (sprite->flags & MSF_SELECTED)) break; {
if (sprite && is_over_graphic && (sprite->flags & MSF_SELECTED)) break;
if (sprite == NULL || !is_over_graphic) if (sprite == NULL || !is_over_graphic)
{ main_clear_selection (window, 0, SI_CLEAR); { main_clear_selection (window, 0, SI_CLEAR);
...@@ -2264,67 +2258,107 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle) ...@@ -2264,67 +2258,107 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
} }
} }
else else
{ if (sprite && is_over_graphic) { /* else right click */
if (sprite && is_over_graphic)
main_select_icon (window, sprite, &rds.box, SI_TOGGLE); main_select_icon (window, sprite, &rds.box, SI_TOGGLE);
} }
} }
else if (e->data.but.m.bbits & (wimp_BDRAGLEFT | wimp_BDRAGRIGHT)) else if (e->data.but.m.bbits & (wimp_BDRAGLEFT | wimp_BDRAGRIGHT))
{ { wimp_redrawstr rds;
wimp_redrawstr rds; int is_over_graphic;
int is_over_graphic;
main_sprite *sprite = main_pick_sprite_bbox (window, &e->data.but.m, &is_over_graphic, &rds.box);
main_sprite *sprite = main_pick_sprite_bbox (window, &e->data.but.m, &is_over_graphic, &rds.box);
if (sprite && is_over_graphic)
if (sprite && is_over_graphic) { wimp_icreate create;
{ main_select_icon (window, sprite, &rds.box, SI_SELECT); wimp_icon icon;
wimp_wstate ws;
if (window->selection.count) static const char iconfile[] = "file_ff9";
{ wimp_box box; static const char iconfiles[] = "package";
box.x0=e->data.but.m.x-17; wimp_i iconhandle;
box.x1=e->data.but.m.x+17; int width, height;
box.y0=e->data.but.m.y-17;
box.y1=e->data.but.m.y+17; /* Read where the window where the click was is */
if (_swix (DragASprite_Start, _INR(0, 3), 1 | (1<<2) | (1<<6) | (1<<7), 1,"file_ff9",&box)) break; wimpt_noerr (wimp_get_wind_state (e->data.but.m.w, &ws));
win_add_unknown_event_processor (main_select_drag, window);
} /* Bounding box is filer thumbnail size */
} if (window->data->file.fullinfo)
else { width = main_FILER_XSize/2;
{ wimp_dragstr drag; height = main_FILER_YSize/2;
wimp_wstate ws; }
struct else
{ { width = main_FILER_XSize;
int window_handle; height = main_FILER_YSize;
struct {int left, bottom, right, top;}pause_zone; }
int pause_duration;
int handler; /* Convert mouse to window offset coordinates */
void *handle; icon.box.x0 = e->data.but.m.x - (ws.o.box.x0 - ws.o.x) - (width/2);
} scroll; icon.box.y0 = e->data.but.m.y - (ws.o.box.y1 - ws.o.y) - (height/2);
icon.box.x1 = icon.box.x0 + width;
wimp_get_wind_state (window->handle,&ws); icon.box.y1 = icon.box.y0 + height;
drag.window=window->handle; /* Create an icon and add it to the window */
drag.type=wimp_USER_RUBBER; icon.flags = wimp_ISPRITE | wimp_INDIRECT;
drag.box.x0=drag.box.x1=e->data.but.m.x; icon.data.indirectsprite.name = window->selection.count > 1 ? (char *)iconfiles :
drag.box.y0=drag.box.y1=e->data.but.m.y; (char *)iconfile;
drag.parent=ws.o.box; icon.data.indirectsprite.spritearea = (sprite_area *)1;
drag.parent.y1=0x7f000000; icon.data.indirectsprite.nameisname = strlen(icon.data.indirectsprite.name);
drag.parent.y0=-0x7f000000; create.w = e->data.but.m.w;
os_swix4 (Wimp_DragBox, 0, &drag, *(int *)"TASK", 3); create.i = icon;
wimpt_noerr (wimp_create_icon (&create, &iconhandle));
scroll.window_handle=window->handle;
scroll.pause_zone.left=0; /* Pretend the event came from that icon which allows it to be
scroll.pause_zone.bottom=0; picked up by DragASprite */
scroll.pause_zone.right=0; e->data.but.m.i = iconhandle;
scroll.pause_zone.top=0;
scroll.pause_duration=0; /* Start the xfersend */
scroll.handler=1; xfersend (FileType_Sprite, msgs_lookup ("PntG6"),
scroll.handle=0; main_selection_file_size(window),
os_swix2 (Wimp_AutoScroll, 2, &scroll); main_save_selection, 0, 0, e, window);
window->selection.flags &= ~MW_SELDRAGRIGHT;
if (e->data.but.m.bbits & wimp_BDRAGRIGHT) /* Denote this as a drag save rather than menu save */
window->selection.flags |= MW_SELDRAGRIGHT; window->selection.flags |= MW_SELSAVEBYDRAG;
win_add_unknown_event_processor (main_select_area, window);
} /* Finished with the icon */
wimpt_noerr (wimp_delete_icon(create.w, iconhandle));
}
else
{ wimp_dragstr drag;
wimp_wstate ws;
struct
{
int window_handle;
struct {int left, bottom, right, top;} pause_zone;
int pause_duration;
int handler;
void *handle;
} scroll;
wimp_get_wind_state (window->handle, &ws);
drag.window=window->handle;
drag.type=wimp_USER_RUBBER;
drag.box.x0=drag.box.x1=e->data.but.m.x;
drag.box.y0=drag.box.y1=e->data.but.m.y;
drag.parent=ws.o.box;
drag.parent.y1=0x7f000000;
drag.parent.y0=-0x7f000000;
os_swix4 (Wimp_DragBox, 0, &drag, *(int *)"TASK", 3);
scroll.window_handle=window->handle;
scroll.pause_zone.left=0;
scroll.pause_zone.bottom=0;
scroll.pause_zone.right=0;
scroll.pause_zone.top=0;
scroll.pause_duration=0;
scroll.handler=1;
scroll.handle=0;
os_swix2 (Wimp_AutoScroll, 2, &scroll);
window->selection.flags &= ~MW_SELDRAGRIGHT;
if (e->data.but.m.bbits & wimp_BDRAGRIGHT)
window->selection.flags |= MW_SELDRAGRIGHT;
win_add_unknown_event_processor (main_select_area, window);
}
} }
break; break;
......
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