morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
shell.hpp File Reference

What the generic client mounts once its source is open: the library's ShellFrame (the sidebar with the navigator, the top bar, the page) with a Workspace of tabs in its page, each a screen mounted through the library's DocumentScreenHost; and the application host a shell of an application's own mounts with. More...

#include <cstddef>
#include <expected>
#include <filesystem>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "../ui/backend.hpp"
#include "../ui/frontend.hpp"
#include "../ui/host.hpp"
#include "../ui/interpreter.hpp"
#include "../ui/route_history.hpp"
#include "../ui/value.hpp"
#include "source.hpp"

Go to the source code of this file.

Classes

struct  morph::client::SignedIn
 What a sign-in installs: the principal, and the session token its server needs (empty for none). More...
class  morph::client::ApplicationHost
 The application's side of the commands a document host does not answer itself (spec 6): sign-in and sign-out, which install a principal into the source, and the file commands, which read a picked file from disk and save a downloaded one, moving the bytes over the source's file side channel or inline. More...
struct  morph::client::ShellOptions
 What a client shell reports, and how it starts. More...

Typedefs

using morph::client::SignInMapper = std::function<std::optional<SignedIn>(ui::Value const& reply)>
 Maps a sign-in mutation's reply to the principal and token to install; std::nullopt refuses the sign-in.

Functions

std::optional< SignedIn > morph::client::defaultSignIn (ui::Value const &reply)
 The default sign-in mapping: a reply {ok, principal, token}, refused when ok is false or there is no principal; token may be absent.
std::unique_ptr< ui::MountedShell > morph::client::mountShell (ui::AppContext &context, ui::IViewBackend &backend, std::expected< ui::Bundle, ui::ConnectError > opened, Source &source, ShellOptions options)
 Mounts the client's shell for what source delivered.

Detailed Description

What the generic client mounts once its source is open: the library's ShellFrame (the sidebar with the navigator, the top bar, the page) with a Workspace of tabs in its page, each a screen mounted through the library's DocumentScreenHost; and the application host a shell of an application's own mounts with.

Specified in docs/spec/client/client.md.

Definition in file shell.hpp.

Typedef Documentation

◆ SignInMapper

using morph::client::SignInMapper = std::function<std::optional<SignedIn>(ui::Value const& reply)>

Maps a sign-in mutation's reply to the principal and token to install; std::nullopt refuses the sign-in.

Definition at line 39 of file shell.hpp.

Function Documentation

◆ defaultSignIn()

std::optional< SignedIn > morph::client::defaultSignIn ( ui::Value const & reply)
nodiscard

The default sign-in mapping: a reply {ok, principal, token}, refused when ok is false or there is no principal; token may be absent.

Parameters
replyThe sign-in mutation's reply.
Returns
The principal and token, or std::nullopt.

◆ mountShell()

std::unique_ptr< ui::MountedShell > morph::client::mountShell ( ui::AppContext & context,
ui::IViewBackend & backend,
std::expected< ui::Bundle, ui::ConnectError > opened,
Source & source,
ShellOptions options )
nodiscard

Mounts the client's shell for what source delivered.

On a bundle: loads each screen of source.screens() with the source's catalog facts, opens the start screen as a tab, and on a document's navigate or a navigator choice opens the screen asked for as a tab (or focuses the tab that shows it), from a task posted to the owner, never from inside the handler that asked. A sign-in or sign-out closes every tab and rebuilds the frame for the new catalog. On a ConnectError, or when no screen can be mounted, shows why as text.

Parameters
contextThe frontend's context.
backendThe view backend the screens mount on. Borrowed: it outlives the shell.
openedWhat the source delivered.
sourceThe source; it outlives the shell.
optionsThe start screen and the observers.
Returns
The shell; destroying it unmounts everything.
Exceptions
std::invalid_argumentwhen options.signIn is empty.