13
0

manually reimplement 3766b22e06 from master (sysex deletion)

Things have changed
This commit is contained in:
Paul Davis 2024-09-16 08:30:36 -06:00
parent 15258b9aa4
commit 739d58840f
3 changed files with 30 additions and 27 deletions

View File

@ -1380,7 +1380,7 @@ MidiView::display_sysexes()
std::shared_ptr<SysEx> sysex = find_canvas_sys_ex (sysex_ptr);
if (!sysex) {
sysex = std::shared_ptr<SysEx>(new SysEx (_note_group, text, height, x, 1.0, sysex_ptr));
sysex = std::shared_ptr<SysEx>(new SysEx (*this, _note_group, text, height, x, 1.0, sysex_ptr));
_sys_exes.insert (make_pair (sysex_ptr, sysex));
} else {
sysex->set_height (height);
@ -4300,16 +4300,13 @@ MidiView::edit_patch_change (PatchChange* pc)
}
void
MidiView::delete_sysex (SysEx* /*sysex*/)
MidiView::delete_sysex (SysEx* sysex)
{
// CAIROCANVAS
// sysyex object doesn't have a pointer to a sysex event
// MidiModel::SysExDiffCommand* c = _model->new_sysex_diff_command (_("delete sysex"));
// c->remove (sysex->sysex());
// _model->apply_command (*trackview.session(), c);
MidiModel::SysExDiffCommand* c = _model->new_sysex_diff_command (_("delete sysex"));
c->remove (sysex->sysex ());
_model->apply_diff_command_as_commit (_editing_context.history(), c);
//_sys_exes.clear ();
// display_sysexes();
display_sysexes();
}
std::string

View File

@ -23,13 +23,14 @@
#include "gtkmm2ext/keyboard.h"
#include "editor.h"
#include "midi_region_view.h"
#include "midi_view.h"
#include "sys_ex.h"
#include "ui_config.h"
using namespace std;
SysEx::SysEx (
MidiView& view,
ArdourCanvas::Container* parent,
string& text,
double height,
@ -37,7 +38,7 @@ SysEx::SysEx (
double y,
ARDOUR::MidiModel::SysExPtr sysex)
: _sysex (sysex)
, _region (region)
, _view (view)
{
_flag = new ArdourCanvas::Flag (
parent,
@ -60,21 +61,24 @@ SysEx::~SysEx()
bool
SysEx::event_handler (GdkEvent* ev)
{
/* XXX: icky dcast */
Editor* e = dynamic_cast<Editor*> (&_region.get_time_axis_view ().editor ());
if (!e->internal_editing ()) {
return false;
}
switch (ev->type) {
case GDK_BUTTON_PRESS:
if (Gtkmm2ext::Keyboard::is_delete_event (&ev->button)) {
_region.delete_sysex (this);
return true;
}
default:
break;
case GDK_BUTTON_PRESS:
if (Gtkmm2ext::Keyboard::is_delete_event (&ev->button)) {
_view.delete_sysex (this);
return true;
}
break;
case GDK_SCROLL:
if (ev->scroll.direction == GDK_SCROLL_UP) {
return true;
} else if (ev->scroll.direction == GDK_SCROLL_DOWN) {
return true;
}
break;
default:
break;
}
return false;

View File

@ -21,12 +21,14 @@
#define __SYSEX_H__
#include "canvas/flag.h"
#include "midi_region_view.h"
class MidiView;
class SysEx
{
public:
SysEx (
MidiView& view,
ArdourCanvas::Container* parent,
std::string& text,
double height,
@ -50,7 +52,7 @@ private:
bool event_handler (GdkEvent* ev);
ArdourCanvas::Flag* _flag;
ARDOUR::MidiModel::SysExPtr _sysex;
MidiRegionView& _region;
MidiView& _view;
};
#endif /* __SYSEX_H__ */