-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
147 lines (119 loc) · 3.34 KB
/
mainwindow.cpp
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QColorDialog>
#include <QtWidgets>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setFixedSize(1000, 600);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::keyPressEvent(QKeyEvent *e)
{
if (e->key() == Qt::Key_Escape)
close();
else
QWidget::keyPressEvent(e);
}
// Alpha sliders
void MainWindow::on_clear_color_alpha_slider_valueChanged(int value)
{
ui->myGLCanvas->setClearAlpha(float(value)/100.0f);
}
void MainWindow::on_top_alpha_slider_valueChanged(int value)
{
ui->myGLCanvas->setTopAlpha(float(value)/100.0f);
}
void MainWindow::on_const_color_alpha_slider_valueChanged(int value)
{
ui->myGLCanvas->setBlendAlpha(float(value)/100.0f);
}
void MainWindow::on_middle_alpha_slider_valueChanged(int value)
{
ui->myGLCanvas->setMiddleAlpha(float(value)/100.0f);
}
void MainWindow::on_bottom_alpha_slider_valueChanged(int value)
{
ui->myGLCanvas->setBottomAlpha(float(value)/100.0f);
}
// checkboxes
void MainWindow::on_blend_checkbox_toggled(bool checked)
{
ui->myGLCanvas->setEnableBlending(checked);
}
void MainWindow::on_depth_test_checkbox_toggled(bool checked)
{
ui->myGLCanvas->setEnableDepthTest(checked);
}
void MainWindow::on_colorLogic_checkbox_toggled(bool checked)
{
ui->myGLCanvas->setEnableColorLogicOp(checked);
}
void MainWindow::on_separate_checkbox_toggled(bool checked)
{
ui->myGLCanvas->setEnabledSeparateBlending(checked);
}
void MainWindow::on_premultiply_alpha_checkbox_toggled(bool checked)
{
ui->myGLCanvas->setEnablePreMultiplyAlpha(checked);
}
// Dropdown menus
void MainWindow::on_srcFactorOpts_activated(const QString &arg1)
{
ui->myGLCanvas->setSrcFactor(arg1);
}
void MainWindow::on_dstFactorOps_activated(const QString &arg1)
{
ui->myGLCanvas->setDstFactor(arg1);
}
void MainWindow::on_sepSrcFactorOps_activated(const QString &arg1)
{
ui->myGLCanvas->setSeparateSrcFactor(arg1);
}
void MainWindow::on_blendEqOps_activated(const QString &arg1)
{
ui->myGLCanvas->setBlendEquation(arg1);
}
void MainWindow::on_logicOpOps_activated(const QString &arg1)
{
ui->myGLCanvas->setLogicOp(arg1);
}
void MainWindow::on_sepDstFactorOps_activated(const QString &arg1)
{
ui->myGLCanvas->setSeparateDstFactor(arg1);
}
// Color dialogs
void MainWindow::on_glClearColorButton_clicked()
{
QColor selectedColor = QColorDialog::getColor(Qt::white,this,"glClearColor");
ui->myGLCanvas->setClearColor(selectedColor);
}
void MainWindow::on_topColorButton_clicked()
{
QColor selectedColor = QColorDialog::getColor(Qt::white, this, "top sprite color");
ui->myGLCanvas->setTopColor(selectedColor);
}
void MainWindow::on_middleColorButton_clicked()
{
QColor selectedColor = QColorDialog::getColor(Qt::white, this, "middle sprite color");
ui->myGLCanvas->setMiddleColor(selectedColor);
}
void MainWindow::on_bottomColorButton_clicked()
{
QColor selectedColor = QColorDialog::getColor(Qt::white, this, "bottom sprite color");
ui->myGLCanvas->setBottomColor(selectedColor);
}
void MainWindow::on_blendColorButton_clicked()
{
QColor selectedColor = QColorDialog::getColor(Qt::white, this, "glBlendColor");
ui->myGLCanvas->setBlendColor(selectedColor);
}
void MainWindow::on_actionExit_triggered()
{
close();
}