Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
LayoutPreview.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
8
9#include <QRectF>
10#include <QString>
11#include <QVector>
12
13#include <optional>
14
15namespace PhosphorLayout {
16
20inline constexpr int DefaultPreviewWindowCount = 4;
21
44{
50 static constexpr int UnlimitedZoneCount = 0;
51
59 QString id;
60
62 QString displayName;
63
65 QString description;
66
69 QVector<QRectF> zones;
70
75 QVector<int> zoneNumbers;
76
83 int zoneCount = 0;
84
91 bool recommended = true;
92
99
105
109 QString sectionKey;
112
116 bool autoAssign = false;
117
129 bool isSystem = false;
130
137
143 std::optional<AlgorithmMetadata> algorithm;
144
153 int masterCount = 1;
154
160 bool isAutotile() const noexcept
161 {
162 return algorithm.has_value();
163 }
164
176 bool isValid() const noexcept
177 {
178 // Negative zoneCount has no meaning in either bounded or unlimited
179 // semantics — reject it explicitly so a stray negative doesn't
180 // sneak past the > 0 bounded check below.
182 return false;
183 }
184 if (zoneCount > UnlimitedZoneCount && zones.size() != zoneCount) {
185 return false;
186 }
187 if (!zoneNumbers.isEmpty() && zoneNumbers.size() != zones.size()) {
188 return false;
189 }
190 return true;
191 }
192};
193
194} // namespace PhosphorLayout
Definition AlgorithmMetadata.h:10
AspectRatioClass
Screen aspect-ratio classification.
Definition AspectRatioClass.h:22
@ Any
Suitable for all aspect ratios (default)
constexpr int DefaultPreviewWindowCount
Reference window count used by ILayoutSource::previewAt when the caller doesn't specify one.
Definition LayoutPreview.h:20
Renderer-ready snapshot of one layout entry (manual zone layout OR autotile algorithm result).
Definition LayoutPreview.h:44
AspectRatioClass aspectRatioClass
Aspect-ratio class hint propagated up from the layout source.
Definition LayoutPreview.h:104
bool isScrollingTemplate
True when this preview backs a native scrolling TEMPLATE (the third card family beside manual layouts...
Definition LayoutPreview.h:136
QString description
Optional longer description shown in tooltips / detail views.
Definition LayoutPreview.h:65
int zoneCount
Number of zones in the preview.
Definition LayoutPreview.h:83
bool isSystem
True when the layout is "system-owned" and should render with a lock badge in the picker.
Definition LayoutPreview.h:129
bool isValid() const noexcept
Structural consistency check.
Definition LayoutPreview.h:176
QString sectionKey
Section-grouping metadata for the picker UI.
Definition LayoutPreview.h:109
int sectionOrder
Definition LayoutPreview.h:111
bool autoAssign
True when new windows should auto-fill the first empty zone (manual layouts only — the autotile equiv...
Definition LayoutPreview.h:116
qreal referenceAspectRatio
For fixed-geometry manual layouts: the reference aspect ratio the zones were authored for.
Definition LayoutPreview.h:98
QString sectionLabel
Definition LayoutPreview.h:110
std::optional< AlgorithmMetadata > algorithm
Optional autotile algorithm metadata.
Definition LayoutPreview.h:143
QVector< int > zoneNumbers
Per-zone display label.
Definition LayoutPreview.h:75
static constexpr int UnlimitedZoneCount
Sentinel for zoneCount meaning "no hard limit on window count" (typical for unlimited autotile algori...
Definition LayoutPreview.h:50
bool isAutotile() const noexcept
True when this preview backs an autotile algorithm (equivalent to algorithm.has_value()).
Definition LayoutPreview.h:160
int masterCount
The master-window count zones was actually computed with.
Definition LayoutPreview.h:153
QString displayName
Human-readable name for the picker UI (i18n'd by the source).
Definition LayoutPreview.h:62
QVector< QRectF > zones
Zone rectangles in 0.0–1.0 relative coordinates.
Definition LayoutPreview.h:69
bool recommended
True when the layout matches the rendering canvas's aspect ratio well enough to be a "recommended" pi...
Definition LayoutPreview.h:91
QString id
Stable identifier for this layout entry.
Definition LayoutPreview.h:59