From dcdedf5b1ae6c3d4eeeb9fdfa7c88fb75c4c4fbd Mon Sep 17 00:00:00 2001 From: Alexandre Bique Date: Mon, 2 Sep 2024 14:46:32 +0200 Subject: [PATCH] undo: have a single delta for both undo and redo --- include/clap/ext/draft/undo.h | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/include/clap/ext/draft/undo.h b/include/clap/ext/draft/undo.h index 365780e6..4cfa17ff 100644 --- a/include/clap/ext/draft/undo.h +++ b/include/clap/ext/draft/undo.h @@ -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 @@ -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 @@ -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);