Vkeybd: add a mod-wheel
[ardour.git] / gtk2_ardour / time_axis_view.cc
index f61ee9560886dd91fe8494d6c282666272eb6379..6ae0c3c5b8a5020f1f69e8a3d4e612f4fe85a494 100644 (file)
@@ -1,21 +1,28 @@
 /*
-    Copyright (C) 2000 Paul Davis
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+ * Copyright (C) 2005-2007 Doug McLain <doug@nostar.net>
+ * Copyright (C) 2005-2008 Nick Mainsbridge <mainsbridge@gmail.com>
+ * Copyright (C) 2005-2019 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
+ * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
+ * Copyright (C) 2006-2016 Tim Mayberry <mojofunk@gmail.com>
+ * Copyright (C) 2008-2012 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2014-2015 Ben Loftis <ben@harrisonconsoles.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
 #include <cstdlib>
 #include <cmath>
@@ -23,6 +30,8 @@
 #include <string>
 #include <list>
 
+#include <boost/smart_ptr/scoped_ptr.hpp>
+
 #include <gtkmm/separator.h>
 
 #include "pbd/error.h"
@@ -44,6 +53,7 @@
 #include "widgets/tooltips.h"
 
 #include "ardour_dialog.h"
+#include "audio_time_axis.h"
 #include "floating_text_entry.h"
 #include "gui_thread.h"
 #include "public_editor.h"
@@ -149,10 +159,9 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        set_tooltip (name_label, _("Track/Bus name (double click to edit)"));
 
        {
-               std::auto_ptr<Gtk::Entry> an_entry (new FocusEntry);
+               boost::scoped_ptr<Gtk::Entry> an_entry (new FocusEntry);
                an_entry->set_name (X_("TrackNameEditor"));
-               Gtk::Requisition req;
-               an_entry->size_request (req);
+               Gtk::Requisition req = an_entry->size_request ();
 
                name_label.set_size_request (-1, req.height);
                name_label.set_ellipsize (Pango::ELLIPSIZE_MIDDLE);
@@ -220,12 +229,11 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        top_hbox.pack_start (scroomer_placeholder, false, false); // OR pack_end to move after meters ?
 
        UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &TimeAxisView::color_handler));
+       UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &TimeAxisView::parameter_changed));
 }
 
 TimeAxisView::~TimeAxisView()
 {
-       CatchDeletion (this);
-
        in_destructor = true;
 
        for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
@@ -579,7 +587,9 @@ TimeAxisView::set_height (uint32_t h, TrackHeightMode m)
        uint32_t lanes = 0;
        if (m == TotalHeight) {
                for (Children::iterator i = children.begin(); i != children.end(); ++i) {
-                       if ( !(*i)->hidden()) ++lanes;
+                       if (!(*i)->hidden()) {
+                               ++lanes;
+                       }
                }
        }
        h /= (lanes + 1);
@@ -660,7 +670,7 @@ TimeAxisView::end_name_edit (std::string str, int next_dir)
 
                                RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*>(*i);
 
-                               if (rtav && (!rtav->is_track() || rtav->track()->rec_enable_control()->get_value())) {
+                               if (rtav && rtav->is_track() && rtav->track()->rec_enable_control()->get_value()) {
                                        continue;
                                }
 
@@ -691,7 +701,7 @@ TimeAxisView::end_name_edit (std::string str, int next_dir)
 
                                RouteTimeAxisView* rtav = dynamic_cast<RouteTimeAxisView*>(*i);
 
-                               if (rtav && (!rtav->is_track() || rtav->track()->rec_enable_control()->get_value())) {
+                               if (rtav && rtav->is_track() && rtav->track()->rec_enable_control()->get_value()) {
                                        continue;
                                }
 
@@ -843,6 +853,12 @@ TimeAxisView::show_selection (TimeSelection& ts)
        selection_group->show();
        selection_group->raise_to_top();
 
+       uint32_t gap = UIConfiguration::instance().get_vertical_region_gap ();
+       float ui_scale = UIConfiguration::instance().get_ui_scale ();
+       if (gap > 0 && ui_scale > 0) {
+               gap = ceil (gap * ui_scale);
+       }
+
        for (list<AudioRange>::iterator i = ts.begin(); i != ts.end(); ++i) {
                samplepos_t start, end;
                samplecnt_t cnt;
@@ -857,6 +873,14 @@ TimeAxisView::show_selection (TimeSelection& ts)
                x2 = _editor.sample_to_pixel (start + cnt - 1);
                y2 = current_height() - 1;
 
+               if (dynamic_cast<AudioTimeAxisView*>(this)) {
+                       if (y2 > gap) {
+                               y2 -= gap;
+                       } else {
+                               y2 = 1;
+                       }
+               }
+
                rect->rect->set (ArdourCanvas::Rect (x1, 0, x2, y2));
 
                // trim boxes are at the top for selections
@@ -967,7 +991,9 @@ TimeAxisView::get_selection_rect (uint32_t id)
 
                rect->rect = new ArdourCanvas::Rectangle (selection_group);
                CANVAS_DEBUG_NAME (rect->rect, "selection rect");
-               rect->rect->set_outline (false);
+               rect->rect->set_outline (true);
+               rect->rect->set_outline_width (1.0);
+               rect->rect->set_outline_color (UIConfiguration::instance().color ("selection"));
                rect->rect->set_fill_color (UIConfiguration::instance().color_mod ("selection rect", "selection rect"));
 
                rect->start_trim = new ArdourCanvas::Rectangle (selection_group);
@@ -1121,8 +1147,8 @@ TimeAxisView::compute_heights ()
        Gtk::Table one_row_table (1, 1);
        ArdourButton* test_button = manage (new ArdourButton);
        const int border_width = 2;
-       const int sample_height = 2;
-       extra_height = (2 * border_width) + sample_height;
+       const int frame_height = 2;
+       extra_height = (2 * border_width) + frame_height;
 
        window.add (one_row_table);
        test_button->set_name ("mute button");
@@ -1172,6 +1198,20 @@ TimeAxisView::color_handler ()
        }
 }
 
+void
+TimeAxisView::parameter_changed (string const & what_changed)
+{
+       if (what_changed == "vertical-region-gap") {
+               if (selected ()) {
+                       show_selection (_editor.get_selection().time);
+               }
+       }
+
+       if (view()) {
+               view()->parameter_changed (what_changed);
+       }
+}
+
 /** @return Pair: TimeAxisView, layer index.
  * TimeAxisView is non-0 if this object covers @param y, or one of its children
  * does. @param y is an offset from the top of the trackview area.