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 #include <cstdio> // for sprintf
23 #include "pbd/convert.h"
24 #include "pbd/enumwriter.h"
26 #include <gtkmm/style.h>
27 #include <sigc++/bind.h>
29 #include "gtkmm2ext/cairocell.h"
30 #include "gtkmm2ext/utils.h"
31 #include "gtkmm2ext/rgb_macros.h"
33 #include "ardour/profile.h"
34 #include "ardour/lmath.h"
35 #include "ardour/session.h"
36 #include "ardour/slave.h"
37 #include "ardour/tempo.h"
38 #include "ardour/types.h"
40 #include "ardour_ui.h"
41 #include "audio_clock.h"
42 #include "gui_thread.h"
44 #include "ui_config.h"
49 using namespace ARDOUR;
50 using namespace ARDOUR_UI_UTILS;
55 using Gtkmm2ext::Keyboard;
57 sigc::signal<void> AudioClock::ModeChanged;
58 vector<AudioClock*> AudioClock::clocks;
59 const double AudioClock::info_font_scale_factor = 0.68;
60 const double AudioClock::separator_height = 0.0;
61 const double AudioClock::x_leading_padding = 6.0;
63 #define BBT_BAR_CHAR "|"
64 #define BBT_SCANF_FORMAT "%" PRIu32 "%*c%" PRIu32 "%*c%" PRIu32
65 #define INFO_FONT_SIZE ((int)lrint(font_size * info_font_scale_factor))
66 #define TXTSPAN "<span font-family=\"Sans\" foreground=\"white\">"
68 AudioClock::AudioClock (const string& clock_name, bool transient, const string& widget_name,
69 bool allow_edit, bool follows_playhead, bool duration, bool with_info,
70 bool accept_on_focus_out)
73 , is_transient (transient)
74 , is_duration (duration)
75 , editable (allow_edit)
76 , _follows_playhead (follows_playhead)
77 , _accept_on_focus_out (accept_on_focus_out)
80 , _edit_by_click_field (false)
81 , _negative_allowed (false)
82 , edit_is_negative (false)
87 , style_resets_first (true)
92 , mode_based_info_ratio (1.0)
96 , bbt_reference_time (-1)
101 , drag_field (Field (0))
105 set_flags (CAN_FOCUS);
107 _layout = Pango::Layout::create (get_pango_context());
108 _layout->set_attributes (normal_attributes);
111 _left_layout = Pango::Layout::create (get_pango_context());
112 _right_layout = Pango::Layout::create (get_pango_context());
115 set_widget_name (widget_name);
117 _mode = BBT; /* lie to force mode switch */
119 set (last_when, true);
122 clocks.push_back (this);
125 UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &AudioClock::set_colors));
126 UIConfiguration::instance().DPIReset.connect (sigc::mem_fun (*this, &AudioClock::dpi_reset));
129 AudioClock::~AudioClock ()
131 delete foreground_attr;
136 AudioClock::set_widget_name (const string& str)
141 set_name (str + " clock");
151 AudioClock::on_realize ()
153 Gtk::Requisition req;
155 CairoWidget::on_realize ();
157 set_clock_dimensions (req);
159 first_width = req.width;
160 first_height = req.height;
162 // XXX FIX ME: define font based on ... ???
168 AudioClock::set_font (Pango::FontDescription font)
170 Glib::RefPtr<Gtk::Style> style = get_style ();
171 Pango::AttrFontDesc* font_attr;
173 font_size = font.get_size();
174 font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
176 normal_attributes.change (*font_attr);
177 editing_attributes.change (*font_attr);
179 /* now a smaller version of the same font */
182 font.set_size (INFO_FONT_SIZE);
183 font.set_weight (Pango::WEIGHT_NORMAL);
184 font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
186 info_attributes.change (*font_attr);
188 /* and an even smaller one */
192 /* get the figure width for the font. This doesn't have to super
193 * accurate since we only use it to measure the (roughly 1 character)
194 * offset from the position Pango tells us for the "cursor"
197 Glib::RefPtr<Pango::Layout> tmp = Pango::Layout::create (get_pango_context());
201 tmp->get_pixel_size (em_width, ignore_height);
203 /* force redraw of markup with new font-size */
204 set (last_when, true);
208 AudioClock::set_active_state (Gtkmm2ext::ActiveState s)
210 CairoWidget::set_active_state (s);
215 AudioClock::set_colors ()
221 uint32_t editing_color;
222 uint32_t cursor_color;
224 if (active_state()) {
225 bg_color = UIConfiguration::instance().color (string_compose ("%1 active: background", get_name()));
226 text_color = UIConfiguration::instance().color (string_compose ("%1 active: text", get_name()));
227 editing_color = UIConfiguration::instance().color (string_compose ("%1 active: edited text", get_name()));
228 cursor_color = UIConfiguration::instance().color (string_compose ("%1 active: cursor", get_name()));
230 bg_color = UIConfiguration::instance().color (string_compose ("%1: background", get_name()));
231 text_color = UIConfiguration::instance().color (string_compose ("%1: text", get_name()));
232 editing_color = UIConfiguration::instance().color (string_compose ("%1: edited text", get_name()));
233 cursor_color = UIConfiguration::instance().color (string_compose ("%1: cursor", get_name()));
236 /* store for bg and cursor in render() */
238 UINT_TO_RGBA (bg_color, &r, &g, &b, &a);
245 UINT_TO_RGBA (cursor_color, &r, &g, &b, &a);
252 /* rescale for Pango colors ... sigh */
254 r = lrint (r * 65535.0);
255 g = lrint (g * 65535.0);
256 b = lrint (b * 65535.0);
258 UINT_TO_RGBA (text_color, &r, &g, &b, &a);
259 r = lrint ((r/255.0) * 65535.0);
260 g = lrint ((g/255.0) * 65535.0);
261 b = lrint ((b/255.0) * 65535.0);
262 delete foreground_attr;
263 foreground_attr = new Pango::AttrColor (Pango::Attribute::create_attr_foreground (r, g, b));
265 UINT_TO_RGBA (editing_color, &r, &g, &b, &a);
266 r = lrint ((r/255.0) * 65535.0);
267 g = lrint ((g/255.0) * 65535.0);
268 b = lrint ((b/255.0) * 65535.0);
270 editing_attr = new Pango::AttrColor (Pango::Attribute::create_attr_foreground (r, g, b));
272 normal_attributes.change (*foreground_attr);
273 info_attributes.change (*foreground_attr);
274 editing_attributes.change (*foreground_attr);
275 editing_attributes.change (*editing_attr);
278 _layout->set_attributes (normal_attributes);
280 _layout->set_attributes (editing_attributes);
287 AudioClock::set_scale (double x, double y)
296 AudioClock::render (cairo_t* cr, cairo_rectangle_t*)
298 /* main layout: rounded rect, plus the text */
301 cairo_set_source_rgba (cr, bg_r, bg_g, bg_b, bg_a);
304 Gtkmm2ext::rounded_top_half_rectangle (cr, 0, 0, get_width(), upper_height, corner_radius);
306 Gtkmm2ext::rounded_rectangle (cr, 0, 0, get_width(), upper_height, corner_radius);
309 cairo_rectangle (cr, 0, 0, get_width(), upper_height);
314 double lw = layout_width * xscale;
315 double lh = layout_height * yscale;
317 cairo_move_to (cr, (get_width() - lw) / 2.0, (upper_height - lh) / 2.0);
319 if (xscale != 1.0 || yscale != 1.0) {
321 cairo_scale (cr, xscale, yscale);
324 pango_cairo_show_layout (cr, _layout->gobj());
326 if (xscale != 1.0 || yscale != 1.0) {
332 double h = get_height() - upper_height - separator_height;
335 cairo_set_source_rgba (cr, bg_r, bg_g, bg_b, bg_a);
338 if (mode_based_info_ratio != 1.0) {
340 double left_rect_width = get_left_rect_width();
344 Gtkmm2ext::rounded_bottom_half_rectangle (cr, 0, upper_height + separator_height,
345 left_rect_width + (separator_height == 0 ? corner_radius : 0),
348 cairo_rectangle (cr, 0, upper_height + separator_height, left_rect_width, h);
353 cairo_move_to (cr, x_leading_padding, upper_height + separator_height + ((h - info_height)/2.0));
354 pango_cairo_show_layout (cr, _left_layout->gobj());
358 Gtkmm2ext::rounded_bottom_half_rectangle (cr, left_rect_width + separator_height,
359 upper_height + separator_height,
360 get_width() - separator_height - left_rect_width,
363 cairo_rectangle (cr, left_rect_width + separator_height, upper_height + separator_height,
364 get_width() - separator_height - left_rect_width, h);
370 if (_right_layout->get_alignment() == Pango::ALIGN_RIGHT) {
371 /* right-align does not work per se beacuse layout width is unset.
372 * Using _right_layout->set_width([value >=0]) would also enable
373 * word-wrapping which is not wanted here.
374 * The solution is to custom align the layout depending on its size.
375 * if it is larger than the available space it will be cropped on the
376 * right edge rather than override text on the left side.
379 _right_layout->get_pixel_size(rw, rh);
380 x = get_width() - rw - separator_height - x_leading_padding;
381 if (x < x_leading_padding + left_rect_width + separator_height) {
382 /* rather cut off the right end than overlap with the text on the left */
383 x = x_leading_padding + left_rect_width + separator_height;
385 cairo_move_to (cr, x, upper_height + separator_height + ((h - info_height)/2.0));
387 cairo_move_to (cr, x_leading_padding + left_rect_width + separator_height, upper_height + separator_height + ((h - info_height)/2.0));
389 pango_cairo_show_layout (cr, _right_layout->gobj());
392 /* no info to display, or just one */
396 Gtkmm2ext::rounded_bottom_half_rectangle (cr, 0, upper_height + separator_height, get_width(), h, corner_radius);
398 cairo_rectangle (cr, 0, upper_height + separator_height, get_width(), h);
406 if (!insert_map.empty()) {
408 int xcenter = (get_width() - layout_width) /2;
410 if (input_string.length() < insert_map.size()) {
411 Pango::Rectangle cursor;
413 if (input_string.empty()) {
414 /* nothing entered yet, put cursor at the end
417 cursor = _layout->get_cursor_strong_pos (edit_string.length() - 1);
419 cursor = _layout->get_cursor_strong_pos (insert_map[input_string.length()]);
422 cairo_set_source_rgba (cr, cursor_r, cursor_g, cursor_b, cursor_a);
424 min (get_width() - 2.0,
425 (double) xcenter + cursor.get_x()/PANGO_SCALE + em_width),
426 (upper_height - layout_height)/2.0,
427 2.0, cursor.get_height()/PANGO_SCALE);
430 /* we've entered all possible digits, no cursor */
434 if (input_string.empty()) {
435 cairo_set_source_rgba (cr, cursor_r, cursor_g, cursor_b, cursor_a);
438 (upper_height - layout_height)/2.0,
447 AudioClock::on_size_allocate (Gtk::Allocation& alloc)
449 CairoWidget::on_size_allocate (alloc);
452 upper_height = (get_height()/2.0) - 1.0;
454 upper_height = get_height();
459 AudioClock::set_clock_dimensions (Gtk::Requisition& req)
461 Glib::RefPtr<Pango::Layout> tmp;
462 Glib::RefPtr<Gtk::Style> style = get_style ();
463 Pango::FontDescription font;
465 tmp = Pango::Layout::create (get_pango_context());
467 if (!is_realized()) {
468 font = get_font_for_style (get_name());
470 font = style->get_font();
473 tmp->set_font_description (font);
475 /* this string is the longest thing we will ever display */
477 tmp->set_text (" 88:88:88,888 ");
479 tmp->set_text (" 88:88:88,88 ");
480 tmp->get_pixel_size (req.width, req.height);
482 layout_height = req.height;
483 layout_width = req.width;
487 AudioClock::on_size_request (Gtk::Requisition* req)
489 /* even for non fixed width clocks, the size we *ask* for never changes,
490 even though the size we receive might. so once we've computed it,
495 req->width = first_width;
496 req->height = first_height;
500 set_clock_dimensions (*req);
502 /* now tackle height, for which we need to know the height of the lower
508 Glib::RefPtr<Pango::Layout> tmp;
509 Glib::RefPtr<Gtk::Style> style = get_style ();
510 Pango::FontDescription font;
513 tmp = Pango::Layout::create (get_pango_context());
515 if (!is_realized()) {
516 font = get_font_for_style (get_name());
518 font = style->get_font();
521 tmp->set_font_description (font);
523 font.set_size (INFO_FONT_SIZE);
524 font.set_weight (Pango::WEIGHT_NORMAL);
525 tmp->set_font_description (font);
527 /* we only care about height, so put as much stuff in here
528 as possible that might change the height.
530 tmp->set_text ("qyhH|"); /* one ascender, one descender */
532 tmp->get_pixel_size (w, info_height);
534 /* silly extra padding that seems necessary to correct the info
535 * that pango just gave us. I have no idea why.
538 req->height += info_height;
539 req->height += separator_height;
544 AudioClock::show_edit_status (int length)
546 editing_attr->set_start_index (edit_string.length() - length);
547 editing_attr->set_end_index (edit_string.length());
549 editing_attributes.change (*foreground_attr);
550 editing_attributes.change (*editing_attr);
552 _layout->set_attributes (editing_attributes);
556 AudioClock::start_edit (Field f)
559 pre_edit_string = _layout->get_text ();
560 if (!insert_map.empty()) {
561 edit_string = pre_edit_string;
563 edit_string.clear ();
564 _layout->set_text ("");
567 input_string.clear ();
569 edit_is_negative = false;
572 input_string = get_field (f);
573 show_edit_status (merge_input_and_edit_string ());
574 _layout->set_text (edit_string);
579 Keyboard::magic_widget_grab_focus ();
585 AudioClock::get_field (Field f)
589 return edit_string.substr (1, 2);
591 case Timecode_Minutes:
592 return edit_string.substr (4, 2);
594 case Timecode_Seconds:
595 return edit_string.substr (7, 2);
597 case Timecode_Frames:
598 return edit_string.substr (10, 2);
601 return edit_string.substr (1, 2);
604 return edit_string.substr (4, 2);
607 return edit_string.substr (7, 2);
609 case MS_Milliseconds:
610 return edit_string.substr (10, 3);
613 return edit_string.substr (1, 3);
616 return edit_string.substr (5, 2);
619 return edit_string.substr (8, 4);
629 AudioClock::end_edit (bool modify)
637 ok = timecode_validate_edit (edit_string);
641 ok = bbt_validate_edit (edit_string);
645 ok = minsec_validate_edit (edit_string);
649 if (edit_string.length() < 1) {
650 edit_string = pre_edit_string;
656 edit_string = pre_edit_string;
657 input_string.clear ();
658 _layout->set_text (edit_string);
659 show_edit_status (0);
660 /* edit attributes remain in use */
664 framepos_t pos = 0; /* stupid gcc */
668 pos = frames_from_timecode_string (edit_string);
673 pos = frame_duration_from_bbt_string (0, edit_string);
675 pos = frames_from_bbt_string (0, edit_string);
680 pos = frames_from_minsec_string (edit_string);
684 pos = frames_from_audioframes_string (edit_string);
689 _layout->set_attributes (normal_attributes);
690 ValueChanged(); /* EMIT_SIGNAL */
696 edit_is_negative = false;
697 _layout->set_attributes (normal_attributes);
698 _layout->set_text (pre_edit_string);
709 AudioClock::drop_focus ()
711 Keyboard::magic_widget_drop_focus ();
714 /* move focus back to the default widget in the top level window */
715 ARDOUR_UI::instance()->reset_focus (this);
720 AudioClock::parse_as_frames_distance (const std::string& str)
724 if (sscanf (str.c_str(), "%" PRId64, &f) == 1) {
732 AudioClock::parse_as_minsec_distance (const std::string& str)
734 framecnt_t sr = _session->frame_rate();
740 switch (str.length()) {
747 sscanf (str.c_str(), "%" PRId32, &msecs);
748 return msecs * (sr / 1000);
751 sscanf (str.c_str(), "%1" PRId32 "%" PRId32, &secs, &msecs);
752 return (secs * sr) + (msecs * (sr/1000));
755 sscanf (str.c_str(), "%2" PRId32 "%" PRId32, &secs, &msecs);
756 return (secs * sr) + (msecs * (sr/1000));
759 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &msecs);
760 return (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
763 sscanf (str.c_str(), "%2" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &msecs);
764 return (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
767 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &msecs);
768 return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
771 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &msecs);
772 return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
782 AudioClock::parse_as_timecode_distance (const std::string& str)
784 double fps = _session->timecode_frames_per_second();
785 framecnt_t sr = _session->frame_rate();
791 switch (str.length()) {
796 sscanf (str.c_str(), "%" PRId32, &frames);
797 return llrint ((frames/(float)fps) * sr);
800 sscanf (str.c_str(), "%1" PRId32 "%" PRId32, &secs, &frames);
801 return (secs * sr) + llrint ((frames/(float)fps) * sr);
804 sscanf (str.c_str(), "%2" PRId32 "%" PRId32, &secs, &frames);
805 return (secs * sr) + llrint ((frames/(float)fps) * sr);
808 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &frames);
809 return (mins * 60 * sr) + (secs * sr) + llrint ((frames/(float)fps) * sr);
812 sscanf (str.c_str(), "%2" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &frames);
813 return (mins * 60 * sr) + (secs * sr) + llrint ((frames/(float)fps) * sr);
816 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &frames);
817 return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + llrint ((frames/(float)fps) * sr);
820 sscanf (str.c_str(), "%2" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &frames);
821 return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + llrint ((frames/(float)fps) * sr);
831 AudioClock::parse_as_bbt_distance (const std::string&)
837 AudioClock::parse_as_distance (const std::string& instr)
841 return parse_as_timecode_distance (instr);
844 return parse_as_frames_distance (instr);
847 return parse_as_bbt_distance (instr);
850 return parse_as_minsec_distance (instr);
857 AudioClock::end_edit_relative (bool add)
863 ok = timecode_validate_edit (edit_string);
867 ok = bbt_validate_edit (edit_string);
871 ok = minsec_validate_edit (edit_string);
879 edit_string = pre_edit_string;
880 input_string.clear ();
881 _layout->set_text (edit_string);
882 show_edit_status (0);
883 /* edit attributes remain in use */
888 framecnt_t frames = parse_as_distance (input_string);
893 _layout->set_attributes (normal_attributes);
897 set (current_time() + frames, true);
899 framepos_t c = current_time();
901 if (c > frames || _negative_allowed) {
902 set (c - frames, true);
907 ValueChanged (); /* EMIT SIGNAL */
910 input_string.clear ();
916 AudioClock::session_property_changed (const PropertyChange&)
918 set (last_when, true);
922 AudioClock::metric_position_changed ()
924 set (last_when, true);
928 AudioClock::session_configuration_changed (std::string p)
930 if (_negative_allowed) {
931 /* session option editor clock */
935 if (p == "sync-source" || p == "external-sync") {
936 set (current_time(), true);
940 if (p != "timecode-offset" && p != "timecode-offset-negative") {
949 current = current_duration ();
951 current = current_time ();
961 AudioClock::set (framepos_t when, bool force, framecnt_t offset)
963 if ((!force && !is_visible()) || _session == 0) {
968 when = when - offset;
971 if (when == last_when && !force) {
972 #if 0 // XXX return if no change and no change forced. verify Aug/2014
973 if (_mode != Timecode && _mode != MinSec) {
974 /* may need to force display of TC source
975 * time, so don't return early.
977 /* ^^ Why was that?, delta times?
978 * Timecode FPS, pull-up/down, etc changes
979 * trigger a 'session_property_changed' which
980 * eventually calls set(last_when, true)
982 * re-rendering the clock every 40ms or so just
983 * because we can is not ideal.
994 _right_layout->set_alignment(Pango::ALIGN_LEFT);
1000 _right_layout->set_alignment(Pango::ALIGN_RIGHT);
1002 set_timecode (when, force);
1006 set_bbt (when, offset, force);
1010 if (_right_layout) {
1011 _right_layout->set_alignment(Pango::ALIGN_RIGHT);
1013 set_minsec (when, force);
1017 set_frames (when, force);
1027 AudioClock::set_slave_info ()
1029 if (!_left_layout || !_right_layout) {
1033 SyncSource sync_src = Config->get_sync_source();
1035 if (_session->config.get_external_sync()) {
1036 Slave* slave = _session->slave();
1040 _left_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%2</span></span>",
1041 INFO_FONT_SIZE, sync_source_to_string(sync_src, true)));
1042 _right_layout->set_text ("");
1046 _left_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%2</span></span>",
1047 INFO_FONT_SIZE, sync_source_to_string(sync_src, true)));
1048 _right_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%2</span></span>",
1049 INFO_FONT_SIZE, slave->approximate_current_delta()));
1051 _left_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%2</span></span>",
1052 INFO_FONT_SIZE, _("--pending--")));
1053 _right_layout->set_text ("");
1060 TimecodeSlave* tcslave;
1061 if ((tcslave = dynamic_cast<TimecodeSlave*>(_session->slave())) != 0) {
1062 matching = (tcslave->apparent_timecode_format() == _session->config.get_timecode_format());
1063 _left_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%2</span><span foreground=\"%3\">%4</span></span>",
1064 INFO_FONT_SIZE, sync_source_to_string(sync_src, true)[0], (matching?"green":"red"),
1065 dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
1066 _right_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%2</span></span>",
1067 INFO_FONT_SIZE, slave->approximate_current_delta()));
1070 _left_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%2</span></span>",
1071 INFO_FONT_SIZE, _("--pending--")));
1072 _right_layout->set_text ("");
1077 _left_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "INT/%2</span></span>",
1078 INFO_FONT_SIZE, sync_source_to_string(sync_src, true)));
1079 _right_layout->set_text ("");
1084 AudioClock::set_frames (framepos_t when, bool /*force*/)
1087 bool negative = false;
1090 _layout->set_text (" ----------");
1093 _left_layout->set_text ("");
1094 _right_layout->set_text ("");
1106 snprintf (buf, sizeof (buf), "-%10" PRId64, when);
1108 snprintf (buf, sizeof (buf), " %10" PRId64, when);
1111 _layout->set_text (buf);
1114 framecnt_t rate = _session->frame_rate();
1116 if (fmod (rate, 100.0) == 0.0) {
1117 sprintf (buf, "%.1fkHz", rate/1000.0);
1119 sprintf (buf, "%" PRId64 "Hz", rate);
1122 _left_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%2 </span><span foreground=\"green\">%3</span></span>",
1123 INFO_FONT_SIZE, _("SR"), buf));
1125 float vid_pullup = _session->config.get_video_pullup();
1127 if (vid_pullup == 0.0) {
1128 _right_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%2 </span><span foreground=\"green\">off</span></span>",
1129 INFO_FONT_SIZE, _("Pull")));
1131 sprintf (buf, _("%+.4f%%"), vid_pullup);
1132 _right_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%2 </span><span foreground=\"green\">%3</span></span>",
1133 INFO_FONT_SIZE, _("Pull"), buf));
1139 AudioClock::print_minsec (framepos_t when, char* buf, size_t bufsize, float frame_rate)
1156 hrs = (int) floor (left / (frame_rate * 60.0f * 60.0f));
1157 left -= (framecnt_t) floor (hrs * frame_rate * 60.0f * 60.0f);
1158 mins = (int) floor (left / (frame_rate * 60.0f));
1159 left -= (framecnt_t) floor (mins * frame_rate * 60.0f);
1160 secs = (int) floor (left / (float) frame_rate);
1161 left -= (framecnt_t) floor ((double)(secs * frame_rate));
1162 millisecs = floor (left * 1000.0 / (float) frame_rate);
1165 snprintf (buf, bufsize, "-%02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs);
1167 snprintf (buf, bufsize, " %02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs);
1173 AudioClock::set_minsec (framepos_t when, bool /*force*/)
1178 _layout->set_text (" --:--:--.---");
1181 _left_layout->set_text ("");
1182 _right_layout->set_text ("");
1188 print_minsec (when, buf, sizeof (buf), _session->frame_rate());
1190 _layout->set_text (buf);
1195 AudioClock::set_timecode (framepos_t when, bool /*force*/)
1198 bool negative = false;
1201 _layout->set_text (" --:--:--:--");
1203 _left_layout->set_text ("");
1204 _right_layout->set_text ("");
1216 _session->timecode_duration (when, TC);
1218 _session->timecode_time (when, TC);
1221 TC.negative = TC.negative || negative;
1223 _layout->set_text (Timecode::timecode_format_time(TC));
1229 AudioClock::set_bbt (framepos_t when, framecnt_t offset, bool /*force*/)
1232 Timecode::BBT_Time BBT;
1233 bool negative = false;
1236 _layout->set_text (" ---|--|----");
1238 _left_layout->set_text ("");
1239 _right_layout->set_text ("");
1249 /* handle a common case */
1256 TempoMap& tmap (_session->tempo_map());
1257 const double divisions = tmap.meter_section_at_frame (offset).divisions_per_bar();
1260 BBT = tmap.bbt_at_beat (tmap.beat_at_frame (offset));
1261 Timecode::BBT_Time when_bbt = tmap.bbt_at_frame (offset - when);
1263 BBT.bars -= when_bbt.bars;
1265 if (BBT.ticks < when_bbt.ticks) {
1266 if (BBT.beats == 1) {
1268 BBT.beats = divisions;
1272 BBT.ticks = Timecode::BBT_Time::ticks_per_beat - (when_bbt.ticks - BBT.ticks);
1274 BBT.ticks -= when_bbt.ticks;
1277 if (BBT.beats < when_bbt.beats) {
1279 BBT.beats = divisions - (when_bbt.beats - BBT.beats);
1281 BBT.beats -= when_bbt.beats;
1284 BBT = tmap.bbt_at_beat (tmap.beat_at_frame (when + offset));
1285 Timecode::BBT_Time when_bbt = tmap.bbt_at_frame (offset);
1287 BBT.bars -= when_bbt.bars;
1289 if (BBT.ticks < when_bbt.ticks) {
1290 if (BBT.beats == 1) {
1292 BBT.beats = divisions;
1296 BBT.ticks = Timecode::BBT_Time::ticks_per_beat - (when_bbt.ticks - BBT.ticks);
1298 BBT.ticks -= when_bbt.ticks;
1301 if (BBT.beats < when_bbt.beats) {
1303 BBT.beats = divisions - (when_bbt.beats - BBT.beats);
1305 BBT.beats -= when_bbt.beats;
1310 BBT = _session->tempo_map().bbt_at_frame (when);
1314 snprintf (buf, sizeof (buf), "-%03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
1315 BBT.bars, BBT.beats, BBT.ticks);
1317 snprintf (buf, sizeof (buf), " %03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
1318 BBT.bars, BBT.beats, BBT.ticks);
1321 _layout->set_text (buf);
1323 if (_right_layout) {
1326 if (bbt_reference_time < 0) {
1329 pos = bbt_reference_time;
1332 TempoMetric m (_session->tempo_map().metric_at (pos));
1334 sprintf (buf, "%-5.3f", _session->tempo_map().tempo_at_frame (pos).beats_per_minute());
1335 _left_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%3</span> <span foreground=\"green\">%2</span></span>",
1336 INFO_FONT_SIZE, buf, _("Tempo")));
1338 sprintf (buf, "%g/%g", m.meter().divisions_per_bar(), m.meter().note_divisor());
1339 _right_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%3</span> <span foreground=\"green\">%2</span></span>",
1340 INFO_FONT_SIZE, buf, _("Meter")));
1345 AudioClock::set_session (Session *s)
1347 SessionHandlePtr::set_session (s);
1351 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
1352 _session->tempo_map().PropertyChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_property_changed, this, _1), gui_context());
1353 _session->tempo_map().MetricPositionChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::metric_position_changed, this), gui_context());
1355 XMLProperty const * prop;
1356 XMLNode* node = _session->extra_xml (X_("ClockModes"));
1357 AudioClock::Mode amode;
1360 for (XMLNodeList::const_iterator i = node->children().begin(); i != node->children().end(); ++i) {
1361 if ((prop = (*i)->property (X_("name"))) && prop->value() == _name) {
1363 if ((prop = (*i)->property (X_("mode"))) != 0) {
1364 amode = AudioClock::Mode (string_2_enum (prop->value(), amode));
1365 set_mode (amode, true);
1367 if ((prop = (*i)->property (X_("on"))) != 0) {
1368 set_off (!string_is_affirmative (prop->value()));
1375 set (last_when, true);
1380 AudioClock::on_key_press_event (GdkEventKey* ev)
1388 int highlight_length;
1391 switch (ev->keyval) {
1434 case GDK_KP_Subtract:
1435 if (_negative_allowed && input_string.empty()) {
1436 edit_is_negative = true;
1437 edit_string.replace(0,1,"-");
1438 _layout->set_text (edit_string);
1441 end_edit_relative (false);
1447 end_edit_relative (true);
1460 ChangeAborted(); /* EMIT SIGNAL */
1465 if (!input_string.empty()) {
1466 /* delete the last key entered
1468 input_string = input_string.substr (0, input_string.length() - 1);
1470 goto use_input_string;
1473 /* do not allow other keys to passthru to the rest of the GUI
1479 if (!insert_map.empty() && (input_string.length() >= insert_map.size())) {
1480 /* too many digits: eat the key event, but do nothing with it */
1484 input_string.push_back (new_char);
1490 /* get this one in the right order, and to the right width */
1491 if (ev->keyval == GDK_Delete || ev->keyval == GDK_BackSpace) {
1492 edit_string = edit_string.substr (0, edit_string.length() - 1);
1494 edit_string.push_back (new_char);
1496 if (!edit_string.empty()) {
1498 sscanf (edit_string.c_str(), "%" PRId64, &pos);
1499 snprintf (buf, sizeof (buf), " %10" PRId64, pos);
1502 /* highlight the whole thing */
1503 highlight_length = edit_string.length();
1507 highlight_length = merge_input_and_edit_string ();
1510 if (edit_is_negative) {
1511 edit_string.replace(0,1,"-");
1513 if (!pre_edit_string.empty() && (pre_edit_string.at(0) == '-')) {
1514 edit_string.replace(0,1,"_");
1516 edit_string.replace(0,1," ");
1520 show_edit_status (highlight_length);
1521 _layout->set_text (edit_string);
1528 AudioClock::merge_input_and_edit_string ()
1530 /* merge with pre-edit-string into edit string */
1532 edit_string = pre_edit_string;
1534 if (input_string.empty()) {
1538 string::size_type target;
1539 for (string::size_type i = 0; i < input_string.length(); ++i) {
1540 target = insert_map[input_string.length() - 1 - i];
1541 edit_string[target] = input_string[i];
1543 /* highlight from end to wherever the last character was added */
1544 return edit_string.length() - insert_map[input_string.length()-1];
1549 AudioClock::on_key_release_event (GdkEventKey *ev)
1555 /* return true for keys that we used on press
1556 so that they cannot possibly do double-duty
1558 switch (ev->keyval) {
1581 case GDK_KP_Decimal:
1589 case GDK_KP_Subtract:
1597 AudioClock::index_to_field (int index) const
1602 return Timecode_Hours;
1603 } else if (index < 7) {
1604 return Timecode_Minutes;
1605 } else if (index < 10) {
1606 return Timecode_Seconds;
1608 return Timecode_Frames;
1614 } else if (index < 7) {
1622 return Timecode_Hours;
1623 } else if (index < 6) {
1625 } else if (index < 9) {
1628 return MS_Milliseconds;
1640 AudioClock::on_button_press_event (GdkEventButton *ev)
1642 switch (ev->button) {
1644 if (editable && !_off) {
1650 /* the text has been centered vertically, so adjust
1653 int xcenter = (get_width() - layout_width) /2;
1655 y = ev->y - ((upper_height - layout_height)/2);
1656 x = ev->x - xcenter;
1658 if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
1659 /* pretend it is a character on the far right */
1662 drag_field = index_to_field (index);
1664 /* make absolutely sure that the pointer is grabbed */
1665 gdk_pointer_grab(ev->window,false ,
1666 GdkEventMask( Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK |Gdk::BUTTON_RELEASE_MASK),
1667 NULL,NULL,ev->time);
1669 drag_start_y = ev->y;
1683 AudioClock::on_button_release_event (GdkEventButton *ev)
1685 if (editable && !_off) {
1687 gdk_pointer_ungrab (GDK_CURRENT_TIME);
1689 if (ev->y > drag_start_y+1 || ev->y < drag_start_y-1 || Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)){
1690 // we actually dragged so return without
1691 // setting editing focus, or we shift clicked
1694 if (ev->button == 1) {
1696 if (_edit_by_click_field) {
1698 int xcenter = (get_width() - layout_width) /2;
1701 int y = ev->y - ((upper_height - layout_height)/2);
1702 int x = ev->x - xcenter;
1705 if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
1709 f = index_to_field (index);
1712 case Timecode_Frames:
1713 case MS_Milliseconds:
1729 if (Keyboard::is_context_menu_event (ev)) {
1730 if (ops_menu == 0) {
1733 ops_menu->popup (1, ev->time);
1741 AudioClock::on_focus_out_event (GdkEventFocus* ev)
1743 bool ret = CairoWidget::on_focus_out_event (ev);
1746 end_edit (_accept_on_focus_out);
1753 AudioClock::on_scroll_event (GdkEventScroll *ev)
1758 if (editing || _session == 0 || !editable || _off) {
1765 /* the text has been centered vertically, so adjust
1769 int xcenter = (get_width() - layout_width) /2;
1770 y = ev->y - ((upper_height - layout_height)/2);
1771 x = ev->x - xcenter;
1773 if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
1774 /* not in the main layout */
1778 Field f = index_to_field (index);
1779 framepos_t frames = 0;
1781 switch (ev->direction) {
1784 frames = get_frame_step (f, current_time(), 1);
1786 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1789 set (current_time() + frames, true);
1790 ValueChanged (); /* EMIT_SIGNAL */
1794 case GDK_SCROLL_DOWN:
1795 frames = get_frame_step (f, current_time(), -1);
1797 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1801 if (!_negative_allowed && (double)current_time() - (double)frames < 0.0) {
1804 set (current_time() - frames, true);
1807 ValueChanged (); /* EMIT_SIGNAL */
1820 AudioClock::on_motion_notify_event (GdkEventMotion *ev)
1822 if (editing || _session == 0 || !dragging) {
1826 float pixel_frame_scale_factor = 0.2f;
1828 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1829 pixel_frame_scale_factor = 0.1f;
1833 if (Keyboard::modifier_state_contains (ev->state,
1834 Keyboard::PrimaryModifier|Keyboard::SecondaryModifier)) {
1836 pixel_frame_scale_factor = 0.025f;
1839 double y_delta = ev->y - drag_y;
1841 drag_accum += y_delta*pixel_frame_scale_factor;
1845 if (floor (drag_accum) != 0) {
1850 dir = (drag_accum < 0 ? 1:-1);
1851 pos = current_time();
1852 frames = get_frame_step (drag_field, pos, dir);
1854 if (frames != 0 && frames * drag_accum < current_time()) {
1855 set ((framepos_t) floor (pos - drag_accum * frames), false); // minus because up is negative in GTK
1861 ValueChanged(); /* EMIT_SIGNAL */
1868 AudioClock::get_frame_step (Field field, framepos_t pos, int dir)
1871 Timecode::BBT_Time BBT;
1873 case Timecode_Hours:
1874 f = (framecnt_t) floor (3600.0 * _session->frame_rate());
1876 case Timecode_Minutes:
1877 f = (framecnt_t) floor (60.0 * _session->frame_rate());
1879 case Timecode_Seconds:
1880 f = _session->frame_rate();
1882 case Timecode_Frames:
1883 f = (framecnt_t) floor (_session->frame_rate() / _session->timecode_frames_per_second());
1891 f = (framecnt_t) floor (3600.0 * _session->frame_rate());
1894 f = (framecnt_t) floor (60.0 * _session->frame_rate());
1897 f = (framecnt_t) _session->frame_rate();
1899 case MS_Milliseconds:
1900 f = (framecnt_t) floor (_session->frame_rate() / 1000.0);
1907 f = _session->tempo_map().bbt_duration_at (pos,BBT,dir);
1913 f = _session->tempo_map().bbt_duration_at(pos,BBT,dir);
1919 f = _session->tempo_map().bbt_duration_at(pos,BBT,dir);
1922 error << string_compose (_("programming error: %1"), "attempt to get frames from non-text field!") << endmsg;
1931 AudioClock::current_time (framepos_t) const
1937 AudioClock::current_duration (framepos_t pos) const
1946 ret = frame_duration_from_bbt_string (pos, _layout->get_text());
1962 AudioClock::bbt_validate_edit (const string& str)
1966 if (sscanf (str.c_str(), BBT_SCANF_FORMAT, &any.bbt.bars, &any.bbt.beats, &any.bbt.ticks) != 3) {
1970 if (any.bbt.ticks > Timecode::BBT_Time::ticks_per_beat) {
1974 if (!is_duration && any.bbt.bars == 0) {
1978 if (!is_duration && any.bbt.beats == 0) {
1986 AudioClock::timecode_validate_edit (const string&)
1992 if (sscanf (_layout->get_text().c_str(), "%[- _]%" PRId32 ":%" PRId32 ":%" PRId32 "%[:;]%" PRId32,
1993 ignored, &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 6) {
1998 TC.hours = hours * -1;
2002 TC.negative = false;
2005 if (TC.negative && !_negative_allowed) {
2009 if (TC.hours > 23U || TC.minutes > 59U || TC.seconds > 59U) {
2013 if (TC.frames > (uint32_t) rint (_session->timecode_frames_per_second()) - 1) {
2017 if (_session->timecode_drop_frames()) {
2018 if (TC.minutes % 10 && TC.seconds == 0U && TC.frames < 2U) {
2027 AudioClock::minsec_validate_edit (const string& str)
2029 int hrs, mins, secs, millisecs;
2031 if (sscanf (str.c_str(), "%d:%d:%d.%d", &hrs, &mins, &secs, &millisecs) != 4) {
2035 if (hrs > 23 || mins > 59 || secs > 59 || millisecs > 999) {
2043 AudioClock::frames_from_timecode_string (const string& str) const
2045 if (_session == 0) {
2054 if (sscanf (str.c_str(), "%[- _]%d:%d:%d%[:;]%d", ignored, &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 6) {
2055 error << string_compose (_("programming error: %1 %2"), "badly formatted timecode clock string", str) << endmsg;
2058 TC.hours = abs(hours);
2059 TC.rate = _session->timecode_frames_per_second();
2060 TC.drop= _session->timecode_drop_frames();
2062 _session->timecode_to_sample (TC, sample, false /* use_offset */, false /* use_subframes */ );
2064 // timecode_tester ();
2065 if (edit_is_negative) {
2073 AudioClock::frames_from_minsec_string (const string& str) const
2075 if (_session == 0) {
2079 int hrs, mins, secs, millisecs;
2080 framecnt_t sr = _session->frame_rate();
2082 if (sscanf (str.c_str(), "%d:%d:%d.%d", &hrs, &mins, &secs, &millisecs) != 4) {
2083 error << string_compose (_("programming error: %1 %2"), "badly formatted minsec clock string", str) << endmsg;
2087 return (framepos_t) floor ((hrs * 60.0f * 60.0f * sr) + (mins * 60.0f * sr) + (secs * sr) + (millisecs * sr / 1000.0));
2091 AudioClock::frames_from_bbt_string (framepos_t pos, const string& str) const
2093 if (_session == 0) {
2094 error << "AudioClock::current_time() called with BBT mode but without session!" << endmsg;
2099 any.type = AnyTime::BBT;
2101 if (sscanf (str.c_str(), BBT_SCANF_FORMAT, &any.bbt.bars, &any.bbt.beats, &any.bbt.ticks) != 3) {
2108 return _session->any_duration_to_frames (pos, any);
2110 return _session->convert_to_frames (any);
2116 AudioClock::frame_duration_from_bbt_string (framepos_t pos, const string& str) const
2118 if (_session == 0) {
2119 error << "AudioClock::frame_duration_from_bbt_string() called with BBT mode but without session!" << endmsg;
2123 Timecode::BBT_Time bbt;
2125 if (sscanf (str.c_str(), BBT_SCANF_FORMAT, &bbt.bars, &bbt.beats, &bbt.ticks) != 3) {
2129 return _session->tempo_map().bbt_duration_at(pos,bbt,1);
2133 AudioClock::frames_from_audioframes_string (const string& str) const
2136 sscanf (str.c_str(), "%" PRId64, &f);
2141 AudioClock::copy_text_to_clipboard () const
2145 val = pre_edit_string;
2147 val = _layout->get_text ();
2149 const size_t trim = val.find_first_not_of(" ");
2150 if (trim == string::npos) {
2151 assert(0); // empty clock, can't be right.
2154 Glib::RefPtr<Clipboard> cl = Gtk::Clipboard::get();
2155 cl->set_text (val.substr(trim));
2159 AudioClock::build_ops_menu ()
2161 using namespace Menu_Helpers;
2162 ops_menu = new Menu;
2163 MenuList& ops_items = ops_menu->items();
2164 ops_menu->set_name ("ArdourContextMenu");
2166 ops_items.push_back (MenuElem (_("Timecode"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Timecode, false)));
2167 ops_items.push_back (MenuElem (_("Bars:Beats"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), BBT, false)));
2168 ops_items.push_back (MenuElem (_("Minutes:Seconds"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), MinSec, false)));
2169 ops_items.push_back (MenuElem (_("Samples"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Frames, false)));
2171 if (editable && !_off && !is_duration && !_follows_playhead) {
2172 ops_items.push_back (SeparatorElem());
2173 ops_items.push_back (MenuElem (_("Set from Playhead"), sigc::mem_fun(*this, &AudioClock::set_from_playhead)));
2174 ops_items.push_back (MenuElem (_("Locate to This Time"), sigc::mem_fun(*this, &AudioClock::locate)));
2176 ops_items.push_back (SeparatorElem());
2177 ops_items.push_back (MenuElem (_("Copy to clipboard"), sigc::mem_fun(*this, &AudioClock::copy_text_to_clipboard)));
2181 AudioClock::set_from_playhead ()
2187 set (_session->transport_frame());
2192 AudioClock::locate ()
2194 if (!_session || is_duration) {
2198 _session->request_locate (current_time(), _session->transport_rolling ());
2202 AudioClock::set_mode (Mode m, bool noemit)
2212 _layout->set_text ("");
2214 Gtk::Requisition req;
2215 set_clock_dimensions (req);
2219 _left_layout->set_attributes (info_attributes);
2220 _right_layout->set_attributes (info_attributes);
2221 /* adjust info_height according to font size */
2223 _left_layout->set_text (" 1234567890");
2224 _left_layout->get_pixel_size (ignored, info_height);
2226 _left_layout->set_text ("");
2227 _right_layout->set_text ("");
2232 mode_based_info_ratio = 0.6;
2233 insert_map.push_back (11);
2234 insert_map.push_back (10);
2235 insert_map.push_back (8);
2236 insert_map.push_back (7);
2237 insert_map.push_back (5);
2238 insert_map.push_back (4);
2239 insert_map.push_back (2);
2240 insert_map.push_back (1);
2244 mode_based_info_ratio = 0.5;
2245 insert_map.push_back (11);
2246 insert_map.push_back (10);
2247 insert_map.push_back (9);
2248 insert_map.push_back (8);
2249 insert_map.push_back (6);
2250 insert_map.push_back (5);
2251 insert_map.push_back (3);
2252 insert_map.push_back (2);
2253 insert_map.push_back (1);
2257 mode_based_info_ratio = 0.6;
2258 insert_map.push_back (12);
2259 insert_map.push_back (11);
2260 insert_map.push_back (10);
2261 insert_map.push_back (8);
2262 insert_map.push_back (7);
2263 insert_map.push_back (5);
2264 insert_map.push_back (4);
2265 insert_map.push_back (2);
2266 insert_map.push_back (1);
2270 mode_based_info_ratio = 0.45;
2274 set (last_when, true);
2276 if (!is_transient && !noemit) {
2277 ModeChanged (); /* EMIT SIGNAL (the static one)*/
2280 mode_changed (); /* EMIT SIGNAL (the member one) */
2284 AudioClock::set_bbt_reference (framepos_t pos)
2286 bbt_reference_time = pos;
2290 AudioClock::on_style_changed (const Glib::RefPtr<Gtk::Style>& old_style)
2292 CairoWidget::on_style_changed (old_style);
2294 Gtk::Requisition req;
2295 set_clock_dimensions (req);
2297 /* XXXX fix me ... we shouldn't be using GTK styles anyway */
2303 AudioClock::set_editable (bool yn)
2309 AudioClock::set_is_duration (bool yn)
2311 if (yn == is_duration) {
2316 set (last_when, true);
2320 AudioClock::set_off (bool yn)
2328 /* force a redraw. last_when will be preserved, but the clock text will
2332 set (last_when, true);
2336 AudioClock::focus ()
2338 start_edit (Field (0));
2342 AudioClock::set_corner_radius (double r)
2351 AudioClock::dpi_reset ()
2353 /* force recomputation of size even if we are fixed width
2361 AudioClock::set_negative_allowed (bool yn)
2363 _negative_allowed = yn;