Toplo is a widget library on top of Bloc.
Spec is a Pharo library for describing user interfaces. You describe a UI by composing the "presenters" and by connecting them via block closures.
More concretely, a Spec UI is a tree of SpPresenter, that is opened in the context of an application (SpApplication) that, among others, indicates what is the backend.
Our backend (SpToploBackend) provides the adapters (hierarchy of SpToploAdapter) to make the Toplo widgets to act as the tree of presenters describe.
Other Spec backends are:
- Morphic (the default)
- GTK
The project can be loaded as usual via Metacello, using the BaselineOfSpecToplo specification. To copy/paste a loading script, see this wiki page.
When developing Spec-Toplo, you should run two sets of test suites:
- Toplo-specific backend tests: Packages matching
Spec-Toplo*-Tests(Spec-Toplo-Tests,Spec-Toplo-Backend-Tests), which test Toplo adapters, widgets, and synchronization directly. - Spec2 generic contract tests: Package
Spec2-Backend-Tests(SpButtonAdapterTest,SpLabelAdapterTest,SpBoxLayoutAdapterTest, etc.). These verify thatSpToploBackendconforms to the upstream Spec2 contract.
"Run both suites in DrTests or via Smalltalk script:"
(TestRunner runPackages: {
'Spec-Toplo-Tests'.
'Spec-Toplo-Backend-Tests'.
'Spec2-Backend-Tests' })Generic Spec tests are parameterized by Bloc host. By default, they run exclusively on the fast Headless host to avoid stealing focus or opening OS windows during development.
You can toggle whether tests run headless-only or across all available hosts (Headless, SDL3, SDL2, Morphic) in two ways:
Open Settings Browser (World Menu > System > Settings), navigate to:
Bloc > Hosts for parameterized tests
- Headless host only (Fast) (Default): Runs tests headlessly in background.
- All available hosts: Tests the matrix against all registered hosts (including real OS windows).
"Run fast on headless host only (default)"
BlParameterizedHostTest testHostsMode: #headlessOnly.
"Run full matrix across Headless, SDL2, and Morphic"
BlParameterizedHostTest testHostsMode: #allAvailable.To run or debug a presenter with the Toplo backend, assign an application configured with #Toplo:
app := StPharoApplication new.
app useBackend: #Toplo.
presenter := MyPresenter new.
presenter application: app.
presenter open.Tip: Omitting
presenter application: appopens the presenter with the default Morphic backend, enabling side-by-side visual and behavioral comparisons.
When diagnosing layout, event, or styling issues, navigate between Spec presenters and Toplo widgets:
"Retrieve the Toplo adapter from the presenter"
adapter := presenter adapter. "Answers an SpToplo*Adapter"
"Retrieve the root BlElement / To* widget"
widget := presenter adapter widget.
"Inspect layout constraint resizers vs. actual computed geometry bounds"
widget constraints horizontal resizer. "e.g. Match parent, Exact 200, Fit content"
widget bounds asRectangle.To quickly close temporary spaces opened during interactive debugging in the Playground, evaluate Bloc closeSpaces.
For the underlying Bloc concurrency model, testing, and layout mechanics, refer to the documentation in the Bloc repository:
- Concurrency and Synchronization: The host pulse loop,
#settle,#deferAndSettle:, and pulse process safety. - Testing and Simulating Interactions: Programmatic event simulation with
BlEventSimulator. - Layout and Constraints: Measurement passes, resizers, and layout events.
GitHub Actions runs on every push and pull request. The workflows are in .github/workflows:
ci.ymlloads the project in a new image and runs the minimal tests (.ci.ston) on Pharo 14 and Pharo 15.full-tests.ymlruns the broader test set (.SpecBackendTests.ston) on the same Pharo versions. Some of these tests still fail, which is why they run separately.
Each run packages the image it tested, so you can download it and debug locally. The package contains:
Spec-Toplo-Pharo14.image(orPharo15) and its.changesfile- the
.sourcesfile of Pharo pharo.version, which contains140for Pharo 14 and150for Pharo 15
There are three kinds of artefacts:
- Action artefacts are saved on every run, including when the tests fail. Open the run from the Actions tab, then download
Spec-Toplo-Pharo14orSpec-Toplo-Pharo15from its Artifacts section. GitHub keeps them for a limited time. - Continuous artefacts are published on every push to
dev. They are attached to thecontinuouspre-release on the Releases page, asSpec-Toplo-Pharo14.zipandSpec-Toplo-Pharo15.zip. Each push replaces the previous ones. The pre-release is published even when the tests fail, so check the CI run for the test results. - Release artefacts are attached to every GitHub release when you create or edit it. The release job runs only when the build succeeds, so failing builds are not attached to releases.
To debug a downloaded image, unzip the package, then open the .image file with the Pharo VM of the matching version.
We describe our contribution workflow & branch name convention in this wiki page.
This code is licensed under the MIT license.