Move util functions into UIConfiguration as they depend on it anyway
[ardour.git] / gtk2_ardour / audio_clock.cc
index a90946f3ba0ab09e1348b01d52554e59cbb9f232..b64e54e95e6413d1f7120adac40de3c98ac31f59 100644 (file)
@@ -55,7 +55,7 @@ using Gtkmm2ext::Keyboard;
 
 sigc::signal<void> AudioClock::ModeChanged;
 vector<AudioClock*> AudioClock::clocks;
-const double AudioClock::info_font_scale_factor = 0.60;
+const double AudioClock::info_font_scale_factor = 0.68;
 const double AudioClock::separator_height = 0.0;
 const double AudioClock::x_leading_padding = 6.0;
 
@@ -65,13 +65,15 @@ const double AudioClock::x_leading_padding = 6.0;
 #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)
+                       bool allow_edit, bool follows_playhead, bool duration, bool with_info,
+                       bool accept_on_focus_out)
        : ops_menu (0)
        , _name (clock_name)
        , is_transient (transient)
        , is_duration (duration)
        , editable (allow_edit)
        , _follows_playhead (follows_playhead)
+       , _accept_on_focus_out (accept_on_focus_out)
        , _off (false)
        , em_width (0)
        , _edit_by_click_field (false)
@@ -334,7 +336,7 @@ AudioClock::render (cairo_t* cr, cairo_rectangle_t*)
 
                if (mode_based_info_ratio != 1.0) {
 
-                       double left_rect_width = round (((get_width() - separator_height) * mode_based_info_ratio) + 0.5);
+                       double left_rect_width = get_left_rect_width();
 
                        if (_need_bg) {
                                if (corner_radius) {
@@ -470,7 +472,10 @@ AudioClock::set_clock_dimensions (Gtk::Requisition& req)
        tmp->set_font_description (font);
 
        /* this string is the longest thing we will ever display */
-       tmp->set_text (" 88:88:88,888");
+       if (_mode == MinSec)
+               tmp->set_text (" 88:88:88,888 ");
+       else
+               tmp->set_text (" 88:88:88,88 ");
        tmp->get_pixel_size (req.width, req.height);
 
        layout_height = req.height;
@@ -1685,7 +1690,7 @@ AudioClock::on_focus_out_event (GdkEventFocus* ev)
        bool ret = CairoWidget::on_focus_out_event (ev);
 
        if (editing) {
-               end_edit (false);
+               end_edit (_accept_on_focus_out);
        }
 
        return ret;
@@ -2155,6 +2160,9 @@ AudioClock::set_mode (Mode m)
 
        _layout->set_text ("");
 
+       Gtk::Requisition req;
+       set_clock_dimensions (req);
+
        if (_left_layout) {
 
                _left_layout->set_attributes (info_attributes);