diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-06-11 12:24:43 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-06-11 23:54:28 -0400 |
commit | 5ee4f419259574197255d11afcc0bec25b6473d2 (patch) | |
tree | 0c2f5bb8597262032f0cbf438fe9e9d1ff04e1a7 /libs/canvas/canvas/ruler.h | |
parent | e1b82caeb9821e7724580574382a63f4ece77e3d (diff) |
add initial (untested) implementation of canvas ruler item
Diffstat (limited to 'libs/canvas/canvas/ruler.h')
-rw-r--r-- | libs/canvas/canvas/ruler.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/libs/canvas/canvas/ruler.h b/libs/canvas/canvas/ruler.h new file mode 100644 index 0000000000..ac72245c0f --- /dev/null +++ b/libs/canvas/canvas/ruler.h @@ -0,0 +1,80 @@ +/* + Copyright (C) 2014 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __CANVAS_RULER_H__ +#define __CANVAS_RULER_H__ + +#include <string> +#include <vector> + +#include "canvas/item.h" +#include "canvas/fill.h" +#include "canvas/outline.h" + +namespace ArdourCanvas +{ + +class LIBCANVAS_API Ruler : virtual public Item, public Fill, public Outline +{ +public: + struct Mark { + enum Style { + Major, + Minor, + Micro + }; + std::string label; + double position; + Style style; + }; + + struct Metric { + Metric () : units_per_pixel (0) {} + virtual ~Metric() {} + + double units_per_pixel; + + /* lower and upper and sample positions, which are also canvas coordinates + */ + + virtual int get_marks (std::vector<Mark>&, double lower, double upper, int maxchars) const = 0; + }; + + Ruler (Group *, const Metric& m); + + void set_range (double lower, double upper); + void set_size (Rect const&); + + 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 + */ + + Coord _lower; + Coord _upper; +}; + +} + + +#endif |