#include "export_timespan_selector.h"
-#include "ardour_ui.h"
-
-#include "ardour/tempo.h"
#include "ardour/location.h"
#include "ardour/types.h"
#include "ardour/session.h"
option_hbox.pack_start (time_format_label, false, false, 0);
option_hbox.pack_start (time_format_combo, false, false, 6);
+ 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);
+
range_scroller.add (range_view);
pack_start (option_hbox, false, false, 0);
time_format_list = Gtk::ListStore::create (time_format_cols);
time_format_combo.set_model (time_format_list);
- time_format_combo.set_name ("PaddedButton");
iter = time_format_list->append();
row = *iter;
/* Range view */
range_list = Gtk::ListStore::create (range_cols);
+ // 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));
range_view.set_model (range_list);
range_view.set_headers_visible (true);
}
}
+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;
+
+ return l1->start() - l2->start();
+}
+
void
ExportTimespanSelector::add_range_to_selection (ARDOUR::Location const * loc)
{
ExportTimespanPtr span = _session->get_export_handler()->add_timespan();
std::string id;
- if (loc == state->session_range.get()) {
- id = "session";
- } else if (loc == state->selection_range.get()) {
+ if (loc == state->selection_range.get()) {
id = "selection";
} else {
id = loc->id().to_s();
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 (secs * _session->frame_rate());
+ left -= (framecnt_t) floor ((double)(secs * _session->frame_rate()));
sec_promilles = (int) (left * 1000 / (float) _session->frame_rate() + 0.5);
oss << std::setfill('0') << std::right <<
CriticalSelectionChanged();
}
+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);
+ }
+}
+
/*** ExportTimespanSelectorSingle ***/
ExportTimespanSelectorSingle::ExportTimespanSelectorSingle (ARDOUR::Session * session, ProfileManagerPtr manager, std::string range_id) :
if (!state) { return; }
std::string id;
- if (!range_id.compare (X_("session"))) {
- id = state->session_range->id().to_s();
- } else if (!range_id.compare (X_("selection"))) {
+ if (!range_id.compare (X_("selection"))) {
id = state->selection_range->id().to_s();
} else {
id = range_id;
for (tree_it = range_list->children().begin(); tree_it != range_list->children().end(); ++tree_it) {
Location * loc = tree_it->get_value (range_cols.location);
- if ((!id.compare ("session") && loc == state->session_range.get()) ||
- (!id.compare ("selection") && loc == state->selection_range.get()) ||
- (!id.compare (loc->id().to_s()))) {
+ if ((id == "selection" && loc == state->selection_range.get()) ||
+ (id == loc->id().to_s())) {
tree_it->set_value (range_cols.selected, true);
}
}