From a44e8ac0888642b497206d544bea52efe38a5f29 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 16 Sep 2024 22:57:17 -0600 Subject: [PATCH] fix drawing of lollipops. There may be more virtual GhostRegion methods that VelocityGhostRegion has to proxy to VelocityDisplay --- gtk2_ardour/ghostregion.cc | 1 - gtk2_ardour/velocity_display.cc | 8 +++----- gtk2_ardour/velocity_display.h | 2 +- gtk2_ardour/velocity_ghost_region.cc | 6 ++++++ gtk2_ardour/velocity_ghost_region.h | 2 ++ 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/ghostregion.cc b/gtk2_ardour/ghostregion.cc index 9e158b0b11..3a4f7cb462 100644 --- a/gtk2_ardour/ghostregion.cc +++ b/gtk2_ardour/ghostregion.cc @@ -428,4 +428,3 @@ MidiGhostRegion::model_changed () ++i; } } - diff --git a/gtk2_ardour/velocity_display.cc b/gtk2_ardour/velocity_display.cc index 319096b47e..def06de4fd 100644 --- a/gtk2_ardour/velocity_display.cc +++ b/gtk2_ardour/velocity_display.cc @@ -68,7 +68,6 @@ VelocityDisplay::VelocityDisplay (EditingContext& ec, MidiViewBackground& backgr , selected (false) , _optimization_iterator (events.end()) { - std::cerr << "new VD @ " << this << " view " << &view << std::endl; base.set_data (X_("ghostregionview"), this); base.Event.connect (sigc::mem_fun (*this, &VelocityDisplay::base_event)); base.set_fill_color (UIConfiguration::instance().color_mod ("ghost track base", "ghost track midi fill")); @@ -159,7 +158,6 @@ VelocityDisplay::clear () void VelocityDisplay::add_note (NoteBase* nb) { - std::cerr << "Add new lolli\n"; ArdourCanvas::Lollipop* l = new ArdourCanvas::Lollipop (lolli_container); l->set_bounding_parent (&base); @@ -189,15 +187,15 @@ VelocityDisplay::set_size_and_position (GhostEvent& gev) } ArdourCanvas::Lollipop* l = dynamic_cast (gev.item); - const double available_height = base.y1(); + const double available_height = base.height(); const double actual_height = ((dragging ? gev.velocity_while_editing : gev.event->note()->velocity()) / 127.0) * available_height; const double scale = UIConfiguration::instance ().get_ui_scale (); if (gev.is_hit) { /* compare to Hit::points , offset by w/2 */ - l->set (ArdourCanvas::Duple (gev.event->x0() + (gev.event->x1() - gev.event->x0()) / 2, base.height() - actual_height), actual_height, lollipop_radius * scale); + l->set (ArdourCanvas::Duple (gev.event->x0() + (gev.event->x1() - gev.event->x0()) / 2, base.y1() - actual_height), actual_height, lollipop_radius * scale); } else { - l->set (ArdourCanvas::Duple (gev.event->x0(), base.height() - actual_height), actual_height, lollipop_radius * scale); + l->set (ArdourCanvas::Duple (gev.event->x0(), base.y1() - actual_height), actual_height, lollipop_radius * scale); } } diff --git a/gtk2_ardour/velocity_display.h b/gtk2_ardour/velocity_display.h index 52e18f234c..1150067513 100644 --- a/gtk2_ardour/velocity_display.h +++ b/gtk2_ardour/velocity_display.h @@ -73,7 +73,7 @@ class VelocityDisplay ArdourCanvas::Rectangle& base_item() { return base; } MidiView& midi_view() const { return view; } - + protected: virtual bool lollevent (GdkEvent*, GhostEvent*) = 0; diff --git a/gtk2_ardour/velocity_ghost_region.cc b/gtk2_ardour/velocity_ghost_region.cc index c2be26999a..9b83adf640 100644 --- a/gtk2_ardour/velocity_ghost_region.cc +++ b/gtk2_ardour/velocity_ghost_region.cc @@ -111,3 +111,9 @@ VelocityGhostRegion::note_selected (NoteBase* nb) { VelocityDisplay::note_selected (nb); } + +void +VelocityGhostRegion::update_contents_height () +{ + VelocityDisplay::redisplay (); +} diff --git a/gtk2_ardour/velocity_ghost_region.h b/gtk2_ardour/velocity_ghost_region.h index adada59405..289f44e30a 100644 --- a/gtk2_ardour/velocity_ghost_region.h +++ b/gtk2_ardour/velocity_ghost_region.h @@ -42,6 +42,8 @@ class VelocityGhostRegion : public MidiGhostRegion, public VelocityDisplay void add_note (NoteBase*); void note_selected (NoteBase*); void update_note (GhostEvent*); + void update_contents_height (); + ArdourCanvas::Rectangle& base_item(); void set_colors ();