1 /* 2 * Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com> 3 * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com> 4 * Copyright (C) 2008-2011 David Robillard <d@drobilla.net> 5 * Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net> 6 * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org> 7 * Copyright (C) 2016-2017 Nick Mainsbridge <mainsbridge@gmail.com> 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_marker_h__ 25 #define __gtk_ardour_marker_h__ 26 27 #include <string> 28 #include <glib.h> 29 30 #include <sigc++/signal.h> 31 32 #include "ardour/ardour.h" 33 #include "pbd/signals.h" 34 35 #include "canvas/fwd.h" 36 #include "canvas/types.h" 37 38 namespace ARDOUR { 39 class TempoSection; 40 class MeterSection; 41 } 42 43 class PublicEditor; 44 class RegionView; 45 46 /** Location Marker 47 * 48 * Editor ruler representation of a location marker or range on the timeline. 49 */ 50 class ArdourMarker : public sigc::trackable 51 { 52 public: 53 enum Type { 54 Mark, 55 Tempo, 56 Meter, 57 SessionStart, ///< session start 58 SessionEnd, ///< session end 59 RangeStart, 60 RangeEnd, 61 LoopStart, 62 LoopEnd, 63 PunchIn, 64 PunchOut, 65 RegionCue 66 }; 67 68 69 ArdourMarker (PublicEditor& editor, ArdourCanvas::Container &, guint32 rgba, const std::string& text, Type, 70 samplepos_t sample = 0, bool handle_events = true, RegionView* rv = 0); 71 72 virtual ~ArdourMarker (); 73 74 static PBD::Signal1<void,ArdourMarker*> CatchDeletion; 75 76 static void setup_sizes (const double timebar_height); 77 78 ArdourCanvas::Item& the_item() const; 79 80 void set_selected (bool); 81 void set_entered (bool); 82 void set_show_line (bool); 83 void set_line_height (double); 84 85 void set_position (samplepos_t); 86 void set_name (const std::string&); 87 void set_points_color (uint32_t rgba); 88 void set_color_rgba (uint32_t rgba); 89 void setup_line (); 90 position()91 samplepos_t position() const { return sample_position; } 92 get_parent()93 ArdourCanvas::Container * get_parent() { return _parent; } 94 void reparent (ArdourCanvas::Container & parent); 95 96 void hide (); 97 void show (); 98 type()99 Type type () { return _type; } 100 101 void set_left_label_limit (double); 102 void set_right_label_limit (double); 103 name()104 std::string name () const { 105 return _name; 106 } 107 108 bool label_on_left () const; 109 110 /* this will be null for all global markers; non-null for region markers */ 111 region_view()112 RegionView* region_view() const { return _region_view; } 113 114 protected: 115 PublicEditor& editor; 116 117 Pango::FontDescription name_font; 118 119 ArdourCanvas::Container* _parent; 120 ArdourCanvas::Container *group; 121 ArdourCanvas::Polygon *mark; 122 ArdourCanvas::Text *_name_item; 123 ArdourCanvas::Points *points; 124 ArdourCanvas::Line* _track_canvas_line; 125 ArdourCanvas::Rectangle* _name_background; 126 127 std::string _name; 128 double unit_position; 129 samplepos_t sample_position; 130 double _shift; 131 Type _type; 132 int name_height; 133 bool _selected; 134 bool _entered; 135 bool _shown; 136 bool _line_shown; 137 uint32_t _color; 138 uint32_t pre_enter_color; 139 uint32_t _points_color; 140 double _left_label_limit; ///< the number of pixels available to the left of this marker for a label 141 double _right_label_limit; ///< the number of pixels available to the right of this marker for a label 142 double _label_offset; 143 double _line_height; 144 145 RegionView* _region_view; 146 147 void reposition (); 148 void setup_line_x (); 149 void setup_name_display (); 150 151 private: 152 /* disallow copy construction */ 153 ArdourMarker (ArdourMarker const &); 154 ArdourMarker & operator= (ArdourMarker const &); 155 }; 156 157 class TempoMarker : public ArdourMarker 158 { 159 public: 160 TempoMarker (PublicEditor& editor, ArdourCanvas::Container &, guint32 rgba, const std::string& text, ARDOUR::TempoSection&); 161 ~TempoMarker (); 162 tempo()163 ARDOUR::TempoSection& tempo() const { return _tempo; } 164 165 void update_height_mark (const double ratio); 166 private: 167 ARDOUR::TempoSection& _tempo; 168 }; 169 170 class MeterMarker : public ArdourMarker 171 { 172 public: 173 MeterMarker (PublicEditor& editor, ArdourCanvas::Container &, guint32 rgba, const std::string& text, ARDOUR::MeterSection&); 174 ~MeterMarker (); 175 meter()176 ARDOUR::MeterSection& meter() const { return _meter; } 177 178 private: 179 ARDOUR::MeterSection& _meter; 180 }; 181 182 #endif /* __gtk_ardour_marker_h__ */ 183