Documentation
¶
Overview ¶
Package panemodal renders a modal inside an arbitrary rectangular box rather than over the whole screen, and puts the modal's mouse hit regions where the box actually is on screen.
A modal.Modal renders and registers its hit regions against the surface it is handed: coordinates run from (0,0) of that surface. Handed a pane, the modal has no idea the pane starts partway down the screen, so every region it registers is wrong by the pane's origin. Render fixes that by translating the regions the modal just registered by the box origin.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
Render draws m inside box on top of background (the pane's own content, rendered at box.W x box.H) and registers m's hit regions at their true screen positions. The result is exactly box.H lines of exactly box.W cells, ready to blit at (box.X, box.Y).
When the box is roomy the modal is centred in it with the pane's content dimmed around it. When the box is tight (see dimMarginX/dimMarginY) the modal fills the box and the pane's content is not shown at all.
handler may be nil, in which case no regions are registered. Note that modal.Modal.Render clears the handler's hit map, so the modal's regions are the only ones in it afterwards — anything the pane registered before this call is gone, exactly as it is for a full-screen modal.
func RenderFunc ¶
RenderFunc is Render for anything that draws itself into a given size and registers its hit regions on a handler — a modal.Modal, a filefind.Finder, a projectsearch.Search. draw is called with the box's own dimensions and with handler; whatever regions it registers are then translated by the box origin, so a surface that knows only its own coordinates still lands where it is drawn.
The compositing rules are Render's: a surface sized to its own content, centred with the pane dimmed around it, when the box has room for a readable margin; otherwise a second pass with fill set, which asks the surface to take the whole box, and no pane content behind it. The two passes are why draw must be cheap and free of side effects beyond its own layout — it may be called twice for one frame. The result is always exactly box.H lines of exactly box.W cells.
handler may be nil, in which case draw is called with nil and registers nothing. A surface that clears the handler (modal.Modal does) leaves the pane's earlier regions gone, exactly as a full-screen modal does; a surface that only adds to it leaves them in place, so hosts that care about ordering hand RenderFunc a scratch handler and merge its regions themselves.
Types ¶
type Box ¶
type Box struct {
X, Y, W, H int
}
Box is a rectangle in screen coordinates: the pane the modal is drawn into. The field names mirror the workspace pane layout's Box.