2023-11-18 22:45:48 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2023 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2024-09-25 20:38:59 -04:00
|
|
|
#pragma once
|
2023-11-18 22:45:48 -05:00
|
|
|
|
|
|
|
#include <gtkmm/adjustment.h>
|
|
|
|
|
2024-02-01 23:24:20 -05:00
|
|
|
#include "canvas/ruler.h"
|
|
|
|
|
2023-11-18 22:45:48 -05:00
|
|
|
#include "cue_editor.h"
|
|
|
|
|
|
|
|
namespace Gtk {
|
|
|
|
class Widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace ArdourCanvas {
|
2024-02-13 14:22:49 -05:00
|
|
|
class Box;
|
2023-11-18 22:45:48 -05:00
|
|
|
class Canvas;
|
|
|
|
class Container;
|
|
|
|
class GtkCanvasViewport;
|
2024-02-07 15:13:40 -05:00
|
|
|
class PianoRollHeader;
|
2023-11-18 22:45:48 -05:00
|
|
|
class ScrollGroup;
|
2024-02-13 14:22:49 -05:00
|
|
|
class Widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace ArdourWidgets {
|
|
|
|
class ArdourButton;
|
2023-11-18 22:45:48 -05:00
|
|
|
}
|
|
|
|
|
2024-01-28 17:26:38 -05:00
|
|
|
class MidiCueView;
|
2024-01-08 16:35:15 -05:00
|
|
|
class CueMidiBackground;
|
|
|
|
|
2023-11-18 22:45:48 -05:00
|
|
|
class MidiCueEditor : public CueEditor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MidiCueEditor ();
|
|
|
|
~MidiCueEditor ();
|
|
|
|
|
2024-02-22 12:37:09 -05:00
|
|
|
ArdourCanvas::Container* get_trackview_group () const { return data_group; }
|
2023-11-18 22:45:48 -05:00
|
|
|
ArdourCanvas::Container* get_noscroll_group() const { return no_scroll_group; }
|
2024-01-08 16:35:15 -05:00
|
|
|
Gtk::Widget& viewport();
|
2024-02-13 14:22:49 -05:00
|
|
|
Gtk::Widget& toolbox ();
|
2023-11-18 22:45:48 -05:00
|
|
|
|
2023-11-19 22:43:29 -05:00
|
|
|
double visible_canvas_width() const { return _visible_canvas_width; }
|
|
|
|
samplecnt_t current_page_samples() const;
|
|
|
|
|
|
|
|
void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<std::shared_ptr<Evoral::Note<Temporal::Beats> > > > >&) const {}
|
|
|
|
|
2024-08-24 18:43:19 -04:00
|
|
|
Temporal::Beats get_grid_type_as_beats (bool& success, Temporal::timepos_t const & position) const;
|
|
|
|
Temporal::Beats get_draw_length_as_beats (bool& success, Temporal::timepos_t const & position) const;
|
2023-11-19 22:43:29 -05:00
|
|
|
|
2024-01-04 21:02:59 -05:00
|
|
|
bool canvas_note_event (GdkEvent* event, ArdourCanvas::Item*);
|
2024-09-18 14:27:43 -04:00
|
|
|
bool canvas_velocity_base_event (GdkEvent* event, ArdourCanvas::Item*);
|
|
|
|
bool canvas_velocity_event (GdkEvent* event, ArdourCanvas::Item*);
|
2024-09-20 21:44:25 -04:00
|
|
|
bool canvas_control_point_event (GdkEvent* event, ArdourCanvas::Item*, ControlPoint*);
|
2024-01-04 21:02:59 -05:00
|
|
|
|
|
|
|
int32_t get_grid_beat_divisions (Editing::GridType gt) const { return 1; }
|
|
|
|
int32_t get_grid_music_divisions (Editing::GridType gt, uint32_t event_state) const { return 1; }
|
2023-11-19 22:43:29 -05:00
|
|
|
|
2024-10-13 11:03:44 -04:00
|
|
|
void set_region (std::shared_ptr<ARDOUR::MidiRegion>);
|
2024-10-11 00:18:17 -04:00
|
|
|
void set_box (std::shared_ptr<ARDOUR::TriggerBox>);
|
2024-10-13 11:03:44 -04:00
|
|
|
void set_track (std::shared_ptr<ARDOUR::MidiTrack>);
|
2024-01-08 16:35:15 -05:00
|
|
|
|
2024-01-26 22:45:22 -05:00
|
|
|
ArdourCanvas::ScrollGroup* get_hscroll_group () const { return h_scroll_group; }
|
|
|
|
ArdourCanvas::ScrollGroup* get_cursor_scroll_group () const { return cursor_scroll_group; }
|
|
|
|
|
2024-02-23 13:25:07 -05:00
|
|
|
void set_samples_per_pixel (samplecnt_t);
|
2024-01-26 22:45:22 -05:00
|
|
|
|
2024-01-30 14:40:30 -05:00
|
|
|
void set_mouse_mode (Editing::MouseMode, bool force = false);
|
|
|
|
void step_mouse_mode (bool next);
|
|
|
|
Editing::MouseMode current_mouse_mode () const;
|
|
|
|
bool internal_editing() const;
|
|
|
|
|
2024-10-18 11:50:31 -04:00
|
|
|
void box_rec_enable_change (ARDOUR::TriggerBox const &);
|
|
|
|
void trigger_rec_enable_change (ARDOUR::Trigger const &);
|
|
|
|
|
2024-02-02 18:37:05 -05:00
|
|
|
double timebar_height;
|
|
|
|
size_t n_timebars;
|
|
|
|
|
2024-02-04 23:21:00 -05:00
|
|
|
ArdourCanvas::GtkCanvasViewport* get_canvas_viewport() const;
|
2024-02-23 13:25:07 -05:00
|
|
|
ArdourCanvas::GtkCanvas* get_canvas() const;
|
2024-02-04 23:21:00 -05:00
|
|
|
|
2024-02-13 18:32:29 -05:00
|
|
|
int set_state (const XMLNode&, int version);
|
|
|
|
XMLNode& get_state () const;
|
|
|
|
|
2024-02-23 13:25:07 -05:00
|
|
|
void maybe_autoscroll (bool, bool, bool);
|
|
|
|
bool autoscroll_active() const;
|
|
|
|
|
2024-06-07 01:46:03 -04:00
|
|
|
void midi_action (void (MidiView::*method)());
|
|
|
|
|
2024-10-07 15:20:11 -04:00
|
|
|
std::list<SelectableOwner*> selectable_owners();
|
|
|
|
|
2024-09-20 21:44:25 -04:00
|
|
|
Gdk::Cursor* which_track_cursor () const;
|
|
|
|
Gdk::Cursor* which_mode_cursor () const;
|
|
|
|
Gdk::Cursor* which_trim_cursor (bool left_side) const;
|
|
|
|
Gdk::Cursor* which_canvas_cursor (ItemType type) const;
|
|
|
|
|
2023-11-19 22:43:29 -05:00
|
|
|
protected:
|
2024-02-14 19:10:56 -05:00
|
|
|
void register_actions ();
|
|
|
|
|
2023-11-19 22:43:29 -05:00
|
|
|
Temporal::timepos_t snap_to_grid (Temporal::timepos_t const & start,
|
|
|
|
Temporal::RoundMode direction,
|
2024-01-04 21:02:59 -05:00
|
|
|
ARDOUR::SnapPref gpref) const;
|
2023-11-19 22:43:29 -05:00
|
|
|
|
|
|
|
void snap_to_internal (Temporal::timepos_t& first,
|
|
|
|
Temporal::RoundMode direction = Temporal::RoundNearest,
|
|
|
|
ARDOUR::SnapPref gpref = ARDOUR::SnapToAny_Visual,
|
2024-01-04 21:02:59 -05:00
|
|
|
bool ensure_snap = false) const;
|
2023-11-19 22:43:29 -05:00
|
|
|
|
2024-01-29 16:32:18 -05:00
|
|
|
bool button_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
|
|
|
|
bool button_press_handler_1 (ArdourCanvas::Item*, GdkEvent*, ItemType);
|
|
|
|
bool button_press_handler_2 (ArdourCanvas::Item*, GdkEvent*, ItemType);
|
|
|
|
bool button_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
|
|
|
|
bool button_press_dispatch (GdkEventButton*);
|
|
|
|
bool button_release_dispatch (GdkEventButton*);
|
|
|
|
bool motion_handler (ArdourCanvas::Item*, GdkEvent*, bool from_autoscroll = false);
|
|
|
|
bool enter_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
|
|
|
|
bool leave_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
|
|
|
|
bool key_press_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
|
|
|
|
bool key_release_handler (ArdourCanvas::Item*, GdkEvent*, ItemType);
|
|
|
|
|
2024-02-13 14:22:49 -05:00
|
|
|
void mouse_mode_toggled (Editing::MouseMode);
|
|
|
|
|
2024-06-07 12:05:25 -04:00
|
|
|
void escape ();
|
2024-06-08 00:54:07 -04:00
|
|
|
void on_samples_per_pixel_changed ();
|
2024-06-07 12:05:25 -04:00
|
|
|
|
2023-11-18 22:45:48 -05:00
|
|
|
private:
|
2024-10-17 17:06:33 -04:00
|
|
|
std::shared_ptr<ARDOUR::MidiTrack> _track;
|
2023-11-18 22:45:48 -05:00
|
|
|
ArdourCanvas::GtkCanvasViewport* _canvas_viewport;
|
2024-01-31 20:08:44 -05:00
|
|
|
ArdourCanvas::GtkCanvas* _canvas;
|
2023-11-18 22:45:48 -05:00
|
|
|
|
|
|
|
/* The group containing all other groups that are scrolled vertically
|
|
|
|
and horizontally.
|
|
|
|
*/
|
|
|
|
ArdourCanvas::ScrollGroup* hv_scroll_group;
|
|
|
|
|
|
|
|
/* The group containing all other groups that are scrolled horizontally ONLY
|
|
|
|
*/
|
|
|
|
ArdourCanvas::ScrollGroup* h_scroll_group;
|
2024-02-09 13:29:23 -05:00
|
|
|
ArdourCanvas::ScrollGroup* v_scroll_group;
|
2023-11-18 22:45:48 -05:00
|
|
|
|
|
|
|
/* Scroll group for cursors, scrolled horizontally, above everything else
|
|
|
|
*/
|
|
|
|
ArdourCanvas::ScrollGroup* cursor_scroll_group;
|
|
|
|
|
|
|
|
ArdourCanvas::Container* global_rect_group;
|
2024-02-01 23:24:20 -05:00
|
|
|
ArdourCanvas::Container* no_scroll_group;
|
|
|
|
ArdourCanvas::Container* data_group;
|
2023-11-18 22:45:48 -05:00
|
|
|
ArdourCanvas::Container* time_line_group;
|
2024-02-01 23:24:20 -05:00
|
|
|
ArdourCanvas::Ruler* bbt_ruler;
|
2024-02-02 18:37:05 -05:00
|
|
|
ArdourCanvas::Rectangle* tempo_bar;
|
2024-02-07 00:27:36 -05:00
|
|
|
ArdourCanvas::Rectangle* meter_bar;
|
2024-02-07 15:13:40 -05:00
|
|
|
ArdourCanvas::PianoRollHeader* prh;
|
2023-11-18 22:45:48 -05:00
|
|
|
|
|
|
|
ArdourCanvas::Rectangle* transport_loop_range_rect;
|
|
|
|
|
2024-02-13 14:22:49 -05:00
|
|
|
Gtk::VBox _toolbox;
|
|
|
|
|
2024-01-08 16:35:15 -05:00
|
|
|
CueMidiBackground* bg;
|
2024-01-28 17:26:38 -05:00
|
|
|
MidiCueView* view;
|
2024-01-08 16:35:15 -05:00
|
|
|
|
2023-11-18 22:45:48 -05:00
|
|
|
void build_canvas ();
|
2024-01-08 16:38:16 -05:00
|
|
|
void canvas_allocate (Gtk::Allocation);
|
2024-01-30 14:40:30 -05:00
|
|
|
|
|
|
|
RegionSelection region_selection();
|
2024-01-31 20:08:44 -05:00
|
|
|
|
|
|
|
bool canvas_enter_leave (GdkEventCrossing* ev);
|
2024-02-01 23:24:20 -05:00
|
|
|
|
|
|
|
void metric_get_bbt (std::vector<ArdourCanvas::Ruler::Mark>&, samplepos_t, samplepos_t, gint);
|
|
|
|
|
|
|
|
class BBTMetric : public ArdourCanvas::Ruler::Metric
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BBTMetric (MidiCueEditor& ec) : context (&ec) {}
|
|
|
|
|
|
|
|
void get_marks (std::vector<ArdourCanvas::Ruler::Mark>& marks, int64_t lower, int64_t upper, int maxchars) const {
|
|
|
|
context->metric_get_bbt (marks, lower, upper, maxchars);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
MidiCueEditor* context;
|
|
|
|
};
|
|
|
|
|
|
|
|
BBTMetric bbt_metric;
|
2024-02-04 23:21:00 -05:00
|
|
|
|
2024-02-07 00:27:36 -05:00
|
|
|
bool canvas_pre_event (GdkEvent*);
|
2024-02-13 14:22:49 -05:00
|
|
|
void setup_toolbar ();
|
2024-02-23 13:25:07 -05:00
|
|
|
|
|
|
|
/* autoscrolling */
|
|
|
|
|
|
|
|
bool autoscroll_canvas ();
|
|
|
|
void start_canvas_autoscroll (bool allow_horiz, bool allow_vert, const ArdourCanvas::Rect& boundary);
|
|
|
|
void stop_canvas_autoscroll ();
|
|
|
|
|
2024-10-17 17:06:33 -04:00
|
|
|
sigc::connection _update_connection;
|
|
|
|
PBD::ScopedConnection track_connection;
|
|
|
|
void maybe_update ();
|
|
|
|
|
2024-02-23 13:25:07 -05:00
|
|
|
void visual_changer (const VisualChange&);
|
2024-06-29 18:47:42 -04:00
|
|
|
void bindings_changed ();
|
2024-10-11 00:18:17 -04:00
|
|
|
|
2024-10-14 23:43:36 -04:00
|
|
|
void data_captured (Temporal::timecnt_t);
|
|
|
|
bool idle_data_captured ();
|
|
|
|
std::atomic<int> idle_update_queued;
|
2024-10-13 11:03:44 -04:00
|
|
|
PBD::ScopedConnectionList capture_connections;
|
2024-10-14 23:43:36 -04:00
|
|
|
Temporal::timecnt_t data_capture_duration;
|
2023-11-18 22:45:48 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|