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

Named owner of a (Window, Layer, Context) triple: the Forma canvas. More...

#include <Surface.hpp>

+ Collaboration diagram for MayaFlux::Portal::Forma::Surface:

Classes

struct  WindowOwnership
 

Public Member Functions

Layer::Slot add (Element element)
 Forward an Element to layer().add() and return the Slot.
 
Kinesis::AABB2D bottom_left (float w, float h, float margin=0.02F) const noexcept
 Rect of size (w, h) at the top-left corner, inset by margin.
 
Kinesis::AABB2D bottom_right (float w, float h, float margin=0.02F) const noexcept
 Rect of size (w, h) at the top-left corner, inset by margin.
 
Kinesis::AABB2D bottom_strip (float h, float margin=0.F) const noexcept
 Full-width strip of height h along the top edge.
 
Kinesis::AABB2D center_rect (float w, float h) const noexcept
 Rect of size (w, h) centered on the NDC origin.
 
const Context & ctx () const noexcept
 Access the event router.
 
Context & ctx () noexcept
 Access the event router.
 
const std::shared_ptr< Context > & ctx_ptr () const noexcept
 Shared handles for callers that need to keep components alive independently of the Surface (background tasks, escapes into coroutines, etc.).
 
Kinesis::AABB2D full () const noexcept
 The entire NDC surface.
 
const Layer & layer () const noexcept
 Access the spatial registry.
 
Layer & layer () noexcept
 Access the spatial registry.
 
const std::shared_ptr< Layer > & layer_ptr () const noexcept
 Shared handles for callers that need to keep components alive independently of the Surface (background tasks, escapes into coroutines, etc.).
 
Kinesis::AABB2D left_strip (float w, float margin=0.F) const noexcept
 Full-height strip of width w along the left edge.
 
Surface & operator= (const Surface &)=default
 
Surface & operator= (Surface &&) noexcept=default
 
void remove (uint32_t id)
 Forward an id to layer().remove().
 
Portal::Graphics::RenderConfig render_config (Portal::Graphics::RenderConfig base={}) const
 base targeting this Surface's window.
 
Kinesis::AABB2D right_strip (float w, float margin=0.F) const noexcept
 Full-height strip of width w along the left edge.
 
 Surface (const Surface &)=default
 
 Surface (Surface &&) noexcept=default
 
 Surface (SurfaceConfig config)
 Construct a Surface from a SurfaceConfig.
 
Kinesis::AABB2D top_left (float w, float h, float margin=0.02F) const noexcept
 Rect of size (w, h) at the top-left corner, inset by margin.
 
Kinesis::AABB2D top_right (float w, float h, float margin=0.02F) const noexcept
 Rect of size (w, h) at the top-left corner, inset by margin.
 
Kinesis::AABB2D top_strip (float h, float margin=0.F) const noexcept
 Full-width strip of height h along the top edge.
 
const std::shared_ptr< Core::Window > & window () const noexcept
 Access the rendering target window.
 
 ~Surface ()=default
 

Private Attributes

std::shared_ptr< Context > m_ctx
 
std::shared_ptr< Layer > m_layer
 
std::shared_ptr< WindowOwnership > m_window_ownership
 

Detailed Description

Named owner of a (Window, Layer, Context) triple: the Forma canvas.

In Forma, three things always travel together: a Window (the rendering target and coordinate space), a Layer (the spatial registry of elements), and a Context (the event router that hit-tests against the layer). They are the three faces of one concept: the canvas. Surface names that concept and owns the triple, so that downstream construction functions accept one argument instead of three.

Surface is not a widget toolkit, not a layout engine, not an event dispatcher. It does not know what an element looks like, how a buffer is built, or where bindings are routed. Construction of FormaBuffers, Mapped<T>s, and Bridge registrations is the job of the free functions in Forma.hpp, which take a Surface& as their canvas argument and read the BufferManager, Bridge, and other module-level state from the singletons established by Portal::Forma::initialize().

The Layer and Context owned by Surface remain fully accessible through the layer() and ctx() accessors. Surface is a named owner, not a wall. Anything that worked against Layer or Context before continues to work against surface.layer() and surface.ctx().

Surface(SurfaceConfig) never creates the Layer or Context itself. It only ever wraps ones already built. Portal::Forma::create_surface (in Forma.hpp) also takes a SurfaceConfig: the default path leaves layer/ctx unset, so a fresh Layer and Context are built against the global EventManager from window/name and the Surface is constructed from those. Set layer/ctx yourself in the same SurfaceConfig for the power-tinkerer path, when you need a custom Context subclass, want to share one Layer across multiple Contexts (split-pane editing), or are constructing in a test against a non-global EventManager.

// Default path
SurfaceConfig { .window = window, .name = "plot_live" });
auto el = Portal::Forma::create_element<float>(surface, geom, 0.5F);
surface.ctx().on_press(el.element.id, IO::MouseButtons::Left, ...);
// Power-tinkerer path: pre-built layer and context
auto layer = std::make_shared<Layer>();
auto ctx = std::make_shared<MyCustomContext>(layer, window, em, "custom");
Surface surface(SurfaceConfig { .window = window, .layer = layer, .ctx = ctx });
const std::shared_ptr< Core::Window > & window() const noexcept
Access the rendering target window.
Definition Surface.hpp:178
Context & ctx() noexcept
Access the event router.
Definition Surface.hpp:170
Layer & layer() noexcept
Access the spatial registry.
Definition Surface.hpp:159
Named owner of a (Window, Layer, Context) triple: the Forma canvas.
Definition Surface.hpp:121
Surface create_surface(SurfaceConfig config)
Construct a Surface from a SurfaceConfig.
Definition Forma.cpp:85
std::shared_ptr< Core::Window > window
Target window. Must outlive the Surface.
Definition Surface.hpp:28
The single argument every Surface-creating function in this module takes, at every level of abstracti...
Definition Surface.hpp:26

Definition at line 121 of file Surface.hpp.


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