experiment - no space in meterbridge.
[ardour.git] / gtk2_ardour / audio_clock.cc
index 9a9fc6d56e71911e42813b8f5c561c6dc1b51093..a0b48b35573f66ff459d943586339c63fd33b725 100644 (file)
@@ -53,13 +53,14 @@ using Gtkmm2ext::Keyboard;
 
 sigc::signal<void> AudioClock::ModeChanged;
 vector<AudioClock*> AudioClock::clocks;
-const double AudioClock::info_font_scale_factor = 0.5;
+const double AudioClock::info_font_scale_factor = 0.50;
 const double AudioClock::separator_height = 0.0;
 const double AudioClock::x_leading_padding = 6.0;
 
 #define BBT_BAR_CHAR "|"
 #define BBT_SCANF_FORMAT "%" PRIu32 "%*c%" PRIu32 "%*c%" PRIu32
-#define INFO_FONT_SIZE ((int)round(font_size * info_font_scale_factor))
+#define INFO_FONT_SIZE ((int)lrint(font_size * info_font_scale_factor))
+#define TXTSPAN "<span font-family=\"Sans\" foreground=\"white\">"
 
 AudioClock::AudioClock (const string& clock_name, bool transient, const string& widget_name,
                        bool allow_edit, bool follows_playhead, bool duration, bool with_info)
@@ -70,8 +71,6 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string&
        , editable (allow_edit)
        , _follows_playhead (follows_playhead)
        , _off (false)
-       , _fixed_width (true)
-       , layout_x_offset (0)
        , em_width (0)
        , _edit_by_click_field (false)
        , _negative_allowed (false)
@@ -80,12 +79,13 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string&
        , foreground_attr (0)
        , first_height (0)
        , first_width (0)
+       , style_resets_first (true)
        , layout_height (0)
        , layout_width (0)
        , info_height (0)
        , upper_height (0)
        , mode_based_info_ratio (1.0)
-       , corner_radius (9)
+       , corner_radius (4)
        , font_size (10240)
        , editing (false)
        , bbt_reference_time (-1)
@@ -94,7 +94,6 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string&
        , last_sdelta (0)
        , dragging (false)
        , drag_field (Field (0))
-
 {
        set_flags (CAN_FOCUS);
 
@@ -144,7 +143,15 @@ AudioClock::set_widget_name (const string& str)
 void
 AudioClock::on_realize ()
 {
+       Gtk::Requisition req;
+
        CairoWidget::on_realize ();
+       
+       set_clock_dimensions (req);
+
+       first_width = req.width;
+       first_height = req.height;
+
        set_font ();
        set_colors ();
 }
@@ -172,7 +179,7 @@ AudioClock::set_font ()
        /* now a smaller version of the same font */
 
        delete font_attr;
-       font.set_size ((int) lrint (font_size * info_font_scale_factor));
+       font.set_size (INFO_FONT_SIZE);
        font.set_weight (Pango::WEIGHT_NORMAL);
        font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
 
@@ -293,12 +300,7 @@ AudioClock::render (cairo_t* cr)
                cairo_fill (cr);
        }
 
-       if (!_fixed_width) {
-               cairo_move_to (cr, layout_x_offset, 0);
-       } else {
-               int xcenter = layout_x_offset > 0 ? 0 : (get_width() - _mode_width[_mode]) /2;
-               cairo_move_to (cr, layout_x_offset + xcenter, (upper_height - layout_height) / 2.0);
-       }
+       cairo_move_to (cr, (get_width() - layout_width) / 2.0, (upper_height - layout_height) / 2.0);
 
        pango_cairo_show_layout (cr, _layout->gobj());
 
@@ -380,7 +382,7 @@ AudioClock::render (cairo_t* cr)
        if (editing) {
                if (!insert_map.empty()) {
 
-                       int xcenter = layout_x_offset > 0 ? 0 : (get_width() - _mode_width[_mode]) /2;
+                       int xcenter = (get_width() - layout_width) /2;
 
                        if (input_string.length() < insert_map.size()) {
                                Pango::Rectangle cursor;
@@ -395,18 +397,11 @@ AudioClock::render (cairo_t* cr)
                                }
 
                                cairo_set_source_rgba (cr, cursor_r, cursor_g, cursor_b, cursor_a);
-                               if (!_fixed_width) {
-                                       cairo_rectangle (cr,
-                                                        min (get_width() - 2.0,
-                                                             (double) cursor.get_x()/PANGO_SCALE + layout_x_offset + xcenter + em_width), 0,
-                                                        2.0, cursor.get_height()/PANGO_SCALE);
-                               } else {
-                                       cairo_rectangle (cr,
-                                                        min (get_width() - 2.0,
-                                                             (double) layout_x_offset + xcenter + cursor.get_x()/PANGO_SCALE + em_width),
-                                                        (upper_height - layout_height)/2.0,
-                                                        2.0, cursor.get_height()/PANGO_SCALE);
-                               }
+                               cairo_rectangle (cr,
+                                                min (get_width() - 2.0,
+                                                     (double) xcenter + cursor.get_x()/PANGO_SCALE + em_width),
+                                                (upper_height - layout_height)/2.0,
+                                                2.0, cursor.get_height()/PANGO_SCALE);
                                cairo_fill (cr);
                        } else {
                                /* we've entered all possible digits, no cursor */
@@ -415,17 +410,10 @@ AudioClock::render (cairo_t* cr)
                } else {
                        if (input_string.empty()) {
                                cairo_set_source_rgba (cr, cursor_r, cursor_g, cursor_b, cursor_a);
-                               if (!_fixed_width) {
-                                       cairo_rectangle (cr,
-                                                        (get_width()/2.0),
-                                                        0,
-                                                        2.0, upper_height);
-                               } else {
-                                       cairo_rectangle (cr,
-                                                        (get_width()/2.0),
-                                                        (upper_height - layout_height)/2.0,
-                                                        2.0, upper_height);
-                               }
+                               cairo_rectangle (cr,
+                                                (get_width()/2.0),
+                                                (upper_height - layout_height)/2.0,
+                                                2.0, upper_height);
                                cairo_fill (cr);
                        }
                }
@@ -442,33 +430,11 @@ AudioClock::on_size_allocate (Gtk::Allocation& alloc)
        } else {
                upper_height = get_height();
        }
-
-       if (_fixed_width) {
-               /* center display in available space
-                * NB. this only works if the containing widget is not the
-                * layout itself (eg. the session->property dialog)
-                */
-               layout_x_offset = (get_width() - layout_width)/2.0;
-       } else {
-               /* left justify */
-               layout_x_offset = 0;
-       }
 }
 
 void
-AudioClock::on_size_request (Gtk::Requisition* req)
+AudioClock::set_clock_dimensions (Gtk::Requisition& req)
 {
-       /* even for non fixed width clocks, the size we *ask* for never changes,
-          even though the size we receive might. so once we've computed it,
-          just return it.
-       */
-
-       if (first_width) {
-               req->width = first_width;
-               req->height = first_height;
-               return;
-       }
-
        Glib::RefPtr<Pango::Layout> tmp;
        Glib::RefPtr<Gtk::Style> style = get_style ();
        Pango::FontDescription font;
@@ -483,46 +449,29 @@ AudioClock::on_size_request (Gtk::Requisition* req)
 
        tmp->set_font_description (font);
 
-       if (_fixed_width) {
-               int ignored;
-               tmp->set_text ("-88:88:88:88");
-               tmp->get_pixel_size (_mode_width[Timecode], ignored);
-               tmp->set_text (" 88888|88|8888");
-               tmp->get_pixel_size (_mode_width[BBT], ignored);
-               tmp->set_text (" 88:88:88,888");
-               tmp->get_pixel_size (_mode_width[MinSec], ignored);
-               tmp->set_text (" 8888888888");
-               tmp->get_pixel_size (_mode_width[Frames], ignored);
-
-               /* this string is the longest thing we will ever display,
-                  it does not include the BBT bar char that may descend
-                        below the baseline.
-                        note; depending on BPM setting this may actually
-                        not be sufficient for 24h worth of BBT
-               */
+       /* this string is the longest thing we will ever display */
+       tmp->set_text (" 88:88:88,888");
+       tmp->get_pixel_size (req.width, req.height);
 
-               tmp->set_text (" 88888888888::,");
-       } else {
-               switch (_mode) {
-               case Timecode:
-                       tmp->set_text ("-88:88:88:88");
-                       break;
-               case BBT:
-                       tmp->set_text (" 88888|88|8888");
-                       break;
-               case MinSec:
-                       tmp->set_text (" 88:88:88,888");
-                       break;
-               case Frames:
-                       tmp->set_text (" 8888888888");
-                       break;
-               }
-       }
+       layout_height = req.height;
+       layout_width = req.width;
+}
 
-       tmp->get_pixel_size (req->width, req->height);
+void
+AudioClock::on_size_request (Gtk::Requisition* req)
+{
+       /* even for non fixed width clocks, the size we *ask* for never changes,
+          even though the size we receive might. so once we've computed it,
+          just return it.
+       */
 
-       layout_height = req->height;
-       layout_width = req->width;
+       if (first_width) {
+               req->width = first_width;
+               req->height = first_height;
+               return;
+       }
+
+       set_clock_dimensions (*req);
 
        /* now tackle height, for which we need to know the height of the lower
         * layout
@@ -530,9 +479,22 @@ AudioClock::on_size_request (Gtk::Requisition* req)
 
        if (_left_layout) {
 
+               Glib::RefPtr<Pango::Layout> tmp;
+               Glib::RefPtr<Gtk::Style> style = get_style ();
+               Pango::FontDescription font;
                int w;
+               
+               tmp = Pango::Layout::create (get_pango_context());
+               
+               if (!is_realized()) {
+                       font = get_font_for_style (get_name());
+               } else {
+                       font = style->get_font();
+               }
+               
+               tmp->set_font_description (font);
 
-               font.set_size ((int) lrint (font.get_size() * info_font_scale_factor));
+               font.set_size (INFO_FONT_SIZE);
                font.set_weight (Pango::WEIGHT_NORMAL);
                tmp->set_font_description (font);
 
@@ -550,9 +512,6 @@ AudioClock::on_size_request (Gtk::Requisition* req)
                req->height += info_height;
                req->height += separator_height;
        }
-
-       first_height = req->height;
-       first_width = req->width;
 }
 
 void
@@ -570,28 +529,30 @@ AudioClock::show_edit_status (int length)
 void
 AudioClock::start_edit (Field f)
 {
-       pre_edit_string = _layout->get_text ();
-       if (!insert_map.empty()) {
-               edit_string = pre_edit_string;
-       } else {
-               edit_string.clear ();
-               _layout->set_text ("");
-       }
-
-       input_string.clear ();
-       editing = true;
-       edit_is_negative = false;
+       if (!editing) {
+               pre_edit_string = _layout->get_text ();
+               if (!insert_map.empty()) {
+                       edit_string = pre_edit_string;
+               } else {
+                       edit_string.clear ();
+                       _layout->set_text ("");
+               }
+               
+               input_string.clear ();
+               editing = true;
+               edit_is_negative = false;
+               
+               if (f) {
+                       input_string = get_field (f);
+                       show_edit_status (merge_input_and_edit_string ());
+                       _layout->set_text (edit_string);
+               }
+               
+               queue_draw ();
 
-       if (f) {
-               input_string = get_field (f);
-               show_edit_status (merge_input_and_edit_string ());
-               _layout->set_text (edit_string);
+               Keyboard::magic_widget_grab_focus ();
+               grab_focus ();
        }
-
-       queue_draw ();
-
-       Keyboard::magic_widget_grab_focus ();
-       grab_focus ();
 }
 
 string
@@ -929,6 +890,12 @@ AudioClock::end_edit_relative (bool add)
        drop_focus ();
 }
 
+void
+AudioClock::session_property_changed (const PropertyChange&)
+{
+       set (last_when, true);
+}
+
 void
 AudioClock::session_configuration_changed (std::string p)
 {
@@ -1030,18 +997,18 @@ AudioClock::set_slave_info ()
 
                switch (sync_src) {
                case JACK:
-                       _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+                       _left_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"%2</span></span>",
                                                INFO_FONT_SIZE, sync_source_to_string(sync_src, true)));
                        _right_layout->set_text ("");
                        break;
                case MIDIClock:
                        if (slave) {
-                               _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+                               _left_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"%2</span></span>",
                                                        INFO_FONT_SIZE, sync_source_to_string(sync_src, true)));
-                               _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+                               _right_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"%2</span></span>",
                                                        INFO_FONT_SIZE, slave->approximate_current_delta()));
                        } else {
-                               _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+                               _left_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"%2</span></span>",
                                                        INFO_FONT_SIZE, _("--pending--")));
                                _right_layout->set_text ("");
                        }
@@ -1053,21 +1020,21 @@ AudioClock::set_slave_info ()
                                TimecodeSlave* tcslave;
                                if ((tcslave = dynamic_cast<TimecodeSlave*>(_session->slave())) != 0) {
                                        matching = (tcslave->apparent_timecode_format() == _session->config.get_timecode_format());
-                                       _left_layout->set_markup (string_compose ("<span size=\"%1\"><span foreground=\"white\">%2</span><span foreground=\"%3\">%4</span></span>",
+                                       _left_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"%2</span><span foreground=\"%3\">%4</span></span>",
                                                                                  INFO_FONT_SIZE, sync_source_to_string(sync_src, true)[0], (matching?"green":"red"),
                                                                                  dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
-                                       _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+                                       _right_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"%2</span></span>",
                                                                                   INFO_FONT_SIZE, slave->approximate_current_delta()));
                                }
                        } else {
-                               _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+                               _left_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"%2</span></span>",
                                                        INFO_FONT_SIZE, _("--pending--")));
                                _right_layout->set_text ("");
                        }
                        break;
                }
        } else {
-               _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">INT/%2</span>",
+               _left_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"INT/%2</span></span>",
                                        INFO_FONT_SIZE, sync_source_to_string(sync_src, true)));
                _right_layout->set_text ("");
        }
@@ -1080,7 +1047,7 @@ AudioClock::set_frames (framepos_t when, bool /*force*/)
        bool negative = false;
 
        if (_off) {
-               _layout->set_text ("\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012\u2012");
+               _layout->set_text (" ----------");
 
                if (_left_layout) {
                        _left_layout->set_text ("");
@@ -1112,17 +1079,17 @@ AudioClock::set_frames (framepos_t when, bool /*force*/)
                        sprintf (buf, "%" PRId64 "Hz", rate);
                }
 
-               _left_layout->set_markup (string_compose ("<span size=\"%1\"><span foreground=\"white\">%2 </span><span foreground=\"green\">%3</span></span>",
+               _left_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"%2 </span><span foreground=\"green\">%3</span></span>",
                                INFO_FONT_SIZE, _("SR"), buf));
 
                float vid_pullup = _session->config.get_video_pullup();
 
                if (vid_pullup == 0.0) {
-                       _right_layout->set_markup (string_compose ("<span size=\"%1\"><span foreground=\"white\">%2 </span><span foreground=\"green\">off</span></span>",
+                       _right_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"%2 </span><span foreground=\"green\">off</span></span>",
                                        INFO_FONT_SIZE, _("Pull")));
                } else {
                        sprintf (buf, _("%+.4f%%"), vid_pullup);
-                       _right_layout->set_markup (string_compose ("<span size=\"%1\"><span foreground=\"white\">%2 </span><span foreground=\"green\">%3</span></span>",
+                       _right_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"%2 </span><span foreground=\"green\">%3</span></span>",
                                        INFO_FONT_SIZE, _("Pull"), buf));
                }
        }
@@ -1140,7 +1107,7 @@ AudioClock::set_minsec (framepos_t when, bool /*force*/)
        bool negative = false;
 
        if (_off) {
-               _layout->set_text ("\u2012\u2012:\u2012\u2012:\u2012\u2012.\u2012\u2012\u2012");
+               _layout->set_text (" --:--:--.---");
 
                if (_left_layout) {
                        _left_layout->set_text ("");
@@ -1181,7 +1148,7 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
        bool negative = false;
 
        if (_off) {
-               _layout->set_text ("\u2012\u2012:\u2012\u2012:\u2012\u2012:\u2012\u2012");
+               _layout->set_text (" --:--:--:--");
                if (_left_layout) {
                        _left_layout->set_text ("");
                        _right_layout->set_text ("");
@@ -1216,7 +1183,7 @@ AudioClock::set_bbt (framepos_t when, bool /*force*/)
        bool negative = false;
 
        if (_off) {
-               _layout->set_text ("\u2012\u2012\u2012|\u2012\u2012|\u2012\u2012\u2012\u2012");
+               _layout->set_text (" ---|--|----");
                if (_left_layout) {
                        _left_layout->set_text ("");
                        _right_layout->set_text ("");
@@ -1265,13 +1232,13 @@ AudioClock::set_bbt (framepos_t when, bool /*force*/)
 
                TempoMetric m (_session->tempo_map().metric_at (pos));
 
-               sprintf (buf, "%-5.2f", m.tempo().beats_per_minute());
-               _left_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">Tmp <span foreground=\"green\">%2</span></span>",
-                                       INFO_FONT_SIZE, buf));
+               sprintf (buf, "%-5.1f", m.tempo().beats_per_minute());
+               _left_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"%3</span> <span foreground=\"green\">%2</span></span>",
+                                                         INFO_FONT_SIZE, buf, _("Tempo")));
 
                sprintf (buf, "%g/%g", m.meter().divisions_per_bar(), m.meter().note_divisor());
-               _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">Mtr <span foreground=\"green\">%2</span></span>",
-                                       INFO_FONT_SIZE, buf));
+               _right_layout->set_markup (string_compose ("<span size=\"%1\">"TXTSPAN"%3</span> <span foreground=\"green\">%2</span></span>",
+                                                          INFO_FONT_SIZE, buf, _("Meter")));
        }
 }
 
@@ -1283,6 +1250,7 @@ AudioClock::set_session (Session *s)
        if (_session) {
 
                _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
+               _session->tempo_map().PropertyChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_property_changed, this, _1), gui_context());
 
                const XMLProperty* prop;
                XMLNode* node = _session->extra_xml (X_("ClockModes"));
@@ -1366,6 +1334,9 @@ AudioClock::on_key_press_event (GdkEventKey* ev)
        case GDK_KP_Subtract:
                if (_negative_allowed && input_string.empty()) {
                                edit_is_negative = true;
+                               edit_string.replace(0,1,"-");
+                               _layout->set_text (edit_string);
+                               queue_draw ();
                } else {
                        end_edit_relative (false);
                }
@@ -1433,6 +1404,16 @@ AudioClock::on_key_press_event (GdkEventKey* ev)
                highlight_length = merge_input_and_edit_string ();
        }
 
+       if (edit_is_negative) {
+               edit_string.replace(0,1,"-");
+       } else {
+               if (!pre_edit_string.empty() && (pre_edit_string.at(0) == '-')) {
+                       edit_string.replace(0,1,"_");
+               } else {
+                       edit_string.replace(0,1," ");
+               }
+       }
+
        show_edit_status (highlight_length);
        _layout->set_text (edit_string);
        queue_draw ();
@@ -1566,10 +1547,10 @@ AudioClock::on_button_press_event (GdkEventButton *ev)
                        /* the text has been centered vertically, so adjust
                         * x and y.
                         */
-                       int xcenter = !_fixed_width || layout_x_offset > 0 ? 0 : (get_width() - _mode_width[_mode]) /2;
+                       int xcenter = (get_width() - layout_width) /2;
 
                        y = ev->y - ((upper_height - layout_height)/2);
-                       x = ev->x - layout_x_offset - xcenter;
+                       x = ev->x - xcenter;
 
                        if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
                                /* pretend it is a character on the far right */
@@ -1611,11 +1592,11 @@ AudioClock::on_button_release_event (GdkEventButton *ev)
 
                                        if (_edit_by_click_field) {
 
-                                               int xcenter = !_fixed_width || layout_x_offset > 0 ? 0 : (get_width() - _mode_width[_mode]) /2;
+                                               int xcenter = (get_width() - layout_width) /2;
                                                int index = 0;
                                                int trailing;
                                                int y = ev->y - ((upper_height - layout_height)/2);
-                                               int x = ev->x - layout_x_offset - xcenter;
+                                               int x = ev->x - xcenter;
                                                Field f;
 
                                                if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
@@ -1682,9 +1663,9 @@ AudioClock::on_scroll_event (GdkEventScroll *ev)
         * x and y.
         */
 
-       int xcenter = !_fixed_width || layout_x_offset > 0 ? 0 : (get_width() - _mode_width[_mode]) /2;
+       int xcenter = (get_width() - layout_width) /2;
        y = ev->y - ((upper_height - layout_height)/2);
-       x = ev->x - layout_x_offset - xcenter;
+       x = ev->x - xcenter;
 
        if (!_layout->xy_to_index (x * PANGO_SCALE, y * PANGO_SCALE, index, trailing)) {
                /* not in the main layout */
@@ -1714,7 +1695,7 @@ AudioClock::on_scroll_event (GdkEventScroll *ev)
                                frames *= 10;
                        }
 
-                       if ((double)current_time() - (double)frames < 0.0) {
+                       if (!_negative_allowed && (double)current_time() - (double)frames < 0.0) {
                                set (0, true);
                        } else {
                                set (current_time() - frames, true);
@@ -1905,8 +1886,8 @@ AudioClock::timecode_validate_edit (const string&)
        int hours;
        char ignored[2];
 
-       if (sscanf (_layout->get_text().c_str(), "%" PRId32 ":%" PRId32 ":%" PRId32 "%[:;]%" PRId32,
-                   &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 5) {
+       if (sscanf (_layout->get_text().c_str(), "%[- _]%" PRId32 ":%" PRId32 ":%" PRId32 "%[:;]%" PRId32,
+                   ignored, &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 6) {
                return false;
        }
 
@@ -1967,7 +1948,7 @@ AudioClock::frames_from_timecode_string (const string& str) const
        char ignored[2];
        int hours;
 
-       if (sscanf (str.c_str(), "%d:%d:%d%[:;]%d", &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 5) {
+       if (sscanf (str.c_str(), "%[- _]%d:%d:%d%[:;]%d", ignored, &hours, &TC.minutes, &TC.seconds, ignored, &TC.frames) != 6) {
                error << string_compose (_("programming error: %1 %2"), "badly formatted timecode clock string", str) << endmsg;
                return 0;
        }
@@ -2124,7 +2105,7 @@ AudioClock::set_mode (Mode m)
 
        switch (_mode) {
        case Timecode:
-               mode_based_info_ratio = 0.5;
+               mode_based_info_ratio = 0.6;
                insert_map.push_back (11);
                insert_map.push_back (10);
                insert_map.push_back (8);
@@ -2149,7 +2130,7 @@ AudioClock::set_mode (Mode m)
                break;
 
        case MinSec:
-               mode_based_info_ratio = 0.5;
+               mode_based_info_ratio = 0.6;
                insert_map.push_back (12);
                insert_map.push_back (11);
                insert_map.push_back (10);
@@ -2162,7 +2143,7 @@ AudioClock::set_mode (Mode m)
                break;
 
        case Frames:
-               mode_based_info_ratio = 0.5;
+               mode_based_info_ratio = 0.45;
                break;
        }
 
@@ -2172,13 +2153,6 @@ AudioClock::set_mode (Mode m)
                 ModeChanged (); /* EMIT SIGNAL (the static one)*/
         }
 
-       if (!_fixed_width) {
-               /* display is different, allow us to resize */
-               first_width = 0;
-               first_height = 0;
-               queue_resize ();
-       }
-
         mode_changed (); /* EMIT SIGNAL (the member one) */
 }
 
@@ -2192,8 +2166,10 @@ void
 AudioClock::on_style_changed (const Glib::RefPtr<Gtk::Style>& old_style)
 {
        CairoWidget::on_style_changed (old_style);
-       first_width = 0;
-       first_height = 0;
+
+       Gtk::Requisition req;
+       set_clock_dimensions (req);
+
        set_font ();
        set_colors ();
 }
@@ -2246,12 +2222,6 @@ AudioClock::set_corner_radius (double r)
        queue_resize ();
 }
 
-void
-AudioClock::set_fixed_width (bool yn)
-{
-       _fixed_width = yn;
-}
-
 void
 AudioClock::dpi_reset ()
 {