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
56 QString id;
57
59 QString displayName;
60
62 QString description;
63
66 QVector<QRectF> zones;
67
72 QVector<int> zoneNumbers;
73
80 int zoneCount = 0;
81
88 bool recommended = true;
89
96
102
106 QString sectionKey;
109
113 bool autoAssign = false;
114
126 bool isSystem = false;
127
133 std::optional<AlgorithmMetadata> algorithm;
134
140 bool isAutotile() const noexcept
141 {
142 return algorithm.has_value();
143 }
144
156 bool isValid() const noexcept
157 {
158 // Negative zoneCount has no meaning in either bounded or unlimited
159 // semantics — reject it explicitly so a stray negative doesn't
160 // sneak past the > 0 bounded check below.
162 return false;
163 }
164 if (zoneCount > UnlimitedZoneCount && zones.size() != zoneCount) {
165 return false;
166 }
167 if (!zoneNumbers.isEmpty() && zoneNumbers.size() != zones.size()) {
168 return false;
169 }
170 return true;
171 }
172};
173
174} // namespace PhosphorLayout
Definition AlgorithmMetadata.h:10
AspectRatioClass
Screen aspect-ratio classification.
Definition AspectRatioClass.h:21
@ 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:101
QString description
Optional longer description shown in tooltips / detail views.
Definition LayoutPreview.h:62
int zoneCount
Number of zones in the preview.
Definition LayoutPreview.h:80
bool isSystem
True when the layout is "system-owned" and should render with a lock badge in the picker.
Definition LayoutPreview.h:126
bool isValid() const noexcept
Structural consistency check.
Definition LayoutPreview.h:156
QString sectionKey
Section-grouping metadata for the picker UI.
Definition LayoutPreview.h:106
int sectionOrder
Definition LayoutPreview.h:108
bool autoAssign
True when new windows should auto-fill the first empty zone (manual layouts only — the autotile equiv...
Definition LayoutPreview.h:113
qreal referenceAspectRatio
For fixed-geometry manual layouts: the reference aspect ratio the zones were authored for.
Definition LayoutPreview.h:95
QString sectionLabel
Definition LayoutPreview.h:107
std::optional< AlgorithmMetadata > algorithm
Optional autotile algorithm metadata.
Definition LayoutPreview.h:133
QVector< int > zoneNumbers
Per-zone display label.
Definition LayoutPreview.h:72
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:140
QString displayName
Human-readable name for the picker UI (i18n'd by the source).
Definition LayoutPreview.h:59
QVector< QRectF > zones
Zone rectangles in 0.0–1.0 relative coordinates.
Definition LayoutPreview.h:66
bool recommended
True when the layout matches the rendering canvas's aspect ratio well enough to be a "recommended" pi...
Definition LayoutPreview.h:88
QString id
Stable identifier for this layout entry.
Definition LayoutPreview.h:56