X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fmidi_region_view.h;h=7280ba6e4eb1bfd2780c6f8991bb2d63d2624cf1;hb=5fef65538040fbac1b9edd1847a269aa925a49c9;hp=5a5c74cb2ca5c5ea9f067edae35f47ee8a73b38f;hpb=e279b9892b467aa823e253d97b6e9504cca0e252;p=ardour.git diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 5a5c74cb2c..7280ba6e4e 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -21,7 +21,7 @@ #include #include - +#include #include "pbd/signals.h" @@ -60,6 +60,7 @@ class MidiListEditor; class EditNoteDialog; class NotePlayer; class PatchChange; +class ItemCounts; class MidiRegionView : public RegionView { @@ -67,18 +68,27 @@ public: typedef Evoral::Note NoteType; typedef Evoral::Sequence::Notes Notes; - MidiRegionView (ArdourCanvas::Group *, - RouteTimeAxisView&, - boost::shared_ptr, - double initial_samples_per_pixel, - Gdk::Color const & basic_color); + MidiRegionView (ArdourCanvas::Container* parent, + RouteTimeAxisView& tv, + boost::shared_ptr r, + double samples_per_pixel, + uint32_t basic_color); + + MidiRegionView (ArdourCanvas::Container* parent, + RouteTimeAxisView& tv, + boost::shared_ptr r, + double samples_per_pixel, + uint32_t basic_color, + bool recording, + Visibility visibility); + MidiRegionView (const MidiRegionView& other); MidiRegionView (const MidiRegionView& other, boost::shared_ptr); ~MidiRegionView (); - virtual void init (Gdk::Color const & basic_color, bool wfd); + void init (bool wfd); const boost::shared_ptr midi_region() const; @@ -109,10 +119,11 @@ public: GhostRegion* add_ghost (TimeAxisView&); void add_note(const boost::shared_ptr 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); @@ -122,7 +133,7 @@ public: * @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 */ @@ -142,16 +153,11 @@ public: 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. */ @@ -256,29 +262,37 @@ public: 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 (); @@ -299,23 +313,19 @@ public: 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, - double samples_per_pixel, - Gdk::Color& basic_color, - TimeAxisViewItem::Visibility); - void region_resized (const PBD::PropertyChange&); void set_flags (XMLNode *); @@ -366,7 +376,7 @@ private: 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*); @@ -377,31 +387,33 @@ private: uint8_t _current_range_min; uint8_t _current_range_max; - - typedef std::list Events; + + typedef std::list Events; typedef std::vector< boost::shared_ptr > PatchChanges; - typedef std::vector< boost::shared_ptr > SysExes; + typedef std::vector< boost::shared_ptr > SysExes; + + ARDOUR::BeatsFramesConverter _region_relative_time_converter; + ARDOUR::BeatsFramesConverter _source_relative_time_converter; boost::shared_ptr _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; @@ -431,7 +443,7 @@ private: 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); @@ -462,10 +474,18 @@ private: void connect_to_diskstream (); void data_recorded (boost::weak_ptr); + /** 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; @@ -473,6 +493,7 @@ private: Gdk::Cursor* pre_enter_cursor; Gdk::Cursor* pre_press_cursor; + Gdk::Cursor* pre_note_enter_cursor; NotePlayer* _note_player;