/*
Copyright (C) 2007 Paul Davis
- Author: Dave Robillard
+ Author: David 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
: _region(region)
, _item(item)
, _text(0)
- , _channel_selector_widget()
, _state(None)
, _note(note)
, _selected(false)
, _valid (true)
, _mouse_x_fraction (-1.0)
, _mouse_y_fraction (-1.0)
+ , _channel_selection (0xffff)
{
}
_text->hide();
delete _text;
}
-
- delete _channel_selector_widget;
}
void
void
CanvasNoteEvent::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_MidiNoteInactiveChannel.get());
- set_outline_color(calculate_outline(ARDOUR_UI::config()->canvasvar_MidiNoteInactiveChannel.get()));
- } else {
- // set the color according to the notes selection state
- set_selected(_selected);
- }
+ _channel_selection = selection;
+
+ /* this takes into account whether or not the note should be drawn as inactive */
+ set_selected (_selected);
+
// this forces the item to update..... maybe slow...
_item->hide();
_item->show();
CanvasNoteEvent::on_channel_change(uint8_t channel)
{
_region.note_selected(this, true);
- hide_channel_selector();
_region.change_channel(channel);
}
-void
-CanvasNoteEvent::show_channel_selector(void)
-{
- if (_channel_selector_widget == 0) {
-
- if(_region.channel_selector_scoped_note() != 0){
- _region.channel_selector_scoped_note()->hide_channel_selector();
- _region.set_channel_selector_scoped_note(0);
- }
-
- SingleMidiChannelSelector* _channel_selector = new SingleMidiChannelSelector(_note->channel());
- _channel_selector->show_all();
- _channel_selector->channel_selected.connect(
- sigc::mem_fun(this, &CanvasNoteEvent::on_channel_change));
-
- _channel_selector->clicked.connect (
- sigc::mem_fun (this, &CanvasNoteEvent::hide_channel_selector));
-
- _channel_selector_widget = new Widget(*(_item->property_parent()),
- x1(),
- y2() + 2,
- (Gtk::Widget &) *_channel_selector);
-
- _channel_selector_widget->hide();
- _channel_selector_widget->property_height() = 100;
- _channel_selector_widget->property_width() = 100;
- _channel_selector_widget->raise_to_top();
- _channel_selector_widget->show();
-
- _region.set_channel_selector_scoped_note(this);
- } else {
- hide_channel_selector();
- }
-}
-
-void
-CanvasNoteEvent::hide_channel_selector(void)
-{
- if (_channel_selector_widget) {
- _channel_selector_widget->hide();
- delete _channel_selector_widget;
- _channel_selector_widget = 0;
- }
-}
-
void
CanvasNoteEvent::set_selected(bool selected)
{
}
_selected = selected;
- set_fill_color (base_color ());
-
- if (_selected) {
+
+ bool const active = (_channel_selection & (1 << _note->channel())) != 0;
+
+ if (_selected && active) {
set_outline_color(calculate_outline(ARDOUR_UI::config()->canvasvar_MidiNoteSelected.get()));
-
- if(_region.channel_selector_scoped_note() != 0){
- _region.channel_selector_scoped_note()->hide_channel_selector();
- _region.set_channel_selector_scoped_note(0);
- }
+ set_fill_color (base_color ());
+
} else {
- set_outline_color(calculate_outline(base_color()));
- hide_channel_selector();
- }
+ if (active) {
+ set_fill_color(base_color());
+ set_outline_color(calculate_outline(base_color()));
+ } else {
+ set_fill_color(ARDOUR_UI::config()->canvasvar_MidiNoteInactiveChannel.get());
+ set_outline_color(calculate_outline(ARDOUR_UI::config()->canvasvar_MidiNoteInactiveChannel.get()));
+ }
+ }
}
#define SCALE_USHORT_TO_UINT8_T(x) ((x) / 257)
SCALE_USHORT_TO_UINT8_T(color.get_red()),
SCALE_USHORT_TO_UINT8_T(color.get_green()),
SCALE_USHORT_TO_UINT8_T(color.get_blue()),
- opacity),
+ opacity),
ARDOUR_UI::config()->canvasvar_MidiNoteSelected.get(), 0.5);
}
case ChannelColors:
return UINT_INTERPOLATE (UINT_RGBA_CHANGE_A (CanvasNoteEvent::midi_channel_colors[_note->channel()],
- opacity),
+ opacity),
ARDOUR_UI::config()->canvasvar_MidiNoteSelected.get(), 0.5);
default:
case GDK_BUTTON_PRESS:
set_mouse_fractions (ev);
if (ev->button.button == 3 && Keyboard::no_modifiers_active (ev->button.state) && _selected) {
- show_channel_selector();
+ _region.get_time_axis_view().editor().edit_notes (_region);
return true;
}
break;
bool
CanvasNoteEvent::big_enough_to_trim () const
{
- return (x2() - x1()) > 10; /* canvas units, really pixels */
+ return (x2() - x1()) > 20; /* canvas units, really pixels */
}
} // namespace Canvas