2 Copyright (C) 2014 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef __CANVAS_RULER_H__
20 #define __CANVAS_RULER_H__
25 #include <pangomm/fontdescription.h>
27 #include "canvas/rectangle.h"
29 namespace ArdourCanvas
32 class LIBCANVAS_API Ruler : public Rectangle
47 Metric () : units_per_pixel (0) {}
50 double units_per_pixel;
52 /* lower and upper and sample positions, which are also canvas coordinates
55 virtual void get_marks (std::vector<Mark>&, double lower, double upper, int maxchars) const = 0;
58 Ruler (Canvas*, const Metric& m);
59 Ruler (Canvas*, const Metric& m, Rect const&);
60 Ruler (Item*, const Metric& m);
61 Ruler (Item*, const Metric& m, Rect const&);
63 void set_range (double lower, double upper);
64 void set_font_description (Pango::FontDescription);
66 void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
69 const Metric& _metric;
71 /* lower and upper and sample positions, which are also canvas coordinates
77 Pango::FontDescription* _font_description;
78 mutable std::vector<Mark> marks;
79 mutable bool _need_marks;