diff options
author | Treeki <treeki@gmail.com> | 2012-09-05 01:36:57 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-09-05 01:36:57 +0200 |
commit | f928869357765e3a73501064408bb7bc0ee363ef (patch) | |
tree | 1c75962f64e4a7bfc38315c21ccadd83092aa0d4 | |
parent | 824b2fa6b700ec7b50f0388b649480a689cf22f3 (diff) | |
download | LayoutStudio-f928869357765e3a73501064408bb7bc0ee363ef.tar.gz LayoutStudio-f928869357765e3a73501064408bb7bc0ee363ef.zip |
improving the material editor
Diffstat (limited to '')
-rw-r--r-- | LayoutStudio.pro | 6 | ||||
-rw-r--r-- | lslayoutwindow.cpp | 10 | ||||
-rw-r--r-- | lsmaterialeditor.cpp | 31 | ||||
-rw-r--r-- | lsmaterialmodel.cpp | 23 | ||||
-rw-r--r-- | lsmaterialmodel.h | 25 |
5 files changed, 93 insertions, 2 deletions
diff --git a/LayoutStudio.pro b/LayoutStudio.pro index 9f2fc26..e4c57c6 100644 --- a/LayoutStudio.pro +++ b/LayoutStudio.pro @@ -42,7 +42,8 @@ SOURCES += main.cpp \ lspaneeditor.cpp \ lstexcoordseteditor.cpp \ lsmaterialeditor.cpp \ - lscolorpicker.cpp + lscolorpicker.cpp \ + lsmaterialmodel.cpp HEADERS += lsmainwindow.h \ lsglobals.h \ lyt/packagebase.h \ @@ -83,7 +84,8 @@ HEADERS += lsmainwindow.h \ lspaneeditor.h \ lstexcoordseteditor.h \ lsmaterialeditor.h \ - lscolorpicker.h + lscolorpicker.h \ + lsmaterialmodel.h FORMS += RESOURCES += resources.qrc diff --git a/lslayoutwindow.cpp b/lslayoutwindow.cpp index 38e0417..3323803 100644 --- a/lslayoutwindow.cpp +++ b/lslayoutwindow.cpp @@ -1,5 +1,6 @@ #include "lslayoutwindow.h" #include "lsscenemodel.h" +#include "lsmaterialmodel.h" #include "lspaneeditor.h" #include "lsmaterialeditor.h" #include "layoutgl/widget.h" @@ -123,6 +124,12 @@ LSLayoutWindow::LSLayoutWindow(LYTPackageBase *pkg, const QString &layoutName, Q m_sceneGraph->expandAll(); connect(m_sceneGraph->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(selectedPaneChanged(QModelIndex,QModelIndex))); + LSMaterialModel *matModel = new LSMaterialModel(&m_layout->materials, this); + + m_materialList->setSelectionMode(QAbstractItemView::SingleSelection); + m_materialList->setModel(matModel); + connect(m_materialList->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(selectedMaterialChanged(QModelIndex,QModelIndex))); + setWindowTitle(m_layoutName); @@ -161,7 +168,10 @@ void LSLayoutWindow::selectedPaneChanged(const QModelIndex ¤t, const QMode } void LSLayoutWindow::selectedMaterialChanged(const QModelIndex ¤t, const QModelIndex &previous) { + (void)previous; + LYTMaterial *mat = m_layout->materials.getMaterialByIndex(current.row()); + m_materialEditor->setMaterial(mat); } diff --git a/lsmaterialeditor.cpp b/lsmaterialeditor.cpp index 20f36f5..f1c5736 100644 --- a/lsmaterialeditor.cpp +++ b/lsmaterialeditor.cpp @@ -1,4 +1,5 @@ #include "lsmaterialeditor.h" +#include <QGroupBox> LSMaterialEditor::LSMaterialEditor(QWidget *parent) : QWidget(parent) { @@ -10,6 +11,25 @@ LSMaterialEditor::LSMaterialEditor(QWidget *parent) : grid->addWidget(new QLabel("Name:", this), 0, 0, 1, 1); grid->addWidget(m_nameEntry, 0, 1, 1, 1); + // TEV colour box + QGroupBox *tevCBox = new QGroupBox("TEV Colours", this); + QGridLayout *tevCLayout = new QGridLayout(tevCBox); + + tevCLayout->addWidget(new QLabel("Registers:", tevCBox), 0, 0, 1, 4); + tevCLayout->addWidget(new QLabel("Constant:", tevCBox), 2, 0, 1, 4); + + for (int i = 0; i < 7; i++) { + m_colourPickers[i] = new LSColorPicker(tevCBox); + bool isKonst = (i >= 3); + tevCLayout->addWidget(m_colourPickers[i], isKonst?3:1, isKonst?(i-3):i, 1, 1); + } + + grid->addWidget(tevCBox, 1, 0, 1, 2); + + + grid->setRowStretch(2, 1); + + m_currentlyLoadingMaterial = false; m_material = 0; } @@ -18,6 +38,13 @@ void LSMaterialEditor::setMaterial(LYTMaterial *mat) { m_currentlyLoadingMaterial = true; m_material = mat; + m_nameEntry->setText(mat->name); + + for (int i = 0; i < 3; i++) + m_colourPickers[i]->setColor(mat->colours[i]); + for (int i = 0; i < 4; i++) + m_colourPickers[i+3]->setColor(mat->tevKColour[i]); + m_currentlyLoadingMaterial = false; } @@ -29,3 +56,7 @@ void LSMaterialEditor::handleNameChanged(QString value) { void LSMaterialEditor::handleSaveChangedName() { } + +void LSMaterialEditor::handleColourPicked(QColor value) { + +} diff --git a/lsmaterialmodel.cpp b/lsmaterialmodel.cpp new file mode 100644 index 0000000..37f8f58 --- /dev/null +++ b/lsmaterialmodel.cpp @@ -0,0 +1,23 @@ +#include "lsmaterialmodel.h" + +LSMaterialModel::LSMaterialModel(LYTMaterialContainer *container, QObject *parent) : + QAbstractListModel(parent) +{ + m_container = container; +} + + +int LSMaterialModel::rowCount(const QModelIndex &parent) const { + return m_container->count(); +} + +QVariant LSMaterialModel::data(const QModelIndex &index, int role) const { + if (index.isValid()) { + switch (role) { + case Qt::DisplayRole: + return m_container->getNameOfIndex(index.row()); + } + } + + return QVariant(); +} diff --git a/lsmaterialmodel.h b/lsmaterialmodel.h new file mode 100644 index 0000000..6b75fd6 --- /dev/null +++ b/lsmaterialmodel.h @@ -0,0 +1,25 @@ +#ifndef LSMATERIALMODEL_H +#define LSMATERIALMODEL_H + +#include <QAbstractListModel> +#include "lyt/materials/materialcontainer.h" + +class LSMaterialModel : public QAbstractListModel +{ + Q_OBJECT +public: + explicit LSMaterialModel(LYTMaterialContainer *container, QObject *parent = 0); + + int rowCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + +private: + LYTMaterialContainer *m_container; + +signals: + +public slots: + +}; + +#endif // LSMATERIALMODEL_H |