From 56bf2bd3ff73fc3cd86dcb4f4cd1e42016522bea Mon Sep 17 00:00:00 2001 From: Treeki Date: Sat, 18 Aug 2012 04:15:43 +0200 Subject: you can now view and edit basic pane settings! exciting, right? --- lslayoutwindow.cpp | 17 ++++- lslayoutwindow.h | 3 + lspaneeditor.cpp | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++-- lspaneeditor.h | 30 +++++++- 4 files changed, 250 insertions(+), 10 deletions(-) diff --git a/lslayoutwindow.cpp b/lslayoutwindow.cpp index a164dd9..d19e397 100644 --- a/lslayoutwindow.cpp +++ b/lslayoutwindow.cpp @@ -12,7 +12,7 @@ LSLayoutWindow::LSLayoutWindow(LYTPackageBase *pkg, const QString &layoutName, Q m_layoutName = layoutName; m_package = pkg; - + m_loadingSettings = true; m_tabWidget = new QTabWidget(this); setCentralWidget(m_tabWidget); @@ -91,6 +91,7 @@ LSLayoutWindow::LSLayoutWindow(LYTPackageBase *pkg, const QString &layoutName, Q m_sceneGraph->setDropIndicatorShown(true); m_sceneGraph->setModel(new LSSceneModel(m_layout, this)); m_sceneGraph->expandAll(); + connect(m_sceneGraph->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(selectedPaneChanged(QModelIndex,QModelIndex))); setWindowTitle(m_layoutName); @@ -105,8 +106,12 @@ LSLayoutWindow::LSLayoutWindow(LYTPackageBase *pkg, const QString &layoutName, Q Qt::WindowMinimizeButtonHint); m_renderer->show(); + connect(m_paneEditor, SIGNAL(mustRedrawLayout()), m_renderer, SLOT(updateGL())); + // clean up here setAttribute(Qt::WA_DeleteOnClose); + + m_loadingSettings = false; } LSLayoutWindow::~LSLayoutWindow() { @@ -116,11 +121,21 @@ LSLayoutWindow::~LSLayoutWindow() { } +void LSLayoutWindow::selectedPaneChanged(const QModelIndex ¤t, const QModelIndex &previous) { + LYTPane *pane = (LYTPane*)current.internalPointer(); + m_paneEditor->setPane(pane); +} + + void LSLayoutWindow::handleWidthChanged(double v) { m_layout->width = v; + if (!m_loadingSettings) + m_renderer->updateGL(); } void LSLayoutWindow::handleHeightChanged(double v) { m_layout->height = v; + if (!m_loadingSettings) + m_renderer->updateGL(); } diff --git a/lslayoutwindow.h b/lslayoutwindow.h index 07e1b76..a626b25 100644 --- a/lslayoutwindow.h +++ b/lslayoutwindow.h @@ -46,9 +46,12 @@ private: LSPaneEditor *m_paneEditor; + bool m_loadingSettings; + private slots: void handleWidthChanged(double v); void handleHeightChanged(double v); + void selectedPaneChanged(const QModelIndex ¤t, const QModelIndex &previous); signals: diff --git a/lspaneeditor.cpp b/lspaneeditor.cpp index 2da39f5..659fd1e 100644 --- a/lspaneeditor.cpp +++ b/lspaneeditor.cpp @@ -1,6 +1,11 @@ #include "lspaneeditor.h" #include +#include "lyt/bounding.h" +#include "lyt/picture.h" +#include "lyt/textbox.h" +#include "lyt/window.h" + LSPaneEditor::LSPaneEditor(QWidget *parent) : QWidget(parent) { @@ -20,6 +25,7 @@ LSPaneEditor::LSPaneEditor(QWidget *parent) : m_removeButton->setText("Remove This Pane"); m_tabs = new QTabWidget(this); + m_tabs->setVisible(false); QGridLayout *layout = new QGridLayout(this); @@ -32,6 +38,9 @@ LSPaneEditor::LSPaneEditor(QWidget *parent) : createPaneTab(); + + m_currentlyLoadingPane = false; + m_pane = 0; } void LSPaneEditor::createPaneTab() { @@ -47,14 +56,18 @@ void LSPaneEditor::createPaneTab() { m_nameEntry = new QLineEdit(propBox); m_nameEntry->setMaxLength(16); + connect(m_nameEntry, SIGNAL(textChanged(QString)), SLOT(handleNameChanged(QString))); m_userDataEntry = new QLineEdit(propBox); m_userDataEntry->setMaxLength(8); + connect(m_userDataEntry, SIGNAL(textChanged(QString)), SLOT(handleUserDataChanged(QString))); m_alpha = new QSpinBox(propBox); m_alpha->setRange(0, 255); + connect(m_alpha, SIGNAL(valueChanged(int)), SLOT(handleAlphaChanged(int))); m_influencedAlpha = new QCheckBox("Influenced Alpha", propBox); + connect(m_influencedAlpha, SIGNAL(toggled(bool)), SLOT(handleInfluencedAlphaChanged(bool))); // Column 0 gLayout->addWidget(new QLabel("Name:", propBox), 0, 0, 1, 1); @@ -74,31 +87,37 @@ void LSPaneEditor::createPaneTab() { m_width = new QDoubleSpinBox(geoBox); m_width->setRange(0.0, 100000.0); + connect(m_width, SIGNAL(valueChanged(double)), SLOT(handleWidthChanged(double))); m_height = new QDoubleSpinBox(geoBox); m_height->setRange(0.0, 100000.0); + connect(m_height, SIGNAL(valueChanged(double)), SLOT(handleHeightChanged(double))); m_horzOrigin = new QComboBox(geoBox); m_horzOrigin->addItem("Left"); m_horzOrigin->addItem("Center"); m_horzOrigin->addItem("Right"); + connect(m_horzOrigin, SIGNAL(currentIndexChanged(int)), SLOT(handleHorzOriginChanged(int))); m_vertOrigin = new QComboBox(geoBox); m_vertOrigin->addItem("Top"); m_vertOrigin->addItem("Center"); m_vertOrigin->addItem("Bottom"); + connect(m_vertOrigin, SIGNAL(currentIndexChanged(int)), SLOT(handleVertOriginChanged(int))); m_widescreen = new QCheckBox("Widescreen", this); + connect(m_widescreen, SIGNAL(toggled(bool)), SLOT(handleWidescreenChanged(bool))); m_visible = new QCheckBox("Visible", this); + connect(m_visible, SIGNAL(toggled(bool)), SLOT(handleVisibleChanged(bool))); - // Row 0 + // Column 0 gLayout->addWidget(new QLabel("Width:", geoBox), 0, 0, 1, 1); gLayout->addWidget(m_width, 0, 1, 1, 1); - gLayout->addWidget(new QLabel("Height:", geoBox), 0, 2, 1, 1); - gLayout->addWidget(m_height, 0, 3, 1, 1); + gLayout->addWidget(new QLabel("Height:", geoBox), 1, 0, 1, 1); + gLayout->addWidget(m_height, 1, 1, 1, 1); - // Row 1 - gLayout->addWidget(new QLabel("Horizontal Origin:", geoBox), 1, 0, 1, 1); - gLayout->addWidget(m_horzOrigin, 1, 1, 1, 1); + // Column 1 + gLayout->addWidget(new QLabel("Horizontal Origin:", geoBox), 0, 2, 1, 1); + gLayout->addWidget(m_horzOrigin, 0, 3, 1, 1); gLayout->addWidget(new QLabel("Vertical Origin:", geoBox), 1, 2, 1, 1); gLayout->addWidget(m_vertOrigin, 1, 3, 1, 1); @@ -120,6 +139,15 @@ void LSPaneEditor::createPaneTab() { m_scaleX = new QDoubleSpinBox(posBox); m_scaleY = new QDoubleSpinBox(posBox); + connect(m_transX, SIGNAL(valueChanged(double)), SLOT(handleTransXChanged(double))); + connect(m_transY, SIGNAL(valueChanged(double)), SLOT(handleTransYChanged(double))); + connect(m_transZ, SIGNAL(valueChanged(double)), SLOT(handleTransZChanged(double))); + connect(m_rotX, SIGNAL(valueChanged(double)), SLOT(handleRotXChanged(double))); + connect(m_rotY, SIGNAL(valueChanged(double)), SLOT(handleRotYChanged(double))); + connect(m_rotZ, SIGNAL(valueChanged(double)), SLOT(handleRotZChanged(double))); + connect(m_scaleX, SIGNAL(valueChanged(double)), SLOT(handleScaleXChanged(double))); + connect(m_scaleY, SIGNAL(valueChanged(double)), SLOT(handleScaleYChanged(double))); + gLayout->addWidget(new QLabel("Translation:", posBox), 0, 0, 1, 1); gLayout->addWidget(m_transX, 0, 1, 1, 1); gLayout->addWidget(m_transY, 0, 2, 1, 1); @@ -130,7 +158,7 @@ void LSPaneEditor::createPaneTab() { gLayout->addWidget(m_rotZ, 1, 3, 1, 1); gLayout->addWidget(new QLabel("Scale:", posBox), 2, 0, 1, 1); gLayout->addWidget(m_scaleX, 2, 1, 1, 1); - gLayout->addWidget(m_scaleY, 2, 1, 1, 1); + gLayout->addWidget(m_scaleY, 2, 2, 1, 1); // put it all together into one @@ -141,3 +169,171 @@ void LSPaneEditor::createPaneTab() { layout->addWidget(posBox); layout->addStretch(1); } + + +void LSPaneEditor::setPane(LYTPane *pane) { + m_currentlyLoadingPane = true; + m_pane = pane; + + m_tabs->setVisible(true); + + + m_nameEntry->setText(pane->name); + m_userDataEntry->setText(pane->userdata); + + m_alpha->setValue(pane->alpha); + m_influencedAlpha->setChecked(pane->influencedAlpha); + + + m_width->setValue(pane->width); + m_height->setValue(pane->height); + + m_horzOrigin->setCurrentIndex((int)pane->horzOrigin); + m_vertOrigin->setCurrentIndex((int)pane->vertOrigin); + + m_widescreen->setChecked(pane->isWidescreen); + m_visible->setChecked(pane->visible); + + + m_transX->setValue(pane->xTrans); + m_transY->setValue(pane->yTrans); + m_transZ->setValue(pane->zTrans); + + m_rotX->setValue(pane->xRot); + m_rotY->setValue(pane->yRot); + m_rotZ->setValue(pane->zRot); + + m_scaleX->setValue(pane->xScale); + m_scaleY->setValue(pane->yScale); + + + m_currentlyLoadingPane = false; +} + + +void LSPaneEditor::handleNameChanged(QString value) { + if (!m_currentlyLoadingPane) { + m_pane->name = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleUserDataChanged(QString value) { + if (!m_currentlyLoadingPane) { + m_pane->userdata = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleAlphaChanged(int value) { + if (!m_currentlyLoadingPane) { + m_pane->alpha = (quint8)value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleInfluencedAlphaChanged(bool value) { + if (!m_currentlyLoadingPane) { + m_pane->influencedAlpha = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleWidthChanged(double value) { + if (!m_currentlyLoadingPane) { + m_pane->width = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleHeightChanged(double value) { + if (!m_currentlyLoadingPane) { + m_pane->width = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleHorzOriginChanged(int value) { + if (!m_currentlyLoadingPane) { + m_pane->horzOrigin = (LYTPane::OriginType)value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleVertOriginChanged(int value) { + if (!m_currentlyLoadingPane) { + m_pane->vertOrigin = (LYTPane::OriginType)value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleWidescreenChanged(bool value) { + if (!m_currentlyLoadingPane) { + m_pane->isWidescreen = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleVisibleChanged(bool value) { + if (!m_currentlyLoadingPane) { + m_pane->visible = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleTransXChanged(double value) { + if (!m_currentlyLoadingPane) { + m_pane->xTrans = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleTransYChanged(double value) { + if (!m_currentlyLoadingPane) { + m_pane->yTrans = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleTransZChanged(double value) { + if (!m_currentlyLoadingPane) { + m_pane->zTrans = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleRotXChanged(double value) { + if (!m_currentlyLoadingPane) { + m_pane->xRot = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleRotYChanged(double value) { + if (!m_currentlyLoadingPane) { + m_pane->yRot = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleRotZChanged(double value) { + if (!m_currentlyLoadingPane) { + m_pane->zRot = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleScaleXChanged(double value) { + if (!m_currentlyLoadingPane) { + m_pane->xScale = value; + emit mustRedrawLayout(); + } +} + +void LSPaneEditor::handleScaleYChanged(double value) { + if (!m_currentlyLoadingPane) { + m_pane->yScale = value; + emit mustRedrawLayout(); + } +} + diff --git a/lspaneeditor.h b/lspaneeditor.h index 4955a72..0c4ddc3 100644 --- a/lspaneeditor.h +++ b/lspaneeditor.h @@ -11,6 +11,7 @@ #include #include #include +#include "lyt/pane.h" class LSPaneEditor : public QWidget { Q_OBJECT @@ -42,11 +43,36 @@ private: QDoubleSpinBox *m_scaleX, *m_scaleY; void createPaneTab(); - + + bool m_currentlyLoadingPane; + LYTPane *m_pane; + +private slots: + void handleNameChanged(QString value); + void handleUserDataChanged(QString value); + void handleAlphaChanged(int value); + void handleInfluencedAlphaChanged(bool value); + void handleWidthChanged(double value); + void handleHeightChanged(double value); + void handleHorzOriginChanged(int value); + void handleVertOriginChanged(int value); + void handleWidescreenChanged(bool value); + void handleVisibleChanged(bool value); + void handleTransXChanged(double value); + void handleTransYChanged(double value); + void handleTransZChanged(double value); + void handleRotXChanged(double value); + void handleRotYChanged(double value); + void handleRotZChanged(double value); + void handleScaleXChanged(double value); + void handleScaleYChanged(double value); + signals: + void mustRedrawLayout(); public slots: - + void setPane(LYTPane *pane); + }; #endif // LSPANEEDITOR_H -- cgit v1.2.3