Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
IZoneDetector.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// IZoneDetector + ZoneDetectionResult — the zone-detection contract.
7//
8// Split out of interfaces.h so zones-related code can include just the
9// detector interface without pulling ISettings / IOverlayService /
10// ILayoutManager. Prerequisite for moving ZoneDetector + this interface
11// into a standalone phosphor-zones library without dragging the rest of
12// PZ's service interfaces along.
13
14#include <phosphorzones_export.h>
15
16#include <QObject>
17#include <QPointF>
18#include <QRectF>
19#include <QVector>
20
21namespace PhosphorZones {
22
23class Zone;
24class Layout;
25
31struct PHOSPHORZONES_EXPORT ZoneDetectionResult
32{
33 Zone* primaryZone = nullptr; // Main zone to snap to
34 QVector<Zone*> adjacentZones; // Adjacent zones for multi-zone snap
35 QVector<Zone*> overlappingZones; // All zones containing cursor point (overlap info)
36 QRectF snapGeometry; // Combined geometry for snapping
37 qreal distance = -1; // Distance to zone edge
38 bool isMultiZone = false; // Whether snapping to multiple zones
39};
40
53class PHOSPHORZONES_EXPORT IZoneDetection
54{
55public:
56 IZoneDetection() = default;
57 virtual ~IZoneDetection();
58
59 virtual Layout* layout() const = 0;
60
61 virtual ZoneDetectionResult detectZone(const QPointF& cursorPos) const = 0;
62 virtual ZoneDetectionResult detectMultiZone(const QPointF& cursorPos) const = 0;
63 virtual Zone* zoneAtPoint(const QPointF& point) const = 0;
64 virtual Zone* nearestZone(const QPointF& point) const = 0;
65
69 virtual QVector<Zone*> expandPaintedZonesToRect(const QVector<Zone*>& seedZones) const = 0;
70
71protected:
72 IZoneDetection(const IZoneDetection&) = default;
74};
75
83class PHOSPHORZONES_EXPORT IZoneDetector : public QObject, public IZoneDetection
84{
85 Q_OBJECT
86
87public:
88 explicit IZoneDetector(QObject* parent = nullptr)
89 : QObject(parent)
90 {
91 }
92 ~IZoneDetector() override;
93
94 virtual void setLayout(Layout* layout) = 0;
95
96 // Highlight management
97 virtual void highlightZone(Zone* zone) = 0;
98 virtual void highlightZones(const QVector<Zone*>& zones) = 0;
99 virtual void clearHighlights() = 0;
100
101Q_SIGNALS:
105};
106
107} // namespace PhosphorZones
108
109Q_DECLARE_METATYPE(PhosphorZones::ZoneDetectionResult)
Pure-query subset of zone detection — read-only geometry lookup.
Definition IZoneDetector.h:54
virtual Zone * nearestZone(const QPointF &point) const =0
IZoneDetection & operator=(const IZoneDetection &)=default
virtual ZoneDetectionResult detectZone(const QPointF &cursorPos) const =0
virtual Layout * layout() const =0
virtual Zone * zoneAtPoint(const QPointF &point) const =0
virtual QVector< Zone * > expandPaintedZonesToRect(const QVector< Zone * > &seedZones) const =0
Paint-to-snap: expand painted zones to include all zones intersecting the bounding rect (same raycast...
virtual ZoneDetectionResult detectMultiZone(const QPointF &cursorPos) const =0
IZoneDetection(const IZoneDetection &)=default
Abstract interface for zone detection + highlight lifecycle.
Definition IZoneDetector.h:84
virtual void highlightZones(const QVector< Zone * > &zones)=0
IZoneDetector(QObject *parent=nullptr)
Definition IZoneDetector.h:88
virtual void setLayout(Layout *layout)=0
virtual void clearHighlights()=0
virtual void highlightZone(Zone *zone)=0
void zoneHighlighted(Zone *zone)
Represents a collection of zones that form a layout.
Definition Layout.h:74
Represents a single zone within a layout.
Definition Zone.h:44
Definition IWindowTrackingService.h:22
Result of zone detection.
Definition IZoneDetector.h:32
QVector< Zone * > adjacentZones
Definition IZoneDetector.h:34
QRectF snapGeometry
Definition IZoneDetector.h:36
QVector< Zone * > overlappingZones
Definition IZoneDetector.h:35