WorldState
Last updated at 10:11 am UTC on 28 May 2022
What is the responsibility of WorldState?
The class WorldState has the responsibility to implement some or all of the world functions for a PasteUpMorph object which plays the role of a world.
This is the case if the PasteUpMorph object answers the message
isWorldMorph
with true.
The #isWorldMorph message is implemented as
^ worldState notNil
Such a PasteUpMorph object then has a WorldState object.
Other PasteUpMorph instances do not have a WorldState instance.
For example BookMorphs use PasteUpMorphs as pages. The pages morphs do have nil for the worldstate variable.
A world knows its hands, bounds and a so called step list.
The step list keeps the morphs which need to be animated. To get into this list a morph has to register itself with the world.
Each morph is steppable. The world object regularily calls the #step method.
The world is responsible for displaying morphs.
- Morphs never directly draw themselves.
- They post requests for redisplay which are collected by the world.
- These requests are optimized and then performed by calling the morphs' drawOn: methods.
The world knows how often this should happen at most. Between each redisplay, all events of all hands are processed.
Note:
A WorldState object responds to the messages
- listOfSteppingMorphs
- runStepMethodsIn:
In the stepList the submorphs which need regularly the message send step are kept.
See also
When are the deferred UI messages processed?
How do I set the Morph stepping interval?_____
See also
Drawing
Morphic as a simulation framework.
Example of message dispatching, the number in square brackets is the oop.
(The output was generated by using #traceRM:levels: of BabySRE (SRE Execution Tracer).
1 [3921] : MyEllipseMorph >> mouseDown: {[3921]a MyEllipseMorph}
2 [3921] : MyEllipseMorph >> handleMouseDown:
3 [3272] : MouseButtonEvent >> sentTo:
4 [3921] : MyEllipseMorph >> handleEvent:
5 [1549] : MorphicEventDispatcher >> dispatchMouseDown:with:
6 [1549] : MorphicEventDispatcher >> dispatchEvent:with:
7 [3921] : MyEllipseMorph >> processEvent:using:
8 [1549] : MorphicEventDispatcher >> dispatchMouseDown:with:
9 [1549] : MorphicEventDispatcher >> dispatchEvent:with:
10 [1763] : PasteUpMorph >> processEvent:using:
11 [1763] : PasteUpMorph >> processEvent:using:
12 [1763] : PasteUpMorph >> processEvent:
13 [1869] : HandMorph >> sendEvent:focus:clear:
14 [1869] : HandMorph >> sendMouseEvent:
15 [1869] : HandMorph >> handleEvent:
16 [1869] : HandMorph >> processEvents
17 [3942] : WorldState >> doOneCycleNowFor:
18 [2934] : Array >> do:
19 [3942] : WorldState >> handsDo:
20 [3942] : WorldState >> doOneCycleNowFor:
21 [3942] : WorldState >> doOneCycleFor:
22 [1763] : PasteUpMorph >> doOneCycle
23 [2445] : Project class >> spawnNewProcess
24 [284] : BlockContext >> newProcess
See also
World PasteUpMorph object (data structure)