Represents a single zone within a layout. More...
#include <PhosphorZones/Zone.h>
Signals | |
| void | nameChanged () |
| void | geometryChanged () |
| void | relativeGeometryChanged () |
| void | zoneNumberChanged () |
| void | highlightColorChanged () |
| void | inactiveColorChanged () |
| void | borderColorChanged () |
| void | activeOpacityChanged () |
| void | inactiveOpacityChanged () |
| void | borderWidthChanged () |
| void | borderRadiusChanged () |
| void | highlightedChanged () |
| void | useCustomColorsChanged () |
| void | overlayDisplayModeChanged () |
| void | geometryModeChanged () |
| void | fixedGeometryChanged () |
Public Member Functions | |
| Zone (QObject *parent=nullptr) | |
| Zone (const QRectF &geometry, QObject *parent=nullptr) | |
| ~Zone () override=default | |
| Zone (const Zone &)=delete | |
| Zone & | operator= (const Zone &)=delete |
| Zone * | clone (QObject *parent=nullptr) const |
| Creates a copy of this zone with a new unique ID. | |
| void | copyPropertiesFrom (const Zone &other) |
| Copies properties from another zone (excluding ID). | |
| QUuid | id () const |
| QString | name () const |
| void | setName (const QString &name) |
| QRectF | geometry () const |
| void | setGeometry (const QRectF &geometry) |
| QRectF | relativeGeometry () const |
| void | setRelativeGeometry (const QRectF &relativeGeometry) |
| int | zoneNumber () const |
| void | setZoneNumber (int number) |
| QColor | highlightColor () const |
| void | setHighlightColor (const QColor &color) |
| QColor | inactiveColor () const |
| void | setInactiveColor (const QColor &color) |
| QColor | borderColor () const |
| void | setBorderColor (const QColor &color) |
| qreal | activeOpacity () const |
| void | setActiveOpacity (qreal opacity) |
| qreal | inactiveOpacity () const |
| void | setInactiveOpacity (qreal opacity) |
| int | borderWidth () const |
| void | setBorderWidth (int width) |
| int | borderRadius () const |
| void | setBorderRadius (int radius) |
| bool | isHighlighted () const |
| void | setHighlighted (bool highlighted) |
| bool | useCustomColors () const |
| void | setUseCustomColors (bool useCustom) |
| int | overlayDisplayMode () const |
| void | setOverlayDisplayMode (int mode) |
| ZoneGeometryMode | geometryMode () const |
| int | geometryModeInt () const |
| bool | isFixedGeometry () const |
| void | setGeometryMode (ZoneGeometryMode mode) |
| void | setGeometryModeInt (int mode) |
| QRectF | fixedGeometry () const |
| void | setFixedGeometry (const QRectF &geometry) |
| QRectF | normalizedGeometry (const QRectF &referenceGeometry, qreal screenScale=0.0) const |
| Returns normalized 0-1 coordinates regardless of geometry mode. | |
| bool | containsPoint (const QPointF &point) const |
| qreal | distanceToPoint (const QPointF &point) const |
| QRectF | calculateAbsoluteGeometry (const QRectF &screenGeometry, qreal screenScale=0.0) const |
screenScale as normalizedGeometry() takes it. | |
| qreal | fixedGeometryDivisor (qreal screenScale) const |
What this zone's fixed geometry is divided by on an output of logical scale screenScale: its layout's Layout::fixedGeometryDivisor, with a zero scale read as the layout's last recalculation scale, and 1.0 for a zone with no layout. | |
| QJsonObject | toJson (const QRectF &referenceGeometry=QRectF()) const |
Static Public Member Functions | |
| static QRectF | sanitizeFixedGeometry (const QRectF &geometry) |
| Normalize a fixedGeometry payload arriving from an untrusted boundary. | |
| static QRectF | fixedGeometryToLogical (const QRectF &fixedGeometry, qreal divisor) |
fixedGeometry in logical units: every component divided by divisor, a non-positive one reading as 1.0. | |
| static QRectF | computeAbsoluteGeometry (ZoneGeometryMode mode, const QRectF &relativeGeometry, const QRectF &fixedGeometry, const QRectF &screenGeometry, qreal fixedDivisor=1.0) |
| Pure helper shared between Zone::calculateAbsoluteGeometry and LayoutWorker (which runs off-thread and cannot touch QObjects). | |
| static Zone * | fromJson (const QJsonObject &json, QObject *parent=nullptr) |
Represents a single zone within a layout.
A zone is a rectangular area on the screen where windows can be snapped. Zones support custom colors, names, and keyboard shortcuts for ricer-friendly customization.
Note: Zone inherits from QObject and follows Qt's object model. QObjects should NOT be copied - use clone() to create duplicates.
|
explicit |
|
explicit |
|
overridedefault |
|
delete |
|
inline |
|
signal |
|
inline |
|
signal |
|
inline |
|
signal |
|
inline |
|
signal |
| QRectF PhosphorZones::Zone::calculateAbsoluteGeometry | ( | const QRectF & | screenGeometry, |
| qreal | screenScale = 0.0 ) const |
screenScale as normalizedGeometry() takes it.
| Zone * PhosphorZones::Zone::clone | ( | QObject * | parent = nullptr | ) | const |
Creates a copy of this zone with a new unique ID.
| parent | Parent object for the new zone |
|
static |
Pure helper shared between Zone::calculateAbsoluteGeometry and LayoutWorker (which runs off-thread and cannot touch QObjects).
Fixed mode: pixel coords relative to screen origin, divided by fixedDivisor (the output's scale for a layout that counts device pixels, else 1.0). Relative mode: 0..1 coords multiplied by screen dimensions.
| bool PhosphorZones::Zone::containsPoint | ( | const QPointF & | point | ) | const |
| void PhosphorZones::Zone::copyPropertiesFrom | ( | const Zone & | other | ) |
Copies properties from another zone (excluding ID).
| other | Source zone to copy from |
| qreal PhosphorZones::Zone::distanceToPoint | ( | const QPointF & | point | ) | const |
|
inline |
|
signal |
| qreal PhosphorZones::Zone::fixedGeometryDivisor | ( | qreal | screenScale | ) | const |
What this zone's fixed geometry is divided by on an output of logical scale screenScale: its layout's Layout::fixedGeometryDivisor, with a zero scale read as the layout's last recalculation scale, and 1.0 for a zone with no layout.
Note the zero case differs from the Layout function, which reads a zero scale as "no scale" and answers 1.0.
|
static |
fixedGeometry in logical units: every component divided by divisor, a non-positive one reading as 1.0.
The one place the division is written, shared by the absolute, normalized, bounding-box and gap-edge readers and by the shell's placement-map parser (PhosphorShell::PlacementMapParser::parseSnappingLayout) so none of them can resolve the unit differently.
|
static |
|
inline |
|
signal |
|
inline |
|
signal |
|
inline |
|
inline |
|
signal |
|
signal |
|
inline |
|
inline |
|
signal |
|
inline |
|
signal |
|
inline |
|
inline |
|
inline |
|
signal |
| QRectF PhosphorZones::Zone::normalizedGeometry | ( | const QRectF & | referenceGeometry, |
| qreal | screenScale = 0.0 ) const |
Returns normalized 0-1 coordinates regardless of geometry mode.
| referenceGeometry | The screen geometry to normalize against |
For Relative mode: returns relativeGeometry() directly. For Fixed mode: converts fixedGeometry pixel coords to 0-1 relative to referenceGeometry dimensions.
screenScale is the logical scale of the output referenceGeometry belongs to. A zone whose layout counts fixed geometry in device pixels divides by it first (Layout::fixedGeometryDivisor). Zero, the default, takes the scale the layout was last recalculated at.
|
inline |
|
signal |
|
inline |
|
signal |
|
static |
Normalize a fixedGeometry payload arriving from an untrusted boundary.
X/Y are pixel offsets from the screen origin and MAY be negative — computeAbsoluteGeometry adds them to the origin verbatim, so a negative offset legitimately places a zone off-screen. Width/height are extents and cannot be negative. A non-finite value has no meaningful clamp (it poisons every later comparison and serializes as JSON null) so it drops to 0, which lands the rect in the degenerate bucket below.
The result is empty (QRectF::isEmpty) when the payload cannot describe a zone that renders. Callers must treat that as "no usable fixed payload" and fall back to Relative rather than storing it: a zero-extent fixed zone normalizes to a zero-extent relativeGeometry, which the layout schema rejects with exclusiveMinimum 0 — and it rejects the WHOLE layout, so storing one turns the next save into a file the loader drops.
Called from Zone::fromJson only. Every ingress that accepts the key builds its zones through fromJson (the layout file loader, and LayoutAdaptor::updateLayout for D-Bus), so they cannot drift apart. A new ingress that builds zones another way must call this itself.
| void PhosphorZones::Zone::setActiveOpacity | ( | qreal | opacity | ) |
| void PhosphorZones::Zone::setBorderColor | ( | const QColor & | color | ) |
| void PhosphorZones::Zone::setBorderRadius | ( | int | radius | ) |
| void PhosphorZones::Zone::setBorderWidth | ( | int | width | ) |
| void PhosphorZones::Zone::setFixedGeometry | ( | const QRectF & | geometry | ) |
| void PhosphorZones::Zone::setGeometry | ( | const QRectF & | geometry | ) |
| void PhosphorZones::Zone::setGeometryMode | ( | ZoneGeometryMode | mode | ) |
| void PhosphorZones::Zone::setGeometryModeInt | ( | int | mode | ) |
| void PhosphorZones::Zone::setHighlightColor | ( | const QColor & | color | ) |
| void PhosphorZones::Zone::setHighlighted | ( | bool | highlighted | ) |
| void PhosphorZones::Zone::setInactiveColor | ( | const QColor & | color | ) |
| void PhosphorZones::Zone::setInactiveOpacity | ( | qreal | opacity | ) |
| void PhosphorZones::Zone::setName | ( | const QString & | name | ) |
| void PhosphorZones::Zone::setOverlayDisplayMode | ( | int | mode | ) |
| void PhosphorZones::Zone::setRelativeGeometry | ( | const QRectF & | relativeGeometry | ) |
| void PhosphorZones::Zone::setUseCustomColors | ( | bool | useCustom | ) |
| void PhosphorZones::Zone::setZoneNumber | ( | int | number | ) |
| QJsonObject PhosphorZones::Zone::toJson | ( | const QRectF & | referenceGeometry = QRectF() | ) | const |
|
inline |
|
signal |
|
inline |
|
signal |