make range+region Bounce dialogs more consistent

* cleaner table layout
* explicit options for bouncing to Trigger and Clip List
* any bounce is added to Source list, so remove that from menu
* format context menus to match "(with processing)"
* use same code structure where possible
This commit is contained in:
Ben Loftis 2022-03-12 11:56:25 -06:00
parent f4940e81ad
commit 2eb286eb76
3 changed files with 186 additions and 108 deletions

View File

@ -1963,11 +1963,10 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
edit_items.push_back (MenuElem (_("Duplicate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_range), false))); edit_items.push_back (MenuElem (_("Duplicate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_range), false)));
edit_items.push_back (SeparatorElem()); edit_items.push_back (SeparatorElem());
edit_items.push_back (MenuElem (_("Consolidate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), ReplaceRange, false))); edit_items.push_back (MenuElem (_("Consolidate"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), ReplaceRange, false)));
edit_items.push_back (MenuElem (_("Consolidate Range with Processing"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), ReplaceRange, true))); edit_items.push_back (MenuElem (_("Consolidate (with processing)"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), ReplaceRange, true)));
edit_items.push_back (MenuElem (_("Bounce Range to Source List"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), NewSource, false))); edit_items.push_back (MenuElem (_("Bounce"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), NewSource, false)));
edit_items.push_back (MenuElem (_("Bounce Range to Source List with Processing"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), NewSource, true))); edit_items.push_back (MenuElem (_("Bounce (with processing)"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), NewSource, true)));
edit_items.push_back (MenuElem (_("Bounce Range to Trigger Clip"), sigc::bind (sigc::mem_fun(*this, &Editor::bounce_range_selection), NewTrigger, false)));
edit_items.push_back (MenuElem (_("Export Range..."), sigc::mem_fun(*this, &Editor::export_selection))); edit_items.push_back (MenuElem (_("Export Range..."), sigc::mem_fun(*this, &Editor::export_selection)));
if (ARDOUR_UI::instance()->video_timeline->get_duration() > 0) { if (ARDOUR_UI::instance()->video_timeline->get_duration() > 0) {
edit_items.push_back (MenuElem (_("Export Video Range..."), sigc::bind (sigc::mem_fun(*(ARDOUR_UI::instance()), &ARDOUR_UI::export_video), true))); edit_items.push_back (MenuElem (_("Export Video Range..."), sigc::bind (sigc::mem_fun(*(ARDOUR_UI::instance()), &ARDOUR_UI::export_video), true)));

View File

@ -275,14 +275,19 @@ Editor::write_region_selection (RegionSelection& regions)
void void
Editor::bounce_region_selection (bool with_processing) Editor::bounce_region_selection (bool with_processing)
{ {
/* this code is largely similar to editor_ops ::bounce_range_selection */
/* no need to check for bounceable() because this operation never puts /* no need to check for bounceable() because this operation never puts
* its results back in the playlist (only in the region list). * its results back in the playlist (only in the region list).
*/ */
/*prompt the user for a new name*/
string bounce_name; string bounce_name;
bool copy_to_clip_library = false; bool copy_to_clip_library = false;
bool copy_to_trigger = false;
uint32_t trigger_slot = 0;
{ {
/*prompt the user for a new name*/
ArdourWidgets::Prompter dialog (true); ArdourWidgets::Prompter dialog (true);
dialog.set_prompt (_("Name for Bounced Region:")); dialog.set_prompt (_("Name for Bounced Region:"));
@ -294,15 +299,46 @@ Editor::bounce_region_selection (bool with_processing)
dialog.add_button (_("Bounce"), RESPONSE_ACCEPT); dialog.add_button (_("Bounce"), RESPONSE_ACCEPT);
dialog.set_initial_text (bounce_name); dialog.set_initial_text (bounce_name);
Gtk::CheckButton cliplib (_("Copy to Clip Libary")); Table* table = manage (new Table);
dialog.get_vbox()->pack_start (cliplib); table->set_spacings (4);
cliplib.show (); table->set_border_width (8);
table->set_homogeneous (true);
dialog.get_vbox()->pack_start (*table);
dialog.get_vbox()->set_spacing (4);
Label label; /* copy to a slot on this track ? */
label.set_text (_("Bounced Region will appear in the Source list.")); Gtk::CheckButton *to_slot = NULL;
dialog.get_vbox()->set_spacing (8); if (!with_processing) {
dialog.get_vbox()->pack_start (label); to_slot = manage (new Gtk::CheckButton (_("Bounce to Trigger Slot:")));
label.show(); Gtk::Alignment *slot_align = manage (new Gtk::Alignment (0, .5, 0, 0));
slot_align->add (*to_slot);
ArdourWidgets::ArdourDropdown *tslot = manage (new ArdourWidgets::ArdourDropdown ());
for (int c = 0; c < default_triggers_per_box; ++c) {
std::string lbl = cue_marker_name (c);
tslot->AddMenuElem (Menu_Helpers::MenuElem (lbl, sigc::bind ([] (uint32_t* t, uint32_t v, ArdourWidgets::ArdourDropdown* s, std::string l) {*t = v; s->set_text (l);}, &trigger_slot, c, tslot, lbl)));
}
tslot->set_active ("A");
HBox *tbox = manage (new HBox());
tbox->pack_start(*slot_align, false, false);
tbox->pack_start(*tslot, false, false);
table->attach (*tbox, 0, 2, 0,1, Gtk::FILL, Gtk::SHRINK);
}
/* copy to the user's Clip Library ? */
Gtk::CheckButton *cliplib = manage (new Gtk::CheckButton (_("Bounce to Clip Libary")));
Gtk::Alignment *align = manage (new Gtk::Alignment (0, .5, 0, 0));
align->add (*cliplib);
align->show_all ();
table->attach (*align, 0, 2, 1,2, Gtk::FILL, Gtk::SHRINK);
/* in all cases, the selected Range will appear in the Source list */
Label* s_label = manage (new Label (_("Bounced Region will appear in the Source list")));
table->attach (*s_label, 0, 2, 2,3, Gtk::FILL, Gtk::SHRINK);
dialog.get_vbox()->show_all ();
dialog.show (); dialog.show ();
@ -313,7 +349,38 @@ Editor::bounce_region_selection (bool with_processing)
return; return;
} }
dialog.get_result(bounce_name); dialog.get_result(bounce_name);
copy_to_clip_library = cliplib.get_active ();
if (to_slot && to_slot->get_active()) {
copy_to_trigger = true;
}
if (cliplib->get_active ()) {
copy_to_clip_library = true;
}
}
/* prevent user from accidentally overwriting a slot that they can't see */
bool overwriting = false;
if (copy_to_trigger) {
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
boost::shared_ptr<Region> region ((*i)->region());
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&(*i)->get_time_axis_view());
boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (rtv->route());
if (!track) {
continue;
}
if (track->triggerbox()->trigger(trigger_slot)->region()) {
overwriting = true;
}
}
if (overwriting) {
ArdourMessageDialog msg (string_compose(_("Are you sure you want to overwrite the contents in slot %1?"),cue_marker_name(trigger_slot)), false, MESSAGE_QUESTION, BUTTONS_YES_NO, true);
msg.set_title (_("Overwriting slot"));
msg.set_secondary_text (_("One of your selected tracks has content in this slot."));
if (msg.run () != RESPONSE_YES) {
return;
}
}
} }
for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) { for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
@ -335,6 +402,16 @@ Editor::bounce_region_selection (bool with_processing)
if (copy_to_clip_library) { if (copy_to_clip_library) {
export_to_clip_library (r); export_to_clip_library (r);
} }
if (copy_to_trigger) {
boost::shared_ptr<Trigger::UIState> state (new Trigger::UIState());
state->name = bounce_name;
//ToDo: can/should we get the tempo for this region?
track->triggerbox ()->enqueue_trigger_state_for_region(r, state);
track->triggerbox ()->set_from_selection (trigger_slot, r);
track->presentation_info ().set_trigger_track (true);
}
} }
} }

View File

@ -4109,17 +4109,37 @@ Editor::freeze_route ()
} }
void void
Editor::bounce_range_selection (BounceTarget target, bool enable_processing) Editor::bounce_range_selection (BounceTarget target, bool with_processing)
{ {
if (selection->time.empty()) { if (selection->time.empty()) {
return; return;
} }
/* you can't currently apply processing to a NewTrigger bounce */ /* you can't currently apply processing to a NewTrigger bounce */
assert (!(enable_processing && (target == NewTrigger))); assert (!(with_processing && (target == NewTrigger)));
bool copy_to_clip_library = false; /* if consolidating a range to this track with processing, make sure the track-count matches */
uint32_t trigger_slot = 0; if (target == ReplaceRange) {
TrackSelection views = selection->tracks;
for (TrackViewList::iterator i = views.begin(); i != views.end(); ++i) {
if (with_processing) {
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
if (rtv && rtv->track() && !rtv->track()->bounceable (rtv->track()->main_outs(), false)) {
ArdourMessageDialog d (
_("You can't perform this operation because the processing of the signal "
"will cause one or more of the tracks to end up with a region with more channels than this track has inputs.\n\n"
"You can do this without processing, which is a different operation.")
);
d.set_title (_("Cannot bounce"));
d.run ();
return;
}
}
}
}
string bounce_name; string bounce_name;
switch (target) { switch (target) {
@ -4133,93 +4153,67 @@ Editor::bounce_range_selection (BounceTarget target, bool enable_processing)
bounce_name = "Unnamed Clip"; bounce_name = "Unnamed Clip";
break; break;
} }
bool copy_to_clip_library = false;
TrackSelection views = selection->tracks; bool copy_to_trigger = false;
uint32_t trigger_slot = 0;
for (TrackViewList::iterator i = views.begin(); i != views.end(); ++i) {
if (enable_processing) {
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
if (rtv && rtv->track() && target == ReplaceRange && !rtv->track()->bounceable (rtv->track()->main_outs(), false)) {
ArdourMessageDialog d (
_("You can't perform this operation because the processing of the signal "
"will cause one or more of the tracks to end up with a region with more channels than this track has inputs.\n\n"
"You can do this without processing, which is a different operation.")
);
d.set_title (_("Cannot bounce"));
d.run ();
return;
}
}
}
/*prompt the user for a new name*/
{ {
Prompter dialog (true); /*prompt the user for a new name*/
ArdourDropdown* tslot = 0;
Gtk::CheckButton* cliplib = 0;
Gtk::Alignment *align = 0;
switch (target) { ArdourWidgets::Prompter dialog (true);
case NewSource:
dialog.set_prompt (_("Name for Bounced Region:")); dialog.set_prompt (_("Name for Bounced Range:"));
dialog.add_button (_("Bounce"), RESPONSE_ACCEPT);
break;
case ReplaceRange:
dialog.set_prompt (_("Name for Consolidated Region:"));
dialog.add_button (_("Rename"), RESPONSE_ACCEPT);
break;
case NewTrigger:
dialog.set_prompt (_("Name for Trigger Clip:"));
dialog.add_button (_("Bounce"), RESPONSE_ACCEPT);
break;
}
dialog.set_name ("BounceNameWindow"); dialog.set_name ("BounceNameWindow");
dialog.set_size_request (400, -1); dialog.set_size_request (400, -1);
dialog.set_position (Gtk::WIN_POS_MOUSE); dialog.set_position (Gtk::WIN_POS_MOUSE);
dialog.add_button (_("Bounce"), RESPONSE_ACCEPT);
dialog.set_initial_text (bounce_name); dialog.set_initial_text (bounce_name);
if (target != ReplaceRange) { Table* table = manage (new Table);
cliplib = manage (new Gtk::CheckButton (_("Copy to Clip Libary"))); table->set_spacings (4);
align = manage (new Gtk::Alignment (0, .5, 0, 0)); table->set_border_width (8);
align->add (*cliplib); table->set_homogeneous (true);
cliplib->show (); dialog.get_vbox()->pack_start (*table);
} dialog.get_vbox()->set_spacing (4);
if (target == NewSource) { /* copy to a slot on this track ? */
Label* label = manage (new Label (_("Bounced Range will appear in the Source list."))); Gtk::CheckButton *to_slot = NULL;
dialog.get_vbox()->set_spacing (8); if (!with_processing) {
dialog.get_vbox()->pack_start (*label); to_slot = manage (new Gtk::CheckButton (_("Bounce to Trigger Slot:")));
dialog.get_vbox()->pack_start (*align); Gtk::Alignment *slot_align = manage (new Gtk::Alignment (0, .5, 0, 0));
label->show(); slot_align->add (*to_slot);
} else if (target == NewTrigger) {
Label* label = manage (new Label (_("Trigger Slot:"))); ArdourWidgets::ArdourDropdown *tslot = manage (new ArdourWidgets::ArdourDropdown ());
label->set_alignment(1.0, 0.5);
HBox* tbox = manage (new HBox);
tslot = manage (new ArdourDropdown ());
for (int c = 0; c < default_triggers_per_box; ++c) { for (int c = 0; c < default_triggers_per_box; ++c) {
std::string lbl = cue_marker_name (c); std::string lbl = cue_marker_name (c);
tslot->AddMenuElem (Menu_Helpers::MenuElem (lbl, sigc::bind ([] (uint32_t* t, uint32_t v, ArdourDropdown* s, std::string l) {*t = v; s->set_text (l);}, &trigger_slot, c, tslot, lbl))); tslot->AddMenuElem (Menu_Helpers::MenuElem (lbl, sigc::bind ([] (uint32_t* t, uint32_t v, ArdourWidgets::ArdourDropdown* s, std::string l) {*t = v; s->set_text (l);}, &trigger_slot, c, tslot, lbl)));
} }
tslot->set_active ("A"); tslot->set_active ("A");
tbox->set_homogeneous (false); HBox *tbox = manage (new HBox());
tbox->set_spacing (5); tbox->pack_start(*slot_align, false, false);
tbox->set_border_width (10); tbox->pack_start(*tslot, false, false);
tbox->pack_start (*label, false, false); table->attach (*tbox, 0, 2, 0,1, Gtk::FILL, Gtk::SHRINK);
tbox->pack_start (*tslot, false, false); if (target==NewTrigger) {
tbox->pack_start (*align, true, true); to_slot->set_active(true);
tbox->show_all (); }
dialog.get_vbox()->pack_start (*tbox);
} else {
dialog.get_vbox()->pack_start (*align);
} }
/* copy to the user's Clip Library ? */
Gtk::CheckButton *cliplib = manage (new Gtk::CheckButton (_("Bounce to Clip Libary")));
Gtk::Alignment *align = manage (new Gtk::Alignment (0, .5, 0, 0));
align->add (*cliplib);
align->show_all ();
table->attach (*align, 0, 2, 1,2, Gtk::FILL, Gtk::SHRINK);
/* in all cases, the selected Range will appear in the Source list */
Label* s_label = manage (new Label (_("Bounced Range will appear in the Source list")));
table->attach (*s_label, 0, 2, 2,3, Gtk::FILL, Gtk::SHRINK);
dialog.get_vbox()->show_all ();
dialog.show (); dialog.show ();
switch (dialog.run ()) { switch (dialog.run ()) {
@ -4228,23 +4222,24 @@ Editor::bounce_range_selection (BounceTarget target, bool enable_processing)
default: default:
return; return;
} }
dialog.get_result(bounce_name);
dialog.get_result (bounce_name); if (to_slot && to_slot->get_active()) {
copy_to_trigger = true;
if (cliplib && cliplib->get_active ()) { }
if (cliplib->get_active ()) {
copy_to_clip_library = true; copy_to_clip_library = true;
} }
} }
/* prevent user from accidentally overwriting a slot that they can't see */ /* prevent user from accidentally overwriting a slot that they can't see */
bool overwriting = false; bool overwriting = false;
if (target == NewTrigger) { if (copy_to_trigger) {
for (TrackViewList::iterator i = views.begin(); i != views.end(); ++i) { for (RegionSelection::iterator i = selection->regions.begin(); i != selection->regions.end(); ++i) {
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
if (!rtv) { boost::shared_ptr<Region> region ((*i)->region());
continue; RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&(*i)->get_time_axis_view());
} boost::shared_ptr<Track> track = boost::dynamic_pointer_cast<Track> (rtv->route());
boost::shared_ptr<ARDOUR::Track> track = rtv->track();
if (!track) { if (!track) {
continue; continue;
} }
@ -4252,13 +4247,13 @@ Editor::bounce_range_selection (BounceTarget target, bool enable_processing)
overwriting = true; overwriting = true;
} }
} }
} if (overwriting) {
if (overwriting) { ArdourMessageDialog msg (string_compose(_("Are you sure you want to overwrite the contents in slot %1?"),cue_marker_name(trigger_slot)), false, MESSAGE_QUESTION, BUTTONS_YES_NO, true);
ArdourMessageDialog msg (string_compose(_("Are you sure you want to overwrite the contents in slot %1?"),cue_marker_name(trigger_slot)), false, MESSAGE_QUESTION, BUTTONS_YES_NO, true); msg.set_title (_("Overwriting slot"));
msg.set_title (_("Overwriting slot")); msg.set_secondary_text (_("One of your selected tracks has content in this slot."));
msg.set_secondary_text (_("One of your selected tracks has content in this slot.")); if (msg.run () != RESPONSE_YES) {
if (msg.run () != RESPONSE_YES) { return;
return; }
} }
} }
@ -4270,6 +4265,7 @@ Editor::bounce_range_selection (BounceTarget target, bool enable_processing)
TempoMap::SharedPtr tmap (TempoMap::use()); TempoMap::SharedPtr tmap (TempoMap::use());
double tempo = tmap->tempo_at(start).quarter_notes_per_minute(); double tempo = tmap->tempo_at(start).quarter_notes_per_minute();
TrackSelection views = selection->tracks;
for (TrackViewList::iterator i = views.begin(); i != views.end(); ++i) { for (TrackViewList::iterator i = views.begin(); i != views.end(); ++i) {
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i); RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
@ -4293,7 +4289,7 @@ Editor::bounce_range_selection (BounceTarget target, bool enable_processing)
/*make the "source" (whole-file region)*/ /*make the "source" (whole-file region)*/
/*note: bounce_range() will append the playlist name to the resulting region and filename*/ /*note: bounce_range() will append the playlist name to the resulting region and filename*/
if (enable_processing) { if (with_processing) {
r = rtv->track()->bounce_range (start.samples(), (start+cnt).samples(), itt, rtv->track()->main_outs(), false, bounce_name); r = rtv->track()->bounce_range (start.samples(), (start+cnt).samples(), itt, rtv->track()->main_outs(), false, bounce_name);
} else { } else {
r = rtv->track()->bounce_range (start.samples(), (start+cnt).samples(), itt, boost::shared_ptr<Processor>(), false, bounce_name); r = rtv->track()->bounce_range (start.samples(), (start+cnt).samples(), itt, boost::shared_ptr<Processor>(), false, bounce_name);
@ -4313,7 +4309,7 @@ Editor::bounce_range_selection (BounceTarget target, bool enable_processing)
} }
if (target == ReplaceRange) { if (target == ReplaceRange) {
/*remove the edxisting regions under the edit range*/ /*remove the existing regions under the edit range*/
list<TimelineRange> ranges; list<TimelineRange> ranges;
ranges.push_back (TimelineRange (start, start+cnt, 0)); ranges.push_back (TimelineRange (start, start+cnt, 0));
playlist->cut (ranges); // discard result playlist->cut (ranges); // discard result
@ -4324,7 +4320,9 @@ Editor::bounce_range_selection (BounceTarget target, bool enable_processing)
plist.add (ARDOUR::Properties::whole_file, false); plist.add (ARDOUR::Properties::whole_file, false);
boost::shared_ptr<Region> copy (RegionFactory::create (r, plist)); boost::shared_ptr<Region> copy (RegionFactory::create (r, plist));
playlist->add_region (copy, start); playlist->add_region (copy, start);
} else if (target == NewTrigger) { }
if (copy_to_trigger) {
boost::shared_ptr<Trigger::UIState> state (new Trigger::UIState()); boost::shared_ptr<Trigger::UIState> state (new Trigger::UIState());
state->name = bounce_name; state->name = bounce_name;
state->tempo = tempo; state->tempo = tempo;
@ -4333,6 +4331,10 @@ Editor::bounce_range_selection (BounceTarget target, bool enable_processing)
rtv->track ()->presentation_info ().set_trigger_track (true); rtv->track ()->presentation_info ().set_trigger_track (true);
} }
if (copy_to_clip_library) {
export_to_clip_library (r);
}
vector<Command*> cmds; vector<Command*> cmds;
playlist->rdiff (cmds); playlist->rdiff (cmds);
_session->add_commands (cmds); _session->add_commands (cmds);