From 29c084a058b2dc2bac994a4c833ffeb7376e2c04 Mon Sep 17 00:00:00 2001 From: Person Date: Sun, 26 Feb 2017 09:34:43 -0800 Subject: [PATCH] --Bug fixes -Add missing Mac build files. -Convert PaletteList into a Singleton. --- .../QtCreator/EmberAnimate/EmberAnimate.pro | 5 +- Builds/QtCreator/EmberGenome/EmberGenome.pro | 5 +- Builds/QtCreator/EmberRender/EmberRender.pro | 5 +- Builds/QtCreator/Fractorium/Fractorium.pro | 5 +- Source/Ember/Ember.cpp | 2 - Source/Ember/PaletteList.cpp | 1 - Source/Ember/PaletteList.h | 12 ++-- Source/Ember/SheepTools.h | 23 ++++---- Source/Ember/XmlToEmber.cpp | 7 ++- Source/Ember/XmlToEmber.h | 2 +- Source/EmberAnimate/EmberAnimate.cpp | 3 +- Source/EmberCommon/EmberCommon.h | 8 +-- Source/EmberGenome/EmberGenome.cpp | 7 ++- Source/EmberRender/EmberRender.cpp | 3 +- Source/EmberTester/EmberTester.cpp | 18 +++--- Source/Fractorium/FractoriumCommon.h | 6 +- .../Fractorium/FractoriumEmberController.cpp | 25 +++------ Source/Fractorium/FractoriumEmberController.h | 2 +- Source/Fractorium/FractoriumMenus.cpp | 2 +- Source/Fractorium/FractoriumPalette.cpp | 20 +++---- Source/Fractorium/Main.cpp | 1 + .../PaletteEditor/PaletteEditor.cpp | 30 +++++----- .../Fractorium/PaletteEditor/PaletteEditor.h | 4 +- archive/Info.plist | 24 ++++++++ archive/build.sh | 55 +++++++++++++++++++ 25 files changed, 178 insertions(+), 97 deletions(-) create mode 100644 archive/Info.plist create mode 100644 archive/build.sh diff --git a/Builds/QtCreator/EmberAnimate/EmberAnimate.pro b/Builds/QtCreator/EmberAnimate/EmberAnimate.pro index 8096171..59f7e9a 100644 --- a/Builds/QtCreator/EmberAnimate/EmberAnimate.pro +++ b/Builds/QtCreator/EmberAnimate/EmberAnimate.pro @@ -1,6 +1,9 @@ TEMPLATE = app CONFIG += console -CONFIG -= app_bundle + +# Uncomment this if you only want to build a binary instead of an app bundle. +#macx:CONFIG -= app_bundle + CONFIG -= qt TARGET = emberanimate diff --git a/Builds/QtCreator/EmberGenome/EmberGenome.pro b/Builds/QtCreator/EmberGenome/EmberGenome.pro index aa7914b..84db52e 100644 --- a/Builds/QtCreator/EmberGenome/EmberGenome.pro +++ b/Builds/QtCreator/EmberGenome/EmberGenome.pro @@ -1,6 +1,9 @@ TEMPLATE = app CONFIG += console -CONFIG -= app_bundle + +# Uncomment this if you only want to build a binary instead of an app bundle. +#macx:CONFIG -= app_bundle + CONFIG -= qt TARGET = embergenome diff --git a/Builds/QtCreator/EmberRender/EmberRender.pro b/Builds/QtCreator/EmberRender/EmberRender.pro index 9551671..d33f3a7 100644 --- a/Builds/QtCreator/EmberRender/EmberRender.pro +++ b/Builds/QtCreator/EmberRender/EmberRender.pro @@ -1,6 +1,9 @@ TEMPLATE = app CONFIG += console -CONFIG -= app_bundle + +# Uncomment this if you only want to build a binary instead of an app bundle. +#macx:CONFIG -= app_bundle + CONFIG -= qt TARGET = emberrender diff --git a/Builds/QtCreator/Fractorium/Fractorium.pro b/Builds/QtCreator/Fractorium/Fractorium.pro index ab505da..0ec4700 100644 --- a/Builds/QtCreator/Fractorium/Fractorium.pro +++ b/Builds/QtCreator/Fractorium/Fractorium.pro @@ -45,9 +45,8 @@ CONFIG(debug, debug|release) { INCLUDEPATH += $$PRJ_SRC_DIR INCLUDEPATH += $$PRJ_SRC_DIR/PaletteEditor -# TODO: Figure out how to build the app bundle correctly. -# This will build a binary instead of an app bundle. -macx:CONFIG -= app_bundle +# Uncomment this if you only want to build a binary instead of an app bundle. +#macx:CONFIG -= app_bundle target.path = $$BIN_INSTALL_DIR #message(TARGET INSTALL: $$target.path) diff --git a/Source/Ember/Ember.cpp b/Source/Ember/Ember.cpp index 33360a8..a0c9f7c 100644 --- a/Source/Ember/Ember.cpp +++ b/Source/Ember/Ember.cpp @@ -56,8 +56,6 @@ uint Timing::m_ProcessorCount; template class Post##varName##Variation; #define EXPORT_SINGLE_TYPE_EMBER(T) \ - template<> const char* PaletteList::m_DefaultFilename = "flam3-palettes.xml"; \ - template<> map>> PaletteList::s_Palettes = map>>(); \ template<> bool XmlToEmber::m_Init = false; \ template<> vector XmlToEmber::m_FlattenNames = vector(); \ template<> unordered_map XmlToEmber::m_BadParamNames = unordered_map(); \ diff --git a/Source/Ember/PaletteList.cpp b/Source/Ember/PaletteList.cpp index fc06fa8..235db0c 100644 --- a/Source/Ember/PaletteList.cpp +++ b/Source/Ember/PaletteList.cpp @@ -9,7 +9,6 @@ namespace EmberNs template PaletteList::PaletteList() { - //Add(string(m_DefaultFilename)); } /// diff --git a/Source/Ember/PaletteList.h b/Source/Ember/PaletteList.h index 224407c..23b4fc6 100644 --- a/Source/Ember/PaletteList.h +++ b/Source/Ember/PaletteList.h @@ -20,14 +20,11 @@ namespace EmberNs /// Template argument should always be float (which makes the templating of this class pointless). /// template -class EMBER_API PaletteList : public EmberReport +class EMBER_API PaletteList : public EmberReport, public Singleton> { public: - static const char* m_DefaultFilename; + const char* m_DefaultFilename = "flam3-palettes.xml"; - PaletteList(); - PaletteList(const PaletteList& paletteList) = delete; - ~PaletteList(); bool AddPaletteFile(const string& filename, const vector>& palettes); bool AddEmptyPaletteFile(const string& filename); bool AddPaletteToFile(const string& filename, const Palette& palette); @@ -52,11 +49,12 @@ public: bool IsModifiable(const string& filename); const map>>& Palettes() const; + SINGLETON_DERIVED_DECL(PaletteList); private: + PaletteList(); bool Save(const string& filename); void ParsePalettes(xmlNode* node, const shared_ptr& filename, vector>& palettes); bool ParsePalettes(const string& buf, const shared_ptr& filename, vector>& palettes); - - static map>> s_Palettes;//The map of filenames to vectors that store the palettes. + map>> s_Palettes;//The map of filenames to vectors that store the palettes. }; } diff --git a/Source/Ember/SheepTools.h b/Source/Ember/SheepTools.h index 6c69966..9ae8b6b 100644 --- a/Source/Ember/SheepTools.h +++ b/Source/Ember/SheepTools.h @@ -62,10 +62,11 @@ public: /// The full path and filename of the palette file /// A pre-constructed renderer to use. The caller should not delete this. SheepTools(const string& palettePath, Renderer* renderer) - : m_VariationList(VariationList::Instance()) + : m_VariationList(VariationList::Instance()), + m_PaletteList(PaletteList::Instance()) { Timing t; - m_PaletteList.Add(palettePath); + m_PaletteList->Add(palettePath); m_Renderer = unique_ptr>(renderer); m_Rand = QTIsaac(ISAAC_INT(t.Tic()), ISAAC_INT(t.Tic() * 2), ISAAC_INT(t.Tic() * 3)); } @@ -90,8 +91,8 @@ public: ember.AddXform(xform2); ember.AddXform(xform3); - if (m_PaletteList.Size()) - ember.m_Palette = *m_PaletteList.GetRandomPalette(); + if (m_PaletteList->Size()) + ember.m_Palette = *m_PaletteList->GetRandomPalette(); return ember; } @@ -365,8 +366,8 @@ public: } else//Randomize palette only. { - if (m_PaletteList.Size()) - ember.m_Palette = *m_PaletteList.GetRandomPalette(); + if (m_PaletteList->Size()) + ember.m_Palette = *m_PaletteList->GetRandomPalette(); //If the palette retrieval fails, skip the mutation. if (ember.m_Palette.m_Index >= 0) @@ -607,8 +608,8 @@ public: }; ember.Clear(); - if (m_PaletteList.Size()) - ember.m_Palette = *m_PaletteList.GetRandomPalette(); + if (m_PaletteList->Size()) + ember.m_Palette = *m_PaletteList->GetRandomPalette(); ember.m_Time = 0; ember.m_Interp = eInterp::EMBER_INTERP_LINEAR; @@ -883,9 +884,9 @@ public: { if (changePalette) { - if (m_PaletteList.Size()) + if (m_PaletteList->Size()) { - ember.m_Palette = *m_PaletteList.GetRandomPalette(); + ember.m_Palette = *m_PaletteList->GetRandomPalette(); } else { @@ -1365,7 +1366,7 @@ private: unique_ptr> m_XaosIterator = make_unique>(); unique_ptr> m_Renderer; QTIsaac m_Rand; - PaletteList m_PaletteList; + shared_ptr> m_PaletteList; shared_ptr> m_VariationList; }; } diff --git a/Source/Ember/XmlToEmber.cpp b/Source/Ember/XmlToEmber.cpp index 514d942..791cad6 100644 --- a/Source/Ember/XmlToEmber.cpp +++ b/Source/Ember/XmlToEmber.cpp @@ -37,7 +37,8 @@ Locale::~Locale() /// template XmlToEmber::XmlToEmber() - : m_VariationList(VariationList::Instance()) + : m_VariationList(VariationList::Instance()), + m_PaletteList(PaletteList::Instance()) { Timing t; @@ -388,7 +389,7 @@ bool XmlToEmber::Parse(const char* filename, C, Alloc>& embers, bool string buf; //Ensure palette list is setup first. - if (!m_PaletteList.Size()) + if (!m_PaletteList->Size()) { AddToReport(string(loc) + " : Palette list must be initialized before parsing embers."); return false; @@ -468,7 +469,7 @@ void XmlToEmber::ScanForEmberNodes(xmlNode* curNode, char* parentFile, C::m_DefaultFilename, currentEmber.PaletteIndex())) + if (auto pal = m_PaletteList->GetPaletteByFilename(m_PaletteList->m_DefaultFilename, currentEmber.PaletteIndex())) currentEmber.m_Palette = *pal; else AddToReport(string(loc) + " : Error assigning palette with index " + std::to_string(currentEmber.PaletteIndex())); diff --git a/Source/Ember/XmlToEmber.h b/Source/Ember/XmlToEmber.h index d7d225e..7bb44a1 100644 --- a/Source/Ember/XmlToEmber.h +++ b/Source/Ember/XmlToEmber.h @@ -71,6 +71,6 @@ private: static unordered_map m_BadParamNames; static vector, vector>> m_BadVariationNames; shared_ptr> m_VariationList;//The variation list used to make copies of variations to populate the embers with. - PaletteList m_PaletteList; + shared_ptr> m_PaletteList; }; } diff --git a/Source/EmberAnimate/EmberAnimate.cpp b/Source/EmberAnimate/EmberAnimate.cpp index ab17ad1..d284320 100644 --- a/Source/EmberAnimate/EmberAnimate.cpp +++ b/Source/EmberAnimate/EmberAnimate.cpp @@ -137,7 +137,7 @@ bool EmberAnimate(EmberOptions& opt) renderers.push_back(std::move(tempRenderer)); } - if (!InitPaletteList(opt.PalettePath()))//For any modern flames, the palette isn't used. This is for legacy purposes and should be removed. + if (!InitPaletteList(opt.PalettePath()))//For any modern flames, the palette isn't used. This is for legacy purposes and should be removed. return false; cout << "Parsing ember file " << opt.Input() << "\n"; @@ -456,6 +456,7 @@ int _tmain(int argc, _TCHAR* argv[]) if (!opt.Populate(argc, argv, eOptionUse::OPT_USE_ANIMATE)) { + auto palf = PaletteList::Instance(); #ifdef DO_DOUBLE if (!opt.Sp()) diff --git a/Source/EmberCommon/EmberCommon.h b/Source/EmberCommon/EmberCommon.h index 422cbf5..9c2bb42 100644 --- a/Source/EmberCommon/EmberCommon.h +++ b/Source/EmberCommon/EmberCommon.h @@ -122,7 +122,7 @@ static bool ParseEmberFile(XmlToEmber& parser, const string& filename, vector template static bool InitPaletteList(const string& filename) { - PaletteList paletteList;//Even though this is local, the members are static so they will remain. + auto paletteList = PaletteList::Instance(); static vector paths = { "./" @@ -138,15 +138,15 @@ static bool InitPaletteList(const string& filename) for (auto& p : paths) { if (!added) - added |= paletteList.Add(p + "/" + filename); + added |= paletteList->Add(p + "/" + filename); else break; } - if (!added || !paletteList.Size()) + if (!added || !paletteList->Size()) { cout << "Error parsing palette file " << filename << ". Reason: \n" - << paletteList.ErrorReportString() << "\nReturning without executing.\n"; + << paletteList->ErrorReportString() << "\nReturning without executing.\n"; return false; } diff --git a/Source/EmberGenome/EmberGenome.cpp b/Source/EmberGenome/EmberGenome.cpp index 89a2d33..67e44b4 100644 --- a/Source/EmberGenome/EmberGenome.cpp +++ b/Source/EmberGenome/EmberGenome.cpp @@ -203,7 +203,7 @@ bool EmberGenome(EmberOptions& opt) return false; } - if (!InitPaletteList(opt.PalettePath())) + if (!InitPaletteList(opt.PalettePath())) return false; if (!opt.EmberCL()) @@ -562,7 +562,7 @@ bool EmberGenome(EmberOptions& opt) cout << emberToXml.ToString(result1, opt.Extras(), opt.PrintEditDepth(), !opt.NoEdits(), opt.HexPalette()); } - tools.Spin(embers[0], pTemplate, result2, frame , blend , opt.CwLoops()); + tools.Spin(embers[0], pTemplate, result2, frame, blend, opt.CwLoops()); tools.Spin(embers[0], pTemplate, result3, frame + 1, blend + spread, opt.CwLoops()); cout << emberToXml.ToString(result2, opt.Extras(), opt.PrintEditDepth(), !opt.NoEdits(), opt.HexPalette()); cout << emberToXml.ToString(result3, opt.Extras(), opt.PrintEditDepth(), !opt.NoEdits(), opt.HexPalette()); @@ -581,7 +581,7 @@ bool EmberGenome(EmberOptions& opt) cout << emberToXml.ToString(result1, opt.Extras(), opt.PrintEditDepth(), !opt.NoEdits(), opt.HexPalette()); } - tools.SpinInter(embers.data(), pTemplate, result2, frame , false, blend , opt.InterpLoops(), opt.CwInterpLoops()); + tools.SpinInter(embers.data(), pTemplate, result2, frame, false, blend, opt.InterpLoops(), opt.CwInterpLoops()); tools.SpinInter(embers.data(), pTemplate, result3, frame + 1, false, blend + spread, opt.InterpLoops(), opt.CwInterpLoops()); cout << emberToXml.ToString(result2, opt.Extras(), opt.PrintEditDepth(), !opt.NoEdits(), opt.HexPalette()); cout << emberToXml.ToString(result3, opt.Extras(), opt.PrintEditDepth(), !opt.NoEdits(), opt.HexPalette()); @@ -862,6 +862,7 @@ int _tmain(int argc, _TCHAR* argv[]) if (!opt.Populate(argc, argv, eOptionUse::OPT_USE_GENOME)) { + auto palf = PaletteList::Instance(); #ifdef DO_DOUBLE if (!opt.Sp()) diff --git a/Source/EmberRender/EmberRender.cpp b/Source/EmberRender/EmberRender.cpp index 3e5e618..46be16d 100644 --- a/Source/EmberRender/EmberRender.cpp +++ b/Source/EmberRender/EmberRender.cpp @@ -63,7 +63,7 @@ bool EmberRender(EmberOptions& opt) if (opt.EmberCL() && renderer->RendererType() != eRendererType::OPENCL_RENDERER)//OpenCL init failed, so fall back to CPU. opt.EmberCL(false); - if (!InitPaletteList(opt.PalettePath()))//For any modern flames, the palette isn't used. This is for legacy purposes and should be removed. + if (!InitPaletteList(opt.PalettePath()))//For any modern flames, the palette isn't used. This is for legacy purposes and should be removed. return false; if (!ParseEmberFile(parser, opt.Input(), embers)) @@ -349,6 +349,7 @@ int _tmain(int argc, _TCHAR* argv[]) if (!opt.Populate(argc, argv, eOptionUse::OPT_USE_RENDER)) { + auto palf = PaletteList::Instance(); #ifdef DO_DOUBLE if (!opt.Sp()) diff --git a/Source/EmberTester/EmberTester.cpp b/Source/EmberTester/EmberTester.cpp index 8385e8c..763031a 100644 --- a/Source/EmberTester/EmberTester.cpp +++ b/Source/EmberTester/EmberTester.cpp @@ -88,9 +88,9 @@ void MakeTestAllVarsRegPrePost(vector>& embers) uint index = 0; ostringstream ss; auto varList = VariationList::Instance(); - PaletteList paletteList; + auto paletteList = PaletteList::Instance(); QTIsaac rand; - paletteList.Add("flam3-palettes.xml"); + paletteList->Add("flam3-palettes.xml"); Timing t; Ember emberNoVars; emberNoVars.m_FinalRasW = 640; @@ -113,7 +113,7 @@ void MakeTestAllVarsRegPrePost(vector>& embers) ss << "NoVars"; emberNoVars.m_Name = ss.str(); ss.str(""); - emberNoVars.m_Palette = *paletteList.GetPaletteByFilename(paletteList.m_DefaultFilename, 0); + emberNoVars.m_Palette = *paletteList->GetPaletteByFilename(paletteList->m_DefaultFilename, 0); embers.push_back(emberNoVars); while (index < varList->RegSize()) @@ -176,7 +176,7 @@ void MakeTestAllVarsRegPrePost(vector>& embers) ss << index << "_" << regVar->Name(); ember1.m_Name = ss.str(); ss.str(""); - ember1.m_Palette = *paletteList.GetRandomPalette(); + ember1.m_Palette = *paletteList->GetRandomPalette(); index++; embers.push_back(ember1); } @@ -1078,10 +1078,10 @@ void PrintAllVars() void TestXformsInOutPoints() { uint index = 0; - auto varList(VariationList::Instance()); - PaletteList paletteList; + auto varList = VariationList::Instance(); + auto paletteList = PaletteList::Instance(); QTIsaac rand; - paletteList.Add("flam3-palettes.xml"); + paletteList->Add("flam3-palettes.xml"); while (index < varList->RegSize()) { @@ -1975,8 +1975,8 @@ int _tmain(int argc, _TCHAR* argv[]) TestThreadedKernel(); - PaletteList palf; - Palette* pal = palf.GetRandomPalette(); + auto palf = PaletteList::Instance(); + Palette* pal = palf->GetRandomPalette(); cout << pal->Size() << endl; diff --git a/Source/Fractorium/FractoriumCommon.h b/Source/Fractorium/FractoriumCommon.h index 0388fd7..6dbb8a9 100644 --- a/Source/Fractorium/FractoriumCommon.h +++ b/Source/Fractorium/FractoriumCommon.h @@ -397,12 +397,14 @@ static void AddPaletteToTable(QTableWidget* paletteTable, Palette* palett /// Called upon initialization, palette combo index change, and controller type change. /// /// The name of the palette file without the path +/// The table to populate +/// The global PaletteList shared_ptr to retrieve the specified palette file from to populate the table with /// True if successful, else false. -static bool FillPaletteTable(const string& s, QTableWidget* paletteTable, PaletteList& paletteList) +static bool FillPaletteTable(const string& s, QTableWidget* paletteTable, shared_ptr> 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); diff --git a/Source/Fractorium/FractoriumEmberController.cpp b/Source/Fractorium/FractoriumEmberController.cpp index a84bae1..8b6db66 100644 --- a/Source/Fractorium/FractoriumEmberController.cpp +++ b/Source/Fractorium/FractoriumEmberController.cpp @@ -9,6 +9,7 @@ /// /// Pointer to the main window. FractoriumEmberControllerBase::FractoriumEmberControllerBase(Fractorium* fractorium) + : m_PaletteList(PaletteList::Instance()) { Timing t; m_Fractorium = fractorium; @@ -46,7 +47,7 @@ FractoriumEmberController::FractoriumEmberController(Fractorium* fractorium) m_GLController = make_unique>(fractorium, fractorium->ui.GLDisplay, this); m_LibraryPreviewRenderer = make_unique>(this, m_Fractorium->ui.LibraryTree, m_EmberFile); m_SequencePreviewRenderer = make_unique>(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::FractoriumEmberController(Fractorium* fractorium) if (b) { - m_SheepTools = make_unique>(m_PaletteList.Name(0), new EmberNs::Renderer()); + m_SheepTools = make_unique>(m_PaletteList->Name(0), new EmberNs::Renderer()); } else { @@ -71,8 +72,8 @@ FractoriumEmberController::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::SetEmberPrivate(const Ember& ember, bool v } static EmberToXml 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. diff --git a/Source/Fractorium/FractoriumEmberController.h b/Source/Fractorium/FractoriumEmberController.h index e828906..aefaf72 100644 --- a/Source/Fractorium/FractoriumEmberController.h +++ b/Source/Fractorium/FractoriumEmberController.h @@ -294,9 +294,9 @@ protected: QTIsaac m_Rand; Fractorium* m_Fractorium; Palette m_TempPalette; - PaletteList m_PaletteList; std::unique_ptr m_RenderTimer; std::unique_ptr m_RenderRestartTimer; + shared_ptr> m_PaletteList; shared_ptr m_Info = OpenCLInfo::Instance(); }; diff --git a/Source/Fractorium/FractoriumMenus.cpp b/Source/Fractorium/FractoriumMenus.cpp index 2272ff3..1504a4e 100644 --- a/Source/Fractorium/FractoriumMenus.cpp +++ b/Source/Fractorium/FractoriumMenus.cpp @@ -98,7 +98,7 @@ void FractoriumEmberController::NewEmptyFlameInCurrentFile() xform.m_Weight = T(0.25); xform.m_ColorX = m_Rand.Frand01(); ember.AddXform(xform); - ember.m_Palette = *m_PaletteList.GetRandomPalette(); + ember.m_Palette = *m_PaletteList->GetRandomPalette(); ember.m_Name = EmberFile::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. diff --git a/Source/Fractorium/FractoriumPalette.cpp b/Source/Fractorium/FractoriumPalette.cpp index d149aaa..626ab3d 100644 --- a/Source/Fractorium/FractoriumPalette.cpp +++ b/Source/Fractorium/FractoriumPalette.cpp @@ -66,7 +66,7 @@ size_t FractoriumEmberController::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::InitPaletteList(const QString& s) } } - return m_PaletteList.Size(); + return m_PaletteList->Size(); } /// @@ -103,10 +103,10 @@ bool FractoriumEmberController::FillPaletteTable(const string& s) } else { - vector errors = m_PaletteList.ErrorReport(); + vector 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::SetBasePaletteAndAdjust(const Palette& template void FractoriumEmberController::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::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 errors = m_PaletteList.ErrorReport(); + vector 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); } diff --git a/Source/Fractorium/Main.cpp b/Source/Fractorium/Main.cpp index 326ea03..73cbd5c 100644 --- a/Source/Fractorium/Main.cpp +++ b/Source/Fractorium/Main.cpp @@ -22,6 +22,7 @@ int main(int argc, char* argv[]) #endif auto vf = VarFuncs::Instance();//Create instances that will stay alive until the program exits. auto vlf = VariationList::Instance(); + auto palf = PaletteList::Instance(); auto settings = FractoriumSettings::Instance(); #ifdef DO_DOUBLE auto vd = VarFuncs::Instance(); diff --git a/Source/Fractorium/PaletteEditor/PaletteEditor.cpp b/Source/Fractorium/PaletteEditor/PaletteEditor.cpp index 7845d67..b27e516 100644 --- a/Source/Fractorium/PaletteEditor/PaletteEditor.cpp +++ b/Source/Fractorium/PaletteEditor/PaletteEditor.cpp @@ -10,10 +10,10 @@ /// /// A reference to an existing palette list, gotten from the main window. /// The parent widget -PaletteEditor::PaletteEditor(PaletteList& paletteList, QWidget* p) : +PaletteEditor::PaletteEditor(QWidget* p) : QDialog(p), ui(make_unique()), - m_PaletteList(paletteList) + m_PaletteList(PaletteList::Instance()) { ui->setupUi(this); m_ColorPicker = new ColorPickerWidget(this); @@ -51,11 +51,11 @@ PaletteEditor::PaletteEditor(PaletteList& 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::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() /// void PaletteEditor::OnCopyPaletteFileButtonClicked() { - auto& paletteFiles = m_PaletteList.Palettes(); + auto& paletteFiles = m_PaletteList->Palettes(); auto qscurr = QString::fromStdString(m_CurrentPaletteFilePath); auto qfilename = EmberFile::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); diff --git a/Source/Fractorium/PaletteEditor/PaletteEditor.h b/Source/Fractorium/PaletteEditor/PaletteEditor.h index 206f789..da0fb23 100644 --- a/Source/Fractorium/PaletteEditor/PaletteEditor.h +++ b/Source/Fractorium/PaletteEditor/PaletteEditor.h @@ -26,7 +26,7 @@ class PaletteEditor : public QDialog Q_OBJECT public: - explicit PaletteEditor(PaletteList& 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& m_PaletteList; + shared_ptr> m_PaletteList; std::unique_ptr ui; }; diff --git a/archive/Info.plist b/archive/Info.plist new file mode 100644 index 0000000..efcf933 --- /dev/null +++ b/archive/Info.plist @@ -0,0 +1,24 @@ + + + + + NSPrincipalClass + NSApplication + CFBundleIconFile + Fractorium.icns + CFBundlePackageType + APPL + CFBundleName + Fractorium + CFBundleGetInfoString + Created by Qt/QMake + CFBundleSignature + ???? + CFBundleExecutable + fractorium + CFBundleIdentifier + com.yourcompany.fractorium + NOTE + This file was generated by Qt/QMake. + + diff --git a/archive/build.sh b/archive/build.sh new file mode 100644 index 0000000..a037960 --- /dev/null +++ b/archive/build.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +OSX_BUILD_PATH=$PWD +FRACTORIUM_RELEASE_ROOT=$PWD/../Bin/release +QT_MACDEPLOY=/Users/mastriani/Qt/5.4/clang_64/bin/macdeployqt + + +cd $FRACTORIUM_RELEASE_ROOT + +EMBERANIMATE_FINAL_ROOT=$PWD/emberanimate.app/Contents/MacOS +EMBERGENOME_FINAL_ROOT=$PWD/embergenome.app/Contents/MacOS +EMBERRENDER_FINAL_ROOT=$PWD/emberrender.app/Contents/MacOS +FRACTORIUM_FINAL_ROOT=$PWD/fractorium.app/Contents/MacOS + +install_name_tool -id $PWD/libember.dylib libember.dylib +install_name_tool -id $PWD/libembercl.dylib libembercl.dylib +install_name_tool -change libember.dylib $PWD/libember.dylib libembercl.dylib + +install_name_tool -change libember.dylib $PWD/libember.dylib $EMBERANIMATE_FINAL_ROOT/emberanimate +install_name_tool -change libembercl.dylib $PWD/libembercl.dylib $EMBERANIMATE_FINAL_ROOT/emberanimate + +install_name_tool -change libember.dylib $PWD/libember.dylib $EMBERGENOME_FINAL_ROOT/embergenome +install_name_tool -change libembercl.dylib $PWD/libembercl.dylib $EMBERGENOME_FINAL_ROOT/embergenome + +install_name_tool -change libember.dylib $PWD/libember.dylib $EMBERRENDER_FINAL_ROOT/emberrender +install_name_tool -change libembercl.dylib $PWD/libembercl.dylib $EMBERRENDER_FINAL_ROOT/emberrender + +install_name_tool -change libember.dylib $PWD/libember.dylib $FRACTORIUM_FINAL_ROOT/fractorium +install_name_tool -change libembercl.dylib $PWD/libembercl.dylib $FRACTORIUM_FINAL_ROOT/fractorium + +$QT_MACDEPLOY emberanimate.app +$QT_MACDEPLOY embergenome.app +$QT_MACDEPLOY emberrender.app +$QT_MACDEPLOY fractorium.app + +cp ./emberanimate.app/Contents/MacOS/emberanimate $FRACTORIUM_FINAL_ROOT +cp ./embergenome.app/Contents/MacOS/embergenome $FRACTORIUM_FINAL_ROOT +cp ./emberrender.app/Contents/MacOS/emberrender $FRACTORIUM_FINAL_ROOT + +cd $OSX_BUILD_PATH + +#python macdeployqtfix.py $FRACTORIUM_FINAL_ROOT/fractorium /Users/mastriani/Qt/5.4/ + +cd ../Data + +cp dark.qss $FRACTORIUM_FINAL_ROOT +cp flam3-palettes.xml $FRACTORIUM_FINAL_ROOT +cp Info.plist $FRACTORIUM_FINAL_ROOT/../ +#cp fractoriumcaller $FRACTORIUM_FINAL_ROOT + +cd $FRACTORIUM_RELEASE_ROOT + +mv fractorium.app Fractorium.app + +hdiutil create -format UDBZ -quiet -srcfolder Fractorium.app Fractorium.dmg