2008-09-17 08:56:00 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2008-2013 Sakari Bergen <sakari.bergen@beatwaves.net>
|
|
|
|
* Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2013-2014 Colin Fletcher <colin.m.fletcher@googlemail.com>
|
|
|
|
* Copyright (C) 2015-2016 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
* Copyright (C) 2015-2019 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2008-09-17 08:56:00 -04:00
|
|
|
|
2017-07-16 21:48:18 -04:00
|
|
|
#include <sstream>
|
|
|
|
#include <iomanip>
|
|
|
|
|
|
|
|
#include "pbd/enumwriter.h"
|
|
|
|
#include "pbd/string_convert.h"
|
2008-09-17 08:56:00 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/location.h"
|
|
|
|
#include "ardour/types.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/export_handler.h"
|
|
|
|
#include "ardour/export_timespan.h"
|
|
|
|
|
2021-12-14 15:23:19 -05:00
|
|
|
#include "temporal/tempo.h"
|
|
|
|
|
2017-07-16 21:48:18 -04:00
|
|
|
#include "export_timespan_selector.h"
|
2008-09-17 08:56:00 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2008-09-17 08:56:00 -04:00
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
using namespace Glib;
|
2008-09-17 08:56:00 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
2010-09-14 12:51:02 -04:00
|
|
|
using std::string;
|
2008-09-17 08:56:00 -04:00
|
|
|
|
2016-07-15 20:15:56 -04:00
|
|
|
ExportTimespanSelector::ExportTimespanSelector (ARDOUR::Session * session, ProfileManagerPtr manager, bool multi)
|
|
|
|
: manager (manager)
|
2020-03-05 21:19:50 -05:00
|
|
|
, _realtime_available (false)
|
2022-01-26 16:19:32 -05:00
|
|
|
, time_format_label (_("Show Times as:"), Gtk::ALIGN_START)
|
2016-07-15 20:15:56 -04:00
|
|
|
, realtime_checkbutton (_("Realtime Export"))
|
2008-09-17 08:56:00 -04:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
set_session (session);
|
2008-09-17 08:56:00 -04:00
|
|
|
|
|
|
|
option_hbox.pack_start (time_format_label, false, false, 0);
|
|
|
|
option_hbox.pack_start (time_format_combo, false, false, 6);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-07-15 20:15:56 -04:00
|
|
|
if (multi) {
|
|
|
|
Gtk::Button* b = Gtk::manage (new Gtk::Button (_("Select All")));
|
|
|
|
b->signal_clicked().connect (
|
|
|
|
sigc::bind (
|
|
|
|
sigc::mem_fun (*this, &ExportTimespanSelector::set_selection_state_of_all_timespans), true
|
|
|
|
)
|
|
|
|
);
|
|
|
|
option_hbox.pack_start (*b, false, false, 6);
|
|
|
|
|
|
|
|
b = Gtk::manage (new Gtk::Button (_("Deselect All")));
|
|
|
|
b->signal_clicked().connect (
|
|
|
|
sigc::bind (
|
|
|
|
sigc::mem_fun (*this, &ExportTimespanSelector::set_selection_state_of_all_timespans), false
|
|
|
|
)
|
|
|
|
);
|
|
|
|
option_hbox.pack_start (*b, false, false, 6);
|
|
|
|
}
|
|
|
|
option_hbox.pack_start (realtime_checkbutton, false, false, 6);
|
|
|
|
realtime_checkbutton.set_active (session->config.get_realtime_export ());
|
2020-03-05 21:19:50 -05:00
|
|
|
realtime_checkbutton.set_sensitive (_realtime_available);
|
2016-07-15 20:15:56 -04:00
|
|
|
|
|
|
|
realtime_checkbutton.signal_toggled ().connect (
|
|
|
|
sigc::mem_fun (*this, &ExportTimespanSelector::toggle_realtime)
|
|
|
|
);
|
2011-12-12 19:15:17 -05:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
range_scroller.add (range_view);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
pack_start (option_hbox, false, false, 0);
|
|
|
|
pack_start (range_scroller, true, true, 6);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/*** Combo boxes ***/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
Gtk::TreeModel::iterator iter;
|
|
|
|
Gtk::TreeModel::Row row;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/* Time format combo */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
time_format_list = Gtk::ListStore::create (time_format_cols);
|
|
|
|
time_format_combo.set_model (time_format_list);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
iter = time_format_list->append();
|
|
|
|
row = *iter;
|
2009-10-26 10:38:58 -04:00
|
|
|
row[time_format_cols.format] = ExportProfileManager::Timecode;
|
2011-02-03 10:34:51 -05:00
|
|
|
row[time_format_cols.label] = _("Timecode");
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
iter = time_format_list->append();
|
|
|
|
row = *iter;
|
|
|
|
row[time_format_cols.format] = ExportProfileManager::MinSec;
|
|
|
|
row[time_format_cols.label] = _("Minutes:Seconds");
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2024-05-23 16:26:32 -04:00
|
|
|
#ifndef LIVETRAX
|
2008-09-17 08:56:00 -04:00
|
|
|
iter = time_format_list->append();
|
|
|
|
row = *iter;
|
|
|
|
row[time_format_cols.format] = ExportProfileManager::BBT;
|
|
|
|
row[time_format_cols.label] = _("Bars:Beats");
|
2024-05-23 16:26:32 -04:00
|
|
|
#endif
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
time_format_combo.pack_start (time_format_cols.label);
|
|
|
|
time_format_combo.set_active (0);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
time_format_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportTimespanSelector::change_time_format));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
/* Range view */
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
range_list = Gtk::ListStore::create (range_cols);
|
2013-06-16 13:50:23 -04:00
|
|
|
// order by location start times
|
|
|
|
range_list->set_sort_column(range_cols.location, Gtk::SORT_ASCENDING);
|
|
|
|
range_list->set_sort_func(range_cols.location, sigc::mem_fun(*this, &ExportTimespanSelector::location_sorter));
|
2008-09-17 08:56:00 -04:00
|
|
|
range_view.set_model (range_list);
|
2010-11-04 16:37:46 -04:00
|
|
|
range_view.set_headers_visible (true);
|
2008-09-17 08:56:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ExportTimespanSelector::~ExportTimespanSelector ()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-16 13:50:23 -04:00
|
|
|
int
|
|
|
|
ExportTimespanSelector::location_sorter(Gtk::TreeModel::iterator a, Gtk::TreeModel::iterator b)
|
|
|
|
{
|
|
|
|
Location *l1 = (*a)[range_cols.location];
|
|
|
|
Location *l2 = (*b)[range_cols.location];
|
|
|
|
const Location *ls = _session->locations()->session_range_location();
|
|
|
|
|
|
|
|
// always sort session range first
|
|
|
|
if (l1 == ls)
|
|
|
|
return -1;
|
|
|
|
if (l2 == ls)
|
|
|
|
return +1;
|
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
return l2->start().distance (l1->start()).samples();
|
2013-06-16 13:50:23 -04:00
|
|
|
}
|
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
void
|
2016-07-15 20:15:56 -04:00
|
|
|
ExportTimespanSelector::add_range_to_selection (ARDOUR::Location const * loc, bool rt)
|
2008-09-17 08:56:00 -04:00
|
|
|
{
|
2011-06-11 10:14:24 -04:00
|
|
|
ExportTimespanPtr span = _session->get_export_handler()->add_timespan();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-14 12:51:02 -04:00
|
|
|
std::string id;
|
2013-05-26 13:25:27 -04:00
|
|
|
if (loc == state->selection_range.get()) {
|
2008-09-29 13:01:52 -04:00
|
|
|
id = "selection";
|
2008-09-17 08:56:00 -04:00
|
|
|
} else {
|
2008-09-29 13:01:52 -04:00
|
|
|
id = loc->id().to_s();
|
2008-09-17 08:56:00 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
span->set_range (loc->start().samples(), loc->end().samples());
|
2008-09-29 13:01:52 -04:00
|
|
|
span->set_name (loc->name());
|
|
|
|
span->set_range_id (id);
|
2016-07-15 20:15:56 -04:00
|
|
|
span->set_realtime (rt);
|
2008-09-29 13:01:52 -04:00
|
|
|
state->timespans->push_back (span);
|
2008-09-17 08:56:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-09-29 13:01:52 -04:00
|
|
|
ExportTimespanSelector::set_time_format_from_state ()
|
2008-09-17 08:56:00 -04:00
|
|
|
{
|
|
|
|
Gtk::TreeModel::Children::iterator tree_it;
|
|
|
|
for (tree_it = time_format_list->children().begin(); tree_it != time_format_list->children().end(); ++tree_it) {
|
|
|
|
if (tree_it->get_value (time_format_cols.format) == state->time_format) {
|
|
|
|
time_format_combo.set_active (tree_it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-03-08 06:56:40 -04:00
|
|
|
ExportTimespanSelector::sync_with_manager ()
|
2008-09-17 08:56:00 -04:00
|
|
|
{
|
2009-03-08 06:56:40 -04:00
|
|
|
state = manager->get_timespans().front();
|
2008-09-29 13:01:52 -04:00
|
|
|
fill_range_list ();
|
|
|
|
CriticalSelectionChanged();
|
2008-09-17 08:56:00 -04:00
|
|
|
}
|
|
|
|
|
2016-07-15 20:15:56 -04:00
|
|
|
void
|
|
|
|
ExportTimespanSelector::allow_realtime_export (bool yn)
|
|
|
|
{
|
|
|
|
if (_realtime_available == yn) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_realtime_available = yn;
|
|
|
|
realtime_checkbutton.set_sensitive (_realtime_available);
|
|
|
|
update_timespans ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportTimespanSelector::toggle_realtime ()
|
|
|
|
{
|
|
|
|
const bool realtime = !_session->config.get_realtime_export ();
|
|
|
|
_session->config.set_realtime_export (realtime);
|
|
|
|
realtime_checkbutton.set_inconsistent (false);
|
|
|
|
realtime_checkbutton.set_active (realtime);
|
|
|
|
|
|
|
|
for (Gtk::TreeStore::Children::iterator it = range_list->children().begin(); it != range_list->children().end(); ++it) {
|
|
|
|
it->set_value (range_cols.realtime, realtime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
void
|
|
|
|
ExportTimespanSelector::change_time_format ()
|
|
|
|
{
|
|
|
|
state->time_format = time_format_combo.get_active()->get_value (time_format_cols.format);
|
|
|
|
|
|
|
|
for (Gtk::ListStore::Children::iterator it = range_list->children().begin(); it != range_list->children().end(); ++it) {
|
|
|
|
Location * location = it->get_value (range_cols.location);
|
|
|
|
it->set_value (range_cols.label, construct_label (location));
|
2010-11-04 16:37:46 -04:00
|
|
|
it->set_value (range_cols.length, construct_length (location));
|
2008-09-17 08:56:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-14 12:51:02 -04:00
|
|
|
std::string
|
2008-09-29 13:01:52 -04:00
|
|
|
ExportTimespanSelector::construct_label (ARDOUR::Location const * location) const
|
2008-09-17 08:56:00 -04:00
|
|
|
{
|
2010-09-14 12:51:02 -04:00
|
|
|
std::string label;
|
|
|
|
std::string start;
|
|
|
|
std::string end;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-10-19 14:37:54 -04:00
|
|
|
samplepos_t start_sample = location->start().samples();
|
|
|
|
samplepos_t end_sample = location->end().samples();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
switch (state->time_format) {
|
2017-11-22 14:36:58 -05:00
|
|
|
case ExportProfileManager::BBT:
|
2017-09-18 12:39:17 -04:00
|
|
|
start = bbt_str (start_sample);
|
|
|
|
end = bbt_str (end_sample);
|
2008-09-17 08:56:00 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-11-22 14:36:58 -05:00
|
|
|
case ExportProfileManager::Timecode:
|
2017-09-18 12:39:17 -04:00
|
|
|
start = timecode_str (start_sample);
|
|
|
|
end = timecode_str (end_sample);
|
2008-09-17 08:56:00 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-11-22 14:36:58 -05:00
|
|
|
case ExportProfileManager::MinSec:
|
2017-09-18 12:39:17 -04:00
|
|
|
start = ms_str (start_sample);
|
|
|
|
end = ms_str (end_sample);
|
2008-09-17 08:56:00 -04:00
|
|
|
break;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-11-22 14:36:58 -05:00
|
|
|
case ExportProfileManager::Samples:
|
2017-09-18 12:39:17 -04:00
|
|
|
start = to_string (start_sample);
|
|
|
|
end = to_string (end_sample);
|
2008-09-17 08:56:00 -04:00
|
|
|
break;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
label += start;
|
|
|
|
label += _(" to ");
|
|
|
|
label += end;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
2010-11-04 16:37:46 -04:00
|
|
|
std::string
|
|
|
|
ExportTimespanSelector::construct_length (ARDOUR::Location const * location) const
|
|
|
|
{
|
|
|
|
if (location->length() == 0) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::stringstream s;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2010-11-04 16:37:46 -04:00
|
|
|
switch (state->time_format) {
|
2017-11-22 14:36:58 -05:00
|
|
|
case ExportProfileManager::BBT:
|
2020-10-19 14:37:54 -04:00
|
|
|
s << bbt_str (location->length ().samples());
|
2010-11-04 16:37:46 -04:00
|
|
|
break;
|
|
|
|
|
2017-11-22 14:36:58 -05:00
|
|
|
case ExportProfileManager::Timecode:
|
2010-11-04 16:37:46 -04:00
|
|
|
{
|
|
|
|
Timecode::Time tc;
|
2020-10-19 14:37:54 -04:00
|
|
|
_session->timecode_duration (location->length().samples(), tc);
|
2010-11-04 16:37:46 -04:00
|
|
|
tc.print (s);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-11-22 14:36:58 -05:00
|
|
|
case ExportProfileManager::MinSec:
|
2020-10-19 14:37:54 -04:00
|
|
|
s << ms_str (location->length ().samples());
|
2010-11-04 16:37:46 -04:00
|
|
|
break;
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2017-11-22 14:36:58 -05:00
|
|
|
case ExportProfileManager::Samples:
|
2020-10-19 14:37:54 -04:00
|
|
|
s << location->length ().samples();
|
2010-11-04 16:37:46 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return s.str ();
|
|
|
|
}
|
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
|
2010-09-14 12:51:02 -04:00
|
|
|
std::string
|
2017-09-18 12:39:17 -04:00
|
|
|
ExportTimespanSelector::bbt_str (samplepos_t samples) const
|
2008-09-17 08:56:00 -04:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
if (!_session) {
|
2008-09-17 08:56:00 -04:00
|
|
|
return "Error!";
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
std::ostringstream oss;
|
2020-07-23 19:46:49 -04:00
|
|
|
Temporal::BBT_Time time;
|
2021-12-14 15:23:19 -05:00
|
|
|
time = Temporal::TempoMap::use()->bbt_at (timepos_t (samples));
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2020-07-23 19:46:49 -04:00
|
|
|
time.print_padded (oss);
|
|
|
|
|
2010-11-04 16:37:46 -04:00
|
|
|
return oss.str ();
|
2008-09-17 08:56:00 -04:00
|
|
|
}
|
|
|
|
|
2010-09-14 12:51:02 -04:00
|
|
|
std::string
|
2017-09-18 12:39:17 -04:00
|
|
|
ExportTimespanSelector::timecode_str (samplecnt_t samples) const
|
2008-09-17 08:56:00 -04:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
if (!_session) {
|
2008-09-17 08:56:00 -04:00
|
|
|
return "Error!";
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
std::ostringstream oss;
|
2009-10-26 10:38:58 -04:00
|
|
|
Timecode::Time time;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
_session->timecode_time (samples, time);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
oss << std::setfill('0') << std::right <<
|
|
|
|
std::setw(2) <<
|
|
|
|
time.hours << ":" <<
|
|
|
|
std::setw(2) <<
|
|
|
|
time.minutes << ":" <<
|
|
|
|
std::setw(2) <<
|
|
|
|
time.seconds << ":" <<
|
|
|
|
std::setw(2) <<
|
|
|
|
time.frames;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
return oss.str();
|
|
|
|
}
|
|
|
|
|
2010-09-14 12:51:02 -04:00
|
|
|
std::string
|
2017-09-18 12:39:17 -04:00
|
|
|
ExportTimespanSelector::ms_str (samplecnt_t samples) const
|
2008-09-17 08:56:00 -04:00
|
|
|
{
|
2009-12-17 13:24:23 -05:00
|
|
|
if (!_session) {
|
2008-09-17 08:56:00 -04:00
|
|
|
return "Error!";
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
std::ostringstream oss;
|
2017-09-18 12:39:17 -04:00
|
|
|
samplecnt_t left;
|
2008-09-17 08:56:00 -04:00
|
|
|
int hrs;
|
|
|
|
int mins;
|
|
|
|
int secs;
|
|
|
|
int sec_promilles;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
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);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
oss << std::setfill('0') << std::right <<
|
|
|
|
std::setw(2) <<
|
|
|
|
hrs << ":" <<
|
|
|
|
std::setw(2) <<
|
|
|
|
mins << ":" <<
|
|
|
|
std::setw(2) <<
|
|
|
|
secs << "." <<
|
|
|
|
std::setw(3) <<
|
|
|
|
sec_promilles;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-17 08:56:00 -04:00
|
|
|
return oss.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-09-14 12:51:02 -04:00
|
|
|
ExportTimespanSelector::update_range_name (std::string const & path, std::string const & new_text)
|
2008-09-17 08:56:00 -04:00
|
|
|
{
|
|
|
|
Gtk::TreeStore::iterator it = range_list->get_iter (path);
|
|
|
|
it->get_value (range_cols.location)->set_name (new_text);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2021-02-16 12:11:24 -05:00
|
|
|
update_timespans ();
|
2008-09-17 08:56:00 -04:00
|
|
|
CriticalSelectionChanged();
|
|
|
|
}
|
2008-09-29 13:01:52 -04:00
|
|
|
|
2011-12-12 19:15:17 -05:00
|
|
|
void
|
|
|
|
ExportTimespanSelector::set_selection_state_of_all_timespans (bool s)
|
|
|
|
{
|
|
|
|
for (Gtk::ListStore::Children::iterator it = range_list->children().begin(); it != range_list->children().end(); ++it) {
|
|
|
|
it->set_value (range_cols.selected, s);
|
|
|
|
}
|
2022-05-12 06:52:43 -04:00
|
|
|
|
|
|
|
update_timespans ();
|
|
|
|
CriticalSelectionChanged ();
|
2011-12-12 19:15:17 -05:00
|
|
|
}
|
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
/*** ExportTimespanSelectorSingle ***/
|
|
|
|
|
2010-09-14 12:51:02 -04:00
|
|
|
ExportTimespanSelectorSingle::ExportTimespanSelectorSingle (ARDOUR::Session * session, ProfileManagerPtr manager, std::string range_id) :
|
2016-07-15 20:15:56 -04:00
|
|
|
ExportTimespanSelector (session, manager, false),
|
2009-12-17 13:24:23 -05:00
|
|
|
range_id (range_id)
|
2008-09-29 13:01:52 -04:00
|
|
|
{
|
|
|
|
range_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_NEVER);
|
2019-10-15 16:45:28 -04:00
|
|
|
range_view.append_column_editable (_("RT"), range_cols.realtime); // 0
|
|
|
|
range_view.append_column_editable (_("Range"), range_cols.name); // 1
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-07-15 20:15:56 -04:00
|
|
|
if (Gtk::CellRendererToggle * renderer = dynamic_cast<Gtk::CellRendererToggle *> (range_view.get_column_cell_renderer (0))) {
|
|
|
|
renderer->signal_toggled().connect (sigc::hide (sigc::mem_fun (*this, &ExportTimespanSelectorSingle::update_timespans)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Gtk::CellRendererText * renderer = dynamic_cast<Gtk::CellRendererText *> (range_view.get_column_cell_renderer (1))) {
|
2008-09-29 13:01:52 -04:00
|
|
|
renderer->signal_edited().connect (sigc::mem_fun (*this, &ExportTimespanSelectorSingle::update_range_name));
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
Gtk::CellRendererText * label_render = Gtk::manage (new Gtk::CellRendererText());
|
2011-05-30 20:16:14 -04:00
|
|
|
Gtk::TreeView::Column * label_col = Gtk::manage (new Gtk::TreeView::Column (_("Time Span"), *label_render));
|
2008-09-29 13:01:52 -04:00
|
|
|
label_col->add_attribute (label_render->property_markup(), range_cols.label);
|
2019-10-15 16:45:28 -04:00
|
|
|
range_view.append_column (*label_col); // 2
|
2008-09-29 13:01:52 -04:00
|
|
|
|
2019-10-15 16:45:28 -04:00
|
|
|
range_view.append_column (_("Length"), range_cols.length); // 3
|
|
|
|
range_view.append_column (_("Creation Date"), range_cols.date); // 4
|
2019-08-28 12:27:40 -04:00
|
|
|
|
2019-10-15 16:45:28 -04:00
|
|
|
Gtk::TreeViewColumn* range_col = range_view.get_column (1); // "Range"
|
|
|
|
range_col->set_sort_column (range_cols.name);
|
2019-08-28 12:27:40 -04:00
|
|
|
|
2019-10-15 16:45:28 -04:00
|
|
|
Gtk::TreeViewColumn* time_span_col = range_view.get_column (2); // "Time Span"
|
|
|
|
time_span_col->set_sort_column (range_cols.start);
|
2019-08-28 12:27:40 -04:00
|
|
|
|
2019-10-15 16:45:28 -04:00
|
|
|
Gtk::TreeViewColumn* length_col = range_view.get_column (3); // "Length"
|
|
|
|
length_col->set_sort_column (range_cols.length_actual);
|
2019-08-28 12:27:40 -04:00
|
|
|
|
2019-10-15 16:45:28 -04:00
|
|
|
Gtk::TreeViewColumn* date_col = range_view.get_column (4); // "Creation Date"
|
|
|
|
date_col->set_sort_column (range_cols.timestamp);
|
2008-09-29 13:01:52 -04:00
|
|
|
}
|
|
|
|
|
2016-07-15 20:15:56 -04:00
|
|
|
void
|
|
|
|
ExportTimespanSelectorSingle::allow_realtime_export (bool yn)
|
|
|
|
{
|
|
|
|
ExportTimespanSelector::allow_realtime_export (yn);
|
|
|
|
range_view.get_column (0)->set_visible (_realtime_available);
|
|
|
|
}
|
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
void
|
|
|
|
ExportTimespanSelectorSingle::fill_range_list ()
|
|
|
|
{
|
|
|
|
if (!state) { return; }
|
2016-07-15 20:15:56 -04:00
|
|
|
const bool realtime = _session->config.get_realtime_export ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-09-14 12:51:02 -04:00
|
|
|
std::string id;
|
2013-05-26 13:25:27 -04:00
|
|
|
if (!range_id.compare (X_("selection"))) {
|
2008-09-29 13:01:52 -04:00
|
|
|
id = state->selection_range->id().to_s();
|
|
|
|
} else {
|
|
|
|
id = range_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
range_list->clear();
|
|
|
|
state->timespans->clear();
|
|
|
|
|
|
|
|
Gtk::TreeModel::iterator iter;
|
|
|
|
Gtk::TreeModel::Row row;
|
|
|
|
for (LocationList::const_iterator it = state->ranges->begin(); it != state->ranges->end(); ++it) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
if (!(*it)->id().to_s().compare (id)) {
|
|
|
|
iter = range_list->append();
|
|
|
|
row = *iter;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
row[range_cols.location] = *it;
|
|
|
|
row[range_cols.selected] = true;
|
2016-07-15 20:15:56 -04:00
|
|
|
row[range_cols.realtime] = realtime;
|
2008-09-29 13:01:52 -04:00
|
|
|
row[range_cols.name] = (*it)->name();
|
|
|
|
row[range_cols.label] = construct_label (*it);
|
2010-11-04 16:37:46 -04:00
|
|
|
row[range_cols.length] = construct_length (*it);
|
2019-08-28 12:27:40 -04:00
|
|
|
//the actual samplecnt_t for sorting
|
2020-10-19 14:37:54 -04:00
|
|
|
row[range_cols.length_actual] = (*it)->length().samples();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2019-08-28 15:19:26 -04:00
|
|
|
//start samplecnt_t for sorting
|
2020-10-19 14:37:54 -04:00
|
|
|
row[range_cols.start] = (*it)->start().samples();
|
2019-08-28 15:19:26 -04:00
|
|
|
|
2019-07-22 16:47:17 -04:00
|
|
|
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");;
|
|
|
|
|
|
|
|
|
2016-07-15 20:15:56 -04:00
|
|
|
add_range_to_selection (*it, false);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
set_time_format_from_state();
|
|
|
|
}
|
|
|
|
|
2016-07-15 20:15:56 -04:00
|
|
|
void
|
|
|
|
ExportTimespanSelectorSingle::update_timespans ()
|
|
|
|
{
|
|
|
|
state->timespans->clear();
|
|
|
|
const bool realtime = _session->config.get_realtime_export ();
|
|
|
|
bool inconsistent = false;
|
2020-03-05 21:19:50 -05:00
|
|
|
bool rt_match = false;
|
2016-07-15 20:15:56 -04:00
|
|
|
|
|
|
|
for (Gtk::TreeStore::Children::iterator it = range_list->children().begin(); it != range_list->children().end(); ++it) {
|
|
|
|
add_range_to_selection (it->get_value (range_cols.location), it->get_value (range_cols.realtime) && _realtime_available);
|
|
|
|
if (it->get_value (range_cols.realtime) != realtime) {
|
|
|
|
inconsistent = true;
|
2020-03-05 21:19:50 -05:00
|
|
|
} else {
|
|
|
|
rt_match = true;
|
2016-07-15 20:15:56 -04:00
|
|
|
}
|
|
|
|
}
|
2020-03-05 21:19:50 -05:00
|
|
|
if (!rt_match) {
|
|
|
|
realtime_checkbutton.set_inconsistent (false);
|
|
|
|
realtime_checkbutton.set_active (!realtime);
|
|
|
|
} else {
|
|
|
|
realtime_checkbutton.set_inconsistent (inconsistent);
|
|
|
|
}
|
2016-07-15 20:15:56 -04:00
|
|
|
}
|
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
/*** ExportTimespanSelectorMultiple ***/
|
|
|
|
|
2009-03-08 06:56:40 -04:00
|
|
|
ExportTimespanSelectorMultiple::ExportTimespanSelectorMultiple (ARDOUR::Session * session, ProfileManagerPtr manager) :
|
2016-07-15 20:15:56 -04:00
|
|
|
ExportTimespanSelector (session, manager, true)
|
2008-09-29 13:01:52 -04:00
|
|
|
{
|
|
|
|
range_scroller.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
|
|
|
range_view.append_column_editable ("", range_cols.selected);
|
2016-07-15 20:15:56 -04:00
|
|
|
range_view.append_column_editable (_("RT"), range_cols.realtime);
|
2011-05-30 20:16:14 -04:00
|
|
|
range_view.append_column_editable (_("Range"), range_cols.name);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
if (Gtk::CellRendererToggle * renderer = dynamic_cast<Gtk::CellRendererToggle *> (range_view.get_column_cell_renderer (0))) {
|
|
|
|
renderer->signal_toggled().connect (sigc::hide (sigc::mem_fun (*this, &ExportTimespanSelectorMultiple::update_selection)));
|
|
|
|
}
|
2016-07-15 20:15:56 -04:00
|
|
|
if (Gtk::CellRendererToggle * renderer = dynamic_cast<Gtk::CellRendererToggle *> (range_view.get_column_cell_renderer (1))) {
|
|
|
|
renderer->signal_toggled().connect (sigc::hide (sigc::mem_fun (*this, &ExportTimespanSelectorMultiple::update_selection)));
|
|
|
|
}
|
|
|
|
if (Gtk::CellRendererText * renderer = dynamic_cast<Gtk::CellRendererText *> (range_view.get_column_cell_renderer (2))) {
|
2008-09-29 13:01:52 -04:00
|
|
|
renderer->signal_edited().connect (sigc::mem_fun (*this, &ExportTimespanSelectorMultiple::update_range_name));
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
Gtk::CellRendererText * label_render = Gtk::manage (new Gtk::CellRendererText());
|
2011-05-30 20:16:14 -04:00
|
|
|
Gtk::TreeView::Column * label_col = Gtk::manage (new Gtk::TreeView::Column (_("Time Span"), *label_render));
|
2008-09-29 13:01:52 -04:00
|
|
|
label_col->add_attribute (label_render->property_markup(), range_cols.label);
|
2019-10-15 16:45:28 -04:00
|
|
|
range_view.append_column (*label_col); // 3
|
2008-09-29 13:01:52 -04:00
|
|
|
|
2019-10-15 16:45:28 -04:00
|
|
|
range_view.append_column (_("Length"), range_cols.length); // 4
|
|
|
|
range_view.append_column (_("Creation Date"), range_cols.date); // 5
|
2019-07-22 16:47:17 -04:00
|
|
|
|
2019-10-15 16:45:28 -04:00
|
|
|
Gtk::TreeViewColumn* range_col = range_view.get_column (2); // "Range"
|
|
|
|
range_col->set_sort_column (range_cols.name);
|
2019-08-28 12:27:40 -04:00
|
|
|
|
2019-10-15 16:45:28 -04:00
|
|
|
Gtk::TreeViewColumn* time_span_col = range_view.get_column (3); // "Time Span"
|
|
|
|
time_span_col->set_sort_column (range_cols.start);
|
2019-08-28 12:27:40 -04:00
|
|
|
|
2019-10-15 16:45:28 -04:00
|
|
|
Gtk::TreeViewColumn* length_col = range_view.get_column (4); // "Length"
|
|
|
|
length_col->set_sort_column (range_cols.length_actual);
|
2019-07-22 16:47:17 -04:00
|
|
|
|
2019-10-15 16:45:28 -04:00
|
|
|
Gtk::TreeViewColumn* date_col = range_view.get_column (5); // "Creation Date"
|
|
|
|
date_col->set_sort_column (range_cols.timestamp);
|
2008-09-29 13:01:52 -04:00
|
|
|
}
|
|
|
|
|
2016-07-15 20:15:56 -04:00
|
|
|
void
|
|
|
|
ExportTimespanSelectorMultiple::allow_realtime_export (bool yn)
|
|
|
|
{
|
|
|
|
ExportTimespanSelector::allow_realtime_export (yn);
|
|
|
|
range_view.get_column (1)->set_visible (_realtime_available);
|
|
|
|
}
|
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
void
|
|
|
|
ExportTimespanSelectorMultiple::fill_range_list ()
|
|
|
|
{
|
|
|
|
if (!state) { return; }
|
2016-07-15 20:15:56 -04:00
|
|
|
const bool realtime = _session->config.get_realtime_export ();
|
2008-09-29 13:01:52 -04:00
|
|
|
|
|
|
|
range_list->clear();
|
|
|
|
|
|
|
|
Gtk::TreeModel::iterator iter;
|
|
|
|
Gtk::TreeModel::Row row;
|
|
|
|
for (LocationList::const_iterator it = state->ranges->begin(); it != state->ranges->end(); ++it) {
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
iter = range_list->append();
|
|
|
|
row = *iter;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
row[range_cols.location] = *it;
|
|
|
|
row[range_cols.selected] = false;
|
2016-07-15 20:15:56 -04:00
|
|
|
row[range_cols.realtime] = realtime;
|
2008-09-29 13:01:52 -04:00
|
|
|
row[range_cols.name] = (*it)->name();
|
|
|
|
row[range_cols.label] = construct_label (*it);
|
2010-11-04 16:37:46 -04:00
|
|
|
row[range_cols.length] = construct_length (*it);
|
2019-08-28 12:27:40 -04:00
|
|
|
//the actual samplecnt_t for sorting
|
2020-10-19 14:37:54 -04:00
|
|
|
row[range_cols.length_actual] = (*it)->length().samples();
|
2019-07-22 16:47:17 -04:00
|
|
|
|
2019-08-28 15:19:26 -04:00
|
|
|
//start samplecnt_t for sorting
|
2020-10-19 14:37:54 -04:00
|
|
|
row[range_cols.start] = (*it)->start().samples();
|
2019-08-28 15:19:26 -04:00
|
|
|
|
2019-07-22 16:47:17 -04:00
|
|
|
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");;
|
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
set_selection_from_state ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportTimespanSelectorMultiple::set_selection_from_state ()
|
|
|
|
{
|
|
|
|
Gtk::TreeModel::Children::iterator tree_it;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
for (TimespanList::iterator it = state->timespans->begin(); it != state->timespans->end(); ++it) {
|
2010-09-14 12:51:02 -04:00
|
|
|
string id = (*it)->range_id();
|
2008-09-29 13:01:52 -04:00
|
|
|
for (tree_it = range_list->children().begin(); tree_it != range_list->children().end(); ++tree_it) {
|
|
|
|
Location * loc = tree_it->get_value (range_cols.location);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2013-05-26 13:25:27 -04:00
|
|
|
if ((id == "selection" && loc == state->selection_range.get()) ||
|
|
|
|
(id == loc->id().to_s())) {
|
2008-09-29 13:01:52 -04:00
|
|
|
tree_it->set_value (range_cols.selected, true);
|
2016-07-15 20:15:56 -04:00
|
|
|
tree_it->set_value (range_cols.realtime, (*it)->realtime ());
|
2008-09-29 13:01:52 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
set_time_format_from_state();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportTimespanSelectorMultiple::update_selection ()
|
|
|
|
{
|
|
|
|
update_timespans ();
|
|
|
|
CriticalSelectionChanged ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExportTimespanSelectorMultiple::update_timespans ()
|
|
|
|
{
|
|
|
|
state->timespans->clear();
|
2016-07-15 20:15:56 -04:00
|
|
|
const bool realtime = _session->config.get_realtime_export ();
|
|
|
|
bool inconsistent = false;
|
2020-03-05 21:19:50 -05:00
|
|
|
bool rt_match = false;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2008-09-29 13:01:52 -04:00
|
|
|
for (Gtk::TreeStore::Children::iterator it = range_list->children().begin(); it != range_list->children().end(); ++it) {
|
|
|
|
if (it->get_value (range_cols.selected)) {
|
2016-07-15 20:15:56 -04:00
|
|
|
add_range_to_selection (it->get_value (range_cols.location), it->get_value (range_cols.realtime) && _realtime_available);
|
|
|
|
}
|
|
|
|
if (it->get_value (range_cols.realtime) != realtime) {
|
|
|
|
inconsistent = true;
|
2020-03-05 21:19:50 -05:00
|
|
|
} else {
|
|
|
|
rt_match = true;
|
2008-09-29 13:01:52 -04:00
|
|
|
}
|
|
|
|
}
|
2020-03-05 21:19:50 -05:00
|
|
|
if (!rt_match) {
|
|
|
|
realtime_checkbutton.set_inconsistent (false);
|
|
|
|
realtime_checkbutton.set_active (!realtime);
|
|
|
|
} else {
|
|
|
|
realtime_checkbutton.set_inconsistent (inconsistent);
|
|
|
|
}
|
2008-09-29 13:01:52 -04:00
|
|
|
}
|
|
|
|
|