]> git.tdb.fi Git - r2c2.git/blobdiff - source/engineer/traindialog.cpp
Persist most dialogs across runs
[r2c2.git] / source / engineer / traindialog.cpp
index 6aa469a37bc7edc85403c694c2b321f9c2e51186..985d4c94ea09eca8bb358e516c19b5641b58619e 100644 (file)
@@ -9,6 +9,7 @@
 #include "libr2c2/layout.h"
 #include "libr2c2/trainstatus.h"
 #include "controlpanel.h"
+#include "engineer.h"
 #include "routerpanel.h"
 #include "timetablepanel.h"
 #include "traindialog.h"
@@ -19,6 +20,7 @@ using namespace Msp;
 using namespace R2C2;
 
 TrainDialog::TrainDialog(Engineer &e, R2C2::Train &t):
+       DynamicDialog(e.get_user_interface()),
        engineer(e),
        train(t),
        updating(false)
@@ -149,3 +151,25 @@ void TrainDialog::toggle_panel(bool show, GLtk::Panel *panel)
 {
        panel->set_visible(show);
 }
+
+bool TrainDialog::save_state(DataFile::Statement &st) const
+{
+       st.keyword = "traindialog";
+       st.append(train.get_address());
+       st.sub.push_back((DataFile::Statement("expanded"), pnl_expander->is_visible()));
+       save_position(st.sub);
+
+       return true;
+}
+
+
+TrainDialog::StateLoader::StateLoader(TrainDialog &td):
+       DataFile::DerivedObjectLoader<TrainDialog, DynamicDialog::StateLoader>(td)
+{
+       add("expanded", &StateLoader::expanded);
+}
+
+void TrainDialog::StateLoader::expanded(bool e)
+{
+       obj.set_expanded(e);
+}