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_sizing_text (_("0000000000000"));
128 // NB right_btn is in a size-group
130 _left_btn.set_layout_font (UIConfiguration::instance().get_SmallFont());
131 _right_btn.set_layout_font (UIConfiguration::instance().get_SmallFont());
133 UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &AudioClock::set_colors));
134 UIConfiguration::instance().DPIReset.connect (sigc::mem_fun (*this, &AudioClock::dpi_reset));
137 AudioClock::~AudioClock ()
140 delete foreground_attr;
145 AudioClock::set_widget_name (const string& str)
150 set_name (str + " clock");
160 AudioClock::on_realize ()
162 Gtk::Requisition req;
164 CairoWidget::on_realize ();
166 set_clock_dimensions (req);
168 first_width = req.width;
169 first_height = req.height;
171 // XXX FIX ME: define font based on ... ???
177 AudioClock::set_font (Pango::FontDescription font)
179 Glib::RefPtr<Gtk::Style> style = get_style ();
180 Pango::AttrFontDesc* font_attr;
182 font_size = font.get_size();
183 font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
185 normal_attributes.change (*font_attr);
186 editing_attributes.change (*font_attr);
189 /* get the figure width for the font. This doesn't have to super
190 * accurate since we only use it to measure the (roughly 1 character)
191 * offset from the position Pango tells us for the "cursor"
194 Glib::RefPtr<Pango::Layout> tmp = Pango::Layout::create (get_pango_context());
198 tmp->get_pixel_size (em_width, ignore_height);
200 /* force redraw of markup with new font-size */
201 AudioClock::set (last_when, true);
205 AudioClock::set_active_state (Gtkmm2ext::ActiveState s)
207 CairoWidget::set_active_state (s);
212 AudioClock::set_colors ()
218 uint32_t editing_color;
219 uint32_t cursor_color;
221 if (active_state()) {
222 bg_color = UIConfiguration::instance().color (string_compose ("%1 active: background", get_name()));
223 text_color = UIConfiguration::instance().color (string_compose ("%1 active: text", get_name()));
224 editing_color = UIConfiguration::instance().color (string_compose ("%1 active: edited text", get_name()));
225 cursor_color = UIConfiguration::instance().color (string_compose ("%1 active: cursor", get_name()));
227 bg_color = UIConfiguration::instance().color (string_compose ("%1: background", get_name()));
228 text_color = UIConfiguration::instance().color (string_compose ("%1: text", get_name()));
229 editing_color = UIConfiguration::instance().color (string_compose ("%1: edited text", get_name()));
230 cursor_color = UIConfiguration::instance().color (string_compose ("%1: cursor", get_name()));
233 /* store for bg and cursor in render() */
235 UINT_TO_RGBA (bg_color, &r, &g, &b, &a);
242 UINT_TO_RGBA (cursor_color, &r, &g, &b, &a);
249 /* rescale for Pango colors ... sigh */
251 r = lrint (r * 65535.0);
252 g = lrint (g * 65535.0);
253 b = lrint (b * 65535.0);
255 UINT_TO_RGBA (text_color, &r, &g, &b, &a);
256 r = lrint ((r/255.0) * 65535.0);
257 g = lrint ((g/255.0) * 65535.0);
258 b = lrint ((b/255.0) * 65535.0);
259 delete foreground_attr;
260 foreground_attr = new Pango::AttrColor (Pango::Attribute::create_attr_foreground (r, g, b));
262 UINT_TO_RGBA (editing_color, &r, &g, &b, &a);
263 r = lrint ((r/255.0) * 65535.0);
264 g = lrint ((g/255.0) * 65535.0);
265 b = lrint ((b/255.0) * 65535.0);
267 editing_attr = new Pango::AttrColor (Pango::Attribute::create_attr_foreground (r, g, b));
269 normal_attributes.change (*foreground_attr);
270 editing_attributes.change (*foreground_attr);
271 editing_attributes.change (*editing_attr);
274 _layout->set_attributes (normal_attributes);
276 _layout->set_attributes (editing_attributes);
283 AudioClock::set_scale (double x, double y)
292 AudioClock::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
294 cairo_t* cr = ctx->cobj();
295 /* main layout: rounded rect, plus the text */
298 cairo_set_source_rgba (cr, bg_r, bg_g, bg_b, bg_a);
300 Gtkmm2ext::rounded_rectangle (cr, 0, 0, get_width(), get_height(), corner_radius);
302 cairo_rectangle (cr, 0, 0, get_width(), get_height());
307 double lw = layout_width * xscale;
308 double lh = layout_height * yscale;
310 cairo_move_to (cr, (get_width() - lw) / 2.0, (get_height() - lh) / 2.0);
312 if (xscale != 1.0 || yscale != 1.0) {
314 cairo_scale (cr, xscale, yscale);
317 pango_cairo_show_layout (cr, _layout->gobj());
319 if (xscale != 1.0 || yscale != 1.0) {
324 if (!insert_map.empty()) {
326 int xcenter = (get_width() - layout_width) /2;
328 if (input_string.length() < insert_map.size()) {
329 Pango::Rectangle cursor;
331 if (input_string.empty()) {
332 /* nothing entered yet, put cursor at the end
335 cursor = _layout->get_cursor_strong_pos (edit_string.length() - 1);
337 cursor = _layout->get_cursor_strong_pos (insert_map[input_string.length()]);
340 cairo_set_source_rgba (cr, cursor_r, cursor_g, cursor_b, cursor_a);
342 min (get_width() - 2.0,
343 (double) xcenter + cursor.get_x()/PANGO_SCALE + em_width),
344 (get_height() - layout_height)/2.0,
345 2.0, cursor.get_height()/PANGO_SCALE);
348 /* we've entered all possible digits, no cursor */
352 if (input_string.empty()) {
353 cairo_set_source_rgba (cr, cursor_r, cursor_g, cursor_b, cursor_a);
356 (get_height() - layout_height)/2.0,
365 AudioClock::set_clock_dimensions (Gtk::Requisition& req)
367 Glib::RefPtr<Pango::Layout> tmp;
368 Glib::RefPtr<Gtk::Style> style = get_style ();
369 Pango::FontDescription font;
371 tmp = Pango::Layout::create (get_pango_context());
373 if (!is_realized()) {
374 font = get_font_for_style (get_name());
376 font = style->get_font();
379 tmp->set_font_description (font);
381 /* this string is the longest thing we will ever display */
383 tmp->set_text (" 88:88:88,888 ");
385 tmp->set_text (" 88:88:88,88 ");
386 tmp->get_pixel_size (req.width, req.height);
388 layout_height = req.height;
389 layout_width = req.width;
393 AudioClock::on_size_request (Gtk::Requisition* req)
395 /* even for non fixed width clocks, the size we *ask* for never changes,
396 even though the size we receive might. so once we've computed it,
401 req->width = first_width;
402 req->height = first_height;
406 set_clock_dimensions (*req);
408 /* now tackle height, for which we need to know the height of the lower
414 AudioClock::show_edit_status (int length)
416 editing_attr->set_start_index (edit_string.length() - length);
417 editing_attr->set_end_index (edit_string.length());
419 editing_attributes.change (*foreground_attr);
420 editing_attributes.change (*editing_attr);
422 _layout->set_attributes (editing_attributes);
426 AudioClock::start_edit (Field f)
429 pre_edit_string = _layout->get_text ();
430 if (!insert_map.empty()) {
431 edit_string = pre_edit_string;
433 edit_string.clear ();
434 _layout->set_text ("");
437 input_string.clear ();
439 edit_is_negative = false;
442 input_string = get_field (f);
443 show_edit_status (merge_input_and_edit_string ());
444 _layout->set_text (edit_string);
449 Keyboard::magic_widget_grab_focus ();
455 AudioClock::get_field (Field f)
459 return edit_string.substr (1, 2);
461 case Timecode_Minutes:
462 return edit_string.substr (4, 2);
464 case Timecode_Seconds:
465 return edit_string.substr (7, 2);
467 case Timecode_frames:
468 return edit_string.substr (10, 2);
471 return edit_string.substr (1, 2);
474 return edit_string.substr (4, 2);
477 return edit_string.substr (7, 2);
479 case MS_Milliseconds:
480 return edit_string.substr (10, 3);
483 return edit_string.substr (1, 3);
486 return edit_string.substr (5, 2);
489 return edit_string.substr (8, 4);
492 return edit_string.substr (0, 8);
494 return edit_string.substr (9, 1);
503 AudioClock::end_edit (bool modify)
511 ok = timecode_validate_edit (edit_string);
515 ok = bbt_validate_edit (edit_string);
519 ok = minsec_validate_edit (edit_string);
525 if (edit_string.length() < 1) {
526 edit_string = pre_edit_string;
532 edit_string = pre_edit_string;
533 input_string.clear ();
534 _layout->set_text (edit_string);
535 show_edit_status (0);
536 /* edit attributes remain in use */
540 samplepos_t pos = 0; /* stupid gcc */
544 pos = samples_from_timecode_string (edit_string);
549 pos = sample_duration_from_bbt_string (bbt_reference_time, edit_string);
551 pos = samples_from_bbt_string (0, edit_string);
556 pos = samples_from_minsec_string (edit_string);
560 pos = samples_from_seconds_string (edit_string);
564 pos = samples_from_audiosamples_string (edit_string);
568 AudioClock::set (pos, true);
569 _layout->set_attributes (normal_attributes);
570 ValueChanged(); /* EMIT_SIGNAL */
576 edit_is_negative = false;
577 _layout->set_attributes (normal_attributes);
578 _layout->set_text (pre_edit_string);
589 AudioClock::drop_focus ()
591 Keyboard::magic_widget_drop_focus ();
594 /* move focus back to the default widget in the top level window */
595 ARDOUR_UI::instance()->reset_focus (this);
600 AudioClock::parse_as_seconds_distance (const std::string& str)
604 if (sscanf (str.c_str(), "%f", &f) == 1) {
605 return f * _session->sample_rate();
612 AudioClock::parse_as_samples_distance (const std::string& str)
616 if (sscanf (str.c_str(), "%" PRId64, &f) == 1) {
624 AudioClock::parse_as_minsec_distance (const std::string& str)
626 samplecnt_t sr = _session->sample_rate();
632 switch (str.length()) {
639 sscanf (str.c_str(), "%" PRId32, &msecs);
640 return msecs * (sr / 1000);
643 sscanf (str.c_str(), "%1" PRId32 "%" PRId32, &secs, &msecs);
644 return (secs * sr) + (msecs * (sr/1000));
647 sscanf (str.c_str(), "%2" PRId32 "%" PRId32, &secs, &msecs);
648 return (secs * sr) + (msecs * (sr/1000));
651 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &msecs);
652 return (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
655 sscanf (str.c_str(), "%2" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &msecs);
656 return (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
659 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &msecs);
660 return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
663 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &msecs);
664 return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + (msecs * (sr/1000));
674 AudioClock::parse_as_timecode_distance (const std::string& str)
676 double fps = _session->timecode_frames_per_second();
677 samplecnt_t sr = _session->sample_rate();
683 switch (str.length()) {
688 sscanf (str.c_str(), "%" PRId32, &samples);
689 return llrint ((samples/(float)fps) * sr);
692 sscanf (str.c_str(), "%1" PRId32 "%" PRId32, &secs, &samples);
693 return (secs * sr) + llrint ((samples/(float)fps) * sr);
696 sscanf (str.c_str(), "%2" PRId32 "%" PRId32, &secs, &samples);
697 return (secs * sr) + llrint ((samples/(float)fps) * sr);
700 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &samples);
701 return (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
704 sscanf (str.c_str(), "%2" PRId32 "%2" PRId32 "%" PRId32, &mins, &secs, &samples);
705 return (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
708 sscanf (str.c_str(), "%1" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &samples);
709 return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
712 sscanf (str.c_str(), "%2" PRId32 "%2" PRId32 "%2" PRId32 "%" PRId32, &hrs, &mins, &secs, &samples);
713 return (hrs * 3600 * sr) + (mins * 60 * sr) + (secs * sr) + llrint ((samples/(float)fps) * sr);
723 AudioClock::parse_as_bbt_distance (const std::string&)
729 AudioClock::parse_as_distance (const std::string& instr)
733 return parse_as_timecode_distance (instr);
736 return parse_as_samples_distance (instr);
739 return parse_as_bbt_distance (instr);
742 return parse_as_minsec_distance (instr);
745 return parse_as_seconds_distance (instr);
752 AudioClock::end_edit_relative (bool add)
758 ok = timecode_validate_edit (edit_string);
762 ok = bbt_validate_edit (edit_string);
766 ok = minsec_validate_edit (edit_string);
777 edit_string = pre_edit_string;
778 input_string.clear ();
779 _layout->set_text (edit_string);
780 show_edit_status (0);
781 /* edit attributes remain in use */
786 samplecnt_t samples = parse_as_distance (input_string);
791 _layout->set_attributes (normal_attributes);
795 AudioClock::set (current_time() + samples, true);
797 samplepos_t c = current_time();
799 if (c > samples || _negative_allowed) {
800 AudioClock::set (c - samples, true);
802 AudioClock::set (0, true);
805 ValueChanged (); /* EMIT SIGNAL */
808 input_string.clear ();
814 AudioClock::session_property_changed (const PropertyChange&)
816 AudioClock::set (last_when, true);
820 AudioClock::session_configuration_changed (std::string p)
822 if (_negative_allowed) {
823 /* session option editor clock */
827 if (p == "sync-source" || p == "external-sync") {
828 AudioClock::set (current_time(), true);
832 if (p != "timecode-offset" && p != "timecode-offset-negative") {
841 current = current_duration ();
843 current = current_time ();
845 AudioClock::set (current, true);
853 AudioClock::set (samplepos_t when, bool force, samplecnt_t offset)
855 if ((!force && !is_visible()) || _session == 0) {
861 when = when - offset;
864 if (when > _limit_pos) {
866 } else if (when < -_limit_pos) {
870 if (when == last_when && !force) {
871 #if 0 // XXX return if no change and no change forced. verify Aug/2014
872 if (_mode != Timecode && _mode != MinSec) {
873 /* may need to force display of TC source
874 * time, so don't return early.
876 /* ^^ Why was that?, delta times?
877 * Timecode FPS, pull-up/down, etc changes
878 * trigger a 'session_property_changed' which
879 * eventually calls set(last_when, true)
881 * re-rendering the clock every 40ms or so just
882 * because we can is not ideal.
897 set_timecode (when, force);
901 set_bbt (when, offset, force);
906 set_minsec (when, force);
910 set_seconds (when, force);
914 set_samples (when, force);
920 _left_btn.set_sensitive (btn_en);
921 _right_btn.set_sensitive (btn_en);
922 _left_btn.set_visual_state (Gtkmm2ext::NoVisualState);
923 _right_btn.set_visual_state (Gtkmm2ext::NoVisualState);
925 _left_btn.set_elements (ArdourButton::Element(ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text));
926 _right_btn.set_elements (ArdourButton::Element(ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text));
927 _left_btn.set_alignment (.5, .5);
928 _right_btn.set_alignment (.5, .5);
929 set_tooltip (_left_btn, _("Change current tempo"));
930 set_tooltip (_right_btn, _("Change current time signature"));
932 _left_btn.set_elements (ArdourButton::Text);
933 _right_btn.set_elements (ArdourButton::Text);
934 _left_btn.set_alignment (0, .5);
935 _right_btn.set_alignment (1, .5);
936 set_tooltip (_left_btn, _(""));
937 set_tooltip (_right_btn, _(""));
946 AudioClock::set_slave_info ()
952 boost::shared_ptr<TransportMaster> tm = TransportMasterManager::instance().current();
954 if (_session->transport_master_is_external()) {
956 switch (tm->type()) {
958 _left_btn.set_text (tm->name(), true);
959 _right_btn.set_text ("", true);
963 _left_btn.set_text (tm->display_name(), true);
964 _right_btn.set_text (tm->delta_string (), true);
966 _left_btn.set_text (_("--pending--"), true);
967 _right_btn.set_text ("", true);
974 boost::shared_ptr<TimecodeTransportMaster> tcmaster;
975 if ((tcmaster = boost::dynamic_pointer_cast<TimecodeTransportMaster>(tm)) != 0) {
976 matching = (tcmaster->apparent_timecode_format() == _session->config.get_timecode_format());
977 _left_btn.set_text (string_compose ("%1<span face=\"monospace\" foreground=\"%3\">%2</span>",
978 tm->display_name()[0],
979 tcmaster->position_string (),
980 matching ? "#66ff66" : "#ff3333"
982 _right_btn.set_text (tm->delta_string (), true);
985 _left_btn.set_text (_("--pending--"), true);
986 _right_btn.set_text ("", true);
991 _left_btn.set_text (string_compose ("%1/%2", _("INT"), tm->display_name()), true);
992 _right_btn.set_text ("", true);
997 AudioClock::set_out_of_bounds (bool negative)
1001 _layout->set_text (" >>> -- <<< ");
1003 _layout->set_text (" >>> ++ <<< ");
1007 _layout->set_text (" <<<<<<<<<< ");
1009 _layout->set_text (" >>>>>>>>>> ");
1015 AudioClock::set_samples (samplepos_t when, bool /*force*/)
1018 bool negative = false;
1021 _layout->set_text (" ----------");
1022 _left_btn.set_text ("", true);
1023 _right_btn.set_text ("", true);
1032 if (when >= _limit_pos) {
1033 set_out_of_bounds (negative);
1034 } else if (negative) {
1035 snprintf (buf, sizeof (buf), "-%10" PRId64, when);
1036 _layout->set_text (buf);
1038 snprintf (buf, sizeof (buf), " %10" PRId64, when);
1039 _layout->set_text (buf);
1043 samplecnt_t rate = _session->sample_rate();
1045 if (fmod (rate, 100.0) == 0.0) {
1046 sprintf (buf, "%.1fkHz", rate/1000.0);
1048 sprintf (buf, "%" PRId64 "Hz", rate);
1051 _left_btn.set_text (string_compose ("%1 %2", _("SR"), buf), true);
1053 float vid_pullup = _session->config.get_video_pullup();
1055 if (vid_pullup == 0.0) {
1056 _right_btn.set_text ("", true);
1058 sprintf (buf, _("%+.4f%%"), vid_pullup);
1059 _right_btn.set_text (string_compose ("%1 %2", _("Pull"), buf), true);
1065 AudioClock::set_seconds (samplepos_t when, bool /*force*/)
1070 _layout->set_text (" ----------");
1071 _left_btn.set_text ("", true);
1072 _right_btn.set_text ("", true);
1076 if (when >= _limit_pos || when <= -_limit_pos) {
1077 set_out_of_bounds (when < 0);
1080 snprintf (buf, sizeof (buf), "%12.1f", when / (float)_session->sample_rate());
1082 snprintf (buf, sizeof (buf), " %11.1f", when / (float)_session->sample_rate());
1084 _layout->set_text (buf);
1091 AudioClock::print_minsec (samplepos_t when, char* buf, size_t bufsize, float sample_rate)
1108 hrs = (int) floor (left / (sample_rate * 60.0f * 60.0f));
1109 left -= (samplecnt_t) floor (hrs * sample_rate * 60.0f * 60.0f);
1110 mins = (int) floor (left / (sample_rate * 60.0f));
1111 left -= (samplecnt_t) floor (mins * sample_rate * 60.0f);
1112 secs = (int) floor (left / (float) sample_rate);
1113 left -= (samplecnt_t) floor ((double)(secs * sample_rate));
1114 millisecs = floor (left * 1000.0 / (float) sample_rate);
1117 snprintf (buf, bufsize, "-%02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs);
1119 snprintf (buf, bufsize, " %02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs);
1125 AudioClock::set_minsec (samplepos_t when, bool /*force*/)
1130 _layout->set_text (" --:--:--.---");
1131 _left_btn.set_text ("", true);
1132 _right_btn.set_text ("", true);
1137 if (when >= _limit_pos || when <= -_limit_pos) {
1138 set_out_of_bounds (when < 0);
1140 print_minsec (when, buf, sizeof (buf), _session->sample_rate());
1141 _layout->set_text (buf);
1148 AudioClock::set_timecode (samplepos_t when, bool /*force*/)
1151 bool negative = false;
1154 _layout->set_text (" --:--:--:--");
1155 _left_btn.set_text ("", true);
1156 _right_btn.set_text ("", true);
1164 if (when >= _limit_pos) {
1165 set_out_of_bounds (negative);
1171 _session->timecode_duration (when, TC);
1173 _session->timecode_time (when, TC);
1176 TC.negative = TC.negative || negative;
1178 _layout->set_text (Timecode::timecode_format_time(TC));
1184 AudioClock::set_bbt (samplepos_t when, samplecnt_t offset, bool /*force*/)
1187 Timecode::BBT_Time BBT;
1188 bool negative = false;
1190 if (_off || when >= _limit_pos || when < -_limit_pos) {
1191 _layout->set_text (" ---|--|----");
1192 _left_btn.set_text ("", true);
1193 _right_btn.set_text ("", true);
1202 /* handle a common case */
1209 TempoMap& tmap (_session->tempo_map());
1212 offset = bbt_reference_time;
1215 const double divisions = tmap.meter_section_at_sample (offset).divisions_per_bar();
1216 Timecode::BBT_Time sub_bbt;
1219 BBT = tmap.bbt_at_beat (tmap.beat_at_sample (offset));
1220 sub_bbt = tmap.bbt_at_sample (offset - when);
1222 BBT = tmap.bbt_at_beat (tmap.beat_at_sample (when + offset));
1223 sub_bbt = tmap.bbt_at_sample (offset);
1226 BBT.bars -= sub_bbt.bars;
1228 if (BBT.ticks < sub_bbt.ticks) {
1229 if (BBT.beats == 1) {
1231 BBT.beats = divisions;
1235 BBT.ticks = Timecode::BBT_Time::ticks_per_beat - (sub_bbt.ticks - BBT.ticks);
1237 BBT.ticks -= sub_bbt.ticks;
1240 if (BBT.beats < sub_bbt.beats) {
1242 BBT.beats = divisions - (sub_bbt.beats - BBT.beats);
1244 BBT.beats -= sub_bbt.beats;
1248 BBT = _session->tempo_map().bbt_at_sample (when);
1252 snprintf (buf, sizeof (buf), "-%03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
1253 BBT.bars, BBT.beats, BBT.ticks);
1255 snprintf (buf, sizeof (buf), " %03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
1256 BBT.bars, BBT.beats, BBT.ticks);
1259 _layout->set_text (buf);
1264 if (bbt_reference_time < 0) {
1267 pos = bbt_reference_time;
1270 TempoMetric m (_session->tempo_map().metric_at (pos));
1272 if (m.tempo().note_type() == 4) {
1273 snprintf (buf, sizeof(buf), "\u2669 = %.3f", _session->tempo_map().tempo_at_sample (pos).note_types_per_minute());
1274 _left_btn.set_text (string_compose ("%1", buf), true);
1275 } else if (m.tempo().note_type() == 8) {
1276 snprintf (buf, sizeof(buf), "\u266a = %.3f", _session->tempo_map().tempo_at_sample (pos).note_types_per_minute());
1277 _left_btn.set_text (string_compose ("%1", buf), true);
1279 snprintf (buf, sizeof(buf), "%.1f = %.3f", m.tempo().note_type(), _session->tempo_map().tempo_at_sample (pos).note_types_per_minute());
1280 _left_btn.set_text (string_compose ("%1: %2", S_("Tempo|T"), buf), true);
1283 snprintf (buf, sizeof(buf), "%g/%g", m.meter().divisions_per_bar(), m.meter().note_divisor());
1284 _right_btn.set_text (string_compose ("%1: %2", S_("TimeSignature|TS"), buf), true);
1289 AudioClock::set_session (Session *s)
1291 SessionHandlePtr::set_session (s);
1295 int64_t limit_sec = UIConfiguration::instance().get_clock_display_limit ();
1296 if (limit_sec > 0) {
1297 _limit_pos = (samplecnt_t) floor ((double)(limit_sec * _session->sample_rate()));
1300 Config->ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
1301 _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
1302 _session->tempo_map().PropertyChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_property_changed, this, _1), gui_context());
1303 _session->tempo_map().MetricPositionChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_property_changed, this, _1), gui_context());
1305 XMLNode* node = _session->extra_xml (X_("ClockModes"));
1308 for (XMLNodeList::const_iterator i = node->children().begin(); i != node->children().end(); ++i) {
1310 if ((*i)->get_property (X_("name"), name) && name == _name) {
1312 AudioClock::Mode amode;
1313 if ((*i)->get_property (X_("mode"), amode)) {
1314 set_mode (amode, true);
1317 if ((*i)->get_property (X_("on"), on)) {
1325 AudioClock::set (last_when, true);
1330 AudioClock::on_key_press_event (GdkEventKey* ev)
1338 int highlight_length;
1341 switch (ev->keyval) {
1384 case GDK_KP_Subtract:
1385 if (_negative_allowed && input_string.empty()) {
1386 edit_is_negative = true;
1387 edit_string.replace(0,1,"-");
1388 _layout->set_text (edit_string);
1391 end_edit_relative (false);
1397 end_edit_relative (true);
1410 ChangeAborted(); /* EMIT SIGNAL */
1415 if (!input_string.empty()) {
1416 /* delete the last key entered
1418 input_string = input_string.substr (0, input_string.length() - 1);
1420 goto use_input_string;
1423 /* do not allow other keys to passthru to the rest of the GUI
1429 if (!insert_map.empty() && (input_string.length() >= insert_map.size())) {
1430 /* too many digits: eat the key event, but do nothing with it */
1434 input_string.push_back (new_char);
1440 /* get this one in the right order, and to the right width */
1441 if (ev->keyval == GDK_Delete || ev->keyval == GDK_BackSpace) {
1442 edit_string = edit_string.substr (0, edit_string.length() - 1);
1444 edit_string.push_back (new_char);
1446 if (!edit_string.empty()) {
1448 sscanf (edit_string.c_str(), "%" PRId64, &pos);
1449 snprintf (buf, sizeof (buf), " %10" PRId64, pos);
1452 /* highlight the whole thing */
1453 highlight_length = edit_string.length();
1457 highlight_length = merge_input_and_edit_string ();
1460 if (edit_is_negative) {
1461 edit_string.replace(0,1,"-");
1463 if (!pre_edit_string.empty() && (pre_edit_string.at(0) == '-')) {
1464 edit_string.replace(0,1,"_");
1466 edit_string.replace(0,1," ");
1470 show_edit_status (highlight_length);
1471 _layout->set_text (edit_string);
1478 AudioClock::merge_input_and_edit_string ()
1480 /* merge with pre-edit-string into edit string */
1482 edit_string = pre_edit_string;
1484 if (input_string.empty()) {
1488 string::size_type target;
1489 for (string::size_type i = 0; i < input_string.length(); ++i) {
1490 target = insert_map[input_string.length() - 1 - i];
1491 edit_string[target] = input_string[i];
1493 /* highlight from end to wherever the last character was added */
1494 return edit_string.length() - insert_map[input_string.length()-1];
1499 AudioClock::on_key_release_event (GdkEventKey *ev)
1505 /* return true for keys that we used on press
1506 so that they cannot possibly do double-duty
1508 switch (ev->keyval) {
1531 case GDK_KP_Decimal:
1539 case GDK_KP_Subtract:
1547 AudioClock::index_to_field (int index) const
1552 return Timecode_Hours;
1553 } else if (index < 7) {
1554 return Timecode_Minutes;
1555 } else if (index < 10) {
1556 return Timecode_Seconds;
1558 return Timecode_frames;
1564 } else if (index < 7) {
1572 return Timecode_Hours;
1573 } else if (index < 6) {
1575 } else if (index < 9) {
1578 return MS_Milliseconds;
1585 return SS_Deciseconds;
1597 AudioClock::on_button_press_event (GdkEventButton *ev)
1599 if (!_session || _session->actively_recording()) {
1600 /* swallow event, do nothing */
1604 switch (ev->button) {
1606 if (editable && !_off) {
1612 /* the text has been centered vertically, so adjust
1615 int xcenter = (get_width() - layout_width) /2;
1617 y = ev->y - ((get_height() - layout_height)/2);
1618 x = ev->x - xcenter;
1620 if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
1621 /* pretend it is a character on the far right */
1624 drag_field = index_to_field (index);
1626 /* make absolutely sure that the pointer is grabbed */
1627 gdk_pointer_grab(ev->window,false ,
1628 GdkEventMask( Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK |Gdk::BUTTON_RELEASE_MASK),
1629 NULL,NULL,ev->time);
1631 drag_start_y = ev->y;
1645 AudioClock::on_button_release_event (GdkEventButton *ev)
1647 if (!_session || _session->actively_recording()) {
1648 /* swallow event, do nothing */
1652 if (editable && !_off) {
1654 gdk_pointer_ungrab (GDK_CURRENT_TIME);
1656 if (ev->y > drag_start_y+1 || ev->y < drag_start_y-1 || Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)){
1657 // we actually dragged so return without
1658 // setting editing focus, or we shift clicked
1661 if (ev->button == 1) {
1663 if (_edit_by_click_field) {
1665 int xcenter = (get_width() - layout_width) /2;
1668 int y = ev->y - ((get_height() - layout_height)/2);
1669 int x = ev->x - xcenter;
1672 if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
1676 f = index_to_field (index);
1679 case Timecode_frames:
1680 case MS_Milliseconds:
1682 case SS_Deciseconds:
1697 if (Keyboard::is_context_menu_event (ev)) {
1698 if (ops_menu == 0) {
1701 ops_menu->popup (1, ev->time);
1709 AudioClock::on_focus_out_event (GdkEventFocus* ev)
1711 bool ret = CairoWidget::on_focus_out_event (ev);
1714 end_edit (_accept_on_focus_out);
1721 AudioClock::on_scroll_event (GdkEventScroll *ev)
1726 if (editing || _session == 0 || !editable || _off || _session->actively_recording()) {
1733 /* the text has been centered vertically, so adjust
1737 int xcenter = (get_width() - layout_width) /2;
1738 y = ev->y - ((get_height() - layout_height)/2);
1739 x = ev->x - xcenter;
1741 if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
1742 /* not in the main layout */
1746 Field f = index_to_field (index);
1747 samplepos_t samples = 0;
1749 switch (ev->direction) {
1752 samples = get_sample_step (f, current_time(), 1);
1754 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1757 AudioClock::set (current_time() + samples, true);
1758 ValueChanged (); /* EMIT_SIGNAL */
1762 case GDK_SCROLL_DOWN:
1763 samples = get_sample_step (f, current_time(), -1);
1765 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1769 if (!_negative_allowed && (double)current_time() - (double)samples < 0.0) {
1770 AudioClock::set (0, true);
1772 AudioClock::set (current_time() - samples, true);
1775 ValueChanged (); /* EMIT_SIGNAL */
1788 AudioClock::on_motion_notify_event (GdkEventMotion *ev)
1790 if (editing || _session == 0 || !dragging || _session->actively_recording()) {
1794 float pixel_sample_scale_factor = 0.2f;
1796 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1797 pixel_sample_scale_factor = 0.1f;
1801 if (Keyboard::modifier_state_contains (ev->state,
1802 Keyboard::PrimaryModifier|Keyboard::SecondaryModifier)) {
1803 pixel_sample_scale_factor = 0.025f;
1806 double y_delta = ev->y - drag_y;
1808 drag_accum += y_delta*pixel_sample_scale_factor;
1812 if (floor (drag_accum) != 0) {
1814 samplepos_t samples;
1817 dir = (drag_accum < 0 ? 1:-1);
1818 pos = current_time();
1819 samples = get_sample_step (drag_field, pos, dir);
1821 if (samples != 0 && samples * drag_accum < current_time()) {
1822 AudioClock::set ((samplepos_t) floor (pos - drag_accum * samples), false); // minus because up is negative in GTK
1824 AudioClock::set (0 , false);
1828 ValueChanged(); /* EMIT_SIGNAL */
1835 AudioClock::get_sample_step (Field field, samplepos_t pos, int dir)
1838 Timecode::BBT_Time BBT;
1840 case Timecode_Hours:
1841 f = (samplecnt_t) floor (3600.0 * _session->sample_rate());
1843 case Timecode_Minutes:
1844 f = (samplecnt_t) floor (60.0 * _session->sample_rate());
1846 case Timecode_Seconds:
1847 f = _session->sample_rate();
1849 case Timecode_frames:
1850 f = (samplecnt_t) floor (_session->sample_rate() / _session->timecode_frames_per_second());
1858 f = (samplecnt_t) _session->sample_rate();
1860 case SS_Deciseconds:
1861 f = (samplecnt_t) _session->sample_rate() / 10.f;
1865 f = (samplecnt_t) floor (3600.0 * _session->sample_rate());
1868 f = (samplecnt_t) floor (60.0 * _session->sample_rate());
1871 f = (samplecnt_t) _session->sample_rate();
1873 case MS_Milliseconds:
1874 f = (samplecnt_t) floor (_session->sample_rate() / 1000.0);
1881 f = _session->tempo_map().bbt_duration_at (pos,BBT,dir);
1887 f = _session->tempo_map().bbt_duration_at(pos,BBT,dir);
1893 f = _session->tempo_map().bbt_duration_at(pos,BBT,dir);
1896 error << string_compose (_("programming error: %1"), "attempt to get samples from non-text field!") << endmsg;
1905 AudioClock::current_time (samplepos_t) const
1911 AudioClock::current_duration (samplepos_t pos) const
1913 samplepos_t ret = 0;
1917 ret = sample_duration_from_bbt_string (pos, _layout->get_text());
1932 AudioClock::bbt_validate_edit (string & str)
1936 if (sscanf (str.c_str(), BBT_SCANF_FORMAT, &any.bbt.bars, &any.bbt.beats, &any.bbt.ticks) != 3) {
1940 if (any.bbt.ticks > Timecode::BBT_Time::ticks_per_beat) {
1944 if (!is_duration && any.bbt.bars == 0) {
1948 if (!is_duration && any.bbt.beats == 0) {
1949 /* user could not have mean zero beats because for a
1950 * non-duration clock that's impossible. Assume that they
1951 * mis-entered things and meant Bar|1|ticks
1955 snprintf (buf, sizeof (buf), "%" PRIu32 "|%" PRIu32 "|%" PRIu32, any.bbt.bars, 1, any.bbt.ticks);
1963 AudioClock::timecode_validate_edit (const string&)
1969 if (sscanf (_layout->get_text().c_str(), "%[- _]%" PRId32 ":%" PRId32 ":%" PRId32 "%[:;]%" PRId32,
1970 ignored, &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 6) {
1975 TC.hours = hours * -1;
1979 TC.negative = false;
1982 if (TC.negative && !_negative_allowed) {
1986 if (TC.hours > 23U || TC.minutes > 59U || TC.seconds > 59U) {
1990 if (TC.frames > (uint32_t) rint (_session->timecode_frames_per_second()) - 1) {
1994 if (_session->timecode_drop_frames()) {
1995 if (TC.minutes % 10 && TC.seconds == 0U && TC.frames < 2U) {
2004 AudioClock::minsec_validate_edit (const string& str)
2006 int hrs, mins, secs, millisecs;
2008 if (sscanf (str.c_str(), "%d:%d:%d.%d", &hrs, &mins, &secs, &millisecs) != 4) {
2012 if (hrs > 23 || mins > 59 || secs > 59 || millisecs > 999) {
2020 AudioClock::samples_from_timecode_string (const string& str) const
2022 if (_session == 0) {
2031 if (sscanf (str.c_str(), "%[- _]%d:%d:%d%[:;]%d", ignored, &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 6) {
2032 error << string_compose (_("programming error: %1 %2"), "badly formatted timecode clock string", str) << endmsg;
2035 TC.hours = abs(hours);
2036 TC.rate = _session->timecode_frames_per_second();
2037 TC.drop= _session->timecode_drop_frames();
2039 _session->timecode_to_sample (TC, sample, false /* use_offset */, false /* use_subframes */ );
2041 // timecode_tester ();
2042 if (edit_is_negative) {
2050 AudioClock::samples_from_minsec_string (const string& str) const
2052 if (_session == 0) {
2056 int hrs, mins, secs, millisecs;
2057 samplecnt_t sr = _session->sample_rate();
2059 if (sscanf (str.c_str(), "%d:%d:%d.%d", &hrs, &mins, &secs, &millisecs) != 4) {
2060 error << string_compose (_("programming error: %1 %2"), "badly formatted minsec clock string", str) << endmsg;
2064 return (samplepos_t) floor ((hrs * 60.0f * 60.0f * sr) + (mins * 60.0f * sr) + (secs * sr) + (millisecs * sr / 1000.0));
2068 AudioClock::samples_from_bbt_string (samplepos_t pos, const string& str) const
2070 if (_session == 0) {
2071 error << "AudioClock::current_time() called with BBT mode but without session!" << endmsg;
2076 any.type = AnyTime::BBT;
2078 if (sscanf (str.c_str(), BBT_SCANF_FORMAT, &any.bbt.bars, &any.bbt.beats, &any.bbt.ticks) != 3) {
2085 return _session->any_duration_to_samples (pos, any);
2087 return _session->convert_to_samples (any);
2093 AudioClock::sample_duration_from_bbt_string (samplepos_t pos, const string& str) const
2095 if (_session == 0) {
2096 error << "AudioClock::sample_duration_from_bbt_string() called with BBT mode but without session!" << endmsg;
2100 Timecode::BBT_Time bbt;
2102 if (sscanf (str.c_str(), BBT_SCANF_FORMAT, &bbt.bars, &bbt.beats, &bbt.ticks) != 3) {
2106 return _session->tempo_map().bbt_duration_at(pos,bbt,1);
2110 AudioClock::samples_from_seconds_string (const string& str) const
2113 sscanf (str.c_str(), "%f", &f);
2114 return f * _session->sample_rate();
2118 AudioClock::samples_from_audiosamples_string (const string& str) const
2121 sscanf (str.c_str(), "%" PRId64, &f);
2126 AudioClock::copy_text_to_clipboard () const
2130 val = pre_edit_string;
2132 val = _layout->get_text ();
2134 const size_t trim = val.find_first_not_of(" ");
2135 if (trim == string::npos) {
2136 assert(0); // empty clock, can't be right.
2139 Glib::RefPtr<Clipboard> cl = Gtk::Clipboard::get();
2140 cl->set_text (val.substr(trim));
2144 AudioClock::build_ops_menu ()
2146 using namespace Menu_Helpers;
2147 ops_menu = new Menu;
2148 MenuList& ops_items = ops_menu->items();
2149 ops_menu->set_name ("ArdourContextMenu");
2151 ops_items.push_back (MenuElem (_("Timecode"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Timecode, false)));
2152 ops_items.push_back (MenuElem (_("Bars:Beats"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), BBT, false)));
2153 ops_items.push_back (MenuElem (_("Minutes:Seconds"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), MinSec, false)));
2154 ops_items.push_back (MenuElem (_("Seconds"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Seconds, false)));
2155 ops_items.push_back (MenuElem (_("Samples"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Samples, false)));
2157 if (editable && !_off && !is_duration && !_follows_playhead) {
2158 ops_items.push_back (SeparatorElem());
2159 ops_items.push_back (MenuElem (_("Set from Playhead"), sigc::mem_fun(*this, &AudioClock::set_from_playhead)));
2160 ops_items.push_back (MenuElem (_("Locate to This Time"), sigc::mem_fun(*this, &AudioClock::locate)));
2162 ops_items.push_back (SeparatorElem());
2163 ops_items.push_back (MenuElem (_("Copy to clipboard"), sigc::mem_fun(*this, &AudioClock::copy_text_to_clipboard)));
2167 AudioClock::set_from_playhead ()
2173 AudioClock::set (_session->transport_sample());
2178 AudioClock::locate ()
2180 if (!_session || is_duration) {
2184 _session->request_locate (current_time(), _session->transport_rolling ());
2188 AudioClock::set_mode (Mode m, bool noemit)
2198 _layout->set_text ("");
2200 Gtk::Requisition req;
2201 set_clock_dimensions (req);
2205 insert_map.push_back (11);
2206 insert_map.push_back (10);
2207 insert_map.push_back (8);
2208 insert_map.push_back (7);
2209 insert_map.push_back (5);
2210 insert_map.push_back (4);
2211 insert_map.push_back (2);
2212 insert_map.push_back (1);
2216 insert_map.push_back (11);
2217 insert_map.push_back (10);
2218 insert_map.push_back (9);
2219 insert_map.push_back (8);
2220 insert_map.push_back (6);
2221 insert_map.push_back (5);
2222 insert_map.push_back (3);
2223 insert_map.push_back (2);
2224 insert_map.push_back (1);
2228 insert_map.push_back (12);
2229 insert_map.push_back (11);
2230 insert_map.push_back (10);
2231 insert_map.push_back (8);
2232 insert_map.push_back (7);
2233 insert_map.push_back (5);
2234 insert_map.push_back (4);
2235 insert_map.push_back (2);
2236 insert_map.push_back (1);
2240 insert_map.push_back (11);
2241 insert_map.push_back (9);
2242 insert_map.push_back (8);
2243 insert_map.push_back (7);
2244 insert_map.push_back (6);
2245 insert_map.push_back (5);
2246 insert_map.push_back (4);
2247 insert_map.push_back (3);
2248 insert_map.push_back (2);
2249 insert_map.push_back (1);
2256 AudioClock::set (last_when, true);
2258 if (!is_transient && !noemit) {
2259 ModeChanged (); /* EMIT SIGNAL (the static one)*/
2262 mode_changed (); /* EMIT SIGNAL (the member one) */
2266 AudioClock::set_bbt_reference (samplepos_t pos)
2268 bbt_reference_time = pos;
2272 AudioClock::on_style_changed (const Glib::RefPtr<Gtk::Style>& old_style)
2274 CairoWidget::on_style_changed (old_style);
2276 Gtk::Requisition req;
2277 set_clock_dimensions (req);
2279 /* XXXX fix me ... we shouldn't be using GTK styles anyway */
2285 AudioClock::set_editable (bool yn)
2291 AudioClock::set_is_duration (bool yn)
2293 if (yn == is_duration) {
2298 AudioClock::set (last_when, true);
2302 AudioClock::set_off (bool yn)
2310 /* force a redraw. last_when will be preserved, but the clock text will
2314 AudioClock::set (last_when, true);
2318 AudioClock::focus ()
2320 start_edit (Field (0));
2324 AudioClock::set_corner_radius (double r)
2333 AudioClock::dpi_reset ()
2335 /* force recomputation of size even if we are fixed width
2343 AudioClock::set_negative_allowed (bool yn)
2345 _negative_allowed = yn;