-
Notifications
You must be signed in to change notification settings - Fork 10
/
LayersWidget.cpp
158 lines (125 loc) · 4.44 KB
/
LayersWidget.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
147
148
149
150
151
152
153
154
155
156
157
#include "LayersWidget.h"
#include <iostream>
#include <algorithm>
#include <QLabel>
#include <QEvent>
#include <QComboBox>
#include <QCheckBox>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QPushButton>
QSize LayersWidget::minimumSizeHint() const
{
return QSize(200, 100);
}
QSize LayersWidget::sizeHint() const
{
return QSize(200, 200);
}
LayersWidget::LayersWidget(QWidget* parent) : QWidget(parent)
{
setWindowTitle("Layers");
QVBoxLayout* vLayout = new QVBoxLayout(this);
setLayout(vLayout);
QGridLayout* topGridLayout = new QGridLayout();
vLayout->addLayout(topGridLayout);
// Layer blend mode
QLabel* modeLabel = new QLabel("Mode");
QComboBox* modeComboBox = new QComboBox();
modeComboBox->addItem("Normal");
topGridLayout->addWidget(modeLabel, 0, 0, 1, 1);
topGridLayout->addWidget(modeComboBox, 0, 1, 1, 3);
// Layer table
m_listModel = new LayerListModel(this);
m_listView = new LayerListView(this);
m_listView->setModel(m_listModel);
topGridLayout->addWidget(m_listView, 1, 0, 1, 4);
// Set the top layer to be active on startup.
m_listView->setCurrentIndex(m_listModel->index(0, 0));
// Checkbox for ignoring faceset objects
//QCheckBox* lockedCheckBox = new QCheckBox("Locked");
//topGridLayout->addWidget(lockedCheckBox, 1, 0, 1, 2);
// Move Layer Up
//QPushButton* buttonUp = new QPushButton("UP");
//buttonUp->setMaximumSize(50, 26);
//connect(buttonUp, SIGNAL(pressed()),
// this, SLOT(moveSelectedUp()));
// Move Layer Down
//QPushButton* buttonDown = new QPushButton("DOWN");
//buttonDown->setMaximumSize(50, 26);
//connect(buttonDown, SIGNAL(pressed()),
// this, SLOT(moveSelectedDown()));
// New Layer
QPushButton* buttonNew = new QPushButton(" New");
buttonNew->setToolTip("New Layer");
buttonNew->setIcon(QIcon(QPixmap(":/icons/layerNew.png")));
connect(buttonNew, SIGNAL(pressed()),
this, SLOT(newLayer()));
// Duplicate Layer
QPushButton* buttonDup = new QPushButton("");
buttonDup->setToolTip("Duplicate Layer");
buttonDup->setIcon(QIcon(QPixmap(":/icons/layerDuplicate.png")));
buttonDup->setMaximumSize(50, 26);
connect(buttonDup, SIGNAL(pressed()),
this, SLOT(duplicateSelected()));
// Delete Layer
QPushButton* buttonDel = new QPushButton("");
buttonDel->setToolTip("Delete Layer");
buttonDel->setIcon(QIcon(QPixmap(":/icons/layerDelete.png")));
buttonDel->setMaximumSize(50, 26);
connect(buttonDel, SIGNAL(pressed()),
this, SLOT(deleteSelected()));
topGridLayout->addWidget(buttonNew, 2, 0, 1, 2);
topGridLayout->addWidget(buttonDup, 2, 2, 1, 1);
topGridLayout->addWidget(buttonDel, 2, 3, 1, 1);
}
void LayersWidget::newLayer()
{
LayerListModel* mdl = dynamic_cast<LayerListModel*>(m_listModel);
int row = m_listView->currentIndex().row();
if (row == -1)
row = 0;
mdl->insertRow(row);
LayerObject newLayer("New", true);
m_listModel->listdata[row] = newLayer;
m_listView->setCurrentIndex(mdl->index(row));
}
void LayersWidget::deleteSelected()
{
LayerListModel* mdl = dynamic_cast<LayerListModel*>(m_listModel);
int row = m_listView->currentIndex().row();
if (row == -1)
return;
mdl->removeRow(row);
}
void LayersWidget::duplicateSelected()
{
LayerListModel* mdl = dynamic_cast<LayerListModel*>(m_listModel);
int row = m_listView->currentIndex().row();
if (row == -1)
return;
LayerObject newLayer(mdl->listdata[row].name + " Dupe", m_listModel->listdata[row].visible);
mdl->insertRow(row);
mdl->listdata[row] = newLayer;
m_listView->setCurrentIndex(mdl->index(row));
}
// void LayersWidget::moveSelectedUp()
// {
// LayerListModel* mdl = dynamic_cast<LayerListModel*>(m_listModel);
// int row = m_listView->currentIndex().row();
// if (row == 0 or row == -1)
// return;
//
// std::swap(mdl->listdata[row-1],mdl->listdata[row]);
// m_listView->setCurrentIndex(mdl->index(row-1));
// }
// void LayersWidget::moveSelectedDown()
// {
// LayerListModel* mdl = dynamic_cast<LayerListModel*>(m_listModel);
// int row = m_listView->currentIndex().row();
// if (row == mdl->rowCount(QModelIndex())-1 or row == -1)
// return;
//
// std::swap(mdl->listdata[row+1],mdl->listdata[row]);
// m_listView->setCurrentIndex(mdl->index(row+1));
// }