Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::ApplicationScene Class Reference

Borrowed scene extension; bindings/models/providers belong to the caller. Construct the Application first, then the scene; destroy the scene before Application. The scene and application must survive every callback and run. No hook may destroy either owner or reenter run. Hooks execute on the creating UI thread; thrown exceptions become explicit failures followed by cleanup. More...

#include <application.hpp>

Inheritance diagram for portals::ApplicationScene:
portals::ApplicationSceneportals::ApplicationScene portals::ManagedScene

Public Member Functions

virtual ~ApplicationScene ()=default
virtual std::expected< void, TreeError > prepare (Application &application, CellSize size)
 Synchronize controls and pin each model once for a dirty frame. Called only when a dirty frame can be submitted, outside tree.frame. Retained view preparations own pins; custom widgets retain any other borrowed render data until rendering completes. Opt-in scenes retain the same pins through every prepareViews pass and final rendering.
virtual std::expected< bool, TreeError > input (Application &application, const InputEvent &event)
 Optional global command interception inside the bounded CONTROL callback.
virtual void stop (Application &application)
 Stop and join only scene-owned producers; called once before terminal restoration.
virtual bool usesPreparedLayout () const noexcept
 Opt into bounded layout-driven view preparation; default is false.
virtual bool usesGeometrySnapshot () const noexcept
virtual bool requiresPointerMotion () const noexcept
virtual bool requiresBackgroundExecutor () const noexcept
virtual std::expected< void, TreeError > prepareViews (Application &application, const LayoutSnapshot &snapshot)
 Prepare views from one owning layout snapshot; default is a no-op. Called only for opt-in scenes, on UI outside tree.frame, after prepare has pinned models once. Use those same pins for all views and repeated passes; do not dispatch the scheduler or replace pins here. Snapshot reads survive invalidations caused by earlier views. A new LAYOUT request repeats layout and this hook up to ApplicationOptions::maxPreparationPasses; PAINT does not.
virtual std::expected< void, TreeError > completedLayout (Application &application)
 Publish owning observations of the successful final frame, outside tree.frame.
virtual std::expected< void, TreeError > afterDispatch (Application &application)
 Retry deferred publication after existing scheduler work has freed queue capacity.
virtual bool hasPendingLayout () const noexcept

Detailed Description

Borrowed scene extension; bindings/models/providers belong to the caller. Construct the Application first, then the scene; destroy the scene before Application. The scene and application must survive every callback and run. No hook may destroy either owner or reenter run. Hooks execute on the creating UI thread; thrown exceptions become explicit failures followed by cleanup.

Constructor & Destructor Documentation

◆ ~ApplicationScene()

virtual portals::ApplicationScene::~ApplicationScene ( )
virtualdefault

Destroy bindings/providers before their Application owner.

Member Function Documentation

◆ afterDispatch()

virtual std::expected< void, TreeError > portals::ApplicationScene::afterDispatch ( Application & application)
virtual

Retry deferred publication after existing scheduler work has freed queue capacity.

Parameters
applicationBorrowed UI services, outside dispatch and tree.frame.
Returns
Success or original scene failure; the default does nothing. Publications accepted here are delivered by a subsequent dispatch.

Reimplemented in portals::ManagedScene.

◆ completedLayout()

virtual std::expected< void, TreeError > portals::ApplicationScene::completedLayout ( Application & application)
virtual

Publish owning observations of the successful final frame, outside tree.frame.

Parameters
applicationBorrowed UI services after final layout, paint and owning render.
Returns
Success or original scene failure; the default does nothing. This is not a terminal flush notification. User callbacks must be deferred through the scheduler.

Reimplemented in portals::ManagedScene.

◆ hasPendingLayout()

virtual bool portals::ApplicationScene::hasPendingLayout ( ) const
virtualnoexcept
Returns
True only while this scene owns pending final-layout notifications to drain at EOF. The default is false; unrelated scheduler DATA never extends the original EOF policy.

Reimplemented in portals::ManagedScene.

◆ input()

virtual std::expected< bool, TreeError > portals::ApplicationScene::input ( Application & application,
const InputEvent & event )
virtual

Optional global command interception inside the bounded CONTROL callback.

Parameters
applicationBorrowed UI services; requestStop is valid here.
eventOwning queued event borrowed for this callback only.
Returns
True if handled, false to route through EventRouter, or a scene error.

Reimplemented in portals::ManagedScene.

◆ prepare()

virtual std::expected< void, TreeError > portals::ApplicationScene::prepare ( Application & application,
CellSize size )
virtual

Synchronize controls and pin each model once for a dirty frame. Called only when a dirty frame can be submitted, outside tree.frame. Retained view preparations own pins; custom widgets retain any other borrowed render data until rendering completes. Opt-in scenes retain the same pins through every prepareViews pass and final rendering.

Parameters
applicationBorrowed UI services.
sizeTerminal viewport for this frame; legacy scenes prepare views with their final sizes here, while opt-in scenes obtain sizes in prepareViews.
Returns
Success or preparation error; no frame is submitted on failure.

Reimplemented in portals::ManagedScene.

◆ prepareViews()

virtual std::expected< void, TreeError > portals::ApplicationScene::prepareViews ( Application & application,
const LayoutSnapshot & snapshot )
virtual

Prepare views from one owning layout snapshot; default is a no-op. Called only for opt-in scenes, on UI outside tree.frame, after prepare has pinned models once. Use those same pins for all views and repeated passes; do not dispatch the scheduler or replace pins here. Snapshot reads survive invalidations caused by earlier views. A new LAYOUT request repeats layout and this hook up to ApplicationOptions::maxPreparationPasses; PAINT does not.

Parameters
applicationBorrowed UI services, available for checked view mutation.
snapshotImmutable owning geometry for this pass, borrowed for the call; copy it if retention is needed. Hidden subtree viewports are zero.
Returns
Success or the original view error; failure submits no frame. Exhausting the pass budget returns WOULD_BLOCK in PREPARE. Hook exceptions also fail PREPARE.

Reimplemented in portals::ManagedScene.

◆ requiresBackgroundExecutor()

virtual bool portals::ApplicationScene::requiresBackgroundExecutor ( ) const
virtualnoexcept
Returns
True when the scene requires background work; default false. Synchronous run creates a default pool before native open. A ready host must inject its own executor. The requirement is sampled before scene callbacks and does not change mid-session.

Reimplemented in portals::ManagedScene.

◆ requiresPointerMotion()

virtual bool portals::ApplicationScene::requiresPointerMotion ( ) const
virtualnoexcept
Returns
True when mounted controls require held-button motion; default false without allocation or tree walks. Sampled once after checked mount, immediately before native open. This requirement does not override ApplicationOptions::nativeMouseReporting=false or dynamically change an already opened transport.

Reimplemented in portals::ManagedScene.

◆ stop()

virtual void portals::ApplicationScene::stop ( Application & application)
virtual

Stop and join only scene-owned producers; called once before terminal restoration.

Parameters
applicationStill-live UI services; scheduler has already been stopped.

Reimplemented in portals::ManagedScene.

◆ usesGeometrySnapshot()

virtual bool portals::ApplicationScene::usesGeometrySnapshot ( ) const
virtualnoexcept
Returns
True to capture owning geometry/visibility/child clips for preparation; default false. The existing dimensions-only capture and its cost remain unchanged when false.

Reimplemented in portals::ManagedScene.

◆ usesPreparedLayout()

virtual bool portals::ApplicationScene::usesPreparedLayout ( ) const
virtualnoexcept

Opt into bounded layout-driven view preparation; default is false.

Returns
True to run preliminary layout and prepareViews before the final frame. False preserves the original single layout/paint/render path.

Reimplemented in portals::ManagedScene.


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