UI: Add obs_frontend_add_undo_redo_action
This commit is contained in:
parent
318db2842a
commit
2d3013ccdc
@ -670,6 +670,20 @@ struct OBSStudioAPI : obs_frontend_callbacks {
|
|||||||
return bstrdup(main->lastReplay.c_str());
|
return bstrdup(main->lastReplay.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void obs_frontend_add_undo_redo_action(const char *name,
|
||||||
|
const undo_redo_cb undo,
|
||||||
|
const undo_redo_cb redo,
|
||||||
|
const char *undo_data,
|
||||||
|
const char *redo_data,
|
||||||
|
bool repeatable) override
|
||||||
|
{
|
||||||
|
main->undo_s.add_action(
|
||||||
|
name,
|
||||||
|
[undo](const std::string &data) { undo(data.c_str()); },
|
||||||
|
[redo](const std::string &data) { redo(data.c_str()); },
|
||||||
|
undo_data, redo_data, repeatable);
|
||||||
|
}
|
||||||
|
|
||||||
void on_load(obs_data_t *settings) override
|
void on_load(obs_data_t *settings) override
|
||||||
{
|
{
|
||||||
for (size_t i = saveCallbacks.size(); i > 0; i--) {
|
for (size_t i = saveCallbacks.size(); i > 0; i--) {
|
||||||
|
@ -600,3 +600,14 @@ char *obs_frontend_get_last_replay(void)
|
|||||||
return !!callbacks_valid() ? c->obs_frontend_get_last_replay()
|
return !!callbacks_valid() ? c->obs_frontend_get_last_replay()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void obs_frontend_add_undo_redo_action(const char *name,
|
||||||
|
const undo_redo_cb undo,
|
||||||
|
const undo_redo_cb redo,
|
||||||
|
const char *undo_data,
|
||||||
|
const char *redo_data, bool repeatable)
|
||||||
|
{
|
||||||
|
if (callbacks_valid())
|
||||||
|
c->obs_frontend_add_undo_redo_action(
|
||||||
|
name, undo, redo, undo_data, redo_data, repeatable);
|
||||||
|
}
|
||||||
|
@ -237,6 +237,11 @@ EXPORT char *obs_frontend_get_last_recording(void);
|
|||||||
EXPORT char *obs_frontend_get_last_screenshot(void);
|
EXPORT char *obs_frontend_get_last_screenshot(void);
|
||||||
EXPORT char *obs_frontend_get_last_replay(void);
|
EXPORT char *obs_frontend_get_last_replay(void);
|
||||||
|
|
||||||
|
typedef void (*undo_redo_cb)(const char *data);
|
||||||
|
EXPORT void obs_frontend_add_undo_redo_action(
|
||||||
|
const char *name, const undo_redo_cb undo, const undo_redo_cb redo,
|
||||||
|
const char *undo_data, const char *redo_data, bool repeatable);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -153,6 +153,13 @@ struct obs_frontend_callbacks {
|
|||||||
virtual char *obs_frontend_get_last_recording(void) = 0;
|
virtual char *obs_frontend_get_last_recording(void) = 0;
|
||||||
virtual char *obs_frontend_get_last_screenshot(void) = 0;
|
virtual char *obs_frontend_get_last_screenshot(void) = 0;
|
||||||
virtual char *obs_frontend_get_last_replay(void) = 0;
|
virtual char *obs_frontend_get_last_replay(void) = 0;
|
||||||
|
|
||||||
|
virtual void obs_frontend_add_undo_redo_action(const char *name,
|
||||||
|
const undo_redo_cb undo,
|
||||||
|
const undo_redo_cb redo,
|
||||||
|
const char *undo_data,
|
||||||
|
const char *redo_data,
|
||||||
|
bool repeatable) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT void
|
EXPORT void
|
||||||
|
@ -226,6 +226,10 @@ Structures/Enumerations
|
|||||||
|
|
||||||
Translation callback
|
Translation callback
|
||||||
|
|
||||||
|
.. type:: void (*undo_redo_cb)(const char *data)
|
||||||
|
|
||||||
|
Undo redo callback
|
||||||
|
|
||||||
|
|
||||||
Functions
|
Functions
|
||||||
---------
|
---------
|
||||||
@ -846,3 +850,15 @@ Functions
|
|||||||
:c:func:`bfree()`
|
:c:func:`bfree()`
|
||||||
|
|
||||||
.. versionadded:: 29.0.0
|
.. versionadded:: 29.0.0
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
|
.. function:: void obs_frontend_add_undo_redo_action(const char *name, const undo_redo_cb undo, const undo_redo_cb redo, const char *undo_data, const char *redo_data, bool repeatable)
|
||||||
|
|
||||||
|
:param name: The name of the undo redo action
|
||||||
|
:param undo: Callback to use for undo
|
||||||
|
:param redo: Callback to use for redo
|
||||||
|
:param undo_data: String with data for the undo callback
|
||||||
|
:param redo_data: String with data for the redo callback
|
||||||
|
:param repeatable: Allow multiple actions with the same name to be merged to 1 undo redo action.
|
||||||
|
This uses the undo action from the first and the redo action from the last action.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user