#include "midi_time_axis.h"
#include "midi_util.h"
#include "public_editor.h"
+#include "rgb_macros.h"
#include "selection.h"
#include "simpleline.h"
#include "streamview.h"
, _diff_command(0)
, _ghost_note(0)
, _drag_rect (0)
+ , _step_edit_cursor (0)
+ , _step_edit_cursor_width (1.0)
+ , _step_edit_cursor_position (0.0)
, _mouse_state(None)
, _pressed_button(0)
, _sort_needed (true)
bool shorter = Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier);
bool fine = Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier);
- change_note_lengths (fine, shorter, start, end);
+ change_note_lengths (fine, shorter, 0.0, start, end);
return true;
} else if (ev->keyval == GDK_Control_L) {
return true;
-
- } else if (ev->keyval == GDK_r) {
- /* yes, this steals r */
- if (midi_view()->midi_track()->step_editing()) {
- midi_view()->step_edit_rest ();
- return true;
- }
+
}
return false;
_selection.clear();
clear_events();
+
delete _note_group;
delete _diff_command;
+ delete _step_edit_cursor;
}
void
if (_enable_display) {
redisplay_model();
}
+
+ move_step_edit_cursor (_step_edit_cursor_position);
+ set_step_edit_cursor_width (_step_edit_cursor_width);
}
void
if (name_pixbuf) {
name_pixbuf->raise_to_top();
}
+
+ for (PgmChanges::iterator x = _pgm_changes.begin(); x != _pgm_changes.end(); ++x) {
+ (*x)->set_height (midi_stream_view()->contents_height());
+ }
+
+ if (_step_edit_cursor) {
+ _step_edit_cursor->property_y2() = midi_stream_view()->contents_height();
+ }
}
void
MidiRegionView::step_add_note (uint8_t channel, uint8_t number, uint8_t velocity,
- Evoral::MusicalTime pos, Evoral::MusicalTime len)
+ Evoral::MusicalTime pos, Evoral::MusicalTime len)
{
boost::shared_ptr<NoteType> new_note (new NoteType (channel, pos, len, number, velocity));
nframes64_t region_end = _region->position() + _region->length() - 1;
if (end_frame > region_end) {
- _region->set_length (end_frame, this);
+ _region->set_length (end_frame - _region->position(), this);
}
+ _marked_for_selection.clear ();
+ clear_selection ();
+
start_diff_command (_("step add"));
diff_add_note (new_note, true, false);
apply_diff();
// last_step_edit_note = new_note;
}
+void
+MidiRegionView::step_sustain (Evoral::MusicalTime beats)
+{
+ change_note_lengths (false, false, beats, false, true);
+}
+
void
MidiRegionView::add_pgm_change(PCEvent& program, const string& displaytext)
{
}
void
-MidiRegionView::note_dropped(CanvasNoteEvent *, double dt, int8_t dnote)
+MidiRegionView::note_dropped(CanvasNoteEvent *, frameoffset_t dt, int8_t dnote)
{
assert (!_selection.empty());
for (Selection::iterator i = _selection.begin(); i != _selection.end() ; ++i) {
- nframes64_t start_frames = beats_to_frames((*i)->note()->time());
-
- if (dt >= 0) {
- start_frames += snap_frame_to_frame(trackview.editor().pixel_to_frame(dt));
- } else {
- start_frames -= snap_frame_to_frame(trackview.editor().pixel_to_frame(-dt));
- }
-
- Evoral::MusicalTime new_time = frames_to_beats(start_frames);
+ Evoral::MusicalTime new_time = frames_to_beats (beats_to_frames ((*i)->note()->time()) + dt);
if (new_time < 0) {
continue;
apply_diff();
}
+void
+MidiRegionView::change_note_channel (CanvasNoteEvent* event, int8_t channel)
+{
+ diff_add_change (event, MidiModel::DiffCommand::Channel, (uint8_t) channel);
+}
+
void
MidiRegionView::change_note_velocity(CanvasNoteEvent* event, int8_t velocity, bool relative)
{
diff_add_change (event, MidiModel::DiffCommand::StartTime, new_time);
}
+void
+MidiRegionView::change_note_length (CanvasNoteEvent* event, Evoral::MusicalTime t)
+{
+ diff_add_change (event, MidiModel::DiffCommand::Length, t);
+}
+
void
MidiRegionView::change_velocities (bool up, bool fine, bool allow_smush)
{
}
void
-MidiRegionView::change_note_lengths (bool fine, bool shorter, bool start, bool end)
+MidiRegionView::change_note_lengths (bool fine, bool shorter, Evoral::MusicalTime delta, bool start, bool end)
{
- Evoral::MusicalTime delta;
-
- if (fine) {
- delta = 1.0/128.0;
- } else {
- /* grab the current grid distance */
- bool success;
- delta = trackview.editor().get_grid_type_as_beats (success, _region->position());
- if (!success) {
- /* XXX cannot get grid type as beats ... should always be possible ... FIX ME */
- cerr << "Grid type not available as beats - TO BE FIXED\n";
- return;
- }
- }
+ if (delta == 0.0) {
+ if (fine) {
+ delta = 1.0/128.0;
+ } else {
+ /* grab the current grid distance */
+ bool success;
+ delta = trackview.editor().get_grid_type_as_beats (success, _region->position());
+ if (!success) {
+ /* XXX cannot get grid type as beats ... should always be possible ... FIX ME */
+ cerr << "Grid type not available as beats - TO BE FIXED\n";
+ return;
+ }
+ }
+ }
if (shorter) {
delta = -delta;
redisplay_model ();
}
}
+
+void
+MidiRegionView::show_step_edit_cursor (Evoral::MusicalTime pos)
+{
+ if (_step_edit_cursor == 0) {
+ ArdourCanvas::Group* const group = (ArdourCanvas::Group*)get_canvas_group();
+
+ _step_edit_cursor = new ArdourCanvas::SimpleRect (*group);
+ _step_edit_cursor->property_y1() = 0;
+ _step_edit_cursor->property_y2() = midi_stream_view()->contents_height();
+ _step_edit_cursor->property_fill_color_rgba() = RGBA_TO_UINT (45,0,0,90);
+ _step_edit_cursor->property_outline_color_rgba() = RGBA_TO_UINT (85,0,0,90);
+ }
+
+ move_step_edit_cursor (pos);
+ _step_edit_cursor->show ();
+}
+
+void
+MidiRegionView::move_step_edit_cursor (Evoral::MusicalTime pos)
+{
+ _step_edit_cursor_position = pos;
+
+ if (_step_edit_cursor) {
+ double pixel = trackview.editor().frame_to_pixel (beats_to_frames (pos));
+ _step_edit_cursor->property_x1() = pixel;
+ set_step_edit_cursor_width (_step_edit_cursor_width);
+ }
+}
+
+void
+MidiRegionView::hide_step_edit_cursor ()
+{
+ if (_step_edit_cursor) {
+ _step_edit_cursor->hide ();
+ }
+}
+
+void
+MidiRegionView::set_step_edit_cursor_width (Evoral::MusicalTime beats)
+{
+ _step_edit_cursor_width = beats;
+
+ if (_step_edit_cursor) {
+ _step_edit_cursor->property_x2() = _step_edit_cursor->property_x1() + trackview.editor().frame_to_pixel (beats_to_frames (beats));
+ }
+}
+