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>
34 class AudioClock : public Gtk::HBox
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 set (nframes_t, bool force = false, nframes_t offset = 0, char which = 0);
52 void set_widget_name (std::string);
54 std::string name() const { return _name; }
56 nframes_t current_time (nframes_t position = 0) const;
57 nframes_t current_duration (nframes_t position = 0) const;
58 void set_session (ARDOUR::Session *s);
60 sigc::signal<void> ValueChanged;
62 static sigc::signal<void> ModeChanged;
63 static std::vector<AudioClock*> clocks;
65 static bool has_focus() { return _has_focus; }
68 ARDOUR::Session *session;
70 uint32_t key_entry_state;
78 Gtk::HBox smpte_packer_hbox;
79 Gtk::HBox smpte_packer;
81 Gtk::HBox minsec_packer_hbox;
82 Gtk::HBox minsec_packer;
84 Gtk::HBox bbt_packer_hbox;
87 Gtk::HBox frames_packer_hbox;
88 Gtk::HBox frames_packer;
104 Gtk::EventBox audio_frames_ebox;
105 Gtk::Label audio_frames_label;
107 Gtk::EventBox hours_ebox;
108 Gtk::EventBox minutes_ebox;
109 Gtk::EventBox seconds_ebox;
110 Gtk::EventBox frames_ebox;
112 Gtk::EventBox ms_hours_ebox;
113 Gtk::EventBox ms_minutes_ebox;
114 Gtk::EventBox ms_seconds_ebox;
116 Gtk::EventBox bars_ebox;
117 Gtk::EventBox beats_ebox;
118 Gtk::EventBox ticks_ebox;
120 Gtk::Label hours_label;
121 Gtk::Label minutes_label;
122 Gtk::Label seconds_label;
123 Gtk::Label frames_label;
124 Gtk::Label colon1, colon2, colon3;
126 Gtk::Label ms_hours_label;
127 Gtk::Label ms_minutes_label;
128 Gtk::Label ms_seconds_label;
129 Gtk::Label colon4, colon5;
131 Gtk::Label bars_label;
132 Gtk::Label beats_label;
133 Gtk::Label ticks_label;
137 Gtk::Label* frames_upper_info_label;
138 Gtk::Label* frames_lower_info_label;
140 Gtk::Label* smpte_upper_info_label;
141 Gtk::Label* smpte_lower_info_label;
143 Gtk::Label* bbt_upper_info_label;
144 Gtk::Label* bbt_lower_info_label;
146 Gtk::VBox frames_info_box;
147 Gtk::VBox smpte_info_box;
148 Gtk::VBox bbt_info_box;
150 Gtk::EventBox clock_base;
151 Gtk::Frame clock_frame;
160 uint32_t last_frames;
174 bool field_motion_notify_event (GdkEventMotion *ev, Field);
175 bool field_button_press_event (GdkEventButton *ev, Field);
176 bool field_button_release_event (GdkEventButton *ev, Field);
177 bool field_button_scroll_event (GdkEventScroll *ev, Field);
178 bool field_key_press_event (GdkEventKey *, Field);
179 bool field_key_release_event (GdkEventKey *, Field);
180 bool field_focus_in_event (GdkEventFocus *, Field);
181 bool field_focus_out_event (GdkEventFocus *, Field);
182 bool drop_focus_handler (GdkEventFocus*);
184 void set_smpte (nframes_t, bool);
185 void set_bbt (nframes_t, bool);
186 void set_minsec (nframes_t, bool);
187 void set_frames (nframes_t, bool);
189 nframes_t get_frames (Field,nframes_t pos = 0,int dir=1);
191 void smpte_sanitize_display();
192 nframes_t smpte_frame_from_display () const;
193 nframes_t bbt_frame_from_display (nframes_t) const;
194 nframes_t bbt_frame_duration_from_display (nframes_t) const;
195 nframes_t minsec_frame_from_display () const;
196 nframes_t audio_frame_from_display () const;
198 void build_ops_menu ();
199 void setup_events ();
201 void smpte_offset_changed ();
202 void set_size_requests ();
204 static const uint32_t field_length[(int)AudioFrames+1];
205 static bool _has_focus;
209 #endif /* __audio_clock_h__ */