mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 04:06:26 +01:00
first round of audio-clock font rendering update
git-svn-id: svn://localhost/ardour2/branches/3.0@13425 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
2bc4b879b6
commit
23f00184c8
6 changed files with 23 additions and 38 deletions
|
|
@ -53,7 +53,7 @@ using Gtkmm2ext::Keyboard;
|
||||||
|
|
||||||
sigc::signal<void> AudioClock::ModeChanged;
|
sigc::signal<void> AudioClock::ModeChanged;
|
||||||
vector<AudioClock*> AudioClock::clocks;
|
vector<AudioClock*> AudioClock::clocks;
|
||||||
const double AudioClock::info_font_scale_factor = 0.6;
|
const double AudioClock::info_font_scale_factor = 0.5;
|
||||||
const double AudioClock::separator_height = 0.0;
|
const double AudioClock::separator_height = 0.0;
|
||||||
const double AudioClock::x_leading_padding = 6.0;
|
const double AudioClock::x_leading_padding = 6.0;
|
||||||
|
|
||||||
|
|
@ -83,6 +83,7 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string&
|
||||||
, upper_height (0)
|
, upper_height (0)
|
||||||
, mode_based_info_ratio (1.0)
|
, mode_based_info_ratio (1.0)
|
||||||
, corner_radius (9)
|
, corner_radius (9)
|
||||||
|
, font_size (10240)
|
||||||
, editing (false)
|
, editing (false)
|
||||||
, bbt_reference_time (-1)
|
, bbt_reference_time (-1)
|
||||||
, last_when(0)
|
, last_when(0)
|
||||||
|
|
@ -151,7 +152,6 @@ AudioClock::set_font ()
|
||||||
Glib::RefPtr<Gtk::Style> style = get_style ();
|
Glib::RefPtr<Gtk::Style> style = get_style ();
|
||||||
Pango::FontDescription font;
|
Pango::FontDescription font;
|
||||||
Pango::AttrFontDesc* font_attr;
|
Pango::AttrFontDesc* font_attr;
|
||||||
uint32_t font_size;
|
|
||||||
|
|
||||||
if (!is_realized()) {
|
if (!is_realized()) {
|
||||||
font = get_font_for_style (get_name());
|
font = get_font_for_style (get_name());
|
||||||
|
|
@ -177,13 +177,6 @@ AudioClock::set_font ()
|
||||||
|
|
||||||
/* and an even smaller one */
|
/* 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;
|
delete font_attr;
|
||||||
|
|
||||||
/* get the figure width for the font. This doesn't have to super
|
/* get the figure width for the font. This doesn't have to super
|
||||||
|
|
@ -263,7 +256,6 @@ AudioClock::set_colors ()
|
||||||
|
|
||||||
normal_attributes.change (*foreground_attr);
|
normal_attributes.change (*foreground_attr);
|
||||||
info_attributes.change (*foreground_attr);
|
info_attributes.change (*foreground_attr);
|
||||||
small_info_attributes.change (*foreground_attr);
|
|
||||||
editing_attributes.change (*foreground_attr);
|
editing_attributes.change (*foreground_attr);
|
||||||
editing_attributes.change (*editing_attr);
|
editing_attributes.change (*editing_attr);
|
||||||
|
|
||||||
|
|
@ -274,14 +266,9 @@ AudioClock::set_colors ()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_left_layout) {
|
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);
|
_left_layout->set_attributes (info_attributes);
|
||||||
_right_layout->set_attributes (info_attributes);
|
_right_layout->set_attributes (info_attributes);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
queue_draw ();
|
queue_draw ();
|
||||||
}
|
}
|
||||||
|
|
@ -364,7 +351,7 @@ AudioClock::render (cairo_t* cr)
|
||||||
if (x < x_leading_padding + left_rect_width + separator_height) {
|
if (x < x_leading_padding + left_rect_width + separator_height) {
|
||||||
x = x_leading_padding + left_rect_width + separator_height;
|
x = x_leading_padding + left_rect_width + separator_height;
|
||||||
}
|
}
|
||||||
cairo_move_to (cr, x, upper_height + separator_height + ((h - info_height)/2.0));
|
cairo_move_to (cr, x, upper_height + separator_height + ((h - rh)/2.0));
|
||||||
} else {
|
} else {
|
||||||
cairo_move_to (cr, x_leading_padding + left_rect_width + separator_height, upper_height + separator_height + ((h - info_height)/2.0));
|
cairo_move_to (cr, x_leading_padding + left_rect_width + separator_height, upper_height + separator_height + ((h - info_height)/2.0));
|
||||||
}
|
}
|
||||||
|
|
@ -1128,6 +1115,7 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
|
||||||
_layout->set_text (Timecode::timecode_format_time(TC));
|
_layout->set_text (Timecode::timecode_format_time(TC));
|
||||||
|
|
||||||
if (_left_layout && _right_layout) {
|
if (_left_layout && _right_layout) {
|
||||||
|
|
||||||
SyncSource sync_src = Config->get_sync_source();
|
SyncSource sync_src = Config->get_sync_source();
|
||||||
|
|
||||||
if (_session->config.get_external_sync()) {
|
if (_session->config.get_external_sync()) {
|
||||||
|
|
@ -1143,7 +1131,8 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
|
||||||
if (slave) {
|
if (slave) {
|
||||||
_left_layout->set_text (string_compose ("%1",
|
_left_layout->set_text (string_compose ("%1",
|
||||||
dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
|
dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
|
||||||
_right_layout->set_text (slave->approximate_current_delta());
|
_right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
|
||||||
|
(int)round(font_size * info_font_scale_factor * .9), slave->approximate_current_delta()));
|
||||||
} else {
|
} else {
|
||||||
_left_layout->set_text (string_compose ("--pending--",
|
_left_layout->set_text (string_compose ("--pending--",
|
||||||
sync_source_to_string(sync_src, true)));
|
sync_source_to_string(sync_src, true)));
|
||||||
|
|
@ -1154,7 +1143,8 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
|
||||||
if (slave) {
|
if (slave) {
|
||||||
_left_layout->set_text (string_compose ("%1",
|
_left_layout->set_text (string_compose ("%1",
|
||||||
sync_source_to_string(sync_src, true)));
|
sync_source_to_string(sync_src, true)));
|
||||||
_right_layout->set_text (slave->approximate_current_delta());
|
_right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
|
||||||
|
(int)round(font_size * info_font_scale_factor * .9), slave->approximate_current_delta()));
|
||||||
} else {
|
} else {
|
||||||
_left_layout->set_text (string_compose ("%1 --pending--",
|
_left_layout->set_text (string_compose ("%1 --pending--",
|
||||||
sync_source_to_string(sync_src, true)));
|
sync_source_to_string(sync_src, true)));
|
||||||
|
|
@ -1165,7 +1155,8 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
|
||||||
if (slave) {
|
if (slave) {
|
||||||
_left_layout->set_text (string_compose ("%1",
|
_left_layout->set_text (string_compose ("%1",
|
||||||
dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
|
dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
|
||||||
_right_layout->set_text (slave->approximate_current_delta());
|
_right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
|
||||||
|
(int)round(font_size * info_font_scale_factor * .9), slave->approximate_current_delta()));
|
||||||
} else {
|
} else {
|
||||||
_left_layout->set_text (string_compose ("%1 --pending--",
|
_left_layout->set_text (string_compose ("%1 --pending--",
|
||||||
sync_source_to_string(sync_src, true)));
|
sync_source_to_string(sync_src, true)));
|
||||||
|
|
@ -2057,13 +2048,8 @@ AudioClock::set_mode (Mode m)
|
||||||
|
|
||||||
if (_left_layout) {
|
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);
|
_left_layout->set_attributes (info_attributes);
|
||||||
_right_layout->set_attributes (info_attributes);
|
_right_layout->set_attributes (info_attributes);
|
||||||
}
|
|
||||||
/* adjust info_height according to font size */
|
/* adjust info_height according to font size */
|
||||||
int ignored;
|
int ignored;
|
||||||
_left_layout->set_text (" 1234567890");
|
_left_layout->set_text (" 1234567890");
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,6 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
||||||
Pango::AttrList normal_attributes;
|
Pango::AttrList normal_attributes;
|
||||||
Pango::AttrList editing_attributes;
|
Pango::AttrList editing_attributes;
|
||||||
Pango::AttrList info_attributes;
|
Pango::AttrList info_attributes;
|
||||||
Pango::AttrList small_info_attributes;
|
|
||||||
|
|
||||||
int first_height;
|
int first_height;
|
||||||
int first_width;
|
int first_width;
|
||||||
|
|
@ -124,6 +123,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
||||||
int upper_height;
|
int upper_height;
|
||||||
double mode_based_info_ratio;
|
double mode_based_info_ratio;
|
||||||
double corner_radius;
|
double corner_radius;
|
||||||
|
uint32_t font_size;
|
||||||
|
|
||||||
static const double info_font_scale_factor;
|
static const double info_font_scale_factor;
|
||||||
static const double separator_height;
|
static const double separator_height;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// used for approximate_current_delta():
|
// used for approximate_current_delta():
|
||||||
#define PLUSMINUS(A) ( ((A)<0) ? "\u2012" : (((A)>0) ? "+" : "\u00B1") )
|
#define PLUSMINUS(A) ( ((A)<0) ? "-" : (((A)>0) ? "+" : "\u00B1") )
|
||||||
|
|
||||||
namespace MIDI {
|
namespace MIDI {
|
||||||
class Port;
|
class Port;
|
||||||
|
|
|
||||||
|
|
@ -540,13 +540,13 @@ LTC_Slave::approximate_current_position() const
|
||||||
std::string
|
std::string
|
||||||
LTC_Slave::approximate_current_delta() const
|
LTC_Slave::approximate_current_delta() const
|
||||||
{
|
{
|
||||||
char delta[24];
|
char delta[80];
|
||||||
if (last_timestamp == 0 || engine_dll_initstate == 0) {
|
if (last_timestamp == 0 || engine_dll_initstate == 0) {
|
||||||
snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
|
snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
|
||||||
} else if ((monotonic_cnt - last_timestamp) > 2 * frames_per_ltc_frame) {
|
} else if ((monotonic_cnt - last_timestamp) > 2 * frames_per_ltc_frame) {
|
||||||
snprintf(delta, sizeof(delta), "flywheel");
|
snprintf(delta, sizeof(delta), _("flywheel"));
|
||||||
} else {
|
} else {
|
||||||
snprintf(delta, sizeof(delta), "\u0394 %s%4" PRIi64 " sm",
|
snprintf(delta, sizeof(delta), "\u0394<span foreground=\"green\" face=\"monospace\" >%s%5" PRIi64 "</span>sm",
|
||||||
PLUSMINUS(-current_delta), abs(current_delta));
|
PLUSMINUS(-current_delta), abs(current_delta));
|
||||||
}
|
}
|
||||||
return std::string(delta);
|
return std::string(delta);
|
||||||
|
|
|
||||||
|
|
@ -359,11 +359,11 @@ MIDIClock_Slave::resolution() const
|
||||||
std::string
|
std::string
|
||||||
MIDIClock_Slave::approximate_current_delta() const
|
MIDIClock_Slave::approximate_current_delta() const
|
||||||
{
|
{
|
||||||
char delta[24];
|
char delta[80];
|
||||||
if (last_timestamp == 0 || _starting) {
|
if (last_timestamp == 0 || _starting) {
|
||||||
snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
|
snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
|
||||||
} else {
|
} else {
|
||||||
snprintf(delta, sizeof(delta), "\u0394 %s%4" PRIi64 " sm",
|
snprintf(delta, sizeof(delta), "\u0394<span foreground=\"green\" face=\"monospace\" >%s%5" PRIi64 "</span>sm",
|
||||||
PLUSMINUS(-current_delta), abs(current_delta));
|
PLUSMINUS(-current_delta), abs(current_delta));
|
||||||
}
|
}
|
||||||
return std::string(delta);
|
return std::string(delta);
|
||||||
|
|
|
||||||
|
|
@ -673,14 +673,13 @@ MTC_Slave::approximate_current_position() const
|
||||||
std::string
|
std::string
|
||||||
MTC_Slave::approximate_current_delta() const
|
MTC_Slave::approximate_current_delta() const
|
||||||
{
|
{
|
||||||
char delta[24];
|
char delta[80];
|
||||||
SafeTime last;
|
SafeTime last;
|
||||||
read_current (&last);
|
read_current (&last);
|
||||||
if (last.timestamp == 0 || reset_pending) {
|
if (last.timestamp == 0 || reset_pending) {
|
||||||
snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
|
snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
|
||||||
} else {
|
} else {
|
||||||
// TODO if current_delta > 1 frame -> display timecode.
|
snprintf(delta, sizeof(delta), "\u0394<span foreground=\"green\" face=\"monospace\">%s%5" PRIi64 "</span>sm",
|
||||||
snprintf(delta, sizeof(delta), "\u0394 %s%4" PRIi64 " sm",
|
|
||||||
PLUSMINUS(-current_delta), abs(current_delta));
|
PLUSMINUS(-current_delta), abs(current_delta));
|
||||||
}
|
}
|
||||||
return std::string(delta);
|
return std::string(delta);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue