trigger_ui: refactor shared features into TriggerUI base
This commit is contained in:
parent
9180a985a4
commit
cdaa9a7262
|
@ -210,10 +210,10 @@ SlotPropertyTable::SlotPropertyTable ()
|
|||
|
||||
_load_button.set_name("FollowAction");
|
||||
_load_button.set_text (_("Load"));
|
||||
_load_button.signal_clicked.connect (sigc::mem_fun (*this, (&SlotPropertyTable::choose_sample)));
|
||||
_load_button.signal_clicked.connect (sigc::mem_fun (*this, (&TriggerUI::choose_sample)));
|
||||
|
||||
_color_button.set_name("FollowAction");
|
||||
_color_button.signal_clicked.connect (sigc::mem_fun (*this, (&SlotPropertyTable::choose_color)));
|
||||
_color_button.signal_clicked.connect (sigc::mem_fun (*this, (&TriggerUI::choose_color)));
|
||||
|
||||
_follow_size_group = Gtk::SizeGroup::create (Gtk::SIZE_GROUP_VERTICAL);
|
||||
_follow_size_group->add_widget(_name_frame);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "pbd/file_utils.h"
|
||||
#include "pbd/pathexpand.h"
|
||||
#include "pbd/search_path.h"
|
||||
#include "pbd/unwind.h"
|
||||
|
||||
#include "ardour/directory_names.h"
|
||||
#include "ardour/filesystem_paths.h"
|
||||
|
@ -40,6 +41,8 @@
|
|||
#include "ardour_ui.h"
|
||||
#include "gui_thread.h"
|
||||
#include "keyboard.h"
|
||||
#include "public_editor.h"
|
||||
#include "region_view.h"
|
||||
#include "trigger_ui.h"
|
||||
#include "ui_config.h"
|
||||
|
||||
|
@ -63,6 +66,10 @@ Glib::RefPtr<Gtk::ActionGroup> TriggerUI::trigger_actions;
|
|||
|
||||
TriggerUI::TriggerUI ()
|
||||
: _renaming (false)
|
||||
, _launch_context_menu (0)
|
||||
, _follow_context_menu (0)
|
||||
, _context_menu (0)
|
||||
, _ignore_menu_action (false)
|
||||
{
|
||||
if (follow_strings.empty()) {
|
||||
follow_strings.push_back (follow_action_to_string (Trigger::None));
|
||||
|
@ -109,7 +116,7 @@ TriggerUI::trigger_swap (uint32_t n)
|
|||
return;
|
||||
}
|
||||
trigger_connections.disconnect ();
|
||||
trigger()->PropertyChanged.connect (trigger_connections, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::trigger_changed, this, _1), gui_context ());
|
||||
trigger()->PropertyChanged.connect (trigger_connections, MISSING_INVALIDATOR, boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context ());
|
||||
trigger_changed (Properties::name);
|
||||
}
|
||||
|
||||
|
@ -388,7 +395,286 @@ TriggerUI::disconnect_entry_signals ()
|
|||
|
||||
/* ****************************************************************************/
|
||||
|
||||
void
|
||||
TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::clear_trigger)));
|
||||
|
||||
_context_menu->popup (1, gtk_get_current_event_time ());
|
||||
}
|
||||
|
||||
void
|
||||
TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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
|
||||
TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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, &TriggerUI::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
|
||||
TriggerUI::toggle_trigger_isolated ()
|
||||
{
|
||||
if (_ignore_menu_action) {
|
||||
return;
|
||||
}
|
||||
|
||||
trigger()->set_scene_isolated (!trigger()->scene_isolated ());
|
||||
}
|
||||
|
||||
void
|
||||
TriggerUI::clear_trigger ()
|
||||
{
|
||||
trigger()->set_region (boost::shared_ptr<Region>());
|
||||
}
|
||||
|
||||
void
|
||||
TriggerUI::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
|
||||
TriggerUI::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
|
||||
TriggerUI::set_launch_style (Trigger::LaunchStyle ls)
|
||||
{
|
||||
trigger()->set_launch_style (ls);
|
||||
}
|
||||
|
||||
void
|
||||
TriggerUI::set_quantization (Temporal::BBT_Offset const& q)
|
||||
{
|
||||
trigger()->set_quantization (q);
|
||||
}
|
||||
|
||||
void
|
||||
TriggerUI::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;
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
TriggerUI::launch_style_to_string (Trigger::LaunchStyle ls)
|
||||
|
|
|
@ -67,6 +67,19 @@ public:
|
|||
void choose_sample ();
|
||||
void sample_chosen (int r);
|
||||
|
||||
void launch_context_menu ();
|
||||
void follow_context_menu ();
|
||||
void context_menu ();
|
||||
|
||||
void set_follow_action (ARDOUR::Trigger::FollowAction);
|
||||
void set_launch_style (ARDOUR::Trigger::LaunchStyle);
|
||||
void set_quantization (Temporal::BBT_Offset const&);
|
||||
void set_from_selection ();
|
||||
|
||||
void toggle_trigger_isolated ();
|
||||
void clear_trigger ();
|
||||
void edit_trigger ();
|
||||
|
||||
private:
|
||||
void trigger_changed (PBD::PropertyChange const& ); //calls on_trigger_changed to subclasses
|
||||
|
||||
|
@ -97,10 +110,15 @@ protected:
|
|||
Gtk::EventBox _namebox;
|
||||
ArdourWidgets::Frame _name_frame;
|
||||
|
||||
Gtk::ColorSelectionDialog _color_dialog;
|
||||
Gtk::FileChooserDialog* _file_chooser;
|
||||
sigc::connection _file_chooser_connection;
|
||||
|
||||
sigc::connection _file_chooser_connection;
|
||||
Gtk::FileChooserDialog* _file_chooser;
|
||||
Gtk::Menu* _launch_context_menu;
|
||||
Gtk::Menu* _follow_context_menu;
|
||||
Gtk::Menu* _context_menu;
|
||||
bool _ignore_menu_action;
|
||||
|
||||
Gtk::ColorSelectionDialog _color_dialog;
|
||||
|
||||
void trigger_swap (uint32_t);
|
||||
PBD::ScopedConnection trigger_swap_connection;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -72,35 +72,10 @@ public:
|
|||
bool name_button_event (GdkEvent*);
|
||||
bool follow_button_event (GdkEvent*);
|
||||
|
||||
void choose_sample ();
|
||||
void sample_chosen (int r);
|
||||
|
||||
void launch_context_menu ();
|
||||
void follow_context_menu ();
|
||||
void context_menu ();
|
||||
|
||||
Gtk::ColorSelectionDialog _color_dialog;
|
||||
void pick_color ();
|
||||
void set_follow_action (ARDOUR::Trigger::FollowAction);
|
||||
void set_launch_style (ARDOUR::Trigger::LaunchStyle);
|
||||
void set_quantization (Temporal::BBT_Offset const&);
|
||||
void set_from_selection ();
|
||||
|
||||
void toggle_trigger_isolated ();
|
||||
void clear_trigger ();
|
||||
void edit_trigger ();
|
||||
|
||||
private:
|
||||
double _poly_size;
|
||||
double _poly_margin;
|
||||
|
||||
Gtk::FileChooserDialog* _file_chooser;
|
||||
sigc::connection _file_chooser_connection;
|
||||
Gtk::Menu* _launch_context_menu;
|
||||
Gtk::Menu* _follow_context_menu;
|
||||
Gtk::Menu* _context_menu;
|
||||
bool _ignore_menu_action;
|
||||
|
||||
PBD::ScopedConnection owner_prop_connection;
|
||||
void owner_prop_change (PBD::PropertyChange const&);
|
||||
void owner_color_changed ();
|
||||
|
|
Loading…
Reference in New Issue