diff --git a/libs/canvas/canvas/ruler.h b/libs/canvas/canvas/ruler.h index f3631a2f03..72e38b56f9 100644 --- a/libs/canvas/canvas/ruler.h +++ b/libs/canvas/canvas/ruler.h @@ -24,14 +24,12 @@ #include -#include "canvas/item.h" -#include "canvas/fill.h" -#include "canvas/outline.h" +#include "canvas/rectangle.h" namespace ArdourCanvas { -class LIBCANVAS_API Ruler : virtual public Item, public Fill, public Outline +class LIBCANVAS_API Ruler : public Rectangle { public: struct Mark { @@ -58,17 +56,15 @@ public: }; Ruler (Group *, const Metric& m); + Ruler (Group *, const Metric& m, Rect const&); void set_range (double lower, double upper); - void set_size (Rect const&); void set_font_description (Pango::FontDescription); void render (Rect const & area, Cairo::RefPtr) const; - void compute_bounding_box () const; private: const Metric& _metric; - Rect _rect; /* lower and upper and sample positions, which are also canvas coordinates */ diff --git a/libs/canvas/ruler.cc b/libs/canvas/ruler.cc index 921b5b2992..aa48b52e92 100644 --- a/libs/canvas/ruler.cc +++ b/libs/canvas/ruler.cc @@ -33,8 +33,17 @@ using namespace ArdourCanvas; Ruler::Ruler (Group *p, const Metric& m) : Item (p) - , Fill (p) - , Outline (p) + , Rectangle (p) + , _metric (m) + , _lower (0) + , _upper (0) + , _need_marks (true) +{ +} + +Ruler::Ruler (Group *p, const Metric& m, Rect const& r) + : Item (p) + , Rectangle (p, r) , _metric (m) , _lower (0) , _upper (0) @@ -60,27 +69,6 @@ Ruler::set_font_description (Pango::FontDescription fd) end_visual_change (); } -void -Ruler::set_size (Rect const & area) -{ - if (_rect != area) { - begin_visual_change (); - _rect = area; - _bounding_box_dirty = true; - end_visual_change (); - } -} - -void -Ruler::compute_bounding_box () const -{ - if (!_rect.empty()) { - _bounding_box = _rect; - } - - _bounding_box_dirty = false; -} - void Ruler::render (Rect const & area, Cairo::RefPtr cr) const { @@ -89,7 +77,7 @@ Ruler::render (Rect const & area, Cairo::RefPtr cr) const return; } - Rect self (item_to_window (_rect)); + Rect self (item_to_window (get())); boost::optional i = self.intersection (area); if (!i) { @@ -117,9 +105,15 @@ Ruler::render (Rect const & area, Cairo::RefPtr cr) const setup_outline_context (cr); /* draw line on lower edge as a separator */ - - cr->move_to (self.x0, self.y1-0.5); - cr->line_to (self.x1, self.y1-0.5); + + if (_outline_width == 1.0) { + /* Cairo single pixel line correction */ + cr->move_to (self.x0, self.y1-0.5); + cr->line_to (self.x1, self.y1-0.5); + } else { + cr->move_to (self.x0, self.y1); + cr->line_to (self.x1, self.y1); + } cr->stroke (); /* draw ticks + text */ @@ -136,6 +130,7 @@ Ruler::render (Rect const & area, Cairo::RefPtr cr) const pos.y = self.y1; /* bottom edge */ if (_outline_width == 1.0) { + /* Cairo single pixel line correction */ cr->move_to (pos.x + 0.5, pos.y); } else { cr->move_to (pos.x, pos.y);