morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::DocumentScreenHost Class Reference

The framework's ScreenHost over UI documents: it mounts them through an Interpreter, closes them by the protocol of spec 6 §3, and hands a document's navigate to onNavigate, which the deriving host implements. More...

#include <host.hpp>

Inheritance diagram for morph::ui::DocumentScreenHost:
morph::ui::ScreenHost morph::ui::InterpreterHost

Public Member Functions

 DocumentScreenHost (Session &session, Dispatcher &dispatcher, DocumentScreenHostOptions options)
 A host over session and dispatcher.
std::expected< std::unique_ptr< ScreenHandle >, MountError > mount (std::string_view screenId, ParamMap params) override
 Mounts a document screen.
std::expected< std::unique_ptr< ScreenHandle >, MountError > mountInto (std::string_view screenId, ParamMap const &params, ContainerWidget &parent)
 Mounts a screen as mount does, with its root widget appended to parent instead of made a backend root: how a shell puts a screen in its own container, such as a tab's page.
std::optional< std::string > identityOf (std::string_view screenId, ParamMap const &params) override
 The identity a document screen would have with params: its identity evaluated over the params.
void prefetch (std::string_view screenId, ParamMap const &params)
 Starts the requests of a screen's prefetch queries before it mounts (spec 5 §5), so the screen mounts on a warm cache: what a shell does when the pointer rests on an entry for a screen that is not open.
std::expected< std::string, std::string > routeOf (std::string_view screenId, ParamMap const &params) const
 The route of a screen instance (spec 6 §20): routeOf over the screen's declared params.
std::expected< Route, std::string > parseRoute (std::string_view route) const
 Reads a route back against the screen it names (parseRoute over this host's documents).
virtual void onNavigate (NavigateRequest const &request)
 A document asked to open another screen, with how (as). The default hands the screen and its params to onNavigate(screenId, params); a host that shows dialogs, drawers or windows overrides this one.
virtual void onScreenClosed (ScreenHandle &screen)
 A screen this host mounted closed itself, by return or close: self (spec 6 §16). Called after the screen is closed, posted to the owner; the host drops its tab or dialog. The default does nothing.
std::expected< void, MountError > remount (ScreenHandle &handle, std::shared_ptr< Document const > document)
 Mounts a screen this host mounted again, on a changed document (spec 5 §12, development reload).
virtual void onNavigate (std::string_view screenId, ParamMap const &params)=0
 A document asked to open another screen. The host decides whether that is a new tab, a focus or a dialog. Implemented by the host.
Public Member Functions inherited from morph::ui::ScreenHost
 ScreenHost (ScreenHost const &)=delete
ScreenHost & operator= (ScreenHost const &)=delete
 ScreenHost (ScreenHost &&)=delete
ScreenHost & operator= (ScreenHost &&)=delete

Static Public Member Functions

static std::optional< Inspector > inspector (ScreenHandle &handle)
 The development inspector over a screen this host mounted (spec 6 §21): what a shell's inspector window reads. It hands out no access to the screen beyond the inspector's own read-only view and its refetch command.
static Widget * rootOf (ScreenHandle const &handle)
 The root widget of a handle this host mounted, which a host places in its own layout.

Detailed Description

The framework's ScreenHost over UI documents: it mounts them through an Interpreter, closes them by the protocol of spec 6 §3, and hands a document's navigate to onNavigate, which the deriving host implements.

It is the interpreter's InterpreterHost for navigate; every other command goes to the application's host, if one was given. Everything runs on the runtime's owner.

Definition at line 344 of file host.hpp.

Constructor & Destructor Documentation

◆ DocumentScreenHost()

morph::ui::DocumentScreenHost::DocumentScreenHost ( Session & session,
Dispatcher & dispatcher,
DocumentScreenHostOptions options )
inline

A host over session and dispatcher.

Parameters
sessionThe session the screens share. Borrowed: it outlives the host.
dispatcherWhere model calls go. Borrowed: it outlives the host.
optionsThe documents, the backend, the close guard and the application's host.
Exceptions
std::invalid_argumentwithout a document lookup or a backend.

Definition at line 351 of file host.hpp.

Member Function Documentation

◆ mount()

std::expected< std::unique_ptr< ScreenHandle >, MountError > morph::ui::DocumentScreenHost::mount ( std::string_view screenId,
ParamMap params )
inlinenodiscardoverridevirtual

Mounts a document screen.

Parameters
screenIdThe screen id.
paramsIts params.
Returns
Its handle, or why it could not be mounted: an unknown screen, or the interpreter's refusal.

Implements morph::ui::ScreenHost.

Definition at line 368 of file host.hpp.

◆ mountInto()

std::expected< std::unique_ptr< ScreenHandle >, MountError > morph::ui::DocumentScreenHost::mountInto ( std::string_view screenId,
ParamMap const & params,
ContainerWidget & parent )
inlinenodiscard

Mounts a screen as mount does, with its root widget appended to parent instead of made a backend root: how a shell puts a screen in its own container, such as a tab's page.

Parameters
screenIdThe screen id.
paramsIts params.
parentThe container; it outlives the handle.
Returns
Its handle, or why it could not be mounted.

Definition at line 379 of file host.hpp.

◆ identityOf()

std::optional< std::string > morph::ui::DocumentScreenHost::identityOf ( std::string_view screenId,
ParamMap const & params )
inlinenodiscardoverridevirtual

The identity a document screen would have with params: its identity evaluated over the params.

Parameters
screenIdThe screen id.
paramsThe params.
Returns
Its canonical text, or std::nullopt for an unknown screen, one without identity, or one whose identity reads more than its params or is null.

Implements morph::ui::ScreenHost.

Definition at line 389 of file host.hpp.

◆ prefetch()

void morph::ui::DocumentScreenHost::prefetch ( std::string_view screenId,
ParamMap const & params )
inline

Starts the requests of a screen's prefetch queries before it mounts (spec 5 §5), so the screen mounts on a warm cache: what a shell does when the pointer rests on an entry for a screen that is not open.

Each named query's body is evaluated over params alone and its entry warmed through the session's cache, under the token the mounted screen's alias will have. A keyed alias's token follows from its key, and a stateless model's is shared. A private alias gets a fresh token when the screen mounts, so nothing could read what a prefetch warmed: its queries are skipped, as are evaluations, a key or body that reads more than the params, and an entry that is already fresh or in flight.

Parameters
screenIdThe screen id; an unknown one does nothing.
paramsThe params it would mount with.

Definition at line 412 of file host.hpp.

◆ routeOf()

std::expected< std::string, std::string > morph::ui::DocumentScreenHost::routeOf ( std::string_view screenId,
ParamMap const & params ) const
inlinenodiscard

The route of a screen instance (spec 6 §20): routeOf over the screen's declared params.

Parameters
screenIdThe screen id.
paramsIts params.
Returns
The route, or why it has none: an unknown screen, or a param with no route form.

Definition at line 445 of file host.hpp.

◆ parseRoute()

std::expected< Route, std::string > morph::ui::DocumentScreenHost::parseRoute ( std::string_view route) const
inlinenodiscard

Reads a route back against the screen it names (parseRoute over this host's documents).

Parameters
routeThe route.
Returns
The screen and its params, or why the route is refused.

Definition at line 457 of file host.hpp.

◆ onNavigate() [1/2]

virtual void morph::ui::DocumentScreenHost::onNavigate ( NavigateRequest const & request)
inlinevirtual

A document asked to open another screen, with how (as). The default hands the screen and its params to onNavigate(screenId, params); a host that shows dialogs, drawers or windows overrides this one.

Parameters
requestThe request: screen, params, as.

Definition at line 464 of file host.hpp.

◆ onScreenClosed()

virtual void morph::ui::DocumentScreenHost::onScreenClosed ( ScreenHandle & screen)
inlinevirtual

A screen this host mounted closed itself, by return or close: self (spec 6 §16). Called after the screen is closed, posted to the owner; the host drops its tab or dialog. The default does nothing.

Parameters
screenThe handle, closed.

Definition at line 474 of file host.hpp.

◆ remount()

std::expected< void, MountError > morph::ui::DocumentScreenHost::remount ( ScreenHandle & handle,
std::shared_ptr< Document const > document )
inlinenodiscard

Mounts a screen this host mounted again, on a changed document (spec 5 §12, development reload).

The new screen is mounted with the same params in the same place, and each state of its own scope starts from the old screen's value of the state of the same name and type; any other state starts from its init. The old screen is then destroyed, which runs its onUnmount, and the handle shows the new one: its title, dirty and identity follow it, and a pending call stays tied to it. A refused mount keeps the old screen.

Parameters
handleA handle this host mounted.
documentThe changed document of the same screen, loaded.
Returns
Nothing, or why the old screen was kept: a foreign or closed handle, a close or save in progress, or the interpreter's refusal of the new document.

Definition at line 486 of file host.hpp.

◆ inspector()

std::optional< Inspector > morph::ui::DocumentScreenHost::inspector ( ScreenHandle & handle)
inlinestaticnodiscard

The development inspector over a screen this host mounted (spec 6 §21): what a shell's inspector window reads. It hands out no access to the screen beyond the inspector's own read-only view and its refetch command.

Parameters
handleA handle this host mounted.
Returns
The inspector, valid until the screen closes or is remounted; nothing for a closed or foreign handle, and nothing for a screen whose session has DevelopmentTools::Off.

Definition at line 502 of file host.hpp.

◆ rootOf()

Widget * morph::ui::DocumentScreenHost::rootOf ( ScreenHandle const & handle)
inlinestaticnodiscard

The root widget of a handle this host mounted, which a host places in its own layout.

Parameters
handleA handle this host mounted.
Returns
Its root widget, or nullptr for a closed or foreign handle.

Definition at line 514 of file host.hpp.

◆ onNavigate() [2/2]

virtual void morph::ui::ScreenHost::onNavigate ( std::string_view screenId,
ParamMap const & params )
virtual

A document asked to open another screen. The host decides whether that is a new tab, a focus or a dialog. Implemented by the host.

Parameters
screenIdThe screen id.
paramsIts params.

Implements morph::ui::ScreenHost.


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