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__
28 #include <gtkmm/alignment.h>
29 #include <gtkmm/box.h>
30 #include <gtkmm/menu.h>
31 #include <gtkmm/label.h>
33 #include "ardour/ardour.h"
34 #include "ardour/session_handle.h"
36 #include "cairo_widget.h"
42 class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
52 AudioClock (const std::string& clock_name, bool is_transient, const std::string& widget_name,
53 bool editable, bool follows_playhead, bool duration = false, bool with_info = false);
56 Mode mode() const { return _mode; }
57 void set_off (bool yn);
58 bool off() const { return _off; }
59 void set_widget_name (const std::string& name);
60 void set_active_state (Gtkmm2ext::ActiveState s);
64 void set (framepos_t, bool force = false, ARDOUR::framecnt_t offset = 0, char which = 0);
65 void set_from_playhead ();
68 void set_bbt_reference (framepos_t);
69 void set_is_duration (bool);
70 void set_draw_background (bool yn);
72 std::string name() const { return _name; }
74 framepos_t current_time (framepos_t position = 0) const;
75 framepos_t current_duration (framepos_t position = 0) const;
76 void set_session (ARDOUR::Session *s);
78 sigc::signal<void> ValueChanged;
79 sigc::signal<void> mode_changed;
80 sigc::signal<void> ChangeAborted;
82 static sigc::signal<void> ModeChanged;
83 static std::vector<AudioClock*> clocks;
86 void render (cairo_t*);
94 /** true if this clock follows the playhead, meaning that certain operations are redundant */
95 bool _follows_playhead;
101 Glib::RefPtr<Pango::Layout> _layout;
102 Glib::RefPtr<Pango::Layout> _left_layout;
103 Glib::RefPtr<Pango::Layout> _right_layout;
105 Pango::AttrColor* editing_attr;
106 Pango::AttrColor* background_attr;
107 Pango::AttrColor* foreground_attr;
109 Pango::AttrList normal_attributes;
110 Pango::AttrList editing_attributes;
111 Pango::AttrList info_attributes;
117 double mode_based_info_ratio;
118 static const double info_font_scale_factor;
119 static const double separator_height;
136 Field index_to_field (int index) const;
139 std::string edit_string;
140 std::string pre_edit_string;
141 std::string input_string;
142 std::string::size_type insert_max;
144 framepos_t bbt_reference_time;
145 framepos_t last_when;
155 /** true if the time of this clock is the one displayed in its widgets.
156 * if false, the time in the widgets is an approximation of _canonical_time,
157 * and _canonical_time should be returned as the `current' time of the clock.
159 bool _canonical_time_is_displayed;
160 framepos_t _canonical_time;
163 bool on_key_press_event (GdkEventKey *);
164 bool on_key_release_event (GdkEventKey *);
165 bool on_scroll_event (GdkEventScroll *ev);
166 bool on_button_press_event (GdkEventButton *ev);
167 bool on_button_release_event(GdkEventButton *ev);
168 void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
169 void on_size_request (Gtk::Requisition* req);
170 bool on_motion_notify_event (GdkEventMotion *ev);
171 void on_size_allocate (Gtk::Allocation&);
173 void set_timecode (framepos_t, bool);
174 void set_bbt (framepos_t, bool);
175 void set_minsec (framepos_t, bool);
176 void set_frames (framepos_t, bool);
178 framepos_t get_frame_step (Field, framepos_t pos = 0, int dir = 1);
180 bool timecode_validate_edit (const std::string&);
181 bool bbt_validate_edit (const std::string&);
183 framepos_t timecode_frame_from_display () const;
184 framepos_t bbt_frame_from_display (framepos_t) const;
185 framepos_t bbt_frame_duration_from_display (framepos_t) const;
186 framepos_t minsec_frame_from_display () const;
187 framepos_t audio_frame_from_display () const;
189 void build_ops_menu ();
191 void session_configuration_changed (std::string);
193 Field index_to_field () const;
196 void end_edit (bool);
197 void edit_next_field ();
201 void show_edit_status (int length);
203 void timecode_tester ();
205 double bg_r, bg_g, bg_b, bg_a;
208 #endif /* __audio_clock_h__ */