all streamviews are now ViewBackgrounds

This new inheritance heirarchy lets us share (a very small piece of) code
between streamviews in the Editor and the nascent piano roll object on the cue
page.
This commit is contained in:
Paul Davis 2024-01-08 14:35:15 -07:00
parent bc6cabece4
commit 2fbcc54def
10 changed files with 160 additions and 9 deletions

View File

@ -52,7 +52,7 @@ public:
void redisplay_track ();
inline double contents_height() const {
double contents_height() const {
return (_trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2);
}

View File

@ -22,7 +22,9 @@
#include "canvas/scroll_group.h"
#include "canvas/rectangle.h"
#include "midi_cue_background.h"
#include "midi_cue_editor.h"
#include "midi_view.h"
#include "ui_config.h"
#include "verbose_cursor.h"
@ -93,6 +95,13 @@ MidiCueEditor::build_canvas ()
// 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();
ArdourCanvas::Text* hw = new ArdourCanvas::Text (hv_scroll_group);
hw->set ("hello, world");
hw->set_fill_color (Gtkmm2ext::Color (0xff0000ff));
std::cerr << "New CMB\n";
bg = new CueMidiBackground (hv_scroll_group);
}
@ -174,3 +183,22 @@ MidiCueEditor::canvas_note_event (GdkEvent* event, ArdourCanvas::Item*)
{
return false;
}
Gtk::Widget&
MidiCueEditor::viewport()
{
return *_canvas_viewport;
}
void
MidiCueEditor::set_region (std::shared_ptr<ARDOUR::MidiTrack> t, std::shared_ptr<ARDOUR::Region> r)
{
// delete view;
// view = nullptr;
if (!t || !r) {
return;
}
// view = new MidiView (t, hv_scroll_group, *this, *bg, 0xff0000ff);
}

View File

@ -34,6 +34,9 @@ namespace ArdourCanvas {
class ScrollGroup;
}
class MidiView;
class CueMidiBackground;
class MidiCueEditor : public CueEditor
{
public:
@ -41,7 +44,7 @@ class MidiCueEditor : public CueEditor
~MidiCueEditor ();
ArdourCanvas::Container* get_noscroll_group() const { return no_scroll_group; }
Gtk::Widget& viewport() { return *_canvas_viewport; }
Gtk::Widget& viewport();
double visible_canvas_width() const { return _visible_canvas_width; }
samplecnt_t current_page_samples() const;
@ -59,6 +62,8 @@ class MidiCueEditor : public CueEditor
void apply_midi_note_edit_op (ARDOUR::MidiOperator& op, const RegionSelection& rs);
PBD::Command* apply_midi_note_edit_op_to_region (ARDOUR::MidiOperator& op, MidiRegionView& mrv);
void set_region (std::shared_ptr<ARDOUR::MidiTrack>, std::shared_ptr<ARDOUR::Region>);
protected:
Temporal::timepos_t snap_to_grid (Temporal::timepos_t const & start,
Temporal::RoundMode direction,
@ -100,6 +105,9 @@ class MidiCueEditor : public CueEditor
ArdourCanvas::Rectangle* transport_loop_range_rect;
CueMidiBackground* bg;
MidiView* view;
void build_canvas ();
};

View File

@ -207,11 +207,19 @@ MidiStreamView::display_track (std::shared_ptr<Track> tr)
{
StreamView::display_track (tr);
std::cerr << "MSV @ " << this << " dnl\n";
draw_note_lines();
NoteRangeChanged(); /* EMIT SIGNAL*/
}
void
MidiStreamView::update_contents_height ()
{
StreamView::update_contents_height();
MidiViewBackground::update_contents_height ();
}
void
MidiStreamView::update_contents_metrics(std::shared_ptr<Region> r)
{

View File

@ -104,6 +104,7 @@ private:
void display_region(MidiRegionView* region_view, bool load_model);
void display_track (std::shared_ptr<ARDOUR::Track> tr);
void update_contents_height ();
void update_contents_metrics (std::shared_ptr<ARDOUR::Region> r);
void color_handler ();
void apply_note_range_to_children ();

View File

@ -45,7 +45,7 @@ MidiViewBackground::MidiViewBackground (ArdourCanvas::Item* parent)
{
_note_lines->lower_to_bottom();
color_handler ();
// color_handler ();
UIConfiguration::instance().ColorsChanged.connect(sigc::mem_fun(*this, &MidiViewBackground::color_handler));
UIConfiguration::instance().ParameterChanged.connect(sigc::mem_fun(*this, &MidiViewBackground::parameter_changed));

View File

@ -29,16 +29,26 @@
#include "ardour/types.h"
#include "gtkmm2ext/colors.h"
#include "view_background.h"
namespace ArdourCanvas {
class Item;
class LineSet;
}
class MidiViewBackground
/** A class that provides various context for a MidiVieww:
= note ranges
* color information
* etc.
*/
class MidiViewBackground : public virtual ViewBackground
{
public:
MidiViewBackground (ArdourCanvas::Item* parent);
virtual ~MidiViewBackground ();
~MidiViewBackground ();
Gtk::Adjustment note_range_adjustment;
@ -62,8 +72,6 @@ class MidiViewBackground
void update_note_range(uint8_t note_num);
virtual double contents_height() const = 0;
double note_to_y (uint8_t note) const {
return contents_height() - (note + 1 - lowest_note()) * note_height() + 1;
}
@ -103,9 +111,9 @@ class MidiViewBackground
void color_handler ();
void parameter_changed (std::string const &);
void note_range_adjustment_changed();
void update_contents_height ();
void draw_note_lines();
bool update_data_note_range(uint8_t min, uint8_t max);
void update_contents_height ();
virtual void apply_note_range_to_children () = 0;
virtual bool updates_suspended() const { return false; }
};

View File

@ -31,7 +31,9 @@
#include "pbd/signals.h"
#include "ardour/location.h"
#include "enums.h"
#include "view_background.h"
namespace Gdk {
class Color;
@ -64,7 +66,7 @@ class RegionSelection;
class CrossfadeView;
class Selection;
class StreamView : public sigc::trackable, public PBD::ScopedConnectionList
class StreamView : public sigc::trackable, public PBD::ScopedConnectionList, public virtual ViewBackground
{
public:
virtual ~StreamView ();

View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
* Copyright (C) 2007 Doug McLain <doug@nostar.net>
* Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
* Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
* Copyright (C) 2015 Tim Mayberry <mojofunk@gmail.com>
* Copyright (C) 2016 Nick Mainsbridge <mainsbridge@gmail.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.
*/
#include "canvas/line_set.h"
#include "view_background.h"
#include "ui_config.h"
using namespace std;
ViewBackground::ViewBackground ()
{
UIConfiguration::instance().ColorsChanged.connect(sigc::mem_fun(*this, &ViewBackground::color_handler));
UIConfiguration::instance().ParameterChanged.connect(sigc::mem_fun(*this, &ViewBackground::parameter_changed));
}
ViewBackground::~ViewBackground()
{
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
* Copyright (C) 2007 Doug McLain <doug@nostar.net>
* Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
* Copyright (C) 2016-2017 Robin Gareus <robin@gareus.org>
*
* 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 __gtk2_ardour_view_background_h__
#define __gtk2_ardour_view_background_h__
#include <cstdint>
#include "gtkmm2ext/colors.h"
namespace ArdourCanvas {
class Item;
}
/** A class that provides limited context for a View
*/
class ViewBackground
{
public:
ViewBackground ();
virtual ~ViewBackground ();
virtual double contents_height() const { return 0.; }
/** @return y position, or -1 if hidden */
virtual double y_position () const { return 0.; }
protected:
virtual void update_contents_height () {}
virtual void color_handler () {}
virtual void parameter_changed (std::string const &) {}
};
#endif /* __gtk2_ardour_view_background_h__ */