]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/extendtool.cpp
Move common accept/cancel handling to the Tool class
[r2c2.git] / source / designer / extendtool.cpp
index e35b4abcf13a43c46a53861472cb127a7466bb49..a5dea819a192132aca5454864203bcc7dddf8bb1 100644 (file)
@@ -8,8 +8,7 @@ using namespace Msp;
 using namespace R2C2;
 
 ExtendTool::ExtendTool(Designer &d, Input::Mouse &m, const set<Object *> &objects):
-       Tool(d, m),
-       accepted(false)
+       Tool(d, m)
 {
        for(set<Object *>::const_iterator i=objects.begin(); i!=objects.end(); ++i)
                if(Track *t = dynamic_cast<Track *>(*i))
@@ -93,28 +92,11 @@ void ExtendTool::connect()
        extend_tracks.front()->link_to(*start_track);
        extend_tracks.back()->link_to(*end_track);
 
-       accepted = true;
-       set_done();
+       set_done(true);
 }
 
-void ExtendTool::button_press(unsigned btn)
+void ExtendTool::pointer_motion()
 {
-       if(btn==1)
-       {
-               for(vector<TrackIter>::const_iterator i=unlinked_endpoints.begin(); i!=unlinked_endpoints.end(); ++i)
-                       if(extend_tracks.front()->link_to(**i))
-                               break;
-               accepted = true;
-               set_done();
-       }
-       else if(btn==3)
-               set_done();
-}
-
-void ExtendTool::axis_motion(unsigned axis, float value, float rel)
-{
-       Tool::axis_motion(axis, value, rel);
-
        Vector pos;
        Angle dir;
        float length = 0;
@@ -163,6 +145,13 @@ void ExtendTool::axis_motion(unsigned axis, float value, float rel)
        }
 }
 
+void ExtendTool::finish()
+{
+       for(vector<TrackIter>::const_iterator i=unlinked_endpoints.begin(); i!=unlinked_endpoints.end(); ++i)
+               if(extend_tracks.front()->link_to(**i))
+                       break;
+}
+
 vector<Track *> ExtendTool::create_straight(const Vector &start, const Angle &dir, float length, float limit)
 {
        const Catalogue::TrackMap &track_types = designer.get_catalogue().get_tracks();