*/
#include "pbd/compose.h"
-#include "pbd/stacktrace.h"
+#include "pbd/demangle.h"
#include "pbd/convert.h"
#include "ardour/utils.h"
, _ignore_events (false)
{
DEBUG_TRACE (DEBUG::CanvasItems, string_compose ("new canvas item %1\n", this));
-}
+}
Item::Item (Item* parent)
: Fill (*this)
}
find_scroll_parent ();
-}
+}
Item::Item (Item* parent, Duple const& p)
: Fill (*this)
find_scroll_parent ();
-}
+}
Item::~Item ()
{
}
Duple
-Item::window_origin () const
+Item::window_origin () const
{
- /* This is slightly subtle. Our _position is in the coordinate space of
+ /* This is slightly subtle. Our _position is in the coordinate space of
our parent. So to find out where that is in window coordinates, we
have to ask our parent.
*/
{
if (_scroll_parent) {
return _scroll_parent->scroll_offset();
- }
+ }
return Duple (0,0);
}
Item::item_to_canvas (Coord& x, Coord& y) const
{
Duple d = item_to_canvas (Duple (x, y));
-
+
x = d.x;
y = d.y;
}
*/
pre_change_parent_bounding_box = item_to_parent (bbox.get());
}
-
+
_position = p;
/* only update canvas and parent if visible. Otherwise, this
will be done when ::show() is called.
*/
-
+
if (visible()) {
_canvas->item_moved (this, pre_change_parent_bounding_box);
-
+
if (_parent) {
_parent->child_changed ();
}
}
-
+
propagate_show_hide ();
}
}
Item::propagate_show_hide ()
{
/* bounding box may have changed while we were hidden */
-
+
if (_parent) {
_parent->child_changed ();
}
-
+
_canvas->item_shown_or_hidden (this);
}
}
i = i->parent();
}
-
+
_scroll_parent = const_cast<ScrollGroup*> (last_scroll_group);
}
uint32_t d2 = other.depth();
const Item* i1 = this;
const Item* i2 = &other;
-
+
/* move towards root until we are at the same level
for both items
*/
return false;
}
}
-
+
return true;
}
i2 = i2->parent ();
}
}
-
+
return i1;
}
}
Coord
-Item::height () const
+Item::height () const
{
boost::optional<ArdourCanvas::Rect> bb = bounding_box();
}
Coord
-Item::width () const
+Item::width () const
{
boost::optional<ArdourCanvas::Rect> bb = bounding_box();
if (visible() && _bounding_box && _canvas) {
_canvas->request_redraw (item_to_window (_bounding_box.get()));
}
-}
+}
void
Item::begin_change ()
{
if (visible()) {
_canvas->item_changed (this, _pre_change_bounding_box);
-
+
if (_parent) {
_parent->child_changed ();
}
if (i == _data.end ()) {
return 0;
}
-
+
return i->second;
}
}
std::string
-Item::whatami () const
+Item::whatami () const
{
std::string type = demangle (typeid (*this).name());
return type.substr (type.find_last_of (':') + 1);
#ifdef CANVAS_DEBUG
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
- cerr << string_compose ("%1%7 %2 @ %7 render %5 @ %6 %3 items out of %4\n",
+ cerr << string_compose ("%1%7 %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,
whatami());
}
#endif
++render_depth;
-
+
for (std::vector<Item*>::const_iterator i = items.begin(); i != items.end(); ++i) {
if (!(*i)->visible ()) {
#endif
continue;
}
-
+
boost::optional<Rect> item_bbox = (*i)->bounding_box ();
if (!item_bbox) {
#endif
continue;
}
-
+
Rect item = (*i)->item_to_window (item_bbox.get(), false);
boost::optional<Rect> d = item.intersection (area);
-
+
if (d) {
Rect draw = d.get();
if (draw.width() && draw.height()) {
if (DEBUG_ENABLED(PBD::DEBUG::CanvasRender)) {
if (dynamic_cast<Container*>(*i) == 0) {
cerr << _canvas->render_indent() << "render "
- << ' '
+ << ' '
<< (*i)
<< ' '
<< (*i)->whatami()
<< (*i)->name
<< " item "
<< item_bbox.get()
- << " window = "
+ << " window = "
<< item
<< " intersect = "
<< draw
- << " @ "
+ << " @ "
<< _position
<< endl;
}
_items.remove (i);
invalidate_lut ();
_bounding_box_dirty = true;
-
+
end_change ();
}
_items.erase (i);
item->unparent ();
-
+
if (with_delete) {
delete item;
}
o << _canvas->indent() << whatami() << ' ' << this << " self-Visible ? " << self_visible() << " visible ? " << visible();
o << " @ " << position();
-
+
#ifdef CANVAS_DEBUG
if (!name.empty()) {
o << ' ' << name;
o << " Items: " << _items.size();
o << " Self-Visible ? " << self_visible();
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--;
}
}