6#include "phosphortiles_export.h"
29 std::unique_ptr<SplitNode>
first;
141 void insertAtFocused(const QString& windowId, const QString& focusedWindowId, qreal initialRatio = 0.0);
151 void insertAtEnd(const QString& windowId, qreal initialRatio = 0.0);
180 void swap(const QString& windowId1, const QString& windowId2);
275 enum class InsertReady {
285 InsertReady prepareInsert(
const QString& windowId);
288 void insertAtEndRaw(
const QString& windowId, qreal initialRatio);
291 void insertAtEndImpl(
const QString& windowId, qreal initialRatio);
293 std::unique_ptr<SplitNode> m_root;
296 const SplitNode* findLeaf(
const SplitNode* node,
const QString& windowId,
int depth = 0)
const;
297 SplitNode* leafAtIndex(
SplitNode* node,
int targetIndex,
int& currentIndex,
int depth = 0)
const;
298 const SplitNode* leafAtIndex(
const SplitNode* node,
int targetIndex,
int& currentIndex,
int depth = 0)
const;
301 void collectLeafOrder(
const SplitNode* node, QStringList& order,
int depth = 0)
const;
302 int countLeaves(
const SplitNode* node,
int depth = 0)
const;
303 void applyGeometryRecursive(
const SplitNode* node,
const QRect& rect,
int innerGap, QVector<QRect>& zones,
304 int depth = 0)
const;
306 static int subtreeHeight(
const SplitNode* node,
int depth = 0);
307 static void splitLeaf(
SplitNode* leaf,
const QString& newId, qreal ratio);
Algorithm-layer constants for the autotile/tile primitives.
int leafCount() const noexcept
Count the number of leaf nodes (windows).
bool rebuildFromOrder(const QStringList &tiledWindows, qreal defaultSplitRatio=AutotileDefaults::DefaultSplitRatio)
Rebuild tree from a new window order, preserving split ratios where possible.
SplitTree(SplitTree &&other) noexcept
Move constructor.
QStringList leafOrder() const
Get window IDs in depth-first left-to-right order.
bool swapLeaves(const QString &a, const QString &b)
Swap the stored window ids on two existing leaves.
const SplitNode * leafForWindow(const QString &windowId) const
Find the leaf node for a given window ID.
void remove(const QString &windowId)
Remove a window, collapsing its parent and promoting its sibling.
const SplitNode * root() const noexcept
Get the root node of the tree.
void swap(const QString &windowId1, const QString &windowId2)
Swap two windows' positions in the tree.
SplitTree & operator=(const SplitTree &)=delete
Edge
A geometric edge of a window's rectangle.
Definition SplitTree.h:65
void insertAtPosition(const QString &windowId, int position, qreal initialRatio=0.0)
Insert a window by splitting the leaf at a given position.
SplitTree & operator=(SplitTree &&other) noexcept
Move assignment.
bool isEmpty() const noexcept
Check if the tree has no nodes.
int treeHeight() const noexcept
Get the maximum height of the tree.
SplitTree()
Construct an empty tree (no root).
void insertAtFocused(const QString &windowId, const QString &focusedWindowId, qreal initialRatio=0.0)
Insert a window by splitting the focused window's leaf.
SplitTree(const SplitTree &)=delete
const SplitNode * splitOwningEdge(const QString &windowId, Edge edge) const
Find the ancestor split whose division line is collinear with a given edge of a leaf window.
void resizeSplitNode(SplitNode *node, qreal newRatio)
Set the split ratio on a specific internal node.
void resizeSplit(const QString &windowId, qreal newRatio)
Adjust the split ratio of a window's parent node.
void insertAtEnd(const QString &windowId, qreal initialRatio=0.0)
Insert a window by splitting the rightmost leaf.
QVector< QRect > applyGeometry(const QRect &area, int innerGap) const
Compute zone rectangles by recursively splitting the area.
Auto-tiling algorithm defaults.
Definition AutotileConstants.h:36
constexpr qreal DefaultSplitRatio
50/50 split when nothing else specified
Definition AutotileConstants.h:41
constexpr int MaxRuntimeTreeDepth
Maximum recursion depth for split tree operations.
Definition AutotileConstants.h:94
Definition AutotileEngine.h:52
A single node in the binary split tree.
Definition SplitTree.h:26
std::unique_ptr< SplitNode > second
Second child (right or bottom).
Definition SplitTree.h:30
bool splitHorizontal
true = top/bottom, false = left/right
Definition SplitTree.h:28
bool isLeaf() const
Definition SplitTree.h:34
std::unique_ptr< SplitNode > first
First child (left or top).
Definition SplitTree.h:29
SplitNode * parent
Non-owning back-pointer.
Definition SplitTree.h:31
qreal splitRatio
How to divide this node's space (first child fraction).
Definition SplitTree.h:27
QString windowId
Non-empty only for leaf nodes.
Definition SplitTree.h:32