#include <string>
#include <vector>
-
+#include <stdint.h>
#include "pbd/signals.h"
class EditNoteDialog;
class NotePlayer;
class PatchChange;
+class ItemCounts;
class MidiRegionView : public RegionView
{
typedef Evoral::Note<Evoral::MusicalTime> NoteType;
typedef Evoral::Sequence<Evoral::MusicalTime>::Notes Notes;
- MidiRegionView (ArdourCanvas::Group *,
- RouteTimeAxisView&,
- boost::shared_ptr<ARDOUR::MidiRegion>,
- double initial_samples_per_pixel,
- Gdk::Color const & basic_color);
+ MidiRegionView (ArdourCanvas::Container* parent,
+ RouteTimeAxisView& tv,
+ boost::shared_ptr<ARDOUR::MidiRegion> r,
+ double samples_per_pixel,
+ uint32_t basic_color);
+
+ MidiRegionView (ArdourCanvas::Container* parent,
+ RouteTimeAxisView& tv,
+ boost::shared_ptr<ARDOUR::MidiRegion> r,
+ double samples_per_pixel,
+ uint32_t basic_color,
+ bool recording,
+ Visibility visibility);
+
MidiRegionView (const MidiRegionView& other);
MidiRegionView (const MidiRegionView& other, boost::shared_ptr<ARDOUR::MidiRegion>);
~MidiRegionView ();
- virtual void init (Gdk::Color const & basic_color, bool wfd);
+ void init (bool wfd);
const boost::shared_ptr<ARDOUR::MidiRegion> midi_region() const;
GhostRegion* add_ghost (TimeAxisView&);
void add_note(const boost::shared_ptr<NoteType> note, bool visible);
- void resolve_note(uint8_t note_num, double end_time);
+ void resolve_note(uint8_t note_num, Evoral::MusicalTime end_time);
void cut_copy_clear (Editing::CutCopyOp);
- void paste (framepos_t pos, float times, const MidiCutBuffer&);
+ bool paste (framepos_t pos, const ::Selection& selection, PasteContext& ctx);
+ void paste_internal (framepos_t pos, unsigned paste_count, float times, const MidiCutBuffer&);
void add_canvas_patch_change (ARDOUR::MidiModel::PatchChangePtr patch, const std::string& displaytext, bool);
* @key a reference to an instance of MIDI::Name::PatchPrimaryKey whose fields will
* will be set according to the result of the lookup
*/
- void get_patch_key_at (double time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const;
+ void get_patch_key_at (Evoral::MusicalTime time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key) const;
/** Convert a given PatchChange into a PatchPrimaryKey
*/
void delete_sysex (SysEx*);
- /** Alter a given patch to be its predecessor in the MIDNAM file.
- */
- void previous_patch (PatchChange &);
-
- /** Alters a given patch to be its successor in the MIDNAM file.
+ /** Change a patch to the next or previous bank/program.
+ * @param bank If true, step bank, otherwise, step program.
+ * @param delta Amount to adjust number.
*/
- void next_patch (PatchChange &);
-
- void previous_bank (PatchChange &);
- void next_bank (PatchChange &);
+ void step_patch (PatchChange& patch, bool bank, int delta);
/** Displays all patch change events in the region as flags on the canvas.
*/
framepos_t snap_pixel_to_sample(double x);
/** Convert a timestamp in beats into frames (both relative to region position) */
- framepos_t region_beats_to_region_frames(double beats) const;
+ framepos_t region_beats_to_region_frames(Evoral::MusicalTime beats) const;
/** Convert a timestamp in beats into absolute frames */
- framepos_t region_beats_to_absolute_frames(double beats) const {
+ framepos_t region_beats_to_absolute_frames(Evoral::MusicalTime beats) const {
return _region->position() + region_beats_to_region_frames (beats);
}
/** Convert a timestamp in frames to beats (both relative to region position) */
- double region_frames_to_region_beats(framepos_t) const;
+ Evoral::MusicalTime region_frames_to_region_beats(framepos_t) const;
/** Convert a timestamp in beats measured from source start into absolute frames */
- framepos_t source_beats_to_absolute_frames(double beats) const;
+ framepos_t source_beats_to_absolute_frames(Evoral::MusicalTime beats) const;
/** Convert a timestamp in beats measured from source start into region-relative frames */
- framepos_t source_beats_to_region_frames(double beats) const {
+ framepos_t source_beats_to_region_frames(Evoral::MusicalTime beats) const {
return source_beats_to_absolute_frames (beats) - _region->position();
}
/** Convert a timestamp in absolute frames to beats measured from source start*/
- double absolute_frames_to_source_beats(framepos_t) const;
+ Evoral::MusicalTime absolute_frames_to_source_beats(framepos_t) const;
+
+ ARDOUR::BeatsFramesConverter const & region_relative_time_converter () const {
+ return _region_relative_time_converter;
+ }
+
+ ARDOUR::BeatsFramesConverter const & source_relative_time_converter () const {
+ return _source_relative_time_converter;
+ }
void goto_previous_note (bool add_to_selection);
void goto_next_note (bool add_to_selection);
void change_note_lengths (bool, bool, Evoral::MusicalTime beats, bool start, bool end);
void change_velocities (bool up, bool fine, bool allow_smush, bool all_together);
void transpose (bool up, bool fine, bool allow_smush);
- void nudge_notes (bool forward);
+ void nudge_notes (bool forward, bool fine);
void channel_edit ();
void velocity_edit ();
void trim_front_starting ();
void trim_front_ending ();
- void create_note_at (framepos_t, double, double, bool);
+ /** Add a note to the model, and the view, at a canvas (click) coordinate.
+ * \param t time in frames relative to the position of the region
+ * \param y vertical position in pixels
+ * \param length duration of the note in beats
+ * \param snap_t true to snap t to the grid, otherwise false.
+ */
+ void create_note_at (framepos_t t, double y, Evoral::MusicalTime length, bool snap_t);
void clear_selection (bool signal = true) { clear_selection_except (0, signal); }
ARDOUR::InstrumentInfo& instrument_info() const;
protected:
- /** Allows derived types to specify their visibility requirements
- * to the TimeAxisViewItem parent class.
- */
- MidiRegionView (ArdourCanvas::Group *,
- RouteTimeAxisView&,
- boost::shared_ptr<ARDOUR::MidiRegion>,
- double samples_per_pixel,
- Gdk::Color& basic_color,
- TimeAxisViewItem::Visibility);
-
void region_resized (const PBD::PropertyChange&);
void set_flags (XMLNode *);
ARDOUR::MidiModel::TimeType end_delta);
void clear_selection_except (NoteBase* ev, bool signal = true);
- void update_drag_selection (double last_x, double x, double last_y, double y, bool extend);
+ void update_drag_selection (framepos_t start, framepos_t end, double y0, double y1, bool extend);
void update_vertical_drag_selection (double last_y, double y, bool extend);
void add_to_selection (NoteBase*);
uint8_t _current_range_min;
uint8_t _current_range_max;
-
- typedef std::list<NoteBase*> Events;
+
+ typedef std::list<NoteBase*> Events;
typedef std::vector< boost::shared_ptr<PatchChange> > PatchChanges;
- typedef std::vector< boost::shared_ptr<SysEx> > SysExes;
+ typedef std::vector< boost::shared_ptr<SysEx> > SysExes;
+
+ ARDOUR::BeatsFramesConverter _region_relative_time_converter;
+ ARDOUR::BeatsFramesConverter _source_relative_time_converter;
boost::shared_ptr<ARDOUR::MidiModel> _model;
Events _events;
PatchChanges _patch_changes;
SysExes _sys_exes;
Note** _active_notes;
- ArdourCanvas::Group* _note_group;
+ ArdourCanvas::Container* _note_group;
ARDOUR::MidiModel::NoteDiffCommand* _note_diff_command;
Note* _ghost_note;
double _last_ghost_x;
double _last_ghost_y;
- ArdourCanvas::Rectangle* _step_edit_cursor;
+ ArdourCanvas::Rectangle* _step_edit_cursor;
Evoral::MusicalTime _step_edit_cursor_width;
Evoral::MusicalTime _step_edit_cursor_position;
- NoteBase* _channel_selection_scoped_note;
-
+ NoteBase* _channel_selection_scoped_note;
/** A group used to temporarily reparent _note_group to during start trims, so
* that the notes don't move with the parent region view.
*/
- ArdourCanvas::Group* _temporary_note_group;
+ ArdourCanvas::Container* _temporary_note_group;
MouseState _mouse_state;
int _pressed_button;
Events::iterator _optimization_iterator;
void update_note (Note *, bool update_ghost_regions = true);
- double update_hit (Hit *);
+ void update_hit (Hit *);
void create_ghost_note (double, double);
void update_ghost_note (double, double);
void connect_to_diskstream ();
void data_recorded (boost::weak_ptr<ARDOUR::MidiSource>);
+ /** Get grid type as beats, or default to 1 if not snapped to beats. */
+ Evoral::MusicalTime get_grid_beats(framepos_t pos) const;
+
void remove_ghost_note ();
void mouse_mode_changed ();
+ void enter_internal ();
+ void leave_internal ();
+
double _last_event_x;
double _last_event_y;
+ bool _grabbed_keyboard;
+ bool _entered;
framepos_t snap_frame_to_grid_underneath (framepos_t p, framecnt_t &) const;
Gdk::Cursor* pre_enter_cursor;
Gdk::Cursor* pre_press_cursor;
+ Gdk::Cursor* pre_note_enter_cursor;
NotePlayer* _note_player;