diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-08 19:48:09 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-08 19:48:09 -0400 |
commit | 1267b1d61cbce8688f3d0f1c4c7932de49735e75 (patch) | |
tree | d8554757715907dda8464b026e467f5832d426b4 /libs/canvas/text.cc | |
parent | 18048747b61017c04399a29fc39d97b652b101e6 (diff) |
mo' better debugging of canvas "structure" via Item::dump and derivatives
Diffstat (limited to 'libs/canvas/text.cc')
-rw-r--r-- | libs/canvas/text.cc | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/libs/canvas/text.cc b/libs/canvas/text.cc index ee15b13ef6..162f814478 100644 --- a/libs/canvas/text.cc +++ b/libs/canvas/text.cc @@ -57,8 +57,9 @@ Text::redraw (Cairo::RefPtr<Cairo::Context> context) const _origin.x = ink_rect.get_x() / 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); @@ -67,6 +68,14 @@ Text::redraw (Cairo::RefPtr<Cairo::Context> context) const /* and draw, in the appropriate color of course */ 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); /* 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 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; + 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 @@ -93,6 +112,8 @@ Text::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) cons if (_need_redraw) { redraw (context); } + + cerr << " with " << _origin << " and " << _width << " x " << _height << " render " << _text << endl; context->set_source (_image, 0, 0); context->rectangle (0, 0, _width, _height); @@ -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; +} |