diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-02-21 21:30:39 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-21 21:30:39 +0000 |
| commit | 723870337f299d4c80aa0048144f3a1ca1c885bd (patch) | |
| tree | ca3279ae5dbc841f676c64d2f58f895de13cd3bf /src/layout/algorithm/Algorithm.hpp | |
| parent | 51f8849e541f0a8150ac3a43fa928c1e299daf18 (diff) | |
layout: rethonk layouts from the ground up (#12890)
Rewrites layouts to be much smaller, and deal with much less annoying
BS. Improves the overall architecture, unifies handling of pseudotiling,
and various other improvements.
Diffstat (limited to 'src/layout/algorithm/Algorithm.hpp')
| -rw-r--r-- | src/layout/algorithm/Algorithm.hpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/layout/algorithm/Algorithm.hpp b/src/layout/algorithm/Algorithm.hpp new file mode 100644 index 00000000..3ee26a3c --- /dev/null +++ b/src/layout/algorithm/Algorithm.hpp @@ -0,0 +1,64 @@ +#pragma once + +#include "../../helpers/math/Math.hpp" +#include "../../helpers/math/Direction.hpp" +#include "../../helpers/memory/Memory.hpp" + +#include "../LayoutManager.hpp" + +#include <expected> +#include <optional> + +namespace Layout { + class ITarget; + class IFloatingAlgorithm; + class ITiledAlgorithm; + class CSpace; + + class CAlgorithm { + public: + static SP<CAlgorithm> create(UP<ITiledAlgorithm>&& tiled, UP<IFloatingAlgorithm>&& floating, SP<CSpace> space); + ~CAlgorithm() = default; + + void addTarget(SP<ITarget> target); + void moveTarget(SP<ITarget> target, std::optional<Vector2D> focalPoint = std::nullopt, bool reposition = false); + void removeTarget(SP<ITarget> target); + + void swapTargets(SP<ITarget> a, SP<ITarget> b); + void moveTargetInDirection(SP<ITarget> t, Math::eDirection dir, bool silent); + + SP<ITarget> getNextCandidate(SP<ITarget> old); + + void setFloating(SP<ITarget> target, bool floating, bool reposition = false); + + std::expected<void, std::string> layoutMsg(const std::string_view& sv); + std::optional<Vector2D> predictSizeForNewTiledTarget(); + + void recalculate(); + void recenter(SP<ITarget> t); + + void resizeTarget(const Vector2D& Δ, SP<ITarget> target, eRectCorner corner = CORNER_NONE); + void moveTarget(const Vector2D& Δ, SP<ITarget> target); + + void updateFloatingAlgo(UP<IFloatingAlgorithm>&& algo); + void updateTiledAlgo(UP<ITiledAlgorithm>&& algo); + + const UP<ITiledAlgorithm>& tiledAlgo() const; + const UP<IFloatingAlgorithm>& floatingAlgo() const; + + SP<CSpace> space() const; + + size_t tiledTargets() const; + size_t floatingTargets() const; + + private: + CAlgorithm(UP<ITiledAlgorithm>&& tiled, UP<IFloatingAlgorithm>&& floating, SP<CSpace> space); + + UP<ITiledAlgorithm> m_tiled; + UP<IFloatingAlgorithm> m_floating; + WP<CSpace> m_space; + WP<CAlgorithm> m_self; + + std::vector<WP<ITarget>> m_tiledTargets, m_floatingTargets; + }; +}
\ No newline at end of file |
