Ardour  9.0-pre0-582-g084a23a80d
midi_cue_editor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Paul Davis <paul@linuxaudiosystems.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #pragma once
20 
21 #include <map>
22 
23 #include <gtkmm/adjustment.h>
24 
25 #include "canvas/ruler.h"
26 
27 #include "cue_editor.h"
28 
29 namespace Gtk {
30  class Widget;
31 }
32 
33 namespace ArdourCanvas {
34  class Box;
35  class Canvas;
36  class Container;
37  class GtkCanvasViewport;
38  class PianoRollHeader;
39  class ScrollGroup;
40  class Widget;
41 }
42 
43 namespace ArdourWidgets {
44  class ArdourButton;
45 }
46 
47 class MidiCueView;
48 class CueMidiBackground;
49 
50 class MidiCueEditor : public CueEditor
51 {
52  public:
55 
60 
61  double visible_canvas_width() const { return _visible_canvas_width; }
63 
64  void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<std::shared_ptr<Evoral::Note<Temporal::Beats> > > > >&) const {}
65 
68 
75 
76  int32_t get_grid_beat_divisions (Editing::GridType gt) const { return 1; }
77  int32_t get_grid_music_divisions (Editing::GridType gt, uint32_t event_state) const { return 1; }
78 
80  void set_region (std::shared_ptr<ARDOUR::MidiRegion>);
81 
84 
86 
87  void set_mouse_mode (Editing::MouseMode, bool force = false);
88  void step_mouse_mode (bool next);
90  bool internal_editing() const;
91 
94 
96  size_t n_timebars;
97 
100 
101  int set_state (const XMLNode&, int version);
102  XMLNode& get_state () const;
103 
104  void maybe_autoscroll (bool, bool, bool);
105  bool autoscroll_active() const;
106 
107  void midi_action (void (MidiView::*method)());
108 
109  std::list<SelectableOwner*> selectable_owners();
110 
113  Gdk::Cursor* which_trim_cursor (bool left_side) const;
115 
116  void set_visible_channel (int chan);
120 
125 
126  protected:
128 
130  Temporal::RoundMode direction,
131  ARDOUR::SnapPref gpref) const;
132 
136  bool ensure_snap = false) const;
137 
144  bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false);
149 
151 
152  void escape ();
154 
155  private:
157  std::shared_ptr<ARDOUR::MidiTrack> _track;
160 
161  /* The group containing all other groups that are scrolled vertically
162  and horizontally.
163  */
165 
166  /* The group containing all other groups that are scrolled horizontally ONLY
167  */
170 
171  /* Scroll group for cursors, scrolled horizontally, above everything else
172  */
174 
183 
185 
187 
197 
198  typedef std::map<Evoral::Parameter,ArdourWidgets::ArdourButton*> ParameterButtonMap;
200 
203 
204  void build_canvas ();
208 
210 
212 
213  void metric_get_bbt (std::vector<ArdourCanvas::Ruler::Mark>&, samplepos_t, samplepos_t, gint);
214 
216  {
217  public:
218  BBTMetric (MidiCueEditor& ec) : context (&ec) {}
219 
220  void get_marks (std::vector<ArdourCanvas::Ruler::Mark>& marks, int64_t lower, int64_t upper, int maxchars) const {
221  context->metric_get_bbt (marks, lower, upper, maxchars);
222  }
223 
224  private:
226  };
227 
229 
231 
232  /* autoscrolling */
233 
235  void start_canvas_autoscroll (bool allow_horiz, bool allow_vert, const ArdourCanvas::Rect& boundary);
237 
238  sigc::connection _update_connection;
240  void maybe_update ();
242 
243  void unset ();
244 
247 
250  std::atomic<int> idle_update_queued;
253 
257 
259 
261  sigc::signal<void> NoteModeChanged;
262 
264 
265 };
266 
267 
double _visible_canvas_width
void get_marks(std::vector< ArdourCanvas::Ruler::Mark > &marks, int64_t lower, int64_t upper, int maxchars) const
BBTMetric(MidiCueEditor &ec)
Editing::MouseMode current_mouse_mode() const
ARDOUR::NoteMode note_mode() const
void maybe_autoscroll(bool, bool, bool)
void set_trigger_start(Temporal::timepos_t const &)
void data_captured(samplecnt_t)
std::list< SelectableOwner * > selectable_owners()
bool button_press_handler_1(ArdourCanvas::Item *, GdkEvent *, ItemType)
bool canvas_velocity_base_event(GdkEvent *event, ArdourCanvas::Item *)
ArdourCanvas::Container * time_line_group
bool motion_handler(ArdourCanvas::Item *, GdkEvent *, bool from_autoscroll=false)
ArdourCanvas::Rectangle * transport_loop_range_rect
void set_trigger_end(Temporal::timepos_t const &)
ArdourCanvas::GtkCanvasViewport * get_canvas_viewport() const
ArdourCanvas::Ruler * bbt_ruler
void register_actions()
ArdourWidgets::ArdourButton * expression_button
ArdourCanvas::Container * no_scroll_group
void visual_changer(const VisualChange &)
bool canvas_cue_start_event(GdkEvent *event, ArdourCanvas::Item *)
ArdourCanvas::ScrollGroup * h_scroll_group
void midi_action(void(MidiView::*method)())
void build_lower_toolbar()
void set_region(std::shared_ptr< ARDOUR::MidiRegion >)
void trigger_prop_change(PBD::PropertyChange const &)
Gtk::Widget & viewport()
ArdourWidgets::ArdourDropdown * cc_dropdown2
Temporal::Beats get_grid_type_as_beats(bool &success, Temporal::timepos_t const &position) const
ArdourCanvas::ScrollGroup * cursor_scroll_group
bool autoscroll_active() const
Gdk::Cursor * which_canvas_cursor(ItemType type) const
ARDOUR::TriggerReference ref
bool key_release_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
ArdourWidgets::ArdourDropdown * cc_dropdown3
Temporal::Beats get_draw_length_as_beats(bool &success, Temporal::timepos_t const &position) const
void bindings_changed()
ArdourCanvas::Container * get_noscroll_group() const
Temporal::timepos_t snap_to_grid(Temporal::timepos_t const &start, Temporal::RoundMode direction, ARDOUR::SnapPref gpref) const
samplecnt_t data_capture_duration
bool button_release_dispatch(GdkEventButton *)
void trigger_rec_enable_change(ARDOUR::Trigger const &)
bool automation_button_event(GdkEventButton *, Evoral::ParameterType type, int id)
bool autoscroll_canvas()
ArdourCanvas::ScrollGroup * get_cursor_scroll_group() const
bool button_press_dispatch(GdkEventButton *)
void box_rec_enable_change(ARDOUR::TriggerBox const &)
ArdourCanvas::ScrollGroup * v_scroll_group
void build_canvas()
ArdourCanvas::GtkCanvasViewport * _canvas_viewport
bool canvas_velocity_event(GdkEvent *event, ArdourCanvas::Item *)
void set(ARDOUR::TriggerReference &)
void set_visible_channel(int chan)
bool canvas_control_point_event(GdkEvent *event, ArdourCanvas::Item *, ControlPoint *)
ArdourCanvas::GtkCanvas * _canvas
RegionSelection region_selection()
bool button_release_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
void mouse_mode_toggled(Editing::MouseMode)
void step_mouse_mode(bool next)
bool internal_editing() const
std::shared_ptr< ARDOUR::MidiTrack > _track
ArdourWidgets::ArdourButton * velocity_button
void start_canvas_autoscroll(bool allow_horiz, bool allow_vert, const ArdourCanvas::Rect &boundary)
void note_mode_clicked()
Gdk::Cursor * which_track_cursor() const
ArdourCanvas::Rectangle * tempo_bar
ArdourCanvas::Rectangle * meter_bar
int set_state(const XMLNode &, int version)
void automation_state_changed()
Gtk::HBox button_bar
ArdourCanvas::ScrollGroup * hv_scroll_group
bool canvas_enter_leave(GdkEventCrossing *ev)
void set_samples_per_pixel(samplecnt_t)
CueMidiBackground * bg
sigc::connection _update_connection
std::map< Evoral::Parameter, ArdourWidgets::ArdourButton * > ParameterButtonMap
ParameterButtonMap parameter_button_map
Gtk::VBox _toolbox
ArdourCanvas::Container * get_trackview_group() const
void snap_to_internal(Temporal::timepos_t &first, Temporal::RoundMode direction=Temporal::RoundNearest, ARDOUR::SnapPref gpref=ARDOUR::SnapToAny_Visual, bool ensure_snap=false) const
void canvas_allocate(Gtk::Allocation)
Gtk::Widget & toolbox()
ArdourCanvas::ScrollGroup * get_hscroll_group() const
bool enter_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
sigc::signal< void > NoteModeChanged
MidiCueView * view
void maybe_update()
ArdourWidgets::ArdourButton * modulation_button
void on_samples_per_pixel_changed()
ARDOUR::NoteMode _note_mode
bool leave_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
ArdourCanvas::PianoRollHeader * prh
ArdourWidgets::ArdourButton * bender_button
PBD::ScopedConnectionList object_connections
void automation_led_click(GdkEventButton *, Evoral::ParameterType type, int id)
ArdourCanvas::Container * data_group
bool idle_data_captured()
void get_per_region_note_selection(std::list< std::pair< PBD::ID, std::set< std::shared_ptr< Evoral::Note< Temporal::Beats > > > > > &) const
double timebar_height
void set_note_mode(ARDOUR::NoteMode)
std::atomic< int > idle_update_queued
bool automation_button_click(Evoral::ParameterType type, int id, ARDOUR::SelectionOperation)
double visible_canvas_width() const
int32_t get_grid_music_divisions(Editing::GridType gt, uint32_t event_state) const
Gdk::Cursor * which_mode_cursor() const
BBTMetric bbt_metric
ArdourWidgets::ArdourDropdown * cc_dropdown1
void stop_canvas_autoscroll()
void set_trigger_bounds(Temporal::timepos_t const &, Temporal::timepos_t const &)
XMLNode & get_state() const
bool canvas_cue_end_event(GdkEvent *event, ArdourCanvas::Item *)
ArdourWidgets::ArdourButton * pressure_button
samplecnt_t current_page_samples() const
Gdk::Cursor * which_trim_cursor(bool left_side) const
bool button_press_handler_2(ArdourCanvas::Item *, GdkEvent *, ItemType)
int32_t get_grid_beat_divisions(Editing::GridType gt) const
void set_mouse_mode(Editing::MouseMode, bool force=false)
void metric_get_bbt(std::vector< ArdourCanvas::Ruler::Mark > &, samplepos_t, samplepos_t, gint)
bool key_press_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
bool canvas_pre_event(GdkEvent *)
void set_trigger_length(Temporal::timecnt_t const &)
ArdourCanvas::Container * global_rect_group
bool canvas_note_event(GdkEvent *event, ArdourCanvas::Item *)
ArdourCanvas::GtkCanvas * get_canvas() const
bool button_press_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
void build_upper_toolbar()
PBD::ScopedConnectionList capture_connections
Definition: id.h:34
Definition: xml++.h:114
ItemType
Definition: editor_items.h:24
PBD::PropertyDescriptor< timepos_t > start
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t
GridType
Definition: editing.h:52
MouseMode
Definition: editing.h:98
uint32_t ParameterType
Definition: ardour_ui.h:188
@ RoundNearest
Round to nearest.