SVScratchpadMonitorImpl.mesa
Last edited by Bier on August 19, 1984 7:34:23 pm PDT
Copyright © 1984 by Xerox Corporation. All rights reserved.
Contents: A flexible setup, suggested by Scott McGregor, for processing mouse input as fast as you can (but no faster). I will use it to synchronize my mouse point processing with the mousepoint. If the processing algorithms become faster, this procedure will still do the right thing.
DIRECTORY
Menus,
Process,
Scratchpad2d,
Scratchpad2dUser,
SV2d,
SVInputMonitor,
SVInterfaceTypes,
SVScratchpadMonitor,
SVViewerTool,
ViewerClasses;
SVScratchpadMonitorImpl: MONITOR
IMPORTS Process, Scratchpad2d, Scratchpad2dUser
EXPORTS SVScratchpadMonitor =
BEGIN
MouseButton: TYPE = Menus.MouseButton;
Point2d: TYPE = SV2d.Point2d;
ScratchpadData: TYPE = SVInterfaceTypes.ScratchpadData;
Viewer: TYPE = ViewerClasses.Viewer;
globalProcess: PROCESSNIL;
screenCoords: Point2d;
clickAtom: ATOM;
spData: ScratchpadData ← NIL;
globalNew: BOOLFALSE;
NewMotion: PUBLIC ENTRY PROC [pt: Point2d, atom: ATOM, scratchpadData: ScratchpadData] = {
globalNew ← TRUE;
screenCoords ← pt;
spData ← scratchpadData;
clickAtom ← atom;
IF globalProcess = NIL THEN Process.Detach[globalProcess ← FORK Painter];
};
Painter: PROC = {
WHILE New[] DO
Dispatch[screenCoords, clickAtom, spData];
ENDLOOP;
};
New: PUBLIC ENTRY PROC RETURNS [x: BOOL] = {
x ← globalNew;
globalNew ← FALSE;
IF NOT x THEN globalProcess ← NIL; -- no mouse action. Let process die.
};
Dispatch: PROC [controlPoint: Point2d, atom: ATOM, scratchpadData: ScratchpadData] = {
SELECT atom FROM
$MOVE => {
IF scratchpadData.mode = drawLin THEN Scratchpad2d.MoveLinPoint[controlPoint, scratchpadData]
ELSE Scratchpad2d.MoveRevoPoint[controlPoint, scratchpadData];
};
$MOVESTART => {
IF scratchpadData.mode = drawLin THEN Scratchpad2d.MoveLinStart[controlPoint, scratchpadData]
ELSE Scratchpad2d.MoveRevoStart[controlPoint, scratchpadData];
};
$MOVEEND => {
self: Viewer ← scratchpadData.scratchViewerData.scratchpad;
Scratchpad2dUser.DrawSceneButton[self, scratchpadData.scratchViewerData, red, FALSE, FALSE]
};
ENDCASE;
};
END.