Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::ShortcutMap Class Reference

(KeyCode, modifiers) → CommandID lookup table. More...

#include <command_registry.hpp>

Classes

struct  Chord
 All chords currently bound to the given command. More...

Public Member Functions

void bind (KeyCode key, std::uint16_t modifiers, CommandID id)
 Associate a (key, modifier) chord with a command.
void unbind (KeyCode key, std::uint16_t modifiers)
 Remove any binding for the given chord. No-op if unbound.
void unbind_command (CommandID id)
 Remove every chord that points to the given command.
CommandID find (KeyCode key, std::uint16_t modifiers) const
 Look up a chord. Returns kInvalidCommandID if unbound.
std::vector< Chord > chords_for (CommandID id) const
std::size_t size () const
 Number of bound chords.
void clear ()
 Clear all bindings.
void save_to (pulp::state::PropertiesFile &props, std::string_view key_prefix="shortcuts") const
 Serialize / restore through a pulp::state::PropertiesFile.
bool load_from (const pulp::state::PropertiesFile &props, std::string_view key_prefix="shortcuts")

Detailed Description

(KeyCode, modifiers) → CommandID lookup table.

Pure data; safe to copy. Persists through save_to / load_from.

Member Function Documentation

◆ bind()

void pulp::view::ShortcutMap::bind ( KeyCode key,
std::uint16_t modifiers,
CommandID id )

Associate a (key, modifier) chord with a command.

If a different command was previously bound to the same chord, it is replaced.

◆ chords_for()

std::vector< Chord > pulp::view::ShortcutMap::chords_for ( CommandID id) const

◆ clear()

void pulp::view::ShortcutMap::clear ( )
inline

Clear all bindings.

◆ find()

CommandID pulp::view::ShortcutMap::find ( KeyCode key,
std::uint16_t modifiers ) const

Look up a chord. Returns kInvalidCommandID if unbound.

◆ load_from()

bool pulp::view::ShortcutMap::load_from ( const pulp::state::PropertiesFile & props,
std::string_view key_prefix = "shortcuts" )

◆ save_to()

void pulp::view::ShortcutMap::save_to ( pulp::state::PropertiesFile & props,
std::string_view key_prefix = "shortcuts" ) const

Serialize / restore through a pulp::state::PropertiesFile.

Round-trip is lossless. The key namespace inside the properties file is "shortcuts.<key>.<mods>" → <command-id> so different subsystems can share one file without colliding (callers can pass a custom key_prefix to use their own namespace).

◆ size()

std::size_t pulp::view::ShortcutMap::size ( ) const
inline

Number of bound chords.

◆ unbind()

void pulp::view::ShortcutMap::unbind ( KeyCode key,
std::uint16_t modifiers )

Remove any binding for the given chord. No-op if unbound.

◆ unbind_command()

void pulp::view::ShortcutMap::unbind_command ( CommandID id)

Remove every chord that points to the given command.


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