1 #include <msp/gl/framebuffer.h>
2 #include <msp/gltk/layout.h>
3 #include <msp/time/utils.h>
4 #include "connectdialog.h"
11 Remote::Remote(int, char **):
14 ui_resources("data/r2c2.res"),
15 root(ui_resources, window),
16 root_layout(new GLtk::Layout),
19 window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &Remote::exit), 0));
21 root.set_size(window.get_width()/2, window.get_height()/2);
22 root.set_layout(root_layout);
23 root_layout->set_margin(GLtk::Sides());
24 root_layout->set_spacing(0);
26 for(unsigned i=0; i<2; ++i)
28 selectors[i] = new TrainSelector(client);
29 root.add(*selectors[i]);
30 root_layout->set_gravity(*selectors[i], i*2-1, 1);
31 root_layout->set_expand(*selectors[i], true, false);
32 selectors[i]->signal_train_selected.connect(sigc::bind(sigc::mem_fun(this, &Remote::train_selected), i));
36 root_layout->add_constraint(*selectors[i], GLtk::Layout::RIGHT_OF, *selectors[i-1]);
37 root_layout->add_constraint(*selectors[i], GLtk::Layout::COPY_WIDTH, *selectors[i-1]);
44 root_layout->set_gravity(status_bar, -1, -1);
45 root_layout->set_expand(status_bar, true, false);
47 catalogue.add_source("data/Märklin/H0");
49 client.use_event_dispatcher(ev_disp);
54 ConnectDialog *dlg = new ConnectDialog(client);
56 root_layout->set_gravity(*dlg, 0, 0);
60 return Application::main();
65 for(unsigned i=0;; ++i)
67 Time::TimeStamp t = Time::now();
68 if(i>0 && t>=next_frame)
70 next_frame = t+Time::sec/30;
73 ev_disp.tick(max(next_frame-t, Time::zero));
78 GL::Framebuffer::system().clear(GL::COLOR_BUFFER_BIT);
80 window.swap_buffers();
83 void Remote::train_selected(NetTrain *train, unsigned index)
90 panels[index] = new TrainPanel(*train);
91 root.add(*panels[index]);
92 root_layout->set_expand(*panels[index], true, true);
93 root_layout->add_constraint(*panels[index], GLtk::Layout::BELOW, *selectors[index]);
94 root_layout->add_constraint(*panels[index], GLtk::Layout::ALIGN_LEFT, *selectors[index]);
95 root_layout->add_constraint(*panels[index], GLtk::Layout::ALIGN_RIGHT, *selectors[index]);
96 root_layout->add_constraint(*panels[index], GLtk::Layout::ABOVE, status_bar);