X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fexport_timespan_selector.cc;h=cfed17cf5625d5dc60df7bbe585afd7508d38d67;hb=4050ca5633dda03679f9aa9fab87d3bbf517395b;hp=0d815f42ee864b954a2639bd44be2d0119a5735b;hpb=31a2957700be383dd99bb82143bce6505bd4eccc;p=ardour.git diff --git a/gtk2_ardour/export_timespan_selector.cc b/gtk2_ardour/export_timespan_selector.cc index 0d815f42ee..cfed17cf56 100644 --- a/gtk2_ardour/export_timespan_selector.cc +++ b/gtk2_ardour/export_timespan_selector.cc @@ -1,24 +1,32 @@ /* - Copyright (C) 2008 Paul Davis - Author: Sakari Bergen + * Copyright (C) 2008-2013 Sakari Bergen + * Copyright (C) 2008-2017 Paul Davis + * Copyright (C) 2009-2011 Carl Hetherington + * Copyright (C) 2009-2012 David Robillard + * Copyright (C) 2013-2014 Colin Fletcher + * Copyright (C) 2015-2016 Tim Mayberry + * Copyright (C) 2015-2019 Robin Gareus + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ +#include +#include -#include "export_timespan_selector.h" +#include "pbd/enumwriter.h" +#include "pbd/string_convert.h" #include "ardour/location.h" #include "ardour/types.h" @@ -26,11 +34,7 @@ #include "ardour/export_handler.h" #include "ardour/export_timespan.h" -#include "pbd/enumwriter.h" -#include "pbd/string_convert.h" - -#include -#include +#include "export_timespan_selector.h" #include "pbd/i18n.h" @@ -221,42 +225,34 @@ ExportTimespanSelector::construct_label (ARDOUR::Location const * location) cons std::string start; std::string end; - framepos_t start_frame = location->start(); - framepos_t end_frame = location->end(); + samplepos_t start_sample = location->start(); + samplepos_t end_sample = location->end(); switch (state->time_format) { - case AudioClock::BBT: - start = bbt_str (start_frame); - end = bbt_str (end_frame); + case ExportProfileManager::BBT: + start = bbt_str (start_sample); + end = bbt_str (end_sample); break; - case AudioClock::Timecode: - start = timecode_str (start_frame); - end = timecode_str (end_frame); + case ExportProfileManager::Timecode: + start = timecode_str (start_sample); + end = timecode_str (end_sample); break; - case AudioClock::MinSec: - start = ms_str (start_frame); - end = ms_str (end_frame); + case ExportProfileManager::MinSec: + start = ms_str (start_sample); + end = ms_str (end_sample); break; - case AudioClock::Frames: - start = to_string (start_frame); - end = to_string (end_frame); + case ExportProfileManager::Samples: + start = to_string (start_sample); + end = to_string (end_sample); break; } - // label += _("from "); - - // label += ""; label += start; -// label += ""; - label += _(" to "); - -// label += ""; label += end; -// label += ""; return label; } @@ -271,11 +267,11 @@ ExportTimespanSelector::construct_length (ARDOUR::Location const * location) con std::stringstream s; switch (state->time_format) { - case AudioClock::BBT: + case ExportProfileManager::BBT: s << bbt_str (location->length ()); break; - case AudioClock::Timecode: + case ExportProfileManager::Timecode: { Timecode::Time tc; _session->timecode_duration (location->length(), tc); @@ -283,11 +279,11 @@ ExportTimespanSelector::construct_length (ARDOUR::Location const * location) con break; } - case AudioClock::MinSec: + case ExportProfileManager::MinSec: s << ms_str (location->length ()); break; - case AudioClock::Frames: + case ExportProfileManager::Samples: s << location->length (); break; } @@ -297,7 +293,7 @@ ExportTimespanSelector::construct_length (ARDOUR::Location const * location) con std::string -ExportTimespanSelector::bbt_str (framepos_t frames) const +ExportTimespanSelector::bbt_str (samplepos_t samples) const { if (!_session) { return "Error!"; @@ -305,14 +301,14 @@ ExportTimespanSelector::bbt_str (framepos_t frames) const std::ostringstream oss; Timecode::BBT_Time time; - _session->bbt_time (frames, time); + _session->bbt_time (samples, time); print_padded (oss, time); return oss.str (); } std::string -ExportTimespanSelector::timecode_str (framecnt_t frames) const +ExportTimespanSelector::timecode_str (samplecnt_t samples) const { if (!_session) { return "Error!"; @@ -321,7 +317,7 @@ ExportTimespanSelector::timecode_str (framecnt_t frames) const std::ostringstream oss; Timecode::Time time; - _session->timecode_time (frames, time); + _session->timecode_time (samples, time); oss << std::setfill('0') << std::right << std::setw(2) << @@ -337,27 +333,27 @@ ExportTimespanSelector::timecode_str (framecnt_t frames) const } std::string -ExportTimespanSelector::ms_str (framecnt_t frames) const +ExportTimespanSelector::ms_str (samplecnt_t samples) const { if (!_session) { return "Error!"; } std::ostringstream oss; - framecnt_t left; + samplecnt_t left; int hrs; int mins; int secs; int sec_promilles; - left = frames; - hrs = (int) floor (left / (_session->frame_rate() * 60.0f * 60.0f)); - left -= (framecnt_t) floor (hrs * _session->frame_rate() * 60.0f * 60.0f); - mins = (int) floor (left / (_session->frame_rate() * 60.0f)); - left -= (framecnt_t) floor (mins * _session->frame_rate() * 60.0f); - secs = (int) floor (left / (float) _session->frame_rate()); - left -= (framecnt_t) floor ((double)(secs * _session->frame_rate())); - sec_promilles = (int) (left * 1000 / (float) _session->frame_rate() + 0.5); + left = samples; + hrs = (int) floor (left / (_session->sample_rate() * 60.0f * 60.0f)); + left -= (samplecnt_t) floor (hrs * _session->sample_rate() * 60.0f * 60.0f); + mins = (int) floor (left / (_session->sample_rate() * 60.0f)); + left -= (samplecnt_t) floor (mins * _session->sample_rate() * 60.0f); + secs = (int) floor (left / (float) _session->sample_rate()); + left -= (samplecnt_t) floor ((double)(secs * _session->sample_rate())); + sec_promilles = (int) (left * 1000 / (float) _session->sample_rate() + 0.5); oss << std::setfill('0') << std::right << std::setw(2) << @@ -413,6 +409,7 @@ ExportTimespanSelectorSingle::ExportTimespanSelectorSingle (ARDOUR::Session * se range_view.append_column (*label_col); range_view.append_column (_("Length"), range_cols.length); + range_view.append_column (_("Creation Date"), range_cols.date); } void @@ -453,6 +450,11 @@ ExportTimespanSelectorSingle::fill_range_list () row[range_cols.label] = construct_label (*it); row[range_cols.length] = construct_length (*it); + Glib::DateTime gdt(Glib::DateTime::create_now_local ((*it)->timestamp())); + row[range_cols.timestamp] = (*it)->timestamp(); + row[range_cols.date] = gdt.format ("%F %H:%M");; + + add_range_to_selection (*it, false); break; @@ -504,6 +506,12 @@ ExportTimespanSelectorMultiple::ExportTimespanSelectorMultiple (ARDOUR::Session range_view.append_column (*label_col); range_view.append_column (_("Length"), range_cols.length); + range_view.append_column (_("Creation Date"), range_cols.date); + + range_list->set_sort_column(5, Gtk::SORT_DESCENDING); + Gtk::TreeViewColumn* date_col = range_view.get_column(5); // date column + date_col->set_sort_column(7); // set sort as the timestamp + } void @@ -534,6 +542,11 @@ ExportTimespanSelectorMultiple::fill_range_list () row[range_cols.name] = (*it)->name(); row[range_cols.label] = construct_label (*it); row[range_cols.length] = construct_length (*it); + + Glib::DateTime gdt(Glib::DateTime::create_now_local ((*it)->timestamp())); + row[range_cols.timestamp] = (*it)->timestamp(); + row[range_cols.date] = gdt.format ("%F %H:%M");; + } set_selection_from_state ();