Luce packages
LuceLuce BaseLuciaOS

dymokomi/luced-3d

Source of release 0.11.6

0.11.6 / tests / editor / timeline_buttons_tests.luc

## The timeline's icon buttons: Play backwards plays toward the start and
## wraps round the range while looping; each play button shows pause while
## it plays; resting the pointer on a button shows its command and shortcut.
from app import Luce3D
from luce_ui.ui import Event
from luce_window.input import EventKind
import timeline_commands
import time

pub func timeline_buttons_tests() -> unit!:
    let editor = Luce3D()
    let w = editor.workspace
    let pane = editor.panels.timeline
    let actions = editor.panels.actions
    timeline_commands.set_range(w, 1.0, 10.0)
    timeline_commands.set_frame(w, 3.0)
    # Backwards, a frame each 1/24 s: from 3 down past 1, round to 10.
    actions.play_backwards.trigger()
    assert(pane.bar.playing and pane.bar.backwards and actions.play_backwards.is_checked() and not actions.play.is_checked())
    pane.poll()
    time.sleep(0.2)
    pane.poll()
    assert(w.network.frame > 3.0 or w.network.frame < 3.0)
    let seen = w.network.frame
    assert(seen >= 7.0 or seen <= 2.0)
    # Play turns round instead of stopping; Play again stops.
    actions.play.trigger()
    assert(pane.bar.playing and not pane.bar.backwards and actions.play.is_checked())
    actions.play.trigger()
    assert(not pane.bar.playing and not actions.play.is_checked())
    # A rest on the Play button: its tooltip, the command and its key.
    editor.app.layout(1400.0, 900.0)
    let at = editor.panels.timeline.button_bounds(3)
    editor.app.dispatch(Event(kind = EventKind.pointer_moved, x = at.x + at.width * 0.5, y = at.y + at.height * 0.5))
    pane.poll()
    time.sleep(0.6)
    pane.poll()
    assert(pane.tooltip_text() == "Play")
    editor.close()
    print("PASS timeline buttons: play backwards wraps, pause while playing, tooltips with the command")