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:
Robin Gareus 2012-11-11 02:45:01 +00:00
parent 2bc4b879b6
commit 23f00184c8
6 changed files with 23 additions and 38 deletions

View File

@ -53,7 +53,7 @@ using Gtkmm2ext::Keyboard;
sigc::signal<void> AudioClock::ModeChanged;
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::x_leading_padding = 6.0;
@ -83,6 +83,7 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string&
, upper_height (0)
, mode_based_info_ratio (1.0)
, corner_radius (9)
, font_size (10240)
, editing (false)
, bbt_reference_time (-1)
, last_when(0)
@ -151,7 +152,6 @@ 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());
@ -177,13 +177,6 @@ AudioClock::set_font ()
/* 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;
/* 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);
info_attributes.change (*foreground_attr);
small_info_attributes.change (*foreground_attr);
editing_attributes.change (*foreground_attr);
editing_attributes.change (*editing_attr);
@ -274,13 +266,8 @@ AudioClock::set_colors ()
}
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);
}
_left_layout->set_attributes (info_attributes);
_right_layout->set_attributes (info_attributes);
}
queue_draw ();
@ -364,7 +351,7 @@ AudioClock::render (cairo_t* cr)
if (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 {
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));
if (_left_layout && _right_layout) {
SyncSource sync_src = Config->get_sync_source();
if (_session->config.get_external_sync()) {
@ -1143,7 +1131,8 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
if (slave) {
_left_layout->set_text (string_compose ("%1",
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 {
_left_layout->set_text (string_compose ("--pending--",
sync_source_to_string(sync_src, true)));
@ -1154,7 +1143,8 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
if (slave) {
_left_layout->set_text (string_compose ("%1",
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 {
_left_layout->set_text (string_compose ("%1 --pending--",
sync_source_to_string(sync_src, true)));
@ -1165,7 +1155,8 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
if (slave) {
_left_layout->set_text (string_compose ("%1",
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 {
_left_layout->set_text (string_compose ("%1 --pending--",
sync_source_to_string(sync_src, true)));
@ -2057,13 +2048,8 @@ AudioClock::set_mode (Mode m)
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);
}
_left_layout->set_attributes (info_attributes);
_right_layout->set_attributes (info_attributes);
/* adjust info_height according to font size */
int ignored;
_left_layout->set_text (" 1234567890");

View File

@ -114,7 +114,6 @@ 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;
@ -124,6 +123,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
int upper_height;
double mode_based_info_ratio;
double corner_radius;
uint32_t font_size;
static const double info_font_scale_factor;
static const double separator_height;

View File

@ -39,7 +39,7 @@
#endif
// used for approximate_current_delta():
#define PLUSMINUS(A) ( ((A)<0) ? "\u2012" : (((A)>0) ? "+" : "\u00B1") )
#define PLUSMINUS(A) ( ((A)<0) ? "-" : (((A)>0) ? "+" : "\u00B1") )
namespace MIDI {
class Port;

View File

@ -540,13 +540,13 @@ LTC_Slave::approximate_current_position() const
std::string
LTC_Slave::approximate_current_delta() const
{
char delta[24];
char delta[80];
if (last_timestamp == 0 || engine_dll_initstate == 0) {
snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
} else if ((monotonic_cnt - last_timestamp) > 2 * frames_per_ltc_frame) {
snprintf(delta, sizeof(delta), "flywheel");
snprintf(delta, sizeof(delta), _("flywheel"));
} 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));
}
return std::string(delta);

View File

@ -359,11 +359,11 @@ MIDIClock_Slave::resolution() const
std::string
MIDIClock_Slave::approximate_current_delta() const
{
char delta[24];
char delta[80];
if (last_timestamp == 0 || _starting) {
snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
} 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));
}
return std::string(delta);

View File

@ -673,14 +673,13 @@ MTC_Slave::approximate_current_position() const
std::string
MTC_Slave::approximate_current_delta() const
{
char delta[24];
char delta[80];
SafeTime last;
read_current (&last);
if (last.timestamp == 0 || reset_pending) {
snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
} else {
// TODO if current_delta > 1 frame -> display timecode.
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));
}
return std::string(delta);