Bifrost abstracts input devices used in interaction in a general interaction model. The input device is typically a pointing device like a mouse. The model is defined in pattern InteractionHandler of the canvas. InteractionHandler defines a series of virtual attributes and a general interaction loop. The usage of the interaction handler is to execute an instance of a specialization of InteractionHandler with some of the virtual attributes further bound. The attributes are:
In addition to these attributes the handler provides three support functions:
The action part of an instance of the pattern InteractionHandler performs the following sequence of code:
(# do Initialize; Loop and call Motion, ButtonPress, ButtonRelease, KeyPress or KeyRelease, depending on user action, until TerminateCondition returns True; Terminated; #)
As the reader migth have noticed, the interaction handler, when excuted, temporarily replaces the event handler of the canvas and processes all events until terminated.
The InteractionHandler pattern is used to implement the interaction operations of the shapes. The following is an example of how the feedback for InteractiveCreate might be implemented for the predefined shape LineShape, using an InteractionHandler:
RubberLine: InteractionHandler (# mousePoint, anchorPoint: @Point; (* Device coords *) themodifier: @modifier; (* the modifier used for constrains *) stopinteraction: @boolean; (* stop when true *) x,y: @integer; (* temporary variables *) Initialize:: (# do (anchorpoint, mousePoint) -> immediateLine #); Motion:: (# do (anchorpoint, mousePoint) -> immediateLine; GetPointerLocation -> mousePoint; (if themodifier -> isModifierOn then (* constrain the angles *) (mousepoint.x-anchorpoint.x) -> abs -> x; (mousepoint.y-anchorpoint.y) -> abs -> y; (if y > x then (* constrain to vertical *) anchorpoint.x -> mousepoint.x else (* constrain to horizontal *) anchorpoint.y -> mousepoint.y if) if); (anchorpoint, mousePoint) -> immediateLine; #); ButtonPress:: (# do true -> stopinteraction #); TerminateCondition:: (# do stopinteraction -> res #); Terminated:: (# do (anchorpoint, mousePoint) -> immediateLine #); enter (anchorpoint, mousepoint, themodifier) exit mousepoint #);
The interaction obtained by the above handler works as follows: a rubberband line is spanned between the anchorpoint point and the pointer location, following the pointer movements. In case the modifier is on (e.g. Shift is down) then the angle of the line is constrained to multiples of 90 degrees. The interaction terminates when the pointer button is pressed again.
|The Bifrost Graphics System - Reference Manual||© 1991-2004 Mjølner Informatics||
[Modified: Monday October 16th 2000 at 13:43]