mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-02-01 18:40:12 -05:00
Bug fixes:
--Typing in the xform color index spinner produced strange results. --Returning from palette editor did not always update xform color indices.
This commit is contained in:
parent
59f5bffc3c
commit
48a6111bf9
@ -281,7 +281,7 @@ public slots:
|
|||||||
|
|
||||||
//Xforms Color.
|
//Xforms Color.
|
||||||
void OnXformColorIndexChanged(double d);
|
void OnXformColorIndexChanged(double d);
|
||||||
void OnXformColorIndexChanged(double d, bool updateRender, eXformUpdate update = eXformUpdate::UPDATE_SELECTED, size_t index = 0);
|
void OnXformColorIndexChanged(double d, bool updateRender, bool updateSpinner, bool updateScroll, eXformUpdate update = eXformUpdate::UPDATE_SELECTED, size_t index = 0);
|
||||||
void OnXformScrollColorIndexChanged(int d);
|
void OnXformScrollColorIndexChanged(int d);
|
||||||
void OnRandomColorIndicesButtonClicked(bool b);
|
void OnRandomColorIndicesButtonClicked(bool b);
|
||||||
void OnToggleColorIndicesButtonClicked(bool b);
|
void OnToggleColorIndicesButtonClicked(bool b);
|
||||||
|
@ -199,8 +199,7 @@ public:
|
|||||||
virtual void InitLockedScale() { }
|
virtual void InitLockedScale() { }
|
||||||
|
|
||||||
//Xforms Color.
|
//Xforms Color.
|
||||||
virtual void XformColorIndexChanged(double d, bool updateRender, eXformUpdate update = eXformUpdate::UPDATE_SELECTED, size_t index = 0) { }
|
virtual void XformColorIndexChanged(double d, bool updateRender, bool updateSpinner, bool updateScroll, eXformUpdate update = eXformUpdate::UPDATE_SELECTED, size_t index = 0) { }
|
||||||
virtual void XformScrollColorIndexChanged(int d) { }
|
|
||||||
virtual void RandomColorIndicesButtonClicked() { }
|
virtual void RandomColorIndicesButtonClicked() { }
|
||||||
virtual void ToggleColorIndicesButtonClicked() { }
|
virtual void ToggleColorIndicesButtonClicked() { }
|
||||||
virtual void RandomColorSpeedButtonClicked() { }
|
virtual void RandomColorSpeedButtonClicked() { }
|
||||||
@ -466,8 +465,7 @@ public:
|
|||||||
T AffineScaleLockedToCurrent();
|
T AffineScaleLockedToCurrent();
|
||||||
|
|
||||||
//Xforms Color.
|
//Xforms Color.
|
||||||
virtual void XformColorIndexChanged(double d, bool updateRender, eXformUpdate update = eXformUpdate::UPDATE_SELECTED, size_t index = 0) override;
|
virtual void XformColorIndexChanged(double d, bool updateRender, bool updateSpinner, bool updateScroll, eXformUpdate update = eXformUpdate::UPDATE_SELECTED, size_t index = 0) override;
|
||||||
virtual void XformScrollColorIndexChanged(int d) override;
|
|
||||||
virtual void RandomColorIndicesButtonClicked() override;
|
virtual void RandomColorIndicesButtonClicked() override;
|
||||||
virtual void ToggleColorIndicesButtonClicked() override;
|
virtual void ToggleColorIndicesButtonClicked() override;
|
||||||
virtual void RandomColorSpeedButtonClicked() override;
|
virtual void RandomColorSpeedButtonClicked() override;
|
||||||
|
@ -172,8 +172,9 @@ void FractoriumEmberController<T>::UpdateAdjustedPaletteGUI(Palette<float>& pale
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Update the current xform's color and reset the rendering process.
|
//Update the current xform's color and reset the rendering process.
|
||||||
|
//Update all controls to be safe.
|
||||||
if (xform)
|
if (xform)
|
||||||
XformColorIndexChanged(xform->m_ColorX, true);
|
XformColorIndexChanged(xform->m_ColorX, true, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -321,9 +322,9 @@ void FractoriumEmberController<T>::PaletteEditorButtonClicked()
|
|||||||
auto ed = m_Fractorium->m_PaletteEditor;
|
auto ed = m_Fractorium->m_PaletteEditor;
|
||||||
Palette<float> edPal;
|
Palette<float> edPal;
|
||||||
Palette<float> prevPal = m_TempPalette;
|
Palette<float> prevPal = m_TempPalette;
|
||||||
ed->SetPalette(m_TempPalette);
|
|
||||||
map<size_t, float> colorIndices;
|
map<size_t, float> colorIndices;
|
||||||
bool forceFinal = m_Fractorium->HaveFinal();
|
bool forceFinal = m_Fractorium->HaveFinal();
|
||||||
|
ed->SetPalette(m_TempPalette);
|
||||||
|
|
||||||
while (auto xform = m_Ember.GetTotalXform(i, forceFinal))
|
while (auto xform = m_Ember.GetTotalXform(i, forceFinal))
|
||||||
colorIndices[i++] = xform->m_ColorX;
|
colorIndices[i++] = xform->m_ColorX;
|
||||||
@ -333,21 +334,29 @@ void FractoriumEmberController<T>::PaletteEditorButtonClicked()
|
|||||||
|
|
||||||
if (ed->exec() == QDialog::Accepted)
|
if (ed->exec() == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
if (!m_Fractorium->PaletteChanged())//If the clicked ok, but never synced, set the palette now.
|
//Copy all just to be safe, because they may or may not have synced.
|
||||||
{
|
colorIndices = ed->GetColorIndices();
|
||||||
edPal = ed->GetPalette(int(256));
|
|
||||||
SetBasePaletteAndAdjust(edPal);
|
|
||||||
|
|
||||||
if (edPal.m_Filename.get() && !edPal.m_Filename->empty())
|
for (auto& index : colorIndices)
|
||||||
m_Fractorium->SetPaletteFileComboIndex(*edPal.m_Filename);
|
if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal))
|
||||||
}
|
xform->m_ColorX = index.second;
|
||||||
|
|
||||||
|
edPal = ed->GetPalette(int(256));
|
||||||
|
SetBasePaletteAndAdjust(edPal);//This will take care of updating the color index controls.
|
||||||
|
|
||||||
|
if (edPal.m_Filename.get() && !edPal.m_Filename->empty())
|
||||||
|
m_Fractorium->SetPaletteFileComboIndex(*edPal.m_Filename);
|
||||||
}
|
}
|
||||||
else if (m_Fractorium->PaletteChanged())//They clicked cancel, but synced at least once, restore the previous palette.
|
else if (m_Fractorium->PaletteChanged())//They clicked cancel, but synced at least once, restore the previous palette.
|
||||||
{
|
{
|
||||||
SetBasePaletteAndAdjust(prevPal);
|
for (auto& index : colorIndices)
|
||||||
|
if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal))
|
||||||
|
xform->m_ColorX = index.second;
|
||||||
|
|
||||||
|
SetBasePaletteAndAdjust(prevPal);//This will take care of updating the color index controls.
|
||||||
}
|
}
|
||||||
|
|
||||||
//Whether the current palette file was changed or not, if it's modifiable then reload it just to be safe.
|
//Whether the current palette file was changed or not, if it's modifiable then reload it just to be safe (even though it might be overkill).
|
||||||
if (m_PaletteList->IsModifiable(m_CurrentPaletteFilePath))
|
if (m_PaletteList->IsModifiable(m_CurrentPaletteFilePath))
|
||||||
m_Fractorium->OnPaletteFilenameComboChanged(QString::fromStdString(m_CurrentPaletteFilePath));
|
m_Fractorium->OnPaletteFilenameComboChanged(QString::fromStdString(m_CurrentPaletteFilePath));
|
||||||
}
|
}
|
||||||
@ -406,15 +415,15 @@ void Fractorium::OnPaletteEditorFileChanged()
|
|||||||
/// <param name="value">The value of the color index</param>
|
/// <param name="value">The value of the color index</param>
|
||||||
void Fractorium::OnPaletteEditorColorIndexChanged(size_t index, float value)
|
void Fractorium::OnPaletteEditorColorIndexChanged(size_t index, float value)
|
||||||
{
|
{
|
||||||
if (index == std::numeric_limits<size_t>::max())
|
if (index == std::numeric_limits<size_t>::max())//Update all in this case.
|
||||||
{
|
{
|
||||||
auto indices = m_PaletteEditor->GetColorIndices();
|
auto indices = m_PaletteEditor->GetColorIndices();
|
||||||
|
|
||||||
for (auto& it : indices)
|
for (auto& it : indices)
|
||||||
OnXformColorIndexChanged(it.second, true, eXformUpdate::UPDATE_SPECIFIC, it.first);
|
OnXformColorIndexChanged(it.second, true, true, true, eXformUpdate::UPDATE_SPECIFIC, it.first);
|
||||||
}
|
}
|
||||||
else
|
else//Only update the xform index that was selected and dragged inside of the palette editor.
|
||||||
OnXformColorIndexChanged(value, true, eXformUpdate::UPDATE_SPECIFIC, index);
|
OnXformColorIndexChanged(value, true, true, true, eXformUpdate::UPDATE_SPECIFIC, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -40,35 +40,44 @@ void Fractorium::InitXformsColorUI()
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="d">The color index, 0-1/</param>
|
/// <param name="d">The color index, 0-1/</param>
|
||||||
/// <param name="updateRender">True to reset the rendering process, else don't.</param>
|
/// <param name="updateRender">True to reset the rendering process, else don't.</param>
|
||||||
|
/// <param name="updateSpinner">True to update the color index spinner with the new value, else don't.</param>
|
||||||
|
/// <param name="updateScroll">True to update the color index scroll bar with the new value, else don't.</param>
|
||||||
/// <param name="update">The type of updating to do, default: eXformUpdate::UPDATE_SELECTED.</param>
|
/// <param name="update">The type of updating to do, default: eXformUpdate::UPDATE_SELECTED.</param>
|
||||||
/// <param name="index">The index of the xform to update. Ignored unless update is eXformUpdate::UPDATE_SPECIFIC. Default: 0.</param>
|
/// <param name="index">The index of the xform to update. Ignored unless update is eXformUpdate::UPDATE_SPECIFIC. Default: 0.</param>
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void FractoriumEmberController<T>::XformColorIndexChanged(double d, bool updateRender, eXformUpdate update, size_t index)
|
void FractoriumEmberController<T>::XformColorIndexChanged(double d, bool updateRender, bool updateSpinner, bool updateScroll, eXformUpdate update, size_t index)
|
||||||
{
|
{
|
||||||
bool updateGUI = update != eXformUpdate::UPDATE_SPECIFIC || index == m_Fractorium->ui.CurrentXformCombo->currentIndex();
|
bool updateGUI = update != eXformUpdate::UPDATE_SPECIFIC || index == m_Fractorium->ui.CurrentXformCombo->currentIndex();
|
||||||
|
|
||||||
if (updateGUI)
|
if (updateRender)//False when just updating GUI in response to a change elsewhere, true when in response to a GUI change so update values and reset renderer.
|
||||||
{
|
|
||||||
auto scroll = m_Fractorium->ui.XformColorScroll;
|
|
||||||
int scrollVal = d * scroll->maximum();
|
|
||||||
scroll->blockSignals(true);
|
|
||||||
scroll->setValue(scrollVal);
|
|
||||||
scroll->blockSignals(false);
|
|
||||||
m_Fractorium->m_XformColorIndexSpin->SetValueStealth(CurrentXform()->m_ColorX);
|
|
||||||
m_Fractorium->ui.XformColorIndexTable->item(0, 0)->setBackgroundColor(ColorIndexToQColor(d));//Grab the current color from the index and assign it to the first cell of the first table.
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updateRender)//False when just updating GUI, true when in response to a GUI change so update values and reset renderer.
|
|
||||||
{
|
{
|
||||||
UpdateXform([&](Xform<T>* xform)
|
UpdateXform([&](Xform<T>* xform)
|
||||||
{
|
{
|
||||||
xform->m_ColorX = Clamp<T>(d, 0, 1);
|
xform->m_ColorX = Clamp<T>(d, 0, 1);
|
||||||
}, update, updateRender, eProcessAction::FULL_RENDER, index);
|
}, update, updateRender, eProcessAction::FULL_RENDER, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Only do this is coming from elsewhere, like the palette editor. Otherwise, normal events will handle updating the spinner.
|
||||||
|
if (updateSpinner && updateGUI)
|
||||||
|
{
|
||||||
|
m_Fractorium->m_XformColorIndexSpin->SetValueStealth(CurrentXform()->m_ColorX);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateScroll && updateGUI)
|
||||||
|
{
|
||||||
|
auto scroll = m_Fractorium->ui.XformColorScroll;
|
||||||
|
int scrollVal = d * scroll->maximum();
|
||||||
|
scroll->blockSignals(true);
|
||||||
|
scroll->setValue(scrollVal);
|
||||||
|
scroll->blockSignals(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateGUI)
|
||||||
|
m_Fractorium->ui.XformColorIndexTable->item(0, 0)->setBackgroundColor(ColorIndexToQColor(d));//Grab the current color from the index and assign it to the first cell of the first table.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fractorium::OnXformColorIndexChanged(double d) { OnXformColorIndexChanged(d, true, eXformUpdate::UPDATE_SELECTED, 0); }
|
void Fractorium::OnXformColorIndexChanged(double d) { OnXformColorIndexChanged(d, true, false, true, eXformUpdate::UPDATE_SELECTED, std::numeric_limits<size_t>::max()); }
|
||||||
void Fractorium::OnXformColorIndexChanged(double d, bool updateRender, eXformUpdate update, size_t index) { m_Controller->XformColorIndexChanged(d, updateRender, update, index); }
|
void Fractorium::OnXformColorIndexChanged(double d, bool updateRender, bool updateSpinner, bool updateScroll, eXformUpdate update, size_t index) { m_Controller->XformColorIndexChanged(d, updateRender, updateSpinner, updateScroll, update, index); }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the color index of the current xform.
|
/// Set the color index of the current xform.
|
||||||
@ -77,14 +86,11 @@ void Fractorium::OnXformColorIndexChanged(double d, bool updateRender, eXformUpd
|
|||||||
/// Resets the rendering process.
|
/// Resets the rendering process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="d">The color index, 0-1.</param>
|
/// <param name="d">The color index, 0-1.</param>
|
||||||
template <typename T>
|
void Fractorium::OnXformScrollColorIndexChanged(int d)
|
||||||
void FractoriumEmberController<T>::XformScrollColorIndexChanged(int d)
|
|
||||||
{
|
{
|
||||||
m_Fractorium->m_XformColorIndexSpin->setValue(d / double(m_Fractorium->ui.XformColorScroll->maximum()));//Will trigger an update.
|
OnXformColorIndexChanged(d / double(ui.XformColorScroll->maximum()), true, true, false);//Update spinner, but not scrollbar. Trigger render update.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fractorium::OnXformScrollColorIndexChanged(int d) { m_Controller->XformScrollColorIndexChanged(d); }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set all xform color indices to a random value between 0 and 1, inclusive.
|
/// Set all xform color indices to a random value between 0 and 1, inclusive.
|
||||||
/// Called when the Random Indices button is clicked.
|
/// Called when the Random Indices button is clicked.
|
||||||
@ -93,8 +99,8 @@ void Fractorium::OnXformScrollColorIndexChanged(int d) { m_Controller->XformScro
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void FractoriumEmberController<T>::RandomColorIndicesButtonClicked()
|
void FractoriumEmberController<T>::RandomColorIndicesButtonClicked()
|
||||||
{
|
{
|
||||||
UpdateXform([&](Xform<T>* xform) { xform->m_ColorX = m_Rand.Frand01<T>(); }, eXformUpdate::UPDATE_ALL);
|
UpdateXform([&](Xform<T>* xform) { xform->m_ColorX = m_Rand.Frand01<T>(); }, eXformUpdate::UPDATE_ALL, false);//Don't update renderer here...
|
||||||
m_Fractorium->OnXformColorIndexChanged(CurrentXform()->m_ColorX, false);//Update GUI, no need to update renderer because UpdateXform() did it.
|
m_Fractorium->m_XformColorIndexSpin->setValue(CurrentXform()->m_ColorX);//...do it via GUI. This will set scrollbar value as well.
|
||||||
}
|
}
|
||||||
void Fractorium::OnRandomColorIndicesButtonClicked(bool b) { m_Controller->RandomColorIndicesButtonClicked(); }
|
void Fractorium::OnRandomColorIndicesButtonClicked(bool b) { m_Controller->RandomColorIndicesButtonClicked(); }
|
||||||
|
|
||||||
@ -107,8 +113,8 @@ template <typename T>
|
|||||||
void FractoriumEmberController<T>::ToggleColorIndicesButtonClicked()
|
void FractoriumEmberController<T>::ToggleColorIndicesButtonClicked()
|
||||||
{
|
{
|
||||||
char ch = 1;
|
char ch = 1;
|
||||||
UpdateXform([&](Xform<T>* xform) { xform->m_ColorX = T(ch ^= 1); }, eXformUpdate::UPDATE_ALL);
|
UpdateXform([&](Xform<T>* xform) { xform->m_ColorX = T(ch ^= 1); }, eXformUpdate::UPDATE_ALL, false);//Don't update renderer here...
|
||||||
m_Fractorium->OnXformColorIndexChanged(CurrentXform()->m_ColorX, false);//Update GUI, no need to update renderer because UpdateXform() did it.
|
m_Fractorium->m_XformColorIndexSpin->setValue(CurrentXform()->m_ColorX);//...do it via GUI. This will set scrollbar value as well.
|
||||||
}
|
}
|
||||||
void Fractorium::OnToggleColorIndicesButtonClicked(bool b) { m_Controller->ToggleColorIndicesButtonClicked(); }
|
void Fractorium::OnToggleColorIndicesButtonClicked(bool b) { m_Controller->ToggleColorIndicesButtonClicked(); }
|
||||||
|
|
||||||
@ -239,7 +245,7 @@ void FractoriumEmberController<T>::FillColorWithXform(Xform<T>* xform)
|
|||||||
m_Fractorium->m_XformColorSpeedSpin->SetValueStealth(xform->m_ColorSpeed);
|
m_Fractorium->m_XformColorSpeedSpin->SetValueStealth(xform->m_ColorSpeed);
|
||||||
m_Fractorium->m_XformOpacitySpin->SetValueStealth(xform->m_Opacity);
|
m_Fractorium->m_XformOpacitySpin->SetValueStealth(xform->m_Opacity);
|
||||||
m_Fractorium->m_XformDirectColorSpin->SetValueStealth(xform->m_DirectColor);
|
m_Fractorium->m_XformDirectColorSpin->SetValueStealth(xform->m_DirectColor);
|
||||||
m_Fractorium->OnXformColorIndexChanged(xform->m_ColorX, false);//Had to call stealth before to avoid doing an update, now manually update related controls, still without doing an update.
|
m_Fractorium->OnXformColorIndexChanged(xform->m_ColorX, false, false, true);//Had to call stealth before to avoid doing an update, now manually update related controls, still without doing an update.
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user