]> git.decadent.org.uk Git - ion3.git/blob - ioncore/ioncore_tabnum.lua
Update cfg_kludge_flash for Flash 10
[ion3.git] / ioncore / ioncore_tabnum.lua
1 --
2 -- ion/share/ioncore_tabnum.lua -- Ioncore tab numbering support
3 -- 
4 -- Copyright (c) Tuomo Valkonen 2007-2009.
5 --
6 -- See the included file LICENSE for details.
7 --
8
9 ioncore.tabnum={}
10
11 local framestate={}
12
13 local function do_show(frame)
14     if obj_exists(frame) then
15         frame:set_grattr('numbered', 'set')
16         framestate[frame]='set'
17     else
18         framestate[frame]=nil
19     end
20 end
21
22 --DOC
23 -- Show tab numbers on \var{frame}, clearing them when submap
24 -- grab is released the next time. If \var{delay} is given, in
25 -- milliseconds, the numbers are not actually displayed until this
26 -- time has passed.
27 function ioncore.tabnum.show(frame, delay)
28     if delay and delay>0 then
29         local tmr=ioncore.create_timer()
30         framestate[frame]=tmr
31         tmr:set(delay, function() do_show(frame) end)
32     else
33         do_show(frame)
34     end
35 end
36
37 --DOC
38 -- Clear all tab numbers set by \fnref{ioncore.tabnum.show}.
39 function ioncore.tabnum.clear()
40     local st=framestate
41     framestate={}
42     
43     for f, s in pairs(st) do
44         if s=='set' then
45             if obj_exists(f) then
46                 f:set_grattr('numbered', 'unset')
47             end
48         elseif obj_is(s, "WTimer") then
49             s:reset()
50         end
51     end
52 end
53
54 ioncore.get_hook("ioncore_submap_ungrab_hook")
55     :add(ioncore.tabnum.clear)