Let xform combo show the names of xforms

This commit is contained in:
luyuju151 2018-07-09 14:55:57 +08:00
parent e58deb1194
commit d88d8bb2ea
3 changed files with 34 additions and 6 deletions

View File

@ -1,4 +1,4 @@
#include "FractoriumPch.h"
#include "FractoriumPch.h"
#include "FractoriumEmberController.h"
#include "FinalRenderEmberController.h"
#include "FinalRenderDialog.h"

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "EmberFile.h"
#include "DoubleSpinBox.h"
@ -183,6 +183,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) { }
@ -448,6 +449,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<T>* xform);
Xform<T>* CurrentXform();
void UpdateXform(std::function<void(Xform<T>*, size_t, size_t)> func, eXformUpdate updateType = eXformUpdate::UPDATE_CURRENT, bool updateRender = true, eProcessAction action = eProcessAction::FULL_RENDER, size_t index = 0);

View File

@ -63,9 +63,8 @@ Xform<T>* FractoriumEmberController<T>::CurrentXform()
void Fractorium::CurrentXform(uint i)
{
if (i < uint(ui.CurrentXformCombo->count()))
ui.CurrentXformCombo->setCurrentIndex(i);
ui.CurrentXformCombo->setCurrentIndex(i);
}
/// <summary>
/// Set the current xform and populate all GUI widgets.
/// Called when the current xform combo box index changes.
@ -394,7 +393,11 @@ void FractoriumEmberController<T>::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());
}
/// <summary>
/// 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
@ -514,6 +517,7 @@ void FractoriumEmberController<T>::FillXforms(int index)
{
combo->addItem(ToString(i + 1));
combo->setItemIcon(i, m_Fractorium->m_XformComboIcons[i % XFORM_COLOR_COUNT]);
UpdateXformName(i);
}
i = 0;
@ -549,6 +553,7 @@ void FractoriumEmberController<T>::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);
@ -559,7 +564,28 @@ void FractoriumEmberController<T>::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.
}
/// <summary>
/// Update the text in xforms combo box to show the name of Xform.
/// </summary>
/// <param name="index">The index of the Xform to update.</param>
///
template<typename T>
void FractoriumEmberController<T>::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<float>;
#ifdef DO_DOUBLE