|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
Builds every widget of a mounted view tree as a core::tui::Component on one Screen. More...
#include <backend.hpp>
Public Types | |
| using | Clock = std::function<std::chrono::steady_clock::time_point()> |
| Reads the current time. | |
Public Member Functions | |
| Backend (::core::tui::Screen &screen, Clock now={}) | |
| ~Backend () override | |
| Destroys the backend; every widget it made must already be gone. | |
| Backend (Backend const &)=delete | |
| Backend & | operator= (Backend const &)=delete |
| Backend (Backend &&)=delete | |
| Backend & | operator= (Backend &&)=delete |
| std::unique_ptr< ui::TextWidget > | createText (ui::ContainerWidget *parent) override |
| Makes read-only text. | |
| std::unique_ptr< ui::ButtonWidget > | createButton (ui::ContainerWidget *parent) override |
| Makes a push button. | |
| std::unique_ptr< ui::TextInputWidget > | createTextInput (ui::ContainerWidget *parent, ui::TextInputMode mode) override |
| Makes a text field. | |
| std::unique_ptr< ui::CheckboxWidget > | createCheckbox (ui::ContainerWidget *parent) override |
| Makes a check box. | |
| std::unique_ptr< ui::SelectWidget > | createSelect (ui::ContainerWidget *parent, ui::SelectStyle style) override |
| Makes a choice of one option. | |
| std::unique_ptr< ui::MenuWidget > | createMenu (ui::ContainerWidget *parent) override |
| Makes a command list. | |
| std::unique_ptr< ui::StackWidget > | createStack (ui::ContainerWidget *parent, ui::Axis axis) override |
| Makes a stack. | |
| std::unique_ptr< ui::GridWidget > | createGrid (ui::ContainerWidget *parent) override |
| Makes a grid. | |
| std::unique_ptr< ui::SpacerWidget > | createSpacer (ui::ContainerWidget *parent) override |
| Makes empty space. | |
| std::unique_ptr< ui::PanelWidget > | createPanel (ui::ContainerWidget *parent) override |
| Makes a titled frame. | |
| std::unique_ptr< ui::ScrollWidget > | createScroll (ui::ContainerWidget *parent, ui::Axis axis) override |
| Makes a scroll area. | |
| std::unique_ptr< ui::SlotWidget > | createSlot (ui::ContainerWidget *parent) override |
| Makes a slot. | |
| std::unique_ptr< ui::TabsWidget > | createTabs (ui::ContainerWidget *parent) override |
| Makes a tab bar. | |
| std::unique_ptr< ui::DialogWidget > | createDialog (ui::ContainerWidget *parent) override |
| Makes a modal overlay. | |
| std::unique_ptr< ui::ToastWidget > | createToast (ui::ContainerWidget *parent) override |
| Makes a transient message. | |
| std::unique_ptr< ui::BusyWidget > | createBusy (ui::ContainerWidget *parent) override |
| Makes a progress indicator. | |
| std::unique_ptr< ui::TableWidget > | createTable (ui::ContainerWidget *parent) override |
| Makes a table. | |
| std::unique_ptr< ui::DateTimeInputWidget > | createDateTimeInput (ui::ContainerWidget *parent, ui::DateMode mode, int offsetMinutes) override |
| Makes a date or date-and-time field. | |
| std::unique_ptr< ui::SliderWidget > | createSlider (ui::ContainerWidget *parent) override |
| Makes a slider. | |
| std::unique_ptr< ui::FilePickerWidget > | createFilePicker (ui::ContainerWidget *parent, ui::FilePickerMode mode) override |
| Makes a file path field. | |
| std::unique_ptr< ui::BannerWidget > | createBanner (ui::ContainerWidget *parent) override |
| Makes a banner. | |
| std::unique_ptr< ui::BadgeWidget > | createBadge (ui::ContainerWidget *parent) override |
| Makes a badge. | |
| std::unique_ptr< ui::ProgressWidget > | createProgress (ui::ContainerWidget *parent) override |
| Makes a progress bar. | |
| std::unique_ptr< ui::StepsWidget > | createSteps (ui::ContainerWidget *parent) override |
| Makes a steps indicator. | |
| std::unique_ptr< ui::KeyValueWidget > | createKeyValue (ui::ContainerWidget *parent) override |
| Makes a key-value list. | |
| std::unique_ptr< ui::EmptyStateWidget > | createEmptyState (ui::ContainerWidget *parent) override |
| Makes an empty state. | |
| std::unique_ptr< ui::DrawerWidget > | createDrawer (ui::ContainerWidget *parent, ui::Side side) override |
| Makes a drawer. | |
| std::unique_ptr< ui::SplitterWidget > | createSplitter (ui::ContainerWidget *parent, ui::Axis axis) override |
| Makes a splitter. | |
| std::unique_ptr< ui::CollapsibleWidget > | createCollapsible (ui::ContainerWidget *parent) override |
| Makes a collapsible section. | |
| std::unique_ptr< ui::DropZoneWidget > | createDropZone (ui::ContainerWidget *parent) override |
| Makes a drop zone. | |
| void | fit () |
| Sizes every root widget to the screen's viewport and centres every open dialog; call before each Screen::draw(), which is how a resize reaches the tree. | |
| void | focusNext () |
| Moves keyboard focus to the next focusable widget — inside the innermost open dialog when one is open, because Screen::focusNext does not know overlays. | |
| void | focusPrev () |
| Moves keyboard focus to the previous focusable widget, with focusNext's dialog rule. | |
| void | focusFirst () |
| Focuses the first focusable widget when nothing has focus yet, or when the focus is on an open dialog's frame (the dialog held nothing focusable when it opened, and has since gained something). | |
| bool | endDrag () |
| Ends the drag-and-drop gesture in progress, if any, with no drop, as Esc does. | |
| bool | animating () const noexcept |
| Whether any Busy widget is spinning, so the frontend should keep advancing the animation. | |
| void | advanceAnimation () noexcept |
| Moves every spinning Busy to its next frame; the next draw shows it. | |
| Public Member Functions inherited from morph::ui::IViewBackend | |
| IViewBackend (IViewBackend const &)=delete | |
| IViewBackend & | operator= (IViewBackend const &)=delete |
| IViewBackend (IViewBackend &&)=delete | |
| IViewBackend & | operator= (IViewBackend &&)=delete |
| virtual std::unique_ptr< CustomWidget > | createCustom (ContainerWidget *parent, CustomRequest const &request) |
| Loads the component a custom node names, if this backend can. The only factory that may return null: null means "not loaded", and the mount shows the node's fallback instead. A backend that loads no components keeps this default. | |
Builds every widget of a mounted view tree as a core::tui::Component on one Screen.
Containers arrange their children in cells when the screen renders them; a Dialog and an open Dropdown are screen overlays; drag-and-drop runs on the mouse with pointer capture. The factories, documented on ui::IViewBackend, run on the screen's thread. Widgets must be destroyed before the backend, and the backend before the screen.
The widgets show no tooltips, so nothing here needs the screen's hover timer (Screen::tickHover). A widget that goes drops the screen's hover target, so a caller that does tick it never reaches a destroyed component.
Definition at line 28 of file backend.hpp.
| using morph::tui::Backend::Clock = std::function<std::chrono::steady_clock::time_point()> |
Reads the current time.
Definition at line 31 of file backend.hpp.
|
explicit |
| screen | Where every widget renders. Borrowed: it must outlive the backend. |
| now | The clock the widgets read the time from (a table telling a double click from two clicks); empty reads std::chrono::steady_clock. A test passes one it advances itself. |
|
nodiscardoverridevirtual |
Makes read-only text.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a push button.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a text field.
| parent | The container to append to, or null for a root. |
| mode | Single-line, multiline or password. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a check box.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a choice of one option.
| parent | The container to append to, or null for a root. |
| style | Dropdown or radio. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a command list.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a stack.
| parent | The container to append to, or null for a root. |
| axis | Vertical (a column) or horizontal (a row). |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a grid.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes empty space.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a titled frame.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a scroll area.
| parent | The container to append to, or null for a root. |
| axis | The scroll direction. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a slot.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a tab bar.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a modal overlay.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a transient message.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a progress indicator.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a table.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a date or date-and-time field.
| parent | The container to append to, or null for a root. |
| mode | Date, or date and time. |
| offsetMinutes | The display zone's offset from UTC. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a slider.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a file path field.
| parent | The container to append to, or null for a root. |
| mode | Open or save. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a banner.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a badge.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a progress bar.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a steps indicator.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a key-value list.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes an empty state.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a drawer.
| parent | The container to append to, or null for a root. |
| side | The edge it slides in from. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a splitter.
| parent | The container to append to, or null for a root. |
| axis | The axis its panes are laid out along. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a collapsible section.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
|
nodiscardoverridevirtual |
Makes a drop zone.
| parent | The container to append to, or null for a root. |
Implements morph::ui::IViewBackend.
| bool morph::tui::Backend::endDrag | ( | ) |
Ends the drag-and-drop gesture in progress, if any, with no drop, as Esc does.
Esc reaches the gesture through the widget that has the keyboard focus; a frontend calls this for an Esc no widget took, so that a drag ends while nothing is focused too.
|
nodiscardnoexcept |
Whether any Busy widget is spinning, so the frontend should keep advancing the animation.