mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
add API to Ruler to optionally draw a divider (2 single pixel horizontal lines) at some position within the vertical extent of the ruler
This commit is contained in:
parent
38728f0835
commit
4cf402bdcf
2 changed files with 33 additions and 1 deletions
|
|
@ -65,7 +65,9 @@ public:
|
|||
void set_metric (const Metric&);
|
||||
|
||||
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
|
||||
|
||||
|
||||
void set_divide_colors (Color top, Color bottom);
|
||||
void set_divide_height (double);
|
||||
private:
|
||||
const Metric* _metric;
|
||||
|
||||
|
|
@ -74,6 +76,9 @@ private:
|
|||
|
||||
Coord _lower;
|
||||
Coord _upper;
|
||||
double _divide_height;
|
||||
Color _divider_color_top;
|
||||
Color _divider_color_bottom;
|
||||
|
||||
Pango::FontDescription* _font_description;
|
||||
mutable std::vector<Mark> marks;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ Ruler::Ruler (Canvas* c, const Metric& m)
|
|||
, _metric (&m)
|
||||
, _lower (0)
|
||||
, _upper (0)
|
||||
, _divide_height (-1.0)
|
||||
, _need_marks (true)
|
||||
{
|
||||
}
|
||||
|
|
@ -45,6 +46,7 @@ Ruler::Ruler (Canvas* c, const Metric& m, Rect const& r)
|
|||
, _metric (&m)
|
||||
, _lower (0)
|
||||
, _upper (0)
|
||||
, _divide_height (-1.0)
|
||||
, _need_marks (true)
|
||||
{
|
||||
}
|
||||
|
|
@ -54,6 +56,7 @@ Ruler::Ruler (Item* parent, const Metric& m)
|
|||
, _metric (&m)
|
||||
, _lower (0)
|
||||
, _upper (0)
|
||||
, _divide_height (-1.0)
|
||||
, _need_marks (true)
|
||||
{
|
||||
}
|
||||
|
|
@ -63,6 +66,7 @@ Ruler::Ruler (Item* parent, const Metric& m, Rect const& r)
|
|||
, _metric (&m)
|
||||
, _lower (0)
|
||||
, _upper (0)
|
||||
, _divide_height (-1.0)
|
||||
, _need_marks (true)
|
||||
{
|
||||
}
|
||||
|
|
@ -178,9 +182,32 @@ Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
|||
}
|
||||
}
|
||||
|
||||
if (_divide_height >= 0.0) {
|
||||
|
||||
cr->set_line_width (1.0);
|
||||
|
||||
set_source_rgba (cr, _divider_color_top);
|
||||
cr->move_to (self.x0, self.y0 + _divide_height+0.5);
|
||||
cr->line_to (self.x1, self.y0 + _divide_height+0.5);
|
||||
cr->stroke ();
|
||||
|
||||
set_source_rgba (cr, _divider_color_bottom);
|
||||
cr->move_to (self.x0, self.y0 + _divide_height+1.5);
|
||||
cr->line_to (self.x1, self.y0 + _divide_height+1.5);
|
||||
cr->stroke ();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* done! */
|
||||
}
|
||||
|
||||
void
|
||||
Ruler::set_divide_height (double h)
|
||||
{
|
||||
_divide_height = h;
|
||||
}
|
||||
|
||||
void
|
||||
Ruler::set_metric (const Metric& m)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue