]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/tool.cpp
Refactor Designer::use_tool so tools don't need to take a set of objects
[r2c2.git] / source / designer / tool.cpp
index a0419d04f8699018a6ac7c23998a4ea1c6b2f022..ffd6e6b6c5385201a1f5041eab1bbd27a71aafb5 100644 (file)
@@ -6,7 +6,8 @@ using namespace Msp;
 
 Tool::Tool(Designer &d, Input::Mouse &mouse):
        designer(d),
-       done(false)
+       done(false),
+       accepted(false)
 {
        mouse.signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &Tool::button_press), false));
        mouse.signal_axis_motion.connect(sigc::bind_return(sigc::mem_fun(this, &Tool::axis_motion), false));
@@ -22,12 +23,24 @@ void Tool::set_status(const std::string &s)
        signal_status.emit(status);
 }
 
-void Tool::set_done()
+void Tool::set_done(bool a)
 {
+       accepted = a;
        done = true;
        signal_done.emit();
 }
 
+void Tool::button_press(unsigned btn)
+{
+       if(btn==1)
+       {
+               finish();
+               set_done(true);
+       }
+       else if(btn==3)
+               set_done(false);
+}
+
 void Tool::axis_motion(unsigned axis, float value, float)
 {
        if(axis==0)
@@ -35,4 +48,6 @@ void Tool::axis_motion(unsigned axis, float value, float)
        else if(axis==1)
                pointer.y = value;
        ground_pointer = designer.map_pointer_to_ground(pointer);
+
+       pointer_motion();
 }