Page:
Themes
Pages
2D Drawing
2D Nodes
Code Edits
Code Services
Containers
Control Input
Engines
Exporting
File System Dock
Getting Started
Home
Input and Actions
Lisp Text
Live Pipelines
Painters
Playing a Game
Popups Menus and Dialogs
Popups and Dialogs
Project Manager
Projects
Render Targets
Resources
Saving Scenes
Scene Tree
Script Screen
Sessions
Signals
Status
The Debugger
The Editor
The REPL
Themes
Tweens
Undo and Redo
User Interface
Widgets
No results
3
Themes
dxtr edited this page 2026-10-20 00:28:25 +02:00
Table of Contents
Themes
A control draws with the items of themes, as Godot's do: colours, constants, fonts, font sizes, style boxes and icons, found by name in the control's own items, in the themes of the control and its ancestors, and in the default theme.
- Theme items are what a control draws with, by name: colours,
constants, fonts, font sizes, style boxes and icons, the kinds the type
theme-item-kindnames, whichcontrol-color,control-constant,control-font,control-font-size,control-style-boxandcontrol-iconfind. They look in the control's own items, whichsetfof them sets one by one,setfofcontrol-color-overridesand the rest all at once, or:color-overridesand the rest when making one; then in thecontrol-themeof the control and of its ancestors, nearest first; then indefault-theme, of which each session has its own. In each theme, a class's items come before those of the classes it inherits from, so an item forui:controlreaches every control, andtheme-item-nameslists those a class finds in a theme. An item no theme gives is an error, unless the lookup is given a default. - Themes are resources, saved in files of their own or with the
scenes that hold them.
make-instanceofthemetakes:colors,:constants,:fonts,:font-sizes,:style-boxesand:icons, each a list of(class name value ...)entries;theme-colorand the rest read an item andsetfit. Icons are images, made as the program runs at the display's scale, or SVG files' pathnames, whichcontrol-iconrasterizes at the scale of the control's window in its:font-color, as the default theme gives the file dialog's; a saved theme leaves them out, as a scene leaves out a control's own. Changing a theme or a style box draws and lays out again, at the next frame, the controls of the trees of the session it is changed in, so a game played in the editor's image changes its own and not the editor's; do it on the tree's thread. - Icons from SVG files: an
icon-setrasterizes SVG files for one window, aticon-set-scale, the window's, the shapes SVG's currentColor paints inicon-set-color, and makes them again as either changes, movingicon-set-generationon;svg-icongives a file's image at a size, andsvg-imagerasterizes one once. Each window keeps the icon sets its theme's SVG icons are rasterized in. An icon keeps its drawing, and is rasterized again for a canvas drawn at another scale, as a viewport zoomed in, so it is as sharp there as raster text, as Godot'sDPITextureicons are.icons-directoryholds Pyssel's icons that the default theme gives. cl-svgread reads the files and cl-svgread/ft2 rasterizes them. - Style boxes draw backgrounds. A
flat-style-boxfills its rectangle withstyle-box-background-color, draws a border inside its edges instyle-box-border-color, as wide on each side asstyle-box-border-width-leftand the rest say, all given at once by:border-width, and rounds its corners bystyle-box-corner-radius; it drawsstyle-box-expand-margin-leftand the rest past the rectangle it is given, all given at once by:expand-margin. Every style box has content margins, which keep content from its edges,style-box-content-margin-leftand the rest, all given at once by:content-margin; a side given its own takes that instead, as(make-instance 'ui:style-box :content-margin 4 :content-margin-left 8). Aline-style-boxdraws a line, as Godot's StyleBoxLine, which separators draw: across the top of its rectangle, or down its left edge withstyle-box-vertical, instyle-box-color,style-box-thicknessthick, reachingstyle-box-grow-beginbefore it andstyle-box-grow-endpast it.draw-style-boxdraws one in a draw method. A plainstyle-boxdraws nothing. - The default theme gives every item pyssel/ui's controls use, as
Godot's default theme has them: Inter as
:fontand JetBrains Mono as:code-font, at a:font-sizeof 16, in a light grey:font-color; the:panelof panels and panel containers, a dark grey at 60%; the separations of boxes and grids, 4 units; margin containers' margins, 0; and the scroll bars' translucent tracks and grabbers, which brighten under the pointer and as they are dragged. The two fonts, the fonts of Godot's editor, ship with pyssel/ui as variable fonts, so apf:font-variationof either gives its other weights.
A control class of your own draws with theme items, falling back on defaults it gives where no theme has them, and a theme may give them for it:
(sc:define-node swatch (ui:control)
()
(:tool t))
(defmethod s2d:draw ((swatch swatch) canvas)
(pyssel/2d:fill-rect canvas 0 0 (ui:control-width swatch) (ui:control-height swatch)
(ui:control-color swatch :swatch-color '(1 0.6 0.2))
:radius (ui:control-constant swatch :radius 4)))
(sc:call-in-tree *tree*
(lambda ()
(setf (ui:theme-color (ui:control-theme (screen *tree*)) 'swatch :swatch-color)
'(0.4 0.6 1))
(sc:add-child (screen *tree*)
(make-instance 'swatch :preset :center-left :preset-margin 16
:custom-minimum-width 40
:custom-minimum-height 40))))
It goes in the panels of User Interface, whose screen
finds the screen panel that holds their theme.
Getting started
The core
Drawing
Scenes
User interface
Games and the editor
- Playing a Game
- Projects
- The Editor
- The File System Dock
- The Script Screen
- The REPL
- The Debugger
- Lisp Text
- Code Services
- Project Manager
- Undo and Redo
- Exporting
The project