mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-02-08 05:50:07 -05:00
Merged mfeemster/fractorium into master
This commit is contained in:
commit
6f42938bd7
@ -360,7 +360,7 @@ public slots:
|
|||||||
void OnPaletteEditorColorChanged();
|
void OnPaletteEditorColorChanged();
|
||||||
void OnPaletteEditorFileChanged();
|
void OnPaletteEditorFileChanged();
|
||||||
void OnPaletteEditorColorIndexChanged(size_t index, float value);
|
void OnPaletteEditorColorIndexChanged(size_t index, float value);
|
||||||
void OnPaletteEditorFinished(int result);
|
void OnPaletteEditorFinished(int result);
|
||||||
|
|
||||||
//Info.
|
//Info.
|
||||||
void OnSummaryTableHeaderResized(int logicalIndex, int oldSize, int newSize);
|
void OnSummaryTableHeaderResized(int logicalIndex, int oldSize, int newSize);
|
||||||
|
@ -249,7 +249,7 @@ public:
|
|||||||
virtual void SetBasePaletteAndAdjust(const Palette<float>& palette) { }
|
virtual void SetBasePaletteAndAdjust(const Palette<float>& palette) { }
|
||||||
virtual void PaletteEditorButtonClicked() { }
|
virtual void PaletteEditorButtonClicked() { }
|
||||||
virtual void PaletteEditorColorChanged() { }
|
virtual void PaletteEditorColorChanged() { }
|
||||||
virtual void SyncPalette(bool accepted) { }
|
virtual void SyncPalette(bool accepted) { }
|
||||||
QImage& FinalPaletteImage() { return m_FinalPaletteImage; }
|
QImage& FinalPaletteImage() { return m_FinalPaletteImage; }
|
||||||
|
|
||||||
//Info.
|
//Info.
|
||||||
@ -311,7 +311,7 @@ protected:
|
|||||||
unique_ptr<EmberNs::RendererBase> m_Renderer;
|
unique_ptr<EmberNs::RendererBase> m_Renderer;
|
||||||
QTIsaac<ISAAC_SIZE, ISAAC_INT> m_Rand;
|
QTIsaac<ISAAC_SIZE, ISAAC_INT> m_Rand;
|
||||||
Fractorium* m_Fractorium;
|
Fractorium* m_Fractorium;
|
||||||
Palette<float> m_TempPalette, m_PreviosTempPalette;
|
Palette<float> m_TempPalette, m_PreviousTempPalette;
|
||||||
std::unique_ptr<QTimer> m_RenderTimer;
|
std::unique_ptr<QTimer> m_RenderTimer;
|
||||||
std::unique_ptr<QTimer> m_RenderRestartTimer;
|
std::unique_ptr<QTimer> m_RenderRestartTimer;
|
||||||
shared_ptr<PaletteList<float>> m_PaletteList;
|
shared_ptr<PaletteList<float>> m_PaletteList;
|
||||||
@ -538,7 +538,7 @@ public:
|
|||||||
virtual void SetBasePaletteAndAdjust(const Palette<float>& palette) override;
|
virtual void SetBasePaletteAndAdjust(const Palette<float>& palette) override;
|
||||||
virtual void PaletteEditorButtonClicked() override;
|
virtual void PaletteEditorButtonClicked() override;
|
||||||
virtual void PaletteEditorColorChanged() override;
|
virtual void PaletteEditorColorChanged() override;
|
||||||
virtual void SyncPalette(bool accepted) override;
|
virtual void SyncPalette(bool accepted) override;
|
||||||
|
|
||||||
//Info.
|
//Info.
|
||||||
virtual void FillSummary() override;
|
virtual void FillSummary() override;
|
||||||
|
@ -383,25 +383,22 @@ template <typename T>
|
|||||||
void FractoriumEmberController<T>::PaletteEditorButtonClicked()
|
void FractoriumEmberController<T>::PaletteEditorButtonClicked()
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
auto ed = m_Fractorium->m_PaletteEditor;
|
auto ed = m_Fractorium->m_PaletteEditor;
|
||||||
map<size_t, float> colorIndices;
|
map<size_t, float> colorIndices;
|
||||||
bool forceFinal = m_Fractorium->HaveFinal();
|
bool forceFinal = m_Fractorium->HaveFinal();
|
||||||
|
m_PreviousTempPalette = m_TempPalette; // it's necessary because m_TempPalette is changed when the user make changes in palette editor
|
||||||
m_PreviosTempPalette = m_TempPalette; // it's necessary because m_TempPalette is changed when the user make changes in palette editor
|
ed->SetPalette(m_TempPalette);
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
ed->SetColorIndices(colorIndices);
|
ed->SetColorIndices(colorIndices);
|
||||||
ed->SetPreviousColorIndices(colorIndices); // also necessary because the colors are changed in palette editor
|
ed->SetPreviousColorIndices(colorIndices); // also necessary because the colors are changed in palette editor
|
||||||
ed->SetPaletteFile(m_CurrentPaletteFilePath);
|
ed->SetPaletteFile(m_CurrentPaletteFilePath);
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
ed->show();
|
ed->show();
|
||||||
#else
|
#else
|
||||||
SyncPalette(ed->exec() == QDialog::Accepted);
|
SyncPalette(ed->exec() == QDialog::Accepted);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,12 +420,12 @@ void Fractorium::OnPaletteEditorButtonClicked(bool checked)
|
|||||||
{
|
{
|
||||||
if (!m_PaletteEditor)
|
if (!m_PaletteEditor)
|
||||||
{
|
{
|
||||||
m_PaletteEditor = new PaletteEditor(this);
|
m_PaletteEditor = new PaletteEditor(this);
|
||||||
connect(m_PaletteEditor, SIGNAL(PaletteChanged()), this, SLOT(OnPaletteEditorColorChanged()), Qt::QueuedConnection);
|
connect(m_PaletteEditor, SIGNAL(PaletteChanged()), this, SLOT(OnPaletteEditorColorChanged()), Qt::QueuedConnection);
|
||||||
connect(m_PaletteEditor, SIGNAL(PaletteFileChanged()), this, SLOT(OnPaletteEditorFileChanged()), Qt::QueuedConnection);
|
connect(m_PaletteEditor, SIGNAL(PaletteFileChanged()), this, SLOT(OnPaletteEditorFileChanged()), Qt::QueuedConnection);
|
||||||
connect(m_PaletteEditor, SIGNAL(ColorIndexChanged(size_t, float)), this, SLOT(OnPaletteEditorColorIndexChanged(size_t, float)), Qt::QueuedConnection);
|
connect(m_PaletteEditor, SIGNAL(ColorIndexChanged(size_t, float)), this, SLOT(OnPaletteEditorColorIndexChanged(size_t, float)), Qt::QueuedConnection);
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
connect(m_PaletteEditor, SIGNAL(finished(int)), this, SLOT(OnPaletteEditorFinished(int)), Qt::QueuedConnection);
|
connect(m_PaletteEditor, SIGNAL(finished(int)), this, SLOT(OnPaletteEditorFinished(int)), Qt::QueuedConnection);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,42 +440,42 @@ void Fractorium::OnPaletteEditorButtonClicked(bool checked)
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void FractoriumEmberController<T>::SyncPalette(bool accepted)
|
void FractoriumEmberController<T>::SyncPalette(bool accepted)
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
auto ed = m_Fractorium->m_PaletteEditor;
|
auto ed = m_Fractorium->m_PaletteEditor;
|
||||||
Palette<float> edPal;
|
Palette<float> edPal;
|
||||||
Palette<float> prevPal = m_PreviosTempPalette;
|
Palette<float> prevPal = m_PreviousTempPalette;
|
||||||
map<size_t, float> colorIndices;
|
map<size_t, float> colorIndices;
|
||||||
bool forceFinal = m_Fractorium->HaveFinal();
|
bool forceFinal = m_Fractorium->HaveFinal();
|
||||||
|
|
||||||
if (accepted)
|
if (accepted)
|
||||||
{
|
{
|
||||||
//Copy all just to be safe, because they may or may not have synced.
|
//Copy all just to be safe, because they may or may not have synced.
|
||||||
colorIndices = ed->GetColorIndices();
|
colorIndices = ed->GetColorIndices();
|
||||||
|
|
||||||
for (auto& index : colorIndices)
|
for (auto& index : colorIndices)
|
||||||
if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal))
|
if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal))
|
||||||
xform->m_ColorX = index.second;
|
xform->m_ColorX = index.second;
|
||||||
|
|
||||||
edPal = ed->GetPalette(int(prevPal.Size()));
|
edPal = ed->GetPalette(int(prevPal.Size()));
|
||||||
SetBasePaletteAndAdjust(edPal);//This will take care of updating the color index controls.
|
SetBasePaletteAndAdjust(edPal);//This will take care of updating the color index controls.
|
||||||
|
|
||||||
if (edPal.m_Filename.get() && !edPal.m_Filename->empty())
|
if (edPal.m_Filename.get() && !edPal.m_Filename->empty())
|
||||||
m_Fractorium->SetPaletteFileComboIndex(*edPal.m_Filename);
|
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.
|
||||||
{
|
{
|
||||||
colorIndices = ed->GetPreviousColorIndices();
|
colorIndices = ed->GetPreviousColorIndices();
|
||||||
|
|
||||||
for (auto& index : colorIndices)
|
for (auto& index : colorIndices)
|
||||||
if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal))
|
if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal))
|
||||||
xform->m_ColorX = index.second;
|
xform->m_ColorX = index.second;
|
||||||
|
|
||||||
SetBasePaletteAndAdjust(prevPal);//This will take care of updating the color index controls.
|
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 (even though it might be overkill).
|
//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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -528,7 +525,7 @@ void Fractorium::OnPaletteEditorColorIndexChanged(size_t index, float value)
|
|||||||
/// <param name="result">Cancel/OK action</param>
|
/// <param name="result">Cancel/OK action</param>
|
||||||
void Fractorium::OnPaletteEditorFinished(int result)
|
void Fractorium::OnPaletteEditorFinished(int result)
|
||||||
{
|
{
|
||||||
m_Controller->SyncPalette(result == QDialog::Accepted);
|
m_Controller->SyncPalette(result == QDialog::Accepted);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -124,7 +124,7 @@ map<size_t, float> PaletteEditor::GetColorIndices() const
|
|||||||
/// <returns>The color indices</returns>
|
/// <returns>The color indices</returns>
|
||||||
map<size_t, float> PaletteEditor::GetPreviousColorIndices() const
|
map<size_t, float> PaletteEditor::GetPreviousColorIndices() const
|
||||||
{
|
{
|
||||||
return m_PreviousColorIndices;
|
return m_PreviousColorIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -143,7 +143,7 @@ void PaletteEditor::SetColorIndices(const map<size_t, float>& indices)
|
|||||||
/// <param name="indices">The color indices to backup</param>
|
/// <param name="indices">The color indices to backup</param>
|
||||||
void PaletteEditor::SetPreviousColorIndices(const map<size_t, float>& indices)
|
void PaletteEditor::SetPreviousColorIndices(const map<size_t, float>& indices)
|
||||||
{
|
{
|
||||||
m_PreviousColorIndices = indices;
|
m_PreviousColorIndices = indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -27,16 +27,16 @@ class PaletteEditor : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PaletteEditor(QWidget* p = nullptr);
|
explicit PaletteEditor(QWidget* p = nullptr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool Sync();
|
bool Sync();
|
||||||
Palette<float>& GetPalette(int size);
|
Palette<float>& GetPalette(int size);
|
||||||
void SetPalette(const Palette<float>& palette);
|
void SetPalette(const Palette<float>& palette);
|
||||||
map<size_t, float> GetColorIndices() const;
|
map<size_t, float> GetColorIndices() const;
|
||||||
map<size_t, float> GetPreviousColorIndices() const;
|
map<size_t, float> GetPreviousColorIndices() const;
|
||||||
void SetColorIndices(const map<size_t, float>& indices);
|
void SetColorIndices(const map<size_t, float>& indices);
|
||||||
void SetPreviousColorIndices(const map<size_t, float>& indices);
|
void SetPreviousColorIndices(const map<size_t, float>& indices);
|
||||||
string GetPaletteFile() const;
|
string GetPaletteFile() const;
|
||||||
void SetPaletteFile(const string& filename);
|
void SetPaletteFile(const string& filename);
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ private:
|
|||||||
bool IsCurrentPaletteAndFileEditable();
|
bool IsCurrentPaletteAndFileEditable();
|
||||||
bool m_PaletteFileChanged = false;
|
bool m_PaletteFileChanged = false;
|
||||||
int m_PaletteIndex = 0;
|
int m_PaletteIndex = 0;
|
||||||
map<size_t, float> m_PreviousColorIndices;
|
map<size_t, float> m_PreviousColorIndices;
|
||||||
QString m_Filename;
|
QString m_Filename;
|
||||||
string m_CurrentPaletteFilePath;
|
string m_CurrentPaletteFilePath;
|
||||||
ColorPickerWidget* m_ColorPicker = nullptr;
|
ColorPickerWidget* m_ColorPicker = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user