#include <contract_editor_session.hpp>
Classes | |
| struct | HostHooks |
| What the adapter does for the editor's context. More... | |
Public Types | |
| enum class | IdleSource : std::uint8_t { self_paced , host_driven } |
| Who calls tick() while attached. More... | |
Public Member Functions | |
| ~ContractEditorSession () | |
| ContractEditorSession (const ContractEditorSession &)=delete | |
| ContractEditorSession & | operator= (const ContractEditorSession &)=delete |
| Editor * | editor () const |
| The editor, or null after invalidate(). | |
| StateStoreParamPort * | param_port () const |
| This session's parameter port, or null after invalidate(). | |
| bool | is_attached () const |
| bool | attach (const NativeParent &parent) |
| Attach the editor to parent and start the idle tick. | |
| void | detach () |
| Stop the tick, release every gesture this session holds, then detach the editor. | |
| void | close_for_owner () |
| The processor is going away while the host's window still exists: stop the tick, release every gesture, detach the editor if attached, then destroy it. | |
| void | invalidate () |
| The host's window is already gone: stop the tick, release every gesture, invalidate the editor and destroy it. | |
| void | use_self_paced_idle () |
| Tick from the session's own timer from now on, for an adapter whose host timer is unavailable. | |
| IdleSource | idle_source () const |
| Who calls tick() while attached. | |
| void | tick () |
| One idle tick: Editor::idle() while attached. | |
| bool | register_with (ContractSessionRegistry ®istry) |
| Be closed by registry when its adapter instance goes away first. | |
| void | disconnect_owner () |
| The owner is going away on another thread: release every gesture, cut the port from the store and refuse the context's host hooks. | |
| EditorSize | size () const |
| The editor's size, or its preferred size while it reports none. | |
| ViewSize | size_hints () const |
| The editor's size hints (defaults when the editor is gone). | |
| bool | set_size (std::uint32_t width, std::uint32_t height) |
| A host resize, keeping the scale the editor reports. | |
| bool | set_scale (double scale) |
| A new content scale at the current size. | |
| bool | resizable () const |
| False only for an editor whose hints fix its size (equal, non-zero minimum and maximum on both axes). | |
| bool | constrain (std::uint32_t &width, std::uint32_t &height) const |
| Adjust a proposed size through the editor, then clamp it to the hints. | |
| KeyDisposition | offer_key (const EditorKeyEvent &event) |
| Offer a key. Forward when not attached. | |
| void | focus_changed (bool focused) |
| void | visibility_changed (bool visible) |
Static Public Member Functions | |
| static std::unique_ptr< ContractEditorSession > | create (Processor &processor, state::StateStore &store, EditorFactory &factory, HostHooks hooks, IdleSource idle=IdleSource::self_paced) |
| A session over a new editor from factory, or null when the factory does not offer the editor role or builds no editor. | |
Static Public Attributes | |
| static constexpr int | kIdleIntervalMs = 16 |
| Interval of the session's own idle tick while attached (about 60 Hz). | |
Friends | |
| class | ContractSessionRegistry |
|
strong |
Who calls tick() while attached.
| Enumerator | |
|---|---|
| self_paced | the session's own main-thread chain |
| host_driven | the adapter, from a host timer |
| pulp::format::ContractEditorSession::~ContractEditorSession | ( | ) |
|
delete |
| bool pulp::format::ContractEditorSession::attach | ( | const NativeParent & | parent | ) |
Attach the editor to parent and start the idle tick.
False when the session is already attached, the parent is empty or of no kind, or the editor refuses it.
| void pulp::format::ContractEditorSession::close_for_owner | ( | ) |
The processor is going away while the host's window still exists: stop the tick, release every gesture, detach the editor if attached, then destroy it.
Every later call is a refusal.
| bool pulp::format::ContractEditorSession::constrain | ( | std::uint32_t & | width, |
| std::uint32_t & | height ) const |
Adjust a proposed size through the editor, then clamp it to the hints.
False when nothing usable results.
|
static |
A session over a new editor from factory, or null when the factory does not offer the editor role or builds no editor.
| void pulp::format::ContractEditorSession::detach | ( | ) |
Stop the tick, release every gesture this session holds, then detach the editor.
A no-op when not attached.
| void pulp::format::ContractEditorSession::disconnect_owner | ( | ) |
The owner is going away on another thread: release every gesture, cut the port from the store and refuse the context's host hooks.
Any thread. The editor stays attached, but is no longer ticked, until close_for_owner() runs on the main thread.
|
inline |
The editor, or null after invalidate().
| void pulp::format::ContractEditorSession::focus_changed | ( | bool | focused | ) |
|
inline |
Who calls tick() while attached.
| void pulp::format::ContractEditorSession::invalidate | ( | ) |
The host's window is already gone: stop the tick, release every gesture, invalidate the editor and destroy it.
Every later call is a refusal.
|
inline |
| KeyDisposition pulp::format::ContractEditorSession::offer_key | ( | const EditorKeyEvent & | event | ) |
Offer a key. Forward when not attached.
|
delete |
|
inline |
This session's parameter port, or null after invalidate().
| bool pulp::format::ContractEditorSession::register_with | ( | ContractSessionRegistry & | registry | ) |
Be closed by registry when its adapter instance goes away first.
The session must be owned by a std::shared_ptr; false otherwise.
| bool pulp::format::ContractEditorSession::resizable | ( | ) | const |
False only for an editor whose hints fix its size (equal, non-zero minimum and maximum on both axes).
| bool pulp::format::ContractEditorSession::set_scale | ( | double | scale | ) |
A new content scale at the current size.
| bool pulp::format::ContractEditorSession::set_size | ( | std::uint32_t | width, |
| std::uint32_t | height ) |
A host resize, keeping the scale the editor reports.
| EditorSize pulp::format::ContractEditorSession::size | ( | ) | const |
The editor's size, or its preferred size while it reports none.
| ViewSize pulp::format::ContractEditorSession::size_hints | ( | ) | const |
The editor's size hints (defaults when the editor is gone).
| void pulp::format::ContractEditorSession::tick | ( | ) |
One idle tick: Editor::idle() while attached.
| void pulp::format::ContractEditorSession::use_self_paced_idle | ( | ) |
Tick from the session's own timer from now on, for an adapter whose host timer is unavailable.
Starts the tick at once when attached.
| void pulp::format::ContractEditorSession::visibility_changed | ( | bool | visible | ) |
|
friend |
|
staticconstexpr |
Interval of the session's own idle tick while attached (about 60 Hz).