2021-12-05 11:56:42 -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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtkmm/filechooserdialog.h>
|
|
|
|
#include <gtkmm/menu.h>
|
|
|
|
#include <gtkmm/menuitem.h>
|
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
|
|
|
|
#include "pbd/compose.h"
|
|
|
|
#include "pbd/convert.h"
|
|
|
|
|
|
|
|
#include "ardour/region.h"
|
|
|
|
#include "ardour/triggerbox.h"
|
|
|
|
|
|
|
|
#include "canvas/polygon.h"
|
|
|
|
#include "canvas/text.h"
|
|
|
|
|
|
|
|
#include "gtkmm2ext/actions.h"
|
|
|
|
#include "gtkmm2ext/colors.h"
|
|
|
|
#include "gtkmm2ext/utils.h"
|
|
|
|
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "gui_thread.h"
|
2021-12-07 16:47:42 -05:00
|
|
|
#include "trigger_master.h"
|
2021-12-05 11:56:42 -05:00
|
|
|
#include "trigger_ui.h"
|
|
|
|
#include "public_editor.h"
|
|
|
|
#include "region_view.h"
|
|
|
|
#include "selection.h"
|
|
|
|
#include "timers.h"
|
|
|
|
#include "ui_config.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
#include "pbd/i18n.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace ArdourCanvas;
|
|
|
|
using namespace Gtkmm2ext;
|
|
|
|
using namespace PBD;
|
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
TriggerMaster::TriggerMaster (Item* parent, boost::shared_ptr<TriggerBox> t)
|
2021-12-05 11:56:42 -05:00
|
|
|
: ArdourCanvas::Rectangle (parent)
|
|
|
|
, _triggerbox (t)
|
|
|
|
{
|
|
|
|
set_layout_sensitive(true); //why???
|
|
|
|
|
|
|
|
name = X_("trigger stopper");
|
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
Event.connect (sigc::mem_fun (*this, &TriggerMaster::event_handler));
|
2021-12-05 11:56:42 -05:00
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
active_bar = new ArdourCanvas::Rectangle (this);
|
|
|
|
active_bar->set_outline (false);
|
|
|
|
|
|
|
|
stop_shape = new ArdourCanvas::Polygon (this);
|
|
|
|
stop_shape->set_outline (false);
|
|
|
|
stop_shape->name = X_("stopbutton");
|
|
|
|
stop_shape->set_ignore_events (true);
|
|
|
|
stop_shape->show ();
|
2021-12-05 11:56:42 -05:00
|
|
|
|
|
|
|
name_text = new Text (this);
|
|
|
|
name_text->set("Now Playing");
|
|
|
|
name_text->set_ignore_events (false);
|
|
|
|
|
|
|
|
/* trigger changes */
|
2021-12-07 16:47:42 -05:00
|
|
|
_triggerbox->PropertyChanged.connect (trigger_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerMaster::prop_change, this, _1), gui_context());
|
2021-12-05 11:56:42 -05:00
|
|
|
|
|
|
|
/* route changes */
|
2021-12-07 16:47:42 -05:00
|
|
|
// dynamic_cast<Stripable*> (_triggerbox->owner())->presentation_info().Change.connect (owner_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerMaster::owner_prop_change, this, _1), gui_context());
|
2021-12-05 11:56:42 -05:00
|
|
|
|
|
|
|
PropertyChange changed;
|
|
|
|
changed.add (ARDOUR::Properties::name);
|
|
|
|
changed.add (ARDOUR::Properties::running);
|
|
|
|
prop_change (changed);
|
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
/* prefs (theme colors) */
|
|
|
|
UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &TriggerMaster::ui_parameter_changed));
|
|
|
|
set_default_colors();
|
2021-12-05 11:56:42 -05:00
|
|
|
}
|
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
TriggerMaster::~TriggerMaster ()
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
TriggerMaster::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
/* Note that item_to_window() already takes _position into account (as
|
|
|
|
part of item_to_canvas()
|
|
|
|
*/
|
|
|
|
Rect self (item_to_window (_rect));
|
|
|
|
const Rect draw = self.intersection (area);
|
|
|
|
|
|
|
|
if (!draw) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
float width = _rect.width();
|
|
|
|
float height = _rect.height();
|
|
|
|
|
|
|
|
const double scale = UIConfiguration::instance().get_ui_scale();
|
|
|
|
|
|
|
|
if (_fill && !_transparent) {
|
|
|
|
setup_fill_context (context);
|
|
|
|
context->rectangle (draw.x0, draw.y0, draw.width(), draw.height());
|
|
|
|
context->fill ();
|
|
|
|
}
|
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
render_children (area, context);
|
2021-12-12 12:20:11 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
//line at right
|
|
|
|
context->set_identity_matrix();
|
|
|
|
context->translate (self.x0, self.y0-0.5);
|
|
|
|
set_source_rgba (context, rgba_to_color (0,0,0,1));
|
|
|
|
context->rectangle(width-1, 0, width, height);
|
|
|
|
context->fill ();
|
|
|
|
context->set_identity_matrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
//line at top
|
|
|
|
context->set_identity_matrix();
|
|
|
|
context->translate (self.x0, self.y0-0.5);
|
|
|
|
set_source_rgba (context, rgba_to_color (0,0,0,1));
|
|
|
|
context->rectangle(0, 0, width, 1.);
|
|
|
|
context->fill ();
|
|
|
|
context->set_identity_matrix();
|
2021-12-05 11:56:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
TriggerMaster::owner_prop_change (PropertyChange const & pc)
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
if (pc.contains (Properties::color)) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
TriggerMaster::selection_change ()
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2021-12-07 16:47:42 -05:00
|
|
|
TriggerMaster::event_handler (GdkEvent* ev)
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
switch (ev->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
if (ev->button.button == 1) {
|
|
|
|
_triggerbox->request_stop_all ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
|
2021-12-12 12:20:11 -05:00
|
|
|
name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest"));
|
2021-12-07 16:47:42 -05:00
|
|
|
stop_shape->set_fill_color (UIConfiguration::instance().color("neutral:foregroundest"));
|
2021-12-12 12:20:11 -05:00
|
|
|
set_fill_color (HSV (fill_color()).lighter(0.15).color ());
|
2021-12-05 11:56:42 -05:00
|
|
|
}
|
|
|
|
redraw ();
|
|
|
|
break;
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
|
2021-12-12 12:20:11 -05:00
|
|
|
set_default_colors();
|
2021-12-05 11:56:42 -05:00
|
|
|
}
|
|
|
|
redraw ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
TriggerMaster::maybe_update ()
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
/* double nbw;
|
|
|
|
|
|
|
|
if (!_trigger->active()) {
|
|
|
|
nbw = 0;
|
|
|
|
} else {
|
|
|
|
nbw = _trigger->position_as_fraction () * (_allocation.width() - _allocation.height());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nbw) {
|
|
|
|
const double scale = UIConfiguration::instance().get_ui_scale();
|
|
|
|
ArdourCanvas::Rect r (get());
|
|
|
|
|
|
|
|
active_bar->set (ArdourCanvas::Rect (r.height() * scale,
|
|
|
|
(r.y0 + 1) * scale,
|
|
|
|
(r.height() + nbw - 1) * scale,
|
|
|
|
(r.y1 - 1) * scale));
|
|
|
|
active_bar->show ();
|
|
|
|
} else {
|
|
|
|
active_bar->hide ();
|
|
|
|
}
|
|
|
|
* */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
TriggerMaster::_size_allocate (ArdourCanvas::Rect const & alloc)
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
Rectangle::_size_allocate (alloc);
|
|
|
|
|
|
|
|
const double scale = UIConfiguration::instance().get_ui_scale();
|
|
|
|
poly_margin = 2. * scale;
|
|
|
|
|
|
|
|
const Distance width = _rect.width();
|
|
|
|
const Distance height = _rect.height();
|
|
|
|
|
|
|
|
poly_size = height - (poly_margin*2);
|
|
|
|
|
|
|
|
Points p;
|
|
|
|
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));
|
2021-12-07 16:47:42 -05:00
|
|
|
stop_shape->set (p);
|
2021-12-05 11:56:42 -05:00
|
|
|
|
|
|
|
float tleft = poly_size + (poly_margin*3);
|
|
|
|
float twidth = width-poly_size-(poly_margin*3);
|
|
|
|
|
|
|
|
ArdourCanvas::Rect text_alloc (tleft, 0, twidth, height); //testing
|
|
|
|
name_text->size_allocate (text_alloc);
|
|
|
|
name_text->set_position (Duple (tleft, 1.*scale));
|
|
|
|
name_text->clamp_width (twidth);
|
|
|
|
|
|
|
|
//font scale may have changed. uiconfig 'embeds' the ui-scale in the font
|
|
|
|
name_text->set_font_description (UIConfiguration::instance().get_NormalFont());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
TriggerMaster::prop_change (PropertyChange const & change)
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
if (change.contains (ARDOUR::Properties::name)
|
|
|
|
|| change.contains (ARDOUR::Properties::running)
|
|
|
|
) {
|
|
|
|
ARDOUR::Trigger *trigger = _triggerbox->currently_playing();
|
|
|
|
|
|
|
|
if (trigger) {
|
|
|
|
name_text->set (trigger->region()->name());
|
|
|
|
} else {
|
|
|
|
// name_text->set ("");
|
|
|
|
}
|
|
|
|
|
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
TriggerMaster::set_default_colors ()
|
|
|
|
{
|
|
|
|
set_fill_color (HSV (UIConfiguration::instance().color("theme:bg")).darker(0.25).color ());
|
|
|
|
name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
|
2021-12-12 12:20:11 -05:00
|
|
|
stop_shape->set_fill_color (UIConfiguration::instance().color("neutral:foreground"));
|
2021-12-07 16:47:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TriggerMaster::ui_parameter_changed (std::string const& p)
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
if (p == "color-file") {
|
2021-12-07 16:47:42 -05:00
|
|
|
set_default_colors();
|
2021-12-05 11:56:42 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
|
2021-12-05 11:56:42 -05:00
|
|
|
//====================================
|
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
CueMaster::CueMaster (Item* parent)
|
2021-12-05 11:56:42 -05:00
|
|
|
: ArdourCanvas::Rectangle (parent)
|
|
|
|
{
|
|
|
|
set_layout_sensitive(true); //why???
|
|
|
|
|
|
|
|
name = X_("trigger stopper");
|
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
Event.connect (sigc::mem_fun (*this, &CueMaster::event_handler));
|
2021-12-05 11:56:42 -05:00
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
stop_shape = new ArdourCanvas::Polygon (this);
|
|
|
|
stop_shape->set_outline (false);
|
|
|
|
stop_shape->set_fill (true);
|
|
|
|
stop_shape->name = X_("stopbutton");
|
|
|
|
stop_shape->set_ignore_events (true);
|
|
|
|
stop_shape->show ();
|
2021-12-05 11:56:42 -05:00
|
|
|
|
|
|
|
name_text = new Text (this);
|
2021-12-07 16:47:42 -05:00
|
|
|
name_text->set("");
|
2021-12-05 11:56:42 -05:00
|
|
|
name_text->set_ignore_events (false);
|
|
|
|
|
|
|
|
/* prefs (theme colors) */
|
2021-12-07 16:47:42 -05:00
|
|
|
UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &CueMaster::ui_parameter_changed));
|
|
|
|
set_default_colors();
|
2021-12-05 11:56:42 -05:00
|
|
|
}
|
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
CueMaster::~CueMaster ()
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
CueMaster::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
/* Note that item_to_window() already takes _position into account (as
|
|
|
|
part of item_to_canvas()
|
|
|
|
*/
|
|
|
|
Rect self (item_to_window (_rect));
|
|
|
|
const Rect draw = self.intersection (area);
|
|
|
|
|
|
|
|
if (!draw) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
float width = _rect.width();
|
|
|
|
float height = _rect.height();
|
|
|
|
|
|
|
|
const double scale = UIConfiguration::instance().get_ui_scale();
|
|
|
|
|
|
|
|
if (_fill && !_transparent) {
|
|
|
|
setup_fill_context (context);
|
|
|
|
context->rectangle (draw.x0, draw.y0, draw.width(), draw.height());
|
|
|
|
context->fill ();
|
|
|
|
}
|
|
|
|
|
2021-12-07 16:47:42 -05:00
|
|
|
render_children (area, context);
|
2021-12-12 12:20:11 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
//line at right
|
|
|
|
context->set_identity_matrix();
|
|
|
|
context->translate (self.x0, self.y0-0.5);
|
|
|
|
set_source_rgba (context, rgba_to_color (0,0,0,1));
|
|
|
|
context->rectangle(width-1, 0, width, height);
|
|
|
|
context->fill ();
|
|
|
|
context->set_identity_matrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
//line at top
|
|
|
|
context->set_identity_matrix();
|
|
|
|
context->translate (self.x0, self.y0-0.5);
|
|
|
|
set_source_rgba (context, rgba_to_color (0,0,0,1));
|
|
|
|
context->rectangle(0, 0, width, 1.);
|
|
|
|
context->fill ();
|
|
|
|
context->set_identity_matrix();
|
2021-12-05 11:56:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2021-12-07 16:47:42 -05:00
|
|
|
CueMaster::event_handler (GdkEvent* ev)
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
switch (ev->type) {
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
if (ev->button.button == 1) {
|
2021-12-12 12:32:38 -05:00
|
|
|
_session->stop_all_triggers();
|
2021-12-05 11:56:42 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
|
2021-12-12 12:20:11 -05:00
|
|
|
name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest"));
|
2021-12-07 16:47:42 -05:00
|
|
|
stop_shape->set_fill_color (UIConfiguration::instance().color("neutral:foregroundest"));
|
2021-12-12 12:20:11 -05:00
|
|
|
set_fill_color (HSV (fill_color()).lighter(0.15).color ());
|
2021-12-05 11:56:42 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
|
2021-12-12 12:20:11 -05:00
|
|
|
set_default_colors();
|
2021-12-05 11:56:42 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
CueMaster::maybe_update ()
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
CueMaster::_size_allocate (ArdourCanvas::Rect const & alloc)
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
Rectangle::_size_allocate (alloc);
|
|
|
|
|
|
|
|
const double scale = UIConfiguration::instance().get_ui_scale();
|
|
|
|
poly_margin = 2. * scale;
|
|
|
|
|
|
|
|
const Distance width = _rect.width();
|
|
|
|
const Distance height = _rect.height();
|
|
|
|
|
|
|
|
poly_size = height - (poly_margin*2);
|
|
|
|
|
|
|
|
Points p;
|
|
|
|
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));
|
2021-12-07 16:47:42 -05:00
|
|
|
stop_shape->set (p);
|
2021-12-05 11:56:42 -05:00
|
|
|
|
|
|
|
float tleft = poly_size + (poly_margin*3);
|
|
|
|
float twidth = width-poly_size-(poly_margin*3);
|
|
|
|
|
|
|
|
ArdourCanvas::Rect text_alloc (tleft, 0, twidth, height); //testing
|
|
|
|
name_text->size_allocate (text_alloc);
|
|
|
|
name_text->set_position (Duple (tleft, 1.*scale));
|
|
|
|
name_text->clamp_width (twidth);
|
|
|
|
|
|
|
|
//font scale may have changed. uiconfig 'embeds' the ui-scale in the font
|
|
|
|
name_text->set_font_description (UIConfiguration::instance().get_NormalFont());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
CueMaster::set_default_colors ()
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
2021-12-07 16:47:42 -05:00
|
|
|
set_fill_color (HSV (UIConfiguration::instance().color("theme:bg")).darker(0.25).color ());
|
|
|
|
name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
|
2021-12-12 12:20:11 -05:00
|
|
|
stop_shape->set_fill_color (UIConfiguration::instance().color("neutral:foreground"));
|
2021-12-05 11:56:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-12-07 16:47:42 -05:00
|
|
|
CueMaster::ui_parameter_changed (std::string const& p)
|
2021-12-05 11:56:42 -05:00
|
|
|
{
|
|
|
|
if (p == "color-file") {
|
2021-12-07 16:47:42 -05:00
|
|
|
set_default_colors();
|
2021-12-05 11:56:42 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|