2 * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
3 * Copyright (C) 2005-2018 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2006-2012 David Robillard <d@drobilla.net>
5 * Copyright (C) 2007 Doug McLain <doug@nostar.net>
6 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
7 * Copyright (C) 2012-2019 Robin Gareus <robin@gareus.org>
8 * Copyright (C) 2013-2017 John Emmas <john@creativepost.co.uk>
9 * Copyright (C) 2015-2016 Tim Mayberry <mojofunk@gmail.com>
10 * Copyright (C) 2015 Ben Loftis <ben@harrisonconsoles.com>
11 * Copyright (C) 2015 Colin Fletcher <colin.m.fletcher@googlemail.com>
12 * Copyright (C) 2016-2017 Nick Mainsbridge <mainsbridge@gmail.com>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include <cstdio> // for sprintf
32 #include "pbd/convert.h"
33 #include "pbd/enumwriter.h"
35 #include <gtkmm/style.h>
36 #include <sigc++/bind.h>
38 #include "gtkmm2ext/utils.h"
39 #include "gtkmm2ext/rgb_macros.h"
41 #include "widgets/tooltips.h"
43 #include "ardour/profile.h"
44 #include "ardour/lmath.h"
45 #include "ardour/session.h"
46 #include "ardour/transport_master.h"
47 #include "ardour/tempo.h"
48 #include "ardour/transport_master_manager.h"
49 #include "ardour/types.h"
51 #include "ardour_ui.h"
52 #include "audio_clock.h"
53 #include "enums_convert.h"
54 #include "gui_thread.h"
56 #include "ui_config.h"
61 using namespace ARDOUR;
62 using namespace ARDOUR_UI_UTILS;
63 using namespace ArdourWidgets;
68 using Gtkmm2ext::Keyboard;
70 sigc::signal<void> AudioClock::ModeChanged;
71 vector<AudioClock*> AudioClock::clocks;
73 #define BBT_BAR_CHAR "|"
74 #define BBT_SCANF_FORMAT "%" PRIu32 "%*c%" PRIu32 "%*c%" PRIu32
76 AudioClock::AudioClock (const string& clock_name, bool transient, const string& widget_name,
77 bool allow_edit, bool follows_playhead, bool duration, bool with_info,
78 bool accept_on_focus_out)
81 , is_transient (transient)
82 , is_duration (duration)
83 , editable (allow_edit)
84 , _follows_playhead (follows_playhead)
85 , _accept_on_focus_out (accept_on_focus_out)
88 , _edit_by_click_field (false)
89 , _negative_allowed (false)
90 , edit_is_negative (false)
91 , _limit_pos (INT64_MAX - 1)
92 , _with_info (with_info)
97 , style_resets_first (true)
103 , bbt_reference_time (-1)
108 , drag_field (Field (0))
112 set_flags (CAN_FOCUS);
114 _layout = Pango::Layout::create (get_pango_context());
115 _layout->set_attributes (normal_attributes);
117 set_widget_name (widget_name);
119 _mode = BBT; /* lie to force mode switch */
121 AudioClock::set (last_when, true);
124 clocks.push_back (this);
127 _left_btn.set_name ("transport option button");
128 _right_btn.set_name ("transport option button");
130 _left_btn.set_sizing_text (_("0000000000000"));
131 // NB right_btn is in a size-group
133 _left_btn.set_layout_font (UIConfiguration::instance().get_SmallFont());
134 _right_btn.set_layout_font (UIConfiguration::instance().get_SmallFont());
136 UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &AudioClock::set_colors));
137 UIConfiguration::instance().DPIReset.connect (sigc::mem_fun (*this, &AudioClock::dpi_reset));
140 AudioClock::~AudioClock ()
143 delete foreground_attr;
148 AudioClock::set_widget_name (const string& str)
153 set_name (str + " clock");
163 AudioClock::on_realize ()
165 Gtk::Requisition req;
167 CairoWidget::on_realize ();
169 set_clock_dimensions (req);
171 first_width = req.width;
172 first_height = req.height;
174 // XXX FIX ME: define font based on ... ???
180 AudioClock::set_font (Pango::FontDescription font)
182 Glib::RefPtr<Gtk::Style> style = get_style ();
183 Pango::AttrFontDesc* font_attr;
185 font_size = font.get_size();
186 font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
188 normal_attributes.change (*font_attr);
189 editing_attributes.change (*font_attr);
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 AudioClock::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 editing_attributes.change (*foreground_attr);
274 editing_attributes.change (*editing_attr);
277 _layout->set_attributes (normal_attributes);
279 _layout->set_attributes (editing_attributes);
286 AudioClock::set_scale (double x, double y)
295 AudioClock::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
297 cairo_t* cr = ctx->cobj();
298 /* main layout: rounded rect, plus the text */
301 cairo_set_source_rgba (cr, bg_r, bg_g, bg_b, bg_a);
303 Gtkmm2ext::rounded_rectangle (cr, 0, 0, get_width(), get_height(), corner_radius);
305 cairo_rectangle (cr, 0, 0, get_width(), get_height());
310 double lw = layout_width * xscale;
311 double lh = layout_height * yscale;
313 cairo_move_to (cr, (get_width() - lw) / 2.0, (get_height() - lh) / 2.0);
315 if (xscale != 1.0 || yscale != 1.0) {
317 cairo_scale (cr, xscale, yscale);
320 pango_cairo_show_layout (cr, _layout->gobj());
322 if (xscale != 1.0 || yscale != 1.0) {
327 if (!insert_map.empty()) {
329 int xcenter = (get_width() - layout_width) /2;
331 if (input_string.length() < insert_map.size()) {
332 Pango::Rectangle cursor;
334 if (input_string.empty()) {
335 /* nothing entered yet, put cursor at the end
338 cursor = _layout->get_cursor_strong_pos (edit_string.length() - 1);
340 cursor = _layout->get_cursor_strong_pos (insert_map[input_string.length()]);
343 cairo_set_source_rgba (cr, cursor_r, cursor_g, cursor_b, cursor_a);
345 min (get_width() - 2.0,
346 (double) xcenter + cursor.get_x()/PANGO_SCALE + em_width),
347 (get_height() - layout_height)/2.0,
348 2.0, cursor.get_height()/PANGO_SCALE);
351 /* we've entered all possible digits, no cursor */
355 if (input_string.empty()) {
356 cairo_set_source_rgba (cr, cursor_r, cursor_g, cursor_b, cursor_a);
359 (get_height() - layout_height)/2.0,
368 AudioClock::set_clock_dimensions (Gtk::Requisition& req)
370 Glib::RefPtr<Pango::Layout> tmp;
371 Glib::RefPtr<Gtk::Style> style = get_style ();
372 Pango::FontDescription font;
374 tmp = Pango::Layout::create (get_pango_context());
376 if (!is_realized()) {
377 font = get_font_for_style (get_name());
379 font = style->get_font();
382 tmp->set_font_description (font);
384 /* this string is the longest thing we will ever display */
386 tmp->set_text (" 88:88:88,888 ");
388 tmp->set_text (" 88:88:88,88 ");
389 tmp->get_pixel_size (req.width, req.height);
391 layout_height = req.height;
392 layout_width = req.width;
396 AudioClock::on_size_request (Gtk::Requisition* req)
398 /* even for non fixed width clocks, the size we *ask* for never changes,
399 even though the size we receive might. so once we've computed it,
404 req->width = first_width;
405 req->height = first_height;
409 set_clock_dimensions (*req);
411 /* now tackle height, for which we need to know the height of the lower
417 AudioClock::show_edit_status (int length)
419 editing_attr->set_start_index (edit_string.length() - length);
420 editing_attr->set_end_index (edit_string.length());
422 editing_attributes.change (*foreground_attr);
423 editing_attributes.change (*editing_attr);
425 _layout->set_attributes (editing_attributes);
429 AudioClock::start_edit (Field f)
432 pre_edit_string = _layout->get_text ();
433 if (!insert_map.empty()) {
434 edit_string = pre_edit_string;
436 edit_string.clear ();
437 _layout->set_text ("");
440 input_string.clear ();
442 edit_is_negative = false;
445 input_string = get_field (f);
446 show_edit_status (merge_input_and_edit_string ());
447 _layout->set_text (edit_string);
452 Keyboard::magic_widget_grab_focus ();
458 AudioClock::get_field (Field f)
462 return edit_string.substr (1, 2);
464 case Timecode_Minutes:
465 return edit_string.substr (4, 2);
467 case Timecode_Seconds:
468 return edit_string.substr (7, 2);
470 case Timecode_frames:
471 return edit_string.substr (10, 2);
474 return edit_string.substr (1, 2);
477 return edit_string.substr (4, 2);
480 return edit_string.substr (7, 2);
482 case MS_Milliseconds:
483 return edit_string.substr (10, 3);
486 return edit_string.substr (1, 3);
489 return edit_string.substr (5, 2);
492 return edit_string.substr (8, 4);
495 return edit_string.substr (0, 8);
497 return edit_string.substr (9, 1);
506 AudioClock::end_edit (bool modify)
514 ok = timecode_validate_edit (edit_string);
518 ok = bbt_validate_edit (edit_string);
522 ok = minsec_validate_edit (edit_string);
528 if (edit_string.length() < 1) {
529 edit_string = pre_edit_string;
535 edit_string = pre_edit_string;
536 input_string.clear ();
537 _layout->set_text (edit_string);
538 show_edit_status (0);
539 /* edit attributes remain in use */
543 samplepos_t pos = 0; /* stupid gcc */
547 pos = samples_from_timecode_string (edit_string);
552 pos = sample_duration_from_bbt_string (bbt_reference_time, edit_string);
554 pos = samples_from_bbt_string (0, edit_string);
559 pos = samples_from_minsec_string (edit_string);
563 pos = samples_from_seconds_string (edit_string);
567 pos = samples_from_audiosamples_string (edit_string);
571 AudioClock::set (pos, true);
572 _layout->set_attributes (normal_attributes);
573 ValueChanged(); /* EMIT_SIGNAL */
579 edit_is_negative = false;
580 _layout->set_attributes (normal_attributes);
581 _layout->set_text (pre_edit_string);
592 AudioClock::drop_focus ()
594 Keyboard::magic_widget_drop_focus ();
597 /* move focus back to the default widget in the top level window */
598 ARDOUR_UI::instance()->reset_focus (this);
603 AudioClock::parse_as_seconds_distance (const std::string& str)
607 if (sscanf (str.c_str(), "%f", &f) == 1) {
608 return f * _session->sample_rate();
615 AudioClock::parse_as_samples_distance (const std::string& str)
619 if (sscanf (str.c_str(), "%" PRId64, &f) == 1) {
627 AudioClock::parse_as_minsec_distance (const std::string& str)
629 samplecnt_t sr = _session->sample_rate();
635 switch (str.length()) {
642 sscanf (str.c_str(), "%" PRId32, &msecs);
643 return msecs * (sr / 1000);
646 sscanf (str.c_str(), "%1" PRId32 "%" PRId32, &secs, &msecs);
647 return (secs * sr) + (msecs * (sr/1000));
650 sscanf (str.c_str(), "%2" PRId32 "%" PRId32, &secs, &msecs);
651 return (secs * sr) + (msecs * (sr/1000));
654 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &msecs);
655 return (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
658 sscanf (str.c_str(), "%2" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &msecs);
659 return (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
662 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &msecs);
663 return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
666 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &msecs);
667 return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
677 AudioClock::parse_as_timecode_distance (const std::string& str)
679 double fps = _session->timecode_frames_per_second();
680 samplecnt_t sr = _session->sample_rate();
686 switch (str.length()) {
691 sscanf (str.c_str(), "%" PRId32, &samples);
692 return llrint ((samples/(float)fps) * sr);
695 sscanf (str.c_str(), "%1" PRId32 "%" PRId32, &secs, &samples);
696 return (secs * sr) + llrint ((samples/(float)fps) * sr);
699 sscanf (str.c_str(), "%2" PRId32 "%" PRId32, &secs, &samples);
700 return (secs * sr) + llrint ((samples/(float)fps) * sr);
703 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &samples);
704 return (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
707 sscanf (str.c_str(), "%2" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &samples);
708 return (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
711 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &samples);
712 return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
715 sscanf (str.c_str(), "%2" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &samples);
716 return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
726 AudioClock::parse_as_bbt_distance (const std::string&)
732 AudioClock::parse_as_distance (const std::string& instr)
736 return parse_as_timecode_distance (instr);
739 return parse_as_samples_distance (instr);
742 return parse_as_bbt_distance (instr);
745 return parse_as_minsec_distance (instr);
748 return parse_as_seconds_distance (instr);
755 AudioClock::end_edit_relative (bool add)
761 ok = timecode_validate_edit (edit_string);
765 ok = bbt_validate_edit (edit_string);
769 ok = minsec_validate_edit (edit_string);
780 edit_string = pre_edit_string;
781 input_string.clear ();
782 _layout->set_text (edit_string);
783 show_edit_status (0);
784 /* edit attributes remain in use */
789 samplecnt_t samples = parse_as_distance (input_string);
794 _layout->set_attributes (normal_attributes);
798 AudioClock::set (current_time() + samples, true);
800 samplepos_t c = current_time();
802 if (c > samples || _negative_allowed) {
803 AudioClock::set (c - samples, true);
805 AudioClock::set (0, true);
808 ValueChanged (); /* EMIT SIGNAL */
811 input_string.clear ();
817 AudioClock::session_property_changed (const PropertyChange&)
819 AudioClock::set (last_when, true);
823 AudioClock::session_configuration_changed (std::string p)
825 if (_negative_allowed) {
826 /* session option editor clock */
830 if (p == "sync-source" || p == "external-sync") {
831 AudioClock::set (current_time(), true);
835 if (p != "timecode-offset" && p != "timecode-offset-negative") {
844 current = current_duration ();
846 current = current_time ();
848 AudioClock::set (current, true);
856 AudioClock::set (samplepos_t when, bool force, samplecnt_t offset)
858 if ((!force && !is_visible()) || _session == 0) {
864 when = when - offset;
867 if (when > _limit_pos) {
869 } else if (when < -_limit_pos) {
873 if (when == last_when && !force) {
874 #if 0 // XXX return if no change and no change forced. verify Aug/2014
875 if (_mode != Timecode && _mode != MinSec) {
876 /* may need to force display of TC source
877 * time, so don't return early.
879 /* ^^ Why was that?, delta times?
880 * Timecode FPS, pull-up/down, etc changes
881 * trigger a 'session_property_changed' which
882 * eventually calls set(last_when, true)
884 * re-rendering the clock every 40ms or so just
885 * because we can is not ideal.
900 set_timecode (when, force);
904 set_bbt (when, offset, force);
909 set_minsec (when, force);
913 set_seconds (when, force);
917 set_samples (when, force);
923 _left_btn.set_sensitive (btn_en);
924 _right_btn.set_sensitive (btn_en);
925 _left_btn.set_visual_state (Gtkmm2ext::NoVisualState);
926 _right_btn.set_visual_state (Gtkmm2ext::NoVisualState);
928 _left_btn.set_elements (ArdourButton::Element(ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text));
929 _right_btn.set_elements (ArdourButton::Element(ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text));
930 _left_btn.set_alignment (.5, .5);
931 _right_btn.set_alignment (.5, .5);
932 set_tooltip (_left_btn, _("Change current tempo"));
933 set_tooltip (_right_btn, _("Change current time signature"));
935 _left_btn.set_elements (ArdourButton::Text);
936 _right_btn.set_elements (ArdourButton::Text);
937 _left_btn.set_alignment (0, .5);
938 _right_btn.set_alignment (1, .5);
939 set_tooltip (_left_btn, _(""));
940 set_tooltip (_right_btn, _(""));
949 AudioClock::set_slave_info ()
955 boost::shared_ptr<TransportMaster> tm = TransportMasterManager::instance().current();
957 if (_session->transport_master_is_external()) {
959 switch (tm->type()) {
961 _left_btn.set_text (tm->name(), true);
962 _right_btn.set_text ("", true);
966 _left_btn.set_text (tm->display_name(), true);
967 _right_btn.set_text (tm->delta_string (), true);
969 _left_btn.set_text (_("--pending--"), true);
970 _right_btn.set_text ("", true);
977 boost::shared_ptr<TimecodeTransportMaster> tcmaster;
978 if ((tcmaster = boost::dynamic_pointer_cast<TimecodeTransportMaster>(tm)) != 0) {
979 matching = (tcmaster->apparent_timecode_format() == _session->config.get_timecode_format());
980 _left_btn.set_text (string_compose ("%1<span face=\"monospace\" foreground=\"%3\">%2</span>",
981 tm->display_name()[0],
982 tcmaster->position_string (),
983 matching ? "#66ff66" : "#ff3333"
985 _right_btn.set_text (tm->delta_string (), true);
988 _left_btn.set_text (_("--pending--"), true);
989 _right_btn.set_text ("", true);
994 _left_btn.set_text (string_compose ("%1/%2", _("INT"), tm->display_name()), true);
995 _right_btn.set_text ("", true);
1000 AudioClock::set_out_of_bounds (bool negative)
1004 _layout->set_text (" >>> -- <<< ");
1006 _layout->set_text (" >>> ++ <<< ");
1010 _layout->set_text (" <<<<<<<<<< ");
1012 _layout->set_text (" >>>>>>>>>> ");
1018 AudioClock::set_samples (samplepos_t when, bool /*force*/)
1021 bool negative = false;
1024 _layout->set_text (" ----------");
1025 _left_btn.set_text ("", true);
1026 _right_btn.set_text ("", true);
1035 if (when >= _limit_pos) {
1036 set_out_of_bounds (negative);
1037 } else if (negative) {
1038 snprintf (buf, sizeof (buf), "-%10" PRId64, when);
1039 _layout->set_text (buf);
1041 snprintf (buf, sizeof (buf), " %10" PRId64, when);
1042 _layout->set_text (buf);
1046 samplecnt_t rate = _session->sample_rate();
1048 if (fmod (rate, 100.0) == 0.0) {
1049 sprintf (buf, "%.1fkHz", rate/1000.0);
1051 sprintf (buf, "%" PRId64 "Hz", rate);
1054 _left_btn.set_text (string_compose ("%1 %2", _("SR"), buf), true);
1056 float vid_pullup = _session->config.get_video_pullup();
1058 if (vid_pullup == 0.0) {
1059 _right_btn.set_text ("", true);
1061 sprintf (buf, _("%+.4f%%"), vid_pullup);
1062 _right_btn.set_text (string_compose ("%1 %2", _("Pull"), buf), true);
1068 AudioClock::set_seconds (samplepos_t when, bool /*force*/)
1073 _layout->set_text (" ----------");
1074 _left_btn.set_text ("", true);
1075 _right_btn.set_text ("", true);
1079 if (when >= _limit_pos || when <= -_limit_pos) {
1080 set_out_of_bounds (when < 0);
1083 snprintf (buf, sizeof (buf), "%12.1f", when / (float)_session->sample_rate());
1085 snprintf (buf, sizeof (buf), " %11.1f", when / (float)_session->sample_rate());
1087 _layout->set_text (buf);
1094 AudioClock::print_minsec (samplepos_t when, char* buf, size_t bufsize, float sample_rate)
1111 hrs = (int) floor (left / (sample_rate * 60.0f * 60.0f));
1112 left -= (samplecnt_t) floor (hrs * sample_rate * 60.0f * 60.0f);
1113 mins = (int) floor (left / (sample_rate * 60.0f));
1114 left -= (samplecnt_t) floor (mins * sample_rate * 60.0f);
1115 secs = (int) floor (left / (float) sample_rate);
1116 left -= (samplecnt_t) floor ((double)(secs * sample_rate));
1117 millisecs = floor (left * 1000.0 / (float) sample_rate);
1120 snprintf (buf, bufsize, "-%02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs);
1122 snprintf (buf, bufsize, " %02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs);
1128 AudioClock::set_minsec (samplepos_t when, bool /*force*/)
1133 _layout->set_text (" --:--:--.---");
1134 _left_btn.set_text ("", true);
1135 _right_btn.set_text ("", true);
1140 if (when >= _limit_pos || when <= -_limit_pos) {
1141 set_out_of_bounds (when < 0);
1143 print_minsec (when, buf, sizeof (buf), _session->sample_rate());
1144 _layout->set_text (buf);
1151 AudioClock::set_timecode (samplepos_t when, bool /*force*/)
1154 bool negative = false;
1157 _layout->set_text (" --:--:--:--");
1158 _left_btn.set_text ("", true);
1159 _right_btn.set_text ("", true);
1167 if (when >= _limit_pos) {
1168 set_out_of_bounds (negative);
1174 _session->timecode_duration (when, TC);
1176 _session->timecode_time (when, TC);
1179 TC.negative = TC.negative || negative;
1181 _layout->set_text (Timecode::timecode_format_time(TC));
1187 AudioClock::set_bbt (samplepos_t when, samplecnt_t offset, bool /*force*/)
1190 Timecode::BBT_Time BBT;
1191 bool negative = false;
1193 if (_off || when >= _limit_pos || when < -_limit_pos) {
1194 _layout->set_text (" ---|--|----");
1195 _left_btn.set_text ("", true);
1196 _right_btn.set_text ("", true);
1205 /* handle a common case */
1212 TempoMap& tmap (_session->tempo_map());
1215 offset = bbt_reference_time;
1218 const double divisions = tmap.meter_section_at_sample (offset).divisions_per_bar();
1219 Timecode::BBT_Time sub_bbt;
1222 BBT = tmap.bbt_at_beat (tmap.beat_at_sample (offset));
1223 sub_bbt = tmap.bbt_at_sample (offset - when);
1225 BBT = tmap.bbt_at_beat (tmap.beat_at_sample (when + offset));
1226 sub_bbt = tmap.bbt_at_sample (offset);
1229 BBT.bars -= sub_bbt.bars;
1231 if (BBT.ticks < sub_bbt.ticks) {
1232 if (BBT.beats == 1) {
1234 BBT.beats = divisions;
1238 BBT.ticks = Timecode::BBT_Time::ticks_per_beat - (sub_bbt.ticks - BBT.ticks);
1240 BBT.ticks -= sub_bbt.ticks;
1243 if (BBT.beats < sub_bbt.beats) {
1245 BBT.beats = divisions - (sub_bbt.beats - BBT.beats);
1247 BBT.beats -= sub_bbt.beats;
1251 BBT = _session->tempo_map().bbt_at_sample (when);
1255 snprintf (buf, sizeof (buf), "-%03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
1256 BBT.bars, BBT.beats, BBT.ticks);
1258 snprintf (buf, sizeof (buf), " %03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
1259 BBT.bars, BBT.beats, BBT.ticks);
1262 _layout->set_text (buf);
1267 if (bbt_reference_time < 0) {
1270 pos = bbt_reference_time;
1273 TempoMetric m (_session->tempo_map().metric_at (pos));
1275 if (m.tempo().note_type() == 4) {
1276 snprintf (buf, sizeof(buf), "\u2669 = %.3f", _session->tempo_map().tempo_at_sample (pos).note_types_per_minute());
1277 _left_btn.set_text (string_compose ("%1", buf), true);
1278 } else if (m.tempo().note_type() == 8) {
1279 snprintf (buf, sizeof(buf), "\u266a = %.3f", _session->tempo_map().tempo_at_sample (pos).note_types_per_minute());
1280 _left_btn.set_text (string_compose ("%1", buf), true);
1282 snprintf (buf, sizeof(buf), "%.1f = %.3f", m.tempo().note_type(), _session->tempo_map().tempo_at_sample (pos).note_types_per_minute());
1283 _left_btn.set_text (string_compose ("%1: %2", S_("Tempo|T"), buf), true);
1286 snprintf (buf, sizeof(buf), "%g/%g", m.meter().divisions_per_bar(), m.meter().note_divisor());
1287 _right_btn.set_text (string_compose ("%1: %2", S_("TimeSignature|TS"), buf), true);
1292 AudioClock::set_session (Session *s)
1294 SessionHandlePtr::set_session (s);
1298 int64_t limit_sec = UIConfiguration::instance().get_clock_display_limit ();
1299 if (limit_sec > 0) {
1300 _limit_pos = (samplecnt_t) floor ((double)(limit_sec * _session->sample_rate()));
1303 Config->ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
1304 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
1305 _session->tempo_map().PropertyChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_property_changed, this, _1), gui_context());
1306 _session->tempo_map().MetricPositionChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_property_changed, this, _1), gui_context());
1308 XMLNode* node = _session->extra_xml (X_("ClockModes"));
1311 for (XMLNodeList::const_iterator i = node->children().begin(); i != node->children().end(); ++i) {
1313 if ((*i)->get_property (X_("name"), name) && name == _name) {
1315 AudioClock::Mode amode;
1316 if ((*i)->get_property (X_("mode"), amode)) {
1317 set_mode (amode, true);
1320 if ((*i)->get_property (X_("on"), on)) {
1328 AudioClock::set (last_when, true);
1333 AudioClock::on_key_press_event (GdkEventKey* ev)
1341 int highlight_length;
1344 switch (ev->keyval) {
1387 case GDK_KP_Subtract:
1388 if (_negative_allowed && input_string.empty()) {
1389 edit_is_negative = true;
1390 edit_string.replace(0,1,"-");
1391 _layout->set_text (edit_string);
1394 end_edit_relative (false);
1400 end_edit_relative (true);
1413 ChangeAborted(); /* EMIT SIGNAL */
1418 if (!input_string.empty()) {
1419 /* delete the last key entered
1421 input_string = input_string.substr (0, input_string.length() - 1);
1423 goto use_input_string;
1426 /* do not allow other keys to passthru to the rest of the GUI
1432 if (!insert_map.empty() && (input_string.length() >= insert_map.size())) {
1433 /* too many digits: eat the key event, but do nothing with it */
1437 input_string.push_back (new_char);
1443 /* get this one in the right order, and to the right width */
1444 if (ev->keyval == GDK_Delete || ev->keyval == GDK_BackSpace) {
1445 edit_string = edit_string.substr (0, edit_string.length() - 1);
1447 edit_string.push_back (new_char);
1449 if (!edit_string.empty()) {
1451 sscanf (edit_string.c_str(), "%" PRId64, &pos);
1452 snprintf (buf, sizeof (buf), " %10" PRId64, pos);
1455 /* highlight the whole thing */
1456 highlight_length = edit_string.length();
1460 highlight_length = merge_input_and_edit_string ();
1463 if (edit_is_negative) {
1464 edit_string.replace(0,1,"-");
1466 if (!pre_edit_string.empty() && (pre_edit_string.at(0) == '-')) {
1467 edit_string.replace(0,1,"_");
1469 edit_string.replace(0,1," ");
1473 show_edit_status (highlight_length);
1474 _layout->set_text (edit_string);
1481 AudioClock::merge_input_and_edit_string ()
1483 /* merge with pre-edit-string into edit string */
1485 edit_string = pre_edit_string;
1487 if (input_string.empty()) {
1491 string::size_type target;
1492 for (string::size_type i = 0; i < input_string.length(); ++i) {
1493 target = insert_map[input_string.length() - 1 - i];
1494 edit_string[target] = input_string[i];
1496 /* highlight from end to wherever the last character was added */
1497 return edit_string.length() - insert_map[input_string.length()-1];
1502 AudioClock::on_key_release_event (GdkEventKey *ev)
1508 /* return true for keys that we used on press
1509 so that they cannot possibly do double-duty
1511 switch (ev->keyval) {
1534 case GDK_KP_Decimal:
1542 case GDK_KP_Subtract:
1550 AudioClock::index_to_field (int index) const
1555 return Timecode_Hours;
1556 } else if (index < 7) {
1557 return Timecode_Minutes;
1558 } else if (index < 10) {
1559 return Timecode_Seconds;
1561 return Timecode_frames;
1567 } else if (index < 7) {
1575 return Timecode_Hours;
1576 } else if (index < 6) {
1578 } else if (index < 9) {
1581 return MS_Milliseconds;
1588 return SS_Deciseconds;
1600 AudioClock::on_button_press_event (GdkEventButton *ev)
1602 if (!_session || _session->actively_recording()) {
1603 /* swallow event, do nothing */
1607 switch (ev->button) {
1609 if (editable && !_off) {
1615 /* the text has been centered vertically, so adjust
1618 int xcenter = (get_width() - layout_width) /2;
1620 y = ev->y - ((get_height() - layout_height)/2);
1621 x = ev->x - xcenter;
1623 if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
1624 /* pretend it is a character on the far right */
1627 drag_field = index_to_field (index);
1629 /* make absolutely sure that the pointer is grabbed */
1630 gdk_pointer_grab(ev->window,false ,
1631 GdkEventMask( Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK |Gdk::BUTTON_RELEASE_MASK),
1632 NULL,NULL,ev->time);
1634 drag_start_y = ev->y;
1648 AudioClock::on_button_release_event (GdkEventButton *ev)
1650 if (!_session || _session->actively_recording()) {
1651 /* swallow event, do nothing */
1655 if (editable && !_off) {
1657 gdk_pointer_ungrab (GDK_CURRENT_TIME);
1659 if (ev->y > drag_start_y+1 || ev->y < drag_start_y-1 || Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)){
1660 // we actually dragged so return without
1661 // setting editing focus, or we shift clicked
1664 if (ev->button == 1) {
1666 if (_edit_by_click_field) {
1668 int xcenter = (get_width() - layout_width) /2;
1671 int y = ev->y - ((get_height() - layout_height)/2);
1672 int x = ev->x - xcenter;
1675 if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
1679 f = index_to_field (index);
1682 case Timecode_frames:
1683 case MS_Milliseconds:
1685 case SS_Deciseconds:
1700 if (Keyboard::is_context_menu_event (ev)) {
1701 if (ops_menu == 0) {
1704 ops_menu->popup (1, ev->time);
1712 AudioClock::on_focus_out_event (GdkEventFocus* ev)
1714 bool ret = CairoWidget::on_focus_out_event (ev);
1717 end_edit (_accept_on_focus_out);
1724 AudioClock::on_scroll_event (GdkEventScroll *ev)
1729 if (editing || _session == 0 || !editable || _off || _session->actively_recording()) {
1736 /* the text has been centered vertically, so adjust
1740 int xcenter = (get_width() - layout_width) /2;
1741 y = ev->y - ((get_height() - layout_height)/2);
1742 x = ev->x - xcenter;
1744 if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
1745 /* not in the main layout */
1749 Field f = index_to_field (index);
1750 samplepos_t samples = 0;
1752 switch (ev->direction) {
1755 samples = get_sample_step (f, current_time(), 1);
1757 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1760 AudioClock::set (current_time() + samples, true);
1761 ValueChanged (); /* EMIT_SIGNAL */
1765 case GDK_SCROLL_DOWN:
1766 samples = get_sample_step (f, current_time(), -1);
1768 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1772 if (!_negative_allowed && (double)current_time() - (double)samples < 0.0) {
1773 AudioClock::set (0, true);
1775 AudioClock::set (current_time() - samples, true);
1778 ValueChanged (); /* EMIT_SIGNAL */
1791 AudioClock::on_motion_notify_event (GdkEventMotion *ev)
1793 if (editing || _session == 0 || !dragging || _session->actively_recording()) {
1797 float pixel_sample_scale_factor = 0.2f;
1799 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1800 pixel_sample_scale_factor = 0.1f;
1804 if (Keyboard::modifier_state_contains (ev->state,
1805 Keyboard::PrimaryModifier|Keyboard::SecondaryModifier)) {
1806 pixel_sample_scale_factor = 0.025f;
1809 double y_delta = ev->y - drag_y;
1811 drag_accum += y_delta*pixel_sample_scale_factor;
1815 if (floor (drag_accum) != 0) {
1817 samplepos_t samples;
1820 dir = (drag_accum < 0 ? 1:-1);
1821 pos = current_time();
1822 samples = get_sample_step (drag_field, pos, dir);
1824 if (samples != 0 && samples * drag_accum < current_time()) {
1825 AudioClock::set ((samplepos_t) floor (pos - drag_accum * samples), false); // minus because up is negative in GTK
1827 AudioClock::set (0 , false);
1831 ValueChanged(); /* EMIT_SIGNAL */
1838 AudioClock::get_sample_step (Field field, samplepos_t pos, int dir)
1841 Timecode::BBT_Time BBT;
1843 case Timecode_Hours:
1844 f = (samplecnt_t) floor (3600.0 * _session->sample_rate());
1846 case Timecode_Minutes:
1847 f = (samplecnt_t) floor (60.0 * _session->sample_rate());
1849 case Timecode_Seconds:
1850 f = _session->sample_rate();
1852 case Timecode_frames:
1853 f = (samplecnt_t) floor (_session->sample_rate() / _session->timecode_frames_per_second());
1861 f = (samplecnt_t) _session->sample_rate();
1863 case SS_Deciseconds:
1864 f = (samplecnt_t) _session->sample_rate() / 10.f;
1868 f = (samplecnt_t) floor (3600.0 * _session->sample_rate());
1871 f = (samplecnt_t) floor (60.0 * _session->sample_rate());
1874 f = (samplecnt_t) _session->sample_rate();
1876 case MS_Milliseconds:
1877 f = (samplecnt_t) floor (_session->sample_rate() / 1000.0);
1884 f = _session->tempo_map().bbt_duration_at (pos,BBT,dir);
1890 f = _session->tempo_map().bbt_duration_at(pos,BBT,dir);
1896 f = _session->tempo_map().bbt_duration_at(pos,BBT,dir);
1899 error << string_compose (_("programming error: %1"), "attempt to get samples from non-text field!") << endmsg;
1908 AudioClock::current_time (samplepos_t) const
1914 AudioClock::current_duration (samplepos_t pos) const
1916 samplepos_t ret = 0;
1920 ret = sample_duration_from_bbt_string (pos, _layout->get_text());
1935 AudioClock::bbt_validate_edit (string & str)
1939 if (sscanf (str.c_str(), BBT_SCANF_FORMAT, &any.bbt.bars, &any.bbt.beats, &any.bbt.ticks) != 3) {
1943 if (any.bbt.ticks > Timecode::BBT_Time::ticks_per_beat) {
1947 if (!is_duration && any.bbt.bars == 0) {
1951 if (!is_duration && any.bbt.beats == 0) {
1952 /* user could not have mean zero beats because for a
1953 * non-duration clock that's impossible. Assume that they
1954 * mis-entered things and meant Bar|1|ticks
1958 snprintf (buf, sizeof (buf), "%" PRIu32 "|%" PRIu32 "|%" PRIu32, any.bbt.bars, 1, any.bbt.ticks);
1966 AudioClock::timecode_validate_edit (const string&)
1972 if (sscanf (_layout->get_text().c_str(), "%[- _]%" PRId32 ":%" PRId32 ":%" PRId32 "%[:;]%" PRId32,
1973 ignored, &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 6) {
1978 TC.hours = hours * -1;
1982 TC.negative = false;
1985 if (TC.negative && !_negative_allowed) {
1989 if (TC.hours > 23U || TC.minutes > 59U || TC.seconds > 59U) {
1993 if (TC.frames > (uint32_t) rint (_session->timecode_frames_per_second()) - 1) {
1997 if (_session->timecode_drop_frames()) {
1998 if (TC.minutes % 10 && TC.seconds == 0U && TC.frames < 2U) {
2007 AudioClock::minsec_validate_edit (const string& str)
2009 int hrs, mins, secs, millisecs;
2011 if (sscanf (str.c_str(), "%d:%d:%d.%d", &hrs, &mins, &secs, &millisecs) != 4) {
2015 if (hrs > 23 || mins > 59 || secs > 59 || millisecs > 999) {
2023 AudioClock::samples_from_timecode_string (const string& str) const
2025 if (_session == 0) {
2034 if (sscanf (str.c_str(), "%[- _]%d:%d:%d%[:;]%d", ignored, &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 6) {
2035 error << string_compose (_("programming error: %1 %2"), "badly formatted timecode clock string", str) << endmsg;
2038 TC.hours = abs(hours);
2039 TC.rate = _session->timecode_frames_per_second();
2040 TC.drop= _session->timecode_drop_frames();
2042 _session->timecode_to_sample (TC, sample, false /* use_offset */, false /* use_subframes */ );
2044 // timecode_tester ();
2045 if (edit_is_negative) {
2053 AudioClock::samples_from_minsec_string (const string& str) const
2055 if (_session == 0) {
2059 int hrs, mins, secs, millisecs;
2060 samplecnt_t sr = _session->sample_rate();
2062 if (sscanf (str.c_str(), "%d:%d:%d.%d", &hrs, &mins, &secs, &millisecs) != 4) {
2063 error << string_compose (_("programming error: %1 %2"), "badly formatted minsec clock string", str) << endmsg;
2067 return (samplepos_t) floor ((hrs * 60.0f * 60.0f * sr) + (mins * 60.0f * sr) + (secs * sr) + (millisecs * sr / 1000.0));
2071 AudioClock::samples_from_bbt_string (samplepos_t pos, const string& str) const
2073 if (_session == 0) {
2074 error << "AudioClock::current_time() called with BBT mode but without session!" << endmsg;
2079 any.type = AnyTime::BBT;
2081 if (sscanf (str.c_str(), BBT_SCANF_FORMAT, &any.bbt.bars, &any.bbt.beats, &any.bbt.ticks) != 3) {
2088 return _session->any_duration_to_samples (pos, any);
2090 return _session->convert_to_samples (any);
2096 AudioClock::sample_duration_from_bbt_string (samplepos_t pos, const string& str) const
2098 if (_session == 0) {
2099 error << "AudioClock::sample_duration_from_bbt_string() called with BBT mode but without session!" << endmsg;
2103 Timecode::BBT_Time bbt;
2105 if (sscanf (str.c_str(), BBT_SCANF_FORMAT, &bbt.bars, &bbt.beats, &bbt.ticks) != 3) {
2109 return _session->tempo_map().bbt_duration_at(pos,bbt,1);
2113 AudioClock::samples_from_seconds_string (const string& str) const
2116 sscanf (str.c_str(), "%f", &f);
2117 return f * _session->sample_rate();
2121 AudioClock::samples_from_audiosamples_string (const string& str) const
2124 sscanf (str.c_str(), "%" PRId64, &f);
2129 AudioClock::copy_text_to_clipboard () const
2133 val = pre_edit_string;
2135 val = _layout->get_text ();
2137 const size_t trim = val.find_first_not_of(" ");
2138 if (trim == string::npos) {
2139 assert(0); // empty clock, can't be right.
2142 Glib::RefPtr<Clipboard> cl = Gtk::Clipboard::get();
2143 cl->set_text (val.substr(trim));
2147 AudioClock::build_ops_menu ()
2149 using namespace Menu_Helpers;
2150 ops_menu = new Menu;
2151 MenuList& ops_items = ops_menu->items();
2152 ops_menu->set_name ("ArdourContextMenu");
2154 ops_items.push_back (MenuElem (_("Timecode"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Timecode, false)));
2155 ops_items.push_back (MenuElem (_("Bars:Beats"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), BBT, false)));
2156 ops_items.push_back (MenuElem (_("Minutes:Seconds"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), MinSec, false)));
2157 ops_items.push_back (MenuElem (_("Seconds"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Seconds, false)));
2158 ops_items.push_back (MenuElem (_("Samples"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Samples, false)));
2160 if (editable && !_off && !is_duration && !_follows_playhead) {
2161 ops_items.push_back (SeparatorElem());
2162 ops_items.push_back (MenuElem (_("Set from Playhead"), sigc::mem_fun(*this, &AudioClock::set_from_playhead)));
2163 ops_items.push_back (MenuElem (_("Locate to This Time"), sigc::mem_fun(*this, &AudioClock::locate)));
2165 ops_items.push_back (SeparatorElem());
2166 ops_items.push_back (MenuElem (_("Copy to clipboard"), sigc::mem_fun(*this, &AudioClock::copy_text_to_clipboard)));
2170 AudioClock::set_from_playhead ()
2176 AudioClock::set (_session->transport_sample());
2181 AudioClock::locate ()
2183 if (!_session || is_duration) {
2187 _session->request_locate (current_time(), _session->transport_rolling ());
2191 AudioClock::set_mode (Mode m, bool noemit)
2201 _layout->set_text ("");
2203 Gtk::Requisition req;
2204 set_clock_dimensions (req);
2208 insert_map.push_back (11);
2209 insert_map.push_back (10);
2210 insert_map.push_back (8);
2211 insert_map.push_back (7);
2212 insert_map.push_back (5);
2213 insert_map.push_back (4);
2214 insert_map.push_back (2);
2215 insert_map.push_back (1);
2219 insert_map.push_back (11);
2220 insert_map.push_back (10);
2221 insert_map.push_back (9);
2222 insert_map.push_back (8);
2223 insert_map.push_back (6);
2224 insert_map.push_back (5);
2225 insert_map.push_back (3);
2226 insert_map.push_back (2);
2227 insert_map.push_back (1);
2231 insert_map.push_back (12);
2232 insert_map.push_back (11);
2233 insert_map.push_back (10);
2234 insert_map.push_back (8);
2235 insert_map.push_back (7);
2236 insert_map.push_back (5);
2237 insert_map.push_back (4);
2238 insert_map.push_back (2);
2239 insert_map.push_back (1);
2243 insert_map.push_back (11);
2244 insert_map.push_back (9);
2245 insert_map.push_back (8);
2246 insert_map.push_back (7);
2247 insert_map.push_back (6);
2248 insert_map.push_back (5);
2249 insert_map.push_back (4);
2250 insert_map.push_back (3);
2251 insert_map.push_back (2);
2252 insert_map.push_back (1);
2259 AudioClock::set (last_when, true);
2261 if (!is_transient && !noemit) {
2262 ModeChanged (); /* EMIT SIGNAL (the static one)*/
2265 mode_changed (); /* EMIT SIGNAL (the member one) */
2269 AudioClock::set_bbt_reference (samplepos_t pos)
2271 bbt_reference_time = pos;
2275 AudioClock::on_style_changed (const Glib::RefPtr<Gtk::Style>& old_style)
2277 CairoWidget::on_style_changed (old_style);
2279 Gtk::Requisition req;
2280 set_clock_dimensions (req);
2282 /* XXXX fix me ... we shouldn't be using GTK styles anyway */
2288 AudioClock::set_editable (bool yn)
2294 AudioClock::set_is_duration (bool yn)
2296 if (yn == is_duration) {
2301 AudioClock::set (last_when, true);
2305 AudioClock::set_off (bool yn)
2313 /* force a redraw. last_when will be preserved, but the clock text will
2317 AudioClock::set (last_when, true);
2321 AudioClock::focus ()
2323 start_edit (Field (0));
2327 AudioClock::set_corner_radius (double r)
2336 AudioClock::dpi_reset ()
2338 /* force recomputation of size even if we are fixed width
2346 AudioClock::set_negative_allowed (bool yn)
2348 _negative_allowed = yn;