diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index a5d13ee87b..c6de325d82 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -1471,7 +1471,7 @@ AudioRegionView::add_ghost (TimeAxisView& tv) 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_colors(); ghosts.push_back (ghost); diff --git a/gtk2_ardour/ghostregion.cc b/gtk2_ardour/ghostregion.cc index 53c3f7eb73..e31cc10d08 100644 --- a/gtk2_ardour/ghostregion.cc +++ b/gtk2_ardour/ghostregion.cc @@ -68,7 +68,7 @@ GhostRegion::GhostRegion (RegionView& rv, CANVAS_DEBUG_NAME (base_rect, "ghost region rect"); base_rect->set_x0 (0); base_rect->set_y0 (1.0); - base_rect->set_y1 (trackview.current_height()); + base_rect->set_y1 (1); base_rect->set_outline (false); if (!is_automation_ghost()) { @@ -97,9 +97,15 @@ GhostRegion::set_duration (double units) } 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 @@ -141,14 +147,14 @@ AudioGhostRegion::set_samples_per_pixel (double fpp) } void -AudioGhostRegion::set_height () +AudioGhostRegion::set_height (double h) { vector::iterator i; 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) { (*i)->set_height (ht); @@ -274,9 +280,9 @@ MidiGhostRegion::midi_view () } void -MidiGhostRegion::set_height () +MidiGhostRegion::set_height (double h) { - GhostRegion::set_height(); + GhostRegion::set_height (h); update_contents_height (); } @@ -293,22 +299,20 @@ MidiGhostRegion::set_colors() } 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(); - 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 -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 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 @@ -320,12 +324,12 @@ MidiGhostRegion::update_contents_height () 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) { 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) { _tmp_rect = static_cast(it->second->item); @@ -357,8 +361,8 @@ MidiGhostRegion::add_note (NoteBase* n) event->item->hide(); } else { uint8_t const note_num = n->note()->note(); - double const h = note_height(trackview, mv); - double const y = note_y(trackview, mv, note_num); + double const h = note_height (*this, mv); + double const y = note_y (*this, mv, note_num); if (!event->is_hit) { _tmp_rect = static_cast(event->item); _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(ev->item); uint8_t const note_num = ev->event->note()->note(); - double const y = note_y(trackview, mv, note_num); - double const h = note_height(trackview, mv); + double const y = note_y (*this, mv, note_num); + double const h = note_height (*this, mv); _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(ev->item); uint8_t const note_num = ev->event->note()->note(); - double const h = note_height(trackview, mv); - double const y = note_y(trackview, mv, note_num); + double const h = note_height (*this, mv); + double const y = note_y (*this, mv, note_num); ArdourCanvas::Duple ppos = ev->item->position(); ArdourCanvas::Duple gpos = _tmp_poly->position(); diff --git a/gtk2_ardour/ghostregion.h b/gtk2_ardour/ghostregion.h index 30ebd662a7..99a4df949a 100644 --- a/gtk2_ardour/ghostregion.h +++ b/gtk2_ardour/ghostregion.h @@ -43,7 +43,7 @@ class MidiRegionView; class GhostRegion : public sigc::trackable { -public: + public: GhostRegion(RegionView& rv, ArdourCanvas::Container* parent, TimeAxisView& tv, @@ -53,10 +53,12 @@ public: virtual ~GhostRegion(); virtual void set_samples_per_pixel (double) = 0; - virtual void set_height(); + virtual void set_height (double h); 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); bool is_automation_ghost(); @@ -78,7 +80,7 @@ public: double initial_unit_pos); void set_samples_per_pixel (double); - void set_height(); + void set_height (double h); void set_colors(); std::vector waves; @@ -111,7 +113,7 @@ public: MidiStreamView* midi_view(); - void set_height(); + void set_height (double h); void set_samples_per_pixel (double spu); void set_colors(); diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index a32bcae7bc..4de5df0684 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -271,8 +271,6 @@ MidiRegionView::init (bool wfd) RegionView::init (false); - //set_height (trackview.current_height()); - region_muted (); region_sync_changed (); region_resized (ARDOUR::bounds_change); @@ -1478,7 +1476,7 @@ MidiRegionView::add_ghost (TimeAxisView& tv) } ghost->set_colors (); - ghost->set_height (); + ghost->set_height (trackview.current_height()); ghost->set_duration (_region->length().samples() / samples_per_pixel); 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) { typedef vector > PossibleChord; - Editor* editor = dynamic_cast (&trackview.editor()); PossibleChord to_play; Temporal::Beats earliest = earliest_in_selection(); diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index f4cb11c680..01d4f0ddbd 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -351,7 +351,7 @@ TimeAxisView::show_at (double y, int& nth, VBox *parent) } for (list::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 */ @@ -621,7 +621,7 @@ TimeAxisView::set_height (uint32_t h, TrackHeightMode m) set_gui_property ("height", height); for (list::iterator i = ghosts.begin(); i != ghosts.end(); ++i) { - (*i)->set_height (); + (*i)->set_height (current_height()); } if (selection_group->visible ()) {