correct placement of buffering adjustments w.r.t Butler thread creation
[ardour.git] / gtk2_ardour / time_axis_view.cc
index 7ee57b3bb7bd9a9bd2291dc19e93a896cb9a9fb0..9deb7eb3e880946e8c124ed397cde4428c23d6b1 100644 (file)
@@ -27,6 +27,7 @@
 #include "pbd/error.h"
 #include "pbd/convert.h"
 #include "pbd/stacktrace.h"
+#include "pbd/unwind.h"
 
 #include <gtkmm2ext/doi.h>
 #include <gtkmm2ext/utils.h>
@@ -74,11 +75,17 @@ const double trim_handle_size = 6.0; /* pixels */
 uint32_t TimeAxisView::button_height = 0;
 uint32_t TimeAxisView::extra_height = 0;
 int const TimeAxisView::_max_order = 512;
-unsigned int TimeAxisView::name_width_px = 100; // TODO adjust with font-scaling on style-change
+unsigned int TimeAxisView::name_width_px = 100;
 PBD::Signal1<void,TimeAxisView*> TimeAxisView::CatchDeletion;
 Glib::RefPtr<Gtk::SizeGroup> TimeAxisView::controls_meters_size_group = Glib::RefPtr<Gtk::SizeGroup>();
 Glib::RefPtr<Gtk::SizeGroup> TimeAxisView::midi_scroomer_size_group = Glib::RefPtr<Gtk::SizeGroup>();
 
+void
+TimeAxisView::setup_sizes()
+{
+       name_width_px = ceilf (100.f * ARDOUR_UI::ui_scale);
+}
+
 TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisView* rent, Canvas& /*canvas*/)
        : AxisView (sess)
        , controls_table (3, 3)
@@ -96,6 +103,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session* sess, PublicEditor& ed, TimeAxisVie
        , _y_position (0)
        , _editor (ed)
        , name_entry (0)
+       , ending_name_edit (false)
        , control_parent (0)
        , _order (0)
        , _effective_height (0)
@@ -228,16 +236,16 @@ TimeAxisView::~TimeAxisView()
        }
 
        for (list<SelectionRect*>::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) {
-               delete (*i)->rect;
-               delete (*i)->start_trim;
-               delete (*i)->end_trim;
+               delete (*i)->rect; (*i)->rect=0;
+               delete (*i)->start_trim; (*i)->start_trim = 0;
+               delete (*i)->end_trim; (*i)->end_trim = 0;
 
        }
 
        for (list<SelectionRect*>::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) {
-               delete (*i)->rect;
-               delete (*i)->start_trim;
-               delete (*i)->end_trim;
+               delete (*i)->rect; (*i)->rect = 0;
+               delete (*i)->start_trim; (*i)->start_trim = 0;
+               delete (*i)->end_trim; (*i)->end_trim = 0;
        }
 
        delete selection_group;
@@ -562,8 +570,16 @@ TimeAxisView::set_height_enum (Height h, bool apply_to_selection)
 }
 
 void
-TimeAxisView::set_height (uint32_t h)
+TimeAxisView::set_height (uint32_t h, TrackHeightMode m)
 {
+       uint32_t lanes = 0;
+       if (m == TotalHeight) {
+               for (Children::iterator i = children.begin(); i != children.end(); ++i) {
+                       if ( !(*i)->hidden()) ++lanes;
+               }
+       }
+       h /= (lanes + 1);
+
        if (h < preset_height (HeightSmall)) {
                h = preset_height (HeightSmall);
        }
@@ -584,6 +600,12 @@ TimeAxisView::set_height (uint32_t h)
                show_selection (_editor.get_selection().time);
        }
 
+       if (m != OnlySelf) {
+               for (Children::iterator i = children.begin(); i != children.end(); ++i) {
+                       (*i)->set_height(h, OnlySelf);
+               }
+       }
+
        _editor.override_visible_track_count ();
 }
 
@@ -676,6 +698,15 @@ TimeAxisView::end_name_edit (int response)
        if (!name_entry) {
                return;
        }
+
+       if (ending_name_edit) {
+               /* already doing this, and focus out or other event has caused 
+                  us to re-enter this code.
+               */
+               return;
+       }
+       
+       PBD::Unwinder<bool> uw (ending_name_edit, true);
        
        bool edit_next = false;
        bool edit_prev = false;
@@ -1022,10 +1053,10 @@ TimeAxisView::get_selection_rect (uint32_t id)
 
                rect = new SelectionRect;
 
-               rect->rect = new ArdourCanvas::TimeRectangle (selection_group);
+               rect->rect = new ArdourCanvas::Rectangle (selection_group);
                CANVAS_DEBUG_NAME (rect->rect, "selection rect");
                rect->rect->set_outline (false);
-               rect->rect->set_fill_color (ARDOUR_UI::config()->color ("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");
@@ -1082,7 +1113,7 @@ TimeAxisView::remove_child (boost::shared_ptr<TimeAxisView> child)
  *  @param result Filled in with selectable things.
  */
 void
-TimeAxisView::get_selectables (framepos_t /*start*/, framepos_t /*end*/, double /*top*/, double /*bot*/, list<Selectable*>& /*result*/)
+TimeAxisView::get_selectables (framepos_t /*start*/, framepos_t /*end*/, double /*top*/, double /*bot*/, list<Selectable*>& /*result*/, bool /*within*/)
 {
        return;
 }
@@ -1167,7 +1198,7 @@ TimeAxisView::compute_heights ()
 
        window.add (one_row_table);
        test_button->set_name ("mute button");
-       test_button->set_text (_("M"));
+       test_button->set_text (S_("Mute|M"));
        test_button->set_tweaks (ArdourButton::TrackHeader);
 
        one_row_table.set_border_width (border_width);
@@ -1190,26 +1221,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()->color ("SelectionRect"));
-               (*i)->rect->set_outline_color (ARDOUR_UI::config()->color ("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()->color ("Selection"));
-               (*i)->start_trim->set_outline_color (ARDOUR_UI::config()->color ("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()->color ("Selection"));
-               (*i)->end_trim->set_outline_color (ARDOUR_UI::config()->color ("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()->color ("SelectionRect"));
-               (*i)->rect->set_outline_color (ARDOUR_UI::config()->color ("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()->color ("Selection"));
-               (*i)->start_trim->set_outline_color (ARDOUR_UI::config()->color ("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()->color ("Selection"));
-               (*i)->end_trim->set_outline_color (ARDOUR_UI::config()->color ("Selection"));
+               (*i)->end_trim->set_fill_color (ARDOUR_UI::config()->color ("selection"));
+               (*i)->end_trim->set_outline_color (ARDOUR_UI::config()->color ("selection"));
        }
 }