X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gtk2_ardour%2Ftime_axis_view.cc;h=7fde1b382637e26e47e154766933f12069560b6a;hb=4050ca5633dda03679f9aa9fab87d3bbf517395b;hp=b03a0c03bd3c4585f8898455fd1ff9ab20565176;hpb=3d505636207b3a595ed8ae2f8c7309477d826638;p=ardour.git diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index b03a0c03bd..7fde1b3826 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -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 + * Copyright (C) 2005-2008 Nick Mainsbridge + * Copyright (C) 2005-2019 Paul Davis + * Copyright (C) 2005 Taybin Rutkin + * Copyright (C) 2006-2014 David Robillard + * Copyright (C) 2006-2016 Tim Mayberry + * Copyright (C) 2008-2012 Carl Hetherington + * Copyright (C) 2013-2019 Robin Gareus + * Copyright (C) 2014-2015 Ben Loftis + * + * 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 #include @@ -23,6 +30,8 @@ #include #include +#include + #include #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 an_entry (new FocusEntry); + boost::scoped_ptr 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,6 +229,7 @@ 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() @@ -579,7 +589,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); @@ -619,7 +631,7 @@ TimeAxisView::begin_name_edit () } Gtk::Window* toplevel = (Gtk::Window*) control_parent->get_toplevel(); - FloatingTextEntry* fte = new FloatingTextEntry (toplevel, name_label.get_text ()); + FloatingTextEntry* fte = new FloatingTextEntry (toplevel, name ()); fte->set_name ("TrackNameEditor"); fte->use_text.connect (sigc::mem_fun (*this, &TimeAxisView::end_name_edit)); @@ -660,7 +672,7 @@ TimeAxisView::end_name_edit (std::string str, int next_dir) RouteTimeAxisView* rtav = dynamic_cast(*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 +703,7 @@ TimeAxisView::end_name_edit (std::string str, int next_dir) RouteTimeAxisView* rtav = dynamic_cast(*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; } @@ -797,7 +809,7 @@ TimeAxisView::set_samples_per_pixel (double fpp) } void -TimeAxisView::show_timestretch (framepos_t start, framepos_t end, int layers, int layer) +TimeAxisView::show_timestretch (samplepos_t start, samplepos_t end, int layers, int layer) { for (Children::iterator i = children.begin(); i != children.end(); ++i) { (*i)->show_timestretch (start, end, layers, layer); @@ -818,8 +830,9 @@ TimeAxisView::show_selection (TimeSelection& ts) double x1; double x2; double y2; - SelectionRect *rect; time_axis_frame.show(); + SelectionRect *rect; + time_axis_frame.show(); for (Children::iterator i = children.begin(); i != children.end(); ++i) { if (!(*i)->selected () && !(*i)->propagate_time_selection ()) { @@ -842,9 +855,15 @@ 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::iterator i = ts.begin(); i != ts.end(); ++i) { - framepos_t start, end; - framecnt_t cnt; + samplepos_t start, end; + samplecnt_t cnt; start = (*i).start; end = (*i).end; @@ -856,6 +875,14 @@ TimeAxisView::show_selection (TimeSelection& ts) x2 = _editor.sample_to_pixel (start + cnt - 1); y2 = current_height() - 1; + if (dynamic_cast(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 @@ -1017,14 +1044,14 @@ TimeAxisView::remove_child (boost::shared_ptr child) } /** Get selectable things within a given range. - * @param start Start time in session frames. - * @param end End time in session frames. + * @param start Start time in session samples. + * @param end End time in session samples. * @param top Top y range, in trackview coordinates (ie 0 is the top of the track view) * @param bot Bottom y range, in trackview coordinates (ie 0 is the top of the track view) * @param result Filled in with selectable things. */ void -TimeAxisView::get_selectables (framepos_t start, framepos_t end, double top, double bot, list& results, bool within) +TimeAxisView::get_selectables (samplepos_t start, samplepos_t end, double top, double bot, list& results, bool within) { for (Children::iterator i = children.begin(); i != children.end(); ++i) { if (!(*i)->hidden()) { @@ -1171,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.