Fix display of MIDI notes/regions while recording.

Make record rect transparency configurable.

Factor out some copy-paste streamview code.
This commit is contained in:
David Robillard 2014-12-17 18:40:38 -05:00
parent 0f63ac06a4
commit 6e912a0aa3
7 changed files with 52 additions and 93 deletions

View File

@ -237,62 +237,11 @@ AudioStreamView::setup_rec_box ()
/* start a new rec box */
boost::shared_ptr<AudioTrack> at;
at = _trackview.audio_track(); /* we know what it is already */
boost::shared_ptr<AudioTrack> at = _trackview.audio_track();
framepos_t const frame_pos = at->current_capture_start ();
gdouble xstart = _trackview.editor().sample_to_pixel (frame_pos);
gdouble xend = xstart; /* keeps gcc optimized happy, really set in switch() below */
uint32_t fill_color;
double const width = ((at->mode() == Destructive) ? 2 : 0);
switch (_trackview.audio_track()->mode()) {
case Normal:
case NonLayered:
xend = xstart;
fill_color = ARDOUR_UI::config()->color ("recording rect");
break;
case Destructive:
xend = xstart + 2;
fill_color = ARDOUR_UI::config()->color ("recording rect");
/* make the recording rect translucent to allow
the user to see the peak data coming in, etc.
*/
fill_color = UINT_RGBA_CHANGE_A (fill_color, 120);
break;
default:
fatal << string_compose (_("programming error: %1: %2"),
"AudioStreamView: impossible track mode",
(int) _trackview.audio_track()->mode()) << endmsg;
abort(); /*NOTREACHED*/
}
ArdourCanvas::Rectangle * rec_rect = new ArdourCanvas::TimeRectangle (_canvas_group);
rec_rect->set_x0 (xstart);
rec_rect->set_y0 (0);
rec_rect->set_x1 (xend);
rec_rect->set_y1 (child_height ());
rec_rect->set_outline_what (ArdourCanvas::Rectangle::What (0));
rec_rect->set_outline_color (ARDOUR_UI::config()->color ("time axis frame"));
rec_rect->set_fill_color (fill_color);
RecBoxInfo recbox;
recbox.rectangle = rec_rect;
if (rec_rects.empty()) {
recbox.start = _trackview.session()->record_location ();
} else {
recbox.start = _trackview.session()->transport_frame ();
}
recbox.length = 0;
rec_rects.push_back (recbox);
screen_update_connection.disconnect();
screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (
sigc::mem_fun (*this, &AudioStreamView::update_rec_box));
rec_updating = true;
rec_active = true;
create_rec_box(frame_pos, width);
} else if (rec_active &&
(_trackview.session()->record_status() != Session::Recording ||

View File

@ -497,6 +497,7 @@
<Modifier name="panner fill" modifier="= alpha:0.7882"/>
<Modifier name="piano roll black" modifier="= alpha:0.331098"/>
<Modifier name="piano roll white" modifier="= alpha:0.4627"/>
<Modifier name="recording rect" modifier="= alpha:0.25"/>
<Modifier name="region base" modifier="= alpha:0.99"/>
<Modifier name="selected midi note" modifier="= alpha:0.7529"/>
<Modifier name="selection rect" modifier="= alpha:0.4666"/>

View File

@ -1559,7 +1559,8 @@ MidiRegionView::extend_active_notes()
for (unsigned i=0; i < 128; ++i) {
if (_active_notes[i]) {
_active_notes[i]->set_x1 (trackview.editor().sample_to_pixel(_region->length()));
_active_notes[i]->set_x1(
trackview.editor().sample_to_pixel(_region->position() + _region->length()));
}
}
}
@ -3781,8 +3782,6 @@ MidiRegionView::data_recorded (boost::weak_ptr<MidiSource> w)
boost::shared_ptr<MidiBuffer> buf = mtv->midi_track()->get_gui_feed_buffer ();
BeatsFramesConverter converter (trackview.session()->tempo_map(), mtv->midi_track()->get_capture_start_frame (0));
framepos_t back = max_framepos;
for (MidiBuffer::iterator i = buf->begin(); i != buf->end(); ++i) {
@ -3796,12 +3795,8 @@ MidiRegionView::data_recorded (boost::weak_ptr<MidiSource> w)
}
}
/* ev.time() is in session frames, so (ev.time() - converter.origin_b()) is
frames from the start of the source, and so time_beats is in terms of the
source.
*/
Evoral::MusicalTime const time_beats = converter.from (ev.time () - converter.origin_b ());
/* convert from session frames to source beats */
Evoral::MusicalTime const time_beats = _source_relative_time_converter.from(ev.time());
if (ev.type() == MIDI_CMD_NOTE_ON) {
boost::shared_ptr<NoteType> note (

View File

@ -497,12 +497,12 @@ MidiStreamView::setup_rec_box ()
if (region) {
region->set_start (_trackview.track()->current_capture_start()
- _trackview.track()->get_capture_start_frame (0));
region->set_position (_trackview.track()->current_capture_start());
region->set_position (_trackview.session()->transport_frame());
RegionView* rv = add_region_view_internal (region, false, true);
MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (rv);
mrv->begin_write ();
/* rec region will be destroyed in setup_rec_box */
rec_regions.push_back (make_pair (region, rv));
@ -515,32 +515,7 @@ MidiStreamView::setup_rec_box ()
/* start a new rec box */
boost::shared_ptr<MidiTrack> mt = _trackview.midi_track(); /* we know what it is already */
framepos_t const frame_pos = mt->current_capture_start ();
gdouble const xstart = _trackview.editor().sample_to_pixel (frame_pos);
gdouble const xend = xstart;
uint32_t fill_color;
fill_color = ARDOUR_UI::config()->color ("recording rect");
ArdourCanvas::Rectangle * rec_rect = new ArdourCanvas::Rectangle (_canvas_group);
rec_rect->set (ArdourCanvas::Rect (xstart, 1, xend, _trackview.current_height() - 1));
rec_rect->set_outline_color (ARDOUR_UI::config()->color ("recording rect"));
rec_rect->set_fill_color (fill_color);
rec_rect->lower_to_bottom();
RecBoxInfo recbox;
recbox.rectangle = rec_rect;
recbox.start = _trackview.session()->transport_frame();
recbox.length = 0;
rec_rects.push_back (recbox);
screen_update_connection.disconnect();
screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (
sigc::mem_fun (*this, &MidiStreamView::update_rec_box));
rec_updating = true;
rec_active = true;
create_rec_box(_trackview.midi_track()->current_capture_start(), 0);
} else if (rec_active &&
(_trackview.session()->record_status() != Session::Recording ||
@ -559,7 +534,6 @@ MidiStreamView::setup_rec_box ()
/* disconnect rapid update */
screen_update_connection.disconnect();
rec_data_ready_connections.drop_connections ();
rec_updating = false;
rec_active = false;

View File

@ -105,10 +105,12 @@ class MidiStreamView : public StreamView
void suspend_updates ();
void resume_updates ();
private:
protected:
void setup_rec_box ();
void update_rec_box ();
private:
RegionView* add_region_view_internal (
boost::shared_ptr<ARDOUR::Region>,
bool wait_for_waves,

View File

@ -404,6 +404,43 @@ StreamView::transport_looped()
Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&StreamView::setup_rec_box, this));
}
void
StreamView::create_rec_box(framepos_t frame_pos, double width)
{
const double xstart = _trackview.editor().sample_to_pixel(frame_pos);
const double xend = xstart + width;
const uint32_t fill_color = ARDOUR_UI::config()->color_mod("recording rect", "recording_rect");
ArdourCanvas::Rectangle* rec_rect = new ArdourCanvas::TimeRectangle(_canvas_group);
rec_rect->set_x0(xstart);
rec_rect->set_y0(0);
rec_rect->set_x1(xend);
rec_rect->set_y1(child_height ());
rec_rect->set_outline_what(ArdourCanvas::Rectangle::What(0));
rec_rect->set_outline_color(ARDOUR_UI::config()->color("recording rect"));
rec_rect->set_fill_color(fill_color);
rec_rect->lower_to_bottom();
RecBoxInfo recbox;
recbox.rectangle = rec_rect;
recbox.length = 0;
if (rec_rects.empty()) {
recbox.start = _trackview.session()->record_location ();
} else {
recbox.start = _trackview.session()->transport_frame ();
}
rec_rects.push_back (recbox);
screen_update_connection.disconnect();
screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect(
sigc::mem_fun(*this, &StreamView::update_rec_box));
rec_updating = true;
rec_active = true;
}
void
StreamView::update_rec_box ()
{

View File

@ -134,6 +134,7 @@ protected:
void transport_looped();
void rec_enable_changed();
void sess_rec_enable_changed();
void create_rec_box(framepos_t frame_pos, double width);
virtual void setup_rec_box () = 0;
virtual void update_rec_box ();