From cc58a842758619b4ce85203f8fd2d4d951192b5e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Laurent?= <francois.laurent@posteo.net>
Date: Mon, 6 Jun 2022 21:43:42 +0200
Subject: [PATCH] largely improves #20

---
 src/plots.jl | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/plots.jl b/src/plots.jl
index bdee891..711acc6 100644
--- a/src/plots.jl
+++ b/src/plots.jl
@@ -145,7 +145,7 @@ function SingleLarvaView(larvae::Vector{LarvaModel}, controller; editabletags::B
     # TODO: move the callbacks to `plot!`
 
     # callbacks
-    on(async_latest(getactivelarva(controller))) do id
+    on(getactivelarva(controller)) do id
         if isnothing(id)
             visible[] = false
         else
@@ -184,8 +184,7 @@ function SingleLarvaView(larvae::Vector{LarvaModel}, controller; editabletags::B
          ) do larva, timestep, tag_lut, usertags
         first_timestep = larva.alignedsteps[1]
         last_timestep = larva.alignedsteps[end]
-        if (first_timestep<=timestep &&
-            timestep<=last_timestep &&
+        if (first_timestep <= timestep <= last_timestep &&
             getactivelarva(controller)[] == model[].id
            )
             step = timestep - first_timestep + 1
@@ -514,7 +513,7 @@ function DecoratedLarvae(larvae::Vector{DecoratedLarva})
         @assert hovering_active[]
         i = current_larva[]
         if i == j
-            @warn "moving too fast?"
+            @warn "moving too fast? - please file an issue at https://gitlab.pasteur.fr/nyx/larvatagger.jl/-/issues"
         end
         if 0 < i
             i_decorated = larvae[i].decorated
@@ -523,7 +522,7 @@ function DecoratedLarvae(larvae::Vector{DecoratedLarva})
             else
                 @warn begin
                     i_id = larvae[i].larva.model.id
-                    "larva #$(i_id)'s decorations already removed"
+                    "Larva #$(i_id)'s decorations already removed"
                 end
             end
         end
@@ -534,7 +533,7 @@ function DecoratedLarvae(larvae::Vector{DecoratedLarva})
             else
                 @error begin
                     j_id = larvae[j].larva.model.id
-                    "cannot decorate invisible larva #$(j_id)"
+                    "cannot decorate invisible larva #$(j_id) - please file an issue at https://gitlab.pasteur.fr/nyx/larvatagger.jl/-/issues"
                 end
                 hovered_larva.val = 0
             end
@@ -570,6 +569,7 @@ function Makie.plot!(plot::LarvaPlot{Tuple{DecoratedLarvae}})
         if content.hovering_active[]
             #pos = Makie.to_world(scene, Makie.screen_relative(scene, mp))
             pos = mouseposition(scene)
+            # both `find` and `hovered_larva` return larva indices (not IDs)
             larva = find(content, pos)
             if larva != content.hovered_larva[]
                 content.hovered_larva[] = larva
@@ -584,7 +584,7 @@ Meshes.boundingbox(larva::DecoratedLarva) = Meshes.boundingbox(larva.larva)
 Meshes.boundingbox(larvae::DecoratedLarvae) = Meshes.boundingbox(map(Meshes.boundingbox, larvae.larvae))
 
 function setmouseevents!(scene, plot::DecoratedLarvae, ctrl; consume=false)
-    on(async_latest(events(scene).mousebutton)) do mb
+    on(events(scene).mousebutton) do mb
         consumed = consume
         if mb.button == Mouse.left && mb.action == Mouse.release
             larva_ix = plot.hovered_larva[]
-- 
GitLab