diff options
author | Robin Gareus <robin@gareus.org> | 2017-07-17 18:34:35 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-07-17 21:06:04 +0200 |
commit | 601c317d70a03190257577bd867cefc2c70d3275 (patch) | |
tree | 077071290f084431a912414c4e87b6127c586677 /libs/canvas/canvas | |
parent | 1f5ebc54853446a786925941bd014666e75221d2 (diff) |
Clean up library inheritance (colors.h, utils.h)
make libwidget independent of libcanvas.
Confine basics to pbd and gtkmm2ext.
Diffstat (limited to 'libs/canvas/canvas')
-rw-r--r-- | libs/canvas/canvas/arrow.h | 4 | ||||
-rw-r--r-- | libs/canvas/canvas/box.h | 2 | ||||
-rw-r--r-- | libs/canvas/canvas/canvas.h | 8 | ||||
-rw-r--r-- | libs/canvas/canvas/colors.h | 130 | ||||
-rw-r--r-- | libs/canvas/canvas/colorspace.h | 54 | ||||
-rw-r--r-- | libs/canvas/canvas/fill.h | 22 | ||||
-rw-r--r-- | libs/canvas/canvas/flag.h | 10 | ||||
-rw-r--r-- | libs/canvas/canvas/grid.h | 2 | ||||
-rw-r--r-- | libs/canvas/canvas/line_set.h | 8 | ||||
-rw-r--r-- | libs/canvas/canvas/outline.h | 12 | ||||
-rw-r--r-- | libs/canvas/canvas/ruler.h | 15 | ||||
-rw-r--r-- | libs/canvas/canvas/text.h | 36 | ||||
-rw-r--r-- | libs/canvas/canvas/types.h | 3 | ||||
-rw-r--r-- | libs/canvas/canvas/utils.h | 6 | ||||
-rw-r--r-- | libs/canvas/canvas/wave_view.h | 8 | ||||
-rw-r--r-- | libs/canvas/canvas/wave_view_private.h | 8 | ||||
-rw-r--r-- | libs/canvas/canvas/xfade_curve.h | 10 |
17 files changed, 74 insertions, 264 deletions
diff --git a/libs/canvas/canvas/arrow.h b/libs/canvas/canvas/arrow.h index ba74fa90e7..e04d450c18 100644 --- a/libs/canvas/canvas/arrow.h +++ b/libs/canvas/canvas/arrow.h @@ -58,7 +58,7 @@ public: void set_head_height (int, Distance); void set_head_width (int, Distance); void set_outline_width (Distance); - void set_color (Color); + void set_color (Gtkmm2ext::Color); Coord x () const; Coord y1 () const; @@ -67,7 +67,7 @@ public: void set_y0 (Coord); void set_y1 (Coord); - bool covers (Duple const &) const; + bool covers (Duple const &) const; private: void setup_polygon (int); diff --git a/libs/canvas/canvas/box.h b/libs/canvas/canvas/box.h index b3b2b85303..cefbc716df 100644 --- a/libs/canvas/canvas/box.h +++ b/libs/canvas/canvas/box.h @@ -56,7 +56,7 @@ public: /* aliases so that CSS box model terms work */ void set_border_width (double w) { set_outline_width (w); } - void set_border_color (Color c) { set_outline_color (c); } + void set_border_color (Gtkmm2ext::Color c) { set_outline_color (c); } void add (Item*); void pack_start (Item*, double extra_padding = 0); diff --git a/libs/canvas/canvas/canvas.h b/libs/canvas/canvas/canvas.h index 3bcf58256d..6d8fd89a7a 100644 --- a/libs/canvas/canvas/canvas.h +++ b/libs/canvas/canvas/canvas.h @@ -98,8 +98,8 @@ public: return &_root; } - void set_background_color (ArdourCanvas::Color); - ArdourCanvas::Color background_color() const { return _bg_color; } + void set_background_color (Gtkmm2ext::Color); + Gtkmm2ext::Color background_color() const { return _bg_color; } /** Called when an item is being destroyed */ virtual void item_going_away (Item *, Rect) {} @@ -170,8 +170,8 @@ public: virtual Glib::RefPtr<Pango::Context> get_pango_context() = 0; protected: - Root _root; - Color _bg_color; + Root _root; + Gtkmm2ext::Color _bg_color; mutable gint64 _last_render_start_timestamp; diff --git a/libs/canvas/canvas/colors.h b/libs/canvas/canvas/colors.h deleted file mode 100644 index f48e2347a3..0000000000 --- a/libs/canvas/canvas/colors.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - Copyright (C) 2011-2013 Paul Davis - Author: Carl Hetherington <cth@carlh.net> - - 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 __ardour_canvas_colors_h__ -#define __ardour_canvas_colors_h__ - -#include <cairomm/context.h> - -#include "canvas/visibility.h" -#include "canvas/types.h" - -namespace ArdourCanvas -{ - -struct LIBCANVAS_API HSV; -struct LIBCANVAS_API HSVA; - -extern LIBCANVAS_API Color change_alpha (Color, double alpha); - -extern LIBCANVAS_API Color hsva_to_color (double h, double s, double v, double a = 1.0); -extern LIBCANVAS_API void color_to_hsva (Color color, double& h, double& s, double& v, double& a); -extern LIBCANVAS_API Color color_at_alpha (Color, double a); -extern LIBCANVAS_API void color_to_hsv (Color color, double& h, double& s, double& v); -extern LIBCANVAS_API void color_to_rgba (Color, double& r, double& g, double& b, double& a); -extern LIBCANVAS_API Color rgba_to_color (double r, double g, double b, double a); - -uint32_t LIBCANVAS_API contrasting_text_color (uint32_t c); - -struct LIBCANVAS_API HSV; - -class LIBCANVAS_API SVAModifier -{ - public: - enum Type { - Add, - Multiply, - Assign - }; - - SVAModifier (std::string const &); - SVAModifier (Type t, double ss, double vv, double aa) : type (t), _s (ss) , _v (vv) , _a (aa) {} - SVAModifier () : type (Add), _s (0), _v (0), _a (0) {} /* no-op modifier */ - - double s() const { return _s; } - double v() const { return _v; } - double a() const { return _a; } - - HSV operator () (HSV& hsv) const; - std::string to_string () const; - void from_string (std::string const &); - - private: - Type type; - double _s; - double _v; - double _a; -}; - -struct LIBCANVAS_API HSV -{ - HSV (); - HSV (double h, double s, double v, double a = 1.0); - HSV (Color); - - double h; - double s; - double v; - double a; - - std::string to_string() const; - bool is_gray() const; - - Color color() const { return hsva_to_color (h,s, v, a); } - operator Color() const { return color(); } - - HSV mod (SVAModifier const & svam); - - HSV operator+ (const HSV&) const; - HSV operator- (const HSV&) const; - - HSV& operator=(Color); - HSV& operator=(const std::string&); - - bool operator== (const HSV& other); - - double distance (const HSV& other) const; - HSV delta (const HSV& other) const; - - HSV darker (double factor = 1.3) const { return shade (factor); } - HSV lighter (double factor = 0.7) const { return shade (factor); } - - HSV shade (double factor) const; - HSV mix (const HSV& other, double amt) const; - - HSV opposite() const; - HSV complement() const { return opposite(); } - - HSV bw_text () const; - HSV text() const; - HSV selected () const; - HSV outline() const; - - void print (std::ostream&) const; - - protected: - void clamp (); -}; - - -} - -std::ostream& operator<<(std::ostream& o, const ArdourCanvas::HSV& hsv); - -#endif /* __ardour_canvas_colors_h__ */ diff --git a/libs/canvas/canvas/colorspace.h b/libs/canvas/canvas/colorspace.h deleted file mode 100644 index 77d0961934..0000000000 --- a/libs/canvas/canvas/colorspace.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @file colorspace.h - * @author Pascal Getreuer 2005-2010 <getreuer@gmail.com> - */ - -#ifndef _ARDOURCANVAS_COLORSPACE_H_ -#define _ARDOURCANVAS_COLORSPACE_H_ - -/** @brief XYZ color of the D65 white point */ -#define WHITEPOINT_X 0.950456 -#define WHITEPOINT_Y 1.0 -#define WHITEPOINT_Z 1.088754 - -void Rgb2Yuv(double *Y, double *U, double *V, double R, double G, double B); -void Yuv2Rgb(double *R, double *G, double *B, double Y, double U, double V); -void Rgb2Ycbcr(double *Y, double *Cb, double *Cr, double R, double G, double B); -void Ycbcr2Rgb(double *R, double *G, double *B, double Y, double Cb, double Cr); -void Rgb2Jpegycbcr(double *R, double *G, double *B, double Y, double Cb, double Cr); -void Jpegycbcr2Rgb(double *R, double *G, double *B, double Y, double Cb, double Cr); -void Rgb2Ypbpr(double *Y, double *Pb, double *Pr, double R, double G, double B); -void Ypbpr2Rgb(double *R, double *G, double *B, double Y, double Pb, double Pr); -void Rgb2Ydbdr(double *Y, double *Db, double *Dr, double R, double G, double B); -void Ydbdr2Rgb(double *R, double *G, double *B, double Y, double Db, double Dr); -void Rgb2Yiq(double *Y, double *I, double *Q, double R, double G, double B); -void Yiq2Rgb(double *R, double *G, double *B, double Y, double I, double Q); - -void Rgb2Hsv(double *H, double *S, double *V, double R, double G, double B); -void Hsv2Rgb(double *R, double *G, double *B, double H, double S, double V); -void Rgb2Hsl(double *H, double *S, double *L, double R, double G, double B); -void Hsl2Rgb(double *R, double *G, double *B, double H, double S, double L); -void Rgb2Hsi(double *H, double *S, double *I, double R, double G, double B); -void Hsi2Rgb(double *R, double *G, double *B, double H, double S, double I); - -void Rgb2Xyz(double *X, double *Y, double *Z, double R, double G, double B); -void Xyz2Rgb(double *R, double *G, double *B, double X, double Y, double Z); -void Xyz2Lab(double *L, double *a, double *b, double X, double Y, double Z); -void Lab2Xyz(double *X, double *Y, double *Z, double L, double a, double b); -void Xyz2Luv(double *L, double *u, double *v, double X, double Y, double Z); -void Luv2Xyz(double *X, double *Y, double *Z, double L, double u, double v); -void Xyz2Lch(double *L, double *C, double *H, double X, double Y, double Z); -void Lch2Xyz(double *X, double *Y, double *Z, double L, double C, double H); -void Xyz2Cat02lms(double *L, double *M, double *S, double X, double Y, double Z); -void Cat02lms2Xyz(double *X, double *Y, double *Z, double L, double M, double S); - -void Rgb2Lab(double *L, double *a, double *b, double R, double G, double B); -void Lab2Rgb(double *R, double *G, double *B, double L, double a, double b); -void Rgb2Luv(double *L, double *u, double *v, double R, double G, double B); -void Luv2Rgb(double *R, double *G, double *B, double L, double u, double v); -void Rgb2Lch(double *L, double *C, double *H, double R, double G, double B); -void Lch2Rgb(double *R, double *G, double *B, double L, double C, double H); -void Rgb2Cat02lms(double *L, double *M, double *S, double R, double G, double B); -void Cat02lms2Rgb(double *R, double *G, double *B, double L, double M, double S); - -#endif /* _ARDOURCANVAS_COLORSPACE_H_ */ diff --git a/libs/canvas/canvas/fill.h b/libs/canvas/canvas/fill.h index 42160a6190..95a29fd760 100644 --- a/libs/canvas/canvas/fill.h +++ b/libs/canvas/canvas/fill.h @@ -38,10 +38,10 @@ public: Fill (Item& self); virtual ~Fill() {} - virtual void set_fill_color (Color); + virtual void set_fill_color (Gtkmm2ext::Color); virtual void set_fill (bool); - Color fill_color () const { + Gtkmm2ext::Color fill_color () const { return _fill_color; } @@ -49,23 +49,23 @@ public: return _fill; } - typedef std::vector<std::pair<double,Color> > StopList; + typedef std::vector<std::pair<double,Gtkmm2ext::Color> > StopList; - void set_gradient (StopList const & stops, bool is_vertical); + void set_gradient (StopList const & stops, bool is_vertical); - void set_pattern (Cairo::RefPtr<Cairo::Pattern>); + void set_pattern (Cairo::RefPtr<Cairo::Pattern>); protected: void setup_fill_context (Cairo::RefPtr<Cairo::Context>) const; - void setup_gradient_context (Cairo::RefPtr<Cairo::Context>, Rect const &, Duple const &) const; + void setup_gradient_context (Cairo::RefPtr<Cairo::Context>, Rect const &, Duple const &) const; - Item& _self; - Color _fill_color; + Item& _self; + Gtkmm2ext::Color _fill_color; bool _fill; bool _transparent; - StopList _stops; - bool _vertical_gradient; - Cairo::RefPtr<Cairo::Pattern> _pattern; + StopList _stops; + bool _vertical_gradient; + Cairo::RefPtr<Cairo::Pattern> _pattern; }; diff --git a/libs/canvas/canvas/flag.h b/libs/canvas/canvas/flag.h index 580adb2837..ac77cc759f 100644 --- a/libs/canvas/canvas/flag.h +++ b/libs/canvas/canvas/flag.h @@ -35,23 +35,23 @@ class Rectangle; class LIBCANVAS_API Flag : public Container { public: - Flag (Canvas *, Distance, Color, Color, Duple, bool invert=false); - Flag (Item*, Distance, Color, Color, Duple, bool invert=false); + Flag (Canvas *, Distance, Gtkmm2ext::Color, Gtkmm2ext::Color, Duple, bool invert=false); + Flag (Item*, Distance, Gtkmm2ext::Color, Gtkmm2ext::Color, Duple, bool invert=false); void set_text (std::string const &); void set_height (Distance); void set_font_description (Pango::FontDescription); - bool covers (Duple const &) const; + bool covers (Duple const &) const; double width() const; private: void setup (Distance height, Duple position); - Color _outline_color; - Color _fill_color; + Gtkmm2ext::Color _outline_color; + Gtkmm2ext::Color _fill_color; Text* _text; Line* _line; Rectangle* _rectangle; diff --git a/libs/canvas/canvas/grid.h b/libs/canvas/canvas/grid.h index 8e6dd3b7de..aa14f2b17a 100644 --- a/libs/canvas/canvas/grid.h +++ b/libs/canvas/canvas/grid.h @@ -45,7 +45,7 @@ public: /* aliases so that CSS box model terms work */ void set_border_width (double w) { set_outline_width (w); } - void set_border_color (Color c) { set_outline_color (c); } + void set_border_color (Gtkmm2ext::Color c) { set_outline_color (c); } void place (Item*, double x, double y, double col_span = 1, double row_span = 1); diff --git a/libs/canvas/canvas/line_set.h b/libs/canvas/canvas/line_set.h index c305cceab5..ccce24aa89 100644 --- a/libs/canvas/canvas/line_set.h +++ b/libs/canvas/canvas/line_set.h @@ -41,20 +41,20 @@ public: void compute_bounding_box () const; void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; - bool covers (Duple const &) const; + bool covers (Duple const &) const; void set_extent (Distance); Distance extent() const { return _extent; } - void add (Coord, Distance, Color); + void add (Coord, Distance, Gtkmm2ext::Color); void clear (); struct Line { - Line (Coord p, Distance width_, Color color_) : pos (p), width (width_), color (color_) {} + Line (Coord p, Distance width_, Gtkmm2ext::Color color_) : pos (p), width (width_), color (color_) {} Coord pos; Distance width; - Color color; + Gtkmm2ext::Color color; }; private: diff --git a/libs/canvas/canvas/outline.h b/libs/canvas/canvas/outline.h index 38f8eb2e32..b33c993077 100644 --- a/libs/canvas/canvas/outline.h +++ b/libs/canvas/canvas/outline.h @@ -37,11 +37,11 @@ public: Outline (Item& self); virtual ~Outline() {} - Color outline_color () const { + Gtkmm2ext::Color outline_color () const { return _outline_color; } - virtual void set_outline_color (Color); + virtual void set_outline_color (Gtkmm2ext::Color); Distance outline_width () const { return _outline_width; @@ -59,10 +59,10 @@ protected: void setup_outline_context (Cairo::RefPtr<Cairo::Context>) const; - Item& _self; - Color _outline_color; - Distance _outline_width; - bool _outline; + Item& _self; + Gtkmm2ext::Color _outline_color; + Distance _outline_width; + bool _outline; }; } diff --git a/libs/canvas/canvas/ruler.h b/libs/canvas/canvas/ruler.h index 751ddcc104..59ce625dca 100644 --- a/libs/canvas/canvas/ruler.h +++ b/libs/canvas/canvas/ruler.h @@ -70,19 +70,18 @@ public: void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; - void set_divide_colors (Color top, Color bottom); + void set_divide_colors (Gtkmm2ext::Color top, Gtkmm2ext::Color bottom); void set_divide_height (double); private: const Metric* _metric; - /* lower and upper and sample positions, which are also canvas coordinates - */ + /* lower and upper and sample positions, which are also canvas coordinates */ - Coord _lower; - Coord _upper; - double _divide_height; - Color _divider_color_top; - Color _divider_color_bottom; + Coord _lower; + Coord _upper; + double _divide_height; + Gtkmm2ext::Color _divider_color_top; + Gtkmm2ext::Color _divider_color_bottom; Pango::FontDescription* _font_description; mutable std::vector<Mark> marks; diff --git a/libs/canvas/canvas/text.h b/libs/canvas/canvas/text.h index bd6c049606..c05bc69050 100644 --- a/libs/canvas/canvas/text.h +++ b/libs/canvas/canvas/text.h @@ -33,43 +33,43 @@ class LIBCANVAS_API Text : public Item public: Text (Canvas*); Text (Item*); - ~Text(); + ~Text(); void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const; void compute_bounding_box () const; - ArdourCanvas::Color color () const { return _color; } - void set_color (ArdourCanvas::Color); + Gtkmm2ext::Color color () const { return _color; } + void set_color (Gtkmm2ext::Color); void set (std::string const &); void set_font_description (Pango::FontDescription); void set_alignment (Pango::Alignment); - void clamp_width (double); + void clamp_width (double); - double width() const; - double height() const; + double width() const; + double height() const; - void set_size_chars (int nchars); - void dump (std::ostream&) const; + void set_size_chars (int nchars); + void dump (std::ostream&) const; std::string text() const { return _text; } double text_width() const; private: std::string _text; - ArdourCanvas::Color _color; + Gtkmm2ext::Color _color; Pango::FontDescription* _font_description; Pango::Alignment _alignment; - mutable Cairo::RefPtr<Cairo::ImageSurface> _image; - mutable Duple _origin; - mutable double _width; - mutable double _height; - mutable bool _need_redraw; - mutable double _width_correction; - double _clamped_width; - - void _redraw () const; + mutable Cairo::RefPtr<Cairo::ImageSurface> _image; + mutable Duple _origin; + mutable double _width; + mutable double _height; + mutable bool _need_redraw; + mutable double _width_correction; + double _clamped_width; + + void _redraw () const; }; } diff --git a/libs/canvas/canvas/types.h b/libs/canvas/canvas/types.h index a3f1b81ea1..9a4f2f7b3b 100644 --- a/libs/canvas/canvas/types.h +++ b/libs/canvas/canvas/types.h @@ -28,6 +28,8 @@ #include <cairomm/refptr.h> +#include "gtkmm2ext/colors.h" + #include "canvas/visibility.h" namespace Cairo { @@ -39,7 +41,6 @@ namespace ArdourCanvas typedef double Coord; typedef double Distance; -typedef uint32_t Color; extern LIBCANVAS_API Coord const COORD_MAX; diff --git a/libs/canvas/canvas/utils.h b/libs/canvas/canvas/utils.h index 42551a6c9a..8137b2abf7 100644 --- a/libs/canvas/canvas/utils.h +++ b/libs/canvas/canvas/utils.h @@ -27,12 +27,6 @@ namespace ArdourCanvas { - extern LIBCANVAS_API void set_source_rgba (Cairo::RefPtr<Cairo::Context>, Color); - extern LIBCANVAS_API void set_source_rgb_a (Cairo::RefPtr<Cairo::Context>, Color, float alpha); //override the color's alpha - - extern LIBCANVAS_API void set_source_rgba (cairo_t*, Color); - extern LIBCANVAS_API void set_source_rgb_a (cairo_t*, Color, float alpha); //override the color's alpha - Distance LIBCANVAS_API distance_to_segment_squared (Duple const & p, Duple const & p1, Duple const & p2, double& t, Duple& at); } diff --git a/libs/canvas/canvas/wave_view.h b/libs/canvas/canvas/wave_view.h index de6b38d13e..1767262151 100644 --- a/libs/canvas/canvas/wave_view.h +++ b/libs/canvas/canvas/wave_view.h @@ -100,8 +100,8 @@ public: */ void set_start_shift (double pixels); - void set_fill_color (Color); - void set_outline_color (Color); + void set_fill_color (Gtkmm2ext::Color); + void set_outline_color (Gtkmm2ext::Color); void region_resized (); void gain_changed (); @@ -109,8 +109,8 @@ public: void set_show_zero_line (bool); bool show_zero_line () const; - void set_zero_color (Color); - void set_clip_color (Color); + void set_zero_color (Gtkmm2ext::Color); + void set_clip_color (Gtkmm2ext::Color); void set_logscaled (bool); void set_gradient_depth (double); diff --git a/libs/canvas/canvas/wave_view_private.h b/libs/canvas/canvas/wave_view_private.h index dca09c90b5..d870300998 100644 --- a/libs/canvas/canvas/wave_view_private.h +++ b/libs/canvas/canvas/wave_view_private.h @@ -48,10 +48,10 @@ public: // member variables double samples_per_pixel; double amplitude; double amplitude_above_axis; - Color fill_color; - Color outline_color; - Color zero_color; - Color clip_color; + Gtkmm2ext::Color fill_color; + Gtkmm2ext::Color outline_color; + Gtkmm2ext::Color zero_color; + Gtkmm2ext::Color clip_color; bool show_zero; bool logscaled; WaveView::Shape shape; diff --git a/libs/canvas/canvas/xfade_curve.h b/libs/canvas/canvas/xfade_curve.h index b6e871936b..50ce96e769 100644 --- a/libs/canvas/canvas/xfade_curve.h +++ b/libs/canvas/canvas/xfade_curve.h @@ -48,13 +48,13 @@ public: void set_points_per_segment (uint32_t n); void set_inout (Points const & in, Points const & out); - void set_outline_color (Color c) { + void set_outline_color (Gtkmm2ext::Color c) { begin_visual_change (); _outline_color = c; end_visual_change (); }; - void set_fill_color (Color c) { + void set_fill_color (Gtkmm2ext::Color c) { begin_visual_change (); _fill_color = c; end_visual_change (); @@ -76,9 +76,9 @@ private: CanvasCurve _in; CanvasCurve _out; - XFadePosition _xfadeposition; - Color _outline_color; - Color _fill_color; + XFadePosition _xfadeposition; + Gtkmm2ext::Color _outline_color; + Gtkmm2ext::Color _fill_color; bool show_background_fade; |