diff --git a/Source/Fractorium/FinalRenderEmberController.cpp b/Source/Fractorium/FinalRenderEmberController.cpp index 284955f..46382f8 100644 --- a/Source/Fractorium/FinalRenderEmberController.cpp +++ b/Source/Fractorium/FinalRenderEmberController.cpp @@ -1,4 +1,4 @@ -#include "FractoriumPch.h" +#include "FractoriumPch.h" #include "FractoriumEmberController.h" #include "FinalRenderEmberController.h" #include "FinalRenderDialog.h" diff --git a/Source/Fractorium/Fractorium.cpp b/Source/Fractorium/Fractorium.cpp index e32d3e5..efb7282 100644 --- a/Source/Fractorium/Fractorium.cpp +++ b/Source/Fractorium/Fractorium.cpp @@ -1,4 +1,4 @@ -#include "FractoriumPch.h" +#include "FractoriumPch.h" #include "Fractorium.h" #include "QssDialog.h" @@ -89,6 +89,10 @@ Fractorium::Fractorium(QWidget* p) pixmap.fill(m_XformComboColors[i]); m_XformComboIcons[i] = QIcon(pixmap); } + + //Set Default VariationTreeBgColor + m_VariationTreeBgColorNoneZero=QColor(200,200,200); + m_VariationTreeBgColorZero=QColor(255,255,255); QPixmap pixmap(iconSize_, iconSize_); pixmap.fill(m_FinalXformComboColor); diff --git a/Source/Fractorium/Fractorium.h b/Source/Fractorium/Fractorium.h index 8874628..4e70e26 100644 --- a/Source/Fractorium/Fractorium.h +++ b/Source/Fractorium/Fractorium.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "ui_Fractorium.h" #include "FractoriumCommon.h" @@ -63,7 +63,9 @@ template class FinalRenderEmberController; class Fractorium : public QMainWindow { Q_OBJECT - + Q_PROPERTY(QColor VariationTreeBgColorNoneZero MEMBER m_VariationTreeBgColorNoneZero) + Q_PROPERTY(QColor VariationTreeBgColorZero MEMBER m_VariationTreeBgColorZero) + friend GLWidget; friend QssDialog; friend LibraryTreeWidget; @@ -482,7 +484,7 @@ private: //Xforms. DoubleSpinBox* m_XformWeightSpin; - SpinnerButtonWidget* m_XformWeightSpinnerButtonWidget; + SpinnerLabelButtonWidget* m_XformWeightSpinnerButtonWidget; QFormLayout* m_XformsSelectionLayout; vector m_XformSelections; @@ -559,6 +561,7 @@ private: char m_CoordinateString[128]; QColor m_XformComboColors[XFORM_COLOR_COUNT], m_FinalXformComboColor; QIcon m_XformComboIcons[XFORM_COLOR_COUNT], m_FinalXformComboIcon; + QColor m_VariationTreeBgColorNoneZero, m_VariationTreeBgColorZero; vector m_Docks; int m_FontSize; @@ -569,4 +572,7 @@ private: shared_ptr m_Info; unique_ptr m_Controller; Ui::FractoriumClass ui; + + + }; diff --git a/Source/Fractorium/FractoriumEmberController.h b/Source/Fractorium/FractoriumEmberController.h index 91e0c2a..d9f41fc 100644 --- a/Source/Fractorium/FractoriumEmberController.h +++ b/Source/Fractorium/FractoriumEmberController.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "EmberFile.h" #include "DoubleSpinBox.h" @@ -184,6 +184,7 @@ public: virtual void XformNameChanged(int row, int col) { } virtual void XformAnimateChanged(int state) { } virtual void FillXforms(int index = 0) { } + virtual void UpdateXformName(int index) { } //Xforms Affine. virtual void AffineSetHelper(double d, int index, bool pre) { } @@ -450,6 +451,7 @@ public: virtual void XformNameChanged(int row, int col) override; virtual void XformAnimateChanged(int state) override; virtual void FillXforms(int index = 0) override; + virtual void UpdateXformName(int index) override; void FillWithXform(Xform* xform); Xform* CurrentXform(); void UpdateXform(std::function*, size_t, size_t)> func, eXformUpdate updateType = eXformUpdate::UPDATE_CURRENT, bool updateRender = true, eProcessAction action = eProcessAction::FULL_RENDER, size_t index = 0); diff --git a/Source/Fractorium/FractoriumXforms.cpp b/Source/Fractorium/FractoriumXforms.cpp index 02b362b..a8627b3 100644 --- a/Source/Fractorium/FractoriumXforms.cpp +++ b/Source/Fractorium/FractoriumXforms.cpp @@ -1,4 +1,4 @@ -#include "FractoriumPch.h" +#include "FractoriumPch.h" #include "Fractorium.h" /// @@ -15,14 +15,20 @@ void Fractorium::InitXformsUI() connect(ui.AddFinalXformButton, SIGNAL(clicked(bool)), this, SLOT(OnAddFinalXformButtonClicked(bool)), Qt::QueuedConnection); connect(ui.CurrentXformCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(OnCurrentXformComboChanged(int)), Qt::QueuedConnection); connect(ui.AnimateXformCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnXformAnimateCheckBoxStateChanged(int)), Qt::QueuedConnection); - SetFixedTableHeader(ui.XformWeightNameTable->horizontalHeader()); + SetFixedTableHeader(ui.XformWeightNameTable->horizontalHeader(),QHeaderView::ResizeToContents); //Use SetupSpinner() just to create the spinner, but use col of -1 to prevent it from being added to the table. SetupSpinner(ui.XformWeightNameTable, this, row, -1, m_XformWeightSpin, spinHeight, 0, 1000, 0.05, SIGNAL(valueChanged(double)), SLOT(OnXformWeightChanged(double)), false, 0, 1, 0); m_XformWeightSpin->setDecimals(3); m_XformWeightSpin->SmallStep(0.001); - m_XformWeightSpinnerButtonWidget = new SpinnerButtonWidget(m_XformWeightSpin, "=", 20, 19, ui.XformWeightNameTable); - m_XformWeightSpinnerButtonWidget->m_Button->setToolTip("Equalize weights"); + m_XformWeightSpin->setMinimumWidth(40); + m_XformWeightSpinnerButtonWidget = new SpinnerLabelButtonWidget(m_XformWeightSpin, "=", 20, 19, ui.XformWeightNameTable); + m_XformWeightSpinnerButtonWidget->m_SpinBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); + m_XformWeightSpinnerButtonWidget->m_Label->setStyleSheet("border: 0px;"); + m_XformWeightSpinnerButtonWidget->m_Label->setAlignment(Qt::AlignRight| Qt::AlignVCenter); + m_XformWeightSpinnerButtonWidget->m_Label->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); + m_XformWeightSpinnerButtonWidget->m_Button->setToolTip("Equalize weights"); m_XformWeightSpinnerButtonWidget->m_Button->setStyleSheet("text-align: center center"); + m_XformWeightSpinnerButtonWidget->setMaximumWidth(130); connect(m_XformWeightSpinnerButtonWidget->m_Button, SIGNAL(clicked(bool)), this, SLOT(OnEqualWeightButtonClicked(bool)), Qt::QueuedConnection); ui.XformWeightNameTable->setCellWidget(0, 0, m_XformWeightSpinnerButtonWidget); ui.XformWeightNameTable->setItem(0, 1, new QTableWidgetItem()); @@ -57,9 +63,8 @@ Xform* FractoriumEmberController::CurrentXform() void Fractorium::CurrentXform(uint i) { if (i < uint(ui.CurrentXformCombo->count())) - ui.CurrentXformCombo->setCurrentIndex(i); + ui.CurrentXformCombo->setCurrentIndex(i); } - /// /// Set the current xform and populate all GUI widgets. /// Called when the current xform combo box index changes. @@ -388,7 +393,11 @@ void FractoriumEmberController::XformNameChanged(int row, int col) }, eXformUpdate::UPDATE_CURRENT, false); FillSummary();//Manually update because this does not trigger a render, which is where this would normally be called. } -void Fractorium::OnXformNameChanged(int row, int col) { m_Controller->XformNameChanged(row, col); } +void Fractorium::OnXformNameChanged(int row, int col) +{ + m_Controller->XformNameChanged(row, col); + m_Controller->UpdateXformName(ui.CurrentXformCombo->currentIndex()); +} /// /// Set the animate field of the selected xforms, this allows excluding current if it's not checked, but applies only to it if none are checked. /// This has no effect on interactive rendering, it only sets a value @@ -471,8 +480,9 @@ void FractoriumEmberController::SetNormalizedWeightText(Xform* xform) m_Ember.CalcNormalizedWeights(m_NormalizedWeights); if (index != -1 && index < m_NormalizedWeights.size()) - m_Fractorium->m_XformWeightSpin->setSuffix(QString(" (") + QLocale::system().toString(double(m_NormalizedWeights[index]), 'g', 3) + ")"); - } + //m_Fractorium->m_XformWeightSpin->setSuffix(QString(" (") + QLocale::system().toString(double(m_NormalizedWeights[index]), 'g', 3) + ")"); + m_Fractorium->m_XformWeightSpinnerButtonWidget->m_Label->setText(QString(" (") + QLocale::system().toString(double(m_NormalizedWeights[index]), 'g', 3) + ")"); + } } /// /// Determine whether the specified xform is the final xform in the ember. @@ -507,6 +517,7 @@ void FractoriumEmberController::FillXforms(int index) { combo->addItem(ToString(i + 1)); combo->setItemIcon(i, m_Fractorium->m_XformComboIcons[i % XFORM_COLOR_COUNT]); + UpdateXformName(i); } i = 0; @@ -542,6 +553,7 @@ void FractoriumEmberController::FillXforms(int index) m_Fractorium->m_XformsSelectionLayout->addRow(cb, new QWidget(m_Fractorium)); combo->addItem("Final"); combo->setItemIcon(i, m_Fractorium->m_FinalXformComboIcon); + UpdateXformName(i); } m_Fractorium->m_XformsSelectionLayout->blockSignals(false); @@ -552,7 +564,28 @@ void FractoriumEmberController::FillXforms(int index) m_Fractorium->FillXaosTable(); m_Fractorium->OnSoloXformCheckBoxStateChanged(Qt::Unchecked); - m_Fractorium->OnCurrentXformComboChanged(index);//Make sure the event gets called, because it won't if the zero index is already selected. + m_Fractorium->OnCurrentXformComboChanged(index);//Make sure the event gets called, because it won't if the zero index is already selected. +} +/// +/// Update the text in xforms combo box to show the name of Xform. +/// +/// The index of the Xform to update. +/// +template +void FractoriumEmberController::UpdateXformName(int index) +{ + bool forceFinal = m_Fractorium->HaveFinal(); + bool isFinal = m_Ember.FinalXform() == m_Ember.GetTotalXform(index, forceFinal); + QString name = isFinal ? "Final" : QString::number(index + 1); + + if (auto xform = m_Ember.GetTotalXform(index, forceFinal)) + { + if (!xform->m_Name.empty()) + { + name += " " + QString::fromStdString(xform->m_Name); + } + m_Fractorium->ui.CurrentXformCombo->setItemText(index,name); + } } template class FractoriumEmberController; #ifdef DO_DOUBLE diff --git a/Source/Fractorium/FractoriumXformsVariations.cpp b/Source/Fractorium/FractoriumXformsVariations.cpp index bcc9621..77b609e 100644 --- a/Source/Fractorium/FractoriumXformsVariations.cpp +++ b/Source/Fractorium/FractoriumXformsVariations.cpp @@ -1,4 +1,4 @@ -#include "FractoriumPch.h" +#include "FractoriumPch.h" #include "Fractorium.h" /// @@ -226,8 +226,8 @@ void FractoriumEmberController::VariationSpinBoxValueChanged(double d)//Would if (xformVar) xform->DeleteVariationById(var->VariationId()); - widgetItem->setBackgroundColor(0, QColor(255, 255, 255));//Ensure background is always white if weight goes to zero. - } +// widgetItem->setBackgroundColor(0, QColor(255, 255, 255));//Ensure background is always white if weight goes to zero. + widgetItem->setBackgroundColor(0, m_Fractorium->m_VariationTreeBgColorZero); } else { if (xformVar)//The xform already contained this variation, which means they just went from a non-zero weight to another non-zero weight (the simple case). @@ -241,8 +241,8 @@ void FractoriumEmberController::VariationSpinBoxValueChanged(double d)//Would auto newVar = var->Copy();//Create a new one with default values. newVar->m_Weight = d; xform->AddVariation(newVar); - widgetItem->setBackgroundColor(0, QColor(200, 200, 200));//Set background to gray when a variation has non-zero weight in this xform. - +// widgetItem->setBackgroundColor(0, QColor(200, 200, 200));//Set background to gray when a variation has non-zero weight in this xform. + widgetItem->setBackgroundColor(0, m_Fractorium->m_VariationTreeBgColorNoneZero); //If they've added a new parametric variation, then grab the values currently in the spinners //for the child parameters and assign them to the newly added variation. if (parVar) @@ -300,9 +300,9 @@ void FractoriumEmberController::FillVariationTreeWithXform(Xform* xform) item->setHidden(false); spinBox->SetValueStealth(var ? var->m_Weight : 0);//If the variation was present, set the spin box to its weight, else zero. - //item->setBackgroundColor(0, var ? Qt::darkGray : Qt::lightGray);//Ensure background is always white if the value goes to zero, else gray if var present. - item->setBackgroundColor(0, var ? QColor(200, 200, 200) : QColor(255, 255, 255));//Ensure background is always white if the value goes to zero, else gray if var present. - +// item->setBackgroundColor(0, var ? Qt::darkGray : Qt::lightGray);//Ensure background is always white if the value goes to zero, else gray if var present. +// item->setBackgroundColor(0, var ? QColor(200, 200, 200) : QColor(255, 255, 255));//Ensure background is always white if the value goes to zero, else gray if var present. + item->setBackgroundColor(0, var ? m_Fractorium->m_VariationTreeBgColorNoneZero : m_Fractorium->m_VariationTreeBgColorZero); for (int j = 0; j < item->childCount(); j++)//Iterate through all of the children, which will be the params if it was a parametric variation. { T* param = nullptr; diff --git a/Source/Fractorium/TwoButtonComboWidget.h b/Source/Fractorium/TwoButtonComboWidget.h index 7537740..86ec269 100644 --- a/Source/Fractorium/TwoButtonComboWidget.h +++ b/Source/Fractorium/TwoButtonComboWidget.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "FractoriumPch.h" #include "DoubleSpinBox.h" @@ -118,3 +118,51 @@ public: DoubleSpinBox* m_SpinBox; QPushButton* m_Button; }; + +class SpinnerLabelButtonWidget : public QWidget +{ + Q_OBJECT + +public: + /// + /// Constructor that passes the parent to the base, then creates a QLabel, + /// then creates a QPushButton and sets up its caption and dimensions, then + /// assigns the DoubleSpinBox. + /// + /// The pre-created DoubleSpinBox + /// The caption of the button + /// The width of the button + /// The height of the button + /// The parent widget + SpinnerLabelButtonWidget(DoubleSpinBox* spinBox, QString buttonCaption, int w, int h, QWidget* p) + : QWidget(p) + { + QHBoxLayout* l = new QHBoxLayout(this); + m_Button = new QPushButton(buttonCaption, p); + m_SpinBox = spinBox; + m_Label = new QLabel(p); + m_Label->setMinimumHeight(h); + m_Label->setMaximumHeight(h); + + if (w != -1) + { + m_Button->setMinimumWidth(w); + m_Button->setMaximumWidth(w); + } + + m_Button->setMinimumHeight(h); + m_Button->setMaximumHeight(h); + + l->addWidget(spinBox); + l->addWidget(m_Label); + l->addWidget(m_Button); + l->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); + l->setMargin(0); + l->setSpacing(0); + setLayout(l); + } + + DoubleSpinBox* m_SpinBox; + QPushButton* m_Button; + QLabel* m_Label; +};