mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-16 11:46:25 +01:00
make it possible for canvas patch changes to receive kbd events, and along the way clean up a couple of related issues, providing noevent-pixbuf (which we should probably use for regionview names too)
git-svn-id: svn://localhost/ardour2/branches/3.0@12745 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
2e71cb2e26
commit
2863640a52
5 changed files with 73 additions and 28 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "ardour_ui.h"
|
#include "ardour_ui.h"
|
||||||
#include "canvas-flag.h"
|
#include "canvas-flag.h"
|
||||||
|
#include "canvas-noevent-pixbuf.h"
|
||||||
#include "time_axis_view_item.h"
|
#include "time_axis_view_item.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
@ -28,7 +29,6 @@ CanvasFlag::CanvasFlag (MidiRegionView& region,
|
||||||
, _line(0)
|
, _line(0)
|
||||||
, _rect(0)
|
, _rect(0)
|
||||||
{
|
{
|
||||||
signal_event().connect (sigc::mem_fun (*this, &CanvasFlag::on_event));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -49,7 +49,7 @@ CanvasFlag::set_text (const string& text)
|
||||||
{
|
{
|
||||||
delete_allocated_objects();
|
delete_allocated_objects();
|
||||||
|
|
||||||
_name_pixbuf = new ArdourCanvas::Pixbuf (*this);
|
_name_pixbuf = new ArdourCanvas::NoEventPixbuf (*this);
|
||||||
name_pixbuf_width = Gtkmm2ext::pixel_width (text, TimeAxisViewItem::NAME_FONT) + 2;
|
name_pixbuf_width = Gtkmm2ext::pixel_width (text, TimeAxisViewItem::NAME_FONT) + 2;
|
||||||
Gdk::Color c;
|
Gdk::Color c;
|
||||||
set_color (c, _outline_color_rgba);
|
set_color (c, _outline_color_rgba);
|
||||||
|
|
@ -75,15 +75,6 @@ CanvasFlag::~CanvasFlag()
|
||||||
delete_allocated_objects();
|
delete_allocated_objects();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CanvasFlag::set_height (double h)
|
CanvasFlag::set_height (double h)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,6 @@ public:
|
||||||
|
|
||||||
virtual ~CanvasFlag();
|
virtual ~CanvasFlag();
|
||||||
|
|
||||||
virtual bool on_event(GdkEvent* ev);
|
|
||||||
|
|
||||||
virtual void set_text(const std::string& a_text);
|
virtual void set_text(const std::string& a_text);
|
||||||
virtual void set_height (double);
|
virtual void set_height (double);
|
||||||
|
|
||||||
|
|
|
||||||
41
gtk2_ardour/canvas-noevent-pixbuf.h
Normal file
41
gtk2_ardour/canvas-noevent-pixbuf.h
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009 Paul Davis <paul@linuxaudiosystems.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __gtk2_ardour_canvas_noevent_pixbuf_h__
|
||||||
|
#define __gtk2_ardour_canvas_noevent_pixbuf_h__
|
||||||
|
|
||||||
|
#include <libgnomecanvasmm/pixbuf.h>
|
||||||
|
|
||||||
|
namespace Gnome { namespace Canvas {
|
||||||
|
|
||||||
|
class NoEventPixbuf : public Pixbuf
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NoEventPixbuf(Group& parent) : Pixbuf (parent) {}
|
||||||
|
|
||||||
|
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 9999999999999.0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} } /* namespaces */
|
||||||
|
|
||||||
|
#endif /* __gtk2_ardour_canvas_noevent_pixbuf_h__ */
|
||||||
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
|
#include "pbd/stacktrace.h"
|
||||||
|
|
||||||
#include "gtkmm2ext/keyboard.h"
|
#include "gtkmm2ext/keyboard.h"
|
||||||
#include "ardour/instrument_info.h"
|
#include "ardour/instrument_info.h"
|
||||||
|
|
||||||
|
|
@ -144,11 +146,12 @@ CanvasPatchChange::on_patch_menu_selected(const PatchPrimaryKey& key)
|
||||||
bool
|
bool
|
||||||
CanvasPatchChange::on_event (GdkEvent* ev)
|
CanvasPatchChange::on_event (GdkEvent* ev)
|
||||||
{
|
{
|
||||||
|
Editor* e;
|
||||||
|
|
||||||
switch (ev->type) {
|
switch (ev->type) {
|
||||||
case GDK_BUTTON_PRESS:
|
case GDK_BUTTON_PRESS:
|
||||||
{
|
|
||||||
/* XXX: icky dcast */
|
/* XXX: icky dcast */
|
||||||
Editor* e = dynamic_cast<Editor*> (&_region.get_time_axis_view().editor());
|
e = dynamic_cast<Editor*> (&_region.get_time_axis_view().editor());
|
||||||
if (e->current_mouse_mode() == Editing::MouseObject && e->internal_editing()) {
|
if (e->current_mouse_mode() == Editing::MouseObject && e->internal_editing()) {
|
||||||
|
|
||||||
if (Gtkmm2ext::Keyboard::is_delete_event (&ev->button)) {
|
if (Gtkmm2ext::Keyboard::is_delete_event (&ev->button)) {
|
||||||
|
|
@ -178,7 +181,6 @@ CanvasPatchChange::on_event (GdkEvent* ev)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case GDK_KEY_PRESS:
|
case GDK_KEY_PRESS:
|
||||||
switch (ev->key.keyval) {
|
switch (ev->key.keyval) {
|
||||||
|
|
@ -200,15 +202,18 @@ CanvasPatchChange::on_event (GdkEvent* ev)
|
||||||
_region.next_patch (*this);
|
_region.next_patch (*this);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case GDK_Delete:
|
||||||
|
case GDK_BackSpace:
|
||||||
|
_region.delete_patch_change (this);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_SCROLL:
|
case GDK_SCROLL:
|
||||||
{
|
|
||||||
/* XXX: icky dcast */
|
/* XXX: icky dcast */
|
||||||
Editor* e = dynamic_cast<Editor*> (&_region.get_time_axis_view().editor());
|
e = dynamic_cast<Editor*> (&_region.get_time_axis_view().editor());
|
||||||
if (e->current_mouse_mode() == Editing::MouseObject && e->internal_editing()) {
|
if (e->current_mouse_mode() == Editing::MouseObject && e->internal_editing()) {
|
||||||
if (ev->scroll.direction == GDK_SCROLL_UP) {
|
if (ev->scroll.direction == GDK_SCROLL_UP) {
|
||||||
if (Keyboard::modifier_state_contains (ev->scroll.state, Keyboard::PrimaryModifier)) {
|
if (Keyboard::modifier_state_contains (ev->scroll.state, Keyboard::PrimaryModifier)) {
|
||||||
|
|
@ -216,25 +221,26 @@ CanvasPatchChange::on_event (GdkEvent* ev)
|
||||||
} else {
|
} else {
|
||||||
_region.previous_patch (*this);
|
_region.previous_patch (*this);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
} else if (ev->scroll.direction == GDK_SCROLL_DOWN) {
|
} else if (ev->scroll.direction == GDK_SCROLL_DOWN) {
|
||||||
if (Keyboard::modifier_state_contains (ev->scroll.state, Keyboard::PrimaryModifier)) {
|
if (Keyboard::modifier_state_contains (ev->scroll.state, Keyboard::PrimaryModifier)) {
|
||||||
_region.next_bank (*this);
|
_region.next_bank (*this);
|
||||||
} else {
|
} else {
|
||||||
_region.next_patch (*this);
|
_region.next_patch (*this);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
|
||||||
case GDK_ENTER_NOTIFY:
|
case GDK_ENTER_NOTIFY:
|
||||||
_region.patch_entered (this);
|
_region.patch_entered (this);
|
||||||
|
return true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_LEAVE_NOTIFY:
|
case GDK_LEAVE_NOTIFY:
|
||||||
_region.patch_left (this);
|
_region.patch_left (this);
|
||||||
|
return true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -277,8 +277,7 @@ MidiRegionView::init (Gdk::Color const & basic_color, bool wfd)
|
||||||
reset_width_dependent_items (_pixel_width);
|
reset_width_dependent_items (_pixel_width);
|
||||||
|
|
||||||
group->raise_to_top();
|
group->raise_to_top();
|
||||||
group->signal_event().connect(
|
group->signal_event().connect (sigc::mem_fun (this, &MidiRegionView::canvas_event), false);
|
||||||
sigc::mem_fun(this, &MidiRegionView::canvas_event), false);
|
|
||||||
|
|
||||||
midi_view()->signal_channel_mode_changed().connect(
|
midi_view()->signal_channel_mode_changed().connect(
|
||||||
sigc::mem_fun(this, &MidiRegionView::midi_channel_mode_changed));
|
sigc::mem_fun(this, &MidiRegionView::midi_channel_mode_changed));
|
||||||
|
|
@ -714,7 +713,11 @@ MidiRegionView::key_press (GdkEventKey* ev)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (ev->keyval == GDK_Delete && unmodified) {
|
} else if ((ev->keyval == GDK_BackSpace || ev->keyval == GDK_Delete) && unmodified) {
|
||||||
|
|
||||||
|
if (_selection.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
delete_selection();
|
delete_selection();
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1798,7 +1801,7 @@ MidiRegionView::add_canvas_patch_change (MidiModel::PatchChangePtr patch, const
|
||||||
double const height = midi_stream_view()->contents_height();
|
double const height = midi_stream_view()->contents_height();
|
||||||
|
|
||||||
boost::shared_ptr<CanvasPatchChange> patch_change = boost::shared_ptr<CanvasPatchChange>(
|
boost::shared_ptr<CanvasPatchChange> patch_change = boost::shared_ptr<CanvasPatchChange>(
|
||||||
new CanvasPatchChange(*this, *_note_group,
|
new CanvasPatchChange(*this, *group,
|
||||||
displaytext,
|
displaytext,
|
||||||
height,
|
height,
|
||||||
x, 1.0,
|
x, 1.0,
|
||||||
|
|
@ -3139,18 +3142,24 @@ MidiRegionView::note_left (ArdourCanvas::CanvasNoteEvent*)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MidiRegionView::patch_entered (ArdourCanvas::CanvasPatchChange* ev)
|
MidiRegionView::patch_entered (ArdourCanvas::CanvasPatchChange* p)
|
||||||
{
|
{
|
||||||
ostringstream s;
|
ostringstream s;
|
||||||
/* XXX should get patch name if we can */
|
/* XXX should get patch name if we can */
|
||||||
s << _("Bank:") << (ev->patch()->bank() + MIDI_BP_ZERO) << '\n' << _("Program:") << ((int) ev->patch()->program()) + MIDI_BP_ZERO << '\n' << _("Channel:") << ((int) ev->patch()->channel() + 1);
|
s << _("Bank:") << (p->patch()->bank() + MIDI_BP_ZERO) << '\n'
|
||||||
|
<< _("Program:") << ((int) p->patch()->program()) + MIDI_BP_ZERO << '\n'
|
||||||
|
<< _("Channel:") << ((int) p->patch()->channel() + 1);
|
||||||
show_verbose_cursor (s.str(), 10, 20);
|
show_verbose_cursor (s.str(), 10, 20);
|
||||||
|
p->grab_focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MidiRegionView::patch_left (ArdourCanvas::CanvasPatchChange *)
|
MidiRegionView::patch_left (ArdourCanvas::CanvasPatchChange *)
|
||||||
{
|
{
|
||||||
trackview.editor().verbose_cursor()->hide ();
|
trackview.editor().verbose_cursor()->hide ();
|
||||||
|
/* focus will transfer back via the enter-notify event sent to this
|
||||||
|
* midi region view.
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue