From e9d63a707a174b180701ea69c854f76f6d462972 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 18 Nov 2023 20:45:48 -0700 Subject: [PATCH] skeleton for MIDI cue editor --- gtk2_ardour/midi_cue_editor.cc | 92 ++++++++++++++++++++++++++++++++++ gtk2_ardour/midi_cue_editor.h | 81 ++++++++++++++++++++++++++++++ gtk2_ardour/wscript | 1 + 3 files changed, 174 insertions(+) create mode 100644 gtk2_ardour/midi_cue_editor.cc create mode 100644 gtk2_ardour/midi_cue_editor.h diff --git a/gtk2_ardour/midi_cue_editor.cc b/gtk2_ardour/midi_cue_editor.cc new file mode 100644 index 0000000000..be6b96cc5f --- /dev/null +++ b/gtk2_ardour/midi_cue_editor.cc @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2023 Paul Davis + * + * 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. + */ + +#include "canvas/canvas.h" +#include "canvas/container.h" +#include "canvas/debug.h" +#include "canvas/scroll_group.h" +#include "canvas/rectangle.h" + +#include "midi_cue_editor.h" +#include "ui_config.h" + +using namespace ArdourCanvas; + +MidiCueEditor::MidiCueEditor() + : vertical_adjustment (0.0, 0.0, 10.0, 400.0) + , horizontal_adjustment (0.0, 0.0, 1e16) +{ + build_canvas (); +} + +MidiCueEditor::~MidiCueEditor () +{ +} + +void +MidiCueEditor::build_canvas () +{ + _canvas_viewport = new ArdourCanvas::GtkCanvasViewport (horizontal_adjustment, vertical_adjustment); + _canvas = _canvas_viewport->canvas (); + + _canvas->set_background_color (UIConfiguration::instance().color ("arrange base")); + // _canvas->use_nsglview (UIConfiguration::instance().get_nsgl_view_mode () == NSGLHiRes); + + /* scroll group for items that should not automatically scroll + * (e.g verbose cursor). It shares the canvas coordinate space. + */ + no_scroll_group = new ArdourCanvas::Container (_canvas->root()); + + ArdourCanvas::ScrollGroup* hsg; + ArdourCanvas::ScrollGroup* hg; + ArdourCanvas::ScrollGroup* cg; + + h_scroll_group = hg = new ArdourCanvas::ScrollGroup (_canvas->root(), ArdourCanvas::ScrollGroup::ScrollsHorizontally); + CANVAS_DEBUG_NAME (h_scroll_group, "canvas h scroll"); + _canvas->add_scroller (*hg); + + hv_scroll_group = hsg = new ArdourCanvas::ScrollGroup (_canvas->root(), + ArdourCanvas::ScrollGroup::ScrollSensitivity (ArdourCanvas::ScrollGroup::ScrollsVertically| + ArdourCanvas::ScrollGroup::ScrollsHorizontally)); + CANVAS_DEBUG_NAME (hv_scroll_group, "canvas hv scroll"); + _canvas->add_scroller (*hsg); + + cursor_scroll_group = cg = new ArdourCanvas::ScrollGroup (_canvas->root(), ArdourCanvas::ScrollGroup::ScrollsHorizontally); + CANVAS_DEBUG_NAME (cursor_scroll_group, "canvas cursor scroll"); + _canvas->add_scroller (*cg); + + /*a group to hold global rects like punch/loop indicators */ + global_rect_group = new ArdourCanvas::Container (hv_scroll_group); + CANVAS_DEBUG_NAME (global_rect_group, "global rect group"); + + transport_loop_range_rect = new ArdourCanvas::Rectangle (global_rect_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, ArdourCanvas::COORD_MAX)); + CANVAS_DEBUG_NAME (transport_loop_range_rect, "loop rect"); + transport_loop_range_rect->hide(); + + /*a group to hold time (measure) lines */ + time_line_group = new ArdourCanvas::Container (h_scroll_group); + CANVAS_DEBUG_NAME (time_line_group, "time line group"); + + _trackview_group = new ArdourCanvas::Container (hv_scroll_group); + CANVAS_DEBUG_NAME (_trackview_group, "Canvas TrackViews"); + + // used as rubberband rect + rubberband_rect = new ArdourCanvas::Rectangle (hv_scroll_group, ArdourCanvas::Rect (0.0, 0.0, 0.0, 0.0)); + rubberband_rect->hide(); +} + diff --git a/gtk2_ardour/midi_cue_editor.h b/gtk2_ardour/midi_cue_editor.h new file mode 100644 index 0000000000..69cf25d78e --- /dev/null +++ b/gtk2_ardour/midi_cue_editor.h @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2023 Paul Davis + * + * 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 __gtk_ardour_midi_cue_editor_h__ +#define __gtk_ardour_midi_cue_editor_h__ + +#include + +#include "cue_editor.h" + +namespace Gtk { + class Widget; +} + +namespace ArdourCanvas { + class Canvas; + class Container; + class GtkCanvasViewport; + class ScrollGroup; +} + +class MidiCueEditor : public CueEditor +{ + public: + MidiCueEditor (); + ~MidiCueEditor (); + + ArdourCanvas::Container* get_noscroll_group() const { return no_scroll_group; } + Gtk::Widget& viewport() { return *_canvas_viewport; } + + private: + Gtk::Adjustment vertical_adjustment; + Gtk::Adjustment horizontal_adjustment; + ArdourCanvas::GtkCanvasViewport* _canvas_viewport; + ArdourCanvas::Canvas* _canvas; + + ArdourCanvas::Container* tempo_group; + + /* 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; + + /* Scroll group for cursors, scrolled horizontally, above everything else + */ + ArdourCanvas::ScrollGroup* cursor_scroll_group; + + /* The group containing all trackviews. */ + ArdourCanvas::Container* no_scroll_group; + + /* The group containing all trackviews. */ + ArdourCanvas::Container* _trackview_group; + ArdourCanvas::Container* global_rect_group; + ArdourCanvas::Container* time_line_group; + + ArdourCanvas::Rectangle* transport_loop_range_rect; + + void build_canvas (); +}; + + +#endif /* __gtk_ardour_midi_cue_editor_h__ */ diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 95aac20121..d8df10b94d 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -159,6 +159,7 @@ gtk2_ardour_sources = [ 'midi_channel_dialog.cc', 'midi_channel_selector.cc', 'midi_clip_editor.cc', + 'midi_cue_editor.cc', 'midi_cut_buffer.cc', 'midi_export_dialog.cc', 'midi_list_editor.cc',