summaryrefslogtreecommitdiffstats
path: root/noatun/library/noatun/effects.h
blob: 0480729d25dfc29477e11b0911f4be4a8dd60b00 (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
#ifndef EFFECTS_H
#define EFFECTS_H

#include <tqptrlist.h>
#include <tqcstring.h>
#include <tqstrlist.h>
#include <tqobject.h>

namespace Arts { class StereoEffect; }
class Engine;
class EffectConfigWidget;

/**
 * @short Base class for a noatun effect
 *
 * Example:
 * \code
 * new Effect("Arts::SomeEffect");
 * \endcode
 * Then you can add, insert, etc. it using Effects
 **/
class Effect
{
friend class Effects;
friend class EffectConfigWidget;
public:
	Effect(const char *name);
	~Effect();

	/**
	 * return the effect processed
	 * directly before this one
	 **/
	Effect *before() const;
	/**
	 * return the effect processed
	 * directly after this one
	 **/
	Effect *after() const;
	long id() const;

	/**
	 * get the Arts object.
	 * @internal
	 **/
	Arts::StereoEffect *effect() const;

	/**
	 * Get the name of the object.
	 **/
	TQCString name() const;

	/**
	 * get the "clean" title of effect
	 **/
	TQString title() const;

	/**
	 * @return true if this effect name is invalid, false otherwise
	 * <b>Note:</b> If you call StereoEffect::start() on an invalid Effect you
	 * will probably be punished with a segmentation fault.
	 **/
	bool isNull() const;

	/**
	 * show the configure dialog box for
	 * this effect.  if friendly is true,
	 * then create a top-level window,
	 * set an icon and make it purdy. Otherwise
	 * create a plan widget that you can reparent.
	 **/
	TQWidget *configure(bool friendly=true);

	/**
	 * Does this widget have a configurable
	 * dialog box.  E.g., will configure
	 * return null?
	 **/
	bool configurable() const;

	/**
	 * Return an effect name that can be presented to a user
	 * i.e. Arts::FREEVERB will end up as FREEVERB
	 **/
	static TQString clean(const TQCString &name);
private:
	long mId;
	Arts::StereoEffect *mEffect;
	TQCString mName;
	TQWidget *mConfig;
};

/**
 * Noatuns effect stack
 * @author Charles Samuels
 **/
class Effects : public TQObject
{
Q_OBJECT
  TQ_OBJECT
friend class Effect;
public:
	Effects();

	bool insert(const Effect *after, Effect *item);

	/**
	 * create the Effect, by getting the proper item
	 * from the list, then append it here.
	 *
	 * for example
	 * \code
	 * append(new Effect(available()[0]));
	 * \endcode
	 **/
	bool append(Effect *item);

	/**
	 * reorder the effect stack. If @p after is null,
	 * it'll be first
	 **/
	void move(const Effect *after, Effect *item);
	/**
	 * Removes an item from the effect stack
	 * @param item item to remove
	 * @param del delete the item from the effect stack as well (default true)
	 **/
	void remove(Effect *item, bool del=true);

	/**
	 * Removes all items from the effect stack.
	 * @param del delete the items from the effect stack as well (default true)
	 **/
	void removeAll(bool del=true);

	/**
	 * A list of all available effects, by name
	 * each of these can be given to the first
	 * argument of the Effect constructor
	 **/
	TQStrList available() const;

	/**
	 * A list of all available effects objects
	 **/
	TQPtrList<Effect> effects() const;

	/**
	 * Get the Effect that has the following id
	 **/
	Effect *findId(long id) const;

private:
	TQPtrListIterator<Effect> stackPosition() const;

signals:
	/**
	 * Emitted when an effect has been added to the effect stack
	 * @param effect the effect that got added
	 **/
	void added(Effect *effect);
	/**
	 * Emitted when an effect has been removed to the effect stack
	 * @param effect the effect that got removed
	 **/
	void removed(Effect *effect);
	/**
	 * Emitted when an effect has been moved
	 * @param effect the effect that got moved
	 **/
	void moved(Effect *effect);
	/**
	 * Emitted when an effect is about to be
	 * deleted (from memory)
	 * @param effect the effect to be deleted
	 **/
	void deleting(Effect *effect);

private:
	// stored in no specific order
	TQPtrList<Effect> mItems;
};



#endif