1 /* 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> 8 * 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. 13 * 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. 18 * 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. 22 */ 23 24 #ifndef __gtk_ardour_region_view_h__ 25 #define __gtk_ardour_region_view_h__ 26 27 #ifdef interface 28 #undef interface 29 #endif 30 31 #include <vector> 32 33 #include <sigc++/signal.h> 34 #include "ardour/region.h" 35 #include "ardour/beats_samples_converter.h" 36 37 #include "canvas/fwd.h" 38 39 #include "time_axis_view_item.h" 40 #include "automation_line.h" 41 #include "enums.h" 42 #include "marker.h" 43 44 class TimeAxisView; 45 class RegionEditor; 46 class GhostRegion; 47 class AutomationTimeAxisView; 48 class AutomationRegionView; 49 50 namespace ArdourCanvas { 51 class Polygon; 52 class Text; 53 } 54 55 class RegionView : public TimeAxisViewItem 56 { 57 public: 58 RegionView (ArdourCanvas::Container* parent, 59 TimeAxisView& time_view, 60 boost::shared_ptr<ARDOUR::Region> region, 61 double samples_per_pixel, 62 uint32_t base_color, 63 bool automation = false); 64 65 RegionView (const RegionView& other); 66 RegionView (const RegionView& other, boost::shared_ptr<ARDOUR::Region> other_region); 67 68 ~RegionView (); 69 70 void set_selected (bool yn); 71 72 virtual void init (bool wait_for_data); 73 region()74 boost::shared_ptr<ARDOUR::Region> region() const { return _region; } 75 is_valid()76 bool is_valid() const { return valid; } 77 set_valid(bool yn)78 void set_valid (bool yn) { valid = yn; } 79 80 virtual void set_height (double); 81 virtual void set_samples_per_pixel (double); 82 virtual bool set_duration (samplecnt_t, void*); 83 84 void move (double xdelta, double ydelta); 85 86 void raise_to_top (); 87 void lower_to_bottom (); 88 89 bool set_position(samplepos_t pos, void* src, double* delta = 0); 90 91 virtual void show_region_editor (); 92 void hide_region_editor (); 93 94 virtual void region_changed (const PBD::PropertyChange&); 95 96 uint32_t get_fill_color () const; 97 98 virtual GhostRegion* add_ghost (TimeAxisView&) = 0; 99 void remove_ghost_in (TimeAxisView&); 100 void remove_ghost (GhostRegion*); 101 entered()102 virtual void entered () {} exited()103 virtual void exited () {} 104 enable_display(bool yn)105 virtual void enable_display(bool yn) { _enable_display = yn; } 106 virtual void update_coverage_frame (LayerDisplay); 107 108 static PBD::Signal1<void,RegionView*> RegionViewGoingAway; 109 110 /** Called when a front trim is about to begin */ trim_front_starting()111 virtual void trim_front_starting () {} 112 113 bool trim_front (samplepos_t, bool, const int32_t sub_num); 114 115 /** Called when a start trim has finished */ trim_front_ending()116 virtual void trim_front_ending () {} 117 118 bool trim_end (samplepos_t, bool, const int32_t sub_num); 119 void move_contents (ARDOUR::sampleoffset_t); 120 virtual void thaw_after_trim (); 121 122 void set_silent_frames (const ARDOUR::AudioIntervalResult&, double threshold); 123 void drop_silent_frames (); 124 void hide_silent_frames (); 125 126 struct PositionOrder { operatorPositionOrder127 bool operator()(const RegionView* a, const RegionView* b) { 128 return a->region()->position() < b->region()->position(); 129 } 130 }; 131 132 ARDOUR::MusicSample snap_sample_to_sample (ARDOUR::sampleoffset_t, bool ensure_snap = false) const; 133 134 void update_visibility (); 135 136 ARDOUR::CueMarker find_model_cue_marker (ArdourMarker*); 137 void drop_cue_marker (ArdourMarker*); 138 139 protected: 140 141 /** Allows derived types to specify their visibility requirements 142 * to the TimeAxisViewItem parent class 143 */ 144 RegionView (ArdourCanvas::Container *, 145 TimeAxisView&, 146 boost::shared_ptr<ARDOUR::Region>, 147 double samples_per_pixel, 148 uint32_t basic_color, 149 bool recording, 150 TimeAxisViewItem::Visibility); 151 152 bool canvas_group_event (GdkEvent*); 153 154 virtual void region_resized (const PBD::PropertyChange&); 155 virtual void region_muted (); 156 void region_locked (); 157 void region_opacity (); 158 virtual void region_renamed (); 159 void region_sync_changed (); 160 161 std::string make_name () const; 162 163 static gint _lock_toggle (ArdourCanvas::Item*, GdkEvent*, void*); 164 void lock_toggle (); 165 166 virtual void set_colors (); 167 virtual void set_sync_mark_color (); 168 virtual void reset_width_dependent_items (double pixel_width); 169 color_handler()170 virtual void color_handler () {} 171 virtual void parameter_changed (std::string const&); 172 173 void maybe_raise_cue_markers (); 174 175 boost::shared_ptr<ARDOUR::Region> _region; 176 177 ArdourCanvas::Polygon* sync_mark; ///< polgyon for sync position 178 ArdourCanvas::Line* sync_line; ///< polgyon for sync position 179 180 RegionEditor* editor; 181 182 std::vector<ControlPoint *> control_points; 183 double current_visible_sync_position; 184 185 bool valid; ///< see StreamView::redisplay_diskstream() 186 bool _enable_display; ///< see StreamView::redisplay_diskstream() 187 double _pixel_width; 188 bool in_destructor; 189 190 bool wait_for_data; 191 192 std::vector<GhostRegion*> ghosts; 193 194 /** a list of rectangles which are used in stacked display mode to colour 195 * different bits of regions according to whether or not they are the one 196 * that will be played at any given time. 197 */ 198 std::list<ArdourCanvas::Rectangle*> _coverage_frame; 199 200 /** a list of rectangles used to show silent segments 201 */ 202 std::list<ArdourCanvas::Rectangle*> _silent_frames; 203 /** a list of rectangles used to show the current silence threshold 204 */ 205 std::list<ArdourCanvas::Rectangle*> _silent_threshold_samples; 206 /** a text item to display strip silence statistics */ 207 ArdourCanvas::Text* _silence_text; 208 209 private: 210 void update_xrun_markers (); 211 std::list<std::pair<samplepos_t, ArdourCanvas::Arrow*> > _xrun_markers; 212 bool _xrun_markers_visible; 213 214 void update_cue_markers (); 215 216 struct ViewCueMarker { 217 ArdourMarker* view_marker; 218 ARDOUR::CueMarker model_marker; 219 ViewCueMarkerViewCueMarker220 ViewCueMarker (ArdourMarker* m, ARDOUR::CueMarker const & c) : view_marker (m), model_marker (c) {} 221 ~ViewCueMarker(); 222 }; 223 224 typedef std::list<ViewCueMarker*> ViewCueMarkers; 225 ViewCueMarkers _cue_markers; 226 bool _cue_markers_visible; 227 }; 228 229 #endif /* __gtk_ardour_region_view_h__ */ 230