mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
trigger_ui: refactor shared features into TriggerUI base
This commit is contained in:
parent
9180a985a4
commit
cdaa9a7262
5 changed files with 310 additions and 317 deletions
|
|
@ -66,11 +66,6 @@ using namespace PBD;
|
|||
|
||||
TriggerEntry::TriggerEntry (Item* item, TriggerReference tr)
|
||||
: ArdourCanvas::Rectangle (item)
|
||||
, _file_chooser (0)
|
||||
, _launch_context_menu (0)
|
||||
, _follow_context_menu (0)
|
||||
, _context_menu (0)
|
||||
, _ignore_menu_action (false)
|
||||
{
|
||||
set_layout_sensitive (true); // why???
|
||||
|
||||
|
|
@ -619,287 +614,6 @@ TriggerEntry::follow_button_event (GdkEvent* ev)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
TriggerEntry::context_menu ()
|
||||
{
|
||||
using namespace Gtk;
|
||||
using namespace Gtk::Menu_Helpers;
|
||||
using namespace Temporal;
|
||||
|
||||
delete _context_menu;
|
||||
|
||||
_context_menu = new Menu;
|
||||
MenuList& items = _context_menu->items ();
|
||||
_context_menu->set_name ("ArdourContextMenu");
|
||||
|
||||
Menu* load_menu = manage (new Menu);
|
||||
MenuList& loitems (load_menu->items ());
|
||||
|
||||
loitems.push_back (MenuElem (_("from file"), sigc::mem_fun (*this, &TriggerUI::choose_sample)));
|
||||
loitems.push_back (MenuElem (_("from selection"), sigc::mem_fun (*this, &TriggerEntry::set_from_selection)));
|
||||
|
||||
items.push_back (MenuElem (_("Load..."), *load_menu));
|
||||
#if DOUBLE_CLICK_IS_NOT_OBVIOUS_ENOUGH
|
||||
items.push_back (MenuElem (_("Edit..."), sigc::mem_fun (*this, &TriggerEntry::edit_trigger)));
|
||||
#endif
|
||||
items.push_back (SeparatorElem());
|
||||
items.push_back (MenuElem (_("Color..."), sigc::mem_fun (*this, &TriggerUI::choose_color)));
|
||||
items.push_back (SeparatorElem());
|
||||
items.push_back (MenuElem (_("Clear"), sigc::mem_fun (*this, &TriggerEntry::clear_trigger)));
|
||||
|
||||
_context_menu->popup (1, gtk_get_current_event_time ());
|
||||
}
|
||||
|
||||
void
|
||||
TriggerEntry::launch_context_menu ()
|
||||
{
|
||||
using namespace Gtk;
|
||||
using namespace Gtk::Menu_Helpers;
|
||||
using namespace Temporal;
|
||||
|
||||
delete _launch_context_menu;
|
||||
|
||||
_launch_context_menu = new Menu;
|
||||
MenuList& items = _launch_context_menu->items ();
|
||||
_launch_context_menu->set_name ("ArdourContextMenu");
|
||||
|
||||
RadioMenuItem::Group lagroup;
|
||||
RadioMenuItem::Group qgroup;
|
||||
|
||||
Menu* launch_menu = manage (new Menu);
|
||||
MenuList& litems = launch_menu->items ();
|
||||
|
||||
litems.push_back (RadioMenuElem (lagroup, TriggerUI::launch_style_to_string(Trigger::OneShot), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_launch_style), Trigger::OneShot)));
|
||||
if (trigger ()->launch_style () == Trigger::OneShot) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&litems.back ())->set_active (true);
|
||||
}
|
||||
litems.push_back (RadioMenuElem (lagroup, TriggerUI::launch_style_to_string(Trigger::Gate), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_launch_style), Trigger::Gate)));
|
||||
if (trigger ()->launch_style () == Trigger::Gate) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&litems.back ())->set_active (true);
|
||||
}
|
||||
litems.push_back (RadioMenuElem (lagroup, TriggerUI::launch_style_to_string(Trigger::Toggle), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_launch_style), Trigger::Toggle)));
|
||||
if (trigger ()->launch_style () == Trigger::Toggle) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&litems.back ())->set_active (true);
|
||||
}
|
||||
litems.push_back (RadioMenuElem (lagroup, TriggerUI::launch_style_to_string(Trigger::Repeat), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_launch_style), Trigger::Repeat)));
|
||||
if (trigger ()->launch_style () == Trigger::Repeat) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&litems.back ())->set_active (true);
|
||||
}
|
||||
|
||||
Menu* quant_menu = manage (new Menu);
|
||||
MenuList& qitems = quant_menu->items ();
|
||||
|
||||
BBT_Offset b;
|
||||
|
||||
#if TRIGGER_PAGE_GLOBAL_QUANTIZATION_IS_IMPLEMENTED
|
||||
bool success;
|
||||
Beats grid_beats (PublicEditor::instance ().get_grid_type_as_beats (success, timepos_t (0)));
|
||||
if (success) {
|
||||
b = BBT_Offset (0, grid_beats.get_beats (), grid_beats.get_ticks ());
|
||||
qitems.push_back (RadioMenuElem (qgroup, _("Main Grid"), sigc::bind(sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), b)));
|
||||
/* can't mark this active because the current trigger quant setting may just a specific setting below */
|
||||
/* XXX HOW TO GET THIS TO FOLLOW GRID CHANGES (which are GUI only) */
|
||||
}
|
||||
#endif
|
||||
|
||||
b = BBT_Offset (1, 0, 0);
|
||||
qitems.push_back (RadioMenuElem (qgroup, TriggerUI::quantize_length_to_string (b), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_quantization), b)));
|
||||
if (trigger ()->quantization () == b) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
||||
}
|
||||
b = BBT_Offset (0, 4, 0);
|
||||
qitems.push_back (RadioMenuElem (qgroup, TriggerUI::quantize_length_to_string (b), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_quantization), b)));
|
||||
if (trigger ()->quantization () == b) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
||||
}
|
||||
b = BBT_Offset (0, 2, 0);
|
||||
qitems.push_back (RadioMenuElem (qgroup, TriggerUI::quantize_length_to_string (b), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_quantization), b)));
|
||||
if (trigger ()->quantization () == b) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
||||
}
|
||||
b = BBT_Offset (0, 1, 0);
|
||||
qitems.push_back (RadioMenuElem (qgroup, TriggerUI::quantize_length_to_string (b), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_quantization), b)));
|
||||
if (trigger ()->quantization () == b) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
||||
}
|
||||
b = BBT_Offset (0, 0, ticks_per_beat / 2);
|
||||
qitems.push_back (RadioMenuElem (qgroup, TriggerUI::quantize_length_to_string (b), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_quantization), b)));
|
||||
if (trigger ()->quantization () == b) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
||||
}
|
||||
b = BBT_Offset (0, 0, ticks_per_beat / 4);
|
||||
qitems.push_back (RadioMenuElem (qgroup, TriggerUI::quantize_length_to_string (b), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_quantization), b)));
|
||||
if (trigger ()->quantization () == b) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
||||
}
|
||||
b = BBT_Offset (0, 0, ticks_per_beat / 8);
|
||||
qitems.push_back (RadioMenuElem (qgroup, TriggerUI::quantize_length_to_string (b), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_quantization), b)));
|
||||
if (trigger ()->quantization () == b) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
||||
}
|
||||
b = BBT_Offset (0, 0, ticks_per_beat / 16);
|
||||
qitems.push_back (RadioMenuElem (qgroup, TriggerUI::quantize_length_to_string (b), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_quantization), b)));
|
||||
if (trigger ()->quantization () == b) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
||||
}
|
||||
|
||||
items.push_back (MenuElem (_("Launch Style..."), *launch_menu));
|
||||
items.push_back (MenuElem (_("Quantization..."), *quant_menu));
|
||||
|
||||
items.push_back (CheckMenuElem (_("Cue Isolate"), sigc::mem_fun (*this, &TriggerEntry::toggle_trigger_isolated)));
|
||||
if (trigger ()->scene_isolated ()) {
|
||||
PBD::Unwinder<bool> uw (_ignore_menu_action, true);
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&items.back ())->set_active (true);
|
||||
}
|
||||
|
||||
_launch_context_menu->popup (1, gtk_get_current_event_time ());
|
||||
}
|
||||
|
||||
void
|
||||
TriggerEntry::follow_context_menu ()
|
||||
{
|
||||
using namespace Gtk;
|
||||
using namespace Gtk::Menu_Helpers;
|
||||
using namespace Temporal;
|
||||
|
||||
delete _follow_context_menu;
|
||||
|
||||
_follow_context_menu = new Menu;
|
||||
MenuList& items = _follow_context_menu->items ();
|
||||
_follow_context_menu->set_name ("ArdourContextMenu");
|
||||
|
||||
Menu* follow_menu = manage (new Menu);
|
||||
MenuList& fitems = follow_menu->items ();
|
||||
|
||||
RadioMenuItem::Group fagroup;
|
||||
|
||||
_ignore_menu_action = true;
|
||||
|
||||
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(Trigger::None), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_follow_action), Trigger::None)));
|
||||
if (trigger ()->follow_action (0) == Trigger::None) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
||||
}
|
||||
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(Trigger::Stop), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_follow_action), Trigger::Stop)));
|
||||
if (trigger ()->follow_action (0) == Trigger::Stop) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
||||
}
|
||||
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(Trigger::Again), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_follow_action), Trigger::Again)));
|
||||
if (trigger ()->follow_action (0) == Trigger::Again) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
||||
}
|
||||
#if QUEUED_SLOTS_IMPLEMENTED
|
||||
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(Trigger::QueuedTrigger), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_follow_action), Trigger::QueuedTrigger)));
|
||||
if (trigger ()->follow_action (0) == Trigger::QueuedTrigger) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
||||
}
|
||||
#endif
|
||||
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(Trigger::PrevTrigger), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_follow_action), Trigger::PrevTrigger)));
|
||||
if (trigger ()->follow_action (0) == Trigger::PrevTrigger) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
||||
}
|
||||
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(Trigger::NextTrigger), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_follow_action), Trigger::NextTrigger)));
|
||||
if (trigger ()->follow_action (0) == Trigger::NextTrigger) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
||||
}
|
||||
#if 0
|
||||
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(Trigger::FirstTrigger), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_follow_action), Trigger::FirstTrigger)));
|
||||
if (trigger ()->follow_action (0) == Trigger::FirstTrigger) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
||||
}
|
||||
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(Trigger::LastTrigger), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_follow_action), Trigger::LastTrigger)));
|
||||
if (trigger ()->follow_action (0) == Trigger::LastTrigger) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
||||
}
|
||||
#endif
|
||||
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(Trigger::AnyTrigger), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_follow_action), Trigger::AnyTrigger)));
|
||||
if (trigger ()->follow_action (0) == Trigger::AnyTrigger) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
||||
}
|
||||
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(Trigger::OtherTrigger), sigc::bind(sigc::mem_fun (*this, &TriggerEntry::set_follow_action), Trigger::OtherTrigger)));
|
||||
if (trigger ()->follow_action (0) == Trigger::OtherTrigger) {
|
||||
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
||||
}
|
||||
|
||||
_ignore_menu_action = false;
|
||||
|
||||
items.push_back (MenuElem (_("Follow Action..."), *follow_menu));
|
||||
|
||||
_follow_context_menu->popup (1, gtk_get_current_event_time ());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TriggerEntry::toggle_trigger_isolated ()
|
||||
{
|
||||
if (_ignore_menu_action) {
|
||||
return;
|
||||
}
|
||||
|
||||
trigger()->set_scene_isolated (!trigger()->scene_isolated ());
|
||||
}
|
||||
|
||||
void
|
||||
TriggerEntry::clear_trigger ()
|
||||
{
|
||||
trigger()->set_region (boost::shared_ptr<Region>());
|
||||
}
|
||||
|
||||
void
|
||||
TriggerEntry::edit_trigger ()
|
||||
{
|
||||
SlotPropertyWindow* tw = static_cast<SlotPropertyWindow*> (trigger()->ui ());
|
||||
|
||||
if (!tw) {
|
||||
tw = new SlotPropertyWindow (TriggerReference (trigger()->box(), trigger()->index()));
|
||||
trigger()->set_ui (tw);
|
||||
}
|
||||
|
||||
tw->present ();
|
||||
}
|
||||
|
||||
void
|
||||
TriggerEntry::set_follow_action (Trigger::FollowAction fa)
|
||||
{
|
||||
if (_ignore_menu_action) {
|
||||
return;
|
||||
}
|
||||
|
||||
trigger()->set_follow_action (fa, 0);
|
||||
trigger()->set_follow_action_probability (0);
|
||||
trigger()->set_use_follow (true);
|
||||
}
|
||||
|
||||
void
|
||||
TriggerEntry::set_launch_style (Trigger::LaunchStyle ls)
|
||||
{
|
||||
trigger()->set_launch_style (ls);
|
||||
}
|
||||
|
||||
void
|
||||
TriggerEntry::set_quantization (Temporal::BBT_Offset const& q)
|
||||
{
|
||||
trigger()->set_quantization (q);
|
||||
}
|
||||
|
||||
void
|
||||
TriggerEntry::set_from_selection ()
|
||||
{
|
||||
Selection& selection (PublicEditor::instance ().get_selection ());
|
||||
RegionSelection rselection (selection.regions);
|
||||
|
||||
if (rselection.empty ()) {
|
||||
/* XXX possible message about no selection ? */
|
||||
return;
|
||||
}
|
||||
|
||||
int n = trigger()->index();
|
||||
|
||||
for (RegionSelection::iterator r = rselection.begin (); r != rselection.end (); ++r) {
|
||||
trigger()->box().set_from_selection (n, (*r)->region ());
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
/* ***************************************************** */
|
||||
|
||||
TriggerBoxUI::TriggerBoxUI (ArdourCanvas::Item* parent, TriggerBox& tb)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue