Abstract producer of LayoutPreview values. More...
#include <phosphor-layout-api/include/PhosphorLayoutApi/ILayoutSource.h>
Signals | |
| void | contentsChanged () |
| Emitted whenever the set of layouts this source reports has changed (entries added, removed, or mutated — e.g. | |
Public Member Functions | |
| ~ILayoutSource () override | |
| virtual QVector< LayoutPreview > | availableLayouts () const =0 |
| Enumerate every layout this source can render. | |
| virtual LayoutPreview | previewAt (const QString &id, int windowCount=DefaultPreviewWindowCount, const QSize &canvas={})=0 |
| Produce a fully-realised preview for one layout entry. | |
Protected Member Functions | |
| ILayoutSource (QObject *parent=nullptr) | |
Abstract producer of LayoutPreview values.
Implemented by phosphor-zones (manual zone layouts) and phosphor-tiles (autotile algorithms). Editor / settings / overlay code holds an ILayoutSource* and renders previews uniformly without branching on the underlying source.
Two-method contract:
availableLayouts — enumerate everything the source can showpreviewAt — produce a fully-realised preview for one entryThe split exists because manual layouts have a fixed shape (zones are authored, no parameters), while autotile previews depend on a window count and canvas size. Calling previewAt re-runs the algorithm at the requested window count; calling it on a manual layout is a thin lookup that ignores the parameter.
Sources are expected to be cheap to query — the layout-picker UI may call availableLayouts after every layout-set change, and previewAt once per visible row. Sources that need expensive work (e.g. running a JS algorithm) are expected to cache results internally and emit contentsChanged when their cached output becomes stale.
windowCount and canvas — authored zones have a fixed shape.windowCount (they re-run the algorithm at that count) but currently ignore canvas (algorithms emit relative zones independent of canvas size).
|
override |
|
explicitprotected |
|
pure virtual |
Enumerate every layout this source can render.
The returned previews are populated enough for the picker UI to render rows (id, displayName, aspect-ratio class, autotile flag, optional algorithm metadata). For autotile entries the zones field is populated with a default-window-count preview; consumers wanting a different count call previewAt with the entry's id.
Implemented in PhosphorLayout::CompositeLayoutSource, PhosphorTiles::AutotileLayoutSource, and PhosphorZones::ZonesLayoutSource.
|
signal |
Emitted whenever the set of layouts this source reports has changed (entries added, removed, or mutated — e.g.
a scripted algorithm registered, a layout file saved). Consumers refresh their local views on this signal. A CompositeLayoutSource forwards every child's contentsChanged, so callers can listen at the composite level and ignore the underlying sources.
|
pure virtual |
Produce a fully-realised preview for one layout entry.
id the LayoutPreview::id from availableLayouts windowCount for autotile entries, the window count to render the algorithm with. Ignored by manual sources (their zones are authored statically). Defaults to PhosphorLayout::DefaultPreviewWindowCount (4 — most picker thumbnails fit this nicely). canvas optional aspect-ratio + size hint. Sources that implement aspect-ratio filtering use this to set LayoutPreview::recommended; sources that don't ignore it. An empty QSize disables the hint.
Returns a default-constructed preview (empty id) when id is not known to this source. Caller checks result.id.isEmpty().
const ILayoutSource* cannot query previews — which matches the intent: querying a preview is an observable-effect operation on the source. Implemented in PhosphorLayout::CompositeLayoutSource, PhosphorTiles::AutotileLayoutSource, and PhosphorZones::ZonesLayoutSource.