Remove internal edit mode and add "content" tool.
[ardour.git] / gtk2_ardour / time_axis_view.cc
index 26939e9c326d212582dd3fb36e06d146177fde79..7130f9de68a87501dcd782eda4c41c2f1282c32b 100644 (file)
@@ -35,6 +35,8 @@
 #include "canvas/canvas.h"
 #include "canvas/rectangle.h"
 #include "canvas/debug.h"
+#include "canvas/utils.h"
+#include "canvas/colors.h"
 
 #include "ardour/profile.h"
 
@@ -113,13 +115,14 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
                compute_heights ();
        }
 
-       _canvas_display = new ArdourCanvas::Container (ed.get_trackview_group (), ArdourCanvas::Duple (0.0, 0.0));
+       _canvas_display = new ArdourCanvas::Container (ed.get_trackview_group ());
        CANVAS_DEBUG_NAME (_canvas_display, "main for TAV");
        _canvas_display->hide(); // reveal as needed
 
-       _canvas_separator = new ArdourCanvas::Line(ed.get_trackview_group ());
+       _canvas_separator = new ArdourCanvas::Line(_canvas_display);
        CANVAS_DEBUG_NAME (_canvas_separator, "separator for TAV");
-       _canvas_separator->set_outline_color(RGBA_TO_UINT (0, 0, 0, 255));
+       _canvas_separator->set (ArdourCanvas::Duple(0.0, 0.0), ArdourCanvas::Duple(ArdourCanvas::COORD_MAX, 0.0));
+       _canvas_separator->set_outline_color(ArdourCanvas::rgba_to_color (0, 0, 0, 1.0));
        _canvas_separator->set_outline_width(1.0);
        _canvas_separator->hide();
 
@@ -216,6 +219,8 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
 
 TimeAxisView::~TimeAxisView()
 {
+       CatchDeletion (this);
+
        in_destructor = true;
 
        for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
@@ -241,9 +246,6 @@ TimeAxisView::~TimeAxisView()
        delete _canvas_display;
        _canvas_display = 0;
 
-       delete _canvas_separator;
-       _canvas_separator = 0;
-
        delete display_menu;
        display_menu = 0;
 
@@ -303,17 +305,13 @@ TimeAxisView::show_at (double y, int& nth, VBox *parent)
        _order = nth;
 
        if (_y_position != y) {
-               _canvas_separator->set (ArdourCanvas::Duple(0, y), ArdourCanvas::Duple(ArdourCanvas::COORD_MAX, y));
-               _canvas_display->set_y_position (y + 1);
+               _canvas_display->set_y_position (y);
                _y_position = y;
        }
 
        _canvas_display->raise_to_top ();
        _canvas_display->show ();
-
-       _canvas_separator->raise_to_top ();
-       _canvas_separator->show ();
-
+       
        _hidden = false;
 
        _effective_height = current_height ();
@@ -329,6 +327,12 @@ TimeAxisView::show_at (double y, int& nth, VBox *parent)
                }
        }
 
+       /* put separator at the bottom of this time axis view */
+
+       _canvas_separator->set (ArdourCanvas::Duple(0, height), ArdourCanvas::Duple(ArdourCanvas::COORD_MAX, height));
+       _canvas_separator->lower_to_bottom ();
+       _canvas_separator->show ();
+
        return _effective_height;
 }
 
@@ -404,9 +408,9 @@ TimeAxisView::controls_ebox_button_press (GdkEventButton* event)
 }
 
 void
-TimeAxisView::idle_resize (uint32_t h)
+TimeAxisView::idle_resize (int32_t h)
 {
-       set_height (h);
+       set_height (std::max(0, h));
 }
 
 
@@ -1018,10 +1022,10 @@ TimeAxisView::get_selection_rect (uint32_t id)
 
                rect = new SelectionRect;
 
-               rect->rect = new ArdourCanvas::Rectangle (selection_group);
+               rect->rect = new ArdourCanvas::TimeRectangle (selection_group);
                CANVAS_DEBUG_NAME (rect->rect, "selection rect");
                rect->rect->set_outline (false);
-               rect->rect->set_fill_color (ARDOUR_UI::config()->get_SelectionRect());
+               rect->rect->set_fill_color (ARDOUR_UI::config()->color_mod ("selection rect", "selection rect"));
 
                rect->start_trim = new ArdourCanvas::Rectangle (selection_group);
                CANVAS_DEBUG_NAME (rect->start_trim, "selection rect start trim");
@@ -1186,26 +1190,26 @@ TimeAxisView::color_handler ()
 
        for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
 
-               (*i)->rect->set_fill_color (ARDOUR_UI::config()->get_SelectionRect());
-               (*i)->rect->set_outline_color (ARDOUR_UI::config()->get_Selection());
+               (*i)->rect->set_fill_color (ARDOUR_UI::config()->color_mod ("selection rect", "selection rect"));
+               (*i)->rect->set_outline_color (ARDOUR_UI::config()->color ("selection"));
 
-               (*i)->start_trim->set_fill_color (ARDOUR_UI::config()->get_Selection());
-               (*i)->start_trim->set_outline_color (ARDOUR_UI::config()->get_Selection());
+               (*i)->start_trim->set_fill_color (ARDOUR_UI::config()->color ("selection"));
+               (*i)->start_trim->set_outline_color (ARDOUR_UI::config()->color ("selection"));
                
-               (*i)->end_trim->set_fill_color (ARDOUR_UI::config()->get_Selection());
-               (*i)->end_trim->set_outline_color (ARDOUR_UI::config()->get_Selection());
+               (*i)->end_trim->set_fill_color (ARDOUR_UI::config()->color ("selection"));
+               (*i)->end_trim->set_outline_color (ARDOUR_UI::config()->color ("selection"));
        }
        
        for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
                
-               (*i)->rect->set_fill_color (ARDOUR_UI::config()->get_SelectionRect());
-               (*i)->rect->set_outline_color (ARDOUR_UI::config()->get_Selection());
+               (*i)->rect->set_fill_color (ARDOUR_UI::config()->color_mod ("selection rect", "selection rect"));
+               (*i)->rect->set_outline_color (ARDOUR_UI::config()->color ("selection"));
                
-               (*i)->start_trim->set_fill_color (ARDOUR_UI::config()->get_Selection());
-               (*i)->start_trim->set_outline_color (ARDOUR_UI::config()->get_Selection());
+               (*i)->start_trim->set_fill_color (ARDOUR_UI::config()->color ("selection"));
+               (*i)->start_trim->set_outline_color (ARDOUR_UI::config()->color ("selection"));
                
-               (*i)->end_trim->set_fill_color (ARDOUR_UI::config()->get_Selection());
-               (*i)->end_trim->set_outline_color (ARDOUR_UI::config()->get_Selection());
+               (*i)->end_trim->set_fill_color (ARDOUR_UI::config()->color ("selection"));
+               (*i)->end_trim->set_outline_color (ARDOUR_UI::config()->color ("selection"));
        }
 }
 
@@ -1310,7 +1314,7 @@ TimeAxisView::preset_height (Height h)
                return button_height + extra_height;
        }
 
-       /* NOTREACHED */
+       abort(); /* NOTREACHED */
        return 0;
 }