NOOP, remove trailing tabs/whitespace.
[ardour.git] / libs / canvas / canvas / ruler.h
1 /*
2     Copyright (C) 2014 Paul Davis
3
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.
8
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.
13
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.
17 */
18
19 #ifndef __CANVAS_RULER_H__
20 #define __CANVAS_RULER_H__
21
22 #include <string>
23 #include <vector>
24
25 #include <pangomm/fontdescription.h>
26
27 #include "canvas/rectangle.h"
28
29 namespace ArdourCanvas
30 {
31
32 class LIBCANVAS_API Ruler : public Rectangle
33 {
34 public:
35         struct Mark {
36                 enum Style {
37                         Major,
38                         Minor,
39                         Micro
40                 };
41                 std::string label;
42                 double position;
43                 Style  style;
44         };
45
46         struct Metric {
47                 Metric () : units_per_pixel (0) {}
48                 virtual ~Metric() {}
49
50                 double units_per_pixel;
51
52                 /* lower and upper and sample positions, which are also canvas coordinates
53                  */
54
55                 virtual void get_marks (std::vector<Mark>&, double lower, double upper, int maxchars) const = 0;
56         };
57
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&);
62
63         void set_range (double lower, double upper);
64         void set_font_description (Pango::FontDescription);
65         void set_metric (const Metric&);
66
67         void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
68
69         void set_divide_colors (Color top, Color bottom);
70         void set_divide_height (double);
71 private:
72         const Metric* _metric;
73
74         /* lower and upper and sample positions, which are also canvas coordinates
75          */
76
77         Coord         _lower;
78         Coord         _upper;
79         double        _divide_height;
80         Color         _divider_color_top;
81         Color         _divider_color_bottom;
82
83         Pango::FontDescription* _font_description;
84         mutable std::vector<Mark> marks;
85         mutable bool _need_marks;
86 };
87
88 }
89
90
91 #endif