2 Copyright (C) 2011-2013 Paul Davis
3 Author: Carl Hetherington <cth@carlh.net>
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.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __CANVAS_TYPES_H__
21 #define __CANVAS_TYPES_H__
26 #include <boost/optional.hpp>
28 #include <cairomm/refptr.h>
30 #include "canvas/visibility.h"
36 namespace ArdourCanvas
40 typedef double Distance;
41 typedef uint32_t Color;
43 extern LIBCANVAS_API Coord const COORD_MAX;
45 struct LIBCANVAS_API Duple
52 Duple (Coord x_, Coord y_)
60 Duple translate (Duple) const;
64 extern LIBCANVAS_API Duple operator- (Duple const &);
65 extern LIBCANVAS_API Duple operator+ (Duple const &, Duple const &);
66 extern LIBCANVAS_API bool operator== (Duple const &, Duple const &);
67 extern LIBCANVAS_API Duple operator- (Duple const &, Duple const &);
68 extern LIBCANVAS_API Duple operator/ (Duple const &, double);
69 extern LIBCANVAS_API std::ostream & operator<< (std::ostream &, Duple const &);
71 struct LIBCANVAS_API Rect
80 Rect (Coord x0_, Coord y0_, Coord x1_, Coord y1_)
92 boost::optional<Rect> intersection (Rect const &) const;
93 Rect extend (Rect const &) const;
94 Rect translate (Duple) const;
95 Rect expand (Distance) const;
96 bool contains (Duple) const;
98 bool empty() const { return (x0 == x1 && y0 == y1); }
100 Distance width () const {
104 Distance height () const {
109 extern LIBCANVAS_API std::ostream & operator<< (std::ostream &, Rect const &);
111 typedef std::vector<Duple> Points;