mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-07-01 05:46:06 -04:00
--Bug fixes
-Add missing Mac build files. -Convert PaletteList into a Singleton<T>.
This commit is contained in:
@ -397,12 +397,14 @@ static void AddPaletteToTable(QTableWidget* paletteTable, Palette<float>* palett
|
||||
/// Called upon initialization, palette combo index change, and controller type change.
|
||||
/// </summary>
|
||||
/// <param name="s">The name of the palette file without the path</param>
|
||||
/// <param name="paletteTable">The table to populate</param>
|
||||
/// <param name="paletteList">The global PaletteList shared_ptr to retrieve the specified palette file from to populate the table with</param>
|
||||
/// <returns>True if successful, else false.</returns>
|
||||
static bool FillPaletteTable(const string& s, QTableWidget* paletteTable, PaletteList<float>& paletteList)
|
||||
static bool FillPaletteTable(const string& s, QTableWidget* paletteTable, shared_ptr<PaletteList<float>> paletteList)
|
||||
{
|
||||
if (!s.empty())//This occasionally seems to get called with an empty string for reasons unknown.
|
||||
{
|
||||
if (auto palettes = paletteList.GetPaletteListByFilename(s))
|
||||
if (auto palettes = paletteList->GetPaletteListByFilename(s))
|
||||
{
|
||||
paletteTable->clear();
|
||||
paletteTable->blockSignals(true);
|
||||
|
@ -9,6 +9,7 @@
|
||||
/// </summary>
|
||||
/// <param name="fractorium">Pointer to the main window.</param>
|
||||
FractoriumEmberControllerBase::FractoriumEmberControllerBase(Fractorium* fractorium)
|
||||
: m_PaletteList(PaletteList<float>::Instance())
|
||||
{
|
||||
Timing t;
|
||||
m_Fractorium = fractorium;
|
||||
@ -46,7 +47,7 @@ FractoriumEmberController<T>::FractoriumEmberController(Fractorium* fractorium)
|
||||
m_GLController = make_unique<GLEmberController<T>>(fractorium, fractorium->ui.GLDisplay, this);
|
||||
m_LibraryPreviewRenderer = make_unique<TreePreviewRenderer<T>>(this, m_Fractorium->ui.LibraryTree, m_EmberFile);
|
||||
m_SequencePreviewRenderer = make_unique<TreePreviewRenderer<T>>(this, m_Fractorium->ui.SequenceTree, m_SequenceFile);
|
||||
m_PaletteList.Clear();
|
||||
m_PaletteList->Clear();
|
||||
m_Fractorium->ui.PaletteFilenameCombo->clear();
|
||||
//Initial combo change event to fill the palette table will be called automatically later.
|
||||
//Look hard for a palette.
|
||||
@ -57,7 +58,7 @@ FractoriumEmberController<T>::FractoriumEmberController(Fractorium* fractorium)
|
||||
|
||||
if (b)
|
||||
{
|
||||
m_SheepTools = make_unique<SheepTools<T, float>>(m_PaletteList.Name(0), new EmberNs::Renderer<T, float>());
|
||||
m_SheepTools = make_unique<SheepTools<T, float>>(m_PaletteList->Name(0), new EmberNs::Renderer<T, float>());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -71,8 +72,8 @@ FractoriumEmberController<T>::FractoriumEmberController(Fractorium* fractorium)
|
||||
throw ex;
|
||||
}
|
||||
|
||||
if (m_PaletteList.Size() >= 1)//Only add the user palette if the folder already had a palette, which means we'll be using this folder.
|
||||
if (m_PaletteList.AddEmptyPaletteFile((GetDefaultUserPath() + "/user-palettes.xml").toStdString()))
|
||||
if (m_PaletteList->Size() >= 1)//Only add the user palette if the folder already had a palette, which means we'll be using this folder.
|
||||
if (m_PaletteList->AddEmptyPaletteFile((GetDefaultUserPath() + "/user-palettes.xml").toStdString()))
|
||||
m_Fractorium->ui.PaletteFilenameCombo->addItem("user-palettes.xml");
|
||||
|
||||
BackgroundChanged(QColor(0, 0, 0));//Default to black.
|
||||
@ -327,23 +328,13 @@ void FractoriumEmberController<T>::SetEmberPrivate(const Ember<U>& ember, bool v
|
||||
}
|
||||
|
||||
static EmberToXml<T> writer;//Save parameters of last full render just in case there is a crash.
|
||||
#ifdef _WIN32
|
||||
string filename = "last.flame";
|
||||
#elif defined(__APPLE__)
|
||||
QDir dir(QDir::applicationDirPath());
|
||||
auto path = GetDefaultUserPath();
|
||||
QDir dir(path);
|
||||
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
|
||||
string filename = QDir::applicationDirPath().toStdString() + "/last.flame";
|
||||
#else
|
||||
QDir dir(QDir::homePath() + "/.config/fractorium");
|
||||
|
||||
if (!dir.exists())
|
||||
dir.mkpath(".");
|
||||
|
||||
string filename = QDir::homePath().toStdString() + "/.config/fractorium/last.flame";
|
||||
#endif
|
||||
string filename = path.toStdString() + "/last.flame";
|
||||
writer.Save(filename.c_str(), m_Ember, 0, true, true, false, true, true);
|
||||
m_GLController->ResetMouseState();
|
||||
FillXforms();//Must do this first because the palette setup in FillParamTablesAndPalette() uses the xforms combo.
|
||||
|
@ -294,9 +294,9 @@ protected:
|
||||
QTIsaac<ISAAC_SIZE, ISAAC_INT> m_Rand;
|
||||
Fractorium* m_Fractorium;
|
||||
Palette<float> m_TempPalette;
|
||||
PaletteList<float> m_PaletteList;
|
||||
std::unique_ptr<QTimer> m_RenderTimer;
|
||||
std::unique_ptr<QTimer> m_RenderRestartTimer;
|
||||
shared_ptr<PaletteList<float>> m_PaletteList;
|
||||
shared_ptr<OpenCLInfo> m_Info = OpenCLInfo::Instance();
|
||||
};
|
||||
|
||||
|
@ -98,7 +98,7 @@ void FractoriumEmberController<T>::NewEmptyFlameInCurrentFile()
|
||||
xform.m_Weight = T(0.25);
|
||||
xform.m_ColorX = m_Rand.Frand01<T>();
|
||||
ember.AddXform(xform);
|
||||
ember.m_Palette = *m_PaletteList.GetRandomPalette();
|
||||
ember.m_Palette = *m_PaletteList->GetRandomPalette();
|
||||
ember.m_Name = EmberFile<T>::DefaultEmberName(m_EmberFile.Size() + 1).toStdString();
|
||||
ember.m_Index = m_EmberFile.Size();
|
||||
m_EmberFile.m_Embers.push_back(ember);//Will invalidate the pointers contained in the EmberTreeWidgetItems, UpdateLibraryTree() will resync.
|
||||
|
@ -66,7 +66,7 @@ size_t FractoriumEmberController<T>::InitPaletteList(const QString& s)
|
||||
|
||||
try
|
||||
{
|
||||
if (QFile::exists(path) && m_PaletteList.Add(path.toStdString()))
|
||||
if (QFile::exists(path) && m_PaletteList->Add(path.toStdString()))
|
||||
m_Fractorium->ui.PaletteFilenameCombo->addItem(qfilename);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
@ -79,7 +79,7 @@ size_t FractoriumEmberController<T>::InitPaletteList(const QString& s)
|
||||
}
|
||||
}
|
||||
|
||||
return m_PaletteList.Size();
|
||||
return m_PaletteList->Size();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -103,10 +103,10 @@ bool FractoriumEmberController<T>::FillPaletteTable(const string& s)
|
||||
}
|
||||
else
|
||||
{
|
||||
vector<string> errors = m_PaletteList.ErrorReport();
|
||||
vector<string> errors = m_PaletteList->ErrorReport();
|
||||
m_Fractorium->ErrorReportToQTextEdit(errors, m_Fractorium->ui.InfoFileOpeningTextEdit);
|
||||
m_Fractorium->ShowCritical("Palette Read Error", "Could not load palette file, all images will be black. See info tab for details.");
|
||||
m_PaletteList.ClearErrorReport();
|
||||
m_PaletteList->ClearErrorReport();
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ void Fractorium::OnPaletteFilenameComboChanged(const QString& text)
|
||||
{
|
||||
auto s = text.toStdString();
|
||||
m_Controller->FillPaletteTable(s);
|
||||
auto fullname = m_Controller->m_PaletteList.GetFullPathFromFilename(s);
|
||||
auto fullname = m_Controller->m_PaletteList->GetFullPathFromFilename(s);
|
||||
ui.PaletteFilenameCombo->setToolTip(QString::fromStdString(fullname));
|
||||
ui.PaletteListTable->sortItems(0, m_PaletteSortMode == 0 ? Qt::AscendingOrder : Qt::DescendingOrder);
|
||||
}
|
||||
@ -222,7 +222,7 @@ void FractoriumEmberController<T>::SetBasePaletteAndAdjust(const Palette<float>&
|
||||
template <typename T>
|
||||
void FractoriumEmberController<T>::PaletteCellClicked(int row, int col)
|
||||
{
|
||||
if (auto palette = m_PaletteList.GetPaletteByFilename(m_CurrentPaletteFilePath, row))
|
||||
if (auto palette = m_PaletteList->GetPaletteByFilename(m_CurrentPaletteFilePath, row))
|
||||
SetBasePaletteAndAdjust(*palette);
|
||||
}
|
||||
|
||||
@ -332,14 +332,14 @@ void FractoriumEmberController<T>::PaletteEditorButtonClicked()
|
||||
}
|
||||
|
||||
//If the palette was modifiable, and any palette was changed at least once
|
||||
if (m_Fractorium->m_PaletteFileChanged && m_PaletteList.IsModifiable(m_CurrentPaletteFilePath))
|
||||
if (m_Fractorium->m_PaletteFileChanged && m_PaletteList->IsModifiable(m_CurrentPaletteFilePath))
|
||||
{
|
||||
if (!::FillPaletteTable(m_CurrentPaletteFilePath, m_Fractorium->ui.PaletteListTable, m_PaletteList))
|
||||
{
|
||||
vector<string> errors = m_PaletteList.ErrorReport();
|
||||
vector<string> errors = m_PaletteList->ErrorReport();
|
||||
m_Fractorium->ErrorReportToQTextEdit(errors, m_Fractorium->ui.InfoFileOpeningTextEdit);
|
||||
m_Fractorium->ShowCritical("Palette Read Error", "Could not re-load modified palette file, all images will be black. See info tab for details.");
|
||||
m_PaletteList.ClearErrorReport();
|
||||
m_PaletteList->ClearErrorReport();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -362,7 +362,7 @@ void Fractorium::OnPaletteEditorButtonClicked(bool checked)
|
||||
{
|
||||
if (!m_PaletteEditor)
|
||||
{
|
||||
m_PaletteEditor = new PaletteEditor(m_Controller->m_PaletteList, 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);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ int main(int argc, char* argv[])
|
||||
#endif
|
||||
auto vf = VarFuncs<float>::Instance();//Create instances that will stay alive until the program exits.
|
||||
auto vlf = VariationList<float>::Instance();
|
||||
auto palf = PaletteList<float>::Instance();
|
||||
auto settings = FractoriumSettings::Instance();
|
||||
#ifdef DO_DOUBLE
|
||||
auto vd = VarFuncs<float>::Instance();
|
||||
|
@ -10,10 +10,10 @@
|
||||
/// </summary>
|
||||
/// <param name="paletteList">A reference to an existing palette list, gotten from the main window.</param>
|
||||
/// <param name="p">The parent widget</param>
|
||||
PaletteEditor::PaletteEditor(PaletteList<float>& paletteList, QWidget* p) :
|
||||
PaletteEditor::PaletteEditor(QWidget* p) :
|
||||
QDialog(p),
|
||||
ui(make_unique<Ui::PaletteEditor>()),
|
||||
m_PaletteList(paletteList)
|
||||
m_PaletteList(PaletteList<float>::Instance())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_ColorPicker = new ColorPickerWidget(this);
|
||||
@ -51,11 +51,11 @@ PaletteEditor::PaletteEditor(PaletteList<float>& paletteList, QWidget* p) :
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(m_GradientColorView);
|
||||
ui->ColorViewGroupBox->setLayout(layout);
|
||||
auto& pals = m_PaletteList.Palettes();
|
||||
auto& pals = m_PaletteList->Palettes();
|
||||
|
||||
for (auto& pal : pals)
|
||||
{
|
||||
if (m_PaletteList.IsModifiable(pal.first))//Only add user created palettes.
|
||||
if (m_PaletteList->IsModifiable(pal.first))//Only add user created palettes.
|
||||
{
|
||||
QFileInfo info(QString::fromStdString(pal.first));
|
||||
ui->PaletteFilenameCombo->addItem(info.fileName());
|
||||
@ -265,7 +265,7 @@ void PaletteEditor::OnPaletteFilenameComboChanged(const QString& text)
|
||||
auto paletteTable = ui->PaletteListTable;
|
||||
m_CurrentPaletteFilePath = text.toStdString();
|
||||
::FillPaletteTable(text.toStdString(), paletteTable, m_PaletteList);
|
||||
auto fullname = m_PaletteList.GetFullPathFromFilename(m_CurrentPaletteFilePath);
|
||||
auto fullname = m_PaletteList->GetFullPathFromFilename(m_CurrentPaletteFilePath);
|
||||
ui->PaletteFilenameCombo->setToolTip(QString::fromStdString(fullname));
|
||||
OnPaletteCellClicked(0, 1);
|
||||
}
|
||||
@ -281,7 +281,7 @@ void PaletteEditor::OnPaletteCellClicked(int row, int col)
|
||||
{
|
||||
if (col == 1)
|
||||
{
|
||||
if (auto palette = m_PaletteList.GetPaletteByFilename(m_CurrentPaletteFilePath, row))
|
||||
if (auto palette = m_PaletteList->GetPaletteByFilename(m_CurrentPaletteFilePath, row))
|
||||
{
|
||||
SetPalette(*palette);
|
||||
m_PaletteIndex = row;
|
||||
@ -299,7 +299,7 @@ void PaletteEditor::OnPaletteCellChanged(int row, int col)
|
||||
{
|
||||
if (col == 0)
|
||||
{
|
||||
if (auto palette = m_PaletteList.GetPaletteByFilename(m_CurrentPaletteFilePath, row))
|
||||
if (auto palette = m_PaletteList->GetPaletteByFilename(m_CurrentPaletteFilePath, row))
|
||||
{
|
||||
palette->m_Name = ui->PaletteListTable->item(row, col)->text().toStdString();
|
||||
emit PaletteFileChanged();
|
||||
@ -316,7 +316,7 @@ void PaletteEditor::OnNewPaletteFileButtonClicked()
|
||||
{
|
||||
auto filename = EmberFile<float>::UniqueFilename(GetDefaultUserPath() + "/user-palettes.xml");
|
||||
|
||||
if (m_PaletteList.AddEmptyPaletteFile(filename.toStdString()))
|
||||
if (m_PaletteList->AddEmptyPaletteFile(filename.toStdString()))
|
||||
{
|
||||
QFileInfo info(filename);
|
||||
ui->PaletteFilenameCombo->addItem(info.fileName());
|
||||
@ -331,17 +331,17 @@ void PaletteEditor::OnNewPaletteFileButtonClicked()
|
||||
/// </summary>
|
||||
void PaletteEditor::OnCopyPaletteFileButtonClicked()
|
||||
{
|
||||
auto& paletteFiles = m_PaletteList.Palettes();
|
||||
auto& paletteFiles = m_PaletteList->Palettes();
|
||||
auto qscurr = QString::fromStdString(m_CurrentPaletteFilePath);
|
||||
auto qfilename = EmberFile<float>::UniqueFilename(GetDefaultUserPath() + "/" + qscurr);
|
||||
auto filename = qfilename.toStdString();
|
||||
|
||||
if (m_PaletteList.GetPaletteListByFullPath(filename) == nullptr)//Ensure the new filename does not exist in the map.
|
||||
if (m_PaletteList->GetPaletteListByFullPath(filename) == nullptr)//Ensure the new filename does not exist in the map.
|
||||
{
|
||||
//Get the list of palettes for the current filename, this will be added as a copy below.
|
||||
if (auto currentPaletteFile = m_PaletteList.GetPaletteListByFilename(m_CurrentPaletteFilePath))//Ensure the list of palettes was properly retrieved.
|
||||
if (auto currentPaletteFile = m_PaletteList->GetPaletteListByFilename(m_CurrentPaletteFilePath))//Ensure the list of palettes was properly retrieved.
|
||||
{
|
||||
if (m_PaletteList.AddPaletteFile(filename, *currentPaletteFile))//Add the current vector of palettes to an entry with the new filename.
|
||||
if (m_PaletteList->AddPaletteFile(filename, *currentPaletteFile))//Add the current vector of palettes to an entry with the new filename.
|
||||
{
|
||||
QFileInfo info(qfilename);
|
||||
ui->PaletteFilenameCombo->addItem(info.fileName());
|
||||
@ -364,7 +364,7 @@ void PaletteEditor::OnCopyPaletteFileButtonClicked()
|
||||
void PaletteEditor::OnAppendPaletteButtonClicked()
|
||||
{
|
||||
auto& pal = m_GradientColorView->GetPalette(256);
|
||||
m_PaletteList.AddPaletteToFile(m_CurrentPaletteFilePath, pal);
|
||||
m_PaletteList->AddPaletteToFile(m_CurrentPaletteFilePath, pal);
|
||||
::FillPaletteTable(m_CurrentPaletteFilePath, ui->PaletteListTable, m_PaletteList);
|
||||
m_PaletteIndex = ui->PaletteListTable->rowCount() - 1;
|
||||
emit PaletteFileChanged();
|
||||
@ -377,7 +377,7 @@ void PaletteEditor::OnAppendPaletteButtonClicked()
|
||||
void PaletteEditor::OnOverwritePaletteButtonClicked()
|
||||
{
|
||||
auto& pal = m_GradientColorView->GetPalette(256);
|
||||
m_PaletteList.Replace(m_CurrentPaletteFilePath, pal, m_PaletteIndex);
|
||||
m_PaletteList->Replace(m_CurrentPaletteFilePath, pal, m_PaletteIndex);
|
||||
::FillPaletteTable(m_CurrentPaletteFilePath, ui->PaletteListTable, m_PaletteList);
|
||||
emit PaletteFileChanged();
|
||||
}
|
||||
@ -393,7 +393,7 @@ void PaletteEditor::OnDeletePaletteButtonClicked()
|
||||
|
||||
if (table->rowCount() > 1)
|
||||
{
|
||||
m_PaletteList.Delete(m_CurrentPaletteFilePath, m_PaletteIndex);
|
||||
m_PaletteList->Delete(m_CurrentPaletteFilePath, m_PaletteIndex);
|
||||
::FillPaletteTable(m_CurrentPaletteFilePath, table, m_PaletteList);
|
||||
emit PaletteFileChanged();
|
||||
OnPaletteCellClicked(0, table->rowCount() - 1);
|
||||
|
@ -26,7 +26,7 @@ class PaletteEditor : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PaletteEditor(PaletteList<float>& paletteList, QWidget* p = nullptr);
|
||||
explicit PaletteEditor(QWidget* p = nullptr);
|
||||
|
||||
public:
|
||||
bool Sync();
|
||||
@ -73,6 +73,6 @@ private:
|
||||
ColorPickerWidget* m_ColorPicker = nullptr;
|
||||
GradientColorsView* m_GradientColorView = nullptr;
|
||||
QFileDialog* m_FileDialog = nullptr;
|
||||
PaletteList<float>& m_PaletteList;
|
||||
shared_ptr<PaletteList<float>> m_PaletteList;
|
||||
std::unique_ptr<Ui::PaletteEditor> ui;
|
||||
};
|
||||
|
Reference in New Issue
Block a user