2007-09-05 22:30:39 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2001-2007 Paul Davis
|
2007-09-05 22:30:39 -04:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <cassert>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include <gtkmm.h>
|
|
|
|
|
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/midi_playlist.h"
|
|
|
|
#include "ardour/midi_region.h"
|
|
|
|
#include "ardour/midi_source.h"
|
|
|
|
#include "ardour/midi_diskstream.h"
|
|
|
|
#include "ardour/midi_track.h"
|
|
|
|
#include "ardour/smf_source.h"
|
|
|
|
#include "ardour/region_factory.h"
|
2007-09-05 22:30:39 -04:00
|
|
|
|
|
|
|
#include "automation_streamview.h"
|
|
|
|
#include "region_view.h"
|
|
|
|
#include "automation_region_view.h"
|
|
|
|
#include "automation_time_axis.h"
|
|
|
|
#include "canvas-simplerect.h"
|
|
|
|
#include "region_selection.h"
|
|
|
|
#include "selection.h"
|
|
|
|
#include "public_editor.h"
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "rgb_macros.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "simplerect.h"
|
|
|
|
#include "simpleline.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace Editing;
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
AutomationStreamView::AutomationStreamView (AutomationTimeAxisView& tv)
|
|
|
|
: StreamView (*dynamic_cast<RouteTimeAxisView*>(tv.get_parent()),
|
|
|
|
new ArdourCanvas::Group(*tv.canvas_display()))
|
|
|
|
, _controller(tv.controller())
|
2007-09-05 22:30:39 -04:00
|
|
|
, _automation_view(tv)
|
|
|
|
{
|
|
|
|
//canvas_rect->property_fill_color_rgba() = stream_base_color;
|
|
|
|
canvas_rect->property_outline_color_rgba() = RGBA_BLACK;
|
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
use_rec_regions = tv.editor().show_waveforms_recording ();
|
2007-09-05 22:30:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
AutomationStreamView::~AutomationStreamView ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RegionView*
|
2009-07-21 11:55:17 -04:00
|
|
|
AutomationStreamView::add_region_view_internal (boost::shared_ptr<Region> region, bool wfd, bool /*recording*/)
|
2007-09-05 22:30:39 -04:00
|
|
|
{
|
|
|
|
if ( ! region) {
|
|
|
|
cerr << "No region" << endl;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wfd) {
|
|
|
|
boost::shared_ptr<MidiRegion> mr = boost::dynamic_pointer_cast<MidiRegion>(region);
|
|
|
|
if (mr)
|
|
|
|
mr->midi_source()->load_model();
|
|
|
|
}
|
|
|
|
|
2008-09-18 20:47:49 -04:00
|
|
|
const boost::shared_ptr<AutomationControl> control
|
|
|
|
= boost::dynamic_pointer_cast<AutomationControl>(
|
|
|
|
region->control(_controller->controllable()->parameter()));
|
2007-09-05 22:30:39 -04:00
|
|
|
|
2007-09-10 23:14:32 -04:00
|
|
|
boost::shared_ptr<AutomationList> list;
|
2008-09-19 02:30:49 -04:00
|
|
|
if (control) {
|
2008-09-18 20:47:49 -04:00
|
|
|
list = boost::dynamic_pointer_cast<AutomationList>(control->list());
|
2008-09-19 02:30:49 -04:00
|
|
|
assert(!control->list() || list);
|
|
|
|
}
|
2007-09-05 22:30:39 -04:00
|
|
|
|
|
|
|
AutomationRegionView *region_view;
|
|
|
|
std::list<RegionView *>::iterator i;
|
|
|
|
|
|
|
|
for (i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
if ((*i)->region() == region) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-21 12:17:02 -04:00
|
|
|
/* great. we already have an AutomationRegionView for this Region. use it again. */
|
|
|
|
AutomationRegionView* arv = dynamic_cast<AutomationRegionView*>(*i);;
|
2007-09-05 22:30:39 -04:00
|
|
|
|
2008-09-21 12:35:55 -04:00
|
|
|
if (arv->line())
|
|
|
|
arv->line()->set_list (list);
|
2007-09-05 22:30:39 -04:00
|
|
|
(*i)->set_valid (true);
|
|
|
|
(*i)->enable_display(wfd);
|
2008-09-21 12:17:02 -04:00
|
|
|
display_region(arv);
|
2007-09-05 22:30:39 -04:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-19 02:30:49 -04:00
|
|
|
region_view = new AutomationRegionView (canvas_group, _automation_view, region,
|
|
|
|
_controller->controllable()->parameter(), list,
|
2007-09-05 22:30:39 -04:00
|
|
|
_samples_per_unit, region_color);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-09-05 22:30:39 -04:00
|
|
|
region_view->init (region_color, false);
|
|
|
|
region_views.push_front (region_view);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-09-05 22:30:39 -04:00
|
|
|
/* follow global waveform setting */
|
|
|
|
|
|
|
|
if (wfd) {
|
|
|
|
region_view->enable_display(true);
|
|
|
|
//region_view->midi_region()->midi_source(0)->load_model();
|
|
|
|
}
|
|
|
|
|
|
|
|
display_region(region_view);
|
|
|
|
|
|
|
|
/* catch regionview going away */
|
2009-12-22 15:21:43 -05:00
|
|
|
region->DropReferences.connect (*this, boost::bind (&AutomationStreamView::remove_region_view, this, boost::weak_ptr<Region>(region)), gui_context());
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-09-05 22:30:39 -04:00
|
|
|
RegionViewAdded (region_view);
|
|
|
|
|
|
|
|
return region_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AutomationStreamView::display_region(AutomationRegionView* region_view)
|
|
|
|
{
|
|
|
|
region_view->line().reset();
|
|
|
|
}
|
|
|
|
|
2008-09-21 12:17:02 -04:00
|
|
|
void
|
|
|
|
AutomationStreamView::set_automation_state (AutoState state)
|
|
|
|
{
|
|
|
|
std::list<RegionView *>::iterator i;
|
|
|
|
for (i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
boost::shared_ptr<AutomationLine> line = ((AutomationRegionView*)(*i))->line();
|
|
|
|
if (line && line->the_list())
|
|
|
|
line->the_list()->set_automation_state (state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-05 22:30:39 -04:00
|
|
|
void
|
|
|
|
AutomationStreamView::redisplay_diskstream ()
|
|
|
|
{
|
|
|
|
list<RegionView *>::iterator i, tmp;
|
|
|
|
|
2009-02-15 15:31:05 -05:00
|
|
|
// Flag region views as invalid and disable drawing
|
2009-01-27 23:55:31 -05:00
|
|
|
for (i = region_views.begin(); i != region_views.end(); ++i) {
|
2007-09-05 22:30:39 -04:00
|
|
|
(*i)->set_valid (false);
|
2009-02-15 15:31:05 -05:00
|
|
|
(*i)->enable_display(false);
|
2009-01-27 23:55:31 -05:00
|
|
|
}
|
2009-02-15 15:31:05 -05:00
|
|
|
|
|
|
|
// Add and display region views, and flag them as valid
|
2009-07-09 13:58:13 -04:00
|
|
|
if (_trackview.is_track()) {
|
|
|
|
_trackview.get_diskstream()->playlist()->foreach_region (
|
2009-06-08 15:28:51 -04:00
|
|
|
sigc::hide_return (sigc::mem_fun (*this, &StreamView::add_region_view))
|
2009-06-02 20:23:34 -04:00
|
|
|
);
|
2007-09-05 22:30:39 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-02-15 15:31:05 -05:00
|
|
|
// Stack regions by layer, and remove invalid regions
|
|
|
|
layer_regions();
|
2007-09-05 22:30:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
AutomationStreamView::setup_rec_box ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 11:55:17 -04:00
|
|
|
AutomationStreamView::update_rec_regions (nframes_t /*start*/, nframes_t /*dur*/)
|
2007-09-05 22:30:39 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AutomationStreamView::rec_data_range_ready (jack_nframes_t start, jack_nframes_t dur)
|
|
|
|
{
|
|
|
|
// this is called from the butler thread for now
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-12-11 18:29:48 -05:00
|
|
|
ENSURE_GUI_THREAD (*this, &AutomationStreamView::rec_data_range_ready, start, dur)
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2007-09-05 22:30:39 -04:00
|
|
|
this->update_rec_regions (start, dur);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AutomationStreamView::color_handler ()
|
|
|
|
{
|
2009-07-09 13:58:13 -04:00
|
|
|
/*if (_trackview.is_midi_track()) {
|
2007-09-05 22:30:39 -04:00
|
|
|
canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiTrackBase.get();
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2007-09-05 22:30:39 -04:00
|
|
|
|
2009-07-09 13:58:13 -04:00
|
|
|
if (!_trackview.is_midi_track()) {
|
2007-09-05 22:30:39 -04:00
|
|
|
canvas_rect->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiBusBase.get();;
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
|