MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Portal::Forma::Layer Class Reference

Flat registry of Elements on a surface. More...

#include <Layer.hpp>

+ 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 order (drawn last).
 
void clear ()
 Remove all elements.
 
const std::vector< Element > & elements () const
 
bool empty () const
 
Elementget (uint32_t id)
 
const Elementget (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 back-to-front.
 
 Layer ()=default
 
 Layer (const Layer &)=delete
 
 Layer (Layer &&)=default
 
Layeroperator= (const Layer &)=delete
 
Layeroperator= (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.
 
bool send_to_back (uint32_t id)
 Move element to the bottom of the hit-test order (drawn first).
 
bool set_bounds (uint32_t id, Kinesis::AABB2D bounds)
 Replace the bounds_hint on an existing element.
 
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
 

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< Elementm_elements
 
uint32_t m_next_id { 1 }
 
std::unordered_map< uint32_t, std::vector< uint32_t > > m_relations
 

Detailed Description

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.

Definition at line 21 of file Layer.hpp.


The documentation for this class was generated from the following files: