X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmarker.cc;h=22fc535722d51a17282927729bf2f91077201591;hb=965c295451916cf7f04d33fbf41ff2beb573439b;hp=e65446189963d158b2f95b17f7fad2a5c4c21a27;hpb=295b2da733f3080c2a96219bb169829ef4a2c0ce;p=ardour.git diff --git a/gtk2_ardour/marker.cc b/gtk2_ardour/marker.cc index e654461899..22fc535722 100644 --- a/gtk2_ardour/marker.cc +++ b/gtk2_ardour/marker.cc @@ -27,6 +27,8 @@ #include "ardour_ui.h" #include "simpleline.h" +#include + #include "i18n.h" Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, const string& annotation, @@ -35,7 +37,6 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con : editor (ed), _parent(&parent), _type(type) { double label_offset = 0; - bool annotate_left = false; /* Shapes we use: @@ -177,7 +178,6 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con shift = 13; label_offset = 6.0; - annotate_left = true; break; case LoopStart: @@ -200,7 +200,6 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con shift = 13; label_offset = 0.0; - annotate_left = true; break; case PunchIn: @@ -223,7 +222,6 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con shift = 13; label_offset = 0.0; - annotate_left = true; break; } @@ -242,22 +240,22 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con mark->property_fill_color_rgba() = rgba; mark->property_outline_color_rgba() = rgba; mark->property_width_pixels() = 1; - Pango::FontDescription* font = get_font_for_style (N_("MarkerText")); - - text = new Text (*group); - text->property_text() = annotation.c_str(); - text->property_font_desc() = *font; - - delete font; - - if (annotate_left) { - text->property_x() = -(text->property_text_width()); - } else { - text->property_x() = label_offset; - } - text->property_y() = 0.0; - text->property_anchor() = Gtk::ANCHOR_NW; - text->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MarkerLabel.get(); + + /* setup name pixbuf sizes */ + name_font = get_font_for_style (N_("MarkerText")); + + Gtk::Label foo; + Glib::RefPtr layout = foo.create_pango_layout (X_("Hg")); /* ascender + descender */ + int width; + + layout->set_font_description (*name_font); + Gtkmm2ext::get_ink_pixel_size (layout, width, name_height); + + name_pixbuf = new ArdourCanvas::Pixbuf(*group); + name_pixbuf->property_x() = label_offset; + name_pixbuf->property_y() = (13 / 2) - (name_height / 2); + + set_name (annotation.c_str()); editor.ZoomChanged.connect (mem_fun (*this, &Marker::reposition)); @@ -277,7 +275,7 @@ Marker::~Marker () drop_references (); /* destroying the parent group destroys its contents, namely any polygons etc. that we added */ - delete text; + delete name_pixbuf; delete mark; delete points; @@ -345,11 +343,14 @@ Marker::the_item() const } void -Marker::set_name (const string& name) +Marker::set_name (const string& new_name) { - text->property_text() = name.c_str(); - if (_type == End) { - text->property_x() = -(text->property_text_width()); + int name_width = pixel_width (new_name, *name_font) + 2; + + name_pixbuf->property_pixbuf() = pixbuf_from_ustring(new_name, name_font, name_width, name_height); + + if (_type == End || _type == LoopEnd || _type == PunchOut) { + name_pixbuf->property_x() = - (name_width); } }