make inclusion/exclusion of hidden children optional in Item::add_child_bounding_boxes
[ardour.git] / gtk2_ardour / audio_clock.cc
index 4afe4a418d7366d42bf693d7eaa58aea3782ccec..ed81b6db2102d3cf40edd773c88a58a53cf09d89 100644 (file)
 #include "ardour/tempo.h"
 #include "ardour/types.h"
 
+#include "ardour_ui.h"
 #include "audio_clock.h"
-#include "utils.h"
-#include "keyboard.h"
 #include "gui_thread.h"
+#include "keyboard.h"
 #include "ui_config.h"
-#include "i18n.h"
+#include "utils.h"
+
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 using namespace ARDOUR_UI_UTILS;
@@ -709,15 +711,8 @@ AudioClock::drop_focus ()
        Keyboard::magic_widget_drop_focus ();
 
        if (has_focus()) {
-
                /* move focus back to the default widget in the top level window */
-
-               Widget* top = get_toplevel();
-
-               if (top->is_toplevel ()) {
-                       Window* win = dynamic_cast<Window*> (top);
-                       win->grab_focus ();
-               }
+               ARDOUR_UI::instance()->reset_focus (this);
        }
 }
 
@@ -923,6 +918,12 @@ AudioClock::session_property_changed (const PropertyChange&)
        set (last_when, true);
 }
 
+void
+AudioClock::metric_position_changed ()
+{
+       set (last_when, true);
+}
+
 void
 AudioClock::session_configuration_changed (std::string p)
 {
@@ -1252,12 +1253,12 @@ AudioClock::set_bbt (framepos_t when, bool /*force*/)
                        BBT.beats = 0;
                        BBT.ticks = 0;
                } else {
-                       _session->tempo_map().bbt_time (when, BBT);
+                       BBT = _session->tempo_map().bbt_at_frame (when);
                        BBT.bars--;
                        BBT.beats--;
                }
        } else {
-               _session->tempo_map().bbt_time (when, BBT);
+               BBT = _session->tempo_map().bbt_at_frame (when);
        }
 
        if (negative) {
@@ -1281,7 +1282,7 @@ AudioClock::set_bbt (framepos_t when, bool /*force*/)
 
                TempoMetric m (_session->tempo_map().metric_at (pos));
 
-               sprintf (buf, "%-5.1f", _session->tempo_map().tempo_at (pos));
+               sprintf (buf, "%-5.3f", _session->tempo_map().tempo_at_frame (pos).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")));
 
@@ -1300,6 +1301,7 @@ AudioClock::set_session (Session *s)
 
                _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());
+               _session->tempo_map().MetricPositionChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::metric_position_changed, this), gui_context());
 
                XMLProperty const * prop;
                XMLNode* node = _session->extra_xml (X_("ClockModes"));