mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 07:45:00 +01:00
clean up item event handling in MidiRegionViews by removing unnecessary InteractiveItem inheritance, and keep child->parent event handling order consistent as much as possible
git-svn-id: svn://localhost/ardour2/branches/3.0@7186 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
3d6493abc9
commit
3e966771d0
11 changed files with 130 additions and 187 deletions
|
|
@ -5,6 +5,26 @@
|
||||||
using namespace Gnome::Canvas;
|
using namespace Gnome::Canvas;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
CanvasFlag::CanvasFlag (MidiRegionView& region,
|
||||||
|
Group& parent,
|
||||||
|
double height,
|
||||||
|
guint outline_color_rgba,
|
||||||
|
guint fill_color_rgba,
|
||||||
|
double x,
|
||||||
|
double y)
|
||||||
|
: Group(parent, x, y)
|
||||||
|
, _text(0)
|
||||||
|
, _height(height)
|
||||||
|
, _outline_color_rgba(outline_color_rgba)
|
||||||
|
, _fill_color_rgba(fill_color_rgba)
|
||||||
|
, _region(region)
|
||||||
|
, _line(0)
|
||||||
|
, _rect(0)
|
||||||
|
{
|
||||||
|
/* XXX this connection is needed if ::on_event() is changed to actually do anything */
|
||||||
|
signal_event().connect (sigc::mem_fun (*this, &CanvasFlag::on_event));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CanvasFlag::delete_allocated_objects()
|
CanvasFlag::delete_allocated_objects()
|
||||||
{
|
{
|
||||||
|
|
@ -23,7 +43,7 @@ CanvasFlag::set_text(const string& a_text)
|
||||||
{
|
{
|
||||||
delete_allocated_objects();
|
delete_allocated_objects();
|
||||||
|
|
||||||
_text = new InteractiveText(*this, this, 0.0, 0.0, Glib::ustring(a_text));
|
_text = new Text (*this, 0.0, 0.0, Glib::ustring(a_text));
|
||||||
_text->property_justification() = Gtk::JUSTIFY_CENTER;
|
_text->property_justification() = Gtk::JUSTIFY_CENTER;
|
||||||
_text->property_fill_color_rgba() = _outline_color_rgba;
|
_text->property_fill_color_rgba() = _outline_color_rgba;
|
||||||
double flagwidth = _text->property_text_width() + 10.0;
|
double flagwidth = _text->property_text_width() + 10.0;
|
||||||
|
|
@ -33,10 +53,14 @@ CanvasFlag::set_text(const string& a_text)
|
||||||
_text->show();
|
_text->show();
|
||||||
_line = new SimpleLine(*this, 0.0, 0.0, 0.0, _height);
|
_line = new SimpleLine(*this, 0.0, 0.0, 0.0, _height);
|
||||||
_line->property_color_rgba() = _outline_color_rgba;
|
_line->property_color_rgba() = _outline_color_rgba;
|
||||||
_rect = new InteractiveRect(*this, this, 0.0, 0.0, flagwidth, flagheight);
|
_rect = new SimpleRect(*this, 0.0, 0.0, flagwidth, flagheight);
|
||||||
_rect->property_outline_color_rgba() = _outline_color_rgba;
|
_rect->property_outline_color_rgba() = _outline_color_rgba;
|
||||||
_rect->property_fill_color_rgba() = _fill_color_rgba;
|
_rect->property_fill_color_rgba() = _fill_color_rgba;
|
||||||
_text->raise_to_top();
|
_text->raise_to_top();
|
||||||
|
|
||||||
|
/* XXX these two connections are needed if ::on_event() is changed to actually do anything */
|
||||||
|
//_rect->signal_event().connect (sigc::mem_fun (*this, &CanvasFlag::on_event));
|
||||||
|
//_text->signal_event().connect (sigc::mem_fun (*this, &CanvasFlag::on_event));
|
||||||
}
|
}
|
||||||
|
|
||||||
CanvasFlag::~CanvasFlag()
|
CanvasFlag::~CanvasFlag()
|
||||||
|
|
@ -47,5 +71,8 @@ CanvasFlag::~CanvasFlag()
|
||||||
bool
|
bool
|
||||||
CanvasFlag::on_event(GdkEvent* /*ev*/)
|
CanvasFlag::on_event(GdkEvent* /*ev*/)
|
||||||
{
|
{
|
||||||
|
/* XXX if you change this function to actually do anything, be sure
|
||||||
|
to fix the connections commented out elsewhere in this file.
|
||||||
|
*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,38 +4,28 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <libgnomecanvasmm/group.h>
|
#include <libgnomecanvasmm/group.h>
|
||||||
#include <libgnomecanvasmm/widget.h>
|
#include <libgnomecanvasmm/widget.h>
|
||||||
|
#include <libgnomecanvasmm/text.h>
|
||||||
|
|
||||||
#include "ardour/midi_model.h"
|
#include "ardour/midi_model.h"
|
||||||
|
|
||||||
#include "simplerect.h"
|
#include "simplerect.h"
|
||||||
#include "simpleline.h"
|
#include "simpleline.h"
|
||||||
#include "interactive-item.h"
|
|
||||||
|
|
||||||
class MidiRegionView;
|
class MidiRegionView;
|
||||||
|
|
||||||
namespace Gnome {
|
namespace Gnome {
|
||||||
namespace Canvas {
|
namespace Canvas {
|
||||||
|
|
||||||
class CanvasFlag : public Group, public InteractiveItem
|
class CanvasFlag : public Group
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CanvasFlag(
|
CanvasFlag(MidiRegionView& region,
|
||||||
MidiRegionView& region,
|
Group& parent,
|
||||||
Group& parent,
|
double height,
|
||||||
double height,
|
guint outline_color_rgba = 0xc0c0c0ff,
|
||||||
guint outline_color_rgba = 0xc0c0c0ff,
|
guint fill_color_rgba = 0x07070707,
|
||||||
guint fill_color_rgba = 0x07070707,
|
double x = 0.0,
|
||||||
double x = 0.0,
|
double y = 0.0);
|
||||||
double y = 0.0)
|
|
||||||
: Group(parent, x, y)
|
|
||||||
, _text(0)
|
|
||||||
, _height(height)
|
|
||||||
, _outline_color_rgba(outline_color_rgba)
|
|
||||||
, _fill_color_rgba(fill_color_rgba)
|
|
||||||
, _region(region)
|
|
||||||
, _line(0)
|
|
||||||
, _rect(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual ~CanvasFlag();
|
virtual ~CanvasFlag();
|
||||||
|
|
||||||
|
|
@ -44,7 +34,7 @@ public:
|
||||||
void set_text(const std::string& a_text);
|
void set_text(const std::string& a_text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
InteractiveText* _text;
|
Text* _text;
|
||||||
double _height;
|
double _height;
|
||||||
guint _outline_color_rgba;
|
guint _outline_color_rgba;
|
||||||
guint _fill_color_rgba;
|
guint _fill_color_rgba;
|
||||||
|
|
@ -54,7 +44,7 @@ private:
|
||||||
void delete_allocated_objects();
|
void delete_allocated_objects();
|
||||||
|
|
||||||
SimpleLine* _line;
|
SimpleLine* _line;
|
||||||
InteractiveRect* _rect;
|
SimpleRect* _rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,26 @@ using namespace ARDOUR;
|
||||||
namespace Gnome {
|
namespace Gnome {
|
||||||
namespace Canvas {
|
namespace Canvas {
|
||||||
|
|
||||||
|
CanvasHit::CanvasHit (MidiRegionView& region,
|
||||||
|
Group& group,
|
||||||
|
double size,
|
||||||
|
const boost::shared_ptr<NoteType> note,
|
||||||
|
bool with_events)
|
||||||
|
: Diamond(group, size)
|
||||||
|
, CanvasNoteEvent(region, this, note)
|
||||||
|
{
|
||||||
|
if (with_events) {
|
||||||
|
signal_event().connect (sigc::mem_fun (*this, &CanvasHit::on_event));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CanvasHit::on_event(GdkEvent* ev)
|
CanvasHit::on_event(GdkEvent* ev)
|
||||||
{
|
{
|
||||||
if (!_region.get_trackview().editor().canvas_note_event (ev, this)) {
|
if (!CanvasNoteEvent::on_event (ev)) {
|
||||||
return CanvasNoteEvent::on_event (ev);
|
return _region.get_trackview().editor().canvas_note_event (ev, this);
|
||||||
} else {
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,8 @@ public:
|
||||||
MidiRegionView& region,
|
MidiRegionView& region,
|
||||||
Group& group,
|
Group& group,
|
||||||
double size,
|
double size,
|
||||||
const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>())
|
const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>(),
|
||||||
|
bool with_events = true);
|
||||||
: Diamond(group, size), CanvasNoteEvent(region, this, note)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void show() { Diamond::show(); }
|
void show() { Diamond::show(); }
|
||||||
void hide() { Diamond::hide(); }
|
void hide() { Diamond::hide(); }
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "gtkmm2ext/keyboard.h"
|
||||||
|
|
||||||
#include "canvas-note-event.h"
|
#include "canvas-note-event.h"
|
||||||
#include "midi_region_view.h"
|
#include "midi_region_view.h"
|
||||||
#include "public_editor.h"
|
#include "public_editor.h"
|
||||||
|
|
@ -25,6 +28,7 @@
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace Gtkmm2ext;
|
||||||
using ARDOUR::MidiModel;
|
using ARDOUR::MidiModel;
|
||||||
|
|
||||||
namespace Gnome {
|
namespace Gnome {
|
||||||
|
|
@ -40,8 +44,7 @@ const uint32_t CanvasNoteEvent::midi_channel_colors[16] = {
|
||||||
0x832dd3ff, 0xa92dd3ff, 0xd32dbfff, 0xd32d67ff
|
0x832dd3ff, 0xa92dd3ff, 0xd32dbfff, 0xd32d67ff
|
||||||
};
|
};
|
||||||
|
|
||||||
CanvasNoteEvent::CanvasNoteEvent(MidiRegionView& region, Item* item,
|
CanvasNoteEvent::CanvasNoteEvent(MidiRegionView& region, Item* item, const boost::shared_ptr<NoteType> note)
|
||||||
const boost::shared_ptr<NoteType> note)
|
|
||||||
: _region(region)
|
: _region(region)
|
||||||
, _item(item)
|
, _item(item)
|
||||||
, _text(0)
|
, _text(0)
|
||||||
|
|
@ -81,7 +84,7 @@ void
|
||||||
CanvasNoteEvent::show_velocity()
|
CanvasNoteEvent::show_velocity()
|
||||||
{
|
{
|
||||||
if (!_text) {
|
if (!_text) {
|
||||||
_text = new InteractiveText(*(_item->property_parent()), this);
|
_text = new NoEventText (*(_item->property_parent()));
|
||||||
}
|
}
|
||||||
_text->property_x() = (x1() + x2()) /2;
|
_text->property_x() = (x1() + x2()) /2;
|
||||||
_text->property_y() = (y1() + y2()) /2;
|
_text->property_y() = (y1() + y2()) /2;
|
||||||
|
|
@ -218,35 +221,31 @@ CanvasNoteEvent::base_color()
|
||||||
bool
|
bool
|
||||||
CanvasNoteEvent::on_event(GdkEvent* ev)
|
CanvasNoteEvent::on_event(GdkEvent* ev)
|
||||||
{
|
{
|
||||||
PublicEditor& editor (_region.get_time_axis_view().editor());
|
cerr << "CNE: on_event type " << ev->type << endl;
|
||||||
|
|
||||||
if (!editor.internal_editing()) {
|
if (!_region.get_time_axis_view().editor().internal_editing()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ev->type) {
|
switch (ev->type) {
|
||||||
case GDK_ENTER_NOTIFY:
|
case GDK_ENTER_NOTIFY:
|
||||||
_region.note_entered(this);
|
_region.note_entered(this);
|
||||||
//Keyboard::magic_widget_grab_focus();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_LEAVE_NOTIFY:
|
case GDK_LEAVE_NOTIFY:
|
||||||
//Keyboard::magic_widget_drop_focus();
|
|
||||||
_region.note_left (this);
|
_region.note_left (this);
|
||||||
if (!selected()) {
|
|
||||||
hide_velocity();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_BUTTON_PRESS:
|
case GDK_BUTTON_PRESS:
|
||||||
if (ev->button.button == 3) {
|
cerr << "button press, bton = " << ev->button.button << endl;
|
||||||
show_channel_selector();
|
if (ev->button.button == 3 && Keyboard::no_modifiers_active (ev->button.state)) {
|
||||||
|
show_channel_selector();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_BUTTON_RELEASE:
|
case GDK_BUTTON_RELEASE:
|
||||||
if (ev->button.button == 3) {
|
if (ev->button.button == 3 && Keyboard::no_modifiers_active (ev->button.state)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@
|
||||||
|
|
||||||
#include "rgb_macros.h"
|
#include "rgb_macros.h"
|
||||||
#include "ardour_ui.h"
|
#include "ardour_ui.h"
|
||||||
|
#include "canvas-noevent-text.h"
|
||||||
#include "ui_config.h"
|
#include "ui_config.h"
|
||||||
#include "interactive-item.h"
|
|
||||||
|
|
||||||
class Editor;
|
class Editor;
|
||||||
class MidiRegionView;
|
class MidiRegionView;
|
||||||
|
|
@ -51,8 +51,9 @@ namespace Canvas {
|
||||||
*
|
*
|
||||||
* A newer, better canvas should remove the need for all the ugly here.
|
* A newer, better canvas should remove the need for all the ugly here.
|
||||||
*/
|
*/
|
||||||
class CanvasNoteEvent : virtual public sigc::trackable, public InteractiveItem {
|
class CanvasNoteEvent : virtual public sigc::trackable
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
typedef Evoral::Note<ARDOUR::MidiModel::TimeType> NoteType;
|
typedef Evoral::Note<ARDOUR::MidiModel::TimeType> NoteType;
|
||||||
|
|
||||||
CanvasNoteEvent(
|
CanvasNoteEvent(
|
||||||
|
|
@ -129,7 +130,7 @@ protected:
|
||||||
|
|
||||||
MidiRegionView& _region;
|
MidiRegionView& _region;
|
||||||
Item* const _item;
|
Item* const _item;
|
||||||
InteractiveText* _text;
|
NoEventText* _text;
|
||||||
Widget* _channel_selector_widget;
|
Widget* _channel_selector_widget;
|
||||||
State _state;
|
State _state;
|
||||||
const boost::shared_ptr<NoteType> _note;
|
const boost::shared_ptr<NoteType> _note;
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,25 @@ using namespace ARDOUR;
|
||||||
namespace Gnome {
|
namespace Gnome {
|
||||||
namespace Canvas {
|
namespace Canvas {
|
||||||
|
|
||||||
|
CanvasNote::CanvasNote (MidiRegionView& region,
|
||||||
|
Group& group,
|
||||||
|
const boost::shared_ptr<NoteType> note,
|
||||||
|
bool with_events)
|
||||||
|
: SimpleRect(group), CanvasNoteEvent(region, this, note)
|
||||||
|
{
|
||||||
|
if (with_events) {
|
||||||
|
signal_event().connect (sigc::mem_fun (*this, &CanvasNote::on_event));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CanvasNote::on_event(GdkEvent* ev)
|
CanvasNote::on_event(GdkEvent* ev)
|
||||||
{
|
{
|
||||||
if (!_region.get_trackview().editor().canvas_note_event (ev, this)) {
|
if (!CanvasNoteEvent::on_event (ev)) {
|
||||||
return CanvasNoteEvent::on_event (ev);
|
return _region.get_trackview().editor().canvas_note_event (ev, this);
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,16 @@
|
||||||
namespace Gnome {
|
namespace Gnome {
|
||||||
namespace Canvas {
|
namespace Canvas {
|
||||||
|
|
||||||
class CanvasNote : public SimpleRect, public CanvasNoteEvent {
|
class CanvasNote : public SimpleRect, public CanvasNoteEvent
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
typedef Evoral::Note<Evoral::MusicalTime> NoteType;
|
typedef Evoral::Note<Evoral::MusicalTime> NoteType;
|
||||||
|
|
||||||
|
CanvasNote (MidiRegionView& region,
|
||||||
|
Group& group,
|
||||||
|
const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>(),
|
||||||
|
bool with_events = true);
|
||||||
|
|
||||||
double x1() { return property_x1(); }
|
double x1() { return property_x1(); }
|
||||||
double y1() { return property_y1(); }
|
double y1() { return property_y1(); }
|
||||||
double x2() { return property_x2(); }
|
double x2() { return property_x2(); }
|
||||||
|
|
@ -46,25 +52,16 @@ public:
|
||||||
|
|
||||||
bool on_event(GdkEvent* ev);
|
bool on_event(GdkEvent* ev);
|
||||||
void move_event(double dx, double dy);
|
void move_event(double dx, double dy);
|
||||||
|
|
||||||
CanvasNote (MidiRegionView& region,
|
|
||||||
Group& group,
|
|
||||||
const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>())
|
|
||||||
: SimpleRect(group), CanvasNoteEvent(region, this, note)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class NoEventCanvasNote : public CanvasNote
|
class NoEventCanvasNote : public CanvasNote
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NoEventCanvasNote (
|
NoEventCanvasNote (MidiRegionView& region,
|
||||||
MidiRegionView& region,
|
Group& group,
|
||||||
Group& group,
|
const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>())
|
||||||
const boost::shared_ptr<NoteType> note = boost::shared_ptr<NoteType>()
|
: CanvasNote (region, group, note, false) {}
|
||||||
)
|
|
||||||
: CanvasNote (region, group, note) {}
|
|
||||||
|
|
||||||
double point_vfunc(double, double, int, int, GnomeCanvasItem**) {
|
double point_vfunc(double, double, int, int, GnomeCanvasItem**) {
|
||||||
/* return a huge value to tell the canvas that we're never the item for an event */
|
/* return a huge value to tell the canvas that we're never the item for an event */
|
||||||
return 9999999999999.0;
|
return 9999999999999.0;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@
|
||||||
#include "control_point.h"
|
#include "control_point.h"
|
||||||
#include "canvas_impl.h"
|
#include "canvas_impl.h"
|
||||||
#include "simplerect.h"
|
#include "simplerect.h"
|
||||||
#include "interactive-item.h"
|
|
||||||
#include "editor_drag.h"
|
#include "editor_drag.h"
|
||||||
#include "midi_time_axis.h"
|
#include "midi_time_axis.h"
|
||||||
#include "editor_regions.h"
|
#include "editor_regions.h"
|
||||||
|
|
@ -65,12 +64,6 @@ Editor::track_canvas_scroll (GdkEventScroll* ev)
|
||||||
nframes64_t xdelta;
|
nframes64_t xdelta;
|
||||||
int direction = ev->direction;
|
int direction = ev->direction;
|
||||||
|
|
||||||
Gnome::Canvas::Item* item = track_canvas->get_item_at(ev->x, ev->y);
|
|
||||||
InteractiveItem* interactive_item = dynamic_cast<InteractiveItem*>(item);
|
|
||||||
if (interactive_item) {
|
|
||||||
return interactive_item->on_event(reinterpret_cast<GdkEvent*>(ev));
|
|
||||||
}
|
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case GDK_SCROLL_UP:
|
case GDK_SCROLL_UP:
|
||||||
|
|
@ -153,8 +146,7 @@ bool
|
||||||
Editor::track_canvas_scroll_event (GdkEventScroll *event)
|
Editor::track_canvas_scroll_event (GdkEventScroll *event)
|
||||||
{
|
{
|
||||||
track_canvas->grab_focus();
|
track_canvas->grab_focus();
|
||||||
track_canvas_scroll (event);
|
return track_canvas_scroll (event);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
@ -961,6 +953,7 @@ Editor::canvas_note_event (GdkEvent *event, ArdourCanvas::Item* item)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cerr << "Forward note event item on to editor\n";
|
||||||
return typed_event (item, event, NoteItem);
|
return typed_event (item, event, NoteItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (C) 2008 Paul Davis
|
|
||||||
Author: Dave Robillard
|
|
||||||
|
|
||||||
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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __ardour_interactive_item_h__
|
|
||||||
#define __ardour_interactive_item_h__
|
|
||||||
|
|
||||||
#include <libgnomecanvasmm/text.h>
|
|
||||||
#include "simplerect.h"
|
|
||||||
|
|
||||||
namespace Gnome {
|
|
||||||
namespace Canvas {
|
|
||||||
|
|
||||||
|
|
||||||
/** A canvas item that handles events.
|
|
||||||
* This is required so ardour can custom deliver events to specific items
|
|
||||||
* (e.g. to delineate scroll events) since Gnome::Canvas::Item::on_event
|
|
||||||
* is protected.
|
|
||||||
*/
|
|
||||||
class InteractiveItem {
|
|
||||||
public:
|
|
||||||
virtual ~InteractiveItem() {}
|
|
||||||
|
|
||||||
virtual bool on_event(GdkEvent* ev) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** A canvas text that forwards events to its parent.
|
|
||||||
*/
|
|
||||||
class InteractiveText : public Text, public InteractiveItem {
|
|
||||||
public:
|
|
||||||
InteractiveText(Group& parent, InteractiveItem* parent_item, double x, double y, const Glib::ustring& text)
|
|
||||||
: Text(parent, x, y, text)
|
|
||||||
, _parent_item(parent_item)
|
|
||||||
{}
|
|
||||||
|
|
||||||
InteractiveText(Group& parent, InteractiveItem* parent_item)
|
|
||||||
: Text(parent)
|
|
||||||
, _parent_item(parent_item)
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool on_event(GdkEvent* ev) {
|
|
||||||
if(_parent_item) {
|
|
||||||
return _parent_item->on_event(ev);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
InteractiveItem* _parent_item;
|
|
||||||
};
|
|
||||||
|
|
||||||
class InteractiveRect: public SimpleRect, public InteractiveItem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
InteractiveRect(Group& parent, InteractiveItem* parent_item,
|
|
||||||
double x1, double y1, double x2, double y2)
|
|
||||||
: SimpleRect(parent, x1, y1, x2, y2)
|
|
||||||
, _parent_item(parent_item)
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool on_event(GdkEvent* ev) {
|
|
||||||
if (_parent_item) {
|
|
||||||
return _parent_item->on_event(ev);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
InteractiveItem* _parent_item;
|
|
||||||
};
|
|
||||||
|
|
||||||
} /* namespace Canvas */
|
|
||||||
} /* namespace Gnome */
|
|
||||||
|
|
||||||
#endif /* __ardour_interactive_item_h__ */
|
|
||||||
|
|
@ -277,6 +277,7 @@ bool
|
||||||
MidiRegionView::enter_notify (GdkEventCrossing* ev)
|
MidiRegionView::enter_notify (GdkEventCrossing* ev)
|
||||||
{
|
{
|
||||||
/* FIXME: do this on switch to note tool, too, if the pointer is already in */
|
/* FIXME: do this on switch to note tool, too, if the pointer is already in */
|
||||||
|
|
||||||
Keyboard::magic_widget_grab_focus();
|
Keyboard::magic_widget_grab_focus();
|
||||||
group->grab_focus();
|
group->grab_focus();
|
||||||
|
|
||||||
|
|
@ -290,6 +291,7 @@ MidiRegionView::enter_notify (GdkEventCrossing* ev)
|
||||||
bool
|
bool
|
||||||
MidiRegionView::leave_notify (GdkEventCrossing* ev)
|
MidiRegionView::leave_notify (GdkEventCrossing* ev)
|
||||||
{
|
{
|
||||||
|
_mouse_state = None;
|
||||||
trackview.editor().hide_verbose_canvas_cursor ();
|
trackview.editor().hide_verbose_canvas_cursor ();
|
||||||
delete _ghost_note;
|
delete _ghost_note;
|
||||||
_ghost_note = 0;
|
_ghost_note = 0;
|
||||||
|
|
@ -511,16 +513,20 @@ MidiRegionView::motion (GdkEventMotion* ev)
|
||||||
bool
|
bool
|
||||||
MidiRegionView::scroll (GdkEventScroll* ev)
|
MidiRegionView::scroll (GdkEventScroll* ev)
|
||||||
{
|
{
|
||||||
bool fine = Keyboard::modifier_state_equals (ev->state, Keyboard::Level4Modifier);
|
if (_selection.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
trackview.editor().hide_verbose_canvas_cursor ();
|
||||||
|
|
||||||
|
bool fine = Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier);
|
||||||
|
|
||||||
if (ev->direction == GDK_SCROLL_UP) {
|
if (ev->direction == GDK_SCROLL_UP) {
|
||||||
change_velocities (true, fine, false);
|
change_velocities (true, fine, false);
|
||||||
return true;
|
|
||||||
} else if (ev->direction == GDK_SCROLL_DOWN) {
|
} else if (ev->direction == GDK_SCROLL_DOWN) {
|
||||||
change_velocities (false, fine, false);
|
change_velocities (false, fine, false);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
@ -566,8 +572,8 @@ MidiRegionView::key_press (GdkEventKey* ev)
|
||||||
|
|
||||||
} else if (ev->keyval == GDK_Up) {
|
} else if (ev->keyval == GDK_Up) {
|
||||||
|
|
||||||
bool allow_smush = Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier);
|
bool allow_smush = Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier);
|
||||||
bool fine = Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier);
|
bool fine = !Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier);
|
||||||
|
|
||||||
if (Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier)) {
|
if (Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier)) {
|
||||||
change_velocities (true, fine, allow_smush);
|
change_velocities (true, fine, allow_smush);
|
||||||
|
|
@ -578,8 +584,8 @@ MidiRegionView::key_press (GdkEventKey* ev)
|
||||||
|
|
||||||
} else if (ev->keyval == GDK_Down) {
|
} else if (ev->keyval == GDK_Down) {
|
||||||
|
|
||||||
bool allow_smush = Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier);
|
bool allow_smush = Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier);
|
||||||
bool fine = Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier);
|
bool fine = !Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier);
|
||||||
|
|
||||||
if (Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier)) {
|
if (Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier)) {
|
||||||
change_velocities (false, fine, allow_smush);
|
change_velocities (false, fine, allow_smush);
|
||||||
|
|
@ -1306,6 +1312,7 @@ MidiRegionView::update_note (CanvasNote* ev)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NoteType> note = ev->note();
|
boost::shared_ptr<NoteType> note = ev->note();
|
||||||
|
|
||||||
|
|
||||||
const nframes64_t note_start_frames = beats_to_frames(note->time());
|
const nframes64_t note_start_frames = beats_to_frames(note->time());
|
||||||
const nframes64_t note_end_frames = beats_to_frames(note->end_time());
|
const nframes64_t note_end_frames = beats_to_frames(note->end_time());
|
||||||
|
|
||||||
|
|
@ -2179,6 +2186,8 @@ MidiRegionView::change_note_velocity(CanvasNoteEvent* event, int8_t velocity, bo
|
||||||
new_velocity = velocity;
|
new_velocity = velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event->show_velocity ();
|
||||||
|
|
||||||
diff_add_change (event, MidiModel::DiffCommand::Velocity, new_velocity);
|
diff_add_change (event, MidiModel::DiffCommand::Velocity, new_velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2485,6 +2494,7 @@ MidiRegionView::change_channel(uint8_t channel)
|
||||||
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
|
for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) {
|
||||||
diff_add_change (*i, MidiModel::DiffCommand::Channel, channel);
|
diff_add_change (*i, MidiModel::DiffCommand::Channel, channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_diff();
|
apply_diff();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2493,20 +2503,19 @@ void
|
||||||
MidiRegionView::note_entered(ArdourCanvas::CanvasNoteEvent* ev)
|
MidiRegionView::note_entered(ArdourCanvas::CanvasNoteEvent* ev)
|
||||||
{
|
{
|
||||||
if (_mouse_state == SelectTouchDragging) {
|
if (_mouse_state == SelectTouchDragging) {
|
||||||
note_selected(ev, true);
|
note_selected (ev, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
show_verbose_canvas_cursor (ev->note ());
|
show_verbose_canvas_cursor (ev->note ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MidiRegionView::note_left (ArdourCanvas::CanvasNoteEvent*)
|
MidiRegionView::note_left (ArdourCanvas::CanvasNoteEvent* note)
|
||||||
{
|
{
|
||||||
PublicEditor& editor (trackview.editor());
|
note->hide_velocity ();
|
||||||
editor.hide_verbose_canvas_cursor ();
|
trackview.editor().hide_verbose_canvas_cursor ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MidiRegionView::switch_source(boost::shared_ptr<Source> src)
|
MidiRegionView::switch_source(boost::shared_ptr<Source> src)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue