mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 08:36:32 +01:00
steps to an ecology of lollipops
This commit is contained in:
parent
52f10ad2a8
commit
4bafadc419
9 changed files with 248 additions and 7 deletions
|
|
@ -208,10 +208,16 @@ MidiGhostRegion::~MidiGhostRegion()
|
||||||
delete _note_group;
|
delete _note_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MidiGhostRegion::GhostEvent::GhostEvent (NoteBase* e, ArdourCanvas::Container* g, ArdourCanvas::Item* i)
|
||||||
|
: event (e)
|
||||||
|
, item (i)
|
||||||
|
, is_hit (false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
MidiGhostRegion::GhostEvent::GhostEvent (NoteBase* e, ArdourCanvas::Container* g)
|
MidiGhostRegion::GhostEvent::GhostEvent (NoteBase* e, ArdourCanvas::Container* g)
|
||||||
: event (e)
|
: event (e)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (dynamic_cast<Note*>(e)) {
|
if (dynamic_cast<Note*>(e)) {
|
||||||
item = new ArdourCanvas::Rectangle(
|
item = new ArdourCanvas::Rectangle(
|
||||||
g, ArdourCanvas::Rect(e->x0(), e->y0(), e->x1(), e->y1()));
|
g, ArdourCanvas::Rect(e->x0(), e->y0(), e->x1(), e->y1()));
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,8 @@ public:
|
||||||
class GhostEvent : public sigc::trackable
|
class GhostEvent : public sigc::trackable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GhostEvent(::NoteBase *, ArdourCanvas::Container *);
|
GhostEvent (::NoteBase *, ArdourCanvas::Container *);
|
||||||
|
GhostEvent (::NoteBase *, ArdourCanvas::Container *, ArdourCanvas::Item* i);
|
||||||
virtual ~GhostEvent ();
|
virtual ~GhostEvent ();
|
||||||
|
|
||||||
NoteBase* event;
|
NoteBase* event;
|
||||||
|
|
@ -119,7 +120,7 @@ public:
|
||||||
void set_samples_per_pixel (double spu);
|
void set_samples_per_pixel (double spu);
|
||||||
void set_colors();
|
void set_colors();
|
||||||
|
|
||||||
void update_contents_height();
|
virtual void update_contents_height();
|
||||||
|
|
||||||
virtual void add_note(NoteBase*);
|
virtual void add_note(NoteBase*);
|
||||||
virtual void update_note (GhostEvent* note);
|
virtual void update_note (GhostEvent* note);
|
||||||
|
|
@ -130,7 +131,7 @@ public:
|
||||||
void view_changed();
|
void view_changed();
|
||||||
void clear_events();
|
void clear_events();
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
ArdourCanvas::Container* _note_group;
|
ArdourCanvas::Container* _note_group;
|
||||||
Gtkmm2ext::Color _outline;
|
Gtkmm2ext::Color _outline;
|
||||||
ArdourCanvas::Rectangle* _tmp_rect;
|
ArdourCanvas::Rectangle* _tmp_rect;
|
||||||
|
|
|
||||||
109
gtk2_ardour/lollipop.cc
Normal file
109
gtk2_ardour/lollipop.cc
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023 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 "evoral/Note.h"
|
||||||
|
|
||||||
|
#include "canvas/lollipop.h"
|
||||||
|
#include "canvas/debug.h"
|
||||||
|
|
||||||
|
#include "lollipop.h"
|
||||||
|
#include "public_editor.h"
|
||||||
|
|
||||||
|
using namespace ARDOUR;
|
||||||
|
using ArdourCanvas::Coord;
|
||||||
|
using ArdourCanvas::Duple;
|
||||||
|
|
||||||
|
Lollipop::Lollipop (
|
||||||
|
MidiRegionView& region, ArdourCanvas::Item* parent, const boost::shared_ptr<NoteType> note, bool with_events)
|
||||||
|
: NoteBase (region, with_events, note)
|
||||||
|
, _lollipop (new ArdourCanvas::Lollipop (parent))
|
||||||
|
{
|
||||||
|
CANVAS_DEBUG_NAME (_lollipop, "note");
|
||||||
|
set_item (_lollipop);
|
||||||
|
}
|
||||||
|
|
||||||
|
Lollipop::~Lollipop ()
|
||||||
|
{
|
||||||
|
delete _lollipop;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::move_event (double dx, double dy)
|
||||||
|
{
|
||||||
|
_lollipop->set (Duple (_lollipop->x0(), _lollipop->y0()).translate (Duple (dx, dy)), _lollipop->length(), _lollipop->radius());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::set_outline_color (uint32_t color)
|
||||||
|
{
|
||||||
|
_lollipop->set_outline_color (color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::set_fill_color (uint32_t color)
|
||||||
|
{
|
||||||
|
_lollipop->set_fill_color (color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::show ()
|
||||||
|
{
|
||||||
|
_lollipop->show ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::hide ()
|
||||||
|
{
|
||||||
|
_lollipop->hide ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::set (ArdourCanvas::Duple const & d, ArdourCanvas::Coord len, ArdourCanvas::Coord radius)
|
||||||
|
{
|
||||||
|
_lollipop->set (d, len, radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::set_x (Coord x)
|
||||||
|
{
|
||||||
|
_lollipop->set_x (x);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::set_len (Coord l)
|
||||||
|
{
|
||||||
|
_lollipop->set_length (l);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::set_outline_what (ArdourCanvas::Rectangle::What what)
|
||||||
|
{
|
||||||
|
// _lollipop->set_outline_what (what);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::set_outline_all ()
|
||||||
|
{
|
||||||
|
// _lollipop->set_outline_all ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::set_ignore_events (bool ignore)
|
||||||
|
{
|
||||||
|
_lollipop->set_ignore_events (ignore);
|
||||||
|
}
|
||||||
67
gtk2_ardour/lollipop.h
Normal file
67
gtk2_ardour/lollipop.h
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2023 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __gtk_ardour_lollipop_h__
|
||||||
|
#define __gtk_ardour_lollipop_h__
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "canvas/rectangle.h"
|
||||||
|
|
||||||
|
#include "note_base.h"
|
||||||
|
#include "midi_util.h"
|
||||||
|
|
||||||
|
namespace ArdourCanvas {
|
||||||
|
class Container;
|
||||||
|
class Lollipop;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Lollipop : public NoteBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef Evoral::Note<Temporal::Beats> NoteType;
|
||||||
|
|
||||||
|
Lollipop (MidiRegionView& region,
|
||||||
|
ArdourCanvas::Item* parent,
|
||||||
|
const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>(),
|
||||||
|
bool with_events = true);
|
||||||
|
|
||||||
|
~Lollipop ();
|
||||||
|
|
||||||
|
void set (ArdourCanvas::Duple const &, ArdourCanvas::Coord, ArdourCanvas::Coord);
|
||||||
|
void set_x (ArdourCanvas::Coord);
|
||||||
|
void set_len (ArdourCanvas::Coord);
|
||||||
|
|
||||||
|
void set_outline_what (ArdourCanvas::Rectangle::What);
|
||||||
|
void set_outline_all ();
|
||||||
|
|
||||||
|
void set_outline_color (uint32_t);
|
||||||
|
void set_fill_color (uint32_t);
|
||||||
|
|
||||||
|
void show ();
|
||||||
|
void hide ();
|
||||||
|
|
||||||
|
void set_ignore_events (bool);
|
||||||
|
|
||||||
|
void move_event (double dx, double dy);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ArdourCanvas::Lollipop* _lollipop;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __gtk_ardour_lollipop_h__ */
|
||||||
|
|
@ -29,12 +29,15 @@
|
||||||
|
|
||||||
#include "gtkmm2ext/keyboard.h"
|
#include "gtkmm2ext/keyboard.h"
|
||||||
|
|
||||||
|
#include "canvas/lollipop.h"
|
||||||
|
|
||||||
#include "velocity_ghost_region.h"
|
#include "velocity_ghost_region.h"
|
||||||
#include "editing.h"
|
#include "editing.h"
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
#include "editor_drag.h"
|
#include "editor_drag.h"
|
||||||
#include "gui_thread.h"
|
#include "gui_thread.h"
|
||||||
#include "midi_automation_line.h"
|
#include "midi_automation_line.h"
|
||||||
|
#include "note_base.h"
|
||||||
#include "public_editor.h"
|
#include "public_editor.h"
|
||||||
#include "ui_config.h"
|
#include "ui_config.h"
|
||||||
|
|
||||||
|
|
@ -52,8 +55,34 @@ VelocityGhostRegion::~VelocityGhostRegion ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VelocityGhostRegion::add_note(NoteBase*)
|
VelocityGhostRegion::update_contents_height ()
|
||||||
{
|
{
|
||||||
|
for (auto const & ev : events) {
|
||||||
|
ArdourCanvas::Lollipop* l = dynamic_cast<ArdourCanvas::Lollipop*> (ev.second->item);
|
||||||
|
l->set_length (ev.second->event->note()->velocity() / 127.0 * base_rect->y1 ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
VelocityGhostRegion::add_note (NoteBase* n)
|
||||||
|
{
|
||||||
|
ArdourCanvas::Lollipop* l = new ArdourCanvas::Lollipop (_note_group);
|
||||||
|
GhostEvent* event = new GhostEvent (n, _note_group, l);
|
||||||
|
events.insert (std::make_pair (n->note(), event));
|
||||||
|
|
||||||
|
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()) {
|
||||||
|
event->item->hide();
|
||||||
|
} else {
|
||||||
|
l->set (ArdourCanvas::Duple (n->x0(), n->y0()), n->note()->velocity() / 127.0 * base_rect->y1(), 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ public:
|
||||||
VelocityGhostRegion (MidiRegionView&, TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos);
|
VelocityGhostRegion (MidiRegionView&, TimeAxisView& tv, TimeAxisView& source_tv, double initial_unit_pos);
|
||||||
~VelocityGhostRegion ();
|
~VelocityGhostRegion ();
|
||||||
|
|
||||||
|
void update_contents_height();
|
||||||
void add_note(NoteBase*);
|
void add_note(NoteBase*);
|
||||||
void update_note (GhostEvent* note);
|
void update_note (GhostEvent* note);
|
||||||
void update_hit (GhostEvent* hit);
|
void update_hit (GhostEvent* hit);
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,7 @@ gtk2_ardour_sources = [
|
||||||
'level_meter.cc',
|
'level_meter.cc',
|
||||||
'library_download_dialog.cc',
|
'library_download_dialog.cc',
|
||||||
'location_ui.cc',
|
'location_ui.cc',
|
||||||
|
'lollipop.cc',
|
||||||
'loudness_dialog.cc',
|
'loudness_dialog.cc',
|
||||||
'loudness_settings.cc',
|
'loudness_settings.cc',
|
||||||
'lua_script_manager.cc',
|
'lua_script_manager.cc',
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,11 @@ public:
|
||||||
Coord radius() const { return _radius; }
|
Coord radius() const { return _radius; }
|
||||||
|
|
||||||
void set_length (Coord);
|
void set_length (Coord);
|
||||||
void set_x (Coord);
|
Coord length() const { return _points[1].y - _points[0].y; }
|
||||||
|
|
||||||
/* Set origin, length, radius in one pass */
|
/* Set origin, length, radius in one pass */
|
||||||
void set (Duple, Coord, Coord);
|
void set (Duple const &, Coord, Coord);
|
||||||
|
void set_x (Coord);
|
||||||
|
|
||||||
Coord x0 () const {
|
Coord x0 () const {
|
||||||
return _points[0].x;
|
return _points[0].x;
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,32 @@ Lollipop::set_x (Coord x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::set_length (Coord len)
|
||||||
|
{
|
||||||
|
if (_points[1].y != _points[0].y - len) {
|
||||||
|
begin_change ();
|
||||||
|
_points[1].y = _points[0].y - len;
|
||||||
|
end_change ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Lollipop::set (Duple const & d, Coord l, Coord r)
|
||||||
|
{
|
||||||
|
begin_change ();
|
||||||
|
|
||||||
|
_points[0].x = d.x;
|
||||||
|
_points[1].x = d.x;
|
||||||
|
|
||||||
|
_points[0].y = d.y;
|
||||||
|
_points[1].y = _points[0].y - l;
|
||||||
|
|
||||||
|
_radius = r;
|
||||||
|
|
||||||
|
end_change ();
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Lollipop::covers (Duple const & point) const
|
Lollipop::covers (Duple const & point) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue