summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-07-18 17:21:25 -0400
committerJoe Crayne <joe@jerkface.net>2019-07-18 17:21:25 -0400
commit592575a2745233fcb865fe27768bdab54ce74bbd (patch)
treeca79007a6895fb5d06c9d0ab710a7215aca68e99
parent8d6b40691b6b40687c2a461baa0c22d14e125224 (diff)
Animator: function to remove an animation.
-rw-r--r--Animator.hs9
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
59removeAnimation :: Animator -> Int -> IO ()
60removeAnimation 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
58tick :: Animator -> Widget -> FrameClock -> IO Bool 67tick :: Animator -> Widget -> FrameClock -> IO Bool
59tick tm widget clock = widgetGetWindow widget >>= \case 68tick tm widget clock = widgetGetWindow widget >>= \case
60 Nothing -> do writeIORef (tmCallback tm) Nothing 69 Nothing -> do writeIORef (tmCallback tm) Nothing