diff options
-rw-r--r-- | Animator.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Animator.hs b/Animator.hs index e51fc50..fb0e3f6 100644 --- a/Animator.hs +++ b/Animator.hs | |||
@@ -55,6 +55,15 @@ addAnimation tm action = do | |||
55 | writeIORef (tmCallback tm) (Just cb) | 55 | writeIORef (tmCallback tm) (Just cb) |
56 | return k | 56 | return k |
57 | 57 | ||
58 | |||
59 | removeAnimation :: Animator -> Int -> IO () | ||
60 | removeAnimation tm k = do | ||
61 | m <- atomicModifyIORef' (tmAnimations tm) $ \m -> (IntMap.delete k m, m) | ||
62 | when (IntMap.null $ IntMap.delete k m) $ do | ||
63 | mcb <- readIORef (tmCallback tm) | ||
64 | mapM_ (widgetRemoveTickCallback $ tmWidget tm) mcb | ||
65 | writeIORef (tmCallback tm) Nothing | ||
66 | |||
58 | tick :: Animator -> Widget -> FrameClock -> IO Bool | 67 | tick :: Animator -> Widget -> FrameClock -> IO Bool |
59 | tick tm widget clock = widgetGetWindow widget >>= \case | 68 | tick tm widget clock = widgetGetWindow widget >>= \case |
60 | Nothing -> do writeIORef (tmCallback tm) Nothing | 69 | Nothing -> do writeIORef (tmCallback tm) Nothing |