+
+void ControlPanel::button_press(int x, int y, unsigned btn)
+{
+ Panel::button_press(x, y, btn);
+
+ if(placing)
+ {
+ signal_ungrab_pointer.emit();
+ placing = false;
+
+ for(vector<PlacementGhost *>::iterator i=ghosts.begin(); i!=ghosts.end(); ++i)
+ delete *i;
+ ghosts.clear();
+
+ if(btn==1 && place_location)
+ train.place(place_location);
+ }
+}
+
+void ControlPanel::pointer_motion(int x, int y)
+{
+ Panel::pointer_motion(x, y);
+
+ if(placing)
+ {
+ int rx = x;
+ int ry = y;
+ map_coords_to_ancestor(rx, ry, *find_ancestor<GLtk::Root>());
+ Ray ray = engineer.get_main_view().create_ray(rx, ry);
+ Track *track = engineer.get_layout().pick<Track>(ray);
+ if(track)
+ {
+ place_location = TrackIter(track, 0).block_iter();
+ if(place_location)
+ {
+ ghosts.back()->place(place_location.track_iter());
+ for(unsigned i=ghosts.size()-1; i--; )
+ ghosts[i]->place_before(*ghosts[i+1]);
+ }
+ }
+ }
+}