* made notes whose channel is not selected in the track appear gray, see http://www.flickr.com/photos/24012642@N02/2429528120/

git-svn-id: svn://localhost/ardour2/branches/3.0@3272 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Hans Baier 2008-04-20 22:33:13 +00:00
parent 20cfa08aea
commit e8c2b6f371
8 changed files with 58 additions and 20 deletions

View file

@ -59,9 +59,11 @@
<Option name="midi note fill max" value="ee33338a"/> <Option name="midi note fill max" value="ee33338a"/>
<Option name="midi note fill mid" value="eeee338a"/> <Option name="midi note fill mid" value="eeee338a"/>
<Option name="midi note fill min" value="33ee338a"/> <Option name="midi note fill min" value="33ee338a"/>
<Option name="midi note fill inactive channel" value="bfbfbf88"/>
<Option name="midi note outline max" value="ff2222b0"/> <Option name="midi note outline max" value="ff2222b0"/>
<Option name="midi note outline mid" value="ffff22b0"/> <Option name="midi note outline mid" value="ffff22b0"/>
<Option name="midi note outline min" value="22ff22b0"/> <Option name="midi note outline min" value="22ff22b0"/>
<Option name="midi note outline inactive channel" value="bfbfbfff"/>
<Option name="midi note selected outline" value="5566ffee"/> <Option name="midi note selected outline" value="5566ffee"/>
<Option name="midi select rect fill" value="8888ff88"/> <Option name="midi select rect fill" value="8888ff88"/>
<Option name="midi select rect outline" value="5555ffff"/> <Option name="midi select rect outline" value="5555ffff"/>

View file

@ -78,6 +78,22 @@ CanvasMidiEvent::hide_velocity(void)
_text->hide(); _text->hide();
} }
void
CanvasMidiEvent::on_channel_selection_change(uint16_t selection)
{
// make note change its color if its channel is not marked active
if( (selection & (1 << _note->channel())) == 0 ) {
set_fill_color(ARDOUR_UI::config()->canvasvar_MidiNoteFillInactiveChannel.get());
set_outline_color(ARDOUR_UI::config()->canvasvar_MidiNoteOutlineInactiveChannel.get());
} else {
set_fill_color(note_fill_color(_note->velocity()));
set_outline_color(note_outline_color(_note->velocity()));
}
// this forces the item to update..... maybe slow...
_item->hide();
_item->show();
}
void void
CanvasMidiEvent::on_channel_change(uint8_t channel) CanvasMidiEvent::on_channel_change(uint8_t channel)
{ {

View file

@ -44,7 +44,7 @@ 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 CanvasMidiEvent { class CanvasMidiEvent : public sigc::trackable {
public: public:
CanvasMidiEvent( CanvasMidiEvent(
MidiRegionView& region, MidiRegionView& region,
@ -64,9 +64,10 @@ public:
void hide_velocity(); void hide_velocity();
/** /**
* This slot is called, when a new channel is selected for the event * This slot is called, when a new channel is selected for the single event
* */ * */
void on_channel_change(uint8_t channel); void on_channel_change(uint8_t channel);
void on_channel_selection_change(uint16_t selection);
void show_channel_selector(); void show_channel_selector();

View file

@ -59,9 +59,11 @@ CANVAS_VARIABLE(canvasvar_MidiFrameBase, "midi frame base")
CANVAS_VARIABLE(canvasvar_MidiNoteFillMax, "midi note fill max") CANVAS_VARIABLE(canvasvar_MidiNoteFillMax, "midi note fill max")
CANVAS_VARIABLE(canvasvar_MidiNoteFillMid, "midi note fill mid") CANVAS_VARIABLE(canvasvar_MidiNoteFillMid, "midi note fill mid")
CANVAS_VARIABLE(canvasvar_MidiNoteFillMin, "midi note fill min") CANVAS_VARIABLE(canvasvar_MidiNoteFillMin, "midi note fill min")
CANVAS_VARIABLE(canvasvar_MidiNoteFillInactiveChannel, "midi note fill inactive channel")
CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMax, "midi note outline max") CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMax, "midi note outline max")
CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMid, "midi note outline mid") CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMid, "midi note outline mid")
CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMin, "midi note outline min") CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMin, "midi note outline min")
CANVAS_VARIABLE(canvasvar_MidiNoteOutlineInactiveChannel, "midi note outline inactive channel")
CANVAS_VARIABLE(canvasvar_MidiNoteSelectedOutline, "midi note selected outline") CANVAS_VARIABLE(canvasvar_MidiNoteSelectedOutline, "midi note selected outline")
CANVAS_VARIABLE(canvasvar_MidiSelectRectFill, "midi select rect fill") CANVAS_VARIABLE(canvasvar_MidiSelectRectFill, "midi select rect fill")
CANVAS_VARIABLE(canvasvar_MidiSelectRectOutline, "midi select rect outline") CANVAS_VARIABLE(canvasvar_MidiSelectRectOutline, "midi select rect outline")

View file

@ -60,6 +60,7 @@ using namespace ArdourCanvas;
MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<MidiRegion> r, double spu, Gdk::Color& basic_color) MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<MidiRegion> r, double spu, Gdk::Color& basic_color)
: RegionView (parent, tv, r, spu, basic_color) : RegionView (parent, tv, r, spu, basic_color)
, last_channel_selection(0xFFFF)
, _default_note_length(0.0) , _default_note_length(0.0)
, _active_notes(0) , _active_notes(0)
, _note_group(new ArdourCanvas::Group(*parent)) , _note_group(new ArdourCanvas::Group(*parent))
@ -75,12 +76,14 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &
MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<MidiRegion> r, double spu, Gdk::Color& basic_color, TimeAxisViewItem::Visibility visibility) MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &tv, boost::shared_ptr<MidiRegion> r, double spu, Gdk::Color& basic_color, TimeAxisViewItem::Visibility visibility)
: RegionView (parent, tv, r, spu, basic_color, visibility) : RegionView (parent, tv, r, spu, basic_color, visibility)
, last_channel_selection(0xFFFF)
, _default_note_length(0.0) , _default_note_length(0.0)
, _active_notes(0) , _active_notes(0)
, _note_group(new ArdourCanvas::Group(*parent)) , _note_group(new ArdourCanvas::Group(*parent))
, _delta_command(NULL) , _delta_command(NULL)
, _mouse_state(None) , _mouse_state(None)
, _pressed_button(0) , _pressed_button(0)
{ {
_note_group->raise_to_top(); _note_group->raise_to_top();
} }
@ -128,6 +131,8 @@ MidiRegionView::init (Gdk::Color& basic_color, bool wfd)
group->signal_event().connect (mem_fun (this, &MidiRegionView::canvas_event), false); group->signal_event().connect (mem_fun (this, &MidiRegionView::canvas_event), false);
midi_view()->signal_channel_selection_changed().connect(
mem_fun(this, &MidiRegionView::midi_channel_selection_changed));
} }
bool bool
@ -721,9 +726,6 @@ MidiRegionView::add_note(const boost::shared_ptr<Note> note)
ev_rect->property_x2() = trackview.editor.frame_to_pixel(_region->length()); ev_rect->property_x2() = trackview.editor.frame_to_pixel(_region->length());
ev_rect->property_y2() = y1 + floor(midi_stream_view()->note_height()); ev_rect->property_y2() = y1 + floor(midi_stream_view()->note_height());
ev_rect->property_fill_color_rgba() = note_fill_color(note->velocity());
ev_rect->property_outline_color_rgba() = note_outline_color(note->velocity());
if (note->duration() == 0) { if (note->duration() == 0) {
_active_notes[note->note()] = ev_rect; _active_notes[note->note()] = ev_rect;
/* outline all but right edge */ /* outline all but right edge */
@ -756,8 +758,6 @@ MidiRegionView::add_note(const boost::shared_ptr<Note> note)
CanvasHit* ev_diamond = new CanvasHit(*this, *group, diamond_size, note); CanvasHit* ev_diamond = new CanvasHit(*this, *group, diamond_size, note);
ev_diamond->move(x, y); ev_diamond->move(x, y);
ev_diamond->show(); ev_diamond->show();
ev_diamond->property_fill_color_rgba() = note_fill_color(note->velocity());
ev_diamond->property_outline_color_rgba() = note_outline_color(note->velocity());
_events.push_back(ev_diamond); _events.push_back(ev_diamond);
event = ev_diamond; event = ev_diamond;
} else { } else {
@ -768,6 +768,7 @@ MidiRegionView::add_note(const boost::shared_ptr<Note> note)
if(_marked_for_selection.find(event->note()) != _marked_for_selection.end()) { if(_marked_for_selection.find(event->note()) != _marked_for_selection.end()) {
note_selected(event, true); note_selected(event, true);
} }
event->on_channel_selection_change(last_channel_selection);
} }
} }
@ -1231,3 +1232,14 @@ MidiRegionView::set_frame_color()
} }
} }
} }
void
MidiRegionView::midi_channel_selection_changed(uint16_t selection)
{
for(std::vector<ArdourCanvas::CanvasMidiEvent*>::iterator i = _events.begin();
i != _events.end();
++i) {
(*i)->on_channel_selection_change(selection);
}
last_channel_selection = selection;
}

View file

@ -237,6 +237,9 @@ class MidiRegionView : public RegionView
bool canvas_event(GdkEvent* ev); bool canvas_event(GdkEvent* ev);
bool note_canvas_event(GdkEvent* ev); bool note_canvas_event(GdkEvent* ev);
uint16_t last_channel_selection;
void midi_channel_selection_changed(uint16_t selection);
void clear_selection_except(ArdourCanvas::CanvasMidiEvent* ev); void clear_selection_except(ArdourCanvas::CanvasMidiEvent* ev);
void clear_selection() { clear_selection_except(NULL); } void clear_selection() { clear_selection_except(NULL); }

View file

@ -91,7 +91,7 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar
, _note_mode_item(NULL) , _note_mode_item(NULL)
, _percussion_mode_item(NULL) , _percussion_mode_item(NULL)
, _midi_expander("MIDI") , _midi_expander("MIDI")
, _channel_selector(0) , _channel_selector(0xFFFF)
{ {
subplugin_menu.set_name ("ArdourContextMenu"); subplugin_menu.set_name ("ArdourContextMenu");
@ -137,15 +137,14 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar
_view->attach (); _view->attach ();
} }
// add channel selector // add channel selector expander
_channel_selector = manage(new MidiMultipleChannelSelector(0xFFFF));
HBox *channel_selector_box = manage(new HBox()); HBox *channel_selector_box = manage(new HBox());
channel_selector_box->pack_start(*_channel_selector, SHRINK, 0); channel_selector_box->pack_start(_channel_selector, SHRINK, 0);
_midi_expander.add(*channel_selector_box); _midi_expander.add(*channel_selector_box);
_midi_expander.property_expanded().signal_changed().connect( _midi_expander.property_expanded().signal_changed().connect(
mem_fun(this, &MidiTimeAxisView::channel_selector_toggled)); mem_fun(this, &MidiTimeAxisView::channel_selector_toggled));
controls_vbox.pack_end(_midi_expander, SHRINK, 0); controls_vbox.pack_end(_midi_expander, SHRINK, 0);
_channel_selector->selection_changed.connect( _channel_selector.selection_changed.connect(
mem_fun(*midi_track()->midi_diskstream(), &MidiDiskstream::set_channel_mask)); mem_fun(*midi_track()->midi_diskstream(), &MidiDiskstream::set_channel_mask));
} }
@ -389,7 +388,6 @@ void
MidiTimeAxisView::channel_selector_toggled() MidiTimeAxisView::channel_selector_toggled()
{ {
static TimeAxisView::TrackHeight previous_height; static TimeAxisView::TrackHeight previous_height;
assert(_channel_selector);
if(_midi_expander.property_expanded()) { if(_midi_expander.property_expanded()) {
previous_height = height_style; previous_height = height_style;
@ -401,3 +399,5 @@ MidiTimeAxisView::channel_selector_toggled()
} }
} }

View file

@ -73,6 +73,8 @@ class MidiTimeAxisView : public RouteTimeAxisView
ARDOUR::NoteMode note_mode() const { return _note_mode; } ARDOUR::NoteMode note_mode() const { return _note_mode; }
void update_range(); void update_range();
sigc::signal<void, uint16_t>& signal_channel_selection_changed() { return _channel_selector.selection_changed; }
private: private:
@ -89,15 +91,15 @@ class MidiTimeAxisView : public RouteTimeAxisView
void channel_selector_toggled(); void channel_selector_toggled();
Gtk::Menu _subplugin_menu; Gtk::Menu _subplugin_menu;
MidiScroomer* _range_scroomer; MidiScroomer* _range_scroomer;
PianoRollHeader* _piano_roll_header; PianoRollHeader* _piano_roll_header;
ARDOUR::NoteMode _note_mode; ARDOUR::NoteMode _note_mode;
Gtk::RadioMenuItem* _note_mode_item; Gtk::RadioMenuItem* _note_mode_item;
Gtk::RadioMenuItem* _percussion_mode_item; Gtk::RadioMenuItem* _percussion_mode_item;
Gtk::Expander _midi_expander; Gtk::Expander _midi_expander;
MidiMultipleChannelSelector* _channel_selector; MidiMultipleChannelSelector _channel_selector;
}; };
#endif /* __ardour_midi_time_axis_h__ */ #endif /* __ardour_midi_time_axis_h__ */