QtCraft API C++ classes QML types Handbook

QcSpatialNavigation Namespace

Moving a focus between rectangles of a screen by direction (decision E-583): from the focused rectangle to the nearest one that lies in the direction. More...

Header: #include <clientcore/input/QcSpatialNavigation.h>

Types

enum class Direction { Up, Down, Left, Right }

Functions

std::optional<qsizetype> first(const QList<QRectF> &candidates)
std::optional<qsizetype> next(const QRectF &from, QcSpatialNavigation::Direction direction, const QList<QRectF> &candidates)

Detailed Description

Pure geometry, for the pad's focus in every screen (QcMenuNavigator); a grid of slots, a column of buttons and a list with rows of different widths all move to their visual neighbour.

Type Documentation

enum class QcSpatialNavigation::Direction

The direction to move in.

ConstantValueDescription
QcSpatialNavigation::Direction::Up0towards the top of the screen
QcSpatialNavigation::Direction::Down1towards the bottom
QcSpatialNavigation::Direction::Left2towards the left edge
QcSpatialNavigation::Direction::Right3towards the right edge

Function Documentation

std::optional<qsizetype> QcSpatialNavigation::first(const QList<QRectF> &candidates)

Returns where among candidates the focus starts without one: the top row first, in it the leftmost (rows by centre, with a tolerance of half the smaller height).

std::optional<qsizetype> QcSpatialNavigation::next(const QRectF &from, QcSpatialNavigation::Direction direction, const QList<QRectF> &candidates)

Returns the index of the one of candidates to move to from from in direction, or nullopt when nothing lies that way. A candidate counts when its centre lies beyond the centre of from in that direction, further than it lies off to the side (its edge's distance across the direction); the cost is the gap along the direction plus twice the offset across it (zero while the two overlap across it), so the neighbour in the same row or column wins over a nearer one diagonally.