]> git.tdb.fi Git - r2c2.git/commitdiff
More toolbar buttons
authorMikko Rasa <tdb@tdb.fi>
Thu, 18 Nov 2010 18:52:38 +0000 (18:52 +0000)
committerMikko Rasa <tdb@tdb.fi>
Thu, 18 Nov 2010 18:52:38 +0000 (18:52 +0000)
Add shortcut keys to tooltips
Don't start extend if no suitable tracks are selected
Check that we are in select mode before doing stuff

source/designer/designer.cpp
source/designer/designer.h
source/designer/layoutbar.cpp
source/designer/manipulator.cpp
source/designer/manipulator.h
source/designer/routebar.cpp
source/designer/trackbar.cpp

index 34398f3177dfd3700ecf9cd8547722341412602c..86fc3494a424508b20ad93de6c685db00cc8ecbd 100644 (file)
@@ -189,12 +189,30 @@ void Designer::quit()
 
 void Designer::new_track()
 {
+       if(mode!=SELECT)
+               return;
+
        mode = CATALOGUE;
+       lbl_status->set_text("Select new track or press Esc to cancel");
+}
+
+void Designer::erase_tracks()
+{
+       if(mode!=SELECT)
+               return;
+
+       set<Track *> tracks = selection.get_tracks();
+       selection.clear();
+       for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
+       {
+               overlay->clear(layout_3d->get_track(**i));
+               delete *i;
+       }
 }
 
 void Designer::track_properties()
 {
-       if(selection.empty())
+       if(mode!=SELECT || selection.empty())
                return;
 
        TrackProperties *track_prop = new TrackProperties(selection);
@@ -206,9 +224,34 @@ void Designer::track_properties()
        track_prop->signal_response.connect(sigc::mem_fun(this, &Designer::track_properties_response));
 }
 
+void Designer::extend_track()
+{
+       if(mode!=SELECT)
+               return;
+
+       if(manipulator.start_extend())
+               mode = MANIPULATE;
+}
+
+void Designer::connect_tracks()
+{
+       if(mode!=SELECT)
+               return;
+
+       manipulator.connect();
+}
+
+void Designer::flatten_tracks()
+{
+       if(mode!=SELECT)
+               return;
+
+       manipulator.flatten();
+}
+
 void Designer::rename_route()
 {
-       if(!cur_route)
+       if(mode!=SELECT || !cur_route)
                return;
 
        InputDialog *input = new InputDialog(*this, "Route name", cur_route->get_name());
@@ -282,10 +325,7 @@ void Designer::key_press(unsigned key, unsigned mod, wchar_t)
        mod = Input::mod_from_sys(mod);
 
        if(key==Msp::Input::KEY_N && (mod&Input::MOD_SHIFT))
-       {
-               manipulator.start_extend();
-               mode = MANIPULATE;
-       }
+               extend_track();
        else if(key==Msp::Input::KEY_N)
                new_track();
        else if(key==Msp::Input::KEY_G)
@@ -332,16 +372,7 @@ void Designer::key_press(unsigned key, unsigned mod, wchar_t)
                        selection.clear();
        }
        else if(key==Msp::Input::KEY_X)
-       {
-               set<Track *> tracks = selection.get_tracks();
-               selection.clear();
-               for(set<Track *>::iterator i=tracks.begin(); i!=tracks.end(); ++i)
-               {
-                       overlay->clear(layout_3d->get_track(**i));
-                       layout->remove_track(**i);
-                       delete *i;
-               }
-       }
+               erase_tracks();
        else if(key==Msp::Input::KEY_F && (mod&Input::MOD_SHIFT))
        {
                const set<Track *> &tracks = selection.get_tracks();
@@ -358,7 +389,7 @@ void Designer::key_press(unsigned key, unsigned mod, wchar_t)
                }
        }
        else if(key==Msp::Input::KEY_F)
-               manipulator.flatten();
+               flatten_tracks();
        else if(key==Msp::Input::KEY_E && (mod&Input::MOD_SHIFT))
                manipulator.even_slope(true);
        else if(key==Msp::Input::KEY_E)
@@ -366,7 +397,7 @@ void Designer::key_press(unsigned key, unsigned mod, wchar_t)
        else if(key==Msp::Input::KEY_A)
                add_selection_to_route();
        else if(key==Msp::Input::KEY_C)
-               manipulator.connect();
+               connect_tracks();
        else if(key==Msp::Input::KEY_V)
                svg_export();
        else if(key==Msp::Input::KEY_P)
index e8d0d7605784c93a2b6af7714e389472b6f8fcb0..2a53745db8634ee450fbe592c957d527c953967a 100644 (file)
@@ -94,7 +94,11 @@ public:
        Msp::GLtk::Root &get_root() { return root; }
 
        void new_track();
+       void erase_tracks();
        void track_properties();
+       void extend_track();
+       void connect_tracks();
+       void flatten_tracks();
        void rename_route();
        void svg_export();
 
index d47485fb3d08c1b540c4d45d9d9a52bb45f9a26e..3e17eac12123f0b130a0a9b2bdb48c0a84245902 100644 (file)
@@ -11,7 +11,7 @@ Distributed under the GPL
 using namespace Msp;
 
 Layoutbar::Layoutbar(Designer &designer):
-       Toolbar("Layout", 120)
+       Toolbar("Layout", 160)
 {
        GLtk::Button *btn;
 
@@ -21,11 +21,16 @@ Layoutbar::Layoutbar(Designer &designer):
 
        pnl_content->add(*(btn = new GLtk::Button("Save")));
        btn->set_geometry(GLtk::Geometry(40, 10, 40, 24));
-       btn->set_tooltip("Save current layout");
+       btn->set_tooltip("Save current layout (W)");
        btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::save));
 
-       pnl_content->add(*(btn = new GLtk::Button("Quit")));
+       pnl_content->add(*(btn = new GLtk::Button("SVG")));
        btn->set_geometry(GLtk::Geometry(80, 10, 40, 24));
+       btn->set_tooltip("Export layout as SVG (V)");
+       btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::svg_export));
+
+       pnl_content->add(*(btn = new GLtk::Button("Quit")));
+       btn->set_geometry(GLtk::Geometry(120, 10, 40, 24));
        btn->set_style("red");
        btn->set_tooltip("Exit Designer");
        btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::quit));
index 23ea138623c42809726c0df07c644ad15ba52f99..720309bd8dc4b773374b7120fd09195685464d91 100644 (file)
@@ -59,12 +59,26 @@ void Manipulator::start_elevate()
        mode = ELEVATE;
 }
 
-void Manipulator::start_extend()
+bool Manipulator::start_extend()
 {
        if(mode)
                cancel();
 
-       mode = EXTEND;
+       bool ok = false;
+       const set<Track *> &stracks = selection.get_tracks();
+       for(set<Track *>::const_iterator i=stracks.begin(); (!ok && i!=stracks.end()); ++i)
+       {
+               const vector<Track *> &links = (*i)->get_links();
+               for(vector<Track *>::const_iterator j=links.begin(); (!ok && j!=links.end()); ++j)
+                       ok = !*j;
+       }
+
+       if(ok)
+               mode = EXTEND;
+       else
+               signal_status.emit("No free endpoints");
+
+       return ok;
 }
 
 void Manipulator::duplicate()
index 66b5d1ae67065e7ee1f275af69c095d8e820127a..75fafe569afbab67dfaf9e34662f65d9f6ea2b79 100644 (file)
@@ -69,7 +69,7 @@ public:
        void start_move();
        void start_rotate();
        void start_elevate();
-       void start_extend();
+       bool start_extend();
        void duplicate();
        void flatten();
        void even_slope(bool =false);
index 0a2b9799d2d41171aea67fe7ce7f77cfb253c50c..da9a5cf94537479079f3b48b3c782fa03aa0ce5f 100644 (file)
@@ -28,6 +28,7 @@ Routebar::Routebar(Designer &d):
 
        pnl_content->add(*(btn = new GLtk::Button("Del")));
        btn->set_geometry(GLtk::Geometry(250, 10, 40, 24));
+       btn->set_style("red");
        btn->set_tooltip("Delete the current route");
        btn->signal_clicked.connect(sigc::mem_fun(this, &Routebar::delete_route_clicked));
 
@@ -38,7 +39,7 @@ Routebar::Routebar(Designer &d):
 
        pnl_content->add(*(btn = new GLtk::Button("Add")));
        btn->set_geometry(GLtk::Geometry(330, 10, 40, 24));
-       btn->set_tooltip("Add selected tracks to current route");
+       btn->set_tooltip("Add selected tracks to current route (A)");
        btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::add_selection_to_route));
 
        designer.get_layout().signal_route_added.connect(sigc::mem_fun(this, &Routebar::route_added));
index 9d7ebc587146afa43b5090010626a25af70d3330..b05f3c85ecaa77181270f5d0a262315ed3ab6b5c 100644 (file)
@@ -11,17 +11,39 @@ Distributed under the GPL
 using namespace Msp;
 
 Trackbar::Trackbar(Designer &designer):
-       Toolbar("Track", 80)
+       Toolbar("Track", 240)
 {
        GLtk::Button *btn;
 
-       pnl_content->add(*(btn = new GLtk::Button("+Trk")));
+       pnl_content->add(*(btn = new GLtk::Button("New")));
        btn->set_geometry(GLtk::Geometry(0, 10, 40, 24));
-       btn->set_tooltip("Add a track piece");
+       btn->set_style("green");
+       btn->set_tooltip("Add a track piece (N)");
        btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::new_track));
 
-       pnl_content->add(*(btn = new GLtk::Button("Prop")));
+       pnl_content->add(*(btn = new GLtk::Button("Del")));
        btn->set_geometry(GLtk::Geometry(40, 10, 40, 24));
-       btn->set_tooltip("Change properties of selected tracks");
+       btn->set_style("red");
+       btn->set_tooltip("Delete selected tracks (X)");
+       btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::erase_tracks));
+
+       pnl_content->add(*(btn = new GLtk::Button("Prop")));
+       btn->set_geometry(GLtk::Geometry(80, 10, 40, 24));
+       btn->set_tooltip("Change properties of selected tracks (P)");
        btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::track_properties));
+
+       pnl_content->add(*(btn = new GLtk::Button("Xtnd")));
+       btn->set_geometry(GLtk::Geometry(120, 10, 40, 24));
+       btn->set_tooltip("Extend straight track out of free endpoint (Shift+N)");
+       btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::extend_track));
+
+       pnl_content->add(*(btn = new GLtk::Button("Conn")));
+       btn->set_geometry(GLtk::Geometry(160, 10, 40, 24));
+       btn->set_tooltip("Connect free endpoints of selected tracks (C)");
+       btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::connect_tracks));
+
+       pnl_content->add(*(btn = new GLtk::Button("Flat")));
+       btn->set_geometry(GLtk::Geometry(200, 10, 40, 24));
+       btn->set_tooltip("Make selected tracks flat (F)");
+       btn->signal_clicked.connect(sigc::mem_fun(&designer, &Designer::flatten_tracks));
 }