summaryrefslogtreecommitdiff
path: root/gtk2_ardour/utils.cc
diff options
context:
space:
mode:
authorNick Mainsbridge <beatroute@iprimus.com.au>2009-06-02 17:45:18 +0000
committerNick Mainsbridge <beatroute@iprimus.com.au>2009-06-02 17:45:18 +0000
commit2641231cb2125a0188264e833c6e6e77202910a9 (patch)
treeb29c2b2a8fe70da2637aa3efd92bf7c87df34cb0 /gtk2_ardour/utils.cc
parentbeef5e20ce6402e55c974d6126db8db6c7a13d7c (diff)
Fix memory leak in name text pixbuf generation, move RegionView::_height to TimeAxisViewItem, clean up name_highlight vs name_text code (removes assumpton that one implied the other), fix mouse offset when track resizing past the smallest size, reinstate zooming to 1 frame per pixel.
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5117 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r--gtk2_ardour/utils.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index d4228781de..fc43b4cde7 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -789,3 +789,30 @@ convert_bgra_to_rgba (guint8 const* src,
src_pixel += 4;
}
}
+
+Glib::RefPtr<Gdk::Pixbuf>
+pixbuf_from_ustring(const ustring& name, Pango::FontDescription* font, int clip_width, int clip_height)
+{
+
+ Glib::RefPtr<Gdk::Pixbuf> buf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, clip_width, clip_height);
+ cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, clip_width, clip_height);
+ cairo_t *cr = cairo_create (surface);
+ cairo_text_extents_t te;
+ unsigned char* src = cairo_image_surface_get_data (surface);
+
+ cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
+ cairo_select_font_face (cr, font->get_family().c_str(),
+ CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+ cairo_set_font_size (cr, font->get_size() / Pango::SCALE);
+ cairo_text_extents (cr, name.c_str(), &te);
+
+ cairo_move_to (cr, 0.5, 0.5 - te.height / 2 - te.y_bearing + clip_height / 2);
+ cairo_show_text (cr, name.c_str());
+
+ convert_bgra_to_rgba(src, buf->get_pixels(), clip_width, clip_height);
+
+ delete [] src;
+ cairo_destroy(cr);
+
+ return buf;
+}