Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorLayout::ILayoutSource Class Referenceabstract

Abstract producer of LayoutPreview values. More...

#include <phosphor-layout-api/include/PhosphorLayoutApi/ILayoutSource.h>

Inheritance diagram for PhosphorLayout::ILayoutSource:
[legend]

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< LayoutPreviewavailableLayouts () 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)
 

Detailed Description

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:

  1. availableLayouts — enumerate everything the source can show
  2. previewAt — produce a fully-realised preview for one entry

The 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.

Note
Per-source contract details:
  • Manual sources (e.g. ZonesLayoutSource) ignore windowCount and canvas — authored zones have a fixed shape.
  • Autotile sources (e.g. AutotileLayoutSource) honour windowCount (they re-run the algorithm at that count) but currently ignore canvas (algorithms emit relative zones independent of canvas size).

Constructor & Destructor Documentation

◆ ~ILayoutSource()

PhosphorLayout::ILayoutSource::~ILayoutSource ( )
override

◆ ILayoutSource()

PhosphorLayout::ILayoutSource::ILayoutSource ( QObject *  parent = nullptr)
explicitprotected

Member Function Documentation

◆ availableLayouts()

virtual QVector< LayoutPreview > PhosphorLayout::ILayoutSource::availableLayouts ( ) const
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.

◆ contentsChanged

void PhosphorLayout::ILayoutSource::contentsChanged ( )
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.

◆ previewAt()

virtual LayoutPreview PhosphorLayout::ILayoutSource::previewAt ( const QString &  id,
int  windowCount = DefaultPreviewWindowCount,
const QSize &  canvas = {} 
)
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().

Note
Non-const because implementations are expected to populate a preview cache here (re-running a scripted algorithm on every picker redraw would be prohibitive). Callers holding a 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.


The documentation for this class was generated from the following file: