X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fautomation_streamview.cc;h=1628612badf853c5358d569f5aa9f1839444d7d0;hb=1df47e9fb4c4561cc67e860c8b1ceec9bf0314da;hp=a1ba99a2b444db5e1990748cc56fe3ec25f557f8;hpb=fa22520fd257f166c00615e7e40ec10c9e29b948;p=ardour.git diff --git a/gtk2_ardour/automation_streamview.cc b/gtk2_ardour/automation_streamview.cc index a1ba99a2b4..1628612bad 100644 --- a/gtk2_ardour/automation_streamview.cc +++ b/gtk2_ardour/automation_streamview.cc @@ -1,56 +1,70 @@ /* - Copyright (C) 2001-2007 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) 2007-2014 David Robillard + * Copyright (C) 2008-2017 Paul Davis + * Copyright (C) 2009-2011 Carl Hetherington + * Copyright (C) 2014-2019 Robin Gareus + * Copyright (C) 2015 Tim Mayberry + * + * 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 +#include #include #include -#include +#include "gtkmm2ext/gtk_ui.h" + +#include "pbd/compose.h" +#include "canvas/debug.h" #include "ardour/midi_region.h" #include "ardour/midi_source.h" -#include "automation_streamview.h" -#include "region_view.h" #include "automation_region_view.h" +#include "automation_streamview.h" #include "automation_time_axis.h" -#include "region_selection.h" -#include "selection.h" +#include "gui_thread.h" #include "public_editor.h" -#include "ardour_ui.h" +#include "region_selection.h" +#include "region_view.h" #include "rgb_macros.h" -#include "gui_thread.h" -#include "utils.h" +#include "selection.h" +#include "ui_config.h" + +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; +using namespace ARDOUR_UI_UTILS; using namespace PBD; using namespace Editing; AutomationStreamView::AutomationStreamView (AutomationTimeAxisView& tv) - : StreamView (*dynamic_cast(tv.get_parent())) + : StreamView (*dynamic_cast(tv.get_parent()), + tv.canvas_display()) , _automation_view(tv) , _pending_automation_state (Off) { - //canvas_rect->property_fill_color_rgba() = stream_base_color; - canvas_rect->set_outline_color (RGBA_BLACK); + CANVAS_DEBUG_NAME (_canvas_group, string_compose ("SV canvas group auto %1", tv.name())); + CANVAS_DEBUG_NAME (canvas_rect, string_compose ("SV canvas rectangle auto %1", tv.name())); + + color_handler (); + + UIConfiguration::instance().ColorsChanged.connect(sigc::mem_fun(*this, &AutomationStreamView::color_handler)); } AutomationStreamView::~AutomationStreamView () @@ -59,14 +73,17 @@ AutomationStreamView::~AutomationStreamView () RegionView* -AutomationStreamView::add_region_view_internal (boost::shared_ptr region, bool wfd, bool /*recording*/) +AutomationStreamView::add_region_view_internal (boost::shared_ptr region, bool wait_for_data, bool /*recording*/) { - assert (region); + if (!region) { + return 0; + } - if (wfd) { + if (wait_for_data) { boost::shared_ptr mr = boost::dynamic_pointer_cast(region); if (mr) { - mr->midi_source()->load_model(); + Source::Lock lock(mr->midi_source()->mutex()); + mr->midi_source()->load_model(lock); } } @@ -77,7 +94,10 @@ AutomationStreamView::add_region_view_internal (boost::shared_ptr region boost::shared_ptr list; if (control) { list = boost::dynamic_pointer_cast(control->list()); - assert(!control->list() || list); + if (control->list() && !list) { + error << _("unable to display automation region for control without list") << endmsg; + return 0; + } } AutomationRegionView *region_view; @@ -93,7 +113,7 @@ AutomationStreamView::add_region_view_internal (boost::shared_ptr region arv->line()->set_list (list); } (*i)->set_valid (true); - (*i)->enable_display(wfd); + (*i)->enable_display (wait_for_data); display_region(arv); return 0; @@ -106,17 +126,17 @@ AutomationStreamView::add_region_view_internal (boost::shared_ptr region _samples_per_pixel, region_color ); - region_view->init (region_color, false); + region_view->init (false); region_views.push_front (region_view); /* follow global waveform setting */ - if (wfd) { + if (wait_for_data) { region_view->enable_display(true); - //region_view->midi_region()->midi_source(0)->load_model(); + // region_view->midi_region()->midi_source(0)->load_model(); } - display_region(region_view); + display_region (region_view); /* catch regionview going away */ region->DropReferences.connect (*this, invalidator (*this), boost::bind (&AutomationStreamView::remove_region_view, this, boost::weak_ptr(region)), gui_context()); @@ -185,13 +205,11 @@ AutomationStreamView::setup_rec_box () void AutomationStreamView::color_handler () { - /*if (_trackview.is_midi_track()) { - canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->get_canvasvar_MidiTrackBase(); + if (_trackview.is_midi_track()) { + canvas_rect->set_fill_color (UIConfiguration::instance().color_mod ("midi track base", "midi track base")); + } else { + canvas_rect->set_fill_color (UIConfiguration::instance().color ("midi bus base")); } - - if (!_trackview.is_midi_track()) { - canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->get_canvasvar_MidiBusBase();; - }*/ } AutoState @@ -261,20 +279,21 @@ AutomationStreamView::clear () } } -/** @param start Start position in session frames. - * @param end End position in session frames. +/** @param start Start position in session samples. + * @param end End position in session samples. * @param bot Bottom position expressed as a fraction of track height where 0 is the bottom of the track. * @param top Top position expressed as a fraction of track height where 0 is the bottom of the track. * NOTE: this y system is different to that for the StreamView method that this overrides, which is a little * confusing. */ void -AutomationStreamView::get_selectables (framepos_t start, framepos_t end, double botfrac, double topfrac, list& results) +AutomationStreamView::get_selectables (samplepos_t start, samplepos_t end, double botfrac, double topfrac, list& results, bool /*within*/) { for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { AutomationRegionView* arv = dynamic_cast (*i); - assert (arv); - arv->line()->get_selectables (start, end, botfrac, topfrac, results); + if (arv) { + arv->line()->get_selectables (start, end, botfrac, topfrac, results); + } } } @@ -295,33 +314,27 @@ AutomationStreamView::get_lines () const for (list::const_iterator i = region_views.begin(); i != region_views.end(); ++i) { AutomationRegionView* arv = dynamic_cast (*i); - assert (arv); - lines.push_back (arv->line()); + if (arv) { + lines.push_back (arv->line()); + } } return lines; } -struct RegionPositionSorter { - bool operator() (RegionView* a, RegionView* b) { - return a->region()->position() < b->region()->position(); - } -}; - - -/** @param pos Position, in session frames. - * @return AutomationLine to paste to for that position, or 0 if there is none appropriate. - */ -boost::shared_ptr -AutomationStreamView::paste_line (framepos_t pos) +bool +AutomationStreamView::paste (samplepos_t pos, + unsigned paste_count, + float times, + boost::shared_ptr alist) { /* XXX: not sure how best to pick this; for now, just use the last region which starts before pos */ if (region_views.empty()) { - return boost::shared_ptr (); + return false; } - region_views.sort (RegionPositionSorter ()); + region_views.sort (RegionView::PositionOrder()); list::const_iterator prev = region_views.begin (); @@ -336,11 +349,9 @@ AutomationStreamView::paste_line (framepos_t pos) /* If *prev doesn't cover pos, it's no good */ if (r->position() > pos || ((r->position() + r->length()) < pos)) { - return boost::shared_ptr (); + return false; } AutomationRegionView* arv = dynamic_cast (*prev); - assert (arv); - - return arv->line (); + return arv ? arv->paste(pos, paste_count, times, alist) : false; }