diff options
author | Joe Crayne <joe@jerkface.net> | 2019-07-18 17:21:25 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-07-18 17:21:25 -0400 |
commit | 592575a2745233fcb865fe27768bdab54ce74bbd (patch) | |
tree | ca79007a6895fb5d06c9d0ab710a7215aca68e99 | |
parent | 8d6b40691b6b40687c2a461baa0c22d14e125224 (diff) |
Animator: function to remove an animation.
-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 |