F.E.I.S/HistoryActions.h
Stepland 8d44098063 - Tab selection in linear view
- Cut/Copy/Paste selected notes
- LN displayed correctly in the Linear View
- bunch of other small stuff
2019-03-27 20:37:30 +01:00

69 lines
1.5 KiB
C++

#include <utility>
//
// Created by Syméon on 02/03/2019.
//
#ifndef FEIS_HISTORYSTATE_H
#define FEIS_HISTORYSTATE_H
#include <string>
#include <variant>
#include <memory>
#include "Chart.h"
class EditorState;
/*
* Base class for history actions (stuff that is stored inside of History objects)
*/
class ActionWithMessage {
public:
explicit ActionWithMessage(std::string message = "") : message(std::move(message)) {};
const std::string &getMessage() const;
virtual void doAction(EditorState &ed) const {};
virtual void undoAction(EditorState &ed) const {};
virtual ~ActionWithMessage() = default;
protected:
std::string message;
};
/*
* A history action replacing every note, typically the first state in history
*/
class OpenChart : public ActionWithMessage {
public:
explicit OpenChart(Chart c);
void doAction(EditorState &ed) const override;
protected:
const std::set<Note> notes;
};
/*
* Some notes have been toggled, either on or off depending on have_been_added
*/
class ToggledNotes : public ActionWithMessage {
public:
ToggledNotes(std::set<Note> notes, bool have_been_added);
void doAction(EditorState &ed) const override;
void undoAction(EditorState &ed) const override;
protected:
const bool have_been_added;
const std::set<Note> notes;
};
auto print_history_message = [](const std::shared_ptr<ActionWithMessage> &hs) -> std::string {
return (*hs).getMessage();
};
#endif //FEIS_HISTORYSTATE_H