fix LTC slave latency compensation typo
[ardour.git] / gtk2_ardour / editor_regions.cc
index cfc56a30823c0dc7d8bf8dbc65dd2306b6990cc4..bb9b0cf8d96b6e5c3e40166eba6c95bd0aa4dd92 100644 (file)
 
 #include "ardour/audioregion.h"
 #include "ardour/audiofilesource.h"
+#include "ardour/silentfilesource.h"
 #include "ardour/region_factory.h"
 #include "ardour/session.h"
-#include "ardour/session_playlists.h"
-#include "ardour/silentfilesource.h"
 #include "ardour/profile.h"
 
 #include "gtkmm2ext/choice.h"
@@ -48,6 +47,7 @@
 #include "utils.h"
 #include "editor_regions.h"
 #include "editor_drag.h"
+#include "main_clock.h"
 
 #include "i18n.h"
 
@@ -78,8 +78,8 @@ EditorRegions::EditorRegions (Editor* e)
        , expanded (false)
 {
        _display.set_size_request (100, -1);
-       _display.set_name ("RegionListDisplay");
        _display.set_rules_hint (true);
+       _display.set_name ("LHSList");
 
        /* Try to prevent single mouse presses from initiating edits.
           This relies on a hack in gtktreeview.c:gtk_treeview_button_press()
@@ -109,12 +109,12 @@ EditorRegions::EditorRegions (Editor* e)
 
        ColumnInfo ci[] = {
                { 0, _("Region"), _("Region name, with number of channels in []'s") },
-               { 1, _("Position"),  _("Length of the region") },
-               { 2, _("End"),  _("Length of the region") },
-               { 3, _("End"),  _("Length of the region") },
+               { 1, _("Position"),  _("Position of start of region") },
+               { 2, _("End"),  _("Position of end of region") },
+               { 3, _("Length"),  _("Length of the region") },
                { 4, _("Sync"),  _("Position of region sync point, relative to start of the region") },
-               { 5, _("Sync"),  _("Region fade-in enabled?") },
-               { 6, _("Fade In"),  _("Region fade-out enabled?") },
+               { 5, _("Fade In"),  _("Length of region fade-in (units: secondary clock), () if disabled") },
+               { 6, _("Fade Out"),  _("Length of region fade-out (units: secondary clock), () if dsisabled") },
                { 7, _("L"),  _("Region position locked?") },
                { 8, _("G"),  _("Region position glued to Bars|Beats time?") },
                { 9, _("M"),  _("Region muted?") },
@@ -128,10 +128,15 @@ EditorRegions::EditorRegions (Editor* e)
                ARDOUR_UI::instance()->set_tip (*l, ci[i].tooltip);
                col->set_widget (*l);
                l->show ();
+
+               if (ci[i].index > 6) {
+                       col->set_expand (false);
+                       col->set_alignment (ALIGN_CENTER);
+               } 
        }
 
        _display.set_headers_visible (true);
-       //_display.set_grid_lines (TREE_VIEW_GRID_LINES_BOTH);
+       _display.set_rules_hint ();
 
        /* show path as the row tooltip */
        _display.set_tooltip_column (14); /* path */
@@ -144,10 +149,10 @@ EditorRegions::EditorRegions (Editor* e)
        _display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorRegions::selection_filter));
 
        TreeViewColumn* tv_col = _display.get_column(0);
-       tv_col->set_resizable (true);
        CellRendererText* renderer = dynamic_cast<CellRendererText*>(_display.get_column_cell_renderer (0));
        tv_col->add_attribute(renderer->property_text(), _columns.name);
        tv_col->add_attribute(renderer->property_foreground_gdk(), _columns.color_);
+       tv_col->set_expand (true);
 
        CellRendererToggle* locked_cell = dynamic_cast<CellRendererToggle*> (_display.get_column_cell_renderer (7));
        locked_cell->property_activatable() = true;
@@ -180,17 +185,6 @@ EditorRegions::EditorRegions (Editor* e)
        _display.get_selection()->set_mode (SELECTION_MULTIPLE);
        _display.add_object_drag (_columns.region.index(), "regions");
 
-
-       /* only the first column (Region name) is resizable */
-
-       for (int i = 1; ; ++i) {
-               TreeViewColumn* col = _display.get_column (i);
-               if (!col) {
-                       break;
-               } 
-               col->set_resizable (false);
-       }
-
        /* setup DnD handling */
 
        list<TargetEntry> region_list_target_table;
@@ -219,11 +213,11 @@ EditorRegions::EditorRegions (Editor* e)
 
        //ARDOUR_UI::instance()->secondary_clock.mode_changed.connect (sigc::mem_fun(*this, &Editor::redisplay_regions));
        ARDOUR_UI::instance()->secondary_clock->mode_changed.connect (sigc::mem_fun(*this, &EditorRegions::update_all_rows));
-       ARDOUR::Region::RegionPropertyChanged.connect (region_property_connection, MISSING_INVALIDATOR, ui_bind (&EditorRegions::region_changed, this, _1, _2), gui_context());
-       ARDOUR::RegionFactory::CheckNewRegion.connect (check_new_region_connection, MISSING_INVALIDATOR, ui_bind (&EditorRegions::add_region, this, _1), gui_context());
+       ARDOUR::Region::RegionPropertyChanged.connect (region_property_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::region_changed, this, _1, _2), gui_context());
+       ARDOUR::RegionFactory::CheckNewRegion.connect (check_new_region_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::add_region, this, _1), gui_context());
 
-       e->EditorFreeze.connect (editor_freeze_connection, MISSING_INVALIDATOR, ui_bind (&EditorRegions::freeze_tree_model, this), gui_context());
-       e->EditorThaw.connect (editor_thaw_connection, MISSING_INVALIDATOR, ui_bind (&EditorRegions::thaw_tree_model, this), gui_context());
+       e->EditorFreeze.connect (editor_freeze_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::freeze_tree_model, this), gui_context());
+       e->EditorThaw.connect (editor_thaw_connection, MISSING_INVALIDATOR, boost::bind (&EditorRegions::thaw_tree_model, this), gui_context());
 }
 
 bool
@@ -310,7 +304,6 @@ EditorRegions::add_region (boost::shared_ptr<Region> region)
 
                TreeModel::iterator iter = _model->get_iter ("0");
                TreeModel::Row parent;
-               TreeModel::Row child;
 
                if (!iter) {
                        parent = *(_model->append());
@@ -492,6 +485,8 @@ EditorRegions::region_changed (boost::shared_ptr<Region> r, const PropertyChange
        our_interests.add (ARDOUR::Properties::opaque);
        our_interests.add (ARDOUR::Properties::fade_in);
        our_interests.add (ARDOUR::Properties::fade_out);
+       our_interests.add (ARDOUR::Properties::fade_in_active);
+       our_interests.add (ARDOUR::Properties::fade_out_active);
 
        if (what_changed.contains (our_interests)) {
 
@@ -555,7 +550,7 @@ EditorRegions::selection_changed ()
 
                for (TreeView::Selection::ListHandle_Path::iterator i = rows.begin(); i != rows.end(); ++i) {
 
-                       if (iter = _model->get_iter (*i)) {
+                       if ((iter = _model->get_iter (*i))) {
                                boost::shared_ptr<Region> region = (*iter)[_columns.region];
 
                                // they could have clicked on a row that is just a placeholder, like "Hidden"
@@ -693,7 +688,7 @@ EditorRegions::update_all_rows ()
 }
 
 void
-EditorRegions::format_position (framepos_t pos, char* buf, size_t bufsize)
+EditorRegions::format_position (framepos_t pos, char* buf, size_t bufsize, bool onoff)
 {
        Timecode::BBT_Time bbt;
        Timecode::Time timecode;
@@ -701,7 +696,11 @@ EditorRegions::format_position (framepos_t pos, char* buf, size_t bufsize)
        switch (ARDOUR_UI::instance()->secondary_clock->mode ()) {
        case AudioClock::BBT:
                _session->tempo_map().bbt_time (pos, bbt);
-               snprintf (buf, bufsize, "%03d|%02d|%04d" , bbt.bars, bbt.beats, bbt.ticks);
+               if (onoff) {
+                       snprintf (buf, bufsize, "%03d|%02d|%04d" , bbt.bars, bbt.beats, bbt.ticks);
+               } else {
+                       snprintf (buf, bufsize, "(%03d|%02d|%04d)" , bbt.bars, bbt.beats, bbt.ticks);
+               }
                break;
 
        case AudioClock::MinSec:
@@ -716,17 +715,29 @@ EditorRegions::format_position (framepos_t pos, char* buf, size_t bufsize)
                mins = (int) floor (left / (_session->frame_rate() * 60.0f));
                left -= (framecnt_t) floor (mins * _session->frame_rate() * 60.0f);
                secs = left / (float) _session->frame_rate();
-               snprintf (buf, bufsize, "%02d:%02d:%06.3f", hrs, mins, secs);
+               if (onoff) {
+                       snprintf (buf, bufsize, "%02d:%02d:%06.3f", hrs, mins, secs);
+               } else {
+                       snprintf (buf, bufsize, "(%02d:%02d:%06.3f)", hrs, mins, secs);
+               }
                break;
 
        case AudioClock::Frames:
-               snprintf (buf, bufsize, "%" PRId64, pos);
+               if (onoff) {
+                       snprintf (buf, bufsize, "%" PRId64, pos);
+               } else {
+                       snprintf (buf, bufsize, "(%" PRId64 ")", pos);
+               }
                break;
 
        case AudioClock::Timecode:
        default:
                _session->timecode_time (pos, timecode);
-               snprintf (buf, bufsize, "%02d:%02d:%02d:%02d", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
+               if (onoff) {
+                       snprintf (buf, bufsize, "%02d:%02d:%02d:%02d", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
+               } else {
+                       snprintf (buf, bufsize, "(%02d:%02d:%02d:%02d)", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
+               }
                break;
        }
 }
@@ -858,16 +869,9 @@ EditorRegions::populate_row_fade_in (boost::shared_ptr<Region> region, TreeModel
                if (used > 1) {
                        row[_columns.fadein] = _("Multiple");
                } else {
-
-                       char buf[16];
-                       format_position (audioregion->fade_in()->back()->when, buf, sizeof (buf));
+                       char buf[32];
+                       format_position (audioregion->fade_in()->back()->when, buf, sizeof (buf), audioregion->fade_in_active());
                        row[_columns.fadein] = buf;
-
-                       if (audioregion->fade_in_active()) {
-                               row[_columns.fadein] = string_compose("%1%2%3", " ", buf, " ");
-                       } else {
-                               row[_columns.fadein] = string_compose("%1%2%3", "(", buf, ")");
-                       }
                }
        }
 }
@@ -881,14 +885,9 @@ EditorRegions::populate_row_fade_out (boost::shared_ptr<Region> region, TreeMode
                if (used > 1) {
                        row[_columns.fadeout] = _("Multiple");
                } else {
-                       char buf[16];
-                       format_position (audioregion->fade_out()->back()->when, buf, sizeof (buf));
-
-                       if (audioregion->fade_out_active()) {
-                               row[_columns.fadeout] = string_compose("%1%2%3", " ", buf, " ");
-                       } else {
-                               row[_columns.fadeout] = string_compose("%1%2%3", "(", buf, ")");
-                       }
+                       char buf[32];
+                       format_position (audioregion->fade_out()->back()->when, buf, sizeof (buf), audioregion->fade_out_active());
+                       row[_columns.fadeout] = buf;
                }
        }
 }