|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
Flat registry of Elements on a surface. More...
#include <Layer.hpp>
Inheritance diagram for MayaFlux::Portal::Forma::Layer:
Collaboration diagram for MayaFlux::Portal::Forma::Layer:Classes | |
| class | Slot |
| Handle returned by Layer::add, carrying the assigned element id. More... | |
Public Member Functions | |
| Slot | add (Element element) |
| Add an element to the layer. | |
| bool | bring_to_front (uint32_t id) |
| Move element to the top of the hit-test and paint order (drawn last), cascading to every related element. | |
| void | clear () |
| Remove all elements. | |
| std::vector< uint32_t > | closure (uint32_t id) const |
Return id plus every id transitively related to it. | |
| const std::vector< Element > & | elements () const |
| bool | empty () const |
| Element * | get (uint32_t id) |
| const Element * | get (uint32_t id) const |
| std::optional< uint32_t > | hit_test (double px, double py, uint32_t win_w, uint32_t win_h) const |
| hit_test with pixel-space input, converted to NDC internally. | |
| std::optional< uint32_t > | hit_test (glm::vec2 ndc) const |
Return the topmost interactive, visible element containing ndc. | |
| std::vector< uint32_t > | hit_test_all (double px, double py, uint32_t win_w, uint32_t win_h) const |
| std::vector< uint32_t > | hit_test_all (glm::vec2 ndc) const |
Return all interactive, visible elements containing ndc, ordered front-to-back (topmost first, matching hit_test). | |
| Layer ()=default | |
| Layer (const Layer &)=delete | |
| Layer (Layer &&)=default | |
| Layer & | operator= (const Layer &)=delete |
| Layer & | operator= (Layer &&)=default |
| bool | relate (uint32_t primary_id, uint32_t related_id) |
Record that related_id belongs with primary_id. | |
| std::vector< uint32_t > | related_ids (uint32_t primary_id) const |
Return the ids related to primary_id, or empty if none. | |
| bool | remove (uint32_t id) |
| Remove an element by id, cascading to every related id. | |
| bool | send_to_back (uint32_t id) |
| Move element to the bottom of the hit-test and paint order (drawn first), cascading to every related element. | |
| void | set_all_visible (bool visible) |
| Set every element in the layer visible or hidden. | |
| bool | set_bounds (uint32_t id, Kinesis::AABB2D bounds) |
| Replace the bounds_hint on an existing element. | |
| bool | set_clip (uint32_t id, std::optional< Kinesis::AABB2D > clip) |
| Confine hit testing of an element to a region, or lift the confinement with std::nullopt. | |
| bool | set_contains (uint32_t id, std::function< bool(glm::vec2)> fn) |
| Replace the contains callable on an existing element. | |
| bool | set_interactive (uint32_t id, bool interactive) |
| bool | set_visible (uint32_t id, bool visible) |
| size_t | size () const |
| bool | unrelate (uint32_t primary_id, uint32_t related_id) |
| Remove a specific relation between two elements. | |
| ~Layer ()=default | |
Private Member Functions | |
| void | reindex () const |
Static Private Member Functions | |
| static bool | test_element (const Element &el, glm::vec2 ndc) noexcept |
| static glm::vec2 | to_ndc (double px, double py, uint32_t win_w, uint32_t win_h) noexcept |
Private Attributes | |
| std::vector< Element > | m_elements |
| std::unordered_map< uint32_t, size_t > | m_index |
| bool | m_index_stale {} |
| int64_t | m_next_back_priority {} |
| int64_t | m_next_front_priority {} |
| uint32_t | m_next_id { 1 } |
| std::unordered_map< uint32_t, std::vector< uint32_t > > | m_relations |
Flat registry of Elements on a surface.
Owns a collection of Elements and provides spatial queries against them in NDC space. Does not drive rendering, scheduling, or event wiring.
Elements are stored and traversed back-to-front so later-added elements are considered on top during hit testing, matching typical draw order.
Pixel-space query overloads accept window dimensions and convert to NDC internally using the same convention as Kinesis::to_ndc: top-left origin, +Y down in pixel space, +Y up in NDC.
Element ids are unique only within one Layer. A Layer used with Bridge must be owned by a shared_ptr, which Bridge uses to tell layers apart.