Commit 938add00 authored by Robert Sprowson's avatar Robert Sprowson

Sprite filer selection logic made consistent with filer

Specifically, in the filer when you menu click on a file it is temporarily selected. Clicking on a different file loses the first temporary selection and moves the highlight to the new file. This behaviour is skipped if there are already files selected (using left or right click).
This change makes !Paint behave this way too, previously the menu click was a permanent selection, so menu clicking elsewhere on a different sprite would actually manipulate the sprite selected some time earlier - very confusing.
Tidy ups
 * Remove hardwired mouse button bitmask operations, now uses defines from <wimp.h>.
 * Use OS_Byte numbers from header

Version 2.12. Tagged as 'Paint-2_12'
parent 6540feac
......@@ -13,6 +13,4 @@
| limitations under the License.
|
Dir <Obey$Dir>
wimpslot -min 1024k
cdir <Install$Dir>.Apps.!Paint
amu_machine install INSTDIR=<Install$Dir>.Apps.!Paint
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "2.11"
Module_Version SETA 211
Module_MajorVersion SETS "2.12"
Module_Version SETA 212
Module_MinorVersion SETS ""
Module_Date SETS "11 Aug 2012"
Module_ApplicationDate SETS "11-Aug-12"
Module_Date SETS "22 Aug 2012"
Module_ApplicationDate SETS "22-Aug-12"
Module_ComponentName SETS "Paint"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Paint"
Module_FullVersion SETS "2.11"
Module_HelpVersion SETS "2.11 (11 Aug 2012)"
Module_FullVersion SETS "2.12"
Module_HelpVersion SETS "2.12 (22 Aug 2012)"
END
/* (2.11)
/* (2.12)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.11
#define Module_MajorVersion_CMHG 2.12
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 11 Aug 2012
#define Module_Date_CMHG 22 Aug 2012
#define Module_MajorVersion "2.11"
#define Module_Version 211
#define Module_MajorVersion "2.12"
#define Module_Version 212
#define Module_MinorVersion ""
#define Module_Date "11 Aug 2012"
#define Module_Date "22 Aug 2012"
#define Module_ApplicationDate "11-Aug-12"
#define Module_ApplicationDate "22-Aug-12"
#define Module_ComponentName "Paint"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Paint"
#define Module_FullVersion "2.11"
#define Module_HelpVersion "2.11 (11 Aug 2012)"
#define Module_LibraryVersionInfo "2:11"
#define Module_FullVersion "2.12"
#define Module_HelpVersion "2.12 (22 Aug 2012)"
#define Module_LibraryVersionInfo "2:12"
......@@ -200,7 +200,7 @@ BOOL altrename_claim_event (wimp_eventstr *e, main_window *window)
{
case wimp_EBUT:
if (window->handle!=rename_window->handle ||
(e->data.but.m.bbits & 2))
(e->data.but.m.bbits & wimp_BMID))
{ altrename_delete ();
break;
}
......
......@@ -334,7 +334,7 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
break;
case wimp_EBUT:
if (e->data.but.m.bbits & 5)
if (e->data.but.m.bbits & (wimp_BRIGHT | wimp_BLEFT))
{ wimp_wstate whereisit;
wimp_redrawstr rds;
int x, y, oldgcol, newgcol, ncols, ncs, perrow;
......@@ -356,7 +356,7 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
y /= coloursize;
newgcol = y*perrow + x;
oldgcol = e->data.but.m.bbits & 4? sprite->gcol: sprite->gcol2;
oldgcol = e->data.but.m.bbits & wimp_BLEFT ? sprite->gcol : sprite->gcol2;
if (newgcol > ncols) break;
......@@ -398,7 +398,7 @@ void colours_event_handler (wimp_eventstr *e, void *handle)
rds.box.y1 =-y*coloursize /*-y*coloursize*/;
wimpt_noerr (wimp_force_redraw (&rds)); /* of old colour */
*(e->data.but.m.bbits & 4? &sprite->gcol: &sprite->gcol2) = newgcol;
*(e->data.but.m.bbits & wimp_BLEFT ? &sprite->gcol : &sprite->gcol2) = newgcol;
}
break;
......
......@@ -70,6 +70,7 @@
#include <swis.h>
#include "Global/CMOS.h"
#include "Global/FileTypes.h"
#include "Global/OsBytes.h"
#include "pointer.h"
#include "akbd.h"
......@@ -226,7 +227,7 @@ static void main_clear_background (wimp_redrawstr *rds)
char name[NAME_LIMIT + 1];
/* Test tiling disabled in CMOS */
os_byte (161, (dummy = DesktopFeaturesCMOS, &dummy), &use_sprite);
os_byte (OsByte_ReadCMOS, (dummy = DesktopFeaturesCMOS, &dummy), &use_sprite);
use_sprite = (use_sprite & desktopwindowtile) == 0;
if (use_sprite)
......@@ -1725,6 +1726,7 @@ static void main_select_icon(main_window *window, main_sprite *sprite, wimp_box
main_update_icon (window, sprite, iconbbox);
}
}
window->selection.transsprite = NULL; /* All selections cancel the transitory one */
}
#define MIN_TARGET_SIZE 64
......@@ -1832,6 +1834,7 @@ static BOOL main_select_area (wimp_eventstr *event, void *handle)
clip.x1 = SCREEN_TO_WORKAREA_X(&ws, MAX(event->data.dragbox.x0, event->data.dragbox.x1));
clip.y0 = SCREEN_TO_WORKAREA_Y(&ws, MIN(event->data.dragbox.y0, event->data.dragbox.y1));
clip.y1 = SCREEN_TO_WORKAREA_Y(&ws, MAX(event->data.dragbox.y0, event->data.dragbox.y1));
/* Lassoo of several sprites */
main_clear_selection (window, &clip, (window->selection.flags & MW_SELDRAGRIGHT) ? SI_TOGGLE : SI_SELECT);
return TRUE;
......@@ -1858,7 +1861,7 @@ static void main_save_finished (int at, void *arg)
at=at;
xfersend_clear_unknowns ();
if (window->selection.flags & MW_SELSAVEBYDRAG)
main_clear_selection (window, 0, SI_CLEAR);
main_clear_selection (window, 0, SI_CLEAR); /* Deselect those just saved */
window->selection.flags &= ~(MW_SELSAVING | MW_SELSAVEBYDRAG);
}
......@@ -2048,25 +2051,45 @@ static main_sprite *main_pick_sprite (main_window *window, wimp_mousestr *mouse)
main_sprite *main_pick_menu_button_sprite (main_window *window)
{ if (window->selection.count==0)
{ int is_in_graphic;
wimp_mousestr mouse;
main_sprite *sprite;
wimp_box bbox;
wimpt_noerr (wimp_get_point_info (&mouse));
sprite = main_pick_sprite_bbox(window, &mouse, &is_in_graphic,&bbox);
if (!sprite || !is_in_graphic) return 0;
{
int is_in_graphic;
wimp_mousestr mouse;
main_sprite *sprite;
wimp_box bbox;
wimpt_noerr (wimp_get_point_info (&mouse));
sprite = main_pick_sprite_bbox(window, &mouse, &is_in_graphic, &bbox);
if (window->selection.count==0)
{ if (!sprite || !is_in_graphic) return NULL;
main_select_icon (window, sprite, &bbox, SI_SELECT);
window->selection.transbox = bbox;
window->selection.transsprite = sprite; /* Retain for later deselection */
return sprite;
}
if (window->selection.count==1)
{ main_sprite *sprite;
for (sprite = window->data->file.sprites; sprite != NULL; sprite = sprite->link)
{ if (sprite->flags & MSF_SELECTED)
break;
{ main_sprite *sp;
for (sp = window->data->file.sprites; sp != NULL; sp = sp->link)
{ if (sp->flags & MSF_SELECTED)
{ if ((window->selection.transsprite == NULL) || /* One permanently selected (by left/right click) */
(sprite == sp) /* Is the same one as already selected */)
return sp;
if ((sprite == NULL) || /* There is a transitory selection, but the user missed the target */
!is_in_graphic) /* by miles */
{
main_select_icon (window, window->selection.transsprite, &window->selection.transbox, SI_CLEAR);
return NULL;
}
if (sp == window->selection.transsprite)
{ /* Otherwise transfer temporary selection */
main_select_icon (window, window->selection.transsprite, &window->selection.transbox, SI_CLEAR);
main_select_icon (window, sprite, &bbox, SI_SELECT);
window->selection.transbox = bbox;
window->selection.transsprite = sprite;
return sprite;
}
}
}
return sprite;
}
return NULL;
......@@ -2211,7 +2234,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
break;
}
if (e->data.but.m.bbits & 4)
if (e->data.but.m.bbits & wimp_BLEFT)
{ main_sprite *sprite = main_pick_sprite (window, &e->data.but.m);
if (sprite != NULL)
......@@ -2224,6 +2247,7 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
}
sprwindow_new (sprite);
/* Double click clears the whole selection */
main_clear_selection (window, 0, SI_CLEAR);
if (main_current_options.tools.show_tools)
toolwindow_display (FALSE);
......@@ -2244,25 +2268,34 @@ static void spritefile_event_handler (wimp_eventstr *e, void *handle)
if (sprite && is_over_graphic && (sprite->flags & MSF_SELECTED)) break;
if (sprite == NULL || !is_over_graphic)
{ main_clear_selection (window, 0, SI_CLEAR);
{ /* Left click in no man's land clears the selection */
main_clear_selection (window, 0, SI_CLEAR);
break;
}
if (window->selection.count==0)
{ main_select_icon (window, sprite, &rds.box, SI_SELECT);
{ /* First (left) click on a sprite */
main_select_icon (window, sprite, &rds.box, SI_SELECT);
break;
}
if (!(sprite->flags & MSF_SELECTED))
{ main_clear_selection (window, 0, SI_CLEAR);
{ /* Left click on a sprite that is not currently selected clears the old
* selection and makes this one sprite the only member of the new selection */
main_clear_selection (window, 0, SI_CLEAR);
main_select_icon (window, sprite, &rds.box, SI_SELECT);
break;
}
}
else
{ /* else right click */
{ /* else right click toggles the selected sprite only */
if (sprite && is_over_graphic)
{ /* Force clear any transitory selection, so menu click then adjust results in
* a net selection */
if (window->selection.transsprite != NULL)
main_select_icon (window, window->selection.transsprite, &window->selection.transbox, SI_CLEAR);
main_select_icon (window, sprite, &rds.box, SI_TOGGLE);
}
}
}
else if (e->data.but.m.bbits & (wimp_BDRAGLEFT | wimp_BDRAGRIGHT))
......
......@@ -939,7 +939,7 @@ static void insdeltool_click (main_window *window, wimp_mousestr *mpos)
{ ftracef0 ("insdeltool_click\n");
if ((mpos->bbits & 4) && window->data->sprite.sprite == insdel_sprite)
if ((mpos->bbits & wimp_BLEFT) && window->data->sprite.sprite == insdel_sprite)
/* only SELECT in appropriate window */
{ int hit = (insdel_pending>>30)&3;
sprite_area **sarea = &insdel_sprite->file->spritearea;
......@@ -1498,7 +1498,7 @@ void menus_sprite_handler (void *handle, char *hit)
columns = dbox_getnumeric (d, d_Adjust_Cols);
rows = dbox_getnumeric (d, d_Adjust_Rows);
wimpt_noerr (wimp_get_point_info (&mouse_str));
adjust = (mouse_str.bbits & 1) != 0;
adjust = (mouse_str.bbits & wimp_BRIGHT) != 0;
switch (i)
{ case d_Adjust_Ok:
......
......@@ -2741,7 +2741,7 @@ static void create_event (main_window *window, wimp_i i)
ftracef0 ("create_event\n");
wimpt_noerr (wimp_get_point_info (&mouse_str));
adjust = (mouse_str.bbits & 1) != 0;
adjust = (mouse_str.bbits & wimp_BRIGHT) != 0;
ftracef0 ("create_event\n");
switch (i)
......
......@@ -29,6 +29,7 @@
#include <math.h>
#include <signal.h>
#include <swis.h>
#include "Global/OsBytes.h"
#include "bbc.h"
#include "flex.h"
......@@ -306,7 +307,7 @@ static void tabledriven_null (main_window *window, wimp_mousestr *mpos)
int point, coord, x, y;
ftracef0 ("tabledriven_null\n");
if ((mpos->bbits & 1) == 0) /* has adjust been released? */
if ((mpos->bbits & wimp_BRIGHT) == 0) /* has adjust been released? */
sprite->toolspace [0] = sprite->toolspace [0] & 0xFF;
/* then clear to just state */
ftracef2 ("0x%X->toolspace [0]: 0x%X\n", sprite, sprite->toolspace [0]);
......@@ -607,7 +608,7 @@ static void pixelpaint_splot (main_window *window, wimp_mousestr *mpos)
{ main_sprite *sprite = window->data->sprite.sprite;
int x, y, ncolours = colours_count (sprite),
gcol = mpos->bbits == 1? sprite->gcol2: sprite->gcol;
gcol = mpos->bbits == wimp_BRIGHT ? sprite->gcol2 : sprite->gcol;
/* adjust clears to 0, select uses current gcol */
ftracef2 ("pixelpaint_splot: sprite %.12s, gcol 0x%X\n",
......@@ -815,7 +816,7 @@ static void parallelogramoutlinepaint_null (main_window *window,
int point, coord, x, y;
ftracef0 ("parallelogramoutlinepaint_null\n");
if ((mpos->bbits & 1) == 0) /* has adjust been released? */
if ((mpos->bbits & wimp_BRIGHT) == 0) /* has adjust been released? */
sprite->toolspace [0] = sprite->toolspace [0] & 0xFF;
/* then clear to just state */
ftracef2 ("0x%X->toolspace [0]: 0x%X\n", sprite, sprite->toolspace [0]);
......@@ -877,7 +878,7 @@ static void parallelogramoutlinepaint_click (main_window *window,
int x, y;
tools_mouse_to_pixel (window, mpos, &x, &y);
if (mpos->bbits & 1) /* adjust: select a point and move it */
if (mpos->bbits & wimp_BRIGHT) /* adjust: select a point and move it */
{ int point = 0, bdist = INT_MAX, i;
for (i = 1; i <= (sprite->toolspace [0] & 0xFF); i++)
......@@ -1239,7 +1240,7 @@ static void floodfillpaint_click (main_window *window,
Escape_Pressed = FALSE;
old_escape_handler = signal (SIGINT, &Escape_Handler);
ftracef0 ("Enable Escape events\n");
wimpt_noerr (os_byte (229, (r1 = 0, &r1), (r2 = 0, &r2)));
wimpt_noerr (os_byte (OsByte_RW_EscapeKeyEffects, (r1 = 0, &r1), (r2 = 0, &r2)));
ftracef4 ("FloodFill: width %d, height %d, mask %d, mode %d\n",
sin.width, sin.height, sin.mask, sin.mode);
......@@ -1282,7 +1283,7 @@ static void floodfillpaint_click (main_window *window,
}
}
ftracef0 ("disable Escape events\n");
wimpt_noerr (os_byte (229, (r1 = 1, &r1), (r2 = 0, &r2)));
wimpt_noerr (os_byte (OsByte_RW_EscapeKeyEffects, (r1 = 1, &r1), (r2 = 0, &r2)));
/*Replace escape handler*/
(void) signal (SIGINT, old_escape_handler);
visdelay_end ();
......
......@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <swis.h>
/*From OSLib*/
#include "os.h"
......@@ -85,7 +86,7 @@ static void m_assert (char *file, int line, char *msg)
sprintf (error.errmess, "%s,%d: Assertion failure: %s",
file, line, msg);
os_swi1 (0x2B /*OS_GenerateError*/, &error);
os_swi1 (OS_GenerateError, &error);
}
/*------------------------------------------------------------------------*/
static void Check (char *file, int line)
......
......@@ -152,7 +152,6 @@ typedef enum
#define MW_SELDRAGRIGHT 1
#define MW_SELSAVING 2
#define MW_SELSAVEBYDRAG 4
typedef struct main_window
{
struct main_window *link;
......@@ -163,6 +162,8 @@ typedef struct main_window
{
int count;
int flags;
wimp_box transbox; /* Holds menu selected temporary */
main_sprite *transsprite;
} selection;
} main_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