tweaks to be ready for more information timecode display in Timecode clock mode
git-svn-id: svn://localhost/ardour2/branches/3.0@13264 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -73,6 +73,7 @@
|
||||
#include "ardour/session_route.h"
|
||||
#include "ardour/session_state_utils.h"
|
||||
#include "ardour/session_utils.h"
|
||||
#include "ardour/slave.h"
|
||||
|
||||
#include "timecode/time.h"
|
||||
|
||||
@@ -1105,8 +1106,17 @@ ARDOUR_UI::update_timecode_format ()
|
||||
char buf[64];
|
||||
|
||||
if (_session) {
|
||||
bool matching;
|
||||
TimecodeSlave* tcslave;
|
||||
|
||||
if ((tcslave = dynamic_cast<TimecodeSlave*>(_session->slave())) != 0) {
|
||||
matching = (tcslave->apparent_timecode_format() == _session->config.get_timecode_format());
|
||||
} else {
|
||||
matching = true;
|
||||
}
|
||||
|
||||
snprintf (buf, sizeof (buf), S_("Timecode|TC: <span foreground=\"%s\">%sfps</span>"),
|
||||
rand() % 2 ? X_("red") : X_("green"),
|
||||
matching ? X_("red") : X_("green"),
|
||||
Timecode::timecode_format_name (_session->config.get_timecode_format()).c_str());
|
||||
} else {
|
||||
snprintf (buf, sizeof (buf), "TC: n/a");
|
||||
|
||||
@@ -30,10 +30,11 @@
|
||||
#include "gtkmm2ext/utils.h"
|
||||
#include "gtkmm2ext/rgb_macros.h"
|
||||
|
||||
#include "ardour/types.h"
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/tempo.h"
|
||||
#include "ardour/profile.h"
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/slave.h"
|
||||
#include "ardour/tempo.h"
|
||||
#include "ardour/types.h"
|
||||
|
||||
#include "ardour_ui.h"
|
||||
#include "audio_clock.h"
|
||||
@@ -150,6 +151,7 @@ AudioClock::set_font ()
|
||||
Glib::RefPtr<Gtk::Style> style = get_style ();
|
||||
Pango::FontDescription font;
|
||||
Pango::AttrFontDesc* font_attr;
|
||||
uint32_t font_size;
|
||||
|
||||
if (!is_realized()) {
|
||||
font = get_font_for_style (get_name());
|
||||
@@ -157,19 +159,30 @@ AudioClock::set_font ()
|
||||
font = style->get_font();
|
||||
}
|
||||
|
||||
font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
|
||||
font_size = font.get_size();
|
||||
|
||||
font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
|
||||
|
||||
normal_attributes.change (*font_attr);
|
||||
editing_attributes.change (*font_attr);
|
||||
|
||||
/* now a smaller version of the same font */
|
||||
|
||||
delete font_attr;
|
||||
font.set_size ((int) lrint (font.get_size() * info_font_scale_factor));
|
||||
font.set_size ((int) lrint (font_size * info_font_scale_factor));
|
||||
font.set_weight (Pango::WEIGHT_NORMAL);
|
||||
font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
|
||||
|
||||
info_attributes.change (*font_attr);
|
||||
|
||||
/* and an even smaller one */
|
||||
|
||||
delete font_attr;
|
||||
font.set_size ((int) lrint (font_size * info_font_scale_factor * 0.75));
|
||||
font.set_weight (Pango::WEIGHT_BOLD);
|
||||
font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
|
||||
|
||||
small_info_attributes.change (*font_attr);
|
||||
|
||||
delete font_attr;
|
||||
|
||||
@@ -250,6 +263,7 @@ AudioClock::set_colors ()
|
||||
|
||||
normal_attributes.change (*foreground_attr);
|
||||
info_attributes.change (*foreground_attr);
|
||||
small_info_attributes.change (*foreground_attr);
|
||||
editing_attributes.change (*foreground_attr);
|
||||
editing_attributes.change (*editing_attr);
|
||||
|
||||
@@ -260,8 +274,13 @@ AudioClock::set_colors ()
|
||||
}
|
||||
|
||||
if (_left_layout) {
|
||||
_left_layout->set_attributes (info_attributes);
|
||||
_right_layout->set_attributes (info_attributes);
|
||||
if (_mode == Timecode) {
|
||||
_left_layout->set_attributes (small_info_attributes);
|
||||
_right_layout->set_attributes (small_info_attributes);
|
||||
} else {
|
||||
_left_layout->set_attributes (info_attributes);
|
||||
_right_layout->set_attributes (info_attributes);
|
||||
}
|
||||
}
|
||||
|
||||
queue_draw ();
|
||||
@@ -919,7 +938,12 @@ AudioClock::set (framepos_t when, bool force, framecnt_t offset)
|
||||
}
|
||||
|
||||
if (when == last_when && !force) {
|
||||
return;
|
||||
if (_mode != Timecode) {
|
||||
/* timecode may need to force display of TC source
|
||||
* time, so don't return early.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!editing) {
|
||||
@@ -1083,25 +1107,35 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
|
||||
if (_left_layout) {
|
||||
|
||||
if (_session->config.get_external_sync()) {
|
||||
Slave* slave = _session->slave();
|
||||
|
||||
switch (Config->get_sync_source()) {
|
||||
case JACK:
|
||||
_left_layout->set_text ("JACK");
|
||||
break;
|
||||
case MTC:
|
||||
_left_layout->set_text ("MTC");
|
||||
if (slave) {
|
||||
_left_layout->set_text (string_compose ("MTC %1", dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
|
||||
} else {
|
||||
_left_layout->set_text ("MTC --pending--");
|
||||
}
|
||||
break;
|
||||
case MIDIClock:
|
||||
_left_layout->set_text ("M-Clock");
|
||||
break;
|
||||
case LTC:
|
||||
_left_layout->set_text ("LTC");
|
||||
if (slave) {
|
||||
_left_layout->set_text (string_compose ("LTC %1", dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
|
||||
} else {
|
||||
_left_layout->set_text ("LTC --pending--");
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
_left_layout->set_text ("INT");
|
||||
}
|
||||
|
||||
_right_layout->set_text ("TBDiscussed");
|
||||
_right_layout->set_text ("77:77:77:77");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1984,7 +2018,7 @@ AudioClock::set_mode (Mode m)
|
||||
|
||||
switch (_mode) {
|
||||
case Timecode:
|
||||
mode_based_info_ratio = 0.5;
|
||||
mode_based_info_ratio = 0.57; // trial and error, could be affected by font metrics
|
||||
insert_map.push_back (11);
|
||||
insert_map.push_back (10);
|
||||
insert_map.push_back (8);
|
||||
@@ -2026,6 +2060,16 @@ AudioClock::set_mode (Mode m)
|
||||
break;
|
||||
}
|
||||
|
||||
if (_left_layout) {
|
||||
if (_mode == Timecode) {
|
||||
_left_layout->set_attributes (small_info_attributes);
|
||||
_right_layout->set_attributes (small_info_attributes);
|
||||
} else {
|
||||
_left_layout->set_attributes (info_attributes);
|
||||
_right_layout->set_attributes (info_attributes);
|
||||
}
|
||||
}
|
||||
|
||||
set (last_when, true);
|
||||
|
||||
if (!is_transient) {
|
||||
|
||||
@@ -114,6 +114,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
||||
Pango::AttrList normal_attributes;
|
||||
Pango::AttrList editing_attributes;
|
||||
Pango::AttrList info_attributes;
|
||||
Pango::AttrList small_info_attributes;
|
||||
|
||||
int first_height;
|
||||
int first_width;
|
||||
|
||||
@@ -800,6 +800,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
|
||||
};
|
||||
|
||||
SlaveState slave_state() const { return _slave_state; }
|
||||
Slave* slave() const { return _slave; }
|
||||
|
||||
boost::shared_ptr<SessionPlaylists> playlists;
|
||||
|
||||
|
||||
@@ -230,6 +230,13 @@ class TimecodeSlave : public Slave {
|
||||
TimecodeSlave () {}
|
||||
|
||||
virtual Timecode::TimecodeFormat apparent_timecode_format() const = 0;
|
||||
|
||||
/* this is intended to be used by a UI and polled from a timeout. it should
|
||||
return a string describing the current position of the TC source. it
|
||||
should NOT do any computation, but should use a cached value
|
||||
of the TC source position.
|
||||
*/
|
||||
virtual std::string approximate_current_position() const = 0;
|
||||
};
|
||||
|
||||
class MTC_Slave : public TimecodeSlave {
|
||||
@@ -250,6 +257,7 @@ class MTC_Slave : public TimecodeSlave {
|
||||
bool give_slave_full_control_over_transport_speed() const;
|
||||
|
||||
Timecode::TimecodeFormat apparent_timecode_format() const;
|
||||
std::string approximate_current_position() const;
|
||||
|
||||
private:
|
||||
Session& session;
|
||||
@@ -325,6 +333,7 @@ public:
|
||||
bool give_slave_full_control_over_transport_speed() const;
|
||||
|
||||
Timecode::TimecodeFormat apparent_timecode_format() const;
|
||||
std::string approximate_current_position() const;
|
||||
|
||||
private:
|
||||
int parse_ltc(const jack_nframes_t, const jack_default_audio_sample_t * const, const framecnt_t);
|
||||
|
||||
@@ -253,3 +253,9 @@ LTC_Slave::apparent_timecode_format () const
|
||||
/* XXX to be computed, determined from incoming stream */
|
||||
return timecode_25;
|
||||
}
|
||||
|
||||
std::string
|
||||
LTC_Slave::approximate_current_position() const
|
||||
{
|
||||
return "88:88:88:88";
|
||||
}
|
||||
|
||||
@@ -626,3 +626,9 @@ MTC_Slave::apparent_timecode_format () const
|
||||
{
|
||||
return mtc_timecode;
|
||||
}
|
||||
|
||||
std::string
|
||||
MTC_Slave::approximate_current_position() const
|
||||
{
|
||||
return "88:88:88:88";
|
||||
}
|
||||
|
||||
@@ -1119,6 +1119,7 @@ Session::process_event (SessionEvent* ev)
|
||||
break;
|
||||
|
||||
case SessionEvent::SetSyncSource:
|
||||
DEBUG_TRACE (DEBUG::Slave, "seen request for new slave\n");
|
||||
use_sync_source (ev->slave);
|
||||
break;
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ Session::request_sync_source (Slave* new_slave)
|
||||
_was_seamless = seamless;
|
||||
|
||||
ev->slave = new_slave;
|
||||
DEBUG_TRACE (DEBUG::Slave, "sent request for new slave\n");
|
||||
queue_event (ev);
|
||||
}
|
||||
|
||||
@@ -1323,6 +1324,8 @@ Session::use_sync_source (Slave* new_slave)
|
||||
delete _slave;
|
||||
_slave = new_slave;
|
||||
|
||||
DEBUG_TRACE (DEBUG::Slave, string_compose ("set new slave to %1\n", _slave));
|
||||
|
||||
send_full_time_code (_transport_frame);
|
||||
|
||||
boost::shared_ptr<RouteList> rl = routes.reader();
|
||||
|
||||
Reference in New Issue
Block a user