MayaFlux 0.4.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:

Public Member Functions

Layer::Slot add (Element element)
 Forward an Element to layer().add() and return the Slot.
 
const Contextctx () const noexcept
 Access the event router.
 
Contextctx () 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.).
 
const Layerlayer () const noexcept
 Access the spatial registry.
 
Layerlayer () 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.).
 
Surfaceoperator= (const Surface &)=default
 
Surfaceoperator= (Surface &&) noexcept=default
 
 Surface (const Surface &)=default
 
 Surface (std::shared_ptr< Core::Window > window, std::shared_ptr< Layer > layer, std::shared_ptr< Context > ctx)
 Construct a Surface around a pre-built Layer and Context.
 
 Surface (Surface &&) noexcept=default
 
const std::shared_ptr< Core::Window > & window () const noexcept
 Access the rendering target window.
 
 ~Surface ()=default
 

Private Attributes

std::shared_ptr< Contextm_ctx
 
std::shared_ptr< Layerm_layer
 
std::shared_ptr< Core::Windowm_window
 

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 has two constructors:

  1. The default: takes Window + name. Internally creates Layer and Context. This is the path covered by Portal::Forma::create_surface in Forma.hpp.
  2. The power-tinkerer: takes Window + pre-built Layer + pre-built Context. Use this 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
auto surface = Portal::Forma::create_surface(window, "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(window, layer, ctx);
const std::shared_ptr< Core::Window > & window() const noexcept
Access the rendering target window.
Definition Surface.hpp:126
Context & ctx() noexcept
Access the event router.
Definition Surface.hpp:118
Layer & layer() noexcept
Access the spatial registry.
Definition Surface.hpp:107
Named owner of a (Window, Layer, Context) triple - the Forma canvas.
Definition Surface.hpp:58
Surface create_surface(std::shared_ptr< Core::Window > window, std::string name)
Construct a Surface, creating Layer and Context internally.
Definition Forma.cpp:234

Definition at line 58 of file Surface.hpp.


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