mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-15 19:16:40 +01:00
a variety of fixes for the cairocanvas, but it still buggy as hell handling events and lots of other stuff
This commit is contained in:
parent
1267b1d61c
commit
053eaf77fd
9 changed files with 100 additions and 33 deletions
|
|
@ -1,7 +1,10 @@
|
|||
#include <gdk/gdk.h>
|
||||
|
||||
#include <cairomm/cairomm.h>
|
||||
#include <gtkmm/label.h>
|
||||
|
||||
#include "pbd/xml++.h"
|
||||
#include "pbd/stacktrace.h"
|
||||
|
||||
#include "canvas/text.h"
|
||||
#include "canvas/canvas.h"
|
||||
|
|
@ -68,13 +71,6 @@ 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);
|
||||
|
||||
|
|
@ -88,18 +84,29 @@ Text::redraw (Cairo::RefPtr<Cairo::Context> context) const
|
|||
void
|
||||
Text::compute_bounding_box () const
|
||||
{
|
||||
if (!_canvas || !_canvas->context () || _text.empty()) {
|
||||
if (!_canvas || _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);
|
||||
PangoContext* _pc = gdk_pango_context_get ();
|
||||
Glib::RefPtr<Pango::Context> context = Glib::wrap (_pc); // context now owns _pc and will free it
|
||||
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context);
|
||||
|
||||
layout->set_text (_text);
|
||||
layout->set_font_description (*_font_description);
|
||||
layout->set_alignment (_alignment);
|
||||
Pango::Rectangle const r = layout->get_ink_extents ();
|
||||
|
||||
_bounding_box = Rect (
|
||||
r.get_x() / Pango::SCALE,
|
||||
r.get_y() / Pango::SCALE,
|
||||
(r.get_x() + r.get_width()) / Pango::SCALE,
|
||||
(r.get_y() + r.get_height()) / Pango::SCALE
|
||||
);
|
||||
|
||||
_bounding_box_dirty = false;
|
||||
|
||||
cerr << "bbox for " << _text << " = " << _bounding_box << endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -113,8 +120,6 @@ Text::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) cons
|
|||
redraw (context);
|
||||
}
|
||||
|
||||
cerr << " with " << _origin << " and " << _width << " x " << _height << " render " << _text << endl;
|
||||
|
||||
context->set_source (_image, 0, 0);
|
||||
context->rectangle (0, 0, _width, _height);
|
||||
context->fill ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue