Move control surface options into RC prefs editor. Remove Options menu.
[ardour.git] / gtk2_ardour / audio_clock.cc
index 5ce5159e7299bdf914c1344c64b24c6958cb260b..28110c685fa70cab14203c985b6d6fe4ef1deb24 100644 (file)
 #include <cstdio> // for sprintf
 #include <cmath>
 
-#include <pbd/convert.h>
-#include <pbd/enumwriter.h>
+#include "pbd/convert.h"
+#include "pbd/enumwriter.h"
 
 #include <gtkmm2ext/utils.h>
 
-#include <ardour/ardour.h>
-#include <ardour/session.h>
-#include <ardour/tempo.h>
-#include <ardour/profile.h>
+#include "ardour/ardour.h"
+#include "ardour/session.h"
+#include "ardour/tempo.h"
+#include "ardour/profile.h"
 #include <sigc++/bind.h>
 
 #include "ardour_ui.h"
@@ -104,6 +104,9 @@ AudioClock::AudioClock (std::string clock_name, bool transient, std::string widg
                Gtkmm2ext::set_size_request_to_display_given_text(*smpte_upper_info_label, "23.98",0,0);
                Gtkmm2ext::set_size_request_to_display_given_text(*smpte_lower_info_label, "NDF",0,0);
 
+               Gtkmm2ext::set_size_request_to_display_given_text(*bbt_upper_info_label, "88|88",0,0);
+               Gtkmm2ext::set_size_request_to_display_given_text(*bbt_lower_info_label, "888.88",0,0);
+
                frames_info_box.pack_start (*frames_upper_info_label, true, true);
                frames_info_box.pack_start (*frames_lower_info_label, true, true);
                smpte_info_box.pack_start (*smpte_upper_info_label, true, true);
@@ -506,7 +509,7 @@ AudioClock::set_frames (nframes_t when, bool force)
                        frames_upper_info_label->set_text (buf);
                }
                
-               float vid_pullup = Config->get_video_pullup();
+               float vid_pullup = session->config.get_video_pullup();
                
                if (vid_pullup == 0.0) {
                        if (frames_lower_info_label->get_text () != _("none")) {
@@ -633,22 +636,33 @@ AudioClock::set_bbt (nframes_t when, bool force)
        char buf[16];
        BBT_Time bbt;
 
-       session->tempo_map().bbt_time (when, bbt);
-
        /* handle a common case */
-
-       if (is_duration && when == 0) {
-               bbt.bars = 0;
-               bbt.beats = 0;
-
+       if (is_duration) {
+               if (when == 0) {
+                       bbt.bars = 0;
+                       bbt.beats = 0;
+                       bbt.ticks = 0;  
+               } else {
+                       session->tempo_map().bbt_time (when, bbt);
+                       bbt.bars--;
+                       bbt.beats--;
+               }
+       } else {
+               session->tempo_map().bbt_time (when, bbt);
        }
 
        sprintf (buf, "%03" PRIu32, bbt.bars);
-       bars_label.set_text (buf);
+       if (force || bars_label.get_text () != buf) {
+               bars_label.set_text (buf);
+       }
        sprintf (buf, "%02" PRIu32, bbt.beats);
-       beats_label.set_text (buf);
+       if (force || beats_label.get_text () != buf) {
+               beats_label.set_text (buf);
+       }
        sprintf (buf, "%04" PRIu32, bbt.ticks);
-       ticks_label.set_text (buf);
+       if (force || ticks_label.get_text () != buf) {
+               ticks_label.set_text (buf);
+       }
        
        if (bbt_upper_info_label) {
                nframes64_t pos;
@@ -828,13 +842,15 @@ AudioClock::field_key_release_event (GdkEventKey *ev, Field field)
                break;
 
        case GDK_Tab:
+       case GDK_Return:
+       case GDK_KP_Enter:
                move_on = true;
                break;
 
        case GDK_Escape:
-       case GDK_Return:
-       case GDK_KP_Enter:
+               key_entry_state = 0;
                clock_base.grab_focus ();
+               ChangeAborted();  /*  EMIT SIGNAL  */
                return true;
 
        default:
@@ -960,6 +976,13 @@ AudioClock::field_key_release_event (GdkEventKey *ev, Field field)
 
        }
 
+       //if user hit Enter, lose focus
+       switch (ev->keyval) {
+       case GDK_Return:
+       case GDK_KP_Enter:
+               clock_base.grab_focus ();
+       }
+
        return true;
 }
 
@@ -1879,6 +1902,11 @@ AudioClock::bbt_frame_from_display (nframes_t pos) const
        any.bbt.beats = atoi (beats_label.get_text());
        any.bbt.ticks = atoi (ticks_label.get_text());
 
+       if (is_duration) {
+               any.bbt.bars++;
+               any.bbt.beats++;
+       }
+
        nframes_t ret = session->convert_to_frames_at (pos, any);
 
        return ret;
@@ -1976,6 +2004,7 @@ AudioClock::set_mode (Mode m)
 
        if (!is_transient) {
                ModeChanged (); /* EMIT SIGNAL */
+               mode_changed (); /* EMIT SIGNAL */
        }
 }