Files
obs-studio/UI/undo-stack-obs.hpp
T
jp9000 78f1983f7d UI: Remove unnecessary Undo/Redo cleanup func
Since fixing the reference holding issue with scene/source deletion, the
undo/redo cleanup function (last param of add_action) is no longer
required.
2021-04-27 20:45:43 -07:00

45 lines
850 B
C++

#pragma once
#include <QString>
#include <deque>
#include <functional>
#include <string>
#include <memory>
#include "ui_OBSBasic.h"
class undo_stack {
typedef std::function<void(const std::string &data)> undo_redo_cb;
typedef std::function<void(bool is_undo)> func;
typedef std::unique_ptr<Ui::OBSBasic> &ui_ptr;
struct undo_redo_t {
QString name;
std::string undo_data;
std::string redo_data;
undo_redo_cb undo;
undo_redo_cb redo;
};
ui_ptr ui;
std::deque<undo_redo_t> undo_items;
std::deque<undo_redo_t> redo_items;
bool disabled = false;
void clear_redo();
public:
undo_stack(ui_ptr ui);
void enable_undo_redo();
void disable_undo_redo();
void clear();
void add_action(const QString &name, undo_redo_cb undo,
undo_redo_cb redo, std::string undo_data,
std::string redo_data);
void undo();
void redo();
};