summaryrefslogtreecommitdiff
path: root/gui/argumentseditor.h
blob: 27aa491f595cfe1162a44bf642a7ceea170d01e4 (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
#ifndef ARGUMENTSEDITOR_H
#define ARGUMENTSEDITOR_H

#include "apitracecall.h"
#include "ui_argumentseditor.h"

#include <QComboBox>
#include <QDialog>
#include <QItemEditorFactory>
#include <QStandardItemModel>
#include <QSpinBox>

#include <limits.h>
#include <float.h>


class ApiTraceCall;

class BooleanComboBox : public QComboBox
{
    Q_OBJECT
    Q_PROPERTY(bool value READ value WRITE setValue USER true)
public:
    BooleanComboBox(QWidget *parent);
    void setValue(bool);
    bool value() const;
};


class BooleanComboBoxEditorCreator : public BooleanComboBox
{
    Q_OBJECT
    Q_PROPERTY(bool value READ value WRITE setValue USER true)
public:
    BooleanComboBoxEditorCreator(QWidget *widget = 0) : BooleanComboBox(widget)
    {
	this->setFrame(false);
    };
};

class UIntEditorCreator : public QSpinBox
{
    Q_OBJECT
    Q_PROPERTY(int value READ value WRITE setValue USER true)
public:
    UIntEditorCreator(QWidget *widget = 0) : QSpinBox(widget)
    {
	this->setFrame(false);
        this->setMaximum(INT_MAX);
    };
};

class IntEditorCreator : public QSpinBox
{
    Q_OBJECT
    Q_PROPERTY(int value READ value WRITE setValue USER true)
public:
    IntEditorCreator(QWidget *widget = 0) : QSpinBox(widget)
    {
	this->setFrame(false);
        this->setMinimum(INT_MIN);
        this->setMaximum(INT_MAX);
    };
};

class ULongLongEditorCreator : public QSpinBox
{
    Q_OBJECT
    Q_PROPERTY(int value READ value WRITE setValue USER true)
public:
    ULongLongEditorCreator(QWidget *widget = 0) : QSpinBox(widget)
    {
	this->setFrame(false);
        this->setMaximum(INT_MAX);
    };
};

class LongLongEditorCreator : public QSpinBox
{
    Q_OBJECT
    Q_PROPERTY(int value READ value WRITE setValue USER true)
public:
    LongLongEditorCreator(QWidget *widget = 0) : QSpinBox(widget)
    {
	this->setFrame(false);
        this->setMinimum(INT_MIN);
        this->setMaximum(INT_MAX);
    };
};

class PixmapEditorCreator : public QLabel
{
    Q_OBJECT
    Q_PROPERTY(QString text READ text WRITE setText USER true)
public:
    PixmapEditorCreator(QWidget *widget = 0) : QLabel (widget)
    {
    };
};

class FloatEditorCreator : public QDoubleSpinBox
{
    Q_OBJECT
    Q_PROPERTY(double value READ value WRITE setValue USER true)
public:
    FloatEditorCreator(QWidget *widget = 0) : QDoubleSpinBox(widget)
    {
	this->setFrame(false);
        this->setMinimum(-FLT_MAX);
        this->setMaximum(FLT_MAX);
        this->setDecimals(8);
    };
};

class DoubleEditorCreator : public QDoubleSpinBox
{
    Q_OBJECT
    Q_PROPERTY(double value READ value WRITE setValue USER true)
public:
    DoubleEditorCreator(QWidget *widget = 0) : QDoubleSpinBox(widget)
    {
	this->setFrame(false);
        this->setMinimum(-DBL_MAX);
        this->setMaximum(DBL_MAX);
        this->setDecimals(8);
    };
};

class InvalidEditorCreator : public QLabel
{
    Q_OBJECT
    Q_PROPERTY(QString text READ text WRITE setText USER true)
public:
    InvalidEditorCreator(QWidget *widget = 0) :  QLabel(widget)
    {
    };
};

class ArgumentsEditor : public QDialog
{
    Q_OBJECT
public:
    ArgumentsEditor(QWidget *parent=0);
    ~ArgumentsEditor();


    virtual void accept();

    void setCall(ApiTraceCall *call);
    ApiTraceCall *call() const;

private slots:
    void currentSourceChanged(int idx);
    void sourceChanged();
    void revert();
private:
    void init();
    void setupCall();
    void setupShaderEditor(const QVector<QVariant> &sources);
    QVariant valueForName(const QString &name,
                          const QVariant &orignalValue,
                          bool *changed) const;
    QVariant arrayFromIndex(const QModelIndex &index,
                            const ApiArray &array,
                            bool *changed) const;
    QVariant arrayFromEditor(const ApiArray &origArray,
                             bool *changed) const;
private:
    Ui_ArgumentsEditor m_ui;
    QStandardItemModel *m_model;

    ApiTraceCall *m_call;
};

#endif