Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
DirectionalNeighbor.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 "phosphorgeometry_export.h"
7
8#include <QList>
9#include <QRectF>
10#include <QStringView>
11
12#include <optional>
13
15
17enum class Direction {
18 Left,
19 Right,
20 Up,
21 Down
22};
23
27PHOSPHORGEOMETRY_EXPORT std::optional<Direction> directionFromString(QStringView token);
28
33constexpr Direction opposite(Direction direction)
34{
35 switch (direction) {
36 case Direction::Left:
37 return Direction::Right;
39 return Direction::Left;
40 case Direction::Up:
41 return Direction::Down;
42 case Direction::Down:
43 return Direction::Up;
44 }
45 return direction;
46}
47
68PHOSPHORGEOMETRY_EXPORT int edgeMostRect(const QList<QRectF>& candidates, Direction edge);
69
114PHOSPHORGEOMETRY_EXPORT int directionalNeighbor(const QRectF& focus, const QList<QRectF>& candidates,
115 Direction direction, bool requireOverlap = false);
116
135PHOSPHORGEOMETRY_EXPORT int neighborDesktopInDirection(int currentDesktop, int desktopCount, int rows,
136 Direction direction);
137
138} // namespace PhosphorGeometry
Definition DirectionalNeighbor.h:14
constexpr Direction opposite(Direction direction)
The reverse of direction.
Definition DirectionalNeighbor.h:33
PHOSPHORGEOMETRY_EXPORT int edgeMostRect(const QList< QRectF > &candidates, Direction edge)
Index of the candidate whose edge-facing side is most extreme toward that edge.
PHOSPHORGEOMETRY_EXPORT int directionalNeighbor(const QRectF &focus, const QList< QRectF > &candidates, Direction direction, bool requireOverlap=false)
Pick the spatial neighbour of focus among candidates in direction.
Direction
Cardinal navigation direction in screen space (y grows downward).
Definition DirectionalNeighbor.h:17
PHOSPHORGEOMETRY_EXPORT std::optional< Direction > directionFromString(QStringView token)
Parse a lower-case direction token ("left"/"right"/"up"/"down") into a Direction.
PHOSPHORGEOMETRY_EXPORT int neighborDesktopInDirection(int currentDesktop, int desktopCount, int rows, Direction direction)
The virtual desktop reached by stepping direction from currentDesktop on a rows-high desktop grid.