diff options
48 files changed, 409 insertions, 178 deletions
diff --git a/libs/canvas/arc.cc b/libs/canvas/arc.cc index 229097b85a..80141d4c66 100644 --- a/libs/canvas/arc.cc +++ b/libs/canvas/arc.cc @@ -31,15 +31,20 @@ using namespace std; using namespace ArdourCanvas; -Arc::Arc (Group* parent) - : Item (parent) - , Outline (parent) - , Fill (parent) +Arc::Arc (Canvas* c) + : Item (c) , _radius (0.0) , _arc_degrees (0.0) , _start_degrees (0.0) { +} +Arc::Arc (Group* g) + : Item (g) + , _radius (0.0) + , _arc_degrees (0.0) + , _start_degrees (0.0) +{ } void diff --git a/libs/canvas/arrow.cc b/libs/canvas/arrow.cc index 2e9557e179..86d4e33ca9 100644 --- a/libs/canvas/arrow.cc +++ b/libs/canvas/arrow.cc @@ -34,11 +34,21 @@ using namespace ArdourCanvas; /** Construct an Arrow. * @param parent Parent canvas group. */ -Arrow::Arrow (Group* parent) - : Group (parent) +Arrow::Arrow (Canvas* c) + : Group (c) { - assert (parent); + setup (); +} + +Arrow::Arrow (Group* g) + : Group (g) +{ + setup (); +} +void +Arrow::setup () +{ /* set up default arrow heads at each end */ for (int i = 0; i < 2; ++i) { _heads[i].polygon = new Polygon (this); @@ -53,6 +63,7 @@ Arrow::Arrow (Group* parent) CANVAS_DEBUG_NAME (_line, "arrow line"); } + /** Set whether to show an arrow head at one end or other * of the line. * @param which 0 or 1 to specify the arrow head to set up. diff --git a/libs/canvas/canvas/arc.h b/libs/canvas/canvas/arc.h index 306a1acb7b..5eaa4a0ab9 100644 --- a/libs/canvas/canvas/arc.h +++ b/libs/canvas/canvas/arc.h @@ -26,10 +26,13 @@ namespace ArdourCanvas { -class LIBCANVAS_API Arc : virtual public Item, public Outline, public Fill +class Canvas; + +class LIBCANVAS_API Arc : public Item { public: - Arc (Group *); + Arc (Canvas*); + Arc (Group*); void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; void compute_bounding_box () const; diff --git a/libs/canvas/canvas/arrow.h b/libs/canvas/canvas/arrow.h index 9d9fe0d700..75c21da07c 100644 --- a/libs/canvas/canvas/arrow.h +++ b/libs/canvas/canvas/arrow.h @@ -31,6 +31,7 @@ namespace ArdourCanvas { +class Canvas; class Line; class Polygon; @@ -48,7 +49,8 @@ class Polygon; class LIBCANVAS_API Arrow : public Group { public: - Arrow (Group *); + Arrow (Canvas*); + Arrow (Group*); void set_show_head (int, bool); void set_head_outward (int, bool); @@ -68,6 +70,7 @@ public: private: void setup_polygon (int); + void setup (); /** Representation of a single arrow head */ struct Head { diff --git a/libs/canvas/canvas/circle.h b/libs/canvas/canvas/circle.h index ee17208a1f..1ca376a7a2 100644 --- a/libs/canvas/canvas/circle.h +++ b/libs/canvas/canvas/circle.h @@ -27,8 +27,9 @@ namespace ArdourCanvas { class LIBCANVAS_API Circle : public Arc { -public: - Circle (Group *); + public: + Circle (Canvas*); + Circle (Group*); }; } diff --git a/libs/canvas/canvas/curve.h b/libs/canvas/canvas/curve.h index 234956763b..1bcab58e32 100644 --- a/libs/canvas/canvas/curve.h +++ b/libs/canvas/canvas/curve.h @@ -29,10 +29,11 @@ namespace ArdourCanvas { class XFadeCurve; -class LIBCANVAS_API Curve : public PolyItem, public Fill, public InterpolatedCurve +class LIBCANVAS_API Curve : public PolyItem, public InterpolatedCurve { -public: - Curve (Group *); + public: + Curve (Canvas*); + Curve (Group*); enum CurveFill { None, diff --git a/libs/canvas/canvas/fill.h b/libs/canvas/canvas/fill.h index 56044de4bd..a4a36eb345 100644 --- a/libs/canvas/canvas/fill.h +++ b/libs/canvas/canvas/fill.h @@ -23,15 +23,20 @@ #include <vector> #include <stdint.h> +#include <boost/noncopyable.hpp> + #include "canvas/visibility.h" -#include "canvas/item.h" +#include "canvas/types.h" namespace ArdourCanvas { -class LIBCANVAS_API Fill : virtual public Item +class Item; + +class LIBCANVAS_API Fill : public boost::noncopyable { public: - Fill (Group *); + Fill (Item& self); + virtual ~Fill() {} virtual void set_fill_color (Color); virtual void set_fill (bool); @@ -51,7 +56,8 @@ public: protected: void setup_fill_context (Cairo::RefPtr<Cairo::Context>) const; void setup_gradient_context (Cairo::RefPtr<Cairo::Context>, Rect const &, Duple const &) const; - + + Item& _self; Color _fill_color; bool _fill; bool _transparent; diff --git a/libs/canvas/canvas/flag.h b/libs/canvas/canvas/flag.h index 2a15f83921..2429e1775e 100644 --- a/libs/canvas/canvas/flag.h +++ b/libs/canvas/canvas/flag.h @@ -30,7 +30,8 @@ class Rectangle; class LIBCANVAS_API Flag : public Group { public: - Flag (Group *, Distance, Color, Color, Duple); + Flag (Canvas *, Distance, Color, Color, Duple); + Flag (Group*, Distance, Color, Color, Duple); void set_text (std::string const &); void set_height (Distance); @@ -38,6 +39,8 @@ public: bool covers (Duple const &) const; private: + void setup (Distance height, Duple position); + Color _outline_color; Color _fill_color; Text* _text; diff --git a/libs/canvas/canvas/group.h b/libs/canvas/canvas/group.h index a9150e7d09..6bfc40ba28 100644 --- a/libs/canvas/canvas/group.h +++ b/libs/canvas/canvas/group.h @@ -33,9 +33,10 @@ namespace ArdourCanvas { class LIBCANVAS_API Group : public Item { public: - explicit Group (Group *); - explicit Group (Group *, Duple); - ~Group (); + Group (Canvas*); + Group (Group*); + Group (Group*, Duple const& positon); + virtual ~Group (); void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const; virtual void compute_bounding_box () const; @@ -60,14 +61,9 @@ public: static int default_items_per_cell; -protected: - - explicit Group (Canvas *); - private: friend class ::OptimizingLookupTableTest; - Group (Group const &); void ensure_lut () const; void invalidate_lut () const; void clear_items (bool with_delete); diff --git a/libs/canvas/canvas/image.h b/libs/canvas/canvas/image.h index d54edd3827..fd86818c21 100644 --- a/libs/canvas/canvas/image.h +++ b/libs/canvas/canvas/image.h @@ -34,7 +34,8 @@ namespace ArdourCanvas { class LIBCANVAS_API Image : public Item { public: - Image (Group *, Cairo::Format, int width, int height); + Image (Canvas *, Cairo::Format, int width, int height); + Image (Group*, Cairo::Format, int width, int height); struct Data { Data (uint8_t *d, int w, int h, int s, Cairo::Format fmt) diff --git a/libs/canvas/canvas/item.h b/libs/canvas/canvas/item.h index ff3095d1ff..bf752f66db 100644 --- a/libs/canvas/canvas/item.h +++ b/libs/canvas/canvas/item.h @@ -30,6 +30,8 @@ #include "canvas/visibility.h" #include "canvas/types.h" +#include "canvas/fill.h" +#include "canvas/outline.h" namespace ArdourCanvas { @@ -50,12 +52,12 @@ class ScrollGroup; * and all except the `root group' have a pointer to their parent group. */ -class LIBCANVAS_API Item +class LIBCANVAS_API Item : public Fill, public Outline { public: Item (Canvas *); Item (Group *); - Item (Group *, Duple); + Item (Group *, Duple const& p); virtual ~Item (); void redraw () const; @@ -219,6 +221,8 @@ public: std::string whatami() const; protected: + friend class Fill; + friend class Outline; /** To be called at the beginning of any property change that * may alter the bounding box of this item diff --git a/libs/canvas/canvas/line.h b/libs/canvas/canvas/line.h index 85b1d41e15..e8f57a00ba 100644 --- a/libs/canvas/canvas/line.h +++ b/libs/canvas/canvas/line.h @@ -27,10 +27,11 @@ namespace ArdourCanvas { -class LIBCANVAS_API Line : virtual public Item, public Outline +class LIBCANVAS_API Line : public Item { -public: - Line (Group *); + public: + Line (Canvas*); + Line (Group*); void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; void compute_bounding_box () const; diff --git a/libs/canvas/canvas/line_set.h b/libs/canvas/canvas/line_set.h index 69f2b96907..38f97250ce 100644 --- a/libs/canvas/canvas/line_set.h +++ b/libs/canvas/canvas/line_set.h @@ -35,7 +35,8 @@ public: Horizontal }; - LineSet (Group *, Orientation o = Vertical); + LineSet (Canvas*, Orientation o = Vertical); + LineSet (Group*, Orientation o = Vertical); void compute_bounding_box () const; void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; diff --git a/libs/canvas/canvas/outline.h b/libs/canvas/canvas/outline.h index 972c07b11c..474501c8c7 100644 --- a/libs/canvas/canvas/outline.h +++ b/libs/canvas/canvas/outline.h @@ -22,17 +22,20 @@ #include <stdint.h> +#include <boost/noncopyable.hpp> + #include "canvas/visibility.h" #include "canvas/types.h" -#include "canvas/item.h" namespace ArdourCanvas { -class LIBCANVAS_API Outline : virtual public Item +class Item; + +class LIBCANVAS_API Outline : public boost::noncopyable { public: - Outline (Group *); - virtual ~Outline () {} + Outline (Item& self); + virtual ~Outline() {} Color outline_color () const { return _outline_color; @@ -55,10 +58,11 @@ public: protected: void setup_outline_context (Cairo::RefPtr<Cairo::Context>) const; - - Color _outline_color; + + Item& _self; + Color _outline_color; Distance _outline_width; - bool _outline; + bool _outline; }; } diff --git a/libs/canvas/canvas/pixbuf.h b/libs/canvas/canvas/pixbuf.h index 3974b560a9..eba73e57bf 100644 --- a/libs/canvas/canvas/pixbuf.h +++ b/libs/canvas/canvas/pixbuf.h @@ -34,7 +34,8 @@ namespace ArdourCanvas { class LIBCANVAS_API Pixbuf : public Item { public: - Pixbuf (Group *); + Pixbuf (Canvas*); + Pixbuf (Group*); void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const; void compute_bounding_box () const; diff --git a/libs/canvas/canvas/poly_item.h b/libs/canvas/canvas/poly_item.h index 4745d24ab9..ab68204ff0 100644 --- a/libs/canvas/canvas/poly_item.h +++ b/libs/canvas/canvas/poly_item.h @@ -26,10 +26,11 @@ namespace ArdourCanvas { -class LIBCANVAS_API PolyItem : virtual public Item, public Outline +class LIBCANVAS_API PolyItem : public Item { public: - PolyItem (Group *); + PolyItem (Canvas*); + PolyItem (Group*); void compute_bounding_box () const; diff --git a/libs/canvas/canvas/poly_line.h b/libs/canvas/canvas/poly_line.h index 4f1b2b0157..5476711e97 100644 --- a/libs/canvas/canvas/poly_line.h +++ b/libs/canvas/canvas/poly_line.h @@ -29,7 +29,8 @@ namespace ArdourCanvas { class LIBCANVAS_API PolyLine : public PolyItem { public: - PolyLine (Group *); + PolyLine (Canvas*); + PolyLine (Group*); void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; diff --git a/libs/canvas/canvas/polygon.h b/libs/canvas/canvas/polygon.h index 917122a9a2..a3eed37cdc 100644 --- a/libs/canvas/canvas/polygon.h +++ b/libs/canvas/canvas/polygon.h @@ -27,10 +27,11 @@ namespace ArdourCanvas { -class LIBCANVAS_API Polygon : public PolyItem, public Fill +class LIBCANVAS_API Polygon : public PolyItem { public: - Polygon (Group *); + Polygon (Canvas*); + Polygon (Group*); virtual ~Polygon(); void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; diff --git a/libs/canvas/canvas/rectangle.h b/libs/canvas/canvas/rectangle.h index 91f23f9336..ff6eca3cd9 100644 --- a/libs/canvas/canvas/rectangle.h +++ b/libs/canvas/canvas/rectangle.h @@ -29,11 +29,13 @@ namespace ArdourCanvas { -class LIBCANVAS_API Rectangle : virtual public Item, public Outline, public Fill +class LIBCANVAS_API Rectangle : public Item { public: - Rectangle (Group *); - Rectangle (Group *, Rect const &); + Rectangle (Canvas*); + Rectangle (Canvas*, Rect const &); + Rectangle (Group*); + Rectangle (Group*, Rect const &); void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const; void compute_bounding_box () const; diff --git a/libs/canvas/canvas/ruler.h b/libs/canvas/canvas/ruler.h index 72e38b56f9..633a1d569e 100644 --- a/libs/canvas/canvas/ruler.h +++ b/libs/canvas/canvas/ruler.h @@ -55,8 +55,10 @@ public: virtual void get_marks (std::vector<Mark>&, double lower, double upper, int maxchars) const = 0; }; - Ruler (Group *, const Metric& m); - Ruler (Group *, const Metric& m, Rect const&); + Ruler (Canvas*, const Metric& m); + Ruler (Canvas*, const Metric& m, Rect const&); + Ruler (Group*, const Metric& m); + Ruler (Group*, const Metric& m, Rect const&); void set_range (double lower, double upper); void set_font_description (Pango::FontDescription); diff --git a/libs/canvas/canvas/scroll_group.h b/libs/canvas/canvas/scroll_group.h index 7652ae2e9b..552538eb21 100644 --- a/libs/canvas/canvas/scroll_group.h +++ b/libs/canvas/canvas/scroll_group.h @@ -31,8 +31,8 @@ class LIBCANVAS_API ScrollGroup : public Group ScrollsHorizontally = 0x2 }; - explicit ScrollGroup (Group *, ScrollSensitivity); - explicit ScrollGroup (Group *, Duple, ScrollSensitivity); + ScrollGroup (Canvas*, ScrollSensitivity); + ScrollGroup (Group*, ScrollSensitivity); void scroll_to (Duple const& d); Duple scroll_offset() const { return _scroll_offset; } diff --git a/libs/canvas/canvas/stateful_image.h b/libs/canvas/canvas/stateful_image.h index 80687c5113..5952752e71 100644 --- a/libs/canvas/canvas/stateful_image.h +++ b/libs/canvas/canvas/stateful_image.h @@ -49,6 +49,7 @@ class StatefulImage : public Item public: + StatefulImage (Canvas*, const XMLNode&); StatefulImage (Group*, const XMLNode&); ~StatefulImage (); diff --git a/libs/canvas/canvas/text.h b/libs/canvas/canvas/text.h index 59d2007ceb..cc6d5c815d 100644 --- a/libs/canvas/canvas/text.h +++ b/libs/canvas/canvas/text.h @@ -31,7 +31,8 @@ namespace ArdourCanvas { class LIBCANVAS_API Text : public Item { public: - Text (Group *); + Text (Canvas*); + Text (Group*); ~Text(); void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const; diff --git a/libs/canvas/canvas/wave_view.h b/libs/canvas/canvas/wave_view.h index 6327277ef4..674df969a5 100644 --- a/libs/canvas/canvas/wave_view.h +++ b/libs/canvas/canvas/wave_view.h @@ -45,7 +45,7 @@ class WaveViewTest; namespace ArdourCanvas { -class LIBCANVAS_API WaveView : virtual public Item, public Outline, public Fill +class LIBCANVAS_API WaveView : public Item { public: @@ -86,7 +86,8 @@ public: */ - WaveView (Group *, boost::shared_ptr<ARDOUR::AudioRegion>); + WaveView (Canvas *, boost::shared_ptr<ARDOUR::AudioRegion>); + WaveView (Group*, boost::shared_ptr<ARDOUR::AudioRegion>); ~WaveView (); void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; diff --git a/libs/canvas/canvas/widget.h b/libs/canvas/canvas/widget.h index 18822ef185..842f336a51 100644 --- a/libs/canvas/canvas/widget.h +++ b/libs/canvas/canvas/widget.h @@ -28,10 +28,11 @@ namespace ArdourCanvas { -class LIBCANVAS_API Widget : virtual public Item +class LIBCANVAS_API Widget : public Item { public: - Widget (Group *, CairoWidget&); + Widget (Canvas*, CairoWidget&); + Widget (Group*, CairoWidget&); void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const; void compute_bounding_box () const; diff --git a/libs/canvas/canvas/xfade_curve.h b/libs/canvas/canvas/xfade_curve.h index a1151817e2..d6a10d1f86 100644 --- a/libs/canvas/canvas/xfade_curve.h +++ b/libs/canvas/canvas/xfade_curve.h @@ -34,8 +34,10 @@ public: End, }; - XFadeCurve (Group *); - XFadeCurve (Group *, XFadePosition); + XFadeCurve (Canvas *); + XFadeCurve (Canvas *, XFadePosition); + XFadeCurve (Group*); + XFadeCurve (Group*, XFadePosition); void set_fade_position (XFadePosition xfp) { _xfadeposition = xfp; } diff --git a/libs/canvas/circle.cc b/libs/canvas/circle.cc index 15a1679f74..3799bf60ac 100644 --- a/libs/canvas/circle.cc +++ b/libs/canvas/circle.cc @@ -20,10 +20,16 @@ using namespace ArdourCanvas; -Circle::Circle (Group* parent) - : Item (parent) - , Arc (parent) +Circle::Circle (Canvas* c) + : Arc (c) { set_arc (360.0); } +Circle::Circle (Group* g) + : Arc (g) +{ + set_arc (360.0); +} + + diff --git a/libs/canvas/curve.cc b/libs/canvas/curve.cc index ce7f163d10..547783ae08 100644 --- a/libs/canvas/curve.cc +++ b/libs/canvas/curve.cc @@ -27,10 +27,17 @@ using namespace ArdourCanvas; using std::min; using std::max; -Curve::Curve (Group* parent) - : Item (parent) - , PolyItem (parent) - , Fill (parent) +Curve::Curve (Canvas* c) + : PolyItem (c) + , n_samples (0) + , points_per_segment (16) + , curve_type (CatmullRomCentripetal) + , curve_fill (None) +{ +} + +Curve::Curve (Group* g) + : PolyItem (g) , n_samples (0) , points_per_segment (16) , curve_type (CatmullRomCentripetal) diff --git a/libs/canvas/fill.cc b/libs/canvas/fill.cc index 41c616a0f9..42bcbfff3c 100644 --- a/libs/canvas/fill.cc +++ b/libs/canvas/fill.cc @@ -17,31 +17,34 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <cairomm/cairomm.h> + #include "ardour/utils.h" #include "pbd/compose.h" #include "pbd/convert.h" #include "canvas/fill.h" +#include "canvas/item.h" +#include "canvas/types.h" #include "canvas/utils.h" using namespace std; using namespace ArdourCanvas; -Fill::Fill (Group* parent) - : Item (parent) +Fill::Fill (Item& self) + : _self (self) , _fill_color (0x000000ff) , _fill (true) , _transparent (false) { - } void Fill::set_fill_color (Color color) { if (_fill_color != color) { - begin_visual_change (); + _self.begin_visual_change (); _fill_color = color; double r, g, b, a; @@ -52,7 +55,7 @@ Fill::set_fill_color (Color color) _transparent = false; } - end_visual_change (); + _self.end_visual_change (); } } @@ -60,9 +63,9 @@ void Fill::set_fill (bool fill) { if (_fill != fill) { - begin_visual_change (); + _self.begin_visual_change (); _fill = fill; - end_visual_change (); + _self.end_visual_change (); } } @@ -95,7 +98,7 @@ Fill::setup_gradient_context (Cairo::RefPtr<Cairo::Context> context, Rect const void Fill::set_gradient (StopList const & stops, bool vertical) { - begin_visual_change (); + _self.begin_visual_change (); if (stops.empty()) { _stops.clear (); @@ -104,5 +107,5 @@ Fill::set_gradient (StopList const & stops, bool vertical) _vertical_gradient = vertical; } - end_visual_change (); + _self.end_visual_change (); } diff --git a/libs/canvas/flag.cc b/libs/canvas/flag.cc index e72aece1f5..f5379791df 100644 --- a/libs/canvas/flag.cc +++ b/libs/canvas/flag.cc @@ -25,11 +25,25 @@ using namespace std; using namespace ArdourCanvas; -Flag::Flag (Group* parent, Distance height, Color outline_color, Color fill_color, Duple position) - : Group (parent) +Flag::Flag (Canvas* canvas, Distance height, Color outline_color, Color fill_color, Duple position) + : Group (canvas) , _outline_color (outline_color) , _fill_color (fill_color) { + setup (height, position); +} + +Flag::Flag (Group* group, Distance height, Color outline_color, Color fill_color, Duple position) + : Group (group) + , _outline_color (outline_color) + , _fill_color (fill_color) +{ + setup (height, position); +} + +void +Flag::setup (Distance height, Duple position) +{ _text = new Text (this); _text->set_alignment (Pango::ALIGN_CENTER); _text->set_color (_outline_color); diff --git a/libs/canvas/group.cc b/libs/canvas/group.cc index 2316e4c997..d63b217396 100644 --- a/libs/canvas/group.cc +++ b/libs/canvas/group.cc @@ -39,21 +39,18 @@ Group::Group (Canvas* canvas) : Item (canvas) , _lut (0) { - } -Group::Group (Group* parent) - : Item (parent) +Group::Group (Group* group) + : Item (group) , _lut (0) { - } -Group::Group (Group* parent, Duple position) - : Item (parent, position) +Group::Group (Group* group, Duple const& p) + : Item (group, p) , _lut (0) { - } Group::~Group () @@ -197,10 +194,9 @@ Group::add (Item* i) /* XXX should really notify canvas about this */ _items.push_back (i); + i->reparent (this); invalidate_lut (); _bounding_box_dirty = true; - - } void diff --git a/libs/canvas/image.cc b/libs/canvas/image.cc index 32e453dc30..5ab280cbbc 100644 --- a/libs/canvas/image.cc +++ b/libs/canvas/image.cc @@ -22,6 +22,16 @@ using namespace ArdourCanvas; +Image::Image (Canvas* canvas, Cairo::Format fmt, int width, int height) + : Item (canvas) + , _format (fmt) + , _width (width) + , _height (height) + , _need_render (false) +{ + DataReady.connect (data_connections, MISSING_INVALIDATOR, boost::bind (&Image::accept_data, this), gui_context()); +} + Image::Image (Group* group, Cairo::Format fmt, int width, int height) : Item (group) , _format (fmt) diff --git a/libs/canvas/item.cc b/libs/canvas/item.cc index 2bca2feac2..53dca5d976 100644 --- a/libs/canvas/item.cc +++ b/libs/canvas/item.cc @@ -34,41 +34,53 @@ using namespace PBD; using namespace ArdourCanvas; Item::Item (Canvas* canvas) - : _canvas (canvas) + : Fill (*this) + , Outline (*this) + , _canvas (canvas) , _parent (0) + , _visible (true) + , _bounding_box_dirty (true) + , _ignore_events (false) { - init (); -} + DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this)); +} Item::Item (Group* parent) - : _canvas (parent->canvas ()) + : Fill (*this) + , Outline (*this) + , _canvas (parent->canvas()) , _parent (parent) + , _visible (true) + , _bounding_box_dirty (true) + , _ignore_events (false) { - init (); -} + DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this)); + + if (parent) { + _parent->add (this); + } + + find_scroll_parent (); +} -Item::Item (Group* parent, Duple position) - : _canvas (parent->canvas()) +Item::Item (Group* parent, Duple const& p) + : Fill (*this) + , Outline (*this) + , _canvas (parent->canvas()) , _parent (parent) - , _position (position) + , _position (p) + , _visible (true) + , _bounding_box_dirty (true) + , _ignore_events (false) { - init (); -} + DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this)); -void -Item::init () -{ - _visible = true; - _bounding_box_dirty = true; - _ignore_events = false; - - if (_parent) { + if (parent) { _parent->add (this); } find_scroll_parent (); - DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this)); } Item::~Item () @@ -98,7 +110,7 @@ Item::window_origin () const if (_parent) { return _parent->item_to_window (_position); } else { - return _parent->item_to_window (Duple (0,0)); + return _position; } } @@ -254,22 +266,25 @@ Item::set_y_position (Coord y) void Item::raise_to_top () { - assert (_parent); - _parent->raise_child_to_top (this); + if (_parent) { + _parent->raise_child_to_top (this); + } } void Item::raise (int levels) { - assert (_parent); - _parent->raise_child (this, levels); + if (_parent) { + _parent->raise_child (this, levels); + } } void Item::lower_to_bottom () { - assert (_parent); - _parent->lower_child_to_bottom (this); + if (_parent) { + _parent->lower_child_to_bottom (this); + } } void @@ -318,7 +333,11 @@ Item::unparent () void Item::reparent (Group* new_parent) { - assert (_canvas == _parent->canvas()); + if (new_parent == _parent) { + return; + } + + assert (_canvas == new_parent->canvas()); if (_parent) { _parent->remove (this); @@ -370,10 +389,16 @@ Item::common_ancestor_within (uint32_t limit, const Item& other) const while (d1 != d2) { if (d1 > d2) { + if (!i1) { + return false; + } i1 = i1->parent(); d1--; limit--; } else { + if (!i2) { + return false; + } i2 = i2->parent(); d2--; limit--; @@ -416,9 +441,15 @@ Item::closest_ancestor_with (const Item& other) const while (d1 != d2) { if (d1 > d2) { + if (!i1) { + return 0; + } i1 = i1->parent(); d1--; } else { + if (!i2) { + return 0; + } i2 = i2->parent(); d2--; } diff --git a/libs/canvas/line.cc b/libs/canvas/line.cc index 0528a44c38..844f05522d 100644 --- a/libs/canvas/line.cc +++ b/libs/canvas/line.cc @@ -29,11 +29,14 @@ using namespace std; using namespace ArdourCanvas; -Line::Line (Group* parent) - : Item (parent) - , Outline (parent) +Line::Line (Canvas* c) + : Item (c) { +} +Line::Line (Group* group) + : Item (group) +{ } void diff --git a/libs/canvas/line_set.cc b/libs/canvas/line_set.cc index 0cc4690f76..3eacadaba2 100644 --- a/libs/canvas/line_set.cc +++ b/libs/canvas/line_set.cc @@ -30,8 +30,16 @@ public: } }; -LineSet::LineSet (Group* parent, Orientation o) - : Item (parent) +LineSet::LineSet (Canvas* c, Orientation o) + : Item (c) + , _extent (0) + , _orientation (o) +{ + +} + +LineSet::LineSet (Group* group, Orientation o) + : Item (group) , _extent (0) , _orientation (o) { diff --git a/libs/canvas/outline.cc b/libs/canvas/outline.cc index be8b924df2..9416859e59 100644 --- a/libs/canvas/outline.cc +++ b/libs/canvas/outline.cc @@ -23,28 +23,29 @@ #include "pbd/convert.h" #include "ardour/utils.h" + +#include "canvas/item.h" #include "canvas/outline.h" #include "canvas/utils.h" #include "canvas/debug.h" using namespace ArdourCanvas; -Outline::Outline (Group* parent) - : Item (parent) +Outline::Outline (Item& self) + : _self (self) , _outline_color (0x000000ff) , _outline_width (1.0) , _outline (true) { - } void Outline::set_outline_color (Color color) { if (color != _outline_color) { - begin_visual_change (); + _self.begin_visual_change (); _outline_color = color; - end_visual_change (); + _self.end_visual_change (); } } @@ -52,10 +53,10 @@ void Outline::set_outline_width (Distance width) { if (width != _outline_width) { - begin_change (); + _self.begin_change (); _outline_width = width; - _bounding_box_dirty = true; - end_change (); + _self._bounding_box_dirty = true; + _self.end_change (); } } @@ -63,10 +64,10 @@ void Outline::set_outline (bool outline) { if (outline != _outline) { - begin_change (); + _self.begin_change (); _outline = outline; - _bounding_box_dirty = true; - end_change (); + _self._bounding_box_dirty = true; + _self.end_change (); } } diff --git a/libs/canvas/pixbuf.cc b/libs/canvas/pixbuf.cc index 62d9357c61..82eb916397 100644 --- a/libs/canvas/pixbuf.cc +++ b/libs/canvas/pixbuf.cc @@ -25,10 +25,14 @@ using namespace std; using namespace ArdourCanvas; +Pixbuf::Pixbuf (Canvas* c) + : Item (c) +{ +} + Pixbuf::Pixbuf (Group* g) : Item (g) { - } void diff --git a/libs/canvas/poly_item.cc b/libs/canvas/poly_item.cc index 0d3369f70b..618983db97 100644 --- a/libs/canvas/poly_item.cc +++ b/libs/canvas/poly_item.cc @@ -27,11 +27,14 @@ using namespace std; using namespace ArdourCanvas; -PolyItem::PolyItem (Group* parent) - : Item (parent) - , Outline (parent) +PolyItem::PolyItem (Canvas* c) + : Item (c) { +} +PolyItem::PolyItem (Group* g) + : Item (g) +{ } void diff --git a/libs/canvas/poly_line.cc b/libs/canvas/poly_line.cc index 08d611117f..bade7d855e 100644 --- a/libs/canvas/poly_line.cc +++ b/libs/canvas/poly_line.cc @@ -25,12 +25,16 @@ using namespace ArdourCanvas; -PolyLine::PolyLine (Group* parent) - : Item (parent) - , PolyItem (parent) +PolyLine::PolyLine (Canvas* c) + : PolyItem (c) , _threshold (1.0) { +} +PolyLine::PolyLine (Group* g) + : PolyItem (g) + , _threshold (1.0) +{ } void diff --git a/libs/canvas/polygon.cc b/libs/canvas/polygon.cc index 56a85c2f47..d84bca4af6 100644 --- a/libs/canvas/polygon.cc +++ b/libs/canvas/polygon.cc @@ -21,15 +21,20 @@ using namespace ArdourCanvas; -Polygon::Polygon (Group* parent) - : Item (parent) - , PolyItem (parent) - , Fill (parent) +Polygon::Polygon (Canvas* c) + : PolyItem (c) , multiple (0) , constant (0) , cached_size (0) { +} +Polygon::Polygon (Group* g) + : PolyItem (g) + , multiple (0) + , constant (0) + , cached_size (0) +{ } Polygon::~Polygon () diff --git a/libs/canvas/rectangle.cc b/libs/canvas/rectangle.cc index cea5567dcc..ac05003693 100644 --- a/libs/canvas/rectangle.cc +++ b/libs/canvas/rectangle.cc @@ -30,22 +30,30 @@ using namespace std; using namespace ArdourCanvas; -Rectangle::Rectangle (Group* parent) - : Item (parent) - , Outline (parent) - , Fill (parent) +Rectangle::Rectangle (Canvas* c) + : Item (c) , _outline_what ((What) (LEFT | RIGHT | TOP | BOTTOM)) { } -Rectangle::Rectangle (Group* parent, Rect const & rect) - : Item (parent) - , Outline (parent) - , Fill (parent) +Rectangle::Rectangle (Canvas* c, Rect const & rect) + : Item (c) + , _rect (rect) + , _outline_what ((What) (LEFT | RIGHT | TOP | BOTTOM)) +{ +} + +Rectangle::Rectangle (Group* g) + : Item (g) + , _outline_what ((What) (LEFT | RIGHT | TOP | BOTTOM)) +{ +} + +Rectangle::Rectangle (Group* g, Rect const & rect) + : Item (g) , _rect (rect) , _outline_what ((What) (LEFT | RIGHT | TOP | BOTTOM)) { - } void diff --git a/libs/canvas/ruler.cc b/libs/canvas/ruler.cc index aa48b52e92..1e7a731899 100644 --- a/libs/canvas/ruler.cc +++ b/libs/canvas/ruler.cc @@ -31,9 +31,8 @@ using namespace std; using namespace ArdourCanvas; -Ruler::Ruler (Group *p, const Metric& m) - : Item (p) - , Rectangle (p) +Ruler::Ruler (Canvas* c, const Metric& m) + : Rectangle (c) , _metric (m) , _lower (0) , _upper (0) @@ -41,9 +40,26 @@ Ruler::Ruler (Group *p, const Metric& m) { } -Ruler::Ruler (Group *p, const Metric& m, Rect const& r) - : Item (p) - , Rectangle (p, r) +Ruler::Ruler (Canvas* c, const Metric& m, Rect const& r) + : Rectangle (c, r) + , _metric (m) + , _lower (0) + , _upper (0) + , _need_marks (true) +{ +} + +Ruler::Ruler (Group* g, const Metric& m) + : Rectangle (g) + , _metric (m) + , _lower (0) + , _upper (0) + , _need_marks (true) +{ +} + +Ruler::Ruler (Group* g, const Metric& m, Rect const& r) + : Rectangle (g, r) , _metric (m) , _lower (0) , _upper (0) diff --git a/libs/canvas/scroll_group.cc b/libs/canvas/scroll_group.cc index 0ce612018a..d78caf4ed0 100644 --- a/libs/canvas/scroll_group.cc +++ b/libs/canvas/scroll_group.cc @@ -27,15 +27,15 @@ using namespace std; using namespace ArdourCanvas; -ScrollGroup::ScrollGroup (Group* parent, ScrollSensitivity s) - : Group (parent) +ScrollGroup::ScrollGroup (Canvas* c, ScrollSensitivity s) + : Group (c) , _scroll_sensitivity (s) { } -ScrollGroup::ScrollGroup (Group* parent, Duple position, ScrollSensitivity s) - : Group (parent, position) - , _scroll_sensitivity (s) +ScrollGroup::ScrollGroup (Group* g, ScrollSensitivity s) + : Group (g) + , _scroll_sensitivity (s) { } diff --git a/libs/canvas/stateful_image.cc b/libs/canvas/stateful_image.cc index f2b8e71744..b372ade7b8 100644 --- a/libs/canvas/stateful_image.cc +++ b/libs/canvas/stateful_image.cc @@ -19,8 +19,8 @@ using PBD::error; PBD::Searchpath StatefulImage::_image_search_path; StatefulImage::ImageCache StatefulImage::_image_cache; -StatefulImage::StatefulImage (Group* group, const XMLNode& node) - : Item (group) +StatefulImage::StatefulImage (Canvas* c, const XMLNode& node) + : Item (c) , _state (0) , _font (0) , _text_x (0) diff --git a/libs/canvas/text.cc b/libs/canvas/text.cc index 438413080a..12fe3eb6cb 100644 --- a/libs/canvas/text.cc +++ b/libs/canvas/text.cc @@ -31,8 +31,8 @@ using namespace std; using namespace ArdourCanvas; -Text::Text (Group* parent) - : Item (parent) +Text::Text (Canvas* c) + : Item (c) , _color (0x000000ff) , _font_description (0) , _alignment (Pango::ALIGN_LEFT) @@ -41,7 +41,18 @@ Text::Text (Group* parent) , _need_redraw (false) , _clamped_width (COORD_MAX) { +} +Text::Text (Group* g) + : Item (g) + , _color (0x000000ff) + , _font_description (0) + , _alignment (Pango::ALIGN_LEFT) + , _width (0) + , _height (0) + , _need_redraw (false) + , _clamped_width (COORD_MAX) +{ } Text::~Text () diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc index 6f626e7010..2d24e38969 100644 --- a/libs/canvas/wave_view.cc +++ b/libs/canvas/wave_view.cc @@ -53,10 +53,31 @@ double WaveView::_clip_level = 0.98853; PBD::Signal0<void> WaveView::VisualPropertiesChanged; PBD::Signal0<void> WaveView::ClipLevelChanged; -WaveView::WaveView (Group* parent, boost::shared_ptr<ARDOUR::AudioRegion> region) - : Item (parent) - , Outline (parent) - , Fill (parent) +WaveView::WaveView (Canvas* c, boost::shared_ptr<ARDOUR::AudioRegion> region) + : Item (c) + , _region (region) + , _channel (0) + , _samples_per_pixel (0) + , _height (64) + , _show_zero (false) + , _zero_color (0xff0000ff) + , _clip_color (0xff0000ff) + , _logscaled (_global_logscaled) + , _shape (_global_shape) + , _gradient_depth (_global_gradient_depth) + , _shape_independent (false) + , _logscaled_independent (false) + , _gradient_depth_independent (false) + , _amplitude_above_axis (1.0) + , _region_amplitude (_region->scale_amplitude ()) + , _region_start (region->start()) +{ + VisualPropertiesChanged.connect_same_thread (invalidation_connection, boost::bind (&WaveView::handle_visual_property_change, this)); + ClipLevelChanged.connect_same_thread (invalidation_connection, boost::bind (&WaveView::handle_clip_level_change, this)); +} + +WaveView::WaveView (Group* g, boost::shared_ptr<ARDOUR::AudioRegion> region) + : Item (g) , _region (region) , _channel (0) , _samples_per_pixel (0) diff --git a/libs/canvas/widget.cc b/libs/canvas/widget.cc index 9206213dbd..0961382128 100644 --- a/libs/canvas/widget.cc +++ b/libs/canvas/widget.cc @@ -29,8 +29,15 @@ using namespace std; using namespace ArdourCanvas; -Widget::Widget (Group* parent, CairoWidget& w) - : Item (parent) +Widget::Widget (Canvas* c, CairoWidget& w) + : Item (c) + , _widget (w) +{ + Event.connect (sigc::mem_fun (*this, &Widget::event_proxy)); +} + +Widget::Widget (Group* g, CairoWidget& w) + : Item (g) , _widget (w) { Event.connect (sigc::mem_fun (*this, &Widget::event_proxy)); @@ -39,6 +46,7 @@ Widget::Widget (Group* parent, CairoWidget& w) bool Widget::event_proxy (GdkEvent* ev) { + /* XXX need to translate coordinate into widget's own coordinate space */ return _widget.event (ev); } diff --git a/libs/canvas/xfade_curve.cc b/libs/canvas/xfade_curve.cc index 5e68dbbb82..9a854cd54e 100644 --- a/libs/canvas/xfade_curve.cc +++ b/libs/canvas/xfade_curve.cc @@ -30,8 +30,8 @@ using namespace ArdourCanvas; using std::min; using std::max; -XFadeCurve::XFadeCurve (Group* parent) - : Item (parent) +XFadeCurve::XFadeCurve (Canvas* c) + : Item (c) , points_per_segment (32) , _xfadeposition (Start) , _outline_color (0x000000ff) @@ -39,8 +39,26 @@ XFadeCurve::XFadeCurve (Group* parent) { } -XFadeCurve::XFadeCurve (Group* parent, XFadePosition pos) - : Item (parent) +XFadeCurve::XFadeCurve (Canvas* c, XFadePosition pos) + : Item (c) + , points_per_segment (32) + , _xfadeposition (pos) + , _outline_color (0x000000ff) + , _fill_color (0x22448880) +{ +} + +XFadeCurve::XFadeCurve (Group* g) + : Item (g) + , points_per_segment (32) + , _xfadeposition (Start) + , _outline_color (0x000000ff) + , _fill_color (0x22448880) +{ +} + +XFadeCurve::XFadeCurve (Group* g, XFadePosition pos) + : Item (g) , points_per_segment (32) , _xfadeposition (pos) , _outline_color (0x000000ff) |