Creating a standalone app based on Glamorous Toolkit is as simple as opening an application specific window and closing the existing GT window. This can be achieved in just a few steps.
BlSpace
Object subclass: #BlSpace
uses: TBlEventTarget + TBlSpaceProperties + TBlDebug
instanceVariableNames: 'id host hostSpace extent position root resizable borderless dirtyAreas eventDispatcher eventListener eventRecorder mouseProcessor focusProcessor keyboardProcessor focusChain dragboard nextPulseRequested currentCursor session focused title fullscreen fullsize layoutError tasks time touchProcessor frame gestureProcessor elementsNeedingPaint elementsNeedingLayout telemetry reference elementsNeedingStyle elementsNeedingPropertiesComputation iconStencil'
classVariableNames: 'UniqueIdGenerator'
package: 'Bloc-Space'
is responsible for displaying a scene in a separate window. Users can customise window's title or extent. To spawn a window send BlSpace>>#show
show
"Open me in a window and show it to the user"
"delegate showing work to the Universe"
(BlParallelUniverse forHost: self host class) openSpace: self
to an instance of the space.
aSpace := BlSpace new
addChild: GtCreateStandaloneAppHowToGuide new helloWorldScene;
extent: 800@600;
title: 'Hello World'.
aSpace show
The Glamorous Toolkit comes with a GtWorld
BlSpace subclass: #GtWorld
instanceVariableNames: 'worldElement'
classVariableNames: ''
package: 'GToolkit-World-UI'
opened by default. When creating a standalone app based on GT we should close that window, which can be done in two steps.
In order to shutdown the process when a window is closed, we add a BlSpaceShutdownOnCloseListener
BlBasicEventHandler subclass: #BlSpaceShutdownOnCloseListener
instanceVariableNames: 'shouldSave'
classVariableNames: ''
package: 'Bloc-Space - Events'
as an event handler to a BlSpace
Object subclass: #BlSpace
uses: TBlEventTarget + TBlSpaceProperties + TBlDebug
instanceVariableNames: 'id host hostSpace extent position root resizable borderless dirtyAreas eventDispatcher eventListener eventRecorder mouseProcessor focusProcessor keyboardProcessor focusChain dragboard nextPulseRequested currentCursor session focused title fullscreen fullsize layoutError tasks time touchProcessor frame gestureProcessor elementsNeedingPaint elementsNeedingLayout telemetry reference elementsNeedingStyle elementsNeedingPropertiesComputation iconStencil'
classVariableNames: 'UniqueIdGenerator'
package: 'Bloc-Space'
. It should be removed before we close such spaces.
GtWorld allInstances do: [ :eachWorld | eachWorld removeShutdownListener ]
To close an opened window, it is enough to just send BlSpace>>#close
close
"Delegate closing work to the Universe"
(BlParallelUniverse forHost: self host class) closeSpace: self
to an intended space.
GtWorld allInstances do: [ :eachWorld | eachWorld close ]
Once the intended application window is opened and there are no more GT windows we can save the image (without quitting):
Smalltalk snapshot: true andQuit: false