Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ACT_ActionC-Api.h « action « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ebc1ce7d5a0e840eaa4ad341900058c8caad3a57 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/**
 * $Id$
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version. The Blender
 * Foundation also sells licenses for use in proprietary software under
 * the Blender License.  See http://www.blender.org/BL/ for information
 * about this.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 * All rights reserved.
 *
 * The Original Code is: all of this file.
 *
 * Contributor(s): none yet.
 *
 * ***** END GPL/BL DUAL LICENSE BLOCK *****
 */

/**

 * $Id$
 * Copyright (C) 2001 NaN Technologies B.V.
 * Interface for C access to actions.
 * @author	Maarten Gribnau
 * @date	April, 25, 2001
 */

#ifndef _H_ACT_ACTION_C_API
#define _H_ACT_ACTION_C_API

#include "MEM_RefCountedC-Api.h"

/** A pointer to an action object. */
typedef MEM_TRefCountedObjectPtr ACT_ActionPtr;
/** A pointer to an action stack object. */
typedef MEM_TObjectPtr ACT_ActionStackPtr;


/** A pointer to user data passed by the callbacks. */
typedef void* ACT_ActionUserDataPtr;

/**
 * An action apply callback routine.
 * @param action The action that should be applied.
 * @param userData The pointer to the user data provided when the action was created.
 */
typedef void (*ACT_ActionApplyProcPtr)(ACT_ActionPtr action, ACT_ActionUserDataPtr userData);

/**
 * An action undo callback routine.
 * @param action The action that should be undone.
 * @param userData The pointer to the user data provided when the action was created.
 */
typedef void (*ACT_ActionUndoProcPtr)(ACT_ActionPtr action, ACT_ActionUserDataPtr userData);

/**
 * An action dispose callback routine.
 * @param action The action that is disposed.
 * @param userData The pointer to the user data provided when the action was created.
 */
typedef void (*ACT_ActionDisposeProcPtr)(ACT_ActionPtr action, ACT_ActionUserDataPtr userData);


#ifdef __cplusplus
extern "C" {
#endif

/**
 * An action is a shared object that can be applied or undone.
 */

/**
 * Creates a new action.
 * This is an action that calls the given callbacks when it needs to be applied or undone.
 * @param name The name of the action.
 * @param isApplied Indication as to whether the action is already applied (0 = not applied).
 * @param userData Pointer passed to the apply/undo callbacks.
 * @param applyProc Pointer to the callback invoked when the action needs to be applied.
 * @param undoProc Pointer to the callback invoked when the action needs to be undone.
 * @return	The new action (null in case of error).
 */
extern ACT_ActionPtr ACT_ActionCreate(
						char* name,
						int isApplied,
						ACT_ActionUserDataPtr userData,
						ACT_ActionApplyProcPtr applyProc,
						ACT_ActionUndoProcPtr undoProc,
						ACT_ActionDisposeProcPtr disposeProc);

/**
 * Returns the name of an action.
 * @return	The name of the action (null in case of error).
 */
extern char* ACT_ActionGetName(ACT_ActionPtr action);



/**
 * An action stack stores actions and implements undo/redo functionality.
 */

/**
 * Creates a new action stack.
 * @param stackSize The maximum number of actions on the stack.
 * @return The new stack (or NULL in case of error).
 */
extern ACT_ActionStackPtr ACT_ActionStackCreate(unsigned int stackSize);

/**
 * Disposes an action stack.
 * @param stack The appropriate stack.
 */
extern void	ACT_ActionStackDispose(ACT_ActionStackPtr stack);

/**
 * Returns the current depth of the stack.
 * @param stack The appropriate stack.
 * @return the current stack depth.
 */
extern unsigned int ACT_ActionStackGetStackDepth(ACT_ActionStackPtr stack);

/**
 * Returns the current maximum depth of the stack.
 * @param stack The appropriate stack.
 * @return the maximum stack depth.
 */
extern unsigned int ACT_ActionStackGetMaxStackDepth(ACT_ActionStackPtr stack);

/**
 * Sets new maximum depth of the stack.
 * @param stack The appropriate stack.
 * @param maxStackDepth	The new stack depth.
 */
extern void ACT_ActionStackSetMaxStackDepth(ACT_ActionStackPtr stack, unsigned int maxStackDepth);

/**
 * Pushes an action on the stack.
 * If the action has not been applied yet, it will be applied here.
 * This will increase the reference count of the action.
 * If there is not enough capacity, the action at the bottom of the stack is removed (and its reference count decreased).
 * @param stack The appropriate stack.
 * @param action	the action that is pushed onto the stack.
 */
extern void	ACT_ActionStackPush(ACT_ActionStackPtr stack, ACT_ActionPtr action);

/**
 * Returns pointer to the current undo item.
 * @param stack The appropriate stack.
 * @return The action scheduled for undo (0 if there is none).
 */
extern ACT_ActionStackPtr ACT_ActionStackPeekUndo(ACT_ActionStackPtr stack);

/**
 * Returns pointer to the current redo item.
 * @param stack The appropriate stack.
 * @return The action scheduled for redo (0 if there is none).
 */
extern ACT_ActionStackPtr ACT_ActionStackPeekRedo(ACT_ActionStackPtr stack);

/**
 * Undos the current action.
 * @param stack The appropriate stack.
 * This will move the current undo index down (if the stack depth allows it).
 */
extern void	ACT_ActionStackUndo(ACT_ActionStackPtr stack);

/**
 * Redos the current action.
 * @param stack The appropriate stack.
 * This will move the action index up (if the stack depth allows it).
 */
extern void	ACT_ActionStackRedo(ACT_ActionStackPtr stack);


#ifdef __cplusplus
}
#endif

#endif // _H_ACT_ACTION_C_API