mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 08:36:32 +01:00
mo' better debugging of canvas "structure" via Item::dump and derivatives
This commit is contained in:
parent
18048747b6
commit
1267b1d61c
5 changed files with 47 additions and 9 deletions
|
|
@ -77,9 +77,9 @@ Canvas::Canvas (XMLTree const * tree)
|
||||||
void
|
void
|
||||||
Canvas::render (Rect const & area, Cairo::RefPtr<Cairo::Context> const & context) const
|
Canvas::render (Rect const & area, Cairo::RefPtr<Cairo::Context> const & context) const
|
||||||
{
|
{
|
||||||
// cerr << "CANVAS @ " << this << endl;
|
cerr << "CANVAS @ " << this << endl;
|
||||||
// dump (cerr);
|
dump (cerr);
|
||||||
// cerr << "-------------------------\n";
|
cerr << "-------------------------\n";
|
||||||
|
|
||||||
checkpoint ("render", "-> render");
|
checkpoint ("render", "-> render");
|
||||||
render_count = 0;
|
render_count = 0;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ public:
|
||||||
void set_alignment (Pango::Alignment);
|
void set_alignment (Pango::Alignment);
|
||||||
|
|
||||||
void set_size_chars (int nchars);
|
void set_size_chars (int nchars);
|
||||||
|
void dump (std::ostream&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _text;
|
std::string _text;
|
||||||
|
|
|
||||||
|
|
@ -342,6 +342,12 @@ Item::dump (ostream& o) const
|
||||||
|
|
||||||
o << _canvas->indent() << whatami() << ' ' << this;
|
o << _canvas->indent() << whatami() << ' ' << this;
|
||||||
|
|
||||||
|
#ifdef CANVAS_DEBUG
|
||||||
|
if (!name.empty()) {
|
||||||
|
o << ' ' << name;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (bb) {
|
if (bb) {
|
||||||
o << endl << _canvas->indent() << "\tbbox: " << bb.get();
|
o << endl << _canvas->indent() << "\tbbox: " << bb.get();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -109,8 +109,8 @@ PolyItem::dump (ostream& o) const
|
||||||
{
|
{
|
||||||
Item::dump (o);
|
Item::dump (o);
|
||||||
|
|
||||||
o << _canvas->indent() << _points.size() << " points" << endl;
|
o << _canvas->indent() << '\t' << _points.size() << " points" << endl;
|
||||||
for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) {
|
for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) {
|
||||||
o << i->x << ", " << i->y << endl;
|
o << _canvas->indent() << "\t\t" << i->x << ", " << i->y << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,9 @@ Text::redraw (Cairo::RefPtr<Cairo::Context> context) const
|
||||||
|
|
||||||
_origin.x = ink_rect.get_x() / Pango::SCALE;
|
_origin.x = ink_rect.get_x() / Pango::SCALE;
|
||||||
_origin.y = ink_rect.get_y() / Pango::SCALE;
|
_origin.y = ink_rect.get_y() / Pango::SCALE;
|
||||||
_width = (ink_rect.get_width() + Pango::SCALE / 2) / Pango::SCALE;
|
|
||||||
_height = (ink_rect.get_height() + Pango::SCALE / 2) / Pango::SCALE;
|
_width = _origin.x + ((ink_rect.get_width() + Pango::SCALE / 2) / Pango::SCALE);
|
||||||
|
_height = _origin.y + ((ink_rect.get_height() + Pango::SCALE / 2) / Pango::SCALE);
|
||||||
|
|
||||||
_image = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, _width, _height);
|
_image = Cairo::ImageSurface::create (Cairo::FORMAT_ARGB32, _width, _height);
|
||||||
|
|
||||||
|
|
@ -67,6 +68,14 @@ Text::redraw (Cairo::RefPtr<Cairo::Context> context) const
|
||||||
/* and draw, in the appropriate color of course */
|
/* and draw, in the appropriate color of course */
|
||||||
|
|
||||||
set_source_rgba (img_context, _color);
|
set_source_rgba (img_context, _color);
|
||||||
|
|
||||||
|
std::cerr << "render " << _text << " as "
|
||||||
|
<< ((_color >> 24) & 0xff) / 255.0
|
||||||
|
<< ((_color >> 16) & 0xff) / 255.0
|
||||||
|
<< ((_color >> 8) & 0xff) / 255.0
|
||||||
|
<< ((_color >> 0) & 0xff) / 255.
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
layout->show_in_cairo_context (img_context);
|
layout->show_in_cairo_context (img_context);
|
||||||
|
|
||||||
/* text has now been rendered in _image and is ready for blit in
|
/* text has now been rendered in _image and is ready for blit in
|
||||||
|
|
@ -79,8 +88,18 @@ Text::redraw (Cairo::RefPtr<Cairo::Context> context) const
|
||||||
void
|
void
|
||||||
Text::compute_bounding_box () const
|
Text::compute_bounding_box () const
|
||||||
{
|
{
|
||||||
_bounding_box = Rect (_origin.x, _origin.y, _origin.x + _width, _origin.y + _height);
|
if (!_canvas || !_canvas->context () || _text.empty()) {
|
||||||
|
_bounding_box = boost::optional<Rect> ();
|
||||||
_bounding_box_dirty = false;
|
_bounding_box_dirty = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
redraw (_canvas->context());
|
||||||
|
|
||||||
|
_bounding_box = Rect (_origin.x, _origin.y, _width - _origin.x, _height - _origin.y);
|
||||||
|
_bounding_box_dirty = false;
|
||||||
|
|
||||||
|
cerr << "bbox for " << _text << " = " << _bounding_box << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -94,6 +113,8 @@ Text::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) cons
|
||||||
redraw (context);
|
redraw (context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cerr << " with " << _origin << " and " << _width << " x " << _height << " render " << _text << endl;
|
||||||
|
|
||||||
context->set_source (_image, 0, 0);
|
context->set_source (_image, 0, 0);
|
||||||
context->rectangle (0, 0, _width, _height);
|
context->rectangle (0, 0, _width, _height);
|
||||||
context->fill ();
|
context->fill ();
|
||||||
|
|
@ -152,3 +173,13 @@ Text::set_color (Color color)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Text::dump (ostream& o) const
|
||||||
|
{
|
||||||
|
Item::dump (o);
|
||||||
|
|
||||||
|
o << _canvas->indent() << '\t' << " text = " << _text << endl
|
||||||
|
<< _canvas->indent() << " color = " << _color;
|
||||||
|
|
||||||
|
o << endl;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue