fix import/embed with "sequence files" option
[ardour2.git] / gtk2_ardour / audio_clock.h
blobce500149c49ea16c9d85f054307a0119369c4dc2
1 /*
2 Copyright (C) 1999 Paul Davis
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.
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.
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.
20 #ifndef __audio_clock_h__
21 #define __audio_clock_h__
23 #include <gtkmm/box.h>
24 #include <gtkmm/menu.h>
25 #include <gtkmm/eventbox.h>
26 #include <gtkmm/label.h>
27 #include <gtkmm/frame.h>
28 #include <ardour/ardour.h>
30 namespace ARDOUR {
31 class Session;
34 class AudioClock : public Gtk::HBox
36 public:
37 enum Mode {
38 SMPTE,
39 BBT,
40 MinSec,
41 Frames,
42 Off
45 AudioClock (std::string clock_name, bool transient, std::string widget_name, bool editable, bool is_duration = false, bool with_info = false);
47 Mode mode() const { return _mode; }
49 void focus ();
51 void set (nframes_t, bool force = false, nframes_t offset = 0, int which = 0);
52 void set_mode (Mode);
53 void set_bbt_reference (nframes64_t);
55 void set_widget_name (std::string);
57 std::string name() const { return _name; }
59 nframes_t current_time (nframes_t position = 0) const;
60 nframes_t current_duration (nframes_t position = 0) const;
61 void set_session (ARDOUR::Session *s);
63 sigc::signal<void> ValueChanged;
64 sigc::signal<void> ChangeAborted;
66 static sigc::signal<void> ModeChanged;
67 static std::vector<AudioClock*> clocks;
69 static bool has_focus() { return _has_focus; }
71 private:
72 ARDOUR::Session *session;
73 Mode _mode;
74 uint32_t key_entry_state;
75 std::string _name;
76 bool is_transient;
77 bool is_duration;
78 bool editable;
80 Gtk::Menu *ops_menu;
82 Gtk::HBox smpte_packer_hbox;
83 Gtk::HBox smpte_packer;
85 Gtk::HBox minsec_packer_hbox;
86 Gtk::HBox minsec_packer;
88 Gtk::HBox bbt_packer_hbox;
89 Gtk::HBox bbt_packer;
91 Gtk::HBox frames_packer_hbox;
92 Gtk::HBox frames_packer;
94 enum Field {
95 SMPTE_Hours,
96 SMPTE_Minutes,
97 SMPTE_Seconds,
98 SMPTE_Frames,
99 MS_Hours,
100 MS_Minutes,
101 MS_Seconds,
102 Bars,
103 Beats,
104 Ticks,
105 AudioFrames
108 Gtk::EventBox audio_frames_ebox;
109 Gtk::Label audio_frames_label;
111 Gtk::HBox off_hbox;
113 Gtk::EventBox hours_ebox;
114 Gtk::EventBox minutes_ebox;
115 Gtk::EventBox seconds_ebox;
116 Gtk::EventBox frames_ebox;
118 Gtk::EventBox ms_hours_ebox;
119 Gtk::EventBox ms_minutes_ebox;
120 Gtk::EventBox ms_seconds_ebox;
122 Gtk::EventBox bars_ebox;
123 Gtk::EventBox beats_ebox;
124 Gtk::EventBox ticks_ebox;
126 Gtk::Label hours_label;
127 Gtk::Label minutes_label;
128 Gtk::Label seconds_label;
129 Gtk::Label frames_label;
130 Gtk::Label colon1, colon2, colon3;
132 Gtk::Label ms_hours_label;
133 Gtk::Label ms_minutes_label;
134 Gtk::Label ms_seconds_label;
135 Gtk::Label colon4, colon5;
137 Gtk::Label bars_label;
138 Gtk::Label beats_label;
139 Gtk::Label ticks_label;
140 Gtk::Label b1;
141 Gtk::Label b2;
143 Gtk::Label* frames_upper_info_label;
144 Gtk::Label* frames_lower_info_label;
146 Gtk::Label* smpte_upper_info_label;
147 Gtk::Label* smpte_lower_info_label;
149 Gtk::Label* bbt_upper_info_label;
150 Gtk::Label* bbt_lower_info_label;
152 Gtk::VBox frames_info_box;
153 Gtk::VBox smpte_info_box;
154 Gtk::VBox bbt_info_box;
156 Gtk::EventBox clock_base;
157 Gtk::Frame clock_frame;
159 nframes64_t bbt_reference_time;
160 nframes_t last_when;
161 bool last_pdelta;
162 bool last_sdelta;
164 uint32_t last_hrs;
165 uint32_t last_mins;
166 uint32_t last_secs;
167 uint32_t last_frames;
168 bool last_negative;
170 long ms_last_hrs;
171 long ms_last_mins;
172 float ms_last_secs;
174 bool dragging;
175 double drag_start_y;
176 double drag_y;
177 double drag_accum;
179 void on_realize ();
181 bool field_motion_notify_event (GdkEventMotion *ev, Field);
182 bool field_button_press_event (GdkEventButton *ev, Field);
183 bool field_button_release_event (GdkEventButton *ev, Field);
184 bool field_button_scroll_event (GdkEventScroll *ev, Field);
185 bool field_key_press_event (GdkEventKey *, Field);
186 bool field_key_release_event (GdkEventKey *, Field);
187 bool field_focus_in_event (GdkEventFocus *, Field);
188 bool field_focus_out_event (GdkEventFocus *, Field);
189 bool drop_focus_handler (GdkEventFocus*);
191 void set_smpte (nframes_t, bool);
192 void set_bbt (nframes_t, bool);
193 void set_minsec (nframes_t, bool);
194 void set_frames (nframes_t, bool);
196 nframes_t get_frames (Field,nframes_t pos = 0,int dir=1);
198 void smpte_sanitize_display();
199 nframes_t smpte_frame_from_display () const;
200 nframes_t bbt_frame_from_display (nframes_t) const;
201 nframes_t bbt_frame_duration_from_display (nframes_t) const;
202 nframes_t minsec_frame_from_display () const;
203 nframes_t audio_frame_from_display () const;
205 void build_ops_menu ();
206 void setup_events ();
208 void smpte_offset_changed ();
209 void set_size_requests ();
211 static const uint32_t field_length[(int)AudioFrames+1];
212 static bool _has_focus;
216 #endif /* __audio_clock_h__ */