2 * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
3 * Copyright (C) 2007-2011 Carl Hetherington <carl@carlh.net>
4 * Copyright (C) 2007-2019 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2007 Doug McLain <doug@nostar.net>
6 * Copyright (C) 2015-2017 Nick Mainsbridge <mainsbridge@gmail.com>
7 * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #ifndef __gtk_ardour_region_view_h__
25 #define __gtk_ardour_region_view_h__
33 #include <sigc++/signal.h>
34 #include "ardour/region.h"
35 #include "ardour/beats_samples_converter.h"
37 #include "canvas/fwd.h"
39 #include "time_axis_view_item.h"
40 #include "automation_line.h"
46 class AutomationTimeAxisView;
47 class AutomationRegionView;
49 namespace ArdourCanvas {
54 class RegionView : public TimeAxisViewItem
57 RegionView (ArdourCanvas::Container* parent,
58 TimeAxisView& time_view,
59 boost::shared_ptr<ARDOUR::Region> region,
60 double samples_per_pixel,
62 bool automation = false);
64 RegionView (const RegionView& other);
65 RegionView (const RegionView& other, boost::shared_ptr<ARDOUR::Region> other_region);
69 virtual void set_selected (bool yn) {
70 _region->set_selected_for_solo(yn);
71 TimeAxisViewItem::set_selected(yn);
74 virtual void init (bool wait_for_data);
76 boost::shared_ptr<ARDOUR::Region> region() const { return _region; }
78 bool is_valid() const { return valid; }
80 void set_valid (bool yn) { valid = yn; }
82 virtual void set_height (double);
83 virtual void set_samples_per_pixel (double);
84 virtual bool set_duration (samplecnt_t, void*);
86 void move (double xdelta, double ydelta);
89 void lower_to_bottom ();
91 bool set_position(samplepos_t pos, void* src, double* delta = 0);
93 virtual void show_region_editor ();
94 void hide_region_editor ();
96 virtual void region_changed (const PBD::PropertyChange&);
98 uint32_t get_fill_color () const;
100 virtual GhostRegion* add_ghost (TimeAxisView&) = 0;
101 void remove_ghost_in (TimeAxisView&);
102 void remove_ghost (GhostRegion*);
104 virtual void entered () {}
105 virtual void exited () {}
107 virtual void enable_display(bool yn) { _enable_display = yn; }
108 virtual void update_coverage_frame (LayerDisplay);
110 static PBD::Signal1<void,RegionView*> RegionViewGoingAway;
112 /** Called when a front trim is about to begin */
113 virtual void trim_front_starting () {}
115 bool trim_front (samplepos_t, bool, const int32_t sub_num);
117 /** Called when a start trim has finished */
118 virtual void trim_front_ending () {}
120 bool trim_end (samplepos_t, bool, const int32_t sub_num);
121 void move_contents (ARDOUR::sampleoffset_t);
122 virtual void thaw_after_trim ();
124 void set_silent_frames (const ARDOUR::AudioIntervalResult&, double threshold);
125 void drop_silent_frames ();
126 void hide_silent_frames ();
128 struct PositionOrder {
129 bool operator()(const RegionView* a, const RegionView* b) {
130 return a->region()->position() < b->region()->position();
134 ARDOUR::MusicSample snap_sample_to_sample (ARDOUR::sampleoffset_t, bool ensure_snap = false) const;
136 void update_visibility ();
140 /** Allows derived types to specify their visibility requirements
141 * to the TimeAxisViewItem parent class
143 RegionView (ArdourCanvas::Container *,
145 boost::shared_ptr<ARDOUR::Region>,
146 double samples_per_pixel,
147 uint32_t basic_color,
149 TimeAxisViewItem::Visibility);
151 bool canvas_group_event (GdkEvent*);
153 virtual void region_resized (const PBD::PropertyChange&);
154 virtual void region_muted ();
155 void region_locked ();
156 void region_opacity ();
157 virtual void region_renamed ();
158 void region_sync_changed ();
160 std::string make_name () const;
162 static gint _lock_toggle (ArdourCanvas::Item*, GdkEvent*, void*);
165 virtual void set_colors ();
166 virtual void set_sync_mark_color ();
167 virtual void reset_width_dependent_items (double pixel_width);
169 virtual void color_handler () {}
171 boost::shared_ptr<ARDOUR::Region> _region;
173 ArdourCanvas::Polygon* sync_mark; ///< polgyon for sync position
174 ArdourCanvas::Line* sync_line; ///< polgyon for sync position
176 RegionEditor* editor;
178 std::vector<ControlPoint *> control_points;
179 double current_visible_sync_position;
181 bool valid; ///< see StreamView::redisplay_diskstream()
182 bool _enable_display; ///< see StreamView::redisplay_diskstream()
188 std::vector<GhostRegion*> ghosts;
190 /** a list of rectangles which are used in stacked display mode to colour
191 * different bits of regions according to whether or not they are the one
192 * that will be played at any given time.
194 std::list<ArdourCanvas::Rectangle*> _coverage_frame;
196 /** a list of rectangles used to show silent segments
198 std::list<ArdourCanvas::Rectangle*> _silent_frames;
199 /** a list of rectangles used to show the current silence threshold
201 std::list<ArdourCanvas::Rectangle*> _silent_threshold_samples;
202 /** a text item to display strip silence statistics */
203 ArdourCanvas::Text* _silence_text;
206 #endif /* __gtk_ardour_region_view_h__ */