Ardour  9.0-pre0-1467-gc8540a5ad6
pianoroll.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 "pbd/timer.h"
24 
25 #include <ytkmm/adjustment.h>
26 
27 #include "canvas/ruler.h"
28 #include "widgets/eventboxext.h"
29 
30 #include "cue_editor.h"
31 
32 namespace Gtk {
33  class Widget;
34  class HScrollbar;
35 }
36 
37 namespace ArdourCanvas {
38  class Box;
39  class Canvas;
40  class Container;
41  class GtkCanvasViewport;
42  class PianoRollHeader;
43  class ScrollGroup;
44  class Widget;
45 }
46 
47 namespace ArdourWidgets {
48  class ArdourButton;
49  class MetaButton;
50 }
51 
52 class PianorollMidiView;
54 
55 class Pianoroll : public CueEditor
56 {
57  public:
58  Pianoroll (std::string const & name, bool with_transport_controls = false);
60 
62 
64 
65  void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<std::shared_ptr<Evoral::Note<Temporal::Beats> > > > >&) const {}
66 
69 
77 
78  int32_t get_grid_beat_divisions (Editing::GridType gt) const { return 1; }
79  int32_t get_grid_music_divisions (Editing::GridType gt, uint32_t event_state) const { return 1; }
80 
82  void set_region (std::shared_ptr<ARDOUR::Region>);
83  void set_track (std::shared_ptr<ARDOUR::Track>);
84 
85  double max_extents_scale() const { return 1.2; }
87 
88  void set_mouse_mode (Editing::MouseMode, bool force = false);
89 
90  void midi_action (void (MidiView::*method)());
91 
92  std::list<SelectableOwner*> selectable_owners();
93  void select_all_within (Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list<SelectableOwner*> const &, ARDOUR::SelectionOperation, bool);
94 
97  Gdk::Cursor* which_trim_cursor (bool left_side) const;
99 
100  void set_visible_channel (int chan);
101  int visible_channel () const { return _visible_channel; }
102 
106 
111 
112  void delete_ ();
113  void paste (float times, bool from_context_menu);
114  void keyboard_paste ();
116 
117  PianorollMidiView* midi_view() const { return view; }
119  bool allow_trim_cursors () const;
120 
121  void shift_midi (Temporal::timepos_t const &, bool model);
123 
125 
126  void set_show_source (bool);
127 
128  protected:
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 
150  void escape ();
151 
152  private:
157 
166 
167  typedef std::map<ArdourWidgets::ArdourButton*,Evoral::Parameter> ParameterButtonMap;
170 
173 
174  void build_canvas ();
177 
179 
181  {
182  public:
183  BBTMetric (Pianoroll& ec) : context (&ec) {}
184 
185  void get_marks (std::vector<ArdourCanvas::Ruler::Mark>& marks, int64_t lower, int64_t upper, int maxchars) const {
186  context->metric_get_bbt (marks, lower, upper, maxchars);
187  }
188 
189  private:
191  };
192 
194 
196  void maybe_update ();
199 
200  void unset (bool trigger_too);
201 
203 
205 
211 
213 
215  sigc::signal<void> NoteModeChanged;
216 
218 
220 
222  void add_multi_controller_item (Gtk::Menu_Helpers::MenuList& ctl_items, uint16_t channels, int ctl, const std::string& name, ArdourWidgets::MetaButton*);
224 
227 
229 
232 
235 
236  void set_note_selection (uint8_t note);
237  void add_note_selection (uint8_t note);
238  void extend_note_selection (uint8_t note);
239  void toggle_note_selection (uint8_t note);
240 
243 
244  void begin_write ();
245  void end_write ();
246 
248 
249  void show_count_in (std::string const &);
250  void hide_count_in ();
251 
252  void instant_save ();
253 };
void metric_get_bbt(std::vector< ArdourCanvas::Ruler::Mark > &, samplepos_t, samplepos_t, gint)
bool with_transport_controls
Definition: cue_editor.h:149
Definition: id.h:34
Pianoroll * context
Definition: pianoroll.h:190
void get_marks(std::vector< ArdourCanvas::Ruler::Mark > &marks, int64_t lower, int64_t upper, int maxchars) const
Definition: pianoroll.h:185
BBTMetric(Pianoroll &ec)
Definition: pianoroll.h:183
void region_prop_change(PBD::PropertyChange const &)
void build_lower_toolbar()
bool leave_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
void set_trigger_bounds(Temporal::timepos_t const &, Temporal::timepos_t const &)
void select_all_within(Temporal::timepos_t const &, Temporal::timepos_t const &, double, double, std::list< SelectableOwner * > const &, ARDOUR::SelectionOperation, bool)
void add_multi_controller_item(Gtk::Menu_Helpers::MenuList &ctl_items, uint16_t channels, int ctl, const std::string &name, ArdourWidgets::MetaButton *)
ArdourWidgets::MetaButton * cc_dropdown1
Definition: pianoroll.h:163
sigc::signal< void > NoteModeChanged
Definition: pianoroll.h:215
PBD::ScopedConnectionList view_connections
Definition: pianoroll.h:195
void add_single_controller_item(Gtk::Menu_Helpers::MenuList &ctl_items, int ctl, const std::string &name, ArdourWidgets::MetaButton *)
ARDOUR::InstrumentInfo * instrument_info() const
void set_note_selection(uint8_t note)
int visible_channel() const
Definition: pianoroll.h:101
bool button_release_dispatch(GdkEventButton *)
void update_rulers()
Definition: pianoroll.h:231
void set_trigger_start(Temporal::timepos_t const &)
void keyboard_paste()
void trigger_prop_change(PBD::PropertyChange const &)
void update_tempo_based_rulers()
void rebuild_parameter_button_map()
void extend_note_selection(uint8_t note)
std::list< SelectableOwner * > selectable_owners()
Gtk::Menu _region_context_menu
Definition: pianoroll.h:233
void canvas_allocate(Gtk::Allocation)
Gtk::Widget & contents()
void delete_()
Gdk::Cursor * which_track_cursor() const
void set_mouse_mode(Editing::MouseMode, bool force=false)
void map_transport_state()
void snap_to_internal(Temporal::timepos_t &first, Temporal::RoundMode direction=Temporal::RoundNearest, ARDOUR::SnapPref gpref=ARDOUR::SnapToAny_Visual, bool ensure_snap=false) const
bool canvas_cue_start_event(GdkEvent *event, ArdourCanvas::Item *)
bool user_automation_button_event(GdkEventButton *ev, ArdourWidgets::MetaButton *mb)
bool canvas_enter_leave(GdkEventCrossing *ev)
Gdk::Cursor * which_trim_cursor(bool left_side) const
bool button_press_handler_2(ArdourCanvas::Item *, GdkEvent *, ItemType)
bool button_release_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
void manage_possible_header(Gtk::Allocation &alloc)
void midi_action(void(MidiView::*method)())
void set_track(std::shared_ptr< ARDOUR::Track >)
bool ignore_channel_changes
Definition: pianoroll.h:225
void toggle_note_selection(uint8_t note)
void begin_write()
ArdourWidgets::ArdourButton * bender_button
Definition: pianoroll.h:159
void point_selection_changed()
void set_region(std::shared_ptr< ARDOUR::Region >)
bool button_press_handler_1(ArdourCanvas::Item *, GdkEvent *, ItemType)
void set_trigger_end(Temporal::timepos_t const &)
bool canvas_bg_event(GdkEvent *event, ArdourCanvas::Item *)
void popup_region_context_menu(ArdourCanvas::Item *item, GdkEvent *event)
Gdk::Cursor * which_mode_cursor() const
void build_canvas()
void pack_inner(Gtk::Box &)
bool canvas_velocity_event(GdkEvent *event, ArdourCanvas::Item *)
PianorollMidiBackground * bg
Definition: pianoroll.h:171
void maybe_update()
ArdourWidgets::ArdourButton * velocity_button
Definition: pianoroll.h:158
ArdourCanvas::Rectangle * meter_bar
Definition: pianoroll.h:155
void note_mode_clicked()
BBTMetric bbt_metric
Definition: pianoroll.h:193
bool canvas_note_event(GdkEvent *event, ArdourCanvas::Item *)
double max_extents_scale() const
Definition: pianoroll.h:85
bool allow_trim_cursors() const
bool canvas_velocity_base_event(GdkEvent *event, ArdourCanvas::Item *)
void shift_midi(Temporal::timepos_t const &, bool model)
bool button_press_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
void get_per_region_note_selection(std::list< std::pair< PBD::ID, std::set< std::shared_ptr< Evoral::Note< Temporal::Beats > > > > > &) const
Definition: pianoroll.h:65
Temporal::timepos_t snap_to_grid(Temporal::timepos_t const &start, Temporal::RoundMode direction, ARDOUR::SnapPref gpref) const
ArdourCanvas::PianoRollHeader * prh
Definition: pianoroll.h:156
PianorollMidiView * midi_view() const
Definition: pianoroll.h:117
ArdourWidgets::MetaButton * cc_dropdown2
Definition: pianoroll.h:164
bool motion_handler(ArdourCanvas::Item *, GdkEvent *, bool from_autoscroll=false)
void automation_state_changed()
bool canvas_control_point_event(GdkEvent *event, ArdourCanvas::Item *, ControlPoint *)
void make_a_region()
int32_t get_grid_beat_divisions(Editing::GridType gt) const
Definition: pianoroll.h:78
void set_samples_per_pixel(samplecnt_t)
void bindings_changed()
void set_visible_channel(int chan)
ArdourWidgets::ArdourButton * expression_button
Definition: pianoroll.h:161
void unset(bool trigger_too)
void end_write()
void set_show_source(bool)
bool idle_data_captured()
void pack_outer(Gtk::Box &)
void instant_save()
ArdourCanvas::Ruler * bbt_ruler
Definition: pianoroll.h:153
void set_trigger(ARDOUR::TriggerReference &)
ArdourWidgets::MetaButton * cc_dropdown3
Definition: pianoroll.h:165
Temporal::Beats get_draw_length_as_beats(bool &success, Temporal::timepos_t const &position) const
bool enter_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
int _visible_channel
Definition: pianoroll.h:212
ArdourWidgets::ArdourButton * pressure_button
Definition: pianoroll.h:160
Temporal::Beats get_grid_type_as_beats(bool &success, Temporal::timepos_t const &position) const
Gdk::Cursor * which_canvas_cursor(ItemType type) const
bool key_release_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
void visible_channel_changed()
void set_note_mode(ARDOUR::NoteMode)
void cut_copy(Editing::CutCopyOp)
samplecnt_t current_page_samples() const
std::map< ArdourWidgets::ArdourButton *, Evoral::Parameter > ParameterButtonMap
Definition: pianoroll.h:167
void escape()
ARDOUR::NoteMode note_mode() const
Definition: pianoroll.h:104
ArdourCanvas::Rectangle * tempo_bar
Definition: pianoroll.h:154
Pianoroll(std::string const &name, bool with_transport_controls=false)
void show_count_in(std::string const &)
int32_t get_grid_music_divisions(Editing::GridType gt, uint32_t event_state) const
Definition: pianoroll.h:79
PianorollMidiView * view
Definition: pianoroll.h:172
ParameterButtonMap parameter_button_map
Definition: pianoroll.h:168
void reset_user_cc_choice(std::string, Evoral::Parameter param, ArdourWidgets::MetaButton *)
void user_led_click(GdkEventButton *ev, ArdourWidgets::MetaButton *metabutton)
void hide_count_in()
bool key_press_handler(ArdourCanvas::Item *, GdkEvent *, ItemType)
ArdourWidgets::ArdourButton * modulation_button
Definition: pianoroll.h:162
bool canvas_cue_end_event(GdkEvent *event, ArdourCanvas::Item *)
void set_trigger_length(Temporal::timecnt_t const &)
void paste(float times, bool from_context_menu)
void automation_led_click(GdkEventButton *, Evoral::ParameterType type, int id)
bool button_press_dispatch(GdkEventButton *)
void add_note_selection(uint8_t note)
bool automation_button_event(GdkEventButton *, Evoral::ParameterType type, int id)
bool automation_button_click(Evoral::ParameterType type, int id, ARDOUR::SelectionOperation)
void set_session(ARDOUR::Session *)
ARDOUR::NoteMode _note_mode
Definition: pianoroll.h:214
ItemType
Definition: editor_items.h:24
GtkImageIconNameData name
Definition: gtkimage.h:6
PBD::PropertyDescriptor< timepos_t > start
Temporal::samplecnt_t samplecnt_t
CutCopyOp
Definition: editing.h:228
GridType
Definition: editing.h:52
MouseMode
Definition: editing.h:98
uint32_t ParameterType
Definition: ardour_ui.h:192
@ RoundNearest
Round to nearest.