1 Popups and Dialogs
dxtr edited this page 2026-10-18 21:50:46 +02:00

Popups and Dialogs

An engine draws into popups too, windows on its own for menus, lists to choose from and tooltips, in the same frames as its window:

(let ((menu (pyssel:open-popup *engine* (pyssel:engine-window *engine*) 160 120
                               :rectangle '(20 10 80 24) :draw 'draw-menu :grab t)))
  …
  (pyssel:close-popup *engine* menu))

open-popup makes a popup of the given size on the engine's window, or on a popup open on it, and places it as cl-windowing's create-popup does, against a rectangle of the parent: by default below it, flipped or slid where it would not fit on the screen. Its :draw function is called as the engine's draw is, for each frame, with a render pass over the popup's texture, cleared to its :clear-color; meanwhile engine-frame-texture and engine-frame-scale are the popup's, which has the scale of the display it is on. :grab t makes it a menu, which takes the keyboard; :pointer-input nil a tooltip, which lets the pointer through. It returns the cl-windowing popup, which tells its size and where it went.

The popup's input reaches the engine's input functions as the window's does, cl-windowing:event-window telling them apart, and so does the :close of a popup the window system dismissed, as when the user clicked outside the program: close it then. close-popup closes a popup and the popups open on it, and engine-popups lists those open. Stopping the engine closes them all. An offscreen engine has no window to open popups on.

It draws into dialogs the same way: open-dialog makes a window of its own titled :title on the engine's window, or on a dialog open on it, which stays above it and opens over it, as cl-windowing's create-window makes one with :parent. With :modal t, the window it is made on takes no input that starts there until it closes. Its input reaches the input functions too, and so does its :close, when the user asks to close it. close-dialog closes it, with the popups and dialogs open on it, and engine-dialogs lists those open.