2023-01-08 11:52:20 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2022 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 <utility>
|
|
|
|
|
|
|
|
#include "pbd/memento_command.h"
|
|
|
|
|
|
|
|
#include "ardour/automation_control.h"
|
|
|
|
#include "ardour/event_type_map.h"
|
|
|
|
#include "ardour/midi_automation_list_binder.h"
|
|
|
|
#include "ardour/midi_region.h"
|
|
|
|
#include "ardour/midi_track.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
|
|
|
|
#include "gtkmm2ext/keyboard.h"
|
|
|
|
|
2023-01-10 23:41:47 -05:00
|
|
|
#include "canvas/lollipop.h"
|
|
|
|
|
2023-01-08 11:52:20 -05:00
|
|
|
#include "velocity_ghost_region.h"
|
|
|
|
#include "editing.h"
|
|
|
|
#include "editor.h"
|
|
|
|
#include "editor_drag.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "midi_automation_line.h"
|
2023-01-10 23:41:47 -05:00
|
|
|
#include "note_base.h"
|
2023-01-08 11:52:20 -05:00
|
|
|
#include "public_editor.h"
|
|
|
|
#include "ui_config.h"
|
|
|
|
|
|
|
|
#include "pbd/i18n.h"
|
|
|
|
|
|
|
|
using namespace Temporal;
|
|
|
|
|
2023-01-11 13:51:03 -05:00
|
|
|
static double const lollipop_radius = 8.0;
|
|
|
|
|
2023-01-08 11:52:20 -05:00
|
|
|
VelocityGhostRegion::VelocityGhostRegion (MidiRegionView& mrv, TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos)
|
|
|
|
: MidiGhostRegion (mrv, tv, source_tv, initial_unit_pos)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VelocityGhostRegion::~VelocityGhostRegion ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-01-10 23:41:47 -05:00
|
|
|
VelocityGhostRegion::update_contents_height ()
|
|
|
|
{
|
2023-01-12 19:06:43 -05:00
|
|
|
for (auto const & i : events) {
|
|
|
|
set_size_and_position (*i.second);
|
2023-01-10 23:41:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-12 19:06:43 -05:00
|
|
|
bool
|
|
|
|
VelocityGhostRegion::lollevent (GdkEvent* ev, MidiGhostRegion::GhostEvent* gev)
|
|
|
|
{
|
|
|
|
return trackview.editor().canvas_velocity_event (ev, gev->item);
|
|
|
|
}
|
|
|
|
|
2023-01-10 23:41:47 -05:00
|
|
|
void
|
|
|
|
VelocityGhostRegion::add_note (NoteBase* n)
|
2023-01-08 11:52:20 -05:00
|
|
|
{
|
2023-01-10 23:41:47 -05:00
|
|
|
ArdourCanvas::Lollipop* l = new ArdourCanvas::Lollipop (_note_group);
|
2023-01-12 19:06:43 -05:00
|
|
|
|
2023-01-10 23:41:47 -05:00
|
|
|
GhostEvent* event = new GhostEvent (n, _note_group, l);
|
|
|
|
events.insert (std::make_pair (n->note(), event));
|
2023-01-12 19:06:43 -05:00
|
|
|
l->Event.connect (sigc::bind (sigc::mem_fun (*this, &VelocityGhostRegion::lollevent), event));
|
|
|
|
l->raise_to_top ();
|
2023-01-10 23:41:47 -05:00
|
|
|
|
|
|
|
event->item->set_fill_color (UIConfiguration::instance().color_mod(n->base_color(), "ghost track midi fill"));
|
|
|
|
event->item->set_outline_color (_outline);
|
|
|
|
|
|
|
|
MidiStreamView* mv = midi_view();
|
|
|
|
|
|
|
|
if (mv) {
|
|
|
|
if (!n->item()->visible()) {
|
2023-01-11 13:51:03 -05:00
|
|
|
l->hide();
|
2023-01-10 23:41:47 -05:00
|
|
|
} else {
|
2023-01-12 19:06:43 -05:00
|
|
|
set_size_and_position (*event);
|
2023-01-10 23:41:47 -05:00
|
|
|
}
|
|
|
|
}
|
2023-01-08 11:52:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-01-12 19:06:43 -05:00
|
|
|
VelocityGhostRegion::set_size_and_position (GhostEvent& ev)
|
|
|
|
{
|
|
|
|
ArdourCanvas::Lollipop* l = dynamic_cast<ArdourCanvas::Lollipop*> (ev.item);
|
|
|
|
const double available_height = base_rect->y1() - (2.0 * lollipop_radius);
|
|
|
|
const double actual_height = (ev.event->note()->velocity() / 127.0) * available_height;
|
|
|
|
l->set (ArdourCanvas::Duple (ev.event->x0() - 1.0, base_rect->y1() - actual_height), actual_height, lollipop_radius);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VelocityGhostRegion::update_note (GhostEvent* ev)
|
2023-01-08 11:52:20 -05:00
|
|
|
{
|
2023-01-12 19:06:43 -05:00
|
|
|
set_size_and_position (*ev);
|
2023-01-08 11:52:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-01-12 19:06:43 -05:00
|
|
|
VelocityGhostRegion::update_hit (GhostEvent* ev)
|
2023-01-08 11:52:20 -05:00
|
|
|
{
|
2023-01-12 19:06:43 -05:00
|
|
|
set_size_and_position (*ev);
|
2023-01-08 11:52:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VelocityGhostRegion::remove_note (NoteBase*)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-01-11 13:51:03 -05:00
|
|
|
void
|
|
|
|
VelocityGhostRegion::set_colors ()
|
|
|
|
{
|
2023-01-12 19:06:43 -05:00
|
|
|
base_rect->set_fill_color (Gtkmm2ext::Color (0xff000085));
|
2023-01-11 13:51:03 -05:00
|
|
|
}
|