Ardour  9.0-pre0-350-gf17a656217
marker.h
Go to the documentation of this file.
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 #pragma once
25 
26 #include <string>
27 #include <glib.h>
28 
29 #include <sigc++/signal.h>
30 
31 #include "ardour/ardour.h"
32 #include "pbd/signals.h"
33 
34 #include "canvas/fwd.h"
35 #include "canvas/types.h"
36 #include "canvas/circle.h"
37 #include "canvas/text.h"
38 
39 namespace Temporal {
40  class Point;
41  class TempoPoint;
42  class MeterPoint;
43  class MusicTimePoint;
44 }
45 
46 class PublicEditor;
47 class RegionView;
48 class TempoCurve;
49 
54 class ArdourMarker : public sigc::trackable
55 {
56 public:
57  enum Type {
72  Cue,
75  };
76 
77 
78  ArdourMarker (PublicEditor& editor, ArdourCanvas::Item &, std::string const& color_name, std::string const& text, Type,
79  Temporal::timepos_t const & position, bool handle_events = true, RegionView* rv = nullptr, bool use_tooltip = true);
80 
81  virtual ~ArdourMarker ();
82 
84 
85  static void setup_sizes (const double timebar_height);
86 
88 
89  void set_selected (bool);
90  void set_entered (bool);
91  void set_show_line (bool);
92  void set_line_height (double);
93 
94  virtual void reposition ();
95  virtual void set_position (Temporal::timepos_t const &);
96  void set_name (const std::string&, const std::string & tooltip = std::string());
97  void set_color (std::string const& color_name);
98  void set_points_color (std::string const& color_name);
99  void setup_line ();
100 
102 
104  void reparent (ArdourCanvas::Item & parent);
105 
106  void hide ();
107  void show ();
108 
109  Type type () { return _type; }
110 
111  void set_left_label_limit (double);
112  void set_right_label_limit (double);
113 
114  std::string name () const {
115  return _name;
116  }
117 
118  bool label_on_left () const;
119 
120  /* this will be null for all global markers; non-null for region markers */
121 
122  RegionView* region_view() const { return _region_view; }
123 
124  /* this will be -1 for all non-cue markers; or cue_index for cue markers */
125 
126  void set_cue_index(int c) { _cue_index = c; set_name(_name); }
127  int cue_index() const { return _cue_index; }
128 
129 protected:
131 
132  Pango::FontDescription name_font;
133 
142 
143  std::string _name;
146  double _shift;
150  bool _selected;
151  bool _entered;
152  bool _shown;
155 
156  std::string _color;
157  std::string _points_color;
158 
162  double _line_height;
163 
165 
167 
168  void setup_line_x ();
170 
171 private:
172  /* disallow copy construction */
175 
176  static uint32_t color (std::string const&);
177  void apply_color ();
178  void color_handler ();
179 };
180 
182 {
183  public:
184  SelectionMarker (PublicEditor& ed, ArdourCanvas::Item& parent, std::string const& color_name, Type);
185 };
186 
188 {
189  public:
190  MetricMarker (PublicEditor& ed, ArdourCanvas::Item& parent, std::string const& color_name, const std::string& annotation, Type type, Temporal::timepos_t const & pos, bool handle_events);
191  virtual Temporal::Point const & point() const = 0;
192  virtual void update() = 0;
193 };
194 
195 class TempoMarker : public MetricMarker
196 {
197  public:
198  TempoMarker (PublicEditor& editor, ArdourCanvas::Item & parent, std::string const& color_name, const std::string& text, Temporal::TempoPoint const &, samplepos_t sample, uint32_t curve_color);
200 
202  void update ();
203  void reposition ();
204 
205  Temporal::TempoPoint const & tempo() const { return *_tempo; }
206  Temporal::Point const & point() const;
207 
209 
210  private:
213 };
214 
215 class MeterMarker : public MetricMarker
216 {
217  public:
218  MeterMarker (PublicEditor& editor, ArdourCanvas::Item &, std::string const& color_name, const std::string& text, Temporal::MeterPoint const &);
220 
222  void update ();
223 
224  Temporal::MeterPoint const & meter() const { return *_meter; }
225  Temporal::Point const & point() const;
226 
227  private:
229 };
230 
231 class BBTMarker : public MetricMarker
232 {
233  public:
234  BBTMarker (PublicEditor& editor, ArdourCanvas::Item &, std::string const& color_name, Temporal::MusicTimePoint const &);
236 
238  void update ();
240 
241  Temporal::MusicTimePoint const & mt_point() const { return *_point; }
242  Temporal::Point const & point() const;
243 
244  private:
248 };
249 
void set_show_line(bool)
virtual void set_position(Temporal::timepos_t const &)
void set_right_label_limit(double)
void reparent(ArdourCanvas::Item &parent)
ArdourCanvas::Polygon * _pmark
Definition: marker.h:137
ArdourCanvas::Rectangle * _name_flag
Definition: marker.h:141
@ BBTPosition
Definition: marker.h:61
@ SessionStart
session start
Definition: marker.h:62
@ SelectionStart
Definition: marker.h:73
@ SessionEnd
session end
Definition: marker.h:63
@ SelectionEnd
Definition: marker.h:74
@ PunchOut
Definition: marker.h:70
@ RegionCue
Definition: marker.h:71
@ RangeStart
Definition: marker.h:65
@ LoopStart
Definition: marker.h:67
@ RangeEnd
Definition: marker.h:66
double _left_label_limit
the number of pixels available to the left of this marker for a label
Definition: marker.h:159
ArdourCanvas::Item * get_parent()
Definition: marker.h:103
bool _entered
Definition: marker.h:151
void color_handler()
PublicEditor & editor
Definition: marker.h:130
bool _shown
Definition: marker.h:152
double _label_offset
Definition: marker.h:161
void set_entered(bool)
std::string name() const
Definition: marker.h:114
void setup_line()
Type _type
Definition: marker.h:147
virtual void reposition()
int name_descent
Definition: marker.h:149
ArdourMarker(PublicEditor &editor, ArdourCanvas::Item &, std::string const &color_name, std::string const &text, Type, Temporal::timepos_t const &position, bool handle_events=true, RegionView *rv=nullptr, bool use_tooltip=true)
std::string _name
Definition: marker.h:143
static void setup_sizes(const double timebar_height)
bool _selected
Definition: marker.h:150
void setup_name_display()
bool _line_shown
Definition: marker.h:153
ArdourCanvas::Item * group
Definition: marker.h:135
void set_left_label_limit(double)
static PBD::Signal< void(ArdourMarker *)> CatchDeletion
Definition: marker.h:83
int cue_index() const
Definition: marker.h:127
void setup_line_x()
std::string _points_color
Definition: marker.h:157
void set_line_height(double)
Type type()
Definition: marker.h:109
void set_name(const std::string &, const std::string &tooltip=std::string())
bool _use_tooltip
Definition: marker.h:154
void set_points_color(std::string const &color_name)
ArdourMarker(ArdourMarker const &)
Pango::FontDescription name_font
Definition: marker.h:132
ARDOUR::timepos_t _position
Definition: marker.h:145
ArdourMarker & operator=(ArdourMarker const &)
RegionView * _region_view
Definition: marker.h:164
void set_selected(bool)
ArdourCanvas::Item & the_item() const
void set_cue_index(int c)
Definition: marker.h:126
RegionView * region_view() const
Definition: marker.h:122
static uint32_t color(std::string const &)
void set_color(std::string const &color_name)
double _line_height
Definition: marker.h:162
std::string _color
Definition: marker.h:156
ArdourCanvas::Item * _parent
Definition: marker.h:134
ArdourCanvas::Text * _name_item
Definition: marker.h:138
ArdourCanvas::Line * _track_canvas_line
Definition: marker.h:140
double _shift
Definition: marker.h:146
double unit_position
Definition: marker.h:144
int name_height
Definition: marker.h:148
void apply_color()
virtual ~ArdourMarker()
ARDOUR::timepos_t position() const
Definition: marker.h:101
bool label_on_left() const
int _cue_index
Definition: marker.h:166
ArdourCanvas::Circle * _pcue
Definition: marker.h:136
double _right_label_limit
the number of pixels available to the right of this marker for a label
Definition: marker.h:160
ArdourCanvas::Points * points
Definition: marker.h:139
void set_position(Temporal::timepos_t const &)
BBTMarker(PublicEditor &editor, ArdourCanvas::Item &, std::string const &color_name, Temporal::MusicTimePoint const &)
Temporal::Point const & point() const
Temporal::MusicTimePoint const * _point
Definition: marker.h:245
MeterMarker * meter_marker
Definition: marker.h:247
TempoMarker * tempo_marker
Definition: marker.h:246
Temporal::MusicTimePoint const & mt_point() const
Definition: marker.h:241
void update()
void reset_point(Temporal::MusicTimePoint const &)
Temporal::Point const & point() const
void update()
MeterMarker(PublicEditor &editor, ArdourCanvas::Item &, std::string const &color_name, const std::string &text, Temporal::MeterPoint const &)
void reset_meter(Temporal::MeterPoint const &m)
Temporal::MeterPoint const * _meter
Definition: marker.h:228
Temporal::MeterPoint const & meter() const
Definition: marker.h:224
MetricMarker(PublicEditor &ed, ArdourCanvas::Item &parent, std::string const &color_name, const std::string &annotation, Type type, Temporal::timepos_t const &pos, bool handle_events)
virtual Temporal::Point const & point() const =0
virtual void update()=0
Representation of the interface of the Editor class.
SelectionMarker(PublicEditor &ed, ArdourCanvas::Item &parent, std::string const &color_name, Type)
void reset_tempo(Temporal::TempoPoint const &t)
TempoMarker(PublicEditor &editor, ArdourCanvas::Item &parent, std::string const &color_name, const std::string &text, Temporal::TempoPoint const &, samplepos_t sample, uint32_t curve_color)
Temporal::Point const & point() const
Temporal::TempoPoint const * _tempo
Definition: marker.h:211
TempoCurve * _curve
Definition: marker.h:212
void update()
TempoCurve & curve()
void reposition()
Temporal::TempoPoint const & tempo() const
Definition: marker.h:205
Temporal::samplepos_t samplepos_t
std::vector< Duple > Points