mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 00:34:59 +01:00
canvas: ruler never shows marks/text for points too close to display the label
This commit is contained in:
parent
19ab75f5e5
commit
0ef10e4f5f
1 changed files with 30 additions and 22 deletions
|
|
@ -161,6 +161,7 @@ Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
||||||
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (cr);
|
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (cr);
|
||||||
|
|
||||||
Pango::FontDescription* last_font_description = 0;
|
Pango::FontDescription* last_font_description = 0;
|
||||||
|
Coord prev = -1;
|
||||||
|
|
||||||
for (vector<Mark>::const_iterator m = marks.begin(); m != marks.end(); ++m) {
|
for (vector<Mark>::const_iterator m = marks.begin(); m != marks.end(); ++m) {
|
||||||
Duple pos;
|
Duple pos;
|
||||||
|
|
@ -169,6 +170,33 @@ Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
||||||
pos.x = floor ((m->position - _lower) / _metric->units_per_pixel);
|
pos.x = floor ((m->position - _lower) / _metric->units_per_pixel);
|
||||||
pos.y = self.y1; /* bottom edge */
|
pos.y = self.y1; /* bottom edge */
|
||||||
|
|
||||||
|
if (fd != last_font_description) {
|
||||||
|
layout->set_font_description (*fd);
|
||||||
|
last_font_description = fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* and the text */
|
||||||
|
|
||||||
|
if (!m->label.empty()) {
|
||||||
|
Pango::Rectangle logical;
|
||||||
|
|
||||||
|
layout->set_text (m->label);
|
||||||
|
logical = layout->get_pixel_logical_extents ();
|
||||||
|
|
||||||
|
if ((prev >= 0.) && ((pos.x - prev) < (6. + logical.get_width()))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_divide_height >= 0) {
|
||||||
|
cr->move_to (pos.x + 2.0, self.y0 + _divide_height + logical.get_y() + 2.0); /* 2 pixel padding below divider */
|
||||||
|
} else {
|
||||||
|
cr->move_to (pos.x + 2.0, self.y0 + logical.get_y() + .5 * (height - logical.get_height()));
|
||||||
|
}
|
||||||
|
|
||||||
|
layout->show_in_cairo_context (cr);
|
||||||
|
prev = pos.x;
|
||||||
|
}
|
||||||
|
|
||||||
if (_outline_width == 1.0) {
|
if (_outline_width == 1.0) {
|
||||||
/* Cairo single pixel line correction */
|
/* Cairo single pixel line correction */
|
||||||
cr->move_to (pos.x + 0.5, pos.y);
|
cr->move_to (pos.x + 0.5, pos.y);
|
||||||
|
|
@ -194,31 +222,11 @@ Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
||||||
cr->rel_line_to (0, -height/5.0);
|
cr->rel_line_to (0, -height/5.0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cr->stroke ();
|
cr->stroke ();
|
||||||
|
|
||||||
if (fd != last_font_description) {
|
|
||||||
layout->set_font_description (*fd);
|
|
||||||
last_font_description = fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* and the text */
|
|
||||||
|
|
||||||
if (!m->label.empty()) {
|
|
||||||
Pango::Rectangle logical;
|
|
||||||
|
|
||||||
layout->set_text (m->label);
|
|
||||||
logical = layout->get_pixel_logical_extents ();
|
|
||||||
|
|
||||||
if (_divide_height >= 0) {
|
|
||||||
cr->move_to (pos.x + 2.0, self.y0 + _divide_height + logical.get_y() + 2.0); /* 2 pixel padding below divider */
|
|
||||||
} else {
|
|
||||||
cr->move_to (pos.x + 2.0, self.y0 + logical.get_y() + .5 * (height - logical.get_height()));
|
|
||||||
}
|
|
||||||
layout->show_in_cairo_context (cr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_divide_height >= 0.0) {
|
if (_divide_height >= 0.0) {
|
||||||
|
|
||||||
cr->set_line_width (1.0);
|
cr->set_line_width (1.0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue