ad9b3fd14013658f779227a881afc69a7f66a317
imsequencer-luau
Timeline/sequencer widget for imgui-luau: items as slots on a frame timeline, drag slots and their edges, scrub the current frame, zoom/scroll with the scrollbar, add/delete/duplicate items, expandable rows with custom drawing.
Luau port of ImSequencer from ImGuizmo for imgui-luau (GitHub). Mirrors: git.bug.tools / GitHub. The example embeds imcurveedit-luau in expanded rows, like upstream's.
Usage
local G = require(ReplicatedStorage.ImGui)
local ImSequencer = require(ReplicatedStorage.ImSequencer)(G)
-- SequenceInterface (C++ ImSequencer::SequenceInterface): any table with these methods, indices 1-based
local Seq = { Items = { { s = 10, e = 30 }, { s = 20, e = 60 } } }
function Seq:GetFrameMin() return 0 end
function Seq:GetFrameMax() return 100 end
function Seq:GetItemCount() return #self.Items end
function Seq:Get(i) local it = self.Items[i]; return it.s, it.e, 1, 0xFFAA8080 end -- start, end, type, color
function Seq:Set(i, s, e) self.Items[i].s, self.Items[i].e = s, e end -- [Port] see below
-- optional: GetItemLabel(i), GetItemTypeCount(), GetItemTypeName(t), Add(t), Del(i), Duplicate(i), Copy(), Paste(),
-- GetCustomHeight(i), DoubleClick(i), CustomDraw(...), CustomDrawCompact(...), BeginEdit(i), EndEdit(), GetCollapseFmt()
local currentFrame, expanded, selectedEntry, firstFrame = 0, true, -1, 0
local flags = bit32.bor(ImSequencer.SEQUENCER_EDIT_STARTEND, ImSequencer.SEQUENCER_CHANGE_FRAME)
-- each frame, inside a window:
local selected
selected, currentFrame, expanded, selectedEntry, firstFrame =
ImSequencer.Sequencer(Seq, currentFrame, expanded, selectedEntry, firstFrame, flags)
[Port] differences:
- The pointer arguments (
int* currentFrame,bool* expanded,int* selectedEntry,int* firstFrame) are passed by value and returned after the result; passnilwhere C++ passesNULL(e.g.expanded = nilhides the expand button). Get(index, int** start, int** end, int* type, unsigned* color)becomesGet(index) -> start, end, type, color, and writes through theint**become a requiredSet(index, start, end).- Item and type indices are 1-based,
selectedEntry-1= none.CustomDraw/CustomDrawCompactreceiveImRects. - As upstream, zoom and drag state is shared by all sequencers (C++ function statics).
Full example (upstream's MySequence + RampEdit): examples/roblox/main.client.luau. The module is plain Lua 5.1 and also loads on LÖVE.
Development
git clone --recursive https://git.bug.tools/bug/imsequencer-luau.git
bash tools/test.sh # tests/t_*.luau in the core's Roblox mock + the Roblox example (uses tools/imcurveedit)
Upstream source (pinned) is in tools/upstream/; port-specific comments are tagged [Port].
License
MIT, see LICENSE (upstream copyright kept).
Languages
C++
47%
Lua
42.4%
Luau
6.8%
Shell
3.8%