From 722d74c3efe56d370bcf1222a13c78c67f570294 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 14 Oct 2023 09:35:08 -0600 Subject: [PATCH] skeleton work for a MidiEditingContext, incomplete --- gtk2_ardour/editor.h | 11 ++-- gtk2_ardour/midi_editing_context.h | 100 +++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 gtk2_ardour/midi_editing_context.h diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index d2bc2bef57..946130a4b1 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -213,10 +213,10 @@ public: void step_mouse_mode (bool next); Editing::MouseMode current_mouse_mode () const { return mouse_mode; } Editing::MidiEditMode current_midi_edit_mode () const; - void remove_midi_note (ArdourCanvas::Item*, GdkEvent*); - bool internal_editing() const; + void remove_midi_note (ArdourCanvas::Item*, GdkEvent*); + void foreach_time_axis_view (sigc::slot); void add_to_idle_resize (TimeAxisView*, int32_t); @@ -450,11 +450,12 @@ public: double get_y_origin () const; void reset_x_origin (samplepos_t); - void reset_x_origin_to_follow_playhead (); void reset_y_origin (double); void reset_zoom (samplecnt_t); void reposition_and_zoom (samplepos_t, double); + void reset_x_origin_to_follow_playhead (); + Temporal::timepos_t get_preferred_edit_position (Editing::EditIgnoreOption = Editing::EDIT_IGNORE_NONE, bool use_context_click = false, bool from_outside_canvas = false); @@ -539,11 +540,11 @@ public: void maybe_autoscroll (bool, bool, bool); bool autoscroll_active() const; - Gdk::Cursor* get_canvas_cursor () const; - void set_current_trimmable (std::shared_ptr); void set_current_movable (std::shared_ptr); + Gdk::Cursor* get_canvas_cursor () const; + MouseCursors const* cursors () const { return _cursors; } diff --git a/gtk2_ardour/midi_editing_context.h b/gtk2_ardour/midi_editing_context.h new file mode 100644 index 0000000000..5ecbb65930 --- /dev/null +++ b/gtk2_ardour/midi_editing_context.h @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2005-2007 Doug McLain + * Copyright (C) 2005-2018 Paul Davis + * Copyright (C) 2005 Karsten Wiese + * Copyright (C) 2006-2009 Sampo Savolainen + * Copyright (C) 2006-2015 David Robillard + * Copyright (C) 2006-2017 Tim Mayberry + * Copyright (C) 2007-2012 Carl Hetherington + * Copyright (C) 2008-2011 Sakari Bergen + * Copyright (C) 2008 Hans Baier + * Copyright (C) 2013-2015 Colin Fletcher + * Copyright (C) 2013-2019 Robin Gareus + * Copyright (C) 2014-2017 Nick Mainsbridge + * Copyright (C) 2014-2019 Ben Loftis + * Copyright (C) 2015-2019 Damien Zammit + * Copyright (C) 2015 André Nusser + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __ardour_midi_editing_context_h__ +#define __ardour_midi_editing_context_h__ + + +class MidiEditingContext : public SessionHandlePtr, public PBD::ScopedConnectionList +{ +public: + MidiEditingContext (); + ~MidiEditingContext (); + + void set_session (ARDOUR::Session*); + + virtual samplepos_t pixel_to_sample_from_event (double pixel) const = 0; + virtual samplepos_t pixel_to_sample (double pixel) const = 0; + virtual double sample_to_pixel (samplepos_t sample) const = 0; + virtual double sample_to_pixel_unrounded (samplepos_t sample) const = 0; + virtual double time_to_pixel (Temporal::timepos_t const & pos) const = 0; + virtual double time_to_pixel_unrounded (Temporal::timepos_t const & pos) const = 0; + virtual double duration_to_pixels (Temporal::timecnt_t const & pos) const = 0; + virtual double duration_to_pixels_unrounded (Temporal::timecnt_t const & pos) const = 0; + + virtual Temporal::Beats get_grid_type_as_beats (bool& success, Temporal::timepos_t const & position) = 0; + virtual Temporal::Beats get_draw_length_as_beats (bool& success, Temporal::timepos_t const & position) = 0; + + virtual int32_t get_grid_beat_divisions (Editing::GridType gt) = 0; + virtual int32_t get_grid_music_divisions (Editing::GridType gt, uint32_t event_state) = 0; + + virtual void snap_to (Temporal::timepos_t & first, + Temporal::RoundMode direction = Temporal::RoundNearest, + ARDOUR::SnapPref pref = ARDOUR::SnapToAny_Visual, + bool ensure_snap = false) = 0; + + virtual void snap_to_with_modifier (Temporal::timepos_t & first, + GdkEvent const* ev, + Temporal::RoundMode direction = Temporal::RoundNearest, + ARDOUR::SnapPref gpref = ARDOUR::SnapToAny_Visual, + bool ensure_snap = false) = 0; + + virtual Temporal::timepos_t snap_to_bbt (Temporal::timepos_t const & start, + Temporal::RoundMode direction, + ARDOUR::SnapPref gpref) = 0; + + virtual double get_y_origin () const = 0; + virtual void reset_x_origin (samplepos_t) = 0; + virtual void reset_y_origin (double) = 0; + virtual void reset_zoom (samplecnt_t) = 0; + virtual void reposition_and_zoom (samplepos_t, double) = 0; + + virtual Selection& get_selection() const = 0; + + virtual void set_mouse_mode (Editing::MouseMode, bool force = false) = 0; + virtual void step_mouse_mode (bool next) = 0; + virtual Editing::MouseMode current_mouse_mode () const = 0; + virtual Editing::MidiEditMode current_midi_edit_mode () const = 0; + virtual bool internal_editing() const = 0; + + Gdk::Cursor* get_canvas_cursor () const; + + MouseCursors const* cursors () const { + return _cursors; + } + + VerboseCursor* verbose_cursor () const { + return _verbose_cursor; + } +}; + +#endif /* __ardour_midi_editing_context_h__ */