-
Notifications
You must be signed in to change notification settings - Fork 0
Statemachine
Each module has a Statemachine with several states. Any user interaction is detected by and processed within the Statemachine. Inputs can come from either from KEYS or MOUSE, and are fetched using Case Matches. When an event corresponds to the Case Match in the active State in the Statemachine, the code block within the given state is executed.
Conceptually, the hierarchy is as follows:
- Statemachine
- States ('Start, 'End, 'Point, etc.)
- Case matches (Case MouseDown(), Case _, Case KeyDown etc.)
- States ('Start, 'End, 'Point, etc.)
In case the module needs to react to a mouse click and store the coordinate point in a value: Case MouseDown(p, MouseButtonLeft, _) :: tail => {point = p}. In //Case MouseDown// a mouse click is registered, and the coordinate is given to the variable //p//. Inside the code block p is passed on to a variable //Point//, which can be accessed from anywhere within the module.
Case matches can be used to do many different things. This case is a part of the Rectangle module, in which a MouseUp triggers this code:
- case MouseUp(point, _, _):: tail => {
- points = points :+ point
- if(points.length == 1) {
- Goto('SecondPoint)
In this example a point is added to a list of points. If there is already a points in the list, it means that the first corner of the rectangle has already been defined. In this case //Goto('SecondPoint) proceeds to execute the State SecondPoint, in which the rectangle is finalized.
- Home - Overview of Siigna
- About - Why we made Siigna
-
Siigna main - The "heart" of Siigna
- Architecture
- Action - Remote and local changes
- Event - How Siigna communicates
- Shape - The figures and geometry
-
Siigna module - The "brain" of Siigna
- Module - How a module is defined
- License - It's open source!
- Contact - Get in touch