1 #include <msp/input/keys.h>
2 #include <msp/strings/format.h>
4 #include "objectselecttool.h"
10 ObjectSelectTool::ObjectSelectTool(Designer &d, Input::Keyboard &k, Input::Mouse &m, Selection &s):
17 void ObjectSelectTool::key_press(unsigned key)
19 if(key==Input::KEY_ESC)
21 else if(key==Msp::Input::KEY_PLUS)
22 selection.select_more();
23 else if(key==Msp::Input::KEY_L && shift_held)
24 selection.select_blocks();
25 else if(key==Msp::Input::KEY_L)
26 selection.select_linked();
28 return Tool::key_press(key);
33 void ObjectSelectTool::button_press(unsigned btn)
37 Ray ray = designer.get_view().create_ray(pointer.x, pointer.y);
38 Object *obj = designer.get_layout().pick<Object>(ray);
43 selection.toggle_object(obj);
50 void ObjectSelectTool::update_status()
52 const set<Object *> &objects = selection.get_objects();
53 float track_length = 0;
54 unsigned other_count = 0;
55 for(set<Object *>::const_iterator i=objects.begin(); i!=objects.end(); ++i)
57 if(Track *track = dynamic_cast<Track *>(*i))
58 track_length += track->get_type().get_total_length();
63 if(!track_length && !other_count)
70 s += format("%.2fm of track", track_length);
76 s += lexical_cast<string>(other_count);