Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
ScrollingTemplate.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
6#include "phosphorzones_export.h"
7
8#include <QJsonObject>
9#include <QLatin1String>
10#include <QList>
11#include <QString>
12#include <QUuid>
13#include <QtGlobal>
14
15namespace PhosphorZones {
16
22inline constexpr qreal MinTemplateFraction = 0.05;
23
31inline constexpr int MaxTemplateColumns = 16;
32
39inline constexpr int DefaultWidthKindProportion = 0;
40inline constexpr int DefaultWidthKindFixed = 1;
41inline constexpr int DefaultWidthKindClientDecides = 2;
42inline constexpr int DefaultWidthKindPreset = 3;
43
49inline constexpr qreal FractionDedupeEpsilon = 0.01;
50
63struct PHOSPHORZONES_EXPORT ScrollingTemplateColumn
64{
67 qreal width = 0.5;
69 int display = 0;
70
71 bool operator==(const ScrollingTemplateColumn&) const = default;
72};
73
85namespace TemplateJsonKeys {
86inline constexpr QLatin1String Id{"id"};
87inline constexpr QLatin1String IsSystem{"isSystem"};
88inline constexpr QLatin1String SourcePath{"sourcePath"};
89} // namespace TemplateJsonKeys
90
127class PHOSPHORZONES_EXPORT ScrollingTemplate
128{
129public:
130 QUuid id;
131 QString name;
133 QString description;
134
137 QList<ScrollingTemplateColumn> columns;
138
141 int defaultColumnWidthKind = DefaultWidthKindPreset;
142 qreal defaultColumnWidthValue = 0.5;
143 int defaultColumnWidthPresetIndex = 1;
145 int defaultColumnDisplay = 0;
146
149 QList<qreal> presetColumnWidths;
151
156 bool isSystem = false;
161 bool hasSystemOrigin = false;
165 QString sourcePath;
166
167 bool isValid() const
168 {
169 return !id.isNull() && !name.isEmpty();
170 }
171
182 bool normalize();
183
189 static QList<qreal> normalizePresetList(QList<qreal> values);
190
191 QJsonObject toJson() const;
194 static ScrollingTemplate fromJson(const QJsonObject& json);
195
196 bool operator==(const ScrollingTemplate&) const = default;
197};
198
199} // namespace PhosphorZones
A scrolling screen's first-class sizing template.
Definition ScrollingTemplate.h:128
QList< qreal > presetWindowHeights
Definition ScrollingTemplate.h:150
QUuid id
Definition ScrollingTemplate.h:130
QList< ScrollingTemplateColumn > columns
Seed blueprint, ordered left to right.
Definition ScrollingTemplate.h:137
QString name
Definition ScrollingTemplate.h:131
bool isValid() const
Definition ScrollingTemplate.h:167
static ScrollingTemplate fromJson(const QJsonObject &json)
Parses and normalizes.
QString description
Optional user-facing description (plain prose).
Definition ScrollingTemplate.h:133
static QList< qreal > normalizePresetList(QList< qreal > values)
The preset-list half of normalize() (floor at MinTemplateFraction, ascending sort,...
QList< qreal > presetColumnWidths
Cycle stops for the preset width/height shortcuts.
Definition ScrollingTemplate.h:149
bool operator==(const ScrollingTemplate &) const =default
bool normalize()
Clamp every fraction into legal range, drop degenerate entries, sort and dedupe the preset lists,...
QString sourcePath
Absolute path of the file this template was loaded from.
Definition ScrollingTemplate.h:165
constexpr QLatin1String Id
Definition ScrollingTemplate.h:86
constexpr QLatin1String SourcePath
Definition ScrollingTemplate.h:88
constexpr QLatin1String IsSystem
Definition ScrollingTemplate.h:87
Definition IWindowTrackingService.h:23
constexpr int DefaultWidthKindClientDecides
Definition ScrollingTemplate.h:41
constexpr qreal MinTemplateFraction
Smallest fraction of the work area a template may express, mirroring the scroll engine's PhosphorScro...
Definition ScrollingTemplate.h:22
constexpr int MaxTemplateColumns
Most blueprint columns a template may carry, mirroring the scroll engine's kMaxTemplateEntries (engin...
Definition ScrollingTemplate.h:31
constexpr int DefaultWidthKindProportion
The engine's DefaultWidthKind wire values, mirrored the same hand-written way MinTemplateFraction mir...
Definition ScrollingTemplate.h:39
constexpr qreal FractionDedupeEpsilon
Two preset stops closer together than this are the same stop: the normalization dedupe drops the late...
Definition ScrollingTemplate.h:49
constexpr int DefaultWidthKindPreset
Definition ScrollingTemplate.h:42
constexpr int DefaultWidthKindFixed
Definition ScrollingTemplate.h:40
One column of a scrolling template's seed blueprint.
Definition ScrollingTemplate.h:64
bool operator==(const ScrollingTemplateColumn &) const =default