From 28ce868a9f497e889a273305e3b1f50934bd4e4c Mon Sep 17 00:00:00 2001 From: Person Date: Tue, 21 May 2019 16:28:37 -0700 Subject: [PATCH] --Code changes -Formatting. --- Source/Fractorium/Fractorium.h | 2 +- Source/Fractorium/FractoriumEmberController.h | 6 +- Source/Fractorium/FractoriumPalette.cpp | 83 +++++++++---------- .../PaletteEditor/PaletteEditor.cpp | 4 +- .../Fractorium/PaletteEditor/PaletteEditor.h | 8 +- 5 files changed, 50 insertions(+), 53 deletions(-) diff --git a/Source/Fractorium/Fractorium.h b/Source/Fractorium/Fractorium.h index 70308d2..7589722 100644 --- a/Source/Fractorium/Fractorium.h +++ b/Source/Fractorium/Fractorium.h @@ -360,7 +360,7 @@ public slots: void OnPaletteEditorColorChanged(); void OnPaletteEditorFileChanged(); void OnPaletteEditorColorIndexChanged(size_t index, float value); - void OnPaletteEditorFinished(int result); + void OnPaletteEditorFinished(int result); //Info. void OnSummaryTableHeaderResized(int logicalIndex, int oldSize, int newSize); diff --git a/Source/Fractorium/FractoriumEmberController.h b/Source/Fractorium/FractoriumEmberController.h index 94d8fd8..d87d1bc 100644 --- a/Source/Fractorium/FractoriumEmberController.h +++ b/Source/Fractorium/FractoriumEmberController.h @@ -249,7 +249,7 @@ public: virtual void SetBasePaletteAndAdjust(const Palette& palette) { } virtual void PaletteEditorButtonClicked() { } virtual void PaletteEditorColorChanged() { } - virtual void SyncPalette(bool accepted) { } + virtual void SyncPalette(bool accepted) { } QImage& FinalPaletteImage() { return m_FinalPaletteImage; } //Info. @@ -311,7 +311,7 @@ protected: unique_ptr m_Renderer; QTIsaac m_Rand; Fractorium* m_Fractorium; - Palette m_TempPalette, m_PreviosTempPalette; + Palette m_TempPalette, m_PreviousTempPalette; std::unique_ptr m_RenderTimer; std::unique_ptr m_RenderRestartTimer; shared_ptr> m_PaletteList; @@ -538,7 +538,7 @@ public: virtual void SetBasePaletteAndAdjust(const Palette& palette) override; virtual void PaletteEditorButtonClicked() override; virtual void PaletteEditorColorChanged() override; - virtual void SyncPalette(bool accepted) override; + virtual void SyncPalette(bool accepted) override; //Info. virtual void FillSummary() override; diff --git a/Source/Fractorium/FractoriumPalette.cpp b/Source/Fractorium/FractoriumPalette.cpp index 7405026..cd332ac 100644 --- a/Source/Fractorium/FractoriumPalette.cpp +++ b/Source/Fractorium/FractoriumPalette.cpp @@ -383,25 +383,22 @@ template void FractoriumEmberController::PaletteEditorButtonClicked() { size_t i = 0; - auto ed = m_Fractorium->m_PaletteEditor; + auto ed = m_Fractorium->m_PaletteEditor; map colorIndices; - bool forceFinal = m_Fractorium->HaveFinal(); - - m_PreviosTempPalette = m_TempPalette; // it's necessary because m_TempPalette is changed when the user make changes in palette editor - - ed->SetPalette(m_TempPalette); + 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 + ed->SetPalette(m_TempPalette); while (auto xform = m_Ember.GetTotalXform(i, forceFinal)) colorIndices[i++] = xform->m_ColorX; 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); - #ifdef __linux__ - ed->show(); -#else - SyncPalette(ed->exec() == QDialog::Accepted); + ed->show(); +#else + SyncPalette(ed->exec() == QDialog::Accepted); #endif } @@ -423,12 +420,12 @@ void Fractorium::OnPaletteEditorButtonClicked(bool checked) { 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(PaletteFileChanged()), this, SLOT(OnPaletteEditorFileChanged()), Qt::QueuedConnection); connect(m_PaletteEditor, SIGNAL(ColorIndexChanged(size_t, float)), this, SLOT(OnPaletteEditorColorIndexChanged(size_t, float)), Qt::QueuedConnection); #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 } @@ -443,42 +440,42 @@ void Fractorium::OnPaletteEditorButtonClicked(bool checked) template void FractoriumEmberController::SyncPalette(bool accepted) { - size_t i = 0; - auto ed = m_Fractorium->m_PaletteEditor; - Palette edPal; - Palette prevPal = m_PreviosTempPalette; - map colorIndices; - bool forceFinal = m_Fractorium->HaveFinal(); + size_t i = 0; + auto ed = m_Fractorium->m_PaletteEditor; + Palette edPal; + Palette prevPal = m_PreviousTempPalette; + map colorIndices; + bool forceFinal = m_Fractorium->HaveFinal(); - if (accepted) - { - //Copy all just to be safe, because they may or may not have synced. - colorIndices = ed->GetColorIndices(); + if (accepted) + { + //Copy all just to be safe, because they may or may not have synced. + colorIndices = ed->GetColorIndices(); - for (auto& index : colorIndices) - if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal)) - xform->m_ColorX = index.second; + for (auto& index : colorIndices) + if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal)) + xform->m_ColorX = index.second; - edPal = ed->GetPalette(int(prevPal.Size())); - SetBasePaletteAndAdjust(edPal);//This will take care of updating the color index controls. + edPal = ed->GetPalette(int(prevPal.Size())); + 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. - { - colorIndices = ed->GetPreviousColorIndices(); + 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. + { + colorIndices = ed->GetPreviousColorIndices(); - for (auto& index : colorIndices) - if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal)) - xform->m_ColorX = index.second; + 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. - } + 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). - if (m_PaletteList->IsModifiable(m_CurrentPaletteFilePath)) - m_Fractorium->OnPaletteFilenameComboChanged(QString::fromStdString(m_CurrentPaletteFilePath)); + //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)) + m_Fractorium->OnPaletteFilenameComboChanged(QString::fromStdString(m_CurrentPaletteFilePath)); } /// @@ -528,7 +525,7 @@ void Fractorium::OnPaletteEditorColorIndexChanged(size_t index, float value) /// Cancel/OK action void Fractorium::OnPaletteEditorFinished(int result) { - m_Controller->SyncPalette(result == QDialog::Accepted); + m_Controller->SyncPalette(result == QDialog::Accepted); } /// diff --git a/Source/Fractorium/PaletteEditor/PaletteEditor.cpp b/Source/Fractorium/PaletteEditor/PaletteEditor.cpp index 63c78cb..8f72943 100644 --- a/Source/Fractorium/PaletteEditor/PaletteEditor.cpp +++ b/Source/Fractorium/PaletteEditor/PaletteEditor.cpp @@ -124,7 +124,7 @@ map PaletteEditor::GetColorIndices() const /// The color indices map PaletteEditor::GetPreviousColorIndices() const { - return m_PreviousColorIndices; + return m_PreviousColorIndices; } /// @@ -143,7 +143,7 @@ void PaletteEditor::SetColorIndices(const map& indices) /// The color indices to backup void PaletteEditor::SetPreviousColorIndices(const map& indices) { - m_PreviousColorIndices = indices; + m_PreviousColorIndices = indices; } /// diff --git a/Source/Fractorium/PaletteEditor/PaletteEditor.h b/Source/Fractorium/PaletteEditor/PaletteEditor.h index 82010e6..b0fc11f 100644 --- a/Source/Fractorium/PaletteEditor/PaletteEditor.h +++ b/Source/Fractorium/PaletteEditor/PaletteEditor.h @@ -27,16 +27,16 @@ class PaletteEditor : public QDialog Q_OBJECT public: - explicit PaletteEditor(QWidget* p = nullptr); + explicit PaletteEditor(QWidget* p = nullptr); public: bool Sync(); Palette& GetPalette(int size); void SetPalette(const Palette& palette); map GetColorIndices() const; - map GetPreviousColorIndices() const; + map GetPreviousColorIndices() const; void SetColorIndices(const map& indices); - void SetPreviousColorIndices(const map& indices); + void SetPreviousColorIndices(const map& indices); string GetPaletteFile() const; void SetPaletteFile(const string& filename); @@ -80,7 +80,7 @@ private: bool IsCurrentPaletteAndFileEditable(); bool m_PaletteFileChanged = false; int m_PaletteIndex = 0; - map m_PreviousColorIndices; + map m_PreviousColorIndices; QString m_Filename; string m_CurrentPaletteFilePath; ColorPickerWidget* m_ColorPicker = nullptr;