Loading...
Searching...
No Matches
AnchorManager.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith.
2// Malena Framework — Licensed under PolyForm Noncommercial 1.0.0; commercial use requires a paid license. See LICENSE.
3
4//
5// AnchorManager.h — owns retained anchors and re-solves them.
6//
7// Anchors live here (external registry) rather than on Positionable, so the trait
8// keeps no data member and stays copyable. AppManager calls solveAll() on window
9// resize; a solve re-reads each reference's current bounds and re-applies the
10// stored Align ops. An object moved externally between solves (a direct
11// setPosition, or an animation) is detected and detached — manual control wins.
12//
13
14#ifndef MALENA_ANCHORMANAGER_H
15#define MALENA_ANCHORMANAGER_H
16
17#pragma once
18
21#include <cstddef>
22#include <unordered_map>
23
24namespace ml
25{
26 class Positionable;
27
29 {
30 public:
34 static void set(Positionable* owner, AnchorOp op, const Positionable* ref, float spacing);
35
38 static void recordBaseline(Positionable* owner);
39
41 static void clear(Positionable* owner);
42
44 static bool hasAnchors(const Positionable* owner);
45
49 static void release(const Positionable* owner);
50
53 static void solveAll();
54
56 static std::size_t anchoredCount();
57
58 private:
59 struct Entry;
60 static std::unordered_map<Positionable*, Entry>& registry();
61 static void solveOwner(Positionable* owner, Entry& e);
62 };
63
64} // namespace ml
65
66#endif // MALENA_ANCHORMANAGER_H
static std::size_t anchoredCount()
Number of objects with at least one anchor (test/introspection helper).
static void clear(Positionable *owner)
Drop all of owner's anchors (the unanchored() opt-out).
static void set(Positionable *owner, AnchorOp op, const Positionable *ref, float spacing)
static void release(const Positionable *owner)
static bool hasAnchors(const Positionable *owner)
True if owner currently has any retained anchor.
static void solveAll()
static void recordBaseline(Positionable *owner)
Trait that provides position, bounds, and animated movement.
#define MALENA_API
Definition Animate.h:25
AnchorOp
Definition Anchor.h:25