summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2012-10-29 17:29:36 +0000
committerRobin Gareus <robin@gareus.org>2012-10-29 17:29:36 +0000
commit5a7e5fc8d5aba7f857ff8df89fbb7c8bf25f380c (patch)
treeadd93399c24fdb52b1685ea4487669122de3f6e5
parent52532839110d4bbd2e4dc3e0eb8967d0f278a611 (diff)
clock-display: right-align slave delta, fix overflow of pull up/down info
also vertically center the info depending on font-size. git-svn-id: svn://localhost/ardour2/branches/3.0@13367 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/audio_clock.cc52
1 files changed, 40 insertions, 12 deletions
diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc
index 5df46da5b4..866fd353e4 100644
--- a/gtk2_ardour/audio_clock.cc
+++ b/gtk2_ardour/audio_clock.cc
@@ -345,7 +345,25 @@ AudioClock::render (cairo_t* cr)
cairo_fill (cr);
}
- cairo_move_to (cr, x_leading_padding + left_rect_width + separator_height, upper_height + separator_height + ((h - info_height)/2.0));
+
+ if (_right_layout->get_alignment() == Pango::ALIGN_RIGHT) {
+ /* right-align does not work per se beacuse layout width is unset.
+ * Using _right_layout->set_width([value >=0]) would also enable
+ * word-wrapping which is not wanted here.
+ * The solution is to custom align the layout depending on its size.
+ * if it is larger than the available space it will be cropped on the
+ * right edge rather than override text on the left side.
+ */
+ int x, rw, rh;
+ _right_layout->get_pixel_size(rw, rh);
+ x = get_width() - rw- separator_height - x_leading_padding;
+ 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));
+ } else {
+ cairo_move_to (cr, x_leading_padding + left_rect_width + separator_height, upper_height + separator_height + ((h - info_height)/2.0));
+ }
pango_cairo_show_layout (cr, _right_layout->gobj());
} else {
@@ -947,9 +965,15 @@ AudioClock::set (framepos_t when, bool force, framecnt_t offset)
}
if (!editing) {
+ if (_right_layout) {
+ _right_layout->set_alignment(Pango::ALIGN_LEFT);
+ }
switch (_mode) {
case Timecode:
+ if (_right_layout) {
+ _right_layout->set_alignment(Pango::ALIGN_RIGHT);
+ }
set_timecode (when, force);
break;
@@ -1017,7 +1041,7 @@ AudioClock::set_frames (framepos_t when, bool /*force*/)
if (vid_pullup == 0.0) {
_right_layout->set_text (_("pullup: \u2012"));
} else {
- sprintf (buf, _("pullup %-6.4f"), vid_pullup);
+ sprintf (buf, _("%+-6.4f%%"), vid_pullup);
_right_layout->set_text (buf);
}
}
@@ -2026,6 +2050,20 @@ AudioClock::set_mode (Mode m)
_layout->set_text ("");
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);
+ }
+ /* adjust info_height according to font size */
+ int ignored;
+ _left_layout->set_text (" 1234567890");
+ _left_layout->get_pixel_size (ignored, info_height);
+ info_height += 4;
+
_left_layout->set_text ("");
_right_layout->set_text ("");
}
@@ -2074,16 +2112,6 @@ 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) {