ghostregions: use their own height, not trackview.current_height()

This commit is contained in:
Paul Davis 2021-12-08 09:28:26 -07:00
parent 71181bbb02
commit de65798619
5 changed files with 38 additions and 35 deletions

View File

@ -1471,7 +1471,7 @@ AudioRegionView::add_ghost (TimeAxisView& tv)
ghost->waves.push_back(wave); ghost->waves.push_back(wave);
} }
ghost->set_height (); ghost->set_height (tv.current_height());
ghost->set_duration (_region->length_samples() / samples_per_pixel); ghost->set_duration (_region->length_samples() / samples_per_pixel);
ghost->set_colors(); ghost->set_colors();
ghosts.push_back (ghost); ghosts.push_back (ghost);

View File

@ -68,7 +68,7 @@ GhostRegion::GhostRegion (RegionView& rv,
CANVAS_DEBUG_NAME (base_rect, "ghost region rect"); CANVAS_DEBUG_NAME (base_rect, "ghost region rect");
base_rect->set_x0 (0); base_rect->set_x0 (0);
base_rect->set_y0 (1.0); base_rect->set_y0 (1.0);
base_rect->set_y1 (trackview.current_height()); base_rect->set_y1 (1);
base_rect->set_outline (false); base_rect->set_outline (false);
if (!is_automation_ghost()) { if (!is_automation_ghost()) {
@ -97,9 +97,15 @@ GhostRegion::set_duration (double units)
} }
void void
GhostRegion::set_height () GhostRegion::set_height (double h)
{ {
base_rect->set_y1 (trackview.current_height()); base_rect->set_y1 (h);
}
double
GhostRegion::height() const
{
return base_rect->y1 ();
} }
void void
@ -141,14 +147,14 @@ AudioGhostRegion::set_samples_per_pixel (double fpp)
} }
void void
AudioGhostRegion::set_height () AudioGhostRegion::set_height (double h)
{ {
vector<ArdourWaveView::WaveView*>::iterator i; vector<ArdourWaveView::WaveView*>::iterator i;
uint32_t n; uint32_t n;
GhostRegion::set_height(); GhostRegion::set_height (h);
double const ht = ((trackview.current_height()) / (double) waves.size()); double const ht = (h / (double) waves.size());
for (n = 0, i = waves.begin(); i != waves.end(); ++i, ++n) { for (n = 0, i = waves.begin(); i != waves.end(); ++i, ++n) {
(*i)->set_height (ht); (*i)->set_height (ht);
@ -274,9 +280,9 @@ MidiGhostRegion::midi_view ()
} }
void void
MidiGhostRegion::set_height () MidiGhostRegion::set_height (double h)
{ {
GhostRegion::set_height(); GhostRegion::set_height (h);
update_contents_height (); update_contents_height ();
} }
@ -293,22 +299,20 @@ MidiGhostRegion::set_colors()
} }
static double static double
note_height(TimeAxisView& trackview, MidiStreamView* mv) note_height(GhostRegion const & gr, MidiStreamView* mv)
{ {
const double tv_height = trackview.current_height();
const double note_range = mv->contents_note_range(); const double note_range = mv->contents_note_range();
return std::max(1.0, floor(tv_height / note_range - 1.0)); return std::max(1.0, floor (gr.height() / note_range - 1.0));
} }
static double static double
note_y(TimeAxisView& trackview, MidiStreamView* mv, uint8_t note_num) note_y (GhostRegion const & gr, MidiStreamView* mv, uint8_t note_num)
{ {
const double tv_height = trackview.current_height();
const double note_range = mv->contents_note_range(); const double note_range = mv->contents_note_range();
const double s = tv_height / note_range; const double s = gr.height() / note_range;
return tv_height - (note_num + 1 - mv->lowest_note()) * s; return gr.height() - (note_num + 1 - mv->lowest_note()) * s;
} }
void void
@ -320,12 +324,12 @@ MidiGhostRegion::update_contents_height ()
return; return;
} }
double const h = note_height(trackview, mv); double const h = note_height (*this, mv);
for (EventList::iterator it = events.begin(); it != events.end(); ++it) { for (EventList::iterator it = events.begin(); it != events.end(); ++it) {
uint8_t const note_num = it->second->event->note()->note(); uint8_t const note_num = it->second->event->note()->note();
double const y = note_y(trackview, mv, note_num); double const y = note_y (*this, mv, note_num);
if (!it->second->is_hit) { if (!it->second->is_hit) {
_tmp_rect = static_cast<ArdourCanvas::Rectangle*>(it->second->item); _tmp_rect = static_cast<ArdourCanvas::Rectangle*>(it->second->item);
@ -357,8 +361,8 @@ MidiGhostRegion::add_note (NoteBase* n)
event->item->hide(); event->item->hide();
} else { } else {
uint8_t const note_num = n->note()->note(); uint8_t const note_num = n->note()->note();
double const h = note_height(trackview, mv); double const h = note_height (*this, mv);
double const y = note_y(trackview, mv, note_num); double const y = note_y (*this, mv, note_num);
if (!event->is_hit) { if (!event->is_hit) {
_tmp_rect = static_cast<ArdourCanvas::Rectangle*>(event->item); _tmp_rect = static_cast<ArdourCanvas::Rectangle*>(event->item);
_tmp_rect->set (ArdourCanvas::Rect (_tmp_rect->x0(), y, _tmp_rect->x1(), y + h)); _tmp_rect->set (ArdourCanvas::Rect (_tmp_rect->x0(), y, _tmp_rect->x1(), y + h));
@ -396,8 +400,8 @@ MidiGhostRegion::update_note (GhostEvent* ev)
_tmp_rect = static_cast<ArdourCanvas::Rectangle*>(ev->item); _tmp_rect = static_cast<ArdourCanvas::Rectangle*>(ev->item);
uint8_t const note_num = ev->event->note()->note(); uint8_t const note_num = ev->event->note()->note();
double const y = note_y(trackview, mv, note_num); double const y = note_y (*this, mv, note_num);
double const h = note_height(trackview, mv); double const h = note_height (*this, mv);
_tmp_rect->set (ArdourCanvas::Rect (ev->event->x0(), y, ev->event->x1(), y + h)); _tmp_rect->set (ArdourCanvas::Rect (ev->event->x0(), y, ev->event->x1(), y + h));
} }
@ -417,8 +421,8 @@ MidiGhostRegion::update_hit (GhostEvent* ev)
_tmp_poly = static_cast<ArdourCanvas::Polygon*>(ev->item); _tmp_poly = static_cast<ArdourCanvas::Polygon*>(ev->item);
uint8_t const note_num = ev->event->note()->note(); uint8_t const note_num = ev->event->note()->note();
double const h = note_height(trackview, mv); double const h = note_height (*this, mv);
double const y = note_y(trackview, mv, note_num); double const y = note_y (*this, mv, note_num);
ArdourCanvas::Duple ppos = ev->item->position(); ArdourCanvas::Duple ppos = ev->item->position();
ArdourCanvas::Duple gpos = _tmp_poly->position(); ArdourCanvas::Duple gpos = _tmp_poly->position();

View File

@ -43,7 +43,7 @@ class MidiRegionView;
class GhostRegion : public sigc::trackable class GhostRegion : public sigc::trackable
{ {
public: public:
GhostRegion(RegionView& rv, GhostRegion(RegionView& rv,
ArdourCanvas::Container* parent, ArdourCanvas::Container* parent,
TimeAxisView& tv, TimeAxisView& tv,
@ -53,10 +53,12 @@ public:
virtual ~GhostRegion(); virtual ~GhostRegion();
virtual void set_samples_per_pixel (double) = 0; virtual void set_samples_per_pixel (double) = 0;
virtual void set_height(); virtual void set_height (double h);
virtual void set_colors(); virtual void set_colors();
void set_duration(double units); double height() const;
void set_duration (double units);
guint source_track_color(unsigned char alpha = 0xff); guint source_track_color(unsigned char alpha = 0xff);
bool is_automation_ghost(); bool is_automation_ghost();
@ -78,7 +80,7 @@ public:
double initial_unit_pos); double initial_unit_pos);
void set_samples_per_pixel (double); void set_samples_per_pixel (double);
void set_height(); void set_height (double h);
void set_colors(); void set_colors();
std::vector<ArdourWaveView::WaveView*> waves; std::vector<ArdourWaveView::WaveView*> waves;
@ -111,7 +113,7 @@ public:
MidiStreamView* midi_view(); MidiStreamView* midi_view();
void set_height(); void set_height (double h);
void set_samples_per_pixel (double spu); void set_samples_per_pixel (double spu);
void set_colors(); void set_colors();

View File

@ -271,8 +271,6 @@ MidiRegionView::init (bool wfd)
RegionView::init (false); RegionView::init (false);
//set_height (trackview.current_height());
region_muted (); region_muted ();
region_sync_changed (); region_sync_changed ();
region_resized (ARDOUR::bounds_change); region_resized (ARDOUR::bounds_change);
@ -1478,7 +1476,7 @@ MidiRegionView::add_ghost (TimeAxisView& tv)
} }
ghost->set_colors (); ghost->set_colors ();
ghost->set_height (); ghost->set_height (trackview.current_height());
ghost->set_duration (_region->length().samples() / samples_per_pixel); ghost->set_duration (_region->length().samples() / samples_per_pixel);
for (Events::iterator i = _events.begin(); i != _events.end(); ++i) { for (Events::iterator i = _events.begin(); i != _events.end(); ++i) {
@ -2516,7 +2514,6 @@ void
MidiRegionView::move_selection(timecnt_t const & dx_qn, double dy, double cumulative_dy) MidiRegionView::move_selection(timecnt_t const & dx_qn, double dy, double cumulative_dy)
{ {
typedef vector<boost::shared_ptr<NoteType> > PossibleChord; typedef vector<boost::shared_ptr<NoteType> > PossibleChord;
Editor* editor = dynamic_cast<Editor*> (&trackview.editor());
PossibleChord to_play; PossibleChord to_play;
Temporal::Beats earliest = earliest_in_selection(); Temporal::Beats earliest = earliest_in_selection();

View File

@ -351,7 +351,7 @@ TimeAxisView::show_at (double y, int& nth, VBox *parent)
} }
for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) { for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
(*i)->set_height (); (*i)->set_height (current_height());
} }
/* put separator at the bottom of this time axis view */ /* put separator at the bottom of this time axis view */
@ -621,7 +621,7 @@ TimeAxisView::set_height (uint32_t h, TrackHeightMode m)
set_gui_property ("height", height); set_gui_property ("height", height);
for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) { for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
(*i)->set_height (); (*i)->set_height (current_height());
} }
if (selection_group->visible ()) { if (selection_group->visible ()) {