commit face94a5f48e60dac00921054d4de3b0068c2dd7
parent c1de322b02be4612a6640b5e838fba03579432c2
Author: Christopher A. Oliver <[email protected]>
Date: Sun, 11 Oct 2015 23:29:39 -0400
Provide for reverting to the last loaded XMZ. Also sets the window title.
Diffstat:
5 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/src/Misc/Master.cpp b/src/Misc/Master.cpp
@@ -103,6 +103,7 @@ static const Ports sysefsendto =
};
static const Ports master_ports = {
+ rString(last_xmz, XMZ_PATH_MAX, "File name for last name loaded if any."),
rRecursp(part, 16, "Part"),//NUM_MIDI_PARTS
rRecursp(sysefx, 4, "System Effect"),//NUM_SYS_EFX
rRecursp(insefx, 8, "Insertion Effect"),//NUM_INS_EFX
@@ -306,6 +307,7 @@ Master::Master(const SYNTH_T &synth_, Config* config)
the_master = this;
#endif
+ last_xmz[0] = 0;
fft = new FFTwrapper(synth.oscilsize);
shutup = 0;
@@ -1056,7 +1058,6 @@ int Master::saveXML(const char *filename)
}
-
int Master::loadXML(const char *filename)
{
XMLwrapper *xml = new XMLwrapper();
diff --git a/src/Misc/Master.h b/src/Misc/Master.h
@@ -54,6 +54,8 @@ class Master
/** Destructor*/
~Master();
+ char last_xmz[XMZ_PATH_MAX];
+
void applyOscEvent(const char *event);
/**Saves all settings to a XML file
@@ -65,7 +67,6 @@ class Master
void defaults();
-
/**loads all settings from a XML file
* @return 0 for ok or -1 if there is an error*/
int loadXML(const char *filename);
diff --git a/src/UI/MasterUI.fl b/src/UI/MasterUI.fl
@@ -61,6 +61,9 @@ decl {\#include "VuPartMeter.h"} {public local
decl {\#include "Fl_Osc_Dial.H"} {private local
}
+decl {\#include "Osc_DataModel.h"} {private local
+}
+
decl {\#include "VuMasterMeter.h"} {public local
}
@@ -265,6 +268,11 @@ class MasterUI {open
xywh {25 25 100 20}
}
MenuItem {} {
+ label {&Revert changes...}
+ callback {do_revert_changes();}
+ xywh {25 25 100 20}
+ }
+ MenuItem {} {
label {&Open Parameters...}
callback {\#if USE_NSM
if ( nsm && nsm->is_active() )
@@ -943,6 +951,11 @@ if (fl_choice("Exit and leave the unsaved data?","No","Yes",NULL))
xywh {30 30 100 20}
}
MenuItem {} {
+ label {&Revert changes...}
+ callback {do_revert_changes();}
+ xywh {30 30 100 20}
+ }
+ MenuItem {} {
label {&Open Parameters...}
callback {do_load_master();}
xywh {30 30 100 20}
@@ -1493,6 +1506,15 @@ osc=osc_;
ninseff=0;
nsyseff=0;
npart=0;
+last_xmz = new Osc_DataModel(osc);
+last_xmz->callback = [this](std::string filestr) {
+ strncpy(last_loaded, filestr.c_str(), XMZ_PATH_MAX);
+ char *label = last_loaded[0] == 0 ? NULL
+ : ((label = strrchr(last_loaded, '/'))) ? label+1
+ : last_loaded;
+ setfilelabel(label);
+};
+last_xmz->doUpdate("/last_xmz");
for (int i=0;i<NUM_SYS_EFX;i++)
for (int j=0;j<NUM_SYS_EFX;j++)
@@ -1560,6 +1582,7 @@ simplelistitemgroup->redraw();} {}
microtonalui=new MicrotonalUI(osc, "/microtonal/");
osc->write("/reset_master");
+ osc->write("/last_xmz", "s", "");
npartcounter->value(1);
refresh_master_ui();
updatepanel();} {}
@@ -1569,9 +1592,26 @@ microtonalui=new MicrotonalUI(osc, "/microtonal/");
do_new_master_unconditional();
}} {}
}
+ Function {do_revert_changes_unconditional()} {return_type int
+ } {
+ code {osc->write("/load_xmz", "s", last_loaded);
+ refresh_master_ui();
+ updatepanel();
+
+return 1;} {}
+ }
+ Function {do_revert_changes()} {} {
+ code {if (last_loaded[0] == 0)
+ do_new_master();
+ else
+ if (fl_choice("Revert *ALL* the parameters ?","No","Yes",NULL)){
+ do_revert_changes_unconditional();
+ }} {}
+ }
Function {do_load_master_unconditional(const char *filename, const char *display_name)} {return_type int
} {
code {osc->write("/load_xmz", "s", filename);
+ osc->write("/last_xmz", "s", filename);
refresh_master_ui();
updatepanel();
@@ -1653,6 +1693,8 @@ simpleinseffnocounter->do_callback();
simplerefresh();
bankui->hide();} {}
}
+ decl {class Osc_DataModel *last_xmz;} {public local
+ }
decl {MicrotonalUI *microtonalui;} {private local
}
decl {BankUI *bankui;} {private local
@@ -1679,6 +1721,8 @@ bankui->hide();} {}
}
decl {class Fl_Osc_Interface *osc;} {public local
}
+ decl {char last_loaded[XMZ_PATH_MAX];} {public local
+ }
Function {close()} {open return_type void
} {
code {*exitprogram=1;} {}
diff --git a/src/globals.h b/src/globals.h
@@ -145,6 +145,14 @@ typedef std::complex<fftw_real> fft_t;
#define PART_MAX_NAME_LEN 30
/*
+ * The maximum we allow for an XMZ path
+ *
+ * Note that this is an ugly hack. Finding a compile time path
+ * max portably is painful.
+ */
+#define XMZ_PATH_MAX 1024
+
+/*
* The maximum number of bands of the equaliser
*/
#define MAX_EQ_BANDS 8
diff --git a/src/main.cpp b/src/main.cpp
@@ -393,13 +393,17 @@ int main(int argc, char *argv[])
initprogram(std::move(synth), &config, prefered_port);
if(!loadfile.empty()) {
- int tmp = master->loadXML(loadfile.c_str());
+ const char *filename = loadfile.c_str();
+ int tmp = master->loadXML(filename);
if(tmp < 0) {
cerr << "ERROR: Could not load master file " << loadfile
<< "." << endl;
exit(1);
}
else {
+ strncpy(master->last_xmz, filename, XMZ_PATH_MAX);
+ if (master->last_xmz[XMZ_PATH_MAX-1] != 0)
+ master->last_xmz[0] = 0;
master->applyparameters();
cout << "Master file loaded." << endl;
}