X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Faudio_clock.cc;h=16b4151a81840a380c46cf45404ecafcfef46db6;hb=cf52d6e4b40111eb04b244ec054055a4ec15dbe0;hp=528d9178948f1f1e360fe3ef6397da80e9cc87fc;hpb=fc1e7dbb55939c708ce572d3a5c2518ea926a682;p=ardour.git diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 528d917894..16b4151a81 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -37,12 +37,12 @@ #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 "i18n.h" +#include "ui_config.h" +#include "pbd/i18n.h" using namespace ARDOUR; using namespace ARDOUR_UI_UTILS; @@ -120,8 +120,8 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string& clocks.push_back (this); } - UIConfiguration::ColorsChanged.connect (sigc::mem_fun (*this, &AudioClock::set_colors)); - UIConfiguration::DPIReset.connect (sigc::mem_fun (*this, &AudioClock::dpi_reset)); + UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &AudioClock::set_colors)); + UIConfiguration::instance().DPIReset.connect (sigc::mem_fun (*this, &AudioClock::dpi_reset)); } AudioClock::~AudioClock () @@ -151,7 +151,7 @@ AudioClock::on_realize () Gtk::Requisition req; CairoWidget::on_realize (); - + set_clock_dimensions (req); first_width = req.width; @@ -220,15 +220,15 @@ AudioClock::set_colors () uint32_t cursor_color; if (active_state()) { - bg_color = ARDOUR_UI::config()->color (string_compose ("%1 active: background", get_name())); - text_color = ARDOUR_UI::config()->color (string_compose ("%1 active: text", get_name())); - editing_color = ARDOUR_UI::config()->color (string_compose ("%1 active: edited text", get_name())); - cursor_color = ARDOUR_UI::config()->color (string_compose ("%1 active: cursor", get_name())); + bg_color = UIConfiguration::instance().color (string_compose ("%1 active: background", get_name())); + text_color = UIConfiguration::instance().color (string_compose ("%1 active: text", get_name())); + editing_color = UIConfiguration::instance().color (string_compose ("%1 active: edited text", get_name())); + cursor_color = UIConfiguration::instance().color (string_compose ("%1 active: cursor", get_name())); } else { - bg_color = ARDOUR_UI::config()->color (string_compose ("%1: background", get_name())); - text_color = ARDOUR_UI::config()->color (string_compose ("%1: text", get_name())); - editing_color = ARDOUR_UI::config()->color (string_compose ("%1: edited text", get_name())); - cursor_color = ARDOUR_UI::config()->color (string_compose ("%1: cursor", get_name())); + bg_color = UIConfiguration::instance().color (string_compose ("%1: background", get_name())); + text_color = UIConfiguration::instance().color (string_compose ("%1: text", get_name())); + editing_color = UIConfiguration::instance().color (string_compose ("%1: edited text", get_name())); + cursor_color = UIConfiguration::instance().color (string_compose ("%1: cursor", get_name())); } /* store for bg and cursor in render() */ @@ -318,7 +318,7 @@ AudioClock::render (cairo_t* cr, cairo_rectangle_t*) cairo_save (cr); cairo_scale (cr, xscale, yscale); } - + pango_cairo_show_layout (cr, _layout->gobj()); if (xscale != 1.0 || yscale != 1.0) { @@ -507,15 +507,15 @@ AudioClock::on_size_request (Gtk::Requisition* req) Glib::RefPtr 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 (INFO_FONT_SIZE); @@ -561,17 +561,17 @@ AudioClock::start_edit (Field f) 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 (); Keyboard::magic_widget_grab_focus (); @@ -923,6 +923,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 +1258,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 +1287,7 @@ AudioClock::set_bbt (framepos_t when, bool /*force*/) TempoMetric m (_session->tempo_map().metric_at (pos)); - sprintf (buf, "%-5.1f", m.tempo().beats_per_minute()); + sprintf (buf, "%-5.3f", _session->tempo_map().tempo_at_frame (pos).beats_per_minute()); _left_layout->set_markup (string_compose ("" TXTSPAN "%3 %2", INFO_FONT_SIZE, buf, _("Tempo"))); @@ -1300,8 +1306,9 @@ 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()); - const XMLProperty* prop; + XMLProperty const * prop; XMLNode* node = _session->extra_xml (X_("ClockModes")); AudioClock::Mode amode; @@ -1311,7 +1318,7 @@ AudioClock::set_session (Session *s) if ((prop = (*i)->property (X_("mode"))) != 0) { amode = AudioClock::Mode (string_2_enum (prop->value(), amode)); - set_mode (amode); + set_mode (amode, true); } if ((prop = (*i)->property (X_("on"))) != 0) { set_off (!string_is_affirmative (prop->value())); @@ -1419,7 +1426,10 @@ AudioClock::on_key_press_event (GdkEventKey* ev) goto use_input_string; default: - return false; + /* do not allow other keys to passthru to the rest of the GUI + when editing. + */ + return true; } if (!insert_map.empty() && (input_string.length() >= insert_map.size())) { @@ -2109,16 +2119,14 @@ AudioClock::build_ops_menu () MenuList& ops_items = ops_menu->items(); ops_menu->set_name ("ArdourContextMenu"); - if (!Profile->get_sae()) { - ops_items.push_back (MenuElem (_("Timecode"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Timecode))); - } - ops_items.push_back (MenuElem (_("Bars:Beats"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), BBT))); - ops_items.push_back (MenuElem (_("Minutes:Seconds"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), MinSec))); - ops_items.push_back (MenuElem (_("Samples"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Frames))); + ops_items.push_back (MenuElem (_("Timecode"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Timecode, false))); + ops_items.push_back (MenuElem (_("Bars:Beats"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), BBT, false))); + ops_items.push_back (MenuElem (_("Minutes:Seconds"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), MinSec, false))); + ops_items.push_back (MenuElem (_("Samples"), sigc::bind (sigc::mem_fun(*this, &AudioClock::set_mode), Frames, false))); if (editable && !_off && !is_duration && !_follows_playhead) { ops_items.push_back (SeparatorElem()); - ops_items.push_back (MenuElem (_("Set From Playhead"), sigc::mem_fun(*this, &AudioClock::set_from_playhead))); + ops_items.push_back (MenuElem (_("Set from Playhead"), sigc::mem_fun(*this, &AudioClock::set_from_playhead))); ops_items.push_back (MenuElem (_("Locate to This Time"), sigc::mem_fun(*this, &AudioClock::locate))); } ops_items.push_back (SeparatorElem()); @@ -2147,7 +2155,7 @@ AudioClock::locate () } void -AudioClock::set_mode (Mode m) +AudioClock::set_mode (Mode m, bool noemit) { if (_mode == m) { return; @@ -2221,11 +2229,11 @@ AudioClock::set_mode (Mode m) set (last_when, true); - if (!is_transient) { - ModeChanged (); /* EMIT SIGNAL (the static one)*/ - } + if (!is_transient && !noemit) { + ModeChanged (); /* EMIT SIGNAL (the static one)*/ + } - mode_changed (); /* EMIT SIGNAL (the member one) */ + mode_changed (); /* EMIT SIGNAL (the member one) */ } void