X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fcanvas%2Fcanvas%2Ftypes.h;fp=libs%2Fcanvas%2Fcanvas%2Ftypes.h;h=20b0799ea60249bcbd4b7b6382ed4c398349246a;hb=aaea166135ace01709f7e0be64f40be80f4107ec;hp=0000000000000000000000000000000000000000;hpb=1d8bac08c0c00d44e22c581768a275e1b21a99a7;p=ardour.git diff --git a/libs/canvas/canvas/types.h b/libs/canvas/canvas/types.h new file mode 100644 index 0000000000..20b0799ea6 --- /dev/null +++ b/libs/canvas/canvas/types.h @@ -0,0 +1,88 @@ +#ifndef __CANVAS_TYPES_H__ +#define __CANVAS_TYPES_H__ + +#include +#include +#include +#include + +namespace ArdourCanvas +{ + +typedef double Coord; +typedef double Distance; +typedef uint32_t Color; +extern Coord const COORD_MAX; +extern Coord const CAIRO_MAX; + +extern Coord safe_add (Coord, Coord); + +struct Duple +{ + Duple () + : x (0) + , y (0) + {} + + Duple (Coord x_, Coord y_) + : x (x_) + , y (y_) + {} + + Coord x; + Coord y; + + Duple translate (Duple) const; +}; + + +extern Duple operator- (Duple const &); +extern Duple operator+ (Duple const &, Duple const &); +extern Duple operator- (Duple const &, Duple const &); +extern Duple operator/ (Duple const &, double); +extern std::ostream & operator<< (std::ostream &, Duple const &); + +struct Rect +{ + Rect () + : x0 (0) + , y0 (0) + , x1 (0) + , y1 (0) + {} + + Rect (Coord x0_, Coord y0_, Coord x1_, Coord y1_) + : x0 (x0_) + , y0 (y0_) + , x1 (x1_) + , y1 (y1_) + {} + + Coord x0; + Coord y0; + Coord x1; + Coord y1; + + boost::optional intersection (Rect const &) const; + Rect extend (Rect const &) const; + Rect translate (Duple) const; + Rect expand (Distance) const; + bool contains (Duple) const; + Rect fix () const; + + Distance width () const { + return x1 - x0; + } + + Distance height () const { + return y1 - y0; + } +}; + +extern std::ostream & operator<< (std::ostream &, Rect const &); + +typedef std::vector Points; + +} + +#endif