This repository has been archived by the owner on Jun 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy patheffectcontroller.h
62 lines (50 loc) · 1.6 KB
/
effectcontroller.h
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
#ifndef EFFECTCONTROLLER_H
#define EFFECTCONTROLLER_H
#include "toolcontroller.h"
#include <QScopedPointer>
#include <QSharedPointer>
#include <QEnableSharedFromThis>
/*
* Here's how effect works:
*
* 1. application creates EffectController.
* 2. EffectController.createEditor and createView is called.
* Effect previews the result by modifying Session.terrain.
* 3. One of either actions is performed:
* a. User clicks "Apply" or "Revert" in EffectEditor.
* EffectController.apply() or EffectController.revert() will be called.
* b. Application calls EffectController.leave().
* EffectController.apply() or EffectController.revert() will be called by leave().
* 4. After effect is done, the signal EffectController.done() is emitted.
*
*/
class Terrain;
class TerrainEdit;
class EffectController : public ToolController, public QEnableSharedFromThis<EffectController>
{
Q_OBJECT
public:
explicit EffectController(QObject *parent = 0);
~EffectController();
QWidget *createEditor(Session *) override final;
bool leave(std::function<void(bool)> callback) override;
signals:
void applied();
void reverted();
void done();
protected:
virtual QWidget *createEffectEditor(Session *) = 0;
virtual void applyEffect(QSharedPointer<Terrain>, QSharedPointer<TerrainEdit>, Session *) = 0;
protected slots:
void preview();
private slots:
void apply();
void revert();
private:
QWidget *editor;
Session *session;
QSharedPointer<TerrainEdit> previewEdit;
private slots:
void editorDestroyed(QObject *);
};
#endif // EFFECTCONTROLLER_H