Bloc is a low-level UI infrastructure & framework for Pharo.
The project can be loaded as usual via Metacello, using the BaselineOfBloc specification. To copy/paste a loading script. Use the following script to install stable Bloc in stable Pharo:
Metacello new
baseline: 'Bloc';
repository: 'github://pharo-graphics/Bloc:master/src';
loadYou can replace master by:
- dev to work on the development branch
- v3.0.0 to load a released version
Add this project to your Baseline with:
spec baseline: 'Bloc' with: [ spec repository: 'github://pharo-graphics/Bloc:master/src' ].Bloc is built on four central abstractions:
BlElement: The fundamental visual building block. Elements are organized in a scene tree (parents, children). Each element has geometry (rectangle, circle, polygon), styling (background, border, opacity), event handlers, and layout constraints.BlSpace: Represents an active window or surface. A space owns the root of the scene graph (space root).BlHost: Bridges a space to the operating system or windowing backend (e.g. SDL3, OSWindow, Morphic, or Headless for tests).- Pulse Process: Each opened space is driven by a background host process that continuously runs frame cycles (events, tasks, layout, rendering).
space := BlSpace new.
space extent: 400 @ 300.
box := BlElement new
extent: 150 @ 150;
background: Color red;
border: (BlBorder paint: Color darkGray width: 2);
yourself.
space root addChild: box.
space open.The guides are arranged in recommended reading order:
- Getting Started — Visual basics: elements, geometry, styling, and basic events.
- Concurrency and Synchronization — The host pulse loop, frame phases, and the
settle&defer:synchronization API. - Building Non-Blocking UIs — Practical patterns for background workers, futures, progress feedback, and data streams.
- Layout and Constraints — Size policies, layout facets, why
position:is a request, and reacting to a layout without looping. - Working with Text —
BlTextElement, what it does not do (wrapping, line breaks), and recipes: lines, wrapping, ellipsis. - Graphical Patterns: Zoom, Pan and Fit — Transformations and the patterns to zoom around the mouse, pan with the mouse and fit a content in a window.
- Overlays: Toolbars, Legends, Tooltips and Pop-ups — Elements above the content: anchoring to a corner, a tooltip after a delay, a pop-up kept inside the window, and not taking the mouse.
- Testing Interactions and Drawing — Headless host, synthetic mouse events (
fireEvent:vsdispatchEvent:) and checking pixels. - Troubleshooting — Symptoms and explanations, including the debugger that freezes the windows.
- Using Bloc in a Spec Presenter — Showing a Bloc space in a Spec window with
SpBlSpaceInMorphPresenter. - About Mouse Events — Event dispatching: enter/leave vs over/out bubbling.
- Understanding Scene Graph Attachment — Working with
BlElement >> #onAddedToSceneGraph. - History and Presentations — Evolution of Bloc and recorded talks.
These pages can also be browsed inside Pharo: World Menu > Help > Documentation Browser > Bloc/doc.
- A Simple Memory Game Booklet: A step-by-step tutorial building a complete memory game in Bloc (Square Bracket Associates).
- Booklet-Graphics: The broader Pharo graphics booklet covering Athens, geometry, and graphical pipelines.
Several options:
- Open the Demo browser via Pharo IDE -> World Menu -> Library -> Bloc -> Bloc demo browser
- Browse Bloc's
-Examplespackages - Browse related projects that use Bloc such as Toplo, BlocBenchs, Pyramid, Coypu.
Want to write us? you are welcome! you can either:
- Join the mailing-list lse-openbloc@inria.fr from http://sympa.inria.fr
- Chat via Discord in the #bloc channel of the Pharo server
We describe our contribution workflow & branch name convention in this wiki page.
This code is licensed under the MIT license.