MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ track()

template<typename T >
void MayaFlux::Portal::Forma::internal::Atelier::track ( Scrollable &  panel,
Layer &  layer,
const Mapped< T > &  mapped,
Kinesis::AABB2D  base_bounds,
std::function< void(Kinesis::AABB2D)>  reposition = {} 
)
inline

Register mapped's element for scroll reflow in panel.

When reposition is empty, one is built from mapped's own buffer, geometry_fn, and state: it reruns geometry_fn unconditionally (assumes the Form was built with live_offset wired to panel's own offset, so it reads the new position itself) and pushes the resulting bounds_hint/contains to layer. These are the same two effects Mapped<T>::sync(Layer*) has, replicated rather than called through, so the closure captures only independently-owned pieces (buffer and state are shared_ptr, geometry_fn is a copyable std::function), never a pointer back to mapped itself, since the closure outlives this call, stored inside panel.

Parameters
panelScrollable to track into.
layerLayer both panel and mapped's element were registered on.
mappedElement to track. Only buffer/geometry_fn/ state/element.id are read, nothing is stored. Its buffer is scissored to the panel's viewport, so it is not drawn outside it.
base_boundsmapped's current on-screen NDC bounds.
repositionCalled with the scrolled bounds on every scroll. Built as described above when empty.

Definition at line 227 of file Atelier.hpp.

232 {})
233 {
234 if (!reposition) {
235 auto buffer = mapped.element.buffer;
236 auto geometry_fn = mapped.geometry_fn;
237 auto state = mapped.state;
238 auto id = mapped.element.id;
239 auto* layer_ptr = &layer;
240
241 reposition = [buffer, geometry_fn, state, id, layer_ptr](Kinesis::AABB2D) {
242 if (!buffer || !geometry_fn || !state)
243 return;
244
245 std::vector<uint8_t> bytes;
246 Element el;
247 el.id = id;
248 geometry_fn(state->value, bytes, el);
249 buffer.submit(bytes);
250
251 if (el.bounds_hint)
252 layer_ptr->set_bounds(id, *el.bounds_hint);
253 if (el.contains)
254 layer_ptr->set_contains(id, el.contains);
255 };
256 }
257
258 panel.track(layer, mapped.element.id, base_bounds, std::move(reposition), mapped.element.buffer);
259 }
std::shared_ptr< NetworkGeometryBuffer > buffer