Skip to content

Commit

Permalink
undo: have a single delta for both undo and redo
Browse files Browse the repository at this point in the history
  • Loading branch information
abique committed Sep 2, 2024
1 parent 8323ec1 commit dcdedf5
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions include/clap/ext/draft/undo.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,23 @@ typedef struct clap_plugin_undo {
bool(CLAP_ABI *can_use_delta_format_version)(const clap_plugin_t *plugin,
clap_id format_version);

// Applies synchronously a delta.
// Undo using the delta.
// Returns true on success.
//
// [main-thread]
bool(CLAP_ABI *apply_delta)(const clap_plugin_t *plugin,
clap_id format_version,
const void *delta,
size_t delta_size);
bool(CLAP_ABI *undo)(const clap_plugin_t *plugin,
clap_id format_version,
const void *delta,
size_t delta_size);

// Redo using the delta.
// Returns true on success.
//
// [main-thread]
bool(CLAP_ABI *redo)(const clap_plugin_t *plugin,
clap_id format_version,
const void *delta,
size_t delta_size);

// Sets the undo context.
// flags: bitmask of clap_undo_context_flags values
Expand Down Expand Up @@ -112,7 +121,7 @@ typedef struct clap_host_undo {
//
// name: mandatory null terminated string describing the change, this is displayed to the user
//
// deltas: optional, they are binary blobs used to perform the undo and redo. When not available
// delta: optional, it is a binary blobs used to perform the undo and redo. When not available
// the host will save the plugin state and use state->load() to perform undo and redo.
//
// Note: the provided delta may be used for incremental state saving and crash recovery. The
Expand All @@ -128,18 +137,16 @@ typedef struct clap_host_undo {
// [main-thread]
void(CLAP_ABI *change_made)(const clap_host_t *host,
const char *name,
const void *redo_delta,
size_t redo_delta_size,
const void *undo_delta,
size_t undo_delta_size);
const void *delta,
size_t delta_size);

// Asks the host to perform the next undo step.
// This operation may be asynchronous.
// This operation may be asynchronous and isn't available while the host is within a change.
// [main-thread]
void(CLAP_ABI *undo)(const clap_host_t *host);

// Asks the host to perform the next redo step.
// This operation may be asynchronous.
// This operation may be asynchronous and isn't available while the host is within a change.
// [main-thread]
void(CLAP_ABI *redo)(const clap_host_t *host);

Expand Down

0 comments on commit dcdedf5

Please sign in to comment.