2021-07-21 18:44:41 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2021-08-05 14:11:19 -04:00
|
|
|
#include <gtkmm/filechooserdialog.h>
|
2021-08-05 17:04:02 -04:00
|
|
|
#include <gtkmm/menu.h>
|
|
|
|
#include <gtkmm/menuitem.h>
|
2021-08-05 14:11:19 -04:00
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
|
2021-07-22 12:33:47 -04:00
|
|
|
#include "pbd/i18n.h"
|
2021-07-27 22:39:55 -04:00
|
|
|
#include "pbd/compose.h"
|
2021-07-28 00:40:35 -04:00
|
|
|
#include "pbd/convert.h"
|
2021-07-27 22:39:55 -04:00
|
|
|
|
2021-07-28 00:40:35 -04:00
|
|
|
#include "ardour/region.h"
|
2021-07-21 19:22:09 -04:00
|
|
|
#include "ardour/triggerbox.h"
|
|
|
|
|
2021-07-27 22:39:55 -04:00
|
|
|
#include "canvas/polygon.h"
|
|
|
|
#include "canvas/text.h"
|
|
|
|
|
2021-07-21 19:22:09 -04:00
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
2021-08-05 17:04:02 -04:00
|
|
|
#include "ardour_ui.h"
|
2021-08-05 18:20:56 -04:00
|
|
|
#include "gui_thread.h"
|
2021-07-21 18:44:41 -04:00
|
|
|
#include "triggerbox_ui.h"
|
2021-08-05 17:04:02 -04:00
|
|
|
#include "public_editor.h"
|
2021-07-28 00:40:35 -04:00
|
|
|
#include "ui_config.h"
|
2021-08-05 17:04:02 -04:00
|
|
|
#include "utils.h"
|
2021-07-21 18:44:41 -04:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace ArdourCanvas;
|
2021-07-21 19:22:09 -04:00
|
|
|
using namespace Gtkmm2ext;
|
2021-07-28 00:40:35 -04:00
|
|
|
using namespace PBD;
|
2021-07-21 18:44:41 -04:00
|
|
|
|
2021-07-29 14:24:04 -04:00
|
|
|
TriggerEntry::TriggerEntry (Canvas* canvas, ARDOUR::Trigger& t)
|
|
|
|
: Rectangle (canvas)
|
2021-07-21 18:44:41 -04:00
|
|
|
, _trigger (t)
|
|
|
|
{
|
2021-07-28 00:40:35 -04:00
|
|
|
const double scale = UIConfiguration::instance().get_ui_scale();
|
|
|
|
const double width = 150. * scale;
|
|
|
|
const double height = 20. * scale;
|
|
|
|
|
2021-08-07 20:55:05 -04:00
|
|
|
poly_margin = 2. * scale;
|
|
|
|
poly_size = height - (poly_margin * 2.);
|
|
|
|
|
2021-07-28 00:40:35 -04:00
|
|
|
Rect r (0, 0, width, height);
|
2021-07-21 19:22:09 -04:00
|
|
|
set (r);
|
|
|
|
set_outline_all ();
|
2021-07-27 19:08:31 -04:00
|
|
|
set_fill_color (Gtkmm2ext::random_color());
|
|
|
|
set_outline_color (Gtkmm2ext::random_color());
|
2021-07-27 22:39:55 -04:00
|
|
|
name = string_compose ("trigger %1", _trigger.index());
|
2021-07-21 18:44:41 -04:00
|
|
|
|
2021-08-07 20:55:05 -04:00
|
|
|
play_button = new Rectangle (this);
|
|
|
|
play_button->set (Rect (0., 0., poly_size + (poly_margin * 2.), height));
|
2021-07-27 22:39:55 -04:00
|
|
|
play_button->set_outline (false);
|
2021-08-07 20:55:05 -04:00
|
|
|
play_button->set_fill_color (0x000000ff);
|
|
|
|
play_button->name = string_compose ("playbutton %1", _trigger.index());
|
2021-07-21 19:22:09 -04:00
|
|
|
|
2021-08-07 20:55:05 -04:00
|
|
|
play_shape = new Polygon (play_button);
|
|
|
|
play_shape->set_fill_color (Gtkmm2ext::random_color());
|
|
|
|
play_shape->set_outline (false);
|
|
|
|
play_shape->name = string_compose ("playshape %1", _trigger.index());
|
2021-07-27 22:39:55 -04:00
|
|
|
|
|
|
|
name_text = new Text (this);
|
2021-07-28 00:40:35 -04:00
|
|
|
name_text->set_font_description (UIConfiguration::instance().get_NormalFont());
|
|
|
|
name_text->set_color (Gtkmm2ext::contrasting_text_color (fill_color()));
|
2021-08-07 20:55:05 -04:00
|
|
|
name_text->set_position (Duple (play_button->get().width() + (2. * scale), poly_margin));
|
2021-08-05 18:20:56 -04:00
|
|
|
|
|
|
|
_trigger.PropertyChanged.connect (trigger_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::prop_change, this, _1), gui_context());
|
|
|
|
|
2021-08-07 20:55:05 -04:00
|
|
|
PropertyChange changed;
|
|
|
|
changed.add (ARDOUR::Properties::name);
|
|
|
|
changed.add (ARDOUR::Properties::running);
|
|
|
|
|
|
|
|
prop_change (changed);
|
2021-07-27 22:39:55 -04:00
|
|
|
}
|
2021-07-27 19:08:31 -04:00
|
|
|
|
2021-08-05 18:20:56 -04:00
|
|
|
|
2021-07-27 22:39:55 -04:00
|
|
|
TriggerEntry::~TriggerEntry ()
|
|
|
|
{
|
2021-07-21 19:22:09 -04:00
|
|
|
}
|
|
|
|
|
2021-08-07 20:55:05 -04:00
|
|
|
void
|
|
|
|
TriggerEntry::draw_play_button ()
|
|
|
|
{
|
|
|
|
Points p;
|
|
|
|
|
|
|
|
if (_trigger.region()) {
|
|
|
|
/* stopped: triangle */
|
|
|
|
p.push_back (Duple (poly_margin, poly_margin));
|
|
|
|
p.push_back (Duple (poly_margin, poly_size));
|
|
|
|
p.push_back (Duple (poly_size, poly_size / 2.));
|
|
|
|
} else {
|
|
|
|
/* stopped: square */
|
|
|
|
p.push_back (Duple (poly_margin, poly_margin));
|
|
|
|
p.push_back (Duple (poly_margin, poly_size));
|
|
|
|
p.push_back (Duple (poly_size, poly_size));
|
|
|
|
p.push_back (Duple (poly_size, poly_margin));
|
|
|
|
}
|
|
|
|
|
|
|
|
play_shape->set (p);
|
|
|
|
|
2021-08-08 21:08:38 -04:00
|
|
|
if (_trigger.active()) {
|
2021-08-07 20:55:05 -04:00
|
|
|
play_button->set_fill (true);
|
|
|
|
} else {
|
|
|
|
play_button->set_fill (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-05 18:20:56 -04:00
|
|
|
void
|
|
|
|
TriggerEntry::prop_change (PropertyChange const & change)
|
|
|
|
{
|
2021-08-07 20:55:05 -04:00
|
|
|
bool need_pb = false;
|
2021-08-06 23:27:38 -04:00
|
|
|
|
2021-08-05 18:20:56 -04:00
|
|
|
if (change.contains (ARDOUR::Properties::name)) {
|
|
|
|
if (_trigger.region()) {
|
|
|
|
name_text->set (short_version (_trigger.region()->name(), 20));
|
|
|
|
} else {
|
|
|
|
/* we need some spaces to have something to click on */
|
2021-08-07 20:55:05 -04:00
|
|
|
name_text->set ("");
|
|
|
|
}
|
2021-08-06 23:27:38 -04:00
|
|
|
|
2021-08-07 20:55:05 -04:00
|
|
|
need_pb = true;
|
|
|
|
}
|
2021-08-06 23:27:38 -04:00
|
|
|
|
2021-08-07 20:55:05 -04:00
|
|
|
if (change.contains (ARDOUR::Properties::running)) {
|
|
|
|
need_pb = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (need_pb) {
|
|
|
|
draw_play_button ();
|
2021-08-05 18:20:56 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-06 12:24:37 -04:00
|
|
|
|
2021-08-05 18:20:56 -04:00
|
|
|
|
2021-07-21 19:22:09 -04:00
|
|
|
/* ---------------------------- */
|
|
|
|
|
|
|
|
TriggerBoxUI::TriggerBoxUI (ArdourCanvas::Item* parent, TriggerBox& tb)
|
2021-07-21 18:44:41 -04:00
|
|
|
: Box (parent, Box::Vertical)
|
2021-07-21 19:22:09 -04:00
|
|
|
, _triggerbox (tb)
|
2021-08-05 14:11:19 -04:00
|
|
|
, file_chooser (0)
|
2021-08-07 17:18:59 -04:00
|
|
|
, _context_menu (0)
|
2021-07-21 18:44:41 -04:00
|
|
|
{
|
2021-07-21 19:22:09 -04:00
|
|
|
set_homogenous (true);
|
2021-07-27 19:08:31 -04:00
|
|
|
set_spacing (16);
|
|
|
|
set_padding (16);
|
|
|
|
set_fill (false);
|
2021-07-21 19:22:09 -04:00
|
|
|
|
|
|
|
build ();
|
2021-07-21 18:44:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
TriggerBoxUI::~TriggerBoxUI ()
|
|
|
|
{
|
|
|
|
}
|
2021-07-21 19:22:09 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
TriggerBoxUI::build ()
|
|
|
|
{
|
|
|
|
Trigger* t;
|
|
|
|
size_t n = 0;
|
|
|
|
|
2021-07-22 12:33:47 -04:00
|
|
|
// clear_items (true);
|
2021-07-21 19:22:09 -04:00
|
|
|
|
2021-07-27 22:39:55 -04:00
|
|
|
_slots.clear ();
|
|
|
|
|
2021-07-21 19:22:09 -04:00
|
|
|
while (true) {
|
|
|
|
t = _triggerbox.trigger (n);
|
|
|
|
if (!t) {
|
|
|
|
break;
|
|
|
|
}
|
2021-07-29 14:24:04 -04:00
|
|
|
TriggerEntry* te = new TriggerEntry (canvas(), *t);
|
|
|
|
te->set_pack_options (PackOptions (PackFill|PackExpand));
|
|
|
|
add (te);
|
2021-07-27 22:39:55 -04:00
|
|
|
|
|
|
|
_slots.push_back (te);
|
|
|
|
|
|
|
|
te->play_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::bang), n));
|
2021-08-05 14:11:19 -04:00
|
|
|
te->name_text->Event.connect (sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::text_event), n));
|
2021-08-05 17:04:02 -04:00
|
|
|
te->Event.connect (sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::event), n));
|
2021-07-27 22:39:55 -04:00
|
|
|
|
2021-07-27 19:08:31 -04:00
|
|
|
++n;
|
2021-07-21 19:22:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-05 14:11:19 -04:00
|
|
|
bool
|
|
|
|
TriggerBoxUI::text_event (GdkEvent *ev, size_t n)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-08-05 17:04:02 -04:00
|
|
|
bool
|
|
|
|
TriggerBoxUI::event (GdkEvent* ev, size_t n)
|
|
|
|
{
|
|
|
|
switch (ev->type) {
|
2021-08-05 17:56:41 -04:00
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
choose_sample (n);
|
|
|
|
return true;
|
2021-08-05 17:04:02 -04:00
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
switch (ev->button.button) {
|
|
|
|
case 3:
|
|
|
|
context_menu (n);
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-27 22:39:55 -04:00
|
|
|
bool
|
|
|
|
TriggerBoxUI::bang (GdkEvent *ev, size_t n)
|
|
|
|
{
|
2021-08-06 23:27:38 -04:00
|
|
|
if (!_triggerbox.trigger (n)->region()) {
|
|
|
|
/* this is a stop button */
|
|
|
|
switch (ev->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
if (ev->button.button == 1) {
|
|
|
|
_triggerbox.stop_all ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-27 22:39:55 -04:00
|
|
|
switch (ev->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
2021-08-05 17:04:02 -04:00
|
|
|
switch (ev->button.button) {
|
|
|
|
case 1:
|
2021-08-08 21:08:38 -04:00
|
|
|
_slots[n]->trigger().bang ();
|
2021-07-27 22:39:55 -04:00
|
|
|
return true;
|
2021-08-05 17:04:02 -04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
switch (ev->button.button) {
|
|
|
|
case 1:
|
2021-08-08 21:08:38 -04:00
|
|
|
if (_slots[n]->trigger().launch_style() == Trigger::Gate) {
|
|
|
|
_slots[n]->trigger().unbang ();
|
2021-08-05 17:04:02 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2021-07-27 22:39:55 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-08-05 17:04:02 -04:00
|
|
|
void
|
|
|
|
TriggerBoxUI::context_menu (size_t n)
|
|
|
|
{
|
|
|
|
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* follow_menu = manage (new Menu);
|
|
|
|
MenuList& fitems = follow_menu->items();
|
|
|
|
|
|
|
|
fitems.push_back (CheckMenuElem (_("Stop"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::Stop)));
|
|
|
|
if (_triggerbox.trigger (n)->follow_action() == Trigger::Stop) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
fitems.push_back (CheckMenuElem (_("Queued"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::QueuedTrigger)));
|
|
|
|
if (_triggerbox.trigger (n)->follow_action() == Trigger::QueuedTrigger) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
fitems.push_back (CheckMenuElem (_("Next"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::NextTrigger)));
|
|
|
|
if (_triggerbox.trigger (n)->follow_action() == Trigger::NextTrigger) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
fitems.push_back (CheckMenuElem (_("Previous"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::PrevTrigger)));
|
|
|
|
if (_triggerbox.trigger (n)->follow_action() == Trigger::PrevTrigger) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
fitems.push_back (CheckMenuElem (_("First"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::FirstTrigger)));
|
|
|
|
if (_triggerbox.trigger (n)->follow_action() == Trigger::FirstTrigger) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
fitems.push_back (CheckMenuElem (_("Last"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::LastTrigger)));
|
|
|
|
if (_triggerbox.trigger (n)->follow_action() == Trigger::LastTrigger) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
fitems.push_back (CheckMenuElem (_("Any"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::AnyTrigger)));
|
|
|
|
if (_triggerbox.trigger (n)->follow_action() == Trigger::AnyTrigger) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
fitems.push_back (CheckMenuElem (_("Other"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_follow_action), n, Trigger::OtherTrigger)));
|
|
|
|
if (_triggerbox.trigger (n)->follow_action() == Trigger::OtherTrigger) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
Menu* launch_menu = manage (new Menu);
|
|
|
|
MenuList& litems = launch_menu->items();
|
|
|
|
|
|
|
|
litems.push_back (CheckMenuElem (_("Loop"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_launch_style), n, Trigger::Loop)));
|
|
|
|
if (_triggerbox.trigger (n)->launch_style() == Trigger::Loop) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&litems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
litems.push_back (CheckMenuElem (_("Gate"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_launch_style), n, Trigger::Gate)));
|
|
|
|
if (_triggerbox.trigger (n)->launch_style() == Trigger::Gate) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&litems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
litems.push_back (CheckMenuElem (_("Toggle"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_launch_style), n, Trigger::Toggle)));
|
|
|
|
if (_triggerbox.trigger (n)->launch_style() == Trigger::Toggle) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&litems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
litems.push_back (CheckMenuElem (_("Repeat"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_launch_style), n, Trigger::Repeat)));
|
|
|
|
if (_triggerbox.trigger (n)->launch_style() == Trigger::Repeat) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&litems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Menu* quant_menu = manage (new Menu);
|
|
|
|
MenuList& qitems = quant_menu->items();
|
|
|
|
bool success;
|
|
|
|
|
|
|
|
Beats grid_beats (PublicEditor::instance().get_grid_type_as_beats (success, timepos_t (0)));
|
|
|
|
BBT_Offset b;
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
b = BBT_Offset (0, grid_beats.get_beats(), grid_beats.get_ticks());
|
|
|
|
qitems.push_back (CheckMenuElem (_("Main Grid"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
|
2021-08-06 12:24:37 -04:00
|
|
|
/* 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) */
|
2021-08-05 17:04:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
b = BBT_Offset (1, 0, 0);
|
|
|
|
qitems.push_back (CheckMenuElem (_("Bars"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
|
|
|
|
if (_triggerbox.trigger (n)->quantization() == b) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
|
2021-08-06 12:24:37 -04:00
|
|
|
b = BBT_Offset (0, 4, 0);
|
|
|
|
qitems.push_back (CheckMenuElem (_("Whole"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
|
|
|
|
if (_triggerbox.trigger (n)->quantization() == b) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
b = BBT_Offset (0, 2, 0);
|
|
|
|
qitems.push_back (CheckMenuElem (_("Half"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
|
|
|
|
if (_triggerbox.trigger (n)->quantization() == b) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
|
|
|
}
|
2021-08-05 17:04:02 -04:00
|
|
|
b = BBT_Offset (0, 1, 0);
|
|
|
|
qitems.push_back (CheckMenuElem (_("Quarters"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
|
|
|
|
if (_triggerbox.trigger (n)->quantization() == b) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
b = BBT_Offset (0, 0, ticks_per_beat/2);
|
|
|
|
qitems.push_back (CheckMenuElem (_("Eighths"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
|
|
|
|
if (_triggerbox.trigger (n)->quantization() == b) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
b = BBT_Offset (0, 0, ticks_per_beat/4);
|
|
|
|
qitems.push_back (CheckMenuElem (_("Sixteenths"), sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::set_quantization), n, b)));
|
|
|
|
if (_triggerbox.trigger (n)->quantization() == b) {
|
|
|
|
dynamic_cast<Gtk::CheckMenuItem*> (&qitems.back ())->set_active (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
items.push_back (MenuElem (_("Follow Action..."), *follow_menu));
|
|
|
|
items.push_back (MenuElem (_("Launch Style..."), *launch_menu));
|
|
|
|
items.push_back (MenuElem (_("Quantization..."), *quant_menu));
|
|
|
|
|
|
|
|
_context_menu->popup (1, gtk_get_current_event_time());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TriggerBoxUI::set_follow_action (size_t n, Trigger::FollowAction fa)
|
|
|
|
{
|
|
|
|
_triggerbox.trigger (n)->set_follow_action (fa);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TriggerBoxUI::set_launch_style (size_t n, Trigger::LaunchStyle ls)
|
|
|
|
{
|
|
|
|
_triggerbox.trigger (n)->set_launch_style (ls);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TriggerBoxUI::set_quantization (size_t n, Temporal::BBT_Offset const & q)
|
|
|
|
{
|
|
|
|
_triggerbox.trigger (n)->set_quantization (q);
|
|
|
|
}
|
|
|
|
|
2021-08-05 14:11:19 -04:00
|
|
|
void
|
|
|
|
TriggerBoxUI::choose_sample (size_t n)
|
|
|
|
{
|
|
|
|
if (!file_chooser) {
|
|
|
|
file_chooser = new Gtk::FileChooserDialog (_("Select sample"), Gtk::FILE_CHOOSER_ACTION_OPEN);
|
|
|
|
file_chooser->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
|
|
|
file_chooser->add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
file_chooser_connection.disconnect ();
|
|
|
|
file_chooser_connection = file_chooser->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &TriggerBoxUI::sample_chosen), n));
|
|
|
|
|
|
|
|
file_chooser->present ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TriggerBoxUI::sample_chosen (int response, size_t n)
|
|
|
|
{
|
|
|
|
file_chooser->hide ();
|
|
|
|
|
|
|
|
switch (response) {
|
|
|
|
case Gtk::RESPONSE_OK:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string path = file_chooser->get_filename ();
|
|
|
|
|
|
|
|
_triggerbox.set_from_path (n, path);
|
2021-08-06 23:27:38 -04:00
|
|
|
// _triggerbox.trigger (n)->set_length (timecnt_t (Temporal::Beats (4, 0)));
|
2021-08-05 14:11:19 -04:00
|
|
|
}
|
|
|
|
|
2021-07-21 19:22:09 -04:00
|
|
|
/* ------------ */
|
|
|
|
|
|
|
|
TriggerBoxWidget::TriggerBoxWidget (TriggerBox& tb)
|
|
|
|
{
|
|
|
|
ui = new TriggerBoxUI (root(), tb);
|
|
|
|
}
|
2021-07-22 12:33:47 -04:00
|
|
|
|
2021-07-28 00:40:35 -04:00
|
|
|
void
|
|
|
|
TriggerBoxWidget::size_request (double& w, double& h) const
|
|
|
|
{
|
|
|
|
ui->size_request (w, h);
|
|
|
|
}
|
|
|
|
|
2021-07-22 12:33:47 -04:00
|
|
|
/* ------------ */
|
|
|
|
|
|
|
|
TriggerBoxWindow::TriggerBoxWindow (TriggerBox& tb)
|
|
|
|
{
|
|
|
|
TriggerBoxWidget* tbw = manage (new TriggerBoxWidget (tb));
|
|
|
|
set_title (_("TriggerBox for XXXX"));
|
2021-07-28 00:40:35 -04:00
|
|
|
|
|
|
|
double w;
|
|
|
|
double h;
|
|
|
|
|
|
|
|
tbw->size_request (w, h);
|
|
|
|
|
|
|
|
set_default_size (w, h);
|
2021-07-22 12:33:47 -04:00
|
|
|
add (*tbw);
|
|
|
|
tbw->show ();
|
|
|
|
}
|
2021-08-05 17:04:02 -04:00
|
|
|
|
|
|
|
bool
|
|
|
|
TriggerBoxWindow::on_key_press_event (GdkEventKey* ev)
|
|
|
|
{
|
|
|
|
Gtk::Window& main_window (ARDOUR_UI::instance()->main_window());
|
|
|
|
return ARDOUR_UI_UTILS::relay_key_press (ev, &main_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TriggerBoxWindow::on_key_release_event (GdkEventKey* ev)
|
|
|
|
{
|
|
|
|
Gtk::Window& main_window (ARDOUR_UI::instance()->main_window());
|
|
|
|
return ARDOUR_UI_UTILS::relay_key_press (ev, &main_window);
|
|
|
|
}
|