Ardour  9.0-pre0-350-gf17a656217
canvas/canvas/ruler.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef __CANVAS_RULER_H__
21 #define __CANVAS_RULER_H__
22 
23 #include <string>
24 #include <vector>
25 
26 #include <pangomm/fontdescription.h>
27 
28 #include "canvas/rectangle.h"
29 
30 namespace ArdourCanvas
31 {
32 
34 {
35 public:
36  struct Mark {
37  enum Style {
40  Micro
41  };
42  std::string label;
43  double position;
45  };
46 
47  struct Metric {
48  Metric () : units_per_pixel (0) {}
49  virtual ~Metric() {}
50 
52 
53  /* lower and upper and sample positions, which are also canvas coordinates
54  */
55 
56  virtual void get_marks (std::vector<Mark>&, int64_t lower, int64_t upper, int maxchars) const = 0;
57  };
58 
59  Ruler (Canvas*, const Metric* m);
60  Ruler (Canvas*, const Metric* m, Rect const&);
61  Ruler (Item*, const Metric* m);
62  Ruler (Item*, const Metric* m, Rect const&);
63 
64  virtual ~Ruler () {
65  delete _font_description;
66  }
67 
68  void set_range (int64_t lower, int64_t upper);
69  void set_font_description (Pango::FontDescription);
70  void set_second_font_description (Pango::FontDescription);
71  void set_metric (const Metric *);
72 
73  void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
74 
76  void set_divide_height (double);
77 private:
78  const Metric* _metric;
79 
80  /* lower and upper and bounds for ruler */
81 
82  int64_t _lower;
83  int64_t _upper;
87 
88  Pango::FontDescription* _font_description;
89  Pango::FontDescription* _second_font_description;
90  mutable std::vector<Mark> marks;
91  mutable bool _need_marks;
92 };
93 
94 }
95 
96 
97 #endif
#define LIBCANVAS_API
void set_divide_height(double)
Ruler(Item *, const Metric *m, Rect const &)
Ruler(Item *, const Metric *m)
Pango::FontDescription * _second_font_description
void set_range(int64_t lower, int64_t upper)
void set_metric(const Metric *)
void render(Rect const &area, Cairo::RefPtr< Cairo::Context >) const
Ruler(Canvas *, const Metric *m, Rect const &)
void set_second_font_description(Pango::FontDescription)
std::vector< Mark > marks
Gtkmm2ext::Color _divider_color_top
void set_font_description(Pango::FontDescription)
Pango::FontDescription * _font_description
void set_divide_colors(Gtkmm2ext::Color top, Gtkmm2ext::Color bottom)
Gtkmm2ext::Color _divider_color_bottom
Ruler(Canvas *, const Metric *m)
uint32_t Color
Definition: colors.h:33
virtual void get_marks(std::vector< Mark > &, int64_t lower, int64_t upper, int maxchars) const =0