#include <pangomm/fontdescription.h>
-#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 {
};
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<Cairo::Context>) const;
- void compute_bounding_box () const;
private:
const Metric& _metric;
- Rect _rect;
/* lower and upper and sample positions, which are also canvas coordinates
*/
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)
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<Cairo::Context> cr) const
{
return;
}
- Rect self (item_to_window (_rect));
+ Rect self (item_to_window (get()));
boost::optional<Rect> i = self.intersection (area);
if (!i) {
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 */
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);