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"
29 #include "ardour/session_handle.h"
35 class AudioClock : public Gtk::HBox, public ARDOUR::SessionHandlePtr
46 AudioClock (const std::string& clock_name, bool is_transient, const std::string& widget_name,
47 bool editable, bool follows_playhead, bool duration = false, bool with_info = false);
49 Mode mode() const { return _mode; }
53 void set (nframes_t, bool force = false, nframes_t offset = 0, char which = 0);
54 void set_from_playhead ();
57 void set_bbt_reference (framepos_t);
58 void set_is_duration (bool);
60 void set_widget_name (std::string);
62 std::string name() const { return _name; }
64 nframes_t current_time (nframes_t position = 0) const;
65 nframes_t current_duration (nframes_t position = 0) const;
66 void set_session (ARDOUR::Session *s);
68 sigc::signal<void> ValueChanged;
69 sigc::signal<void> mode_changed;
70 sigc::signal<void> ChangeAborted;
72 static sigc::signal<void> ModeChanged;
73 static std::vector<AudioClock*> clocks;
75 static bool has_focus() { return _has_focus; }
79 uint32_t key_entry_state;
84 /** true if this clock follows the playhead, meaning that certain operations are redundant */
85 bool _follows_playhead;
89 Gtk::HBox timecode_packer_hbox;
90 Gtk::HBox timecode_packer;
92 Gtk::HBox minsec_packer_hbox;
93 Gtk::HBox minsec_packer;
95 Gtk::HBox bbt_packer_hbox;
98 Gtk::HBox frames_packer_hbox;
99 Gtk::HBox frames_packer;
115 Gtk::EventBox audio_frames_ebox;
116 Gtk::Label audio_frames_label;
120 Gtk::EventBox hours_ebox;
121 Gtk::EventBox minutes_ebox;
122 Gtk::EventBox seconds_ebox;
123 Gtk::EventBox frames_ebox;
125 Gtk::EventBox ms_hours_ebox;
126 Gtk::EventBox ms_minutes_ebox;
127 Gtk::EventBox ms_seconds_ebox;
129 Gtk::EventBox bars_ebox;
130 Gtk::EventBox beats_ebox;
131 Gtk::EventBox ticks_ebox;
133 Gtk::Label hours_label;
134 Gtk::Label minutes_label;
135 Gtk::Label seconds_label;
136 Gtk::Label frames_label;
137 Gtk::Label colon1, colon2, colon3;
139 Gtk::Label ms_hours_label;
140 Gtk::Label ms_minutes_label;
141 Gtk::Label ms_seconds_label;
142 Gtk::Label colon4, colon5;
144 Gtk::Label bars_label;
145 Gtk::Label beats_label;
146 Gtk::Label ticks_label;
150 Gtk::Label* frames_upper_info_label;
151 Gtk::Label* frames_lower_info_label;
153 Gtk::Label* timecode_upper_info_label;
154 Gtk::Label* timecode_lower_info_label;
156 Gtk::Label* bbt_upper_info_label;
157 Gtk::Label* bbt_lower_info_label;
159 Gtk::VBox frames_info_box;
160 Gtk::VBox timecode_info_box;
161 Gtk::VBox bbt_info_box;
163 Gtk::EventBox clock_base;
164 Gtk::Frame clock_frame;
166 framepos_t bbt_reference_time;
174 uint32_t last_frames;
188 bool field_motion_notify_event (GdkEventMotion *ev, Field);
189 bool field_button_press_event (GdkEventButton *ev, Field);
190 bool field_button_release_event (GdkEventButton *ev, Field);
191 bool field_button_scroll_event (GdkEventScroll *ev, Field);
192 bool field_key_press_event (GdkEventKey *, Field);
193 bool field_key_release_event (GdkEventKey *, Field);
194 bool field_focus_in_event (GdkEventFocus *, Field);
195 bool field_focus_out_event (GdkEventFocus *, Field);
196 bool drop_focus_handler (GdkEventFocus*);
198 void set_timecode (nframes_t, bool);
199 void set_bbt (nframes_t, bool);
200 void set_minsec (nframes_t, bool);
201 void set_frames (nframes_t, bool);
203 nframes_t get_frames (Field,nframes_t pos = 0,int dir=1);
205 void timecode_sanitize_display();
206 nframes_t timecode_frame_from_display () const;
207 nframes_t bbt_frame_from_display (nframes_t) const;
208 nframes_t bbt_frame_duration_from_display (nframes_t) const;
209 nframes_t minsec_frame_from_display () const;
210 nframes_t audio_frame_from_display () const;
212 void build_ops_menu ();
213 void setup_events ();
215 void timecode_offset_changed ();
216 void set_size_requests ();
218 static const uint32_t field_length[(int)AudioFrames+1];
219 static bool _has_focus;
221 void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
224 #endif /* __audio_clock_h__ */