ardour
time_axis_view_item.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #ifndef __gtk_ardour_time_axis_view_item_h__
21 #define __gtk_ardour_time_axis_view_item_h__
22 
23 #include <string>
24 #include <gdk/gdk.h>
25 #include <gdkmm/color.h>
26 #include <pangomm/fontdescription.h>
27 #include "pbd/signals.h"
28 #include "selectable.h"
29 
30 class TimeAxisView;
31 
32 namespace ArdourCanvas {
33  class Pixbuf;
34  class Rectangle;
35  class Item;
36  class Container;
37  class Text;
38 }
39 
40 using ARDOUR::framepos_t;
41 using ARDOUR::framecnt_t;
42 
48 {
49  public:
50  virtual ~TimeAxisViewItem();
51 
52  virtual bool set_position(framepos_t, void*, double* delta = 0);
53  framepos_t get_position() const;
54  virtual bool set_duration(framecnt_t, void*);
55  framecnt_t get_duration() const;
56  virtual void set_max_duration(framecnt_t, void*);
58  virtual void set_min_duration(framecnt_t, void*);
60  virtual void set_position_locked(bool, void*);
61  bool get_position_locked() const;
62  void set_max_duration_active(bool, void*);
63  bool get_max_duration_active() const;
64  void set_min_duration_active(bool, void*);
65  bool get_min_duration_active() const;
66  void set_item_name(std::string, void*);
67  virtual std::string get_item_name() const;
68  virtual void set_selected(bool yn);
69  void set_sensitive (bool yn) { _sensitive = yn; }
70  bool sensitive () const { return _sensitive; }
72  void set_name_text(const std::string&);
73  virtual void set_height(double h);
74  virtual double height() const { return _height; }
75  void set_y (double);
76  void set_color (uint32_t);
77  void set_name_text_color ();
78 
79  virtual uint32_t get_fill_color () const;
80 
81  ArdourCanvas::Item* get_canvas_frame();
82  ArdourCanvas::Item* get_canvas_group();
83  ArdourCanvas::Item* get_name_highlight();
84 
85  virtual void set_samples_per_pixel (double);
86 
87  double get_samples_per_pixel () const;
88 
89  virtual void drag_start();
90  virtual void drag_end();
91  bool dragging() const { return _dragging; }
92 
93  virtual void raise () { return; }
94  virtual void raise_to_top () { return; }
95  virtual void lower () { return; }
96  virtual void lower_to_bottom () { return; }
97 
99  bool name_active() const { return name_connected; }
100 
101  // Default sizes, font and spacing
102  static Pango::FontDescription NAME_FONT;
103  static void set_constant_heights ();
104  static const double NAME_X_OFFSET;
105  static const double GRAB_HANDLE_TOP;
106  static const double GRAB_HANDLE_WIDTH;
107 
108  /* these are not constant, but vary with the pixel size
109  of the font used to display the item name.
110  */
111  static int NAME_HEIGHT;
112  static double NAME_Y_OFFSET;
113  static double NAME_HIGHLIGHT_SIZE;
114  static double NAME_HIGHLIGHT_THRESH;
115 
124  sigc::signal<void,std::string,void*> ItemRemoved;
125 
127  sigc::signal<void,std::string,std::string,void*> NameChanged;
128 
130  sigc::signal<void,framepos_t,void*> PositionChanged;
131 
133  sigc::signal<void,bool,void*> PositionLockChanged;
134 
136  sigc::signal<void,framecnt_t,void*> DurationChanged;
137 
139  sigc::signal<void,framecnt_t,void*> MaxDurationChanged;
140 
142  sigc::signal<void,framecnt_t,void*> MinDurationChanged;
143 
144  enum Visibility {
145  ShowFrame = 0x1,
148  ShowHandles = 0x8,
151  HideFrameTB = 0x40,
153  };
154 
155  protected:
156  TimeAxisViewItem (const std::string &, ArdourCanvas::Item&, TimeAxisView&, double, uint32_t fill_color,
157  framepos_t, framecnt_t, bool recording = false, bool automation = false, Visibility v = Visibility (0));
158 
160 
161  void init (ArdourCanvas::Item*, double, uint32_t, framepos_t, framepos_t, Visibility, bool, bool);
162 
163  virtual bool canvas_group_event (GdkEvent*);
164 
165  virtual void set_colors();
166  virtual void set_frame_color();
167  virtual void set_frame_gradient ();
168  void set_trim_handle_colors();
169 
170  virtual void reset_width_dependent_items (double);
171 
172  static gint idle_remove_this_item(TimeAxisViewItem*, void*);
173 
176 
179 
182 
185 
188 
191 
194 
197 
200 
203 
208  std::string item_name;
209 
212 
215 
216  uint32_t fill_color;
217 
218  uint32_t last_item_width;
222 
223  ArdourCanvas::Container* group;
224  ArdourCanvas::Rectangle* vestigial_frame;
225  ArdourCanvas::Rectangle* frame;
226  ArdourCanvas::Rectangle* selection_frame;
227  ArdourCanvas::Text* name_text;
228  ArdourCanvas::Rectangle* name_highlight;
229 
230  /* with these two values, if frame_handle_start == 0 then frame_handle_end will also be 0 */
231  ArdourCanvas::Rectangle* frame_handle_start;
232  ArdourCanvas::Rectangle* frame_handle_end;
233 
234  bool frame_handle_crossing (GdkEvent*, ArdourCanvas::Rectangle*);
235 
236  double _height;
238  std::string fill_color_name;
240  bool _automation;
241  bool _dragging;
242 
243 private:
244  double _width;
245 
246  void parameter_changed (std::string);
247  void manage_name_highlight ();
248  void manage_name_text ();
249 
250 }; /* class TimeAxisViewItem */
251 
252 #endif /* __gtk_ardour_time_axis_view_item_h__ */
static Pango::FontDescription NAME_FONT
ArdourCanvas::Item * get_canvas_frame()
ArdourCanvas::Item * get_canvas_group()
virtual void set_height(double h)
TimeAxisView & get_time_axis_view() const
virtual void drag_end()
sigc::signal< void, bool, void * > PositionLockChanged
bool get_min_duration_active() const
static double NAME_HIGHLIGHT_THRESH
static gint idle_remove_this_item(TimeAxisViewItem *, void *)
void parameter_changed(std::string)
bool get_position_locked() const
sigc::signal< void, framecnt_t, void * > MinDurationChanged
static void set_constant_heights()
virtual void lower_to_bottom()
virtual void set_frame_gradient()
virtual uint32_t get_fill_color() const
ArdourCanvas::Rectangle * vestigial_frame
TimeAxisView & trackview
virtual void set_position_locked(bool, void *)
std::string fill_color_name
virtual std::string get_item_name() const
ArdourCanvas::Text * name_text
ArdourCanvas::Rectangle * name_highlight
sigc::signal< void, std::string, std::string, void * > NameChanged
bool _automation
true if this is an automation region view
virtual void set_samples_per_pixel(double)
static double NAME_Y_OFFSET
framecnt_t get_min_duration() const
virtual void drag_start()
virtual void lower()
framecnt_t min_item_duration
static const double GRAB_HANDLE_WIDTH
ArdourCanvas::Rectangle * selection_frame
int64_t framecnt_t
Definition: types.h:76
void set_item_name(std::string, void *)
bool get_max_duration_active() const
virtual void raise_to_top()
virtual void set_min_duration(framecnt_t, void *)
virtual bool set_duration(framecnt_t, void *)
framecnt_t get_duration() const
bool sensitive() const
virtual void set_frame_color()
void set_min_duration_active(bool, void *)
bool dragging() const
static const double GRAB_HANDLE_TOP
bool name_active() const
virtual bool canvas_group_event(GdkEvent *)
int64_t framepos_t
Definition: types.h:66
ArdourCanvas::Rectangle * frame_handle_start
`frame' (fade) handle for the start of the item, or 0
virtual bool set_position(framepos_t, void *, double *delta=0)
framecnt_t get_max_duration() const
virtual double height() const
void set_name_text(const std::string &)
sigc::signal< void, std::string, void * > ItemRemoved
void init(ArdourCanvas::Item *, double, uint32_t, framepos_t, framepos_t, Visibility, bool, bool)
virtual void reset_width_dependent_items(double)
bool frame_handle_crossing(GdkEvent *, ArdourCanvas::Rectangle *)
virtual void set_max_duration(framecnt_t, void *)
ArdourCanvas::Rectangle * frame
virtual void set_colors()
sigc::signal< void, framepos_t, void * > PositionChanged
ArdourCanvas::Rectangle * frame_handle_end
`frame' (fade) handle for the end of the item, or 0
void set_max_duration_active(bool, void *)
sigc::signal< void, framecnt_t, void * > DurationChanged
ArdourCanvas::Container * group
void set_sensitive(bool yn)
double get_samples_per_pixel() const
sigc::signal< void, framecnt_t, void * > MaxDurationChanged
framepos_t get_position() const
int64_t framepos_t
static const double NAME_X_OFFSET
virtual void set_selected(bool yn)
void set_color(uint32_t)
TimeAxisViewItem(const std::string &, ArdourCanvas::Item &, TimeAxisView &, double, uint32_t fill_color, framepos_t, framecnt_t, bool recording=false, bool automation=false, Visibility v=Visibility(0))
framecnt_t max_item_duration
static double NAME_HIGHLIGHT_SIZE
ArdourCanvas::Item * get_name_highlight()