mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-15 19:16:40 +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 "canvas-flag.h"
|
||||
#include "canvas-noevent-pixbuf.h"
|
||||
#include "time_axis_view_item.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
|
@ -28,7 +29,6 @@ CanvasFlag::CanvasFlag (MidiRegionView& region,
|
|||
, _line(0)
|
||||
, _rect(0)
|
||||
{
|
||||
signal_event().connect (sigc::mem_fun (*this, &CanvasFlag::on_event));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -49,7 +49,7 @@ CanvasFlag::set_text (const string& text)
|
|||
{
|
||||
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;
|
||||
Gdk::Color c;
|
||||
set_color (c, _outline_color_rgba);
|
||||
|
|
@ -75,15 +75,6 @@ CanvasFlag::~CanvasFlag()
|
|||
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
|
||||
CanvasFlag::set_height (double h)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ public:
|
|||
|
||||
virtual ~CanvasFlag();
|
||||
|
||||
virtual bool on_event(GdkEvent* ev);
|
||||
|
||||
virtual void set_text(const std::string& a_text);
|
||||
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 "pbd/stacktrace.h"
|
||||
|
||||
#include "gtkmm2ext/keyboard.h"
|
||||
#include "ardour/instrument_info.h"
|
||||
|
||||
|
|
@ -144,11 +146,12 @@ CanvasPatchChange::on_patch_menu_selected(const PatchPrimaryKey& key)
|
|||
bool
|
||||
CanvasPatchChange::on_event (GdkEvent* ev)
|
||||
{
|
||||
Editor* e;
|
||||
|
||||
switch (ev->type) {
|
||||
case GDK_BUTTON_PRESS:
|
||||
{
|
||||
/* 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 (Gtkmm2ext::Keyboard::is_delete_event (&ev->button)) {
|
||||
|
|
@ -178,7 +181,6 @@ CanvasPatchChange::on_event (GdkEvent* ev)
|
|||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case GDK_KEY_PRESS:
|
||||
switch (ev->key.keyval) {
|
||||
|
|
@ -200,15 +202,18 @@ CanvasPatchChange::on_event (GdkEvent* ev)
|
|||
_region.next_patch (*this);
|
||||
}
|
||||
break;
|
||||
case GDK_Delete:
|
||||
case GDK_BackSpace:
|
||||
_region.delete_patch_change (this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_SCROLL:
|
||||
{
|
||||
/* 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 (ev->scroll.direction == GDK_SCROLL_UP) {
|
||||
if (Keyboard::modifier_state_contains (ev->scroll.state, Keyboard::PrimaryModifier)) {
|
||||
|
|
@ -216,25 +221,26 @@ CanvasPatchChange::on_event (GdkEvent* ev)
|
|||
} else {
|
||||
_region.previous_patch (*this);
|
||||
}
|
||||
return true;
|
||||
} else if (ev->scroll.direction == GDK_SCROLL_DOWN) {
|
||||
if (Keyboard::modifier_state_contains (ev->scroll.state, Keyboard::PrimaryModifier)) {
|
||||
_region.next_bank (*this);
|
||||
} else {
|
||||
_region.next_patch (*this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GDK_ENTER_NOTIFY:
|
||||
_region.patch_entered (this);
|
||||
return true;
|
||||
break;
|
||||
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
_region.patch_left (this);
|
||||
return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -277,8 +277,7 @@ MidiRegionView::init (Gdk::Color const & basic_color, bool wfd)
|
|||
reset_width_dependent_items (_pixel_width);
|
||||
|
||||
group->raise_to_top();
|
||||
group->signal_event().connect(
|
||||
sigc::mem_fun(this, &MidiRegionView::canvas_event), false);
|
||||
group->signal_event().connect (sigc::mem_fun (this, &MidiRegionView::canvas_event), false);
|
||||
|
||||
midi_view()->signal_channel_mode_changed().connect(
|
||||
sigc::mem_fun(this, &MidiRegionView::midi_channel_mode_changed));
|
||||
|
|
@ -322,7 +321,7 @@ bool
|
|||
MidiRegionView::canvas_event(GdkEvent* ev)
|
||||
{
|
||||
bool r;
|
||||
|
||||
|
||||
switch (ev->type) {
|
||||
case GDK_ENTER_NOTIFY:
|
||||
case GDK_LEAVE_NOTIFY:
|
||||
|
|
@ -714,7 +713,11 @@ MidiRegionView::key_press (GdkEventKey* ev)
|
|||
|
||||
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();
|
||||
return true;
|
||||
|
|
@ -1798,7 +1801,7 @@ MidiRegionView::add_canvas_patch_change (MidiModel::PatchChangePtr patch, const
|
|||
double const height = midi_stream_view()->contents_height();
|
||||
|
||||
boost::shared_ptr<CanvasPatchChange> patch_change = boost::shared_ptr<CanvasPatchChange>(
|
||||
new CanvasPatchChange(*this, *_note_group,
|
||||
new CanvasPatchChange(*this, *group,
|
||||
displaytext,
|
||||
height,
|
||||
x, 1.0,
|
||||
|
|
@ -3139,18 +3142,24 @@ MidiRegionView::note_left (ArdourCanvas::CanvasNoteEvent*)
|
|||
}
|
||||
|
||||
void
|
||||
MidiRegionView::patch_entered (ArdourCanvas::CanvasPatchChange* ev)
|
||||
MidiRegionView::patch_entered (ArdourCanvas::CanvasPatchChange* p)
|
||||
{
|
||||
ostringstream s;
|
||||
/* 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);
|
||||
p->grab_focus();
|
||||
}
|
||||
|
||||
void
|
||||
MidiRegionView::patch_left (ArdourCanvas::CanvasPatchChange *)
|
||||
{
|
||||
trackview.editor().verbose_cursor()->hide ();
|
||||
/* focus will transfer back via the enter-notify event sent to this
|
||||
* midi region view.
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue