]> git.notmuchmail.org Git - vogl/blob - src/vogleditor/vogleditor_statetreeprogramitem.h
UI: separate capturing of vogl_gl_state_snapshot from allocation of the vogleditor_gl...
[vogl] / src / vogleditor / vogleditor_statetreeprogramitem.h
1 #ifndef VOGLEDITOR_STATETREEPROGRAMITEM_H
2 #define VOGLEDITOR_STATETREEPROGRAMITEM_H
3
4 #include "vogleditor_statetreeitem.h"
5 #include "vogl_program_state.h"
6
7 class vogleditor_stateTreeProgramDiffableItem : public vogleditor_stateTreeItem
8 {
9 public:
10     vogleditor_stateTreeProgramDiffableItem(QString name, QString value, vogleditor_stateTreeItem* parent, const vogl_program_state& state)
11         : vogleditor_stateTreeItem(name, value, parent),
12           m_pState(&state),
13           m_pDiffBaseState(NULL)
14     {
15     }
16
17     virtual void set_diff_base_state(const vogl_program_state* pBaseState) {
18         m_pDiffBaseState = pBaseState;
19     }
20
21     const vogl_program_state* get_current_state() const { return m_pState; }
22     const vogl_program_state* get_base_state() const { return m_pDiffBaseState; }
23
24     virtual bool hasChanged() const = 0;
25
26 protected:
27     const vogl_program_state* m_pState;
28     const vogl_program_state* m_pDiffBaseState;
29 };
30
31 class vogleditor_stateTreeProgramBoolItem : public vogleditor_stateTreeProgramDiffableItem
32 {
33 public:
34     vogleditor_stateTreeProgramBoolItem(QString name, bool (vogl_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_program_state& state);
35     virtual ~vogleditor_stateTreeProgramBoolItem() { m_pState = NULL; }
36
37     virtual bool hasChanged() const;
38     virtual QString getDiffedValue() const;
39
40 private:
41     bool (vogl_program_state::* m_pFunc)(void) const;
42 };
43
44 class vogleditor_stateTreeProgramUIntItem : public vogleditor_stateTreeProgramDiffableItem
45 {
46 public:
47     vogleditor_stateTreeProgramUIntItem(QString name, uint (vogl_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_program_state& state);
48     virtual ~vogleditor_stateTreeProgramUIntItem() { m_pState = NULL; }
49
50     virtual bool hasChanged() const;
51     virtual QString getDiffedValue() const;
52
53 private:
54     uint (vogl_program_state::* m_pFunc)(void) const;
55 };
56
57 class vogleditor_stateTreeProgramEnumItem : public vogleditor_stateTreeProgramDiffableItem
58 {
59 public:
60     vogleditor_stateTreeProgramEnumItem(QString name, GLenum (vogl_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_program_state& state);
61     virtual ~vogleditor_stateTreeProgramEnumItem() { m_pState = NULL; }
62
63     virtual bool hasChanged() const;
64     virtual QString getDiffedValue() const;
65
66 private:
67     GLenum (vogl_program_state::* m_pFunc)(void) const;
68 };
69
70 class vogleditor_stateTreeProgramLogItem : public vogleditor_stateTreeProgramDiffableItem
71 {
72 public:
73     vogleditor_stateTreeProgramLogItem(QString name, const vogl::dynamic_string& (vogl_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_program_state& state);
74     virtual ~vogleditor_stateTreeProgramLogItem() { m_pState = NULL; }
75
76     virtual bool hasChanged() const;
77     virtual QString getDiffedValue() const;
78
79 private:
80     const vogl::dynamic_string& (vogl_program_state::* m_pFunc)(void) const;
81 };
82
83 class vogleditor_stateTreeProgramStringItem : public vogleditor_stateTreeProgramDiffableItem
84 {
85 public:
86     vogleditor_stateTreeProgramStringItem(QString name, const vogl::dynamic_string& (vogl_program_state::* func)(void) const, vogleditor_stateTreeItem* parent, const vogl_program_state& state);
87     virtual ~vogleditor_stateTreeProgramStringItem() { m_pState = NULL; }
88
89     virtual bool hasChanged() const;
90     virtual QString getDiffedValue() const;
91
92 private:
93     dynamic_string m_value;
94     const vogl::dynamic_string& (vogl_program_state::* m_pFunc)(void) const;
95 };
96
97 class vogleditor_stateTreeProgramAttribItem : public vogleditor_stateTreeItem
98 {
99 public:
100     vogleditor_stateTreeProgramAttribItem(QString name, vogleditor_stateTreeItem* parent, const vogl_program_attrib_state& state);
101     virtual ~vogleditor_stateTreeProgramAttribItem() { m_pState = NULL; }
102
103     virtual void set_diff_base_state(const vogl_attrib_state_vec* pBaseState) {
104         m_pDiffBaseState = pBaseState;
105     }
106
107     virtual bool hasChanged() const;
108     virtual QString getDiffedValue() const;
109
110     const dynamic_string& get_name() const { return m_pState->m_name; }
111
112 private:
113     const vogl_program_attrib_state* m_pState;
114     const vogl_attrib_state_vec* m_pDiffBaseState;
115 };
116
117 class vogleditor_stateTreeProgramUniformItem : public vogleditor_stateTreeItem
118 {
119 public:
120     vogleditor_stateTreeProgramUniformItem(QString name, vogleditor_stateTreeItem* parent, const vogl_program_uniform_state& state);
121     virtual ~vogleditor_stateTreeProgramUniformItem() { m_pState = NULL; }
122
123     virtual void set_diff_base_state(const vogl_uniform_state_vec* pBaseState) {
124         m_pDiffBaseState = pBaseState;
125     }
126
127     virtual bool hasChanged() const;
128     virtual QString getDiffedValue() const;
129
130     const dynamic_string& get_name() const { return m_pState->m_name; }
131
132 private:
133     const vogl_program_uniform_state* m_pState;
134     const vogl_uniform_state_vec* m_pDiffBaseState;
135 };
136
137 class vogleditor_stateTreeProgramItem : public vogleditor_stateTreeItem
138 {
139 public:
140    vogleditor_stateTreeProgramItem(QString name, QString value, vogleditor_stateTreeItem* parent, vogl_program_state& state, const vogl_context_info& info);
141    virtual ~vogleditor_stateTreeProgramItem() { m_pState = NULL; m_pDiffBaseState = NULL; }
142    virtual state_tree_type getStateType() const { return vogleditor_stateTreeItem::cPROGRAM; }
143
144    vogl_program_state* get_current_state() const { return m_pState; }
145    const vogl_program_state* get_base_state() const { return m_pDiffBaseState; }
146
147    void add_diffable_child(vogleditor_stateTreeProgramDiffableItem* pItem);
148
149    void set_diff_base_state(const vogl_program_state* pBaseState) {
150        m_pDiffBaseState = pBaseState;
151        for (vogleditor_stateTreeProgramDiffableItem** iter = m_diffableItems.begin(); iter != m_diffableItems.end(); iter++)
152        {
153            (*iter)->set_diff_base_state(pBaseState);
154        }
155
156        for (vogleditor_stateTreeProgramAttribItem** iter = m_attribItems.begin(); iter != m_attribItems.end(); iter++)
157        {
158            (*iter)->set_diff_base_state(&(pBaseState->get_attrib_state_vec()));
159        }
160
161        for (vogleditor_stateTreeProgramUniformItem** iter = m_uniformItems.begin(); iter != m_uniformItems.end(); iter++)
162        {
163            (*iter)->set_diff_base_state(&(pBaseState->get_uniform_state_vec()));
164        }
165    }
166
167 private:
168    vogl_program_state* m_pState;
169    const vogl_program_state* m_pDiffBaseState;
170    vogl::vector<vogleditor_stateTreeProgramDiffableItem*> m_diffableItems;
171    vogl::vector<vogleditor_stateTreeProgramAttribItem*> m_attribItems;
172    vogl::vector<vogleditor_stateTreeProgramUniformItem*> m_uniformItems;
173 };
174 #endif // VOGLEDITOR_STATETREEPROGRAMITEM_H