+int
+MiniTimeline::draw_edge (cairo_t* cr, int x0, int x1, bool left, const std::string& label, bool& prelight)
+{
+ int h = _marker_height;
+ int w2 = (h - 1) / 4;
+
+ const int y = PADDING;
+ const double yc = rint (h * .5);
+ const double dy = h * .4;
+
+ bool with_label;
+ int lw, lh, lx;
+ _layout->set_text (label);
+ _layout->get_pixel_size (lw, lh);
+
+ double px, dx;
+ if (left) {
+ if (x0 + 2 * w2 + lw + 2 < x1) {
+ x1 = std::min (x1, x0 + 2 * w2 + lw + 2);
+ with_label = true;
+ } else {
+ x1 = std::min (x1, x0 + 2 * w2);
+ with_label = false;
+ }
+ px = x0;
+ dx = 2 * w2;
+ lx = x0 + dx;
+ } else {
+ if (x1 - 2 * w2 - lw - 2 > x0) {
+ x0 = std::max (x0, x1 - 2 * w2 - lw - 2);
+ with_label = true;
+ } else {
+ x0 = std::max (x0, x1 - 2 * w2);
+ with_label = false;
+ }
+ px = x1;
+ dx = -2 * w2;
+ lx = x1 + dx - lw - 2;
+ }
+
+ if (x1 - x0 < 2 * w2) {
+ return left ? x0 : x1;
+ }
+
+ if (_pointer_y >= 0 && _pointer_y <= y + h && _pointer_x >= x0 && _pointer_x <= x1) {
+ prelight = true;
+ }
+
+ // TODO cache in set_colors()
+ uint32_t color = UIConfiguration::instance().color (
+ prelight ? "entered marker" : "location marker");
+
+ double r, g, b, a;
+ Gtkmm2ext::color_to_rgba (color, r, g, b, a);
+
+ if (with_label) {
+ const int y = PADDING;
+ cairo_save (cr);
+ cairo_rectangle (cr, lx, y, lw + 2, h);
+ cairo_set_source_rgba (cr, r, g, b, 0.5); // this should use a shaded color
+ cairo_fill_preserve (cr);
+ cairo_clip (cr);
+
+ // marker label
+ cairo_move_to (cr, lx + 1, y + .5 * (h - lh));
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ pango_cairo_show_layout (cr, _layout->gobj());
+ cairo_restore (cr);
+ }
+
+ // draw arrow
+ cairo_move_to (cr, px - .5, PADDING + yc - .5);
+ cairo_rel_line_to (cr, dx , dy);
+ cairo_rel_line_to (cr, 0, -2. * dy);
+ cairo_close_path (cr);
+ cairo_set_source_rgba (cr, r, g, b, 1.0);
+ cairo_set_line_width (cr, 1.0);
+ cairo_stroke_preserve (cr);
+ cairo_fill (cr);
+
+ return left ? x1 : x0;
+}
+
+