2006-07-23 08:03:19 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2001, 2006 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.
|
|
|
|
*/
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <cmath>
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
#include <ardour/playlist.h>
|
|
|
|
#include <ardour/region.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/source.h>
|
2006-07-23 08:03:19 -04:00
|
|
|
#include <ardour/diskstream.h>
|
|
|
|
#include <ardour/track.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "streamview.h"
|
2006-08-01 13:19:38 -04:00
|
|
|
#include "region_view.h"
|
2006-07-23 08:03:19 -04:00
|
|
|
#include "route_time_axis.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "canvas-waveview.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"
|
2005-11-28 17:36:26 -05:00
|
|
|
#include "utils.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
Large nasty commit in the form of a 5000 line patch chock-full of completely
unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one)
Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now.
Relevant (significant) changes:
- Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...)
- IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why)
- AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output.
- (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise.
- MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here.
- Random cleanups and variable renamings etc. because I have OCD and can't help myself. :)
Known broken: Loading of sessions containing MIDI tracks.
git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-06-26 12:01:34 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Editing;
|
|
|
|
|
2007-09-05 22:30:39 -04:00
|
|
|
StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group)
|
2005-09-25 14:42:24 -04:00
|
|
|
: _trackview (tv)
|
2008-02-21 20:45:29 -05:00
|
|
|
, owns_canvas_group(group == 0)
|
2007-09-05 22:30:39 -04:00
|
|
|
, canvas_group(group ? group : new ArdourCanvas::Group(*_trackview.canvas_display))
|
2006-08-01 20:22:16 -04:00
|
|
|
, canvas_rect(new ArdourCanvas::SimpleRect (*canvas_group))
|
|
|
|
, _samples_per_unit(_trackview.editor.get_current_zoom())
|
|
|
|
, rec_updating(false)
|
|
|
|
, rec_active(false)
|
|
|
|
, use_rec_regions(tv.editor.show_waveforms_recording())
|
|
|
|
, region_color(_trackview.color())
|
|
|
|
, stream_base_color(0xFFFFFFFF)
|
2007-05-17 06:41:14 -04:00
|
|
|
, layers(1)
|
2007-06-05 12:39:23 -04:00
|
|
|
, height(tv.height)
|
|
|
|
, layer_display(Overlaid)
|
2006-08-14 04:44:14 -04:00
|
|
|
, last_rec_data_frame(0)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
/* set_position() will position the group */
|
2005-11-12 22:53:51 -05:00
|
|
|
|
2005-11-27 17:35:04 -05:00
|
|
|
canvas_rect->property_x1() = 0.0;
|
|
|
|
canvas_rect->property_y1() = 0.0;
|
2006-11-19 11:45:16 -05:00
|
|
|
canvas_rect->property_x2() = _trackview.editor.frame_to_pixel (max_frames);
|
2005-11-27 17:35:04 -05:00
|
|
|
canvas_rect->property_y2() = (double) tv.height;
|
2007-08-05 19:17:40 -04:00
|
|
|
canvas_rect->property_outline_what() = (guint32) (0x2|0x8); // outline RHS and bottom
|
2006-08-01 20:22:16 -04:00
|
|
|
// (Fill/Outline colours set in derived classes)
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-25 19:06:46 -05:00
|
|
|
canvas_rect->signal_event().connect (bind (mem_fun (_trackview.editor, &PublicEditor::canvas_stream_view_event), canvas_rect, &_trackview));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if (_trackview.is_track()) {
|
|
|
|
_trackview.track()->DiskstreamChanged.connect (mem_fun (*this, &StreamView::diskstream_changed));
|
2005-09-25 17:19:23 -04:00
|
|
|
_trackview.session().TransportStateChange.connect (mem_fun (*this, &StreamView::transport_changed));
|
2007-06-25 22:16:54 -04:00
|
|
|
_trackview.session().TransportLooped.connect (mem_fun (*this, &StreamView::transport_looped));
|
2006-07-19 01:44:23 -04:00
|
|
|
_trackview.get_diskstream()->RecordEnableChanged.connect (mem_fun (*this, &StreamView::rec_enable_changed));
|
2006-01-18 19:03:55 -05:00
|
|
|
_trackview.session().RecordStateChanged.connect (mem_fun (*this, &StreamView::sess_rec_enable_changed));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-06-15 18:08:27 -04:00
|
|
|
ColorsChanged.connect (mem_fun (*this, &StreamView::color_handler));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
StreamView::~StreamView ()
|
|
|
|
{
|
|
|
|
undisplay_diskstream ();
|
2008-02-21 20:45:29 -05:00
|
|
|
|
|
|
|
delete canvas_rect;
|
|
|
|
|
|
|
|
if (owns_canvas_group) {
|
|
|
|
delete canvas_group;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StreamView::attach ()
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
if (_trackview.is_track()) {
|
2005-09-25 14:42:24 -04:00
|
|
|
display_diskstream (_trackview.get_diskstream());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
StreamView::set_position (gdouble x, gdouble y)
|
|
|
|
{
|
2005-11-27 17:35:04 -05:00
|
|
|
canvas_group->property_x() = x;
|
|
|
|
canvas_group->property_y() = y;
|
2005-09-25 14:42:24 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-05-17 06:41:14 -04:00
|
|
|
StreamView::set_height (double h)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
/* limit the values to something sane-ish */
|
|
|
|
if (h < 10.0 || h > 1000.0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-04-29 13:23:11 -04:00
|
|
|
if (canvas_rect->property_y2() == h) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-05-17 06:41:14 -04:00
|
|
|
height = h;
|
|
|
|
update_contents_y_position_and_height ();
|
2005-09-25 14:42:24 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
StreamView::set_samples_per_unit (gdouble spp)
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionViewList::iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (spp < 1.0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
_samples_per_unit = spp;
|
|
|
|
|
|
|
|
for (i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
(*i)->set_samples_per_unit (spp);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (vector<RecBoxInfo>::iterator xi = rec_rects.begin(); xi != rec_rects.end(); ++xi) {
|
|
|
|
RecBoxInfo &recbox = (*xi);
|
|
|
|
|
|
|
|
gdouble xstart = _trackview.editor.frame_to_pixel ( recbox.start );
|
|
|
|
gdouble xend = _trackview.editor.frame_to_pixel ( recbox.start + recbox.length );
|
|
|
|
|
2005-11-27 17:35:04 -05:00
|
|
|
recbox.rectangle->property_x1() = xstart;
|
|
|
|
recbox.rectangle->property_x2() = xend;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-08-29 17:21:48 -04:00
|
|
|
StreamView::add_region_view (boost::shared_ptr<Region> r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-10-11 18:07:47 -04:00
|
|
|
// ENSURE_GUI_THREAD (bind (mem_fun (*this, &AudioStreamView::add_region_view), r));
|
|
|
|
|
2007-08-02 17:08:18 -04:00
|
|
|
add_region_view_internal (r, true);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
StreamView::remove_region_view (boost::weak_ptr<Region> weak_r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-10-21 15:01:50 -04:00
|
|
|
ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::remove_region_view), weak_r));
|
|
|
|
|
|
|
|
boost::shared_ptr<Region> r (weak_r.lock());
|
|
|
|
|
|
|
|
if (!r) {
|
|
|
|
return;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView *>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
|
2006-08-29 17:21:48 -04:00
|
|
|
if (((*i)->region()) == r) {
|
2008-02-21 20:45:29 -05:00
|
|
|
RegionView* rv = *i;
|
2005-09-25 14:42:24 -04:00
|
|
|
region_views.erase (i);
|
2008-02-21 20:45:29 -05:00
|
|
|
delete rv;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StreamView::undisplay_diskstream ()
|
|
|
|
{
|
2008-02-21 20:45:29 -05:00
|
|
|
for (RegionViewList::iterator i = region_views.begin(); i != region_views.end() ; ) {
|
|
|
|
RegionViewList::iterator next = i;
|
|
|
|
++next;
|
2005-09-25 14:42:24 -04:00
|
|
|
delete *i;
|
2008-02-21 20:45:29 -05:00
|
|
|
i = next;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
region_views.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-08-24 03:37:17 -04:00
|
|
|
StreamView::display_diskstream (boost::shared_ptr<Diskstream> ds)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
playlist_change_connection.disconnect();
|
|
|
|
playlist_changed (ds);
|
2005-09-25 17:19:23 -04:00
|
|
|
playlist_change_connection = ds->PlaylistChanged.connect (bind (mem_fun (*this, &StreamView::playlist_changed), ds));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-05-17 06:41:14 -04:00
|
|
|
StreamView::playlist_modified_weak (boost::weak_ptr<Diskstream> ds)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-05-17 06:41:14 -04:00
|
|
|
boost::shared_ptr<Diskstream> sp (ds.lock());
|
|
|
|
if (!sp) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
playlist_modified (sp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StreamView::playlist_modified (boost::shared_ptr<Diskstream> ds)
|
|
|
|
{
|
|
|
|
/* we do not allow shared_ptr<T> to be bound to slots */
|
|
|
|
ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::playlist_modified_weak), ds));
|
|
|
|
|
|
|
|
/* update layers count and the y positions and heights of our regions */
|
2007-08-07 16:51:24 -04:00
|
|
|
if (ds->playlist()) {
|
|
|
|
layers = ds->playlist()->top_layer() + 1;
|
|
|
|
update_contents_y_position_and_height ();
|
|
|
|
redisplay_diskstream ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-08-24 03:37:17 -04:00
|
|
|
StreamView::playlist_changed (boost::shared_ptr<Diskstream> ds)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-05-17 06:41:14 -04:00
|
|
|
/* XXX: binding to a shared_ptr, is this ok? */
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::playlist_changed), ds));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* disconnect from old playlist */
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
for (vector<sigc::connection>::iterator i = playlist_connections.begin(); i != playlist_connections.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
(*i).disconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
playlist_connections.clear();
|
|
|
|
undisplay_diskstream ();
|
|
|
|
|
2007-10-04 12:26:02 -04:00
|
|
|
/* update layers count and the y positions and heights of our regions */
|
|
|
|
layers = ds->playlist()->top_layer() + 1;
|
|
|
|
update_contents_y_position_and_height ();
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* draw it */
|
|
|
|
redisplay_diskstream ();
|
|
|
|
|
|
|
|
/* catch changes */
|
|
|
|
|
2007-05-17 06:41:14 -04:00
|
|
|
playlist_connections.push_back (ds->playlist()->Modified.connect (bind (mem_fun (*this, &StreamView::playlist_modified_weak), ds)));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-08-01 13:19:38 -04:00
|
|
|
StreamView::diskstream_changed ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-06-15 18:05:07 -04:00
|
|
|
boost::shared_ptr<Track> t;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
if ((t = _trackview.track()) != 0) {
|
2006-08-24 03:37:17 -04:00
|
|
|
Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun (*this, &StreamView::display_diskstream), t->diskstream()));
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2005-09-25 17:19:23 -04:00
|
|
|
Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &StreamView::undisplay_diskstream));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-10-06 00:59:20 -04:00
|
|
|
StreamView::apply_color (Gdk::Color& color, ColorTarget target)
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
list<RegionView *>::iterator i;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
switch (target) {
|
|
|
|
case RegionColor:
|
|
|
|
region_color = color;
|
|
|
|
for (i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
(*i)->set_color (region_color);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case StreamBaseColor:
|
2006-08-01 20:22:16 -04:00
|
|
|
stream_base_color = RGBA_TO_UINT (
|
|
|
|
color.get_red_p(), color.get_green_p(), color.get_blue_p(), 255);
|
|
|
|
canvas_rect->property_fill_color_rgba() = stream_base_color;
|
2005-09-25 14:42:24 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-23 08:03:19 -04:00
|
|
|
StreamView::region_layered (RegionView* rv)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
|
use filechooser widget in export dialog, selected files set format combos, hide progress bar until use in export dialog, speed up 'separate regions in range' operation on larger sessions, ruler scale now calculated separately to mark generation, fix for non-stacked layering regression, try not to generate 'buried' crossfades, use playlist->freeze() to speed up copying/moving regions on large playlists (not done for undo), width dependent items now reset on regionview init, get rid of jack_port_ensure_monitor check, remove audiosourse _length (only source has a length.. i think), make overlapend differ to overlapexternal where start points coincide.
git-svn-id: svn://localhost/ardour2/trunk@2576 d708f5d6-7413-0410-9779-e7cbd77b26cf
2007-10-26 09:32:24 -04:00
|
|
|
/*
|
|
|
|
Currently 'layer' has nothing to do with the desired canvas layer.
|
|
|
|
For now, ensure that multiple regionviews passed here in groups are
|
|
|
|
ordered by 'layer' (lowest to highest).
|
|
|
|
|
|
|
|
(see AudioStreamView::redisplay_diskstream ()).
|
|
|
|
|
|
|
|
We move them to the top layer as they arrive.
|
|
|
|
*/
|
|
|
|
|
|
|
|
rv->get_canvas_group()->raise_to_top();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-08-01 13:19:38 -04:00
|
|
|
StreamView::rec_enable_changed ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &StreamView::setup_rec_box));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StreamView::sess_rec_enable_changed ()
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &StreamView::setup_rec_box));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StreamView::transport_changed()
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &StreamView::setup_rec_box));
|
2007-06-25 22:16:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StreamView::transport_looped()
|
|
|
|
{
|
|
|
|
// to force a new rec region
|
|
|
|
rec_active = false;
|
|
|
|
Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &StreamView::setup_rec_box));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StreamView::update_rec_box ()
|
|
|
|
{
|
|
|
|
if (rec_active && rec_rects.size() > 0) {
|
2006-03-13 22:43:54 -05:00
|
|
|
/* only update the last box */
|
2005-09-25 14:42:24 -04:00
|
|
|
RecBoxInfo & rect = rec_rects.back();
|
2006-10-21 15:01:50 -04:00
|
|
|
nframes_t at = _trackview.get_diskstream()->current_capture_end();
|
2006-03-13 22:43:54 -05:00
|
|
|
double xstart;
|
|
|
|
double xend;
|
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
switch (_trackview.track()->mode()) {
|
2006-03-13 22:43:54 -05:00
|
|
|
case Normal:
|
|
|
|
rect.length = at - rect.start;
|
|
|
|
xstart = _trackview.editor.frame_to_pixel (rect.start);
|
|
|
|
xend = _trackview.editor.frame_to_pixel (at);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Destructive:
|
|
|
|
rect.length = 2;
|
2006-03-17 15:24:26 -05:00
|
|
|
xstart = _trackview.editor.frame_to_pixel (_trackview.get_diskstream()->current_capture_start());
|
|
|
|
xend = _trackview.editor.frame_to_pixel (at);
|
2006-03-13 22:43:54 -05:00
|
|
|
break;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-27 17:35:04 -05:00
|
|
|
rect.rectangle->property_x1() = xstart;
|
|
|
|
rect.rectangle->property_x2() = xend;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2006-03-13 22:43:54 -05:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
RegionView*
|
2006-08-29 17:21:48 -04:00
|
|
|
StreamView::find_view (boost::shared_ptr<const Region> region)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
if ((*i)->region() == region) {
|
2005-09-25 14:42:24 -04:00
|
|
|
return *i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-23 08:03:19 -04:00
|
|
|
StreamView::foreach_regionview (sigc::slot<void,RegionView*> slot)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
slot (*i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-23 08:03:19 -04:00
|
|
|
StreamView::set_selected_regionviews (RegionSelection& regions)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
bool selected;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
|
|
|
|
selected = false;
|
|
|
|
|
|
|
|
for (RegionSelection::iterator ii = regions.begin(); ii != regions.end(); ++ii) {
|
|
|
|
if (*i == *ii) {
|
|
|
|
selected = true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2008-01-10 16:20:59 -05:00
|
|
|
|
2006-07-23 08:03:19 -04:00
|
|
|
(*i)->set_selected (selected);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-10-21 15:01:50 -04:00
|
|
|
StreamView::get_selectables (nframes_t start, nframes_t end, list<Selectable*>& results)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
|
2006-08-29 17:21:48 -04:00
|
|
|
if ((*i)->region()->coverage(start, end) != OverlapNone) {
|
2006-07-23 08:03:19 -04:00
|
|
|
results.push_back (*i);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-23 08:03:19 -04:00
|
|
|
StreamView::get_inverted_selectables (Selection& sel, list<Selectable*>& results)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-07-23 08:03:19 -04:00
|
|
|
for (list<RegionView*>::iterator i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
if (!sel.regions.contains (*i)) {
|
|
|
|
results.push_back (*i);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-14 12:19:58 -05:00
|
|
|
|
2007-05-17 06:41:14 -04:00
|
|
|
void
|
|
|
|
StreamView::update_contents_y_position_and_height ()
|
|
|
|
{
|
|
|
|
canvas_rect->property_y2() = height;
|
|
|
|
|
|
|
|
const double lh = height / layers;
|
|
|
|
|
|
|
|
for (RegionViewList::iterator i = region_views.begin(); i != region_views.end(); ++i) {
|
|
|
|
switch (layer_display) {
|
|
|
|
case Overlaid:
|
|
|
|
(*i)->set_y_position_and_height (0, height);
|
|
|
|
break;
|
|
|
|
case Stacked:
|
|
|
|
double const y = (*i)->region()->layer() * lh;
|
|
|
|
(*i)->set_y_position_and_height (y, lh);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (vector<RecBoxInfo>::iterator i = rec_rects.begin(); i != rec_rects.end(); ++i) {
|
|
|
|
i->rectangle->property_y2() = height - 1.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StreamView::set_layer_display (LayerDisplay d)
|
|
|
|
{
|
|
|
|
layer_display = d;
|
|
|
|
update_contents_y_position_and_height ();
|
|
|
|
}
|