Ardour  9.0-pre0-582-g084a23a80d
time_axis_view_item.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2009 Nick Mainsbridge <mainsbridge@gmail.com>
3  * Copyright (C) 2005-2019 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
5  * Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
6  * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
7  * Copyright (C) 2008-2014 David Robillard <d@drobilla.net>
8  * Copyright (C) 2017-2019 Robin Gareus <robin@gareus.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 
25 #pragma once
26 
27 #include <string>
28 #include <gdk/gdk.h>
29 #include <gdkmm/color.h>
30 #include <pangomm/fontdescription.h>
31 #include "ardour/types.h"
32 #include "pbd/signals.h"
33 #include "selectable.h"
34 
35 class TimeAxisView;
36 
37 namespace ArdourCanvas {
38  class Pixbuf;
39  class Rectangle;
40  class Item;
41  class Container;
42  class Text;
43 }
44 
47 
53 {
54 public:
55  virtual ~TimeAxisViewItem();
56 
57  virtual bool set_position(Temporal::timepos_t const &, void*, double* delta = 0);
59  virtual bool set_duration(Temporal::timecnt_t const &, void*);
61  virtual void set_max_duration(Temporal::timecnt_t const &, void*);
63  virtual void set_min_duration(Temporal::timecnt_t const &, void*);
65  virtual void set_position_locked(bool, void*);
66  bool get_position_locked() const;
67  void set_max_duration_active(bool, void*);
69  void set_min_duration_active(bool, void*);
71  void set_item_name(std::string, void*);
72  virtual std::string get_item_name() const;
73  virtual void set_selected(bool yn);
74  void set_sensitive (bool yn) { _sensitive = yn; }
75  bool sensitive () const { return _sensitive; }
77  void set_name_text(const std::string&);
78  virtual void set_height(double h);
79  virtual double height() const { return _height; }
80  void set_y (double);
81  void set_color (uint32_t);
83 
84  virtual void set_frame_color();
85  virtual uint32_t get_fill_color () const;
86 
90 
91  virtual void set_samples_per_pixel (double);
92 
93  double get_samples_per_pixel () const;
94 
95  virtual void drag_start();
96  virtual void drag_end();
97  bool dragging() const { return _dragging; }
98 
99  virtual void visual_layer_on_top() {}
100  virtual void raise () {}
101  virtual void raise_to_top () {}
102  virtual void lower () {}
103  virtual void lower_to_bottom () {}
104 
106  bool name_active() const { return name_connected; }
107 
108  // Default sizes, font and spacing
109  static Pango::FontDescription NAME_FONT;
110  static void set_constant_heights ();
111  static const double NAME_X_OFFSET;
112  static const double GRAB_HANDLE_TOP;
113  static const double GRAB_HANDLE_WIDTH;
114 
115  /* these are not constant, but vary with the pixel size
116  * of the font used to display the item name.
117  */
118  static int NAME_HEIGHT;
119  static double NAME_Y_OFFSET;
120  static double NAME_HIGHLIGHT_SIZE;
121  static double NAME_HIGHLIGHT_THRESH;
122 
131  sigc::signal<void,std::string,void*> ItemRemoved;
132 
133  enum Visibility {
134  ShowFrame = 0x1,
137  ShowHandles = 0x8,
140  HideFrameTB = 0x40,
142  };
143 
144  virtual void update_visibility () {}
145 
146 protected:
147  TimeAxisViewItem (const std::string &, ArdourCanvas::Item&, TimeAxisView&, double, uint32_t fill_color,
148  Temporal::timepos_t const &, Temporal::timecnt_t const &, bool recording = false, bool automation = false, Visibility v = Visibility (0));
149 
151 
152  void init (ArdourCanvas::Item*, double, uint32_t, Temporal::timepos_t const &, Temporal::timecnt_t const &, Visibility, bool, bool);
153 
154  virtual bool canvas_group_event (GdkEvent*);
155 
156  virtual void set_colors();
157  virtual void set_frame_gradient ();
158 
160 
161  virtual void reset_width_dependent_items (double);
162 
164 
167 
170 
173 
176 
179 
182 
185 
188 
191 
194 
199  std::string item_name;
200 
203 
204  uint32_t fill_color;
205 
206  uint32_t last_item_width;
210 
212 
217 
218  /* with these two values, if frame_handle_start == 0 then frame_handle_end will also be 0 */
221 
223 
224  double _height;
226  std::string fill_color_name;
228  bool _automation;
229  bool _dragging;
230  double _width;
231 
233 
234 private:
235  void parameter_changed (std::string);
237 
238 }; /* class TimeAxisViewItem */
239 
bool get_max_duration_active() const
ArdourCanvas::Text * name_text
ArdourCanvas::Rectangle * name_highlight
void manage_name_text()
TimeAxisView & get_time_axis_view() const
ArdourCanvas::Rectangle * frame_handle_end
‘frame’ (fade) handle for the end of the item, or 0
virtual void drag_end()
virtual void update_visibility()
Temporal::timepos_t time_position
void manage_name_highlight()
static const double NAME_X_OFFSET
void set_max_duration_active(bool, void *)
Temporal::timepos_t get_position() const
bool _automation
true if this is an automation region view
virtual void set_min_duration(Temporal::timecnt_t const &, void *)
virtual bool canvas_group_event(GdkEvent *)
virtual void set_frame_gradient()
static double NAME_HIGHLIGHT_THRESH
static double NAME_HIGHLIGHT_SIZE
void set_sensitive(bool yn)
void set_item_name(std::string, void *)
bool get_min_duration_active() const
ArdourCanvas::Container * group
Temporal::timecnt_t min_item_duration
virtual void set_height(double h)
ArdourCanvas::Item * get_canvas_frame()
virtual void raise_to_top()
static double NAME_Y_OFFSET
bool get_position_locked() const
TimeAxisViewItem(const TimeAxisViewItem &)
virtual bool set_duration(Temporal::timecnt_t const &, void *)
void init(ArdourCanvas::Item *, double, uint32_t, Temporal::timepos_t const &, Temporal::timecnt_t const &, Visibility, bool, bool)
bool name_active() const
virtual uint32_t get_fill_color() const
virtual std::string get_item_name() const
virtual void set_selected(bool yn)
Temporal::timecnt_t max_item_duration
virtual void set_frame_color()
void set_name_text_color()
static gint idle_remove_this_item(TimeAxisViewItem *, void *)
void set_color(uint32_t)
void set_y(double)
TimeAxisView & trackview
sigc::signal< void, std::string, void * > ItemRemoved
virtual void set_samples_per_pixel(double)
ArdourCanvas::Item * get_canvas_group() const
virtual bool set_position(Temporal::timepos_t const &, void *, double *delta=0)
std::string fill_color_name
ArdourCanvas::Rectangle * frame_handle_start
‘frame’ (fade) handle for the start of the item, or 0
static const double GRAB_HANDLE_TOP
Temporal::timecnt_t item_duration
virtual double height() const
virtual void lower_to_bottom()
bool sensitive() const
static Pango::FontDescription NAME_FONT
ArdourCanvas::Item * get_name_highlight()
Temporal::timecnt_t get_max_duration() const
static const double GRAB_HANDLE_WIDTH
static void set_constant_heights()
Temporal::timecnt_t get_min_duration() const
virtual void visual_layer_on_top()
bool frame_handle_crossing(GdkEvent *, ArdourCanvas::Rectangle *)
virtual void lower()
virtual void set_position_locked(bool, void *)
virtual void set_max_duration(Temporal::timecnt_t const &, void *)
void parameter_changed(std::string)
TimeAxisViewItem(const std::string &, ArdourCanvas::Item &, TimeAxisView &, double, uint32_t fill_color, Temporal::timepos_t const &, Temporal::timecnt_t const &, bool recording=false, bool automation=false, Visibility v=Visibility(0))
void set_name_text(const std::string &)
virtual ~TimeAxisViewItem()
virtual void reset_width_dependent_items(double)
ArdourCanvas::Rectangle * selection_frame
void set_min_duration_active(bool, void *)
void set_trim_handle_colors()
virtual void set_colors()
ArdourCanvas::Rectangle * frame
virtual void drag_start()
double get_samples_per_pixel() const
Temporal::timecnt_t get_duration() const
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t