summaryrefslogtreecommitdiffstats
path: root/src/undo-stack-observer.h
blob: 0d277800b5807250dd1f48f1dd88688254b3da2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Authors:
 * David Yip <yipdw@rose-hulman.edu>
 *
 * Copyright (c) 2005 Authors
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#ifndef SEEN_UNDO_COMMIT_OBSERVER_H
#define SEEN_UNDO_COMMIT_OBSERVER_H

#include "inkgc/gc-managed.h"

namespace Inkscape {

struct Event;

/**
 * Observes changes made to the undo and redo stacks.
 *
 * More specifically, an UndoStackObserver is a class that receives notifications when
 * any of the following events occur:
 * <ul>
 * 	<li>A change is committed to the undo stack.</li>
 * 	<li>An undo action is made.</li>
 * 	<li>A redo action is made.</li>
 * </ul>
 *
 * UndoStackObservers should not be used on their own.  Instead, they should be registered
 * with a CompositeUndoStackObserver.
 */
class UndoStackObserver : public GC::Managed<> {
public:
	UndoStackObserver() = default;
	virtual ~UndoStackObserver() = default;

	/**
	 * Triggered when the user issues an undo command.
	 *
	 * \param log Pointer to an Event describing the undone event.
	 */
	virtual void notifyUndoEvent(Event* log) = 0;

	/**
	 * Triggered when the user issues a redo command.
	 *
	 * \param log Pointer to an Event describing the redone event.
	 */
	virtual void notifyRedoEvent(Event* log) = 0;

	/**
	 * Triggered when a set of transactions is committed to the undo log.
	 *
	 * \param log Pointer to an Event describing the committed events.
	 */
	virtual void notifyUndoCommitEvent(Event* log) = 0;

	/**
	 * Triggered when the undo log is cleared.
	 */
	virtual void notifyClearUndoEvent() = 0;

	/**
	 * Triggered when the redo log is cleared.
	 */
	virtual void notifyClearRedoEvent() = 0;

};

}

#endif // SEEN_UNDO_COMMIT_OBSERVER_H