X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmarker.cc;h=33135181d5392324d6ebcae4e301291b5a15dc5e;hb=5fef65538040fbac1b9edd1847a269aa925a49c9;hp=0242ab98b71689c9a21557a90a071f48d0f72f36;hpb=f4b5f4c72ee60b6f509e307c5bfd164108d1f30b;p=ardour.git diff --git a/gtk2_ardour/marker.cc b/gtk2_ardour/marker.cc index 0242ab98b7..33135181d5 100644 --- a/gtk2_ardour/marker.cc +++ b/gtk2_ardour/marker.cc @@ -21,11 +21,12 @@ #include "ardour/tempo.h" #include "canvas/rectangle.h" -#include "canvas/group.h" +#include "canvas/container.h" #include "canvas/line.h" #include "canvas/polygon.h" #include "canvas/text.h" #include "canvas/canvas.h" +#include "canvas/scroll_group.h" #include "canvas/debug.h" #include "ardour_ui.h" @@ -46,18 +47,18 @@ using namespace std; using namespace ARDOUR; +using namespace ARDOUR_UI_UTILS; using namespace Gtkmm2ext; PBD::Signal1 Marker::CatchDeletion; static const double marker_height = 13.0; -Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, const string& annotation, +Marker::Marker (PublicEditor& ed, ArdourCanvas::Container& parent, guint32 rgba, const string& annotation, Type type, framepos_t frame, bool handle_events) : editor (ed) , _parent (&parent) - , _time_bars_line (0) , _track_canvas_line (0) , _type (type) , _selected (false) @@ -242,12 +243,12 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con unit_position = editor.sample_to_pixel (frame); unit_position -= _shift; - group = new ArdourCanvas::Group (&parent, ArdourCanvas::Duple (unit_position, 0)); + group = new ArdourCanvas::Container (&parent, ArdourCanvas::Duple (unit_position, 0)); #ifdef CANVAS_DEBUG group->name = string_compose ("Marker::group for %1", annotation); #endif - _name_background = new ArdourCanvas::Rectangle (group); + _name_background = new ArdourCanvas::TimeRectangle (group); #ifdef CANVAS_DEBUG _name_background->name = string_compose ("Marker::_name_background for %1", annotation); #endif @@ -299,11 +300,10 @@ Marker::~Marker () /* destroying the parent group destroys its contents, namely any polygons etc. that we added */ delete group; - delete _time_bars_line; delete _track_canvas_line; } -void Marker::reparent(ArdourCanvas::Group & parent) +void Marker::reparent(ArdourCanvas::Container & parent) { group->reparent (&parent); _parent = &parent; @@ -328,40 +328,26 @@ Marker::setup_line () { if (_shown && (_selected || _line_shown)) { - if (_time_bars_line == 0) { + if (_track_canvas_line == 0) { - _time_bars_line = new ArdourCanvas::Line (editor.get_time_bars_group()); - _time_bars_line->set_outline_color (ARDOUR_UI::config()->get_canvasvar_EditPoint()); - _time_bars_line->Event.connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_marker_event), group, this)); - - _track_canvas_line = new ArdourCanvas::Line (editor.get_track_canvas_group()); - _track_canvas_line->set_outline_color (ARDOUR_UI::config()->get_canvasvar_EditPoint()); + _track_canvas_line = new ArdourCanvas::Line (editor.get_hscroll_group()); + _track_canvas_line->set_outline_color (ARDOUR_UI::config()->color ("edit point")); _track_canvas_line->Event.connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_marker_event), group, this)); } - ArdourCanvas::Duple g = group->item_to_canvas (ArdourCanvas::Duple (0, 0)); - ArdourCanvas::Duple d = _time_bars_line->canvas_to_item (ArdourCanvas::Duple (g.x + _shift, 0)); - - _time_bars_line->set_x0 (d.x); - _time_bars_line->set_x1 (d.x); - _time_bars_line->set_y0 (d.y); - _time_bars_line->set_y1 (ArdourCanvas::COORD_MAX); - _time_bars_line->set_outline_color (_selected ? ARDOUR_UI::config()->get_canvasvar_EditPoint() : _color); - _time_bars_line->raise_to_top (); - _time_bars_line->show (); + ArdourCanvas::Duple g = group->canvas_origin(); + ArdourCanvas::Duple d = _track_canvas_line->canvas_to_item (ArdourCanvas::Duple (g.x + _shift, 0)); - d = _track_canvas_line->canvas_to_item (ArdourCanvas::Duple (g.x + _shift, 0)); _track_canvas_line->set_x0 (d.x); _track_canvas_line->set_x1 (d.x); _track_canvas_line->set_y0 (d.y); _track_canvas_line->set_y1 (ArdourCanvas::COORD_MAX); - _track_canvas_line->set_outline_color (_selected ? ARDOUR_UI::config()->get_canvasvar_EditPoint() : _color); + _track_canvas_line->set_outline_color (_selected ? ARDOUR_UI::config()->color ("edit point") : _color); _track_canvas_line->raise_to_top (); _track_canvas_line->show (); } else { - if (_time_bars_line) { - _time_bars_line->hide (); + if (_track_canvas_line) { _track_canvas_line->hide (); } } @@ -422,11 +408,14 @@ Marker::setup_name_display () _name_item->set (_name); if (label_on_left ()) { + /* adjust right edge of background to fit text */ _name_background->set_x0 (_name_item->position().x - 2); _name_background->set_x1 (_name_item->position().x + name_width + _shift); } else { - _name_background->set_x0 (_name_item->position().x - _label_offset + 2); - _name_background->set_x1 (_name_item->position().x + name_width); + /* right edge remains at zero (group-relative). Add + * arbitrary 4 pixels of extra padding at the end + */ + _name_background->set_x1 (_name_item->position().x + name_width + 4.0); } } @@ -475,8 +464,7 @@ Marker::set_color_rgba (uint32_t c) mark->set_fill_color (_color); mark->set_outline_color (_color); - if (_time_bars_line && !_selected) { - _time_bars_line->set_outline_color (_color); + if (_track_canvas_line && !_selected) { _track_canvas_line->set_outline_color (_color); } @@ -517,7 +505,7 @@ Marker::set_right_label_limit (double p) /***********************************************************************/ -TempoMarker::TempoMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text, +TempoMarker::TempoMarker (PublicEditor& editor, ArdourCanvas::Container& parent, guint32 rgba, const string& text, ARDOUR::TempoSection& temp) : Marker (editor, parent, rgba, text, Tempo, 0, false), _tempo (temp) @@ -532,7 +520,7 @@ TempoMarker::~TempoMarker () /***********************************************************************/ -MeterMarker::MeterMarker (PublicEditor& editor, ArdourCanvas::Group& parent, guint32 rgba, const string& text, +MeterMarker::MeterMarker (PublicEditor& editor, ArdourCanvas::Container& parent, guint32 rgba, const string& text, ARDOUR::MeterSection& m) : Marker (editor, parent, rgba, text, Meter, 0, false), _meter (m)