/*
- 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.
-
-*/
+ * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
+ * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2007-2019 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2007 Doug McLain <doug@nostar.net>
+ * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2015-2017 Nick Mainsbridge <mainsbridge@gmail.com>
+ * Copyright (C) 2015 Tim Mayberry <mojofunk@gmail.com>
+ * Copyright (C) 2018 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 <cmath>
#include <algorithm>
bool automation)
: TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(), false, automation,
(automation ? TimeAxisViewItem::ShowFrame :
- TimeAxisViewItem::Visibility (TimeAxisViewItem::ShowNameText|
+ TimeAxisViewItem::Visibility ((UIConfiguration::instance().get_show_region_name() ? TimeAxisViewItem::ShowNameText : 0) |
TimeAxisViewItem::ShowNameHighlight| TimeAxisViewItem::ShowFrame)))
, _region (r)
, sync_mark(0)
name_highlight->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_region_view_name_highlight_event), name_highlight, this));
}
- if (sample_handle_start) {
- sample_handle_start->set_data ("regionview", this);
- sample_handle_start->set_data ("isleft", (void*) 1);
- sample_handle_start->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_sample_handle_event), sample_handle_start, this));
- sample_handle_start->raise_to_top();
+ if (frame_handle_start) {
+ frame_handle_start->set_data ("regionview", this);
+ frame_handle_start->set_data ("isleft", (void*) 1);
+ frame_handle_start->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_frame_handle_event), frame_handle_start, this));
+ frame_handle_start->raise_to_top();
}
- if (sample_handle_end) {
- sample_handle_end->set_data ("regionview", this);
- sample_handle_end->set_data ("isleft", (void*) 0);
- sample_handle_end->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_sample_handle_event), sample_handle_end, this));
- sample_handle_end->raise_to_top();
+ if (frame_handle_end) {
+ frame_handle_end->set_data ("regionview", this);
+ frame_handle_end->set_data ("isleft", (void*) 0);
+ frame_handle_end->Event.connect (sigc::bind (sigc::mem_fun (PublicEditor::instance(), &PublicEditor::canvas_frame_handle_event), frame_handle_end, this));
+ frame_handle_end->raise_to_top();
}
if (name_text) {
delete *g;
}
- for (list<ArdourCanvas::Rectangle*>::iterator i = _coverage_samples.begin (); i != _coverage_samples.end (); ++i) {
+ for (list<ArdourCanvas::Rectangle*>::iterator i = _coverage_frame.begin (); i != _coverage_frame.end (); ++i) {
delete *i;
}
- drop_silent_samples ();
+ drop_silent_frames ();
delete editor;
}
}
void
-RegionView::set_silent_samples (const AudioIntervalResult& silences, double /*threshold*/)
+RegionView::set_silent_frames (const AudioIntervalResult& silences, double /*threshold*/)
{
samplecnt_t shortest = max_samplecnt;
- /* remove old silent samples */
- drop_silent_samples ();
+ /* remove old silent frames */
+ drop_silent_frames ();
if (silences.empty()) {
return;
ArdourCanvas::Rectangle* cr = new ArdourCanvas::Rectangle (group);
cr->set_ignore_events (true);
- _silent_samples.push_back (cr);
+ _silent_frames.push_back (cr);
/* coordinates for the rect are relative to the regionview origin */
}
void
-RegionView::hide_silent_samples ()
+RegionView::hide_silent_frames ()
{
- for (list<ArdourCanvas::Rectangle*>::iterator i = _silent_samples.begin (); i != _silent_samples.end (); ++i) {
+ for (list<ArdourCanvas::Rectangle*>::iterator i = _silent_frames.begin (); i != _silent_frames.end (); ++i) {
(*i)->hide ();
}
_silence_text->hide();
}
void
-RegionView::drop_silent_samples ()
+RegionView::drop_silent_frames ()
{
- for (list<ArdourCanvas::Rectangle*>::iterator i = _silent_samples.begin (); i != _silent_samples.end (); ++i) {
+ for (list<ArdourCanvas::Rectangle*>::iterator i = _silent_frames.begin (); i != _silent_frames.end (); ++i) {
delete *i;
}
- _silent_samples.clear ();
+ _silent_frames.clear ();
delete _silence_text;
_silence_text = 0;
unit_length = _region->length() / samples_per_pixel;
- for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
+ for (vector<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
- (*i)->set_duration (unit_length);
+ (*i)->set_duration (unit_length);
- }
+ }
}
}
void
RegionView::region_muted ()
{
- set_sample_color ();
+ set_frame_color ();
region_renamed ();
}
void
RegionView::region_opacity ()
{
- set_sample_color ();
+ set_frame_color ();
}
void
Gtkmm2ext::Color f = TimeAxisViewItem::get_fill_color();
char const *modname;
- if (_region->opaque() && (!ARDOUR::Profile->get_mixbus() || (!_dragging && !_region->muted ()))) {
+ if (_region->opaque() && ( !_dragging && !_region->muted () )) {
modname = "opaque region base";
} else {
modname = "transparent region base";
);
}
- for (list<ArdourCanvas::Rectangle*>::iterator i = _coverage_samples.begin(); i != _coverage_samples.end(); ++i) {
+ for (list<ArdourCanvas::Rectangle*>::iterator i = _coverage_frame.begin(); i != _coverage_frame.end(); ++i) {
(*i)->set_y1 (h + 1);
}
- for (list<ArdourCanvas::Rectangle*>::iterator i = _silent_samples.begin(); i != _silent_samples.end(); ++i) {
+ for (list<ArdourCanvas::Rectangle*>::iterator i = _silent_frames.begin(); i != _silent_frames.end(); ++i) {
(*i)->set_y1 (h + 1);
}
}
-/** Remove old coverage samples and make new ones, if we're in a LayerDisplay mode
+/** Remove old coverage frame and make new ones, if we're in a LayerDisplay mode
* which uses them. */
void
-RegionView::update_coverage_samples (LayerDisplay d)
+RegionView::update_coverage_frame (LayerDisplay d)
{
- /* remove old coverage samples */
- for (list<ArdourCanvas::Rectangle*>::iterator i = _coverage_samples.begin (); i != _coverage_samples.end (); ++i) {
+ /* remove old coverage frame */
+ for (list<ArdourCanvas::Rectangle*>::iterator i = _coverage_frame.begin (); i != _coverage_frame.end (); ++i) {
delete *i;
}
- _coverage_samples.clear ();
+ _coverage_frame.clear ();
if (d != Stacked) {
- /* don't do coverage samples unless we're in stacked mode */
+ /* don't do coverage frame unless we're in stacked mode */
return;
}
/* start off any new rect, if required */
if (cr == 0 || me != new_me) {
cr = new ArdourCanvas::Rectangle (group);
- _coverage_samples.push_back (cr);
+ _coverage_frame.push_back (cr);
cr->set_x0 (trackview.editor().sample_to_pixel (t - position));
cr->set_y0 (1);
cr->set_y1 (_height + 1);
cr->set_x1 (trackview.editor().sample_to_pixel (end - position));
}
- if (sample_handle_start) {
- sample_handle_start->raise_to_top ();
+ if (frame_handle_start) {
+ frame_handle_start->raise_to_top ();
}
- if (sample_handle_end) {
- sample_handle_end->raise_to_top ();
+ if (frame_handle_end) {
+ frame_handle_end->raise_to_top ();
}
if (name_highlight) {
_region->trim_front (new_bound, sub_num);
if (no_overlap) {
- // Get the next region on the left of this region and shrink/expand it.
+ /* Get the next region on the left of this region and shrink/expand it. */
boost::shared_ptr<Playlist> playlist (_region->playlist());
boost::shared_ptr<Region> region_left = playlist->find_next_region (pre_trim_first_sample, End, 0);
regions_touching = true;
}
- // Only trim region on the left if the first sample has gone beyond the left region's last sample.
- if (region_left != 0 && (region_left->last_sample() > _region->first_sample() || regions_touching)) {
+ /* Only trim region on the left if the first sample has gone beyond the left region's last sample. */
+ if (region_left != 0 && (region_left->last_sample() > _region->first_sample() || regions_touching)) {
region_left->trim_end (_region->first_sample() - 1);
}
}
region_changed (ARDOUR::bounds_change);
- return (pre_trim_first_sample != _region->first_sample()); //return true if we actually changed something
+ return (pre_trim_first_sample != _region->first_sample()); // return true if we actually changed something
}
bool
_region->trim_end (new_bound, sub_num);
if (no_overlap) {
- // Get the next region on the right of this region and shrink/expand it.
+ /* Get the next region on the right of this region and shrink/expand it. */
boost::shared_ptr<Playlist> playlist (_region->playlist());
boost::shared_ptr<Region> region_right = playlist->find_next_region (pre_trim_last_sample, Start, 1);
regions_touching = true;
}
- // Only trim region on the right if the last sample has gone beyond the right region's first sample.
+ /* Only trim region on the right if the last sample has gone beyond the right region's first sample. */
if (region_right != 0 && (region_right->first_sample() < _region->last_sample() || regions_touching)) {
region_right->trim_front (_region->last_sample() + 1, sub_num);
}
region_changed (PropertyChange (ARDOUR::Properties::length));
}
- return (pre_trim_last_sample != _region->last_sample()); //return true if we actually changed something
+ return (pre_trim_last_sample != _region->last_sample()); // return true if we actually changed something
}
/* try a snap in either direction */
MusicSample sample (session_sample, 0);
- editor.snap_to (sample, RoundNearest, SnapToAny, false, ensure_snap);
+ editor.snap_to (sample, RoundNearest, SnapToAny_Visual, ensure_snap);
/* if we went off the beginning of the region, snap forwards */
if (sample.sample < _region->position ()) {
sample.sample = session_sample;
- editor.snap_to (sample, RoundUpAlways, SnapToAny, false, ensure_snap);
+ editor.snap_to (sample, RoundUpAlways, SnapToAny_Visual, ensure_snap);
}
/* back to region relative, keeping the relevant divisor */
return MusicSample (sample.sample - _region->position(), sample.division);
}
+
+void
+RegionView::update_visibility ()
+{
+ /* currently only the name visibility can be changed dynamically */
+
+ if (UIConfiguration::instance().get_show_region_name()) {
+ visibility = Visibility (visibility | ShowNameText);
+ } else {
+ visibility = Visibility (visibility & ~ShowNameText);
+ }
+
+ manage_name_text ();
+}