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

A mounted screen: its scopes, its view mounted through Mounted, and what its host asks of it. More...

#include <interpreter.hpp>

Public Member Functions

 Screen (Screen const &)=delete
Screen & operator= (Screen const &)=delete
 Screen (Screen &&)=delete
Screen & operator= (Screen &&)=delete
 ~Screen ()
 Runs onUnmount, then unmounts.
Widget & root () const
 The root widget.
std::string const & id () const noexcept
 The document's id.
Value read (Json const &expression) const
 Evaluates an expression in the screen's scope: what a host reads (title, identity), and what a test inspects.
Value title () const
 Evaluates the document's title.
Value identity () const
 Evaluates the document's identity.
Value subtitle () const
 Evaluates the document's subtitle, the head's line under the title.
std::vector< HeadBadge > status () const
 The head's status badges that are visible now, in order. A tracked read.
std::vector< HeadAction > actions () const
 The head's actions that are visible now, in order, each with whether it is enabled. A tracked read.
bool runAction (std::string_view actionId)
 Runs a head action's onClick as a user event in the screen scope, in one batch.
bool dirty () const
 Evaluates the document's dirty.
bool pending () const
 Whether the screen has work a close waits for: an open dialog or drawer, a mutation run, or an upload or download in flight, in any of its scopes (spec 6 §3). A tracked read, so an Effect that reads it runs again when it changes.
reactive::Runtime & runtime () const noexcept
 The reactive runtime the screen runs on.
bool requestClose ()
 Runs onClose, as the host does before it closes the screen.
std::shared_ptr< bool const > beginClose ()
 Runs onClose, and hands back the flag its cancelClose sets.
bool declares (std::string_view key) const
 Whether the document declares a lifecycle command list.
void runLifecycle (std::string_view key)
 Runs a lifecycle command list: onSave, onBackendChange, or any other the document declares.
std::vector< Refusal > const & diagnostics () const noexcept
 The diagnostics reported so far, each path and reason once.
bool setPreference (std::string const &point, Value value)
 Sets the user's choice at a customization point, as the preferences store loaded or the user made it. A choice that does not fit the point is ignored (spec 5 §12b).
Document const & document () const noexcept
 The screen's document, whose customize block names the points a preferences store loads.
BorrowedModel lend (std::string_view alias) const
 What an alias of this screen lends to a screen it opens that borrows it.

Detailed Description

A mounted screen: its scopes, its view mounted through Mounted, and what its host asks of it.

Neither copyable nor movable. It belongs to the runtime's owner; the runtime, the session, the dispatcher and the backend outlive it. Destroying it runs onUnmount, unmounts the view and releases every scope.

Definition at line 2696 of file interpreter.hpp.

Constructor & Destructor Documentation

◆ ~Screen()

morph::ui::Screen::~Screen ( )
inline

Runs onUnmount, then unmounts.

Definition at line 2704 of file interpreter.hpp.

Member Function Documentation

◆ root()

Widget & morph::ui::Screen::root ( ) const
inlinenodiscard

The root widget.

Returns
It, valid as long as the screen.

Definition at line 2720 of file interpreter.hpp.

◆ id()

std::string const & morph::ui::Screen::id ( ) const
inlinenodiscardnoexcept

The document's id.

Returns
It.

Definition at line 2729 of file interpreter.hpp.

◆ read()

Value morph::ui::Screen::read ( Json const & expression) const
inlinenodiscard

Evaluates an expression in the screen's scope: what a host reads (title, identity), and what a test inspects.

Parameters
expressionThe expression's JSON.
Returns
The value; null for an expression that does not parse.

Definition at line 2735 of file interpreter.hpp.

◆ title()

Value morph::ui::Screen::title ( ) const
inlinenodiscard

Evaluates the document's title.

Returns
It, or null.

Definition at line 2745 of file interpreter.hpp.

◆ identity()

Value morph::ui::Screen::identity ( ) const
inlinenodiscard

Evaluates the document's identity.

Returns
It, or null.

Definition at line 2749 of file interpreter.hpp.

◆ subtitle()

Value morph::ui::Screen::subtitle ( ) const
inlinenodiscard

Evaluates the document's subtitle, the head's line under the title.

Returns
It, or null.

Definition at line 2753 of file interpreter.hpp.

◆ status()

std::vector< HeadBadge > morph::ui::Screen::status ( ) const
inlinenodiscard

The head's status badges that are visible now, in order. A tracked read.

Returns
They.

Definition at line 2757 of file interpreter.hpp.

◆ actions()

std::vector< HeadAction > morph::ui::Screen::actions ( ) const
inlinenodiscard

The head's actions that are visible now, in order, each with whether it is enabled. A tracked read.

Returns
They.

Definition at line 2770 of file interpreter.hpp.

◆ runAction()

bool morph::ui::Screen::runAction ( std::string_view actionId)
inline

Runs a head action's onClick as a user event in the screen scope, in one batch.

Parameters
actionIdThe action's id.
Returns
Whether it ran: false, with a diagnostic, for an id the head does not hold, or holds hidden or disabled.

Definition at line 2788 of file interpreter.hpp.

◆ dirty()

bool morph::ui::Screen::dirty ( ) const
inlinenodiscard

Evaluates the document's dirty.

Returns
Whether it is true.

Definition at line 2808 of file interpreter.hpp.

◆ pending()

bool morph::ui::Screen::pending ( ) const
inlinenodiscard

Whether the screen has work a close waits for: an open dialog or drawer, a mutation run, or an upload or download in flight, in any of its scopes (spec 6 §3). A tracked read, so an Effect that reads it runs again when it changes.

Returns
It.

Definition at line 2818 of file interpreter.hpp.

◆ runtime()

reactive::Runtime & morph::ui::Screen::runtime ( ) const
inlinenodiscardnoexcept

The reactive runtime the screen runs on.

Returns
It.

Definition at line 2822 of file interpreter.hpp.

◆ requestClose()

bool morph::ui::Screen::requestClose ( )
inline

Runs onClose, as the host does before it closes the screen.

Returns
False when onClose ran cancelClose: the screen stays open.

Definition at line 2826 of file interpreter.hpp.

◆ beginClose()

std::shared_ptr< bool const > morph::ui::Screen::beginClose ( )
inlinenodiscard

Runs onClose, and hands back the flag its cancelClose sets.

The flag is shared with every command list onClose starts, such as the onResult of a confirm dialog it opens, so it can still be set after this returns; a host reads it once the screen is no longer pending().

Returns
The flag, or nullptr when the document declares no onClose.

Definition at line 2836 of file interpreter.hpp.

◆ declares()

bool morph::ui::Screen::declares ( std::string_view key) const
inlinenodiscard

Whether the document declares a lifecycle command list.

Parameters
keyThe key: onClose, onSave, …
Returns
It.

Definition at line 2847 of file interpreter.hpp.

◆ runLifecycle()

void morph::ui::Screen::runLifecycle ( std::string_view key)
inline

Runs a lifecycle command list: onSave, onBackendChange, or any other the document declares.

Parameters
keyThe key.

Definition at line 2851 of file interpreter.hpp.

◆ diagnostics()

std::vector< Refusal > const & morph::ui::Screen::diagnostics ( ) const
inlinenodiscardnoexcept

The diagnostics reported so far, each path and reason once.

Returns
They.

Definition at line 2859 of file interpreter.hpp.

◆ setPreference()

bool morph::ui::Screen::setPreference ( std::string const & point,
Value value )
inline

Sets the user's choice at a customization point, as the preferences store loaded or the user made it. A choice that does not fit the point is ignored (spec 5 §12b).

Parameters
pointThe point.
valueThe choice.
Returns
Whether it fits and was taken.

Definition at line 2866 of file interpreter.hpp.

◆ document()

Document const & morph::ui::Screen::document ( ) const
inlinenodiscardnoexcept

The screen's document, whose customize block names the points a preferences store loads.

Returns
It.

Definition at line 2879 of file interpreter.hpp.

◆ lend()

BorrowedModel morph::ui::Screen::lend ( std::string_view alias) const
inlinenodiscard

What an alias of this screen lends to a screen it opens that borrows it.

Parameters
aliasThe alias.
Returns
Its channel and token; an empty channel when it has none.

Definition at line 7668 of file interpreter.hpp.


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