2021-12-07 16:47:00 -05: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.
|
|
|
|
*/
|
|
|
|
|
2022-02-08 17:54:13 -05:00
|
|
|
#include <pangomm.h>
|
|
|
|
|
2021-12-07 16:47:00 -05:00
|
|
|
#include "pbd/compose.h"
|
|
|
|
#include "pbd/convert.h"
|
|
|
|
|
|
|
|
#include "ardour/region.h"
|
2021-12-23 23:14:48 -05:00
|
|
|
#include "ardour/session.h"
|
2021-12-07 16:47:00 -05:00
|
|
|
#include "ardour/triggerbox.h"
|
|
|
|
|
2022-01-18 16:52:54 -05:00
|
|
|
#include "canvas/circle.h"
|
2021-12-07 16:47:00 -05:00
|
|
|
#include "canvas/polygon.h"
|
|
|
|
#include "canvas/text.h"
|
|
|
|
|
2021-12-23 23:14:48 -05:00
|
|
|
#include <gtkmm/menu.h>
|
|
|
|
#include <gtkmm/menuitem.h>
|
2022-02-08 17:54:13 -05:00
|
|
|
|
|
|
|
#include "gtkmm2ext/actions.h"
|
|
|
|
#include "gtkmm2ext/colors.h"
|
2021-12-07 16:47:00 -05:00
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "cuebox_ui.h"
|
2021-12-17 10:32:52 -05:00
|
|
|
#include "gui_thread.h"
|
2021-12-07 16:47:00 -05:00
|
|
|
#include "public_editor.h"
|
|
|
|
#include "region_view.h"
|
|
|
|
#include "selection.h"
|
|
|
|
#include "timers.h"
|
2021-12-23 23:14:48 -05:00
|
|
|
#include "trigger_ui.h"
|
2021-12-07 16:47:00 -05:00
|
|
|
#include "ui_config.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include "pbd/i18n.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace ArdourCanvas;
|
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
using namespace PBD;
|
|
|
|
|
|
|
|
CueEntry::CueEntry (Item* item, uint64_t cue_index)
|
|
|
|
: ArdourCanvas::Rectangle (item)
|
|
|
|
, _cue_idx (cue_index)
|
2022-01-26 10:22:15 -05:00
|
|
|
, _grabbed (false)
|
2021-12-07 16:47:00 -05:00
|
|
|
{
|
2021-12-17 10:32:52 -05:00
|
|
|
set_layout_sensitive (true); // why???
|
2021-12-07 16:47:00 -05:00
|
|
|
|
|
|
|
name = string_compose ("cue %1", _cue_idx);
|
|
|
|
|
|
|
|
Event.connect (sigc::mem_fun (*this, &CueEntry::event_handler));
|
|
|
|
|
|
|
|
set_outline (false);
|
2021-12-17 10:32:52 -05:00
|
|
|
set_fill_color (UIConfiguration::instance ().color ("theme:bg"));
|
2021-12-07 16:47:00 -05:00
|
|
|
|
2022-01-18 16:52:54 -05:00
|
|
|
name_button = new ArdourCanvas::Circle (this);
|
2021-12-28 09:14:44 -05:00
|
|
|
name_button->set_outline (false);
|
|
|
|
name_button->set_fill (true);
|
2021-12-07 16:47:00 -05:00
|
|
|
name_button->name = ("slot_selector_button");
|
|
|
|
name_button->show ();
|
|
|
|
|
2022-08-04 14:40:06 -04:00
|
|
|
jump_text = new ArdourCanvas::Text (this);
|
|
|
|
jump_text->set_outline (false);
|
|
|
|
jump_text->set_fill (true);
|
|
|
|
jump_text->name = ("slot_selector_button");
|
|
|
|
jump_text->set (cue_marker_name (_cue_idx));
|
|
|
|
jump_text->show ();
|
|
|
|
|
2022-02-19 13:12:43 -05:00
|
|
|
set_tooltip (_("Click to launch all clips in this row\nRight-click to select properties for all clips in this row"));
|
|
|
|
|
2022-01-23 20:33:16 -05:00
|
|
|
/* watch for cue-recording state */
|
|
|
|
TriggerBox::CueRecordingChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&CueEntry::rec_state_changed, this), gui_context ());
|
|
|
|
|
2021-12-07 16:47:00 -05:00
|
|
|
/* watch for change in theme */
|
2021-12-17 10:32:52 -05:00
|
|
|
UIConfiguration::instance ().ParameterChanged.connect (sigc::mem_fun (*this, &CueEntry::ui_parameter_changed));
|
|
|
|
set_default_colors ();
|
2021-12-07 16:47:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
CueEntry::~CueEntry ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CueEntry::event_handler (GdkEvent* ev)
|
|
|
|
{
|
|
|
|
switch (ev->type) {
|
2021-12-17 10:32:52 -05:00
|
|
|
case GDK_BUTTON_PRESS:
|
2022-01-26 10:22:15 -05:00
|
|
|
_grabbed = true;
|
|
|
|
set_fill_color (UIConfiguration::instance ().color ("neutral:foregroundest"));
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
_grabbed = false;
|
|
|
|
set_default_colors ();
|
2021-12-17 10:32:52 -05:00
|
|
|
break;
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
|
2022-01-21 18:17:53 -05:00
|
|
|
name_button->set_fill_color (UIConfiguration::instance ().color ("neutral:foregroundest"));
|
2021-12-17 10:32:52 -05:00
|
|
|
set_fill_color (HSV (fill_color ()).lighter (0.15).color ());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
2022-01-26 10:22:15 -05:00
|
|
|
_grabbed = false;
|
2021-12-17 10:32:52 -05:00
|
|
|
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
|
|
|
|
set_default_colors ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2021-12-07 16:47:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-17 10:32:52 -05:00
|
|
|
CueEntry::_size_allocate (ArdourCanvas::Rect const& alloc)
|
2021-12-07 16:47:00 -05:00
|
|
|
{
|
2021-12-16 17:42:33 -05:00
|
|
|
ArdourCanvas::Rectangle::_size_allocate (alloc);
|
2021-12-07 16:47:00 -05:00
|
|
|
|
2022-08-04 14:40:06 -04:00
|
|
|
const Distance width = _rect.width ();
|
2021-12-17 10:32:52 -05:00
|
|
|
const Distance height = _rect.height ();
|
2021-12-07 16:47:00 -05:00
|
|
|
|
2021-12-17 10:32:52 -05:00
|
|
|
const double scale = UIConfiguration::instance ().get_ui_scale ();
|
2021-12-07 16:47:00 -05:00
|
|
|
|
2022-01-18 16:52:54 -05:00
|
|
|
name_button->set_center ( Duple(height/2, height/2) );
|
2022-08-04 14:40:06 -04:00
|
|
|
name_button->set_radius ( (height/2)- 1*scale );
|
|
|
|
|
Fix typos
Found via `codespell -q 3 -S *.po,./.git,./share/patchfiles,./libs,./msvc_extra_headers,./share/web_surfaces,*.patch -L acount,ba,buss,busses,discreet,doubleclick,hsi,ontop,retrn,ro,scrollin,seh,siz,sord,sur,te,trough,ue`
2022-09-21 21:01:23 -04:00
|
|
|
/* have to do this in the size-allocate if we want to dynamically respond to scale-changes */
|
2022-08-04 14:40:06 -04:00
|
|
|
jump_text->set_font_description (UIConfiguration::instance().get_NormalFont());
|
|
|
|
jump_text->set_alignment (Pango::ALIGN_CENTER);
|
|
|
|
|
|
|
|
/* calculate centering offset */
|
|
|
|
int cx = (width-jump_text->text_width())/2;
|
|
|
|
int cy = (0.5+height-jump_text->text_height())/2;
|
|
|
|
|
|
|
|
jump_text->set_position ( Duple(cx,cy) );
|
|
|
|
jump_text->set_size_request ( width, height );
|
2021-12-07 16:47:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-17 10:32:52 -05:00
|
|
|
CueEntry::render (ArdourCanvas::Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
|
2021-12-07 16:47:00 -05:00
|
|
|
{
|
2021-12-17 10:32:52 -05:00
|
|
|
ArdourCanvas::Rectangle::render (area, context);
|
2021-12-12 12:20:11 -05:00
|
|
|
|
|
|
|
/* Note that item_to_window() already takes _position into account (as
|
2021-12-17 10:32:52 -05:00
|
|
|
* part of item_to_canvas()
|
|
|
|
*/
|
|
|
|
ArdourCanvas::Rect self (item_to_window (_rect));
|
2021-12-16 17:42:33 -05:00
|
|
|
const ArdourCanvas::Rect draw = self.intersection (area);
|
2021-12-12 12:20:11 -05:00
|
|
|
|
|
|
|
if (!draw) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_fill && !_transparent) {
|
|
|
|
setup_fill_context (context);
|
2021-12-17 10:32:52 -05:00
|
|
|
context->rectangle (draw.x0, draw.y0, draw.width (), draw.height ());
|
2021-12-12 12:20:11 -05:00
|
|
|
context->fill ();
|
|
|
|
}
|
|
|
|
|
|
|
|
render_children (area, context);
|
2021-12-07 16:47:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
CueEntry::set_default_colors ()
|
2021-12-07 16:47:00 -05:00
|
|
|
{
|
2022-01-18 16:52:54 -05:00
|
|
|
color_t bg_col = UIConfiguration::instance ().color ("theme:bg");
|
2021-12-17 10:32:52 -05:00
|
|
|
if ((_cue_idx / 2) % 2 == 0) {
|
2022-01-18 16:52:54 -05:00
|
|
|
bg_col = HSV (bg_col).darker (0.25).color ();
|
2021-12-07 16:47:42 -05:00
|
|
|
}
|
2022-01-18 16:52:54 -05:00
|
|
|
set_fill_color (bg_col);
|
2022-01-23 18:53:45 -05:00
|
|
|
|
2022-02-08 17:54:13 -05:00
|
|
|
color_t fg_col = UIConfiguration::instance ().color ("location marker");
|
2022-01-23 18:53:45 -05:00
|
|
|
if ((_cue_idx / 2) % 2 == 0) {
|
|
|
|
fg_col = HSV (fg_col).darker (0.20).color ();
|
|
|
|
}
|
|
|
|
name_button->set_fill_color (fg_col);
|
|
|
|
|
|
|
|
if (TriggerBox::cue_recording()) {
|
2022-01-23 20:33:16 -05:00
|
|
|
name_button->set_fill_color (UIConfiguration::instance ().color ("alert:ruddy"));
|
|
|
|
}
|
2021-12-07 16:47:42 -05:00
|
|
|
}
|
2021-12-07 16:47:00 -05:00
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
void
|
|
|
|
CueEntry::ui_parameter_changed (std::string const& p)
|
|
|
|
{
|
|
|
|
if (p == "color-file") {
|
|
|
|
set_default_colors ();
|
2021-12-07 16:47:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-23 20:33:16 -05:00
|
|
|
void
|
|
|
|
CueEntry::rec_state_changed ()
|
|
|
|
{
|
|
|
|
set_default_colors ();
|
|
|
|
}
|
|
|
|
|
2021-12-07 16:47:00 -05:00
|
|
|
CueBoxUI::CueBoxUI (ArdourCanvas::Item* parent)
|
2021-12-16 17:42:33 -05:00
|
|
|
: ArdourCanvas::Rectangle (parent)
|
2021-12-23 23:14:48 -05:00
|
|
|
, _context_menu (0)
|
2021-12-07 16:47:00 -05:00
|
|
|
{
|
2021-12-17 10:32:52 -05:00
|
|
|
set_layout_sensitive (true); // why???
|
2021-12-07 16:47:00 -05:00
|
|
|
|
2021-12-17 10:32:52 -05:00
|
|
|
set_fill_color (UIConfiguration::instance ().color (X_("theme:bg")));
|
2021-12-07 16:47:00 -05:00
|
|
|
set_fill (true);
|
|
|
|
|
|
|
|
build ();
|
|
|
|
}
|
|
|
|
|
|
|
|
CueBoxUI::~CueBoxUI ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-12-23 23:14:48 -05:00
|
|
|
void
|
|
|
|
CueBoxUI::context_menu (uint64_t idx)
|
|
|
|
{
|
|
|
|
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 ();
|
|
|
|
|
2022-01-19 17:50:47 -05:00
|
|
|
fitems.push_back (MenuElem (TriggerUI::follow_action_to_string(FollowAction (FollowAction::None)), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_follow_action), FollowAction (FollowAction::None), idx)));
|
|
|
|
fitems.push_back (MenuElem (TriggerUI::follow_action_to_string(FollowAction (FollowAction::Stop)), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_follow_action), FollowAction (FollowAction::Stop), idx)));
|
|
|
|
fitems.push_back (MenuElem (TriggerUI::follow_action_to_string(FollowAction (FollowAction::Again)), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_follow_action), FollowAction (FollowAction::Again), idx)));
|
|
|
|
fitems.push_back (MenuElem (TriggerUI::follow_action_to_string(FollowAction (FollowAction::ReverseTrigger)), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_follow_action), FollowAction (FollowAction::ReverseTrigger), idx)));
|
|
|
|
fitems.push_back (MenuElem (TriggerUI::follow_action_to_string(FollowAction (FollowAction::ForwardTrigger)), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_follow_action), FollowAction (FollowAction::ForwardTrigger), idx)));
|
2022-01-21 15:46:40 -05:00
|
|
|
Menu* jump_menu = manage (new Menu);
|
|
|
|
MenuList& jitems = jump_menu->items ();
|
2022-10-04 21:55:15 -04:00
|
|
|
for (int i = 0; i < TriggerBox::default_triggers_per_box; i++) {
|
2022-01-21 15:46:40 -05:00
|
|
|
FollowAction jump_fa = (FollowAction::JumpTrigger);
|
|
|
|
jump_fa.targets.set(i);
|
2022-02-11 13:33:43 -05:00
|
|
|
jitems.push_back (MenuElem (cue_marker_name (i), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_follow_action), jump_fa, idx)));
|
2022-01-21 15:46:40 -05:00
|
|
|
}
|
|
|
|
fitems.push_back (MenuElem (_("Jump..."), *jump_menu));
|
2021-12-23 23:14:48 -05:00
|
|
|
|
|
|
|
Menu* launch_menu = manage (new Menu);
|
|
|
|
MenuList& litems = launch_menu->items ();
|
|
|
|
|
|
|
|
litems.push_back (MenuElem (TriggerUI::launch_style_to_string(Trigger::OneShot), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_launch_style), Trigger::OneShot, idx)));
|
2022-01-03 19:45:13 -05:00
|
|
|
litems.push_back (MenuElem (TriggerUI::launch_style_to_string(Trigger::ReTrigger), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_launch_style), Trigger::ReTrigger, idx)));
|
2021-12-23 23:14:48 -05:00
|
|
|
litems.push_back (MenuElem (TriggerUI::launch_style_to_string(Trigger::Gate), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_launch_style), Trigger::Gate, idx)));
|
|
|
|
litems.push_back (MenuElem (TriggerUI::launch_style_to_string(Trigger::Toggle), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_launch_style), Trigger::Toggle, idx)));
|
|
|
|
litems.push_back (MenuElem (TriggerUI::launch_style_to_string(Trigger::Repeat), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_launch_style), Trigger::Repeat, idx)));
|
|
|
|
|
|
|
|
Menu* quant_menu = manage (new Menu);
|
|
|
|
MenuList& qitems = quant_menu->items ();
|
|
|
|
|
|
|
|
BBT_Offset b;
|
|
|
|
|
2022-01-07 09:51:18 -05:00
|
|
|
b = BBT_Offset (4, 0, 0);
|
2022-01-07 19:05:38 -05:00
|
|
|
qitems.push_back (MenuElem (TriggerUI::quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_quantization), b, idx)));
|
2022-01-07 09:51:18 -05:00
|
|
|
b = BBT_Offset (2, 0, 0);
|
2022-01-07 19:05:38 -05:00
|
|
|
qitems.push_back (MenuElem (TriggerUI::quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_quantization), b, idx)));
|
2021-12-23 23:14:48 -05:00
|
|
|
b = BBT_Offset (1, 0, 0);
|
2022-01-07 19:05:38 -05:00
|
|
|
qitems.push_back (MenuElem (TriggerUI::quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_quantization), b, idx)));
|
2021-12-23 23:14:48 -05:00
|
|
|
b = BBT_Offset (0, 2, 0);
|
2022-01-07 19:05:38 -05:00
|
|
|
qitems.push_back (MenuElem (TriggerUI::quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_quantization), b, idx)));
|
2021-12-23 23:14:48 -05:00
|
|
|
b = BBT_Offset (0, 1, 0);
|
2022-01-07 19:05:38 -05:00
|
|
|
qitems.push_back (MenuElem (TriggerUI::quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_quantization), b, idx)));
|
2021-12-23 23:14:48 -05:00
|
|
|
b = BBT_Offset (0, 0, ticks_per_beat / 2);
|
2022-01-07 19:05:38 -05:00
|
|
|
qitems.push_back (MenuElem (TriggerUI::quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_quantization), b, idx)));
|
2021-12-23 23:14:48 -05:00
|
|
|
b = BBT_Offset (0, 0, ticks_per_beat / 4);
|
2022-01-07 19:05:38 -05:00
|
|
|
qitems.push_back (MenuElem (TriggerUI::quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_quantization), b, idx)));
|
2021-12-23 23:14:48 -05:00
|
|
|
b = BBT_Offset (0, 0, ticks_per_beat / 8);
|
2022-01-07 19:05:38 -05:00
|
|
|
qitems.push_back (MenuElem (TriggerUI::quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_quantization), b, idx)));
|
2021-12-23 23:14:48 -05:00
|
|
|
b = BBT_Offset (0, 0, ticks_per_beat / 16);
|
2022-01-07 19:05:38 -05:00
|
|
|
qitems.push_back (MenuElem (TriggerUI::quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_quantization), b, idx)));
|
2022-01-07 19:06:31 -05:00
|
|
|
b = BBT_Offset (-1, 0, 0);
|
|
|
|
qitems.push_back (MenuElem (TriggerUI::quantize_length_to_string (b), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_quantization), b, idx)));
|
2021-12-23 23:14:48 -05:00
|
|
|
|
|
|
|
items.push_back (MenuElem (_("Set All Follow Actions..."), *follow_menu));
|
|
|
|
items.push_back (MenuElem (_("Set All Launch Styles..."), *launch_menu));
|
|
|
|
items.push_back (MenuElem (_("Set All Quantizations..."), *quant_menu));
|
|
|
|
items.push_back (SeparatorElem());
|
2021-12-27 18:35:24 -05:00
|
|
|
items.push_back (MenuElem (_("Set All Colors..."), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_colors), idx)));
|
|
|
|
items.push_back (SeparatorElem());
|
2021-12-23 23:14:48 -05:00
|
|
|
items.push_back (MenuElem (_("Clear All..."), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::clear_all_triggers), idx)));
|
|
|
|
|
|
|
|
_context_menu->popup (1, gtk_get_current_event_time ());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CueBoxUI::get_slots (TriggerList &triggerlist, uint64_t idx)
|
|
|
|
{
|
|
|
|
boost::shared_ptr<RouteList> rl = _session->get_routes();
|
|
|
|
for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
|
|
|
|
boost::shared_ptr<Route> route = *r;
|
|
|
|
boost::shared_ptr<TriggerBox> box = route->triggerbox();
|
|
|
|
#warning @Ben disambiguate processor *active* vs *visibility*
|
|
|
|
if (box /*&& box.active*/) {
|
|
|
|
TriggerPtr trigger = box->trigger(idx);
|
|
|
|
triggerlist.push_back(trigger);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CueBoxUI::clear_all_triggers (uint64_t idx)
|
|
|
|
{
|
|
|
|
TriggerList tl;
|
|
|
|
get_slots(tl, idx);
|
|
|
|
for (TriggerList::iterator t = tl.begin(); t != tl.end(); ++t) {
|
|
|
|
(*t)->set_region(boost::shared_ptr<Region>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-27 18:35:24 -05:00
|
|
|
void
|
|
|
|
CueBoxUI::set_all_colors (uint64_t idx)
|
|
|
|
{
|
2022-01-26 18:06:19 -05:00
|
|
|
_color_dialog.get_color_selection()->set_has_opacity_control (false);
|
|
|
|
_color_dialog.get_color_selection()->set_has_palette (true);
|
2021-12-27 18:35:24 -05:00
|
|
|
_color_dialog.get_ok_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_ACCEPT));
|
|
|
|
_color_dialog.get_cancel_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_CANCEL));
|
|
|
|
|
2022-08-10 23:11:52 -04:00
|
|
|
Gdk::Color c = Gtkmm2ext::gdk_color_from_rgba(0xBEBEBEFF);
|
2021-12-27 18:35:24 -05:00
|
|
|
|
2022-01-26 18:06:19 -05:00
|
|
|
_color_dialog.get_color_selection()->set_previous_color (c);
|
|
|
|
_color_dialog.get_color_selection()->set_current_color (c);
|
2021-12-27 18:35:24 -05:00
|
|
|
|
|
|
|
switch (_color_dialog.run()) {
|
|
|
|
case Gtk::RESPONSE_ACCEPT: {
|
2022-01-26 18:06:19 -05:00
|
|
|
c = _color_dialog.get_color_selection()->get_current_color();
|
2022-08-10 23:11:52 -04:00
|
|
|
color_t ct = Gtkmm2ext::gdk_color_to_rgba(c);
|
2021-12-27 18:35:24 -05:00
|
|
|
TriggerList tl;
|
|
|
|
get_slots(tl, idx);
|
|
|
|
for (TriggerList::iterator t = tl.begin(); t != tl.end(); ++t) {
|
|
|
|
(*t)->set_color(ct);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
_color_dialog.hide ();
|
|
|
|
}
|
|
|
|
|
2021-12-23 23:14:48 -05:00
|
|
|
void
|
2022-01-19 17:50:47 -05:00
|
|
|
CueBoxUI::set_all_follow_action (FollowAction const & fa, uint64_t idx)
|
2021-12-23 23:14:48 -05:00
|
|
|
{
|
|
|
|
TriggerList tl;
|
|
|
|
get_slots(tl, idx);
|
|
|
|
for (TriggerList::iterator t = tl.begin(); t != tl.end(); ++t) {
|
2022-01-25 20:07:13 -05:00
|
|
|
(*t)->set_follow_action0 (fa);
|
2021-12-23 23:14:48 -05:00
|
|
|
(*t)->set_follow_action_probability(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CueBoxUI::set_all_launch_style (Trigger::LaunchStyle ls, uint64_t idx)
|
|
|
|
{
|
|
|
|
TriggerList tl;
|
|
|
|
get_slots(tl, idx);
|
|
|
|
for (TriggerList::iterator t = tl.begin(); t != tl.end(); ++t) {
|
|
|
|
(*t)->set_launch_style(ls);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CueBoxUI::set_all_quantization (Temporal::BBT_Offset const& q, uint64_t idx)
|
|
|
|
{
|
|
|
|
TriggerList tl;
|
|
|
|
get_slots(tl, idx);
|
|
|
|
for (TriggerList::iterator t = tl.begin(); t != tl.end(); ++t) {
|
|
|
|
(*t)->set_quantization(q);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-07 16:47:00 -05:00
|
|
|
void
|
2022-09-26 16:48:30 -04:00
|
|
|
CueBoxUI::trigger_cue_row (uint64_t n)
|
2021-12-07 16:47:00 -05:00
|
|
|
{
|
2022-09-26 16:48:30 -04:00
|
|
|
_session->trigger_cue_row (n);
|
2021-12-07 16:47:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CueBoxUI::build ()
|
|
|
|
{
|
|
|
|
// clear_items (true);
|
|
|
|
|
|
|
|
_slots.clear ();
|
|
|
|
|
2022-10-04 21:55:15 -04:00
|
|
|
for (int32_t n = 0; n < TriggerBox::default_triggers_per_box; ++n) { // TODO
|
2021-12-07 16:47:00 -05:00
|
|
|
CueEntry* te = new CueEntry (this, n);
|
|
|
|
|
|
|
|
_slots.push_back (te);
|
|
|
|
|
|
|
|
te->Event.connect (sigc::bind (sigc::mem_fun (*this, &CueBoxUI::event), n));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-17 10:32:52 -05:00
|
|
|
CueBoxUI::_size_allocate (ArdourCanvas::Rect const& alloc)
|
2021-12-07 16:47:00 -05:00
|
|
|
{
|
2021-12-16 17:42:33 -05:00
|
|
|
ArdourCanvas::Rectangle::_size_allocate (alloc);
|
2021-12-07 16:47:00 -05:00
|
|
|
|
2021-12-17 10:32:52 -05:00
|
|
|
const float width = alloc.width ();
|
|
|
|
const float height = alloc.height ();
|
2021-12-07 16:47:00 -05:00
|
|
|
|
2022-10-04 21:55:15 -04:00
|
|
|
const float slot_h = height / TriggerBox::default_triggers_per_box; // TODO
|
2021-12-07 16:47:00 -05:00
|
|
|
|
|
|
|
float ypos = 0;
|
2021-12-17 10:32:52 -05:00
|
|
|
for (auto& slot : _slots) {
|
2021-12-17 06:07:45 -05:00
|
|
|
slot->size_allocate (ArdourCanvas::Rect (0, 0, width, slot_h));
|
2021-12-07 16:47:00 -05:00
|
|
|
slot->set_position (Duple (0, ypos));
|
|
|
|
ypos += slot_h;
|
2021-12-17 10:32:52 -05:00
|
|
|
slot->show ();
|
2021-12-07 16:47:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2021-12-17 10:32:52 -05:00
|
|
|
CueBoxUI::text_event (GdkEvent* ev, uint64_t n)
|
2021-12-07 16:47:00 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CueBoxUI::event (GdkEvent* ev, uint64_t n)
|
|
|
|
{
|
|
|
|
switch (ev->type) {
|
2021-12-17 10:32:52 -05:00
|
|
|
case GDK_BUTTON_PRESS:
|
2021-12-23 23:14:48 -05:00
|
|
|
if (ev->button.button==1) {
|
2022-09-26 16:48:30 -04:00
|
|
|
trigger_cue_row (n);
|
2021-12-23 23:14:48 -05:00
|
|
|
}
|
2021-12-17 10:32:52 -05:00
|
|
|
break;
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
2021-12-23 23:14:48 -05:00
|
|
|
switch (ev->button.button) {
|
|
|
|
case 3:
|
|
|
|
context_menu (n);
|
|
|
|
return true;
|
|
|
|
}
|
2021-12-17 10:32:52 -05:00
|
|
|
default:
|
|
|
|
break;
|
2021-12-07 16:47:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-12-17 10:32:52 -05:00
|
|
|
CueBoxWidget::CueBoxWidget (float w, float h)
|
|
|
|
: FittedCanvasWidget (w, h)
|
2021-12-07 16:47:00 -05:00
|
|
|
{
|
2021-12-17 10:32:52 -05:00
|
|
|
ui = new CueBoxUI (root ());
|
|
|
|
set_background_color (UIConfiguration::instance ().color (X_("theme:bg")));
|
2021-12-07 16:47:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CueBoxWidget::on_map ()
|
|
|
|
{
|
|
|
|
FittedCanvasWidget::on_map ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CueBoxWidget::on_unmap ()
|
|
|
|
{
|
|
|
|
FittedCanvasWidget::on_unmap ();
|
|
|
|
}
|
|
|
|
|
|
|
|
CueBoxWindow::CueBoxWindow ()
|
|
|
|
{
|
2022-10-04 21:55:15 -04:00
|
|
|
CueBoxWidget* tbw = manage (new CueBoxWidget (-1., TriggerBox::default_triggers_per_box * 16.));
|
2021-12-07 16:47:00 -05:00
|
|
|
set_title (_("CueBox for XXXX"));
|
|
|
|
|
2022-10-04 21:55:15 -04:00
|
|
|
set_default_size (-1., TriggerBox::default_triggers_per_box * 16.);
|
2021-12-07 16:47:00 -05:00
|
|
|
add (*tbw);
|
|
|
|
tbw->show ();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CueBoxWindow::on_key_press_event (GdkEventKey* ev)
|
|
|
|
{
|
2021-12-17 10:32:52 -05:00
|
|
|
Gtk::Window& main_window (ARDOUR_UI::instance ()->main_window ());
|
2021-12-07 16:47:00 -05:00
|
|
|
return ARDOUR_UI_UTILS::relay_key_press (ev, &main_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CueBoxWindow::on_key_release_event (GdkEventKey* ev)
|
|
|
|
{
|
2021-12-17 10:32:52 -05:00
|
|
|
Gtk::Window& main_window (ARDOUR_UI::instance ()->main_window ());
|
2021-12-07 16:47:00 -05:00
|
|
|
return ARDOUR_UI_UTILS::relay_key_press (ev, &main_window);
|
|
|
|
}
|