add functionality for cut tool
[ardour.git] / gtk2_ardour / marker.cc
index 0242ab98b71689c9a21557a90a071f48d0f72f36..af201286a9bd1f53997478ca92982a94ac33a781 100644 (file)
 #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"
 
 using namespace std;
 using namespace ARDOUR;
+using namespace ARDOUR_UI_UTILS;
 using namespace Gtkmm2ext;
 
 PBD::Signal1<void,Marker*> 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,7 +243,7 @@ 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 
@@ -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,29 +328,16 @@ 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 = new ArdourCanvas::Line (editor.get_hscroll_group());
                        _track_canvas_line->set_outline_color (ARDOUR_UI::config()->get_canvasvar_EditPoint());
                        _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);
@@ -360,8 +347,7 @@ Marker::setup_line ()
                _track_canvas_line->show ();
 
        } else {
-               if (_time_bars_line) {
-                       _time_bars_line->hide ();
+               if (_track_canvas_line) {
                        _track_canvas_line->hide ();
                }
        }
@@ -475,8 +461,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 +502,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 +517,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)