refactor Canvas so that all Items have children; add Container abstract base class; rename Group as "Layout" and retain only drawing semantics

This commit is contained in:
Paul Davis 2014-06-21 11:43:42 -04:00
parent 5d6dc388f7
commit a8bd6ecc4f
51 changed files with 442 additions and 637 deletions

View file

@ -39,8 +39,8 @@ Arc::Arc (Canvas* c)
{ {
} }
Arc::Arc (Group* g) Arc::Arc (Item* parent)
: Item (g) : Item (parent)
, _radius (0.0) , _radius (0.0)
, _arc_degrees (0.0) , _arc_degrees (0.0)
, _start_degrees (0.0) , _start_degrees (0.0)

View file

@ -35,13 +35,13 @@ using namespace ArdourCanvas;
* @param parent Parent canvas group. * @param parent Parent canvas group.
*/ */
Arrow::Arrow (Canvas* c) Arrow::Arrow (Canvas* c)
: Group (c) : Layout (c)
{ {
setup (); setup ();
} }
Arrow::Arrow (Group* g) Arrow::Arrow (Item* parent)
: Group (g) : Layout (parent)
{ {
setup (); setup ();
} }

View file

@ -396,7 +396,7 @@ GtkCanvas::pick_current_item (Duple const & point, int state)
/* We ignore invisible items, groups and items that ignore events */ /* We ignore invisible items, groups and items that ignore events */
if (!new_item->visible() || new_item->ignore_events() || dynamic_cast<Group const *>(new_item) != 0) { if (!new_item->visible() || new_item->ignore_events() || dynamic_cast<Container const *>(new_item) != 0) {
continue; continue;
} }

View file

@ -32,7 +32,7 @@ class LIBCANVAS_API Arc : public Item
{ {
public: public:
Arc (Canvas*); Arc (Canvas*);
Arc (Group*); Arc (Item*);
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const; void compute_bounding_box () const;

View file

@ -26,8 +26,7 @@
#define __CANVAS_ARROW_H__ #define __CANVAS_ARROW_H__
#include "canvas/visibility.h" #include "canvas/visibility.h"
#include "canvas/layout.h"
#include "canvas/group.h"
namespace ArdourCanvas { namespace ArdourCanvas {
@ -46,11 +45,11 @@ class Polygon;
* to draw lines at any angle. * to draw lines at any angle.
*/ */
class LIBCANVAS_API Arrow : public Group class LIBCANVAS_API Arrow : public Layout
{ {
public: public:
Arrow (Canvas*); Arrow (Canvas*);
Arrow (Group*); Arrow (Item*);
void set_show_head (int, bool); void set_show_head (int, bool);
void set_head_outward (int, bool); void set_head_outward (int, bool);

View file

@ -42,7 +42,7 @@ namespace ArdourCanvas
{ {
class Rect; class Rect;
class Group; class Item;
class ScrollGroup; class ScrollGroup;
/** The base class for our different types of canvas. /** The base class for our different types of canvas.
@ -78,7 +78,7 @@ public:
void render (Rect const &, Cairo::RefPtr<Cairo::Context> const &) const; void render (Rect const &, Cairo::RefPtr<Cairo::Context> const &) const;
/** @return root group */ /** @return root group */
Group* root () { Item* root () {
return &_root; return &_root;
} }
@ -122,8 +122,8 @@ public:
protected: protected:
void queue_draw_item_area (Item *, Rect); void queue_draw_item_area (Item *, Rect);
/** our root group */ /** our root item */
RootGroup _root; Root _root;
virtual void pick_current_item (int state) = 0; virtual void pick_current_item (int state) = 0;
virtual void pick_current_item (Duple const &, int state) = 0; virtual void pick_current_item (Duple const &, int state) = 0;

View file

@ -29,7 +29,7 @@ class LIBCANVAS_API Circle : public Arc
{ {
public: public:
Circle (Canvas*); Circle (Canvas*);
Circle (Group*); Circle (Item*);
}; };
} }

View file

@ -33,7 +33,7 @@ class LIBCANVAS_API Curve : public PolyItem, public InterpolatedCurve
{ {
public: public:
Curve (Canvas*); Curve (Canvas*);
Curve (Group*); Curve (Item*);
enum CurveFill { enum CurveFill {
None, None,

View file

@ -18,8 +18,8 @@
*/ */
#include "canvas/visibility.h" #include "canvas/visibility.h"
#include "canvas/group.h"
#include "canvas/types.h" #include "canvas/types.h"
#include "canvas/layout.h"
namespace ArdourCanvas { namespace ArdourCanvas {
@ -27,11 +27,11 @@ class Text;
class Line; class Line;
class Rectangle; class Rectangle;
class LIBCANVAS_API Flag : public Group class LIBCANVAS_API Flag : public Layout
{ {
public: public:
Flag (Canvas *, Distance, Color, Color, Duple); Flag (Canvas *, Distance, Color, Color, Duple);
Flag (Group*, Distance, Color, Color, Duple); Flag (Item*, Distance, Color, Color, Duple);
void set_text (std::string const &); void set_text (std::string const &);
void set_height (Distance); void set_height (Distance);

View file

@ -33,6 +33,7 @@ namespace ArdourCanvas {
class GtkCanvasViewport; class GtkCanvasViewport;
class Text; class Text;
class Curve; class Curve;
class ScrollGroup;
} }
#endif /* __canvas_canvas_fwd_h__ */ #endif /* __canvas_canvas_fwd_h__ */

View file

@ -1,79 +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 __CANVAS_GROUP_H__
#define __CANVAS_GROUP_H__
#include <list>
#include <vector>
#include "canvas/visibility.h"
#include "canvas/item.h"
#include "canvas/types.h"
#include "canvas/lookup_table.h"
namespace ArdourCanvas {
class LIBCANVAS_API Group : public Item
{
public:
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;
void add (Item *);
void remove (Item *);
void clear (bool with_delete = false);
std::list<Item*> const & items () const {
return _items;
}
void raise_child_to_top (Item *);
void raise_child (Item *, int);
void lower_child_to_bottom (Item *);
void child_changed ();
void scroll_to (Duple const& d);
void add_items_at_point (Duple, std::vector<Item const *> &) const;
void dump (std::ostream&) const;
static int default_items_per_cell;
private:
friend class ::OptimizingLookupTableTest;
void ensure_lut () const;
void invalidate_lut () const;
void clear_items (bool with_delete);
/* our items, from lowest to highest in the stack */
std::list<Item*> _items;
mutable LookupTable* _lut;
};
}
#endif

View file

@ -35,7 +35,7 @@ class LIBCANVAS_API Image : public Item
{ {
public: public:
Image (Canvas *, Cairo::Format, int width, int height); Image (Canvas *, Cairo::Format, int width, int height);
Image (Group*, Cairo::Format, int width, int height); Image (Item*, Cairo::Format, int width, int height);
struct Data { struct Data {
Data (uint8_t *d, int w, int h, int s, Cairo::Format fmt) Data (uint8_t *d, int w, int h, int s, Cairo::Format fmt)

View file

@ -32,12 +32,12 @@
#include "canvas/types.h" #include "canvas/types.h"
#include "canvas/fill.h" #include "canvas/fill.h"
#include "canvas/outline.h" #include "canvas/outline.h"
#include "canvas/lookup_table.h"
namespace ArdourCanvas namespace ArdourCanvas
{ {
class Canvas; class Canvas;
class Group;
class Rect; class Rect;
class ScrollGroup; class ScrollGroup;
@ -56,8 +56,8 @@ class LIBCANVAS_API Item : public Fill, public Outline
{ {
public: public:
Item (Canvas *); Item (Canvas *);
Item (Group *); Item (Item *);
Item (Group *, Duple const& p); Item (Item *, Duple const& p);
virtual ~Item (); virtual ~Item ();
void redraw () const; void redraw () const;
@ -80,13 +80,11 @@ public:
* *
* Note that Item::add_items_at_window_point() is only intended to be * Note that Item::add_items_at_window_point() is only intended to be
* called on items already looked up in a LookupTable (i.e. by a * called on items already looked up in a LookupTable (i.e. by a
* parent group) and thus known to cover @param point already. * parent) and thus known to cover @param point already.
* *
* Derived classes may add more items than themselves (e.g. Group). * Derived classes may add more items than themselves (e.g. containers).
*/ */
virtual void add_items_at_point (Duple /*point*/, std::vector<Item const *>& items) const { virtual void add_items_at_point (Duple /*point*/, std::vector<Item const *>& items) const;
items.push_back (this);
}
virtual bool covers (Duple const &) const; virtual bool covers (Duple const &) const;
@ -97,10 +95,10 @@ public:
void ungrab (); void ungrab ();
void unparent (); void unparent ();
void reparent (Group *); void reparent (Item *);
/** @return Parent group, or 0 if this is the root group */ /** @return Parent group, or 0 if this is the root group */
Group* parent () const { Item* parent () const {
return _parent; return _parent;
} }
@ -124,8 +122,6 @@ public:
void set_y_position (Coord); void set_y_position (Coord);
void move (Duple); void move (Duple);
virtual void scroll_to (Duple const&) {}
/** @return Position of this item in the parent's coordinates */ /** @return Position of this item in the parent's coordinates */
Duple position () const { Duple position () const {
return _position; return _position;
@ -188,6 +184,21 @@ public:
void set_data (std::string const &, void *); void set_data (std::string const &, void *);
void* get_data (std::string const &) const; void* get_data (std::string const &) const;
/* nested item ("grouping") API */
void add (Item *);
void remove (Item *);
void clear (bool with_delete = false);
std::list<Item*> const & items () const {
return _items;
}
void raise_child_to_top (Item *);
void raise_child (Item *, int);
void lower_child_to_bottom (Item *);
void child_changed ();
static int default_items_per_cell;
/* This is a sigc++ signal because it is solely /* This is a sigc++ signal because it is solely
concerned with GUI stuff and is thus single-threaded concerned with GUI stuff and is thus single-threaded
*/ */
@ -243,7 +254,7 @@ protected:
Canvas* _canvas; Canvas* _canvas;
/** parent group; may be 0 if we are the root group or if we have been unparent()ed */ /** parent group; may be 0 if we are the root group or if we have been unparent()ed */
Group* _parent; Item* _parent;
/** scroll parent group; may be 0 if we are the root group or if we have been unparent()ed */ /** scroll parent group; may be 0 if we are the root group or if we have been unparent()ed */
ScrollGroup* _scroll_parent; ScrollGroup* _scroll_parent;
/** position of this item in parent coordinates */ /** position of this item in parent coordinates */
@ -261,6 +272,18 @@ protected:
/* XXX: this is a bit grubby */ /* XXX: this is a bit grubby */
std::map<std::string, void *> _data; std::map<std::string, void *> _data;
/* nesting ("grouping") API */
void invalidate_lut () const;
void clear_items (bool with_delete);
void ensure_lut () const;
mutable LookupTable* _lut;
/* our items, from lowest to highest in the stack */
std::list<Item*> _items;
void add_child_bounding_boxes() const;
private: private:
void init (); void init ();

View file

@ -31,7 +31,7 @@ class LIBCANVAS_API Line : public Item
{ {
public: public:
Line (Canvas*); Line (Canvas*);
Line (Group*); Line (Item*);
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const; void compute_bounding_box () const;

View file

@ -36,7 +36,7 @@ public:
}; };
LineSet (Canvas*, Orientation o = Vertical); LineSet (Canvas*, Orientation o = Vertical);
LineSet (Group*, Orientation o = Vertical); LineSet (Item*, Orientation o = Vertical);
void compute_bounding_box () const; void compute_bounding_box () const;
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;

View file

@ -31,12 +31,11 @@ class OptimizingLookupTableTest;
namespace ArdourCanvas { namespace ArdourCanvas {
class Item; class Item;
class Group;
class LIBCANVAS_API LookupTable class LIBCANVAS_API LookupTable
{ {
public: public:
LookupTable (Group const &); LookupTable (Item const &);
virtual ~LookupTable (); virtual ~LookupTable ();
virtual std::vector<Item*> get (Rect const &) = 0; virtual std::vector<Item*> get (Rect const &) = 0;
@ -45,13 +44,13 @@ public:
protected: protected:
Group const & _group; Item const & _item;
}; };
class LIBCANVAS_API DumbLookupTable : public LookupTable class LIBCANVAS_API DumbLookupTable : public LookupTable
{ {
public: public:
DumbLookupTable (Group const &); DumbLookupTable (Item const &);
std::vector<Item*> get (Rect const &); std::vector<Item*> get (Rect const &);
std::vector<Item*> items_at_point (Duple const &) const; std::vector<Item*> items_at_point (Duple const &) const;
@ -61,7 +60,7 @@ public:
class LIBCANVAS_API OptimizingLookupTable : public LookupTable class LIBCANVAS_API OptimizingLookupTable : public LookupTable
{ {
public: public:
OptimizingLookupTable (Group const &, int); OptimizingLookupTable (Item const &, int);
~OptimizingLookupTable (); ~OptimizingLookupTable ();
std::vector<Item*> get (Rect const &); std::vector<Item*> get (Rect const &);
std::vector<Item*> items_at_point (Duple const &) const; std::vector<Item*> items_at_point (Duple const &) const;

View file

@ -35,7 +35,7 @@ class LIBCANVAS_API Pixbuf : public Item
{ {
public: public:
Pixbuf (Canvas*); Pixbuf (Canvas*);
Pixbuf (Group*); Pixbuf (Item*);
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const; void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const; void compute_bounding_box () const;

View file

@ -30,7 +30,7 @@ class LIBCANVAS_API PolyItem : public Item
{ {
public: public:
PolyItem (Canvas*); PolyItem (Canvas*);
PolyItem (Group*); PolyItem (Item*);
void compute_bounding_box () const; void compute_bounding_box () const;

View file

@ -30,7 +30,7 @@ class LIBCANVAS_API PolyLine : public PolyItem
{ {
public: public:
PolyLine (Canvas*); PolyLine (Canvas*);
PolyLine (Group*); PolyLine (Item*);
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;

View file

@ -31,7 +31,7 @@ class LIBCANVAS_API Polygon : public PolyItem
{ {
public: public:
Polygon (Canvas*); Polygon (Canvas*);
Polygon (Group*); Polygon (Item*);
virtual ~Polygon(); virtual ~Polygon();
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;

View file

@ -34,8 +34,8 @@ class LIBCANVAS_API Rectangle : public Item
public: public:
Rectangle (Canvas*); Rectangle (Canvas*);
Rectangle (Canvas*, Rect const &); Rectangle (Canvas*, Rect const &);
Rectangle (Group*); Rectangle (Item*);
Rectangle (Group*, Rect const &); Rectangle (Item*, Rect const &);
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const; void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const; void compute_bounding_box () const;

View file

@ -21,19 +21,18 @@
#define __CANVAS_ROOT_GROUP_H__ #define __CANVAS_ROOT_GROUP_H__
#include "canvas/visibility.h" #include "canvas/visibility.h"
#include "canvas/group.h" #include "canvas/layout.h"
namespace ArdourCanvas { namespace ArdourCanvas {
class LIBCANVAS_API RootGroup : public Group class LIBCANVAS_API Root : public Layout
{ {
private: private:
friend class Canvas; friend class Canvas;
RootGroup (Canvas *); Root (Canvas *);
void compute_bounding_box () const; void compute_bounding_box () const;
void child_changed ();
}; };
} }

View file

@ -57,8 +57,8 @@ public:
Ruler (Canvas*, const Metric& m); Ruler (Canvas*, const Metric& m);
Ruler (Canvas*, const Metric& m, Rect const&); Ruler (Canvas*, const Metric& m, Rect const&);
Ruler (Group*, const Metric& m); Ruler (Item*, const Metric& m);
Ruler (Group*, const Metric& m, Rect const&); Ruler (Item*, const Metric& m, Rect const&);
void set_range (double lower, double upper); void set_range (double lower, double upper);
void set_font_description (Pango::FontDescription); void set_font_description (Pango::FontDescription);

View file

@ -19,11 +19,15 @@
#ifndef __CANVAS_SCROLL_GROUP_H__ #ifndef __CANVAS_SCROLL_GROUP_H__
#define __CANVAS_SCROLL_GROUP_H__ #define __CANVAS_SCROLL_GROUP_H__
#include "canvas/group.h" #include "canvas/layout.h"
namespace ArdourCanvas { namespace ArdourCanvas {
class LIBCANVAS_API ScrollGroup : public Group /** A ScrollGroup has no contents of its own, but renders
* its children in a way that reflects the most recent
* call to its scroll_to() method.
*/
class LIBCANVAS_API ScrollGroup : public Layout
{ {
public: public:
enum ScrollSensitivity { enum ScrollSensitivity {
@ -32,7 +36,7 @@ class LIBCANVAS_API ScrollGroup : public Group
}; };
ScrollGroup (Canvas*, ScrollSensitivity); ScrollGroup (Canvas*, ScrollSensitivity);
ScrollGroup (Group*, ScrollSensitivity); ScrollGroup (Item*, ScrollSensitivity);
void scroll_to (Duple const& d); void scroll_to (Duple const& d);
Duple scroll_offset() const { return _scroll_offset; } Duple scroll_offset() const { return _scroll_offset; }

View file

@ -50,7 +50,7 @@ class StatefulImage : public Item
public: public:
StatefulImage (Canvas*, const XMLNode&); StatefulImage (Canvas*, const XMLNode&);
StatefulImage (Group*, const XMLNode&); StatefulImage (Item*, const XMLNode&);
~StatefulImage (); ~StatefulImage ();
bool set_state (States::size_type); bool set_state (States::size_type);

View file

@ -32,7 +32,7 @@ class LIBCANVAS_API Text : public Item
{ {
public: public:
Text (Canvas*); Text (Canvas*);
Text (Group*); Text (Item*);
~Text(); ~Text();
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const; void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;

View file

@ -92,7 +92,7 @@ public:
WaveView (Canvas *, boost::shared_ptr<ARDOUR::AudioRegion>); WaveView (Canvas *, boost::shared_ptr<ARDOUR::AudioRegion>);
WaveView (Group*, boost::shared_ptr<ARDOUR::AudioRegion>); WaveView (Item*, boost::shared_ptr<ARDOUR::AudioRegion>);
~WaveView (); ~WaveView ();
void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const; void render (Rect const & area, Cairo::RefPtr<Cairo::Context>) const;

View file

@ -32,7 +32,7 @@ class LIBCANVAS_API Widget : public Item
{ {
public: public:
Widget (Canvas*, CairoWidget&); Widget (Canvas*, CairoWidget&);
Widget (Group*, CairoWidget&); Widget (Item*, CairoWidget&);
void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const; void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const;
void compute_bounding_box () const; void compute_bounding_box () const;

View file

@ -36,8 +36,8 @@ public:
XFadeCurve (Canvas *); XFadeCurve (Canvas *);
XFadeCurve (Canvas *, XFadePosition); XFadeCurve (Canvas *, XFadePosition);
XFadeCurve (Group*); XFadeCurve (Item*);
XFadeCurve (Group*, XFadePosition); XFadeCurve (Item*, XFadePosition);
void set_fade_position (XFadePosition xfp) { _xfadeposition = xfp; } void set_fade_position (XFadePosition xfp) { _xfadeposition = xfp; }

View file

@ -26,8 +26,8 @@ Circle::Circle (Canvas* c)
set_arc (360.0); set_arc (360.0);
} }
Circle::Circle (Group* g) Circle::Circle (Item * parent)
: Arc (g) : Arc (parent)
{ {
set_arc (360.0); set_arc (360.0);
} }

View file

@ -36,8 +36,8 @@ Curve::Curve (Canvas* c)
{ {
} }
Curve::Curve (Group* g) Curve::Curve (Item* parent)
: PolyItem (g) : PolyItem (parent)
, n_samples (0) , n_samples (0)
, points_per_segment (16) , points_per_segment (16)
, curve_type (CatmullRomCentripetal) , curve_type (CatmullRomCentripetal)

View file

@ -26,15 +26,15 @@ using namespace std;
using namespace ArdourCanvas; using namespace ArdourCanvas;
Flag::Flag (Canvas* canvas, Distance height, Color outline_color, Color fill_color, Duple position) Flag::Flag (Canvas* canvas, Distance height, Color outline_color, Color fill_color, Duple position)
: Group (canvas) : Layout (canvas)
, _outline_color (outline_color) , _outline_color (outline_color)
, _fill_color (fill_color) , _fill_color (fill_color)
{ {
setup (height, position); setup (height, position);
} }
Flag::Flag (Group* group, Distance height, Color outline_color, Color fill_color, Duple position) Flag::Flag (Item* parent, Distance height, Color outline_color, Color fill_color, Duple position)
: Group (group) : Layout (parent)
, _outline_color (outline_color) , _outline_color (outline_color)
, _fill_color (fill_color) , _fill_color (fill_color)
{ {

View file

@ -1,395 +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.
*/
#include <iostream>
#include <cairomm/context.h>
#include "pbd/stacktrace.h"
#include "pbd/compose.h"
#include "canvas/group.h"
#include "canvas/types.h"
#include "canvas/debug.h"
#include "canvas/item.h"
#include "canvas/canvas.h"
using namespace std;
using namespace ArdourCanvas;
int Group::default_items_per_cell = 64;
Group::Group (Canvas* canvas)
: Item (canvas)
, _lut (0)
{
}
Group::Group (Group* group)
: Item (group)
, _lut (0)
{
}
Group::Group (Group* group, Duple const& p)
: Item (group, p)
, _lut (0)
{
}
Group::~Group ()
{
clear_items (true);
}
/** @param area Area to draw in window coordinates.
* @param context Context, set up with its origin at this group's position.
*/
void
Group::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
ensure_lut ();
vector<Item*> items = _lut->get (area);
#ifdef CANVAS_DEBUG
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
cerr << string_compose ("%1GROUP %2 @ %7 render %5 @ %6 %3 items out of %4\n",
_canvas->render_indent(), (name.empty() ? string ("[unnamed]") : name), items.size(), _items.size(), area, _position, this);
}
#endif
++render_depth;
for (vector<Item*>::const_iterator i = items.begin(); i != items.end(); ++i) {
if (!(*i)->visible ()) {
#ifdef CANVAS_DEBUG
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
cerr << _canvas->render_indent() << "Item " << (*i)->whatami() << " [" << (*i)->name << "] invisible - skipped\n";
}
#endif
continue;
}
boost::optional<Rect> item_bbox = (*i)->bounding_box ();
if (!item_bbox) {
#ifdef CANVAS_DEBUG
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
cerr << _canvas->render_indent() << "Item " << (*i)->whatami() << " [" << (*i)->name << "] empty - skipped\n";
}
#endif
continue;
}
Rect item = (*i)->item_to_window (item_bbox.get());
boost::optional<Rect> d = item.intersection (area);
if (d) {
Rect draw = d.get();
if (draw.width() && draw.height()) {
#ifdef CANVAS_DEBUG
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
if (dynamic_cast<Group*>(*i) == 0) {
cerr << _canvas->render_indent() << "render "
<< ' '
<< (*i)
<< ' '
<< (*i)->whatami()
<< ' '
<< (*i)->name
<< " item "
<< item_bbox.get()
<< " window = "
<< item
<< " intersect = "
<< draw
<< " @ "
<< _position
<< endl;
}
}
#endif
(*i)->render (area, context);
++render_count;
}
} else {
#ifdef CANVAS_DEBUG
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
cerr << string_compose ("%1skip render of %2 %3, no intersection between %4 and %5\n", _canvas->render_indent(), (*i)->whatami(),
(*i)->name, item, area);
}
#endif
}
}
--render_depth;
}
void
Group::scroll_to (Duple const& d)
{
Item::scroll_to (d);
for (list<Item*>::iterator i = _items.begin(); i != _items.end(); ++i) {
(*i)->scroll_to (d);
}
}
void
Group::compute_bounding_box () const
{
Rect bbox;
bool have_one = false;
for (list<Item*>::const_iterator i = _items.begin(); i != _items.end(); ++i) {
boost::optional<Rect> item_bbox = (*i)->bounding_box ();
if (!item_bbox) {
continue;
}
Rect group_bbox = (*i)->item_to_parent (item_bbox.get ());
if (have_one) {
bbox = bbox.extend (group_bbox);
} else {
bbox = group_bbox;
have_one = true;
}
}
if (!have_one) {
_bounding_box = boost::optional<Rect> ();
} else {
_bounding_box = bbox;
}
_bounding_box_dirty = false;
}
void
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
Group::remove (Item* i)
{
if (i->parent() != this) {
return;
}
/* we cannot call bounding_box() here because that will iterate over
_items, one of which (the argument, i) may be in the middle of
deletion, making it impossible to call compute_bounding_box()
on it.
*/
if (_bounding_box) {
_pre_change_bounding_box = _bounding_box;
} else {
_pre_change_bounding_box = Rect();
}
i->unparent ();
_items.remove (i);
invalidate_lut ();
_bounding_box_dirty = true;
end_change ();
}
void
Group::clear (bool with_delete)
{
begin_change ();
clear_items (with_delete);
invalidate_lut ();
_bounding_box_dirty = true;
end_change ();
}
void
Group::clear_items (bool with_delete)
{
for (list<Item*>::iterator i = _items.begin(); i != _items.end(); ) {
list<Item*>::iterator tmp = i;
Item *item = *i;
++tmp;
/* remove from list before doing anything else, because we
* don't want to find the item in _items during any activity
* driven by unparent-ing or deletion.
*/
_items.erase (i);
item->unparent ();
if (with_delete) {
delete item;
}
i = tmp;
}
}
void
Group::raise_child_to_top (Item* i)
{
if (!_items.empty()) {
if (_items.back() == i) {
return;
}
}
_items.remove (i);
_items.push_back (i);
invalidate_lut ();
}
void
Group::raise_child (Item* i, int levels)
{
list<Item*>::iterator j = find (_items.begin(), _items.end(), i);
assert (j != _items.end ());
++j;
_items.remove (i);
while (levels > 0 && j != _items.end ()) {
++j;
--levels;
}
_items.insert (j, i);
invalidate_lut ();
}
void
Group::lower_child_to_bottom (Item* i)
{
if (!_items.empty()) {
if (_items.front() == i) {
return;
}
}
_items.remove (i);
_items.push_front (i);
invalidate_lut ();
}
void
Group::ensure_lut () const
{
if (!_lut) {
_lut = new DumbLookupTable (*this);
}
}
void
Group::invalidate_lut () const
{
delete _lut;
_lut = 0;
}
void
Group::child_changed ()
{
invalidate_lut ();
_bounding_box_dirty = true;
if (_parent) {
_parent->child_changed ();
}
}
void
Group::add_items_at_point (Duple const point, vector<Item const *>& items) const
{
boost::optional<Rect> const bbox = bounding_box ();
/* Point is in window coordinate system */
if (!bbox || !item_to_window (bbox.get()).contains (point)) {
return;
}
/* now recurse and add any items within our group that contain point */
ensure_lut ();
vector<Item*> our_items = _lut->items_at_point (point);
if (!our_items.empty()) {
/* this adds this group itself to the list of items at point */
Item::add_items_at_point (point, items);
}
for (vector<Item*>::iterator i = our_items.begin(); i != our_items.end(); ++i) {
(*i)->add_items_at_point (point, items);
}
}
void
Group::dump (ostream& o) const
{
#ifdef CANVAS_DEBUG
o << _canvas->indent();
o << "Group " << this << " [" << name << ']';
o << " @ " << position();
o << " Items: " << _items.size();
o << " Visible ? " << _visible;
boost::optional<Rect> bb = bounding_box();
if (bb) {
o << endl << _canvas->indent() << " bbox: " << bb.get();
o << endl << _canvas->indent() << " CANVAS bbox: " << item_to_canvas (bb.get());
} else {
o << " bbox unset";
}
o << endl;
#endif
ArdourCanvas::dump_depth++;
for (list<Item*>::const_iterator i = _items.begin(); i != _items.end(); ++i) {
o << **i;
}
ArdourCanvas::dump_depth--;
}

View file

@ -32,8 +32,8 @@ Image::Image (Canvas* canvas, Cairo::Format fmt, int width, int height)
DataReady.connect (data_connections, MISSING_INVALIDATOR, boost::bind (&Image::accept_data, this), gui_context()); 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) Image::Image (Item* parent, Cairo::Format fmt, int width, int height)
: Item (group) : Item (parent)
, _format (fmt) , _format (fmt)
, _width (width) , _width (width)
, _height (height) , _height (height)

View file

@ -25,7 +25,6 @@
#include "canvas/canvas.h" #include "canvas/canvas.h"
#include "canvas/debug.h" #include "canvas/debug.h"
#include "canvas/group.h"
#include "canvas/item.h" #include "canvas/item.h"
#include "canvas/scroll_group.h" #include "canvas/scroll_group.h"
@ -33,6 +32,8 @@ using namespace std;
using namespace PBD; using namespace PBD;
using namespace ArdourCanvas; using namespace ArdourCanvas;
int Item::default_items_per_cell = 64;
Item::Item (Canvas* canvas) Item::Item (Canvas* canvas)
: Fill (*this) : Fill (*this)
, Outline (*this) , Outline (*this)
@ -41,12 +42,13 @@ Item::Item (Canvas* canvas)
, _scroll_parent (0) , _scroll_parent (0)
, _visible (true) , _visible (true)
, _bounding_box_dirty (true) , _bounding_box_dirty (true)
, _lut (0)
, _ignore_events (false) , _ignore_events (false)
{ {
DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this)); DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this));
} }
Item::Item (Group* parent) Item::Item (Item* parent)
: Fill (*this) : Fill (*this)
, Outline (*this) , Outline (*this)
, _canvas (parent->canvas()) , _canvas (parent->canvas())
@ -54,6 +56,7 @@ Item::Item (Group* parent)
, _scroll_parent (0) , _scroll_parent (0)
, _visible (true) , _visible (true)
, _bounding_box_dirty (true) , _bounding_box_dirty (true)
, _lut (0)
, _ignore_events (false) , _ignore_events (false)
{ {
DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this)); DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this));
@ -65,7 +68,7 @@ Item::Item (Group* parent)
find_scroll_parent (); find_scroll_parent ();
} }
Item::Item (Group* parent, Duple const& p) Item::Item (Item* parent, Duple const& p)
: Fill (*this) : Fill (*this)
, Outline (*this) , Outline (*this)
, _canvas (parent->canvas()) , _canvas (parent->canvas())
@ -74,6 +77,7 @@ Item::Item (Group* parent, Duple const& p)
, _position (p) , _position (p)
, _visible (true) , _visible (true)
, _bounding_box_dirty (true) , _bounding_box_dirty (true)
, _lut (0)
, _ignore_events (false) , _ignore_events (false)
{ {
DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this)); DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this));
@ -95,6 +99,9 @@ Item::~Item ()
if (_canvas) { if (_canvas) {
_canvas->item_going_away (this, _bounding_box); _canvas->item_going_away (this, _bounding_box);
} }
clear_items (true);
delete _lut;
} }
Duple Duple
@ -350,7 +357,7 @@ Item::unparent ()
} }
void void
Item::reparent (Group* new_parent) Item::reparent (Item* new_parent)
{ {
if (new_parent == _parent) { if (new_parent == _parent) {
return; return;
@ -516,6 +523,7 @@ Item::bounding_box () const
if (_bounding_box_dirty) { if (_bounding_box_dirty) {
compute_bounding_box (); compute_bounding_box ();
assert (!_bounding_box_dirty); assert (!_bounding_box_dirty);
add_child_bounding_boxes ();
} }
return _bounding_box; return _bounding_box;
@ -626,30 +634,6 @@ Item::set_ignore_events (bool ignore)
_ignore_events = ignore; _ignore_events = ignore;
} }
void
Item::dump (ostream& o) const
{
boost::optional<ArdourCanvas::Rect> bb = bounding_box();
o << _canvas->indent() << whatami() << ' ' << this << " Visible ? " << _visible;
o << " @ " << position();
#ifdef CANVAS_DEBUG
if (!name.empty()) {
o << ' ' << name;
}
#endif
if (bb) {
o << endl << _canvas->indent() << "\tbbox: " << bb.get();
o << endl << _canvas->indent() << "\tCANVAS bbox: " << item_to_canvas (bb.get());
} else {
o << " bbox unset";
}
o << endl;
}
std::string std::string
Item::whatami () const Item::whatami () const
{ {
@ -687,6 +671,276 @@ Item::covers (Duple const & point) const
return r.get().contains (p); return r.get().contains (p);
} }
/* nesting/grouping API */
void
Item::add_child_bounding_boxes() const
{
boost::optional<Rect> self;
Rect bbox;
bool have_one = false;
if (_bounding_box) {
bbox = _bounding_box.get();
have_one = true;
}
for (list<Item*>::const_iterator i = _items.begin(); i != _items.end(); ++i) {
boost::optional<Rect> item_bbox = (*i)->bounding_box ();
if (!item_bbox) {
continue;
}
Rect group_bbox = (*i)->item_to_parent (item_bbox.get ());
if (have_one) {
bbox = bbox.extend (group_bbox);
} else {
bbox = group_bbox;
have_one = true;
}
}
if (!have_one) {
_bounding_box = boost::optional<Rect> ();
} else {
_bounding_box = bbox;
}
}
void
Item::add (Item* i)
{
/* XXX should really notify canvas about this */
_items.push_back (i);
i->reparent (this);
invalidate_lut ();
_bounding_box_dirty = true;
}
void
Item::remove (Item* i)
{
if (i->parent() != this) {
return;
}
/* we cannot call bounding_box() here because that will iterate over
_items, one of which (the argument, i) may be in the middle of
deletion, making it impossible to call compute_bounding_box()
on it.
*/
if (_bounding_box) {
_pre_change_bounding_box = _bounding_box;
} else {
_pre_change_bounding_box = Rect();
}
i->unparent ();
_items.remove (i);
invalidate_lut ();
_bounding_box_dirty = true;
end_change ();
}
void
Item::clear (bool with_delete)
{
begin_change ();
clear_items (with_delete);
invalidate_lut ();
_bounding_box_dirty = true;
end_change ();
}
void
Item::clear_items (bool with_delete)
{
for (list<Item*>::iterator i = _items.begin(); i != _items.end(); ) {
list<Item*>::iterator tmp = i;
Item *item = *i;
++tmp;
/* remove from list before doing anything else, because we
* don't want to find the item in _items during any activity
* driven by unparent-ing or deletion.
*/
_items.erase (i);
item->unparent ();
if (with_delete) {
delete item;
}
i = tmp;
}
}
void
Item::raise_child_to_top (Item* i)
{
if (!_items.empty()) {
if (_items.back() == i) {
return;
}
}
_items.remove (i);
_items.push_back (i);
invalidate_lut ();
}
void
Item::raise_child (Item* i, int levels)
{
list<Item*>::iterator j = find (_items.begin(), _items.end(), i);
assert (j != _items.end ());
++j;
_items.remove (i);
while (levels > 0 && j != _items.end ()) {
++j;
--levels;
}
_items.insert (j, i);
invalidate_lut ();
}
void
Item::lower_child_to_bottom (Item* i)
{
if (!_items.empty()) {
if (_items.front() == i) {
return;
}
}
_items.remove (i);
_items.push_front (i);
invalidate_lut ();
}
void
Item::ensure_lut () const
{
if (!_lut) {
_lut = new DumbLookupTable (*this);
}
}
void
Item::invalidate_lut () const
{
delete _lut;
_lut = 0;
}
void
Item::child_changed ()
{
invalidate_lut ();
_bounding_box_dirty = true;
if (_parent) {
_parent->child_changed ();
}
}
void
Item::add_items_at_point (Duple const point, vector<Item const *>& items) const
{
boost::optional<Rect> const bbox = bounding_box ();
/* Point is in window coordinate system */
if (!bbox || !item_to_window (bbox.get()).contains (point)) {
return;
}
/* recurse and add any items within our group that contain point */
vector<Item*> our_items;
if (!_items.empty()) {
ensure_lut ();
our_items = _lut->items_at_point (point);
}
if (!our_items.empty() || covers (point)) {
/* this adds this item itself to the list of items at point */
items.push_back (this);
}
for (vector<Item*>::iterator i = our_items.begin(); i != our_items.end(); ++i) {
(*i)->add_items_at_point (point, items);
}
}
void
Item::dump (ostream& o) const
{
boost::optional<ArdourCanvas::Rect> bb = bounding_box();
o << _canvas->indent() << whatami() << ' ' << this << " Visible ? " << _visible;
o << " @ " << position();
#ifdef CANVAS_DEBUG
if (!name.empty()) {
o << ' ' << name;
}
#endif
if (bb) {
o << endl << _canvas->indent() << "\tbbox: " << bb.get();
o << endl << _canvas->indent() << "\tCANVAS bbox: " << item_to_canvas (bb.get());
} else {
o << " bbox unset";
}
o << endl;
if (!_items.empty()) {
#ifdef CANVAS_DEBUG
o << _canvas->indent();
o << " @ " << position();
o << " Items: " << _items.size();
o << " Visible ? " << _visible;
boost::optional<Rect> bb = bounding_box();
if (bb) {
o << endl << _canvas->indent() << " bbox: " << bb.get();
o << endl << _canvas->indent() << " CANVAS bbox: " << item_to_canvas (bb.get());
} else {
o << " bbox unset";
}
o << endl;
#endif
ArdourCanvas::dump_depth++;
for (list<Item*>::const_iterator i = _items.begin(); i != _items.end(); ++i) {
o << **i;
}
ArdourCanvas::dump_depth--;
}
}
ostream& ostream&
ArdourCanvas::operator<< (ostream& o, const Item& i) ArdourCanvas::operator<< (ostream& o, const Item& i)
{ {

View file

@ -34,8 +34,8 @@ Line::Line (Canvas* c)
{ {
} }
Line::Line (Group* group) Line::Line (Item* parent)
: Item (group) : Item (parent)
{ {
} }

View file

@ -38,8 +38,8 @@ LineSet::LineSet (Canvas* c, Orientation o)
} }
LineSet::LineSet (Group* group, Orientation o) LineSet::LineSet (Item* parent, Orientation o)
: Item (group) : Item (parent)
, _extent (0) , _extent (0)
, _orientation (o) , _orientation (o)
{ {

View file

@ -17,14 +17,14 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "canvas/item.h"
#include "canvas/lookup_table.h" #include "canvas/lookup_table.h"
#include "canvas/group.h"
using namespace std; using namespace std;
using namespace ArdourCanvas; using namespace ArdourCanvas;
LookupTable::LookupTable (Group const & group) LookupTable::LookupTable (Item const & item)
: _group (group) : _item (item)
{ {
} }
@ -34,8 +34,8 @@ LookupTable::~LookupTable ()
} }
DumbLookupTable::DumbLookupTable (Group const & group) DumbLookupTable::DumbLookupTable (Item const & item)
: LookupTable (group) : LookupTable (item)
{ {
} }
@ -43,7 +43,7 @@ DumbLookupTable::DumbLookupTable (Group const & group)
vector<Item *> vector<Item *>
DumbLookupTable::get (Rect const &) DumbLookupTable::get (Rect const &)
{ {
list<Item *> const & items = _group.items (); list<Item *> const & items = _item.items ();
vector<Item *> vitems; vector<Item *> vitems;
copy (items.begin(), items.end(), back_inserter (vitems)); copy (items.begin(), items.end(), back_inserter (vitems));
return vitems; return vitems;
@ -54,7 +54,7 @@ DumbLookupTable::items_at_point (Duple const & point) const
{ {
/* Point is in window coordinate system */ /* Point is in window coordinate system */
list<Item *> const & items (_group.items ()); list<Item *> const & items (_item.items ());
vector<Item *> vitems; vector<Item *> vitems;
for (list<Item *>::const_iterator i = items.begin(); i != items.end(); ++i) { for (list<Item *>::const_iterator i = items.begin(); i != items.end(); ++i) {
@ -73,7 +73,7 @@ DumbLookupTable::has_item_at_point (Duple const & point) const
{ {
/* Point is in window coordinate system */ /* Point is in window coordinate system */
list<Item *> const & items (_group.items ()); list<Item *> const & items (_item.items ());
vector<Item *> vitems; vector<Item *> vitems;
for (list<Item *>::const_iterator i = items.begin(); i != items.end(); ++i) { for (list<Item *>::const_iterator i = items.begin(); i != items.end(); ++i) {
@ -92,12 +92,12 @@ DumbLookupTable::has_item_at_point (Duple const & point) const
return false; return false;
} }
OptimizingLookupTable::OptimizingLookupTable (Group const & group, int items_per_cell) OptimizingLookupTable::OptimizingLookupTable (Item const & item, int items_per_cell)
: LookupTable (group) : LookupTable (item)
, _items_per_cell (items_per_cell) , _items_per_cell (items_per_cell)
, _added (false) , _added (false)
{ {
list<Item*> const & items = _group.items (); list<Item*> const & items = _item.items ();
/* number of cells */ /* number of cells */
int const cells = items.size() / _items_per_cell; int const cells = items.size() / _items_per_cell;
@ -109,8 +109,8 @@ OptimizingLookupTable::OptimizingLookupTable (Group const & group, int items_per
_cells[i] = new Cell[_dimension]; _cells[i] = new Cell[_dimension];
} }
/* our group's bounding box in its coordinates */ /* our item's bounding box in its coordinates */
boost::optional<Rect> bbox = _group.bounding_box (); boost::optional<Rect> bbox = _item.bounding_box ();
if (!bbox) { if (!bbox) {
return; return;
} }
@ -130,11 +130,11 @@ OptimizingLookupTable::OptimizingLookupTable (Group const & group, int items_per
continue; continue;
} }
/* and in the group's coordinates */ /* and in the item's coordinates */
Rect const item_bbox_in_group = (*i)->item_to_parent (item_bbox.get ()); Rect const item_bbox_in_item = (*i)->item_to_parent (item_bbox.get ());
int x0, y0, x1, y1; int x0, y0, x1, y1;
area_to_indices (item_bbox_in_group, x0, y0, x1, y1); area_to_indices (item_bbox_in_item, x0, y0, x1, y1);
/* XXX */ /* XXX */
assert (x0 >= 0); assert (x0 >= 0);
@ -147,19 +147,19 @@ OptimizingLookupTable::OptimizingLookupTable (Group const & group, int items_per
//assert (y1 <= _dimension); //assert (y1 <= _dimension);
if (x0 > _dimension) { if (x0 > _dimension) {
cout << "WARNING: item outside bbox by " << (item_bbox_in_group.x0 - bbox.get().x0) << "\n"; cout << "WARNING: item outside bbox by " << (item_bbox_in_item.x0 - bbox.get().x0) << "\n";
x0 = _dimension; x0 = _dimension;
} }
if (x1 > _dimension) { if (x1 > _dimension) {
cout << "WARNING: item outside bbox by " << (item_bbox_in_group.x1 - bbox.get().x1) << "\n"; cout << "WARNING: item outside bbox by " << (item_bbox_in_item.x1 - bbox.get().x1) << "\n";
x1 = _dimension; x1 = _dimension;
} }
if (y0 > _dimension) { if (y0 > _dimension) {
cout << "WARNING: item outside bbox by " << (item_bbox_in_group.y0 - bbox.get().y0) << "\n"; cout << "WARNING: item outside bbox by " << (item_bbox_in_item.y0 - bbox.get().y0) << "\n";
y0 = _dimension; y0 = _dimension;
} }
if (y1 > _dimension) { if (y1 > _dimension) {
cout << "WARNING: item outside bbox by " << (item_bbox_in_group.y1 - bbox.get().y1) << "\n"; cout << "WARNING: item outside bbox by " << (item_bbox_in_item.y1 - bbox.get().y1) << "\n";
y1 = _dimension; y1 = _dimension;
} }
@ -284,7 +284,7 @@ OptimizingLookupTable::has_item_at_point (Duple const & point) const
return false; return false;
} }
/** @param area Area in our owning group's coordinates */ /** @param area Area in our owning item's coordinates */
vector<Item*> vector<Item*>
OptimizingLookupTable::get (Rect const & area) OptimizingLookupTable::get (Rect const & area)
{ {

View file

@ -30,8 +30,8 @@ Pixbuf::Pixbuf (Canvas* c)
{ {
} }
Pixbuf::Pixbuf (Group* g) Pixbuf::Pixbuf (Item* parent)
: Item (g) : Item (parent)
{ {
} }

View file

@ -32,8 +32,8 @@ PolyItem::PolyItem (Canvas* c)
{ {
} }
PolyItem::PolyItem (Group* g) PolyItem::PolyItem (Item* parent)
: Item (g) : Item (parent)
{ {
} }

View file

@ -31,8 +31,8 @@ PolyLine::PolyLine (Canvas* c)
{ {
} }
PolyLine::PolyLine (Group* g) PolyLine::PolyLine (Item* parent)
: PolyItem (g) : PolyItem (parent)
, _threshold (1.0) , _threshold (1.0)
{ {
} }

View file

@ -29,8 +29,8 @@ Polygon::Polygon (Canvas* c)
{ {
} }
Polygon::Polygon (Group* g) Polygon::Polygon (Item* parent)
: PolyItem (g) : PolyItem (parent)
, multiple (0) , multiple (0)
, constant (0) , constant (0)
, cached_size (0) , cached_size (0)

View file

@ -43,14 +43,14 @@ Rectangle::Rectangle (Canvas* c, Rect const & rect)
{ {
} }
Rectangle::Rectangle (Group* g) Rectangle::Rectangle (Item* parent)
: Item (g) : Item (parent)
, _outline_what ((What) (LEFT | RIGHT | TOP | BOTTOM)) , _outline_what ((What) (LEFT | RIGHT | TOP | BOTTOM))
{ {
} }
Rectangle::Rectangle (Group* g, Rect const & rect) Rectangle::Rectangle (Item* parent, Rect const & rect)
: Item (g) : Item (parent)
, _rect (rect) , _rect (rect)
, _outline_what ((What) (LEFT | RIGHT | TOP | BOTTOM)) , _outline_what ((What) (LEFT | RIGHT | TOP | BOTTOM))
{ {

View file

@ -23,8 +23,8 @@
using namespace std; using namespace std;
using namespace ArdourCanvas; using namespace ArdourCanvas;
RootGroup::RootGroup (Canvas* canvas) Root::Root (Canvas* canvas)
: Group (canvas) : Layout (canvas)
{ {
#ifdef CANVAS_DEBUG #ifdef CANVAS_DEBUG
name = "ROOT"; name = "ROOT";
@ -32,11 +32,12 @@ RootGroup::RootGroup (Canvas* canvas)
} }
void void
RootGroup::compute_bounding_box () const Root::compute_bounding_box () const
{ {
Group::compute_bounding_box (); Layout::compute_bounding_box ();
if (_bounding_box) { if (_bounding_box) {
_canvas->request_size (Duple (_bounding_box.get().width (), _bounding_box.get().height ())); Rect r (_bounding_box.get());
_canvas->request_size (Duple (r.width (), r.height ()));
} }
} }

View file

@ -49,8 +49,8 @@ Ruler::Ruler (Canvas* c, const Metric& m, Rect const& r)
{ {
} }
Ruler::Ruler (Group* g, const Metric& m) Ruler::Ruler (Item* parent, const Metric& m)
: Rectangle (g) : Rectangle (parent)
, _metric (m) , _metric (m)
, _lower (0) , _lower (0)
, _upper (0) , _upper (0)
@ -58,8 +58,8 @@ Ruler::Ruler (Group* g, const Metric& m)
{ {
} }
Ruler::Ruler (Group* g, const Metric& m, Rect const& r) Ruler::Ruler (Item* parent, const Metric& m, Rect const& r)
: Rectangle (g, r) : Rectangle (parent, r)
, _metric (m) , _metric (m)
, _lower (0) , _lower (0)
, _upper (0) , _upper (0)

View file

@ -28,13 +28,13 @@ using namespace std;
using namespace ArdourCanvas; using namespace ArdourCanvas;
ScrollGroup::ScrollGroup (Canvas* c, ScrollSensitivity s) ScrollGroup::ScrollGroup (Canvas* c, ScrollSensitivity s)
: Group (c) : Layout (c)
, _scroll_sensitivity (s) , _scroll_sensitivity (s)
{ {
} }
ScrollGroup::ScrollGroup (Group* g, ScrollSensitivity s) ScrollGroup::ScrollGroup (Item* parent, ScrollSensitivity s)
: Group (g) : Layout (parent)
, _scroll_sensitivity (s) , _scroll_sensitivity (s)
{ {
} }
@ -61,11 +61,9 @@ ScrollGroup::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) c
context->rectangle (self.x0, self.y0, self.width(), self.height()); context->rectangle (self.x0, self.y0, self.width(), self.height());
context->clip (); context->clip ();
Group::render (area, context); Layout::render (area, context);
context->restore (); context->restore ();
} }
void void

View file

@ -43,8 +43,8 @@ Text::Text (Canvas* c)
{ {
} }
Text::Text (Group* g) Text::Text (Item* parent)
: Item (g) : Item (parent)
, _color (0x000000ff) , _color (0x000000ff)
, _font_description (0) , _font_description (0)
, _alignment (Pango::ALIGN_LEFT) , _alignment (Pango::ALIGN_LEFT)

View file

@ -76,8 +76,8 @@ WaveView::WaveView (Canvas* c, boost::shared_ptr<ARDOUR::AudioRegion> region)
ClipLevelChanged.connect_same_thread (invalidation_connection, boost::bind (&WaveView::handle_clip_level_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) WaveView::WaveView (Item* parent, boost::shared_ptr<ARDOUR::AudioRegion> region)
: Item (g) : Item (parent)
, _region (region) , _region (region)
, _channel (0) , _channel (0)
, _samples_per_pixel (0) , _samples_per_pixel (0)

View file

@ -36,8 +36,8 @@ Widget::Widget (Canvas* c, CairoWidget& w)
Event.connect (sigc::mem_fun (*this, &Widget::event_proxy)); Event.connect (sigc::mem_fun (*this, &Widget::event_proxy));
} }
Widget::Widget (Group* g, CairoWidget& w) Widget::Widget (Item* parent, CairoWidget& w)
: Item (g) : Item (parent)
, _widget (w) , _widget (w)
{ {
Event.connect (sigc::mem_fun (*this, &Widget::event_proxy)); Event.connect (sigc::mem_fun (*this, &Widget::event_proxy));

View file

@ -32,13 +32,14 @@ canvas_sources = [
'arrow.cc', 'arrow.cc',
'canvas.cc', 'canvas.cc',
'circle.cc', 'circle.cc',
'container.cc',
'curve.cc', 'curve.cc',
'debug.cc', 'debug.cc',
'item.cc', 'item.cc',
'fill.cc', 'fill.cc',
'flag.cc', 'flag.cc',
'group.cc',
'image.cc', 'image.cc',
'layout.cc',
'line.cc', 'line.cc',
'line_set.cc', 'line_set.cc',
'lookup_table.cc', 'lookup_table.cc',

View file

@ -48,8 +48,8 @@ XFadeCurve::XFadeCurve (Canvas* c, XFadePosition pos)
{ {
} }
XFadeCurve::XFadeCurve (Group* g) XFadeCurve::XFadeCurve (Item* parent)
: Item (g) : Item (parent)
, points_per_segment (32) , points_per_segment (32)
, _xfadeposition (Start) , _xfadeposition (Start)
, _outline_color (0x000000ff) , _outline_color (0x000000ff)
@ -57,8 +57,8 @@ XFadeCurve::XFadeCurve (Group* g)
{ {
} }
XFadeCurve::XFadeCurve (Group* g, XFadePosition pos) XFadeCurve::XFadeCurve (Item* parent, XFadePosition pos)
: Item (g) : Item (parent)
, points_per_segment (32) , points_per_segment (32)
, _xfadeposition (pos) , _xfadeposition (pos)
, _outline_color (0x000000ff) , _outline_color (0x000000ff)