mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
canvas/ruler: provide option for a second font to be used for "major" marks
This commit is contained in:
parent
d92d707180
commit
20029ec7e6
2 changed files with 27 additions and 3 deletions
|
|
@ -67,6 +67,7 @@ public:
|
|||
|
||||
void set_range (double lower, double upper);
|
||||
void set_font_description (Pango::FontDescription);
|
||||
void set_second_font_description (Pango::FontDescription);
|
||||
void set_metric (const Metric&);
|
||||
|
||||
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
|
||||
|
|
@ -85,6 +86,7 @@ private:
|
|||
Gtkmm2ext::Color _divider_color_bottom;
|
||||
|
||||
Pango::FontDescription* _font_description;
|
||||
Pango::FontDescription* _second_font_description;
|
||||
mutable std::vector<Mark> marks;
|
||||
mutable bool _need_marks;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ Ruler::Ruler (Canvas* c, const Metric& m)
|
|||
, _upper (0)
|
||||
, _divide_height (-1.0)
|
||||
, _font_description (0)
|
||||
, _second_font_description (0)
|
||||
, _need_marks (true)
|
||||
{
|
||||
}
|
||||
|
|
@ -49,6 +50,7 @@ Ruler::Ruler (Canvas* c, const Metric& m, Rect const& r)
|
|||
, _upper (0)
|
||||
, _divide_height (-1.0)
|
||||
, _font_description (0)
|
||||
, _second_font_description (0)
|
||||
, _need_marks (true)
|
||||
{
|
||||
}
|
||||
|
|
@ -60,6 +62,7 @@ Ruler::Ruler (Item* parent, const Metric& m)
|
|||
, _upper (0)
|
||||
, _divide_height (-1.0)
|
||||
, _font_description (0)
|
||||
, _second_font_description (0)
|
||||
, _need_marks (true)
|
||||
{
|
||||
}
|
||||
|
|
@ -71,6 +74,7 @@ Ruler::Ruler (Item* parent, const Metric& m, Rect const& r)
|
|||
, _upper (0)
|
||||
, _divide_height (-1.0)
|
||||
, _font_description (0)
|
||||
, _second_font_description (0)
|
||||
, _need_marks (true)
|
||||
{
|
||||
}
|
||||
|
|
@ -94,6 +98,16 @@ Ruler::set_font_description (Pango::FontDescription fd)
|
|||
end_visual_change ();
|
||||
}
|
||||
|
||||
void
|
||||
Ruler::set_second_font_description (Pango::FontDescription fd)
|
||||
{
|
||||
begin_visual_change ();
|
||||
delete _second_font_description;
|
||||
_second_font_description = new Pango::FontDescription (fd);
|
||||
end_visual_change ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
||||
{
|
||||
|
|
@ -144,12 +158,12 @@ Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
|||
/* draw ticks + text */
|
||||
|
||||
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (cr);
|
||||
if (_font_description) {
|
||||
layout->set_font_description (*_font_description);
|
||||
}
|
||||
|
||||
Pango::FontDescription* last_font_description = 0;
|
||||
|
||||
for (vector<Mark>::const_iterator m = marks.begin(); m != marks.end(); ++m) {
|
||||
Duple pos;
|
||||
Pango::FontDescription* fd = _font_description;
|
||||
|
||||
pos.x = floor ((m->position - _lower) / _metric->units_per_pixel);
|
||||
pos.y = self.y1; /* bottom edge */
|
||||
|
|
@ -168,6 +182,9 @@ Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
|||
} else {
|
||||
cr->rel_line_to (0, -height);
|
||||
}
|
||||
if (_second_font_description) {
|
||||
fd = _second_font_description;
|
||||
}
|
||||
break;
|
||||
case Mark::Minor:
|
||||
cr->rel_line_to (0, -height/3.0);
|
||||
|
|
@ -178,6 +195,11 @@ Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
|||
}
|
||||
cr->stroke ();
|
||||
|
||||
if (fd != last_font_description) {
|
||||
layout->set_font_description (*fd);
|
||||
last_font_description = fd;
|
||||
}
|
||||
|
||||
/* and the text */
|
||||
|
||||
if (!m->label.empty()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue