Remove internal edit mode and add "content" tool.
[ardour.git] / gtk2_ardour / midi_region_view.h
index 098361e9846ee7a74386c57d315ddd1023f52c98..7280ba6e4eb1bfd2780c6f8991bb2d63d2624cf1 100644 (file)
@@ -68,11 +68,20 @@ public:
        typedef Evoral::Note<Evoral::MusicalTime> NoteType;
        typedef Evoral::Sequence<Evoral::MusicalTime>::Notes Notes;
 
-       MidiRegionView (ArdourCanvas::Container *,
-                       RouteTimeAxisView&,
-                       boost::shared_ptr<ARDOUR::MidiRegion>,
-                       double initial_samples_per_pixel,
-                       uint32_t base_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>);
@@ -110,10 +119,10 @@ public:
        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);
-       bool paste (framepos_t pos, unsigned paste_count, float times, const ::Selection& selection, ItemCounts& counts);
+       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);
@@ -124,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
         */
@@ -144,16 +153,11 @@ public:
 
        void delete_sysex (SysEx*);
 
-       /** Alter a given patch to be its predecessor 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 previous_patch (PatchChange &);
-
-       /** Alters a given patch to be its successor in the MIDNAM file.
-        */
-       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.
         */
@@ -258,22 +262,22 @@ 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;
@@ -288,7 +292,7 @@ public:
        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 ();
 
@@ -309,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::Container *,
-                       RouteTimeAxisView&,
-                       boost::shared_ptr<ARDOUR::MidiRegion>,
-                       double samples_per_pixel,
-                       uint32_t basic_color,
-                       TimeAxisViewItem::Visibility);
-
        void region_resized (const PBD::PropertyChange&);
 
        void set_flags (XMLNode *);
@@ -479,8 +479,13 @@ private:
 
        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;