#include "ardour_ui.h"
#include "simpleline.h"
+#include <gtkmm2ext/utils.h>
+
#include "i18n.h"
Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, const string& annotation,
: editor (ed), _parent(&parent), _type(type)
{
double label_offset = 0;
- bool annotate_left = false;
/* Shapes we use:
shift = 13;
label_offset = 6.0;
- annotate_left = true;
break;
case LoopStart:
shift = 13;
label_offset = 0.0;
- annotate_left = true;
break;
case PunchIn:
shift = 13;
label_offset = 0.0;
- annotate_left = true;
break;
}
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<Pango::Layout> 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));
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;
}
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);
}
}