catch markers as they go away, to avoid selection corruption; add select-range-betwee...
[ardour.git] / gtk2_ardour / marker.cc
index 4065ad978be5a00ed61b61034fb34368ec81ba8f..505e577c4288d5ae8356efebd1de462400ee4db4 100644 (file)
@@ -250,9 +250,9 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con
        delete font;
        
        if (annotate_left) {
-         text->property_x() = -(text->property_text_width());
+               text->property_x() = -(text->property_text_width());
        } else {
-         text->property_x() = label_offset;
+               text->property_x() = label_offset;
        }
        text->property_y() = 0.0;
        text->property_anchor() = Gtk::ANCHOR_NW;
@@ -266,14 +266,59 @@ Marker::Marker (PublicEditor& ed, ArdourCanvas::Group& parent, guint32 rgba, con
                group->signal_event().connect (bind (mem_fun (editor, &PublicEditor::canvas_marker_event), mark, this));
        }
 
+       line = 0;
+       line_points = 0;
+
 }
 
 Marker::~Marker ()
 {
+       drop_references ();
+
        /* destroying the parent group destroys its contents, namely any polygons etc. that we added */
        delete text;
        delete mark;
        delete points;
+
+       if (line) {
+               delete line;
+               delete line_points;
+       }
+}
+
+void
+Marker::add_line (ArdourCanvas::Group* group, double initial_height)
+{
+       if (!line) {
+
+               line_points = new ArdourCanvas::Points ();
+               line_points->push_back (Gnome::Art::Point (unit_position + shift, 0.0));
+               line_points->push_back (Gnome::Art::Point (unit_position + shift, initial_height));                     
+               
+               line = new ArdourCanvas::Line (*group);
+               line->property_width_pixels() = 1;
+               line->property_points() = *line_points;
+               line->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_EditPoint.get();
+       }
+
+       show_line ();
+}
+
+void
+Marker::show_line ()
+{
+       if (line) {
+               line->raise_to_top();
+               line->show ();
+       }
+}
+
+void 
+Marker::hide_line ()
+{
+       if (line) {
+               line->hide ();
+       }
 }
 
 ArdourCanvas::Item&
@@ -299,6 +344,12 @@ Marker::set_position (nframes_t frame)
        group->move (new_unit_position - unit_position, 0.0);
        frame_position = frame;
        unit_position = new_unit_position;
+
+       if (line) {
+               (*line_points)[0].set_x (unit_position + shift);
+               (*line_points)[1].set_x (unit_position + shift);
+               line->property_points() = *line_points;
+       }
 }
 
 void