ILayoutSource adapter wrapping an ITileAlgorithmRegistry. More...
#include <phosphor-tiles/include/PhosphorTiles/AutotileLayoutSource.h>
Public Member Functions | |
| AutotileLayoutSource (PhosphorTiles::ITileAlgorithmRegistry *registry, QObject *parent=nullptr) | |
| Construct over a borrowed algorithm registry. | |
| ~AutotileLayoutSource () override | |
| QVector< PhosphorLayout::LayoutPreview > | availableLayouts () const override |
| Enumerate every layout this source can render. | |
| PhosphorLayout::LayoutPreview | previewAt (const QString &id, int windowCount=PhosphorLayout::DefaultPreviewWindowCount, const QSize &canvas={}) override |
id must be in the form "autotile:<algorithmId>" — returns an empty preview otherwise. | |
| void | invalidateCache () |
| Drop any cached previews — next query re-runs the algorithms. | |
Public Member Functions inherited from PhosphorLayout::ILayoutSource | |
| ~ILayoutSource () override | |
Additional Inherited Members | |
Signals inherited from PhosphorLayout::ILayoutSource | |
| void | contentsChanged () |
| Emitted whenever the set of layouts this source reports has changed (entries added, removed, or mutated — e.g. | |
Protected Member Functions inherited from PhosphorLayout::ILayoutSource | |
| ILayoutSource (QObject *parent=nullptr) | |
ILayoutSource adapter wrapping an ITileAlgorithmRegistry.
Implements PhosphorLayout::ILayoutSource so editor / settings / overlay code can render autotile-algorithm previews uniformly with manual zone previews from PhosphorZones::ZonesLayoutSource. Both adapt to the same LayoutPreview shape, so consumers branch on LayoutPreview::isAutotile rather than on which concrete source they hold.
Caches previews keyed on (algorithmId, windowCount) so repeated queries (typical for the layout-picker UI) don't re-execute scripted (JS) algorithms. The cache is invalidated on the registry's unified ILayoutSourceRegistry::contentsChanged signal (covering algorithm register/unregister and preview-params changes), at which point the source also emits contentsChanged.
Borrows the registry — caller owns it and must keep it alive for the source's lifetime. Source is non-copyable (inherited from ILayoutSource).
|
explicit |
Construct over a borrowed algorithm registry.
Composition roots (daemon, editor, settings, tests) create their own AlgorithmRegistry instance and thread it here. Null is tolerated (source returns empty) — matches ZonesLayoutSource's discipline.
|
override |
|
overridevirtual |
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.
Implements PhosphorLayout::ILayoutSource.
| void PhosphorTiles::AutotileLayoutSource::invalidateCache | ( | ) |
Drop any cached previews — next query re-runs the algorithms.
Called automatically on registry changes; exposed publicly so tests / advanced callers can trigger an explicit flush.
|
overridevirtual |
id must be in the form "autotile:<algorithmId>" — returns an empty preview otherwise.
windowCount number of windows to render the algorithm with. canvas ignored at this stage; algorithms produce relative zones independent of canvas size.
Implements PhosphorLayout::ILayoutSource.