using namespace Marklin;
using namespace Msp;
-Manipulator::Manipulator(Designer &d, Selection &s):
+Manipulator::Manipulator(Designer &d, Graphics::EventSource &es, Selection &s):
designer(d),
+ event_source(es),
selection(s),
mode(NONE),
angle(0)
{
+ event_source.signal_button_press.connect(sigc::mem_fun(this, &Manipulator::button_press));
+ event_source.signal_pointer_motion.connect(sigc::mem_fun(this, &Manipulator::pointer_motion));
selection.signal_changed.connect(sigc::mem_fun(this, &Manipulator::selection_changed));
}
signal_done.emit(false);
}
-void Manipulator::button_press(int, int, float, float, unsigned btn)
+void Manipulator::button_press(int, int, unsigned btn, unsigned)
{
+ if(!mode)
+ return;
+
if(btn==3)
cancel();
- else if(btn==1 && mode)
+ else if(btn==1)
{
Mode m = mode;
mode = NONE;
}
}
-void Manipulator::pointer_motion(int, int y, float gx, float gy)
+void Manipulator::pointer_motion(int x, int y)
{
pointer_y = y;
- gpointer = Point(gx, gy, 0);
+ gpointer = designer.map_pointer_to_ground(x, event_source.get_height()-1-y);
if(mode==MOVE)
{
float ep_dir = i->track->get_endpoint_direction(j);
float c = cos(ep_dir);
float s = sin(ep_dir);
- float dx = gx-ep_pos.x;
- float dy = gy-ep_pos.y;
+ float dx = gpointer.x-ep_pos.x;
+ float dy = gpointer.y-ep_pos.y;
float len = dx*c+dy*s;
if(len<length)