From c4de76c835498f52484dd6b7da3d15ab129fb102 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Fri, 17 Dec 2021 09:45:34 -0600 Subject: [PATCH] triggerbox: implement clear_trigger and isolate (gtk part) --- gtk2_ardour/triggerbox_ui.cc | 54 ++++++++++++++++++++++++++++++++---- gtk2_ardour/triggerbox_ui.h | 3 ++ 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/triggerbox_ui.cc b/gtk2_ardour/triggerbox_ui.cc index 2eeae1303e..f6214be06f 100644 --- a/gtk2_ardour/triggerbox_ui.cc +++ b/gtk2_ardour/triggerbox_ui.cc @@ -256,11 +256,24 @@ TriggerEntry::render (ArdourCanvas::Rect const& area, Cairo::RefPtr drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6 * scale); - drop_shadow_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7); - drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0); + if (_trigger.scene_isolated()) { + //left shadow + context->set_identity_matrix(); + context->translate (self.x0, self.y0-0.5); + Cairo::RefPtr l_shadow = Cairo::LinearGradient::create (0, 0, scale*12, 0); + l_shadow->add_color_stop_rgba ( 0.0, 0.0,0.0,0.0, 0.8); + l_shadow->add_color_stop_rgba ( 1.0, 0.0,0.0,0.0, 0.0); + context->set_source (l_shadow); + context->rectangle( 0, 0, scale*12, height ); + context->fill (); + context->set_identity_matrix(); + } + + if (_trigger.index()==1) { + //drop-shadow at top + Cairo::RefPtr drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6*scale); + drop_shadow_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7); + drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0); context->set_source (drop_shadow_pattern); context->rectangle (0, 0, width, 6 * scale); context->fill (); @@ -337,6 +350,10 @@ TriggerEntry::prop_change (PropertyChange const& change) redraw (); } + if (change.contains (ARDOUR::Properties::isolated)) { + redraw(); + } + if (need_pb) { shape_play_button (); } @@ -391,6 +408,7 @@ TriggerBoxUI::TriggerBoxUI (ArdourCanvas::Item* parent, TriggerBox& tb) , _triggerbox (tb) , _file_chooser (0) , _context_menu (0) + , _ignore_menu_action (false) { set_layout_sensitive (true); // why??? @@ -764,15 +782,41 @@ TriggerBoxUI::context_menu (uint64_t n) 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 (_("Clear"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::clear_trigger), 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)); items.push_back (MenuElem (_("Quantization..."), *quant_menu)); + items.push_back (CheckMenuElem (_("Cue Isolate"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::toggle_trigger_isolated), n))); + if (_triggerbox.trigger (n)->scene_isolated()) { + _ignore_menu_action = true; + dynamic_cast (&items.back ())->set_active (true); + _ignore_menu_action = false; + } + _context_menu->popup (1, gtk_get_current_event_time ()); } +void +TriggerBoxUI::toggle_trigger_isolated (uint64_t n) +{ + if (_ignore_menu_action) { + return; + } + + Trigger* trigger = _triggerbox.trigger (n); + trigger->set_scene_isolated(!trigger->scene_isolated()); +} + +void +TriggerBoxUI::clear_trigger (uint64_t n) +{ + Trigger* trigger = _triggerbox.trigger (n); +// trigger->clear_trigger(); +} + void TriggerBoxUI::edit_trigger (uint64_t n) { diff --git a/gtk2_ardour/triggerbox_ui.h b/gtk2_ardour/triggerbox_ui.h index 4f634055ea..ee3ba707bd 100644 --- a/gtk2_ardour/triggerbox_ui.h +++ b/gtk2_ardour/triggerbox_ui.h @@ -93,6 +93,8 @@ public: TriggerBoxUI (ArdourCanvas::Item* parent, ARDOUR::TriggerBox&); ~TriggerBoxUI (); + void toggle_trigger_isolated (uint64_t n); + void clear_trigger (uint64_t n); void edit_trigger (uint64_t n); void start_updating (); void stop_updating (); @@ -112,6 +114,7 @@ private: Gtk::FileChooserDialog* _file_chooser; sigc::connection _file_chooser_connection; Gtk::Menu* _context_menu; + bool _ignore_menu_action; static Gtkmm2ext::Bindings* bindings; static void load_bindings ();