2016-07-10 12:38:55 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2016 Paul Davis
|
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <pangomm/layout.h>
|
|
|
|
|
|
|
|
#include "pbd/compose.h"
|
|
|
|
#include "pbd/convert.h"
|
|
|
|
#include "pbd/debug.h"
|
|
|
|
#include "pbd/failed_constructor.h"
|
|
|
|
#include "pbd/file_utils.h"
|
|
|
|
#include "pbd/search_path.h"
|
|
|
|
#include "pbd/enumwriter.h"
|
|
|
|
|
|
|
|
#include "midi++/parser.h"
|
|
|
|
#include "timecode/time.h"
|
|
|
|
#include "timecode/bbt_time.h"
|
|
|
|
|
|
|
|
#include "ardour/async_midi_port.h"
|
|
|
|
#include "ardour/audioengine.h"
|
|
|
|
#include "ardour/debug.h"
|
|
|
|
#include "ardour/filesystem_paths.h"
|
|
|
|
#include "ardour/midiport_manager.h"
|
|
|
|
#include "ardour/midi_track.h"
|
|
|
|
#include "ardour/midi_port.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/tempo.h"
|
|
|
|
|
2016-07-12 07:46:30 -04:00
|
|
|
#include "gtkmm2ext/gui_thread.h"
|
2016-07-11 09:07:52 -04:00
|
|
|
#include "gtkmm2ext/rgb_macros.h"
|
|
|
|
|
|
|
|
#include "knob.h"
|
2016-07-10 12:38:55 -04:00
|
|
|
#include "menu.h"
|
|
|
|
#include "push2.h"
|
|
|
|
#include "track_mix.h"
|
2016-07-11 09:07:52 -04:00
|
|
|
#include "utils.h"
|
2016-07-10 12:38:55 -04:00
|
|
|
|
2016-07-15 00:06:10 -04:00
|
|
|
#include "pbd/i18n.h"
|
2016-07-10 12:38:55 -04:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace std;
|
|
|
|
using namespace PBD;
|
|
|
|
using namespace Glib;
|
|
|
|
using namespace ArdourSurface;
|
|
|
|
|
|
|
|
TrackMixLayout::TrackMixLayout (Push2& p, Session& s, Cairo::RefPtr<Cairo::Context> context)
|
|
|
|
: Push2Layout (p, s)
|
2016-07-11 18:17:04 -04:00
|
|
|
, _dirty (true)
|
2016-07-10 12:38:55 -04:00
|
|
|
{
|
2016-07-10 15:22:16 -04:00
|
|
|
Pango::FontDescription fd2 ("Sans 10");
|
2016-07-11 18:17:04 -04:00
|
|
|
|
2016-07-10 15:22:16 -04:00
|
|
|
for (int n = 0; n < 8; ++n) {
|
|
|
|
upper_layout[n] = Pango::Layout::create (context);
|
|
|
|
upper_layout[n]->set_font_description (fd2);
|
2016-07-11 18:17:04 -04:00
|
|
|
|
2016-07-12 07:46:30 -04:00
|
|
|
lower_layout[n] = Pango::Layout::create (context);
|
|
|
|
lower_layout[n]->set_font_description (fd2);
|
|
|
|
|
2016-07-11 18:17:04 -04:00
|
|
|
switch (n) {
|
|
|
|
case 0:
|
|
|
|
upper_layout[n]->set_text (_("TRACK VOLUME"));
|
2016-07-12 07:46:30 -04:00
|
|
|
lower_layout[n]->set_text (_("MUTE"));
|
2016-07-11 18:17:04 -04:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
upper_layout[n]->set_text (_("TRACK PAN"));
|
2016-07-12 07:46:30 -04:00
|
|
|
lower_layout[n]->set_text (_("SOLO"));
|
2016-07-11 18:17:04 -04:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
upper_layout[n]->set_text (_("TRACK WIDTH"));
|
2016-07-12 07:46:30 -04:00
|
|
|
lower_layout[n]->set_text (_("REC-ENABLE"));
|
2016-07-11 18:17:04 -04:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
upper_layout[n]->set_text (_("TRACK TRIM"));
|
2016-07-12 07:46:30 -04:00
|
|
|
lower_layout[n]->set_text (_("IN"));
|
2016-07-11 18:17:04 -04:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
upper_layout[n]->set_text (_(""));
|
2016-07-12 07:46:30 -04:00
|
|
|
lower_layout[n]->set_text (_("DISK"));
|
2016-07-11 18:17:04 -04:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
upper_layout[n]->set_text (_(""));
|
2016-07-12 07:46:30 -04:00
|
|
|
lower_layout[n]->set_text (_("SOLO ISO"));
|
2016-07-11 18:17:04 -04:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
upper_layout[n]->set_text (_(""));
|
2016-07-12 07:46:30 -04:00
|
|
|
lower_layout[n]->set_text (_("SOLO LOCK"));
|
2016-07-11 18:17:04 -04:00
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
upper_layout[n]->set_text (_(""));
|
2016-07-12 07:46:30 -04:00
|
|
|
lower_layout[n]->set_text (_(""));
|
2016-07-11 18:17:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
knobs[n] = new Push2Knob (p2, context);
|
|
|
|
knobs[n]->set_position (60 + (120*n), 95);
|
|
|
|
knobs[n]->set_radius (25);
|
|
|
|
}
|
2016-07-11 09:07:52 -04:00
|
|
|
|
2016-07-12 07:46:30 -04:00
|
|
|
ControlProtocol::StripableSelectionChanged.connect (selection_connection, invalidator (*this), boost::bind (&TrackMixLayout::selection_changed, this), &p2);
|
2016-07-10 12:38:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
TrackMixLayout::~TrackMixLayout ()
|
|
|
|
{
|
2016-07-11 18:17:04 -04:00
|
|
|
for (int n = 0; n < 8; ++n) {
|
|
|
|
delete knobs[n];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TrackMixLayout::selection_changed ()
|
|
|
|
{
|
|
|
|
boost::shared_ptr<Stripable> s = ControlProtocol::first_selected_stripable();
|
|
|
|
if (s) {
|
|
|
|
set_stripable (s);
|
2016-07-11 09:07:52 -04:00
|
|
|
}
|
2016-07-10 12:38:55 -04:00
|
|
|
}
|
2016-07-11 18:17:04 -04:00
|
|
|
void
|
|
|
|
TrackMixLayout::on_show ()
|
|
|
|
{
|
|
|
|
selection_changed ();
|
|
|
|
}
|
2016-07-10 12:38:55 -04:00
|
|
|
|
|
|
|
bool
|
2016-07-11 18:17:04 -04:00
|
|
|
TrackMixLayout::redraw (Cairo::RefPtr<Cairo::Context> context, bool force) const
|
2016-07-10 12:38:55 -04:00
|
|
|
{
|
2016-07-11 09:07:52 -04:00
|
|
|
bool children_dirty = false;
|
|
|
|
|
2016-07-11 18:17:04 -04:00
|
|
|
for (int n = 0; n < 8; ++n) {
|
|
|
|
if (knobs[n]->dirty()) {
|
2016-07-11 09:07:52 -04:00
|
|
|
children_dirty = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-11 18:17:04 -04:00
|
|
|
if (!children_dirty) {
|
2016-07-10 13:02:42 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-07-11 09:07:52 -04:00
|
|
|
set_source_rgb (context, p2.get_color (Push2::DarkBackground));
|
|
|
|
context->rectangle (0, 0, p2.cols, p2.rows);
|
2016-07-10 12:38:55 -04:00
|
|
|
context->fill ();
|
|
|
|
|
2016-07-11 18:17:04 -04:00
|
|
|
for (int n = 0; n < 8; ++n) {
|
|
|
|
|
2016-07-12 07:46:30 -04:00
|
|
|
if (!upper_layout[n]->get_text().empty()) {
|
|
|
|
|
|
|
|
/* Draw highlight box */
|
2016-07-11 18:17:04 -04:00
|
|
|
|
2016-07-12 07:46:30 -04:00
|
|
|
uint32_t color = p2.get_color (Push2::ParameterName);
|
|
|
|
set_source_rgb (context, color);
|
2016-07-11 18:17:04 -04:00
|
|
|
|
2016-07-12 07:46:30 -04:00
|
|
|
context->move_to (10 + (n*120), 2);
|
|
|
|
upper_layout[n]->update_from_cairo_context (context);
|
|
|
|
upper_layout[n]->show_in_cairo_context (context);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lower_layout[n]->get_text().empty()) {
|
|
|
|
context->move_to (10 + (n*120), 140);
|
|
|
|
lower_layout[n]->update_from_cairo_context (context);
|
|
|
|
lower_layout[n]->show_in_cairo_context (context);
|
|
|
|
}
|
2016-07-11 09:07:52 -04:00
|
|
|
}
|
2016-07-10 13:02:42 -04:00
|
|
|
|
2016-07-11 18:17:04 -04:00
|
|
|
context->move_to (0, 22.5);
|
|
|
|
context->line_to (p2.cols, 22.5);
|
|
|
|
context->set_line_width (1.0);
|
|
|
|
context->stroke ();
|
|
|
|
|
|
|
|
for (int n = 0; n < 8; ++n) {
|
|
|
|
knobs[n]->redraw (context, force);
|
2016-07-11 09:07:52 -04:00
|
|
|
}
|
|
|
|
|
2016-07-10 13:02:42 -04:00
|
|
|
return true;
|
2016-07-10 12:38:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TrackMixLayout::button_upper (uint32_t n)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TrackMixLayout::button_lower (uint32_t n)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TrackMixLayout::set_stripable (boost::shared_ptr<Stripable> s)
|
|
|
|
{
|
2016-07-11 18:17:04 -04:00
|
|
|
stripable_connections.drop_connections ();
|
|
|
|
|
2016-07-10 12:38:55 -04:00
|
|
|
stripable = s;
|
2016-07-10 13:02:42 -04:00
|
|
|
|
|
|
|
if (stripable) {
|
2016-07-11 18:17:04 -04:00
|
|
|
|
2016-07-12 07:46:30 -04:00
|
|
|
stripable->DropReferences.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::drop_stripable, this), &p2);
|
2016-07-10 15:22:16 -04:00
|
|
|
|
2016-07-12 07:46:30 -04:00
|
|
|
stripable->PropertyChanged.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
|
|
|
|
stripable->presentation_info().PropertyChanged.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
|
2016-07-10 15:22:16 -04:00
|
|
|
|
2016-07-11 09:07:52 -04:00
|
|
|
knobs[0]->set_controllable (stripable->gain_control());
|
|
|
|
knobs[1]->set_controllable (stripable->pan_azimuth_control());
|
2016-07-11 18:17:04 -04:00
|
|
|
knobs[1]->add_flag (Push2Knob::ArcToZero);
|
|
|
|
knobs[2]->set_controllable (stripable->pan_width_control());
|
|
|
|
knobs[3]->set_controllable (stripable->trim_control());
|
|
|
|
knobs[3]->add_flag (Push2Knob::ArcToZero);
|
|
|
|
knobs[4]->set_controllable (boost::shared_ptr<AutomationControl>());
|
|
|
|
knobs[5]->set_controllable (boost::shared_ptr<AutomationControl>());
|
|
|
|
knobs[6]->set_controllable (boost::shared_ptr<AutomationControl>());
|
|
|
|
knobs[7]->set_controllable (boost::shared_ptr<AutomationControl>());
|
2016-07-11 09:07:52 -04:00
|
|
|
|
2016-07-10 13:02:42 -04:00
|
|
|
name_changed ();
|
2016-07-10 15:22:16 -04:00
|
|
|
color_changed ();
|
2016-07-10 13:02:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_dirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TrackMixLayout::drop_stripable ()
|
|
|
|
{
|
|
|
|
stripable_connections.drop_connections ();
|
|
|
|
stripable.reset ();
|
|
|
|
_dirty = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TrackMixLayout::name_changed ()
|
|
|
|
{
|
2016-07-10 12:38:55 -04:00
|
|
|
_dirty = true;
|
|
|
|
}
|
2016-07-10 15:22:16 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
TrackMixLayout::color_changed ()
|
|
|
|
{
|
|
|
|
uint32_t rgb = stripable->presentation_info().color();
|
|
|
|
|
2016-07-11 18:17:04 -04:00
|
|
|
for (int n = 0; n < 8; ++n) {
|
|
|
|
knobs[n]->set_text_color (rgb);
|
|
|
|
knobs[n]->set_arc_start_color (rgb);
|
|
|
|
knobs[n]->set_arc_end_color (rgb);
|
|
|
|
}
|
2016-07-10 15:22:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TrackMixLayout::stripable_property_change (PropertyChange const& what_changed)
|
|
|
|
{
|
|
|
|
if (what_changed.contains (Properties::color)) {
|
|
|
|
color_changed ();
|
|
|
|
}
|
|
|
|
if (what_changed.contains (Properties::name)) {
|
|
|
|
name_changed ();
|
|
|
|
}
|
|
|
|
}
|
2016-07-11 18:17:04 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
TrackMixLayout::strip_vpot (int n, int delta)
|
|
|
|
{
|
|
|
|
boost::shared_ptr<Controllable> ac = knobs[n]->controllable();
|
|
|
|
|
|
|
|
if (ac) {
|
|
|
|
ac->set_value (ac->get_value() + ((2.0/64.0) * delta), PBD::Controllable::UseGroup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TrackMixLayout::strip_vpot_touch (int n, bool touching)
|
|
|
|
{
|
|
|
|
boost::shared_ptr<AutomationControl> ac = knobs[n]->controllable();
|
|
|
|
if (ac) {
|
|
|
|
if (touching) {
|
|
|
|
ac->start_touch (session.audible_frame());
|
|
|
|
} else {
|
|
|
|
ac->stop_touch (true, session.audible_frame());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|