triggerboxUI: GUI elements to load slots from selected regions

This commit is contained in:
Paul Davis 2021-10-24 09:25:49 -06:00
parent 7339aa7c0d
commit 65f85dfdfe
2 changed files with 25 additions and 1 deletions

View File

@ -38,6 +38,8 @@
#include "triggerbox_ui.h"
#include "trigger_ui.h"
#include "public_editor.h"
#include "region_view.h"
#include "selection.h"
#include "timers.h"
#include "ui_config.h"
#include "utils.h"
@ -508,9 +510,13 @@ TriggerBoxUI::context_menu (uint64_t n)
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
}
Menu* load_menu = manage (new Menu);
MenuList& loitems (load_menu->items());
loitems.push_back (MenuElem (_("from file"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::choose_sample), n)));
loitems.push_back (MenuElem (_("from selection"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_from_selection), n)));
items.push_back (MenuElem (_("Load..."), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::choose_sample), n)));
items.push_back (MenuElem (_("Load..."), *load_menu));
items.push_back (MenuElem (_("Edit..."), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::edit_trigger), n)));
items.push_back (MenuElem (_("Follow Action..."), *follow_menu));
items.push_back (MenuElem (_("Launch Style..."), *launch_menu));
@ -588,6 +594,23 @@ TriggerBoxUI::sample_chosen (int response, uint64_t n)
}
}
void
TriggerBoxUI::set_from_selection (uint64_t n)
{
Selection& selection (PublicEditor::instance().get_selection());
RegionSelection rselection (selection.regions);
if (rselection.empty()) {
/* XXX possible message about no selection ? */
return;
}
for (RegionSelection::iterator r = rselection.begin(); r != rselection.end(); ++r) {
_triggerbox.set_from_selection (n, (*r)->region());
++n;
}
}
void
TriggerBoxUI::start_updating ()
{

View File

@ -104,6 +104,7 @@ class TriggerBoxUI : public ArdourCanvas::Table
void set_follow_action (uint64_t slot, ARDOUR::Trigger::FollowAction);
void set_launch_style (uint64_t slot, ARDOUR::Trigger::LaunchStyle);
void set_quantization (uint64_t slot, Temporal::BBT_Offset const &);
void set_from_selection (uint64_t slot);
void build ();
void rapid_update ();