import { State } from '@hookstate/core'; import { Downgraded } from '@hookstate/core'; import { SpringRef } from 'react-spring'; import InputAdornment from '@material-ui/core/InputAdornment'; import TextField from '@material-ui/core/TextField'; import TimecodeInput from '../components/timeinput'; import { globalState, slideAPIprops } from '../pages/editor'; import { TimedVideoPlayer } from '../pages/present'; import { anySlide, delaySlide, loopBeginSlide, loopSlide, speedChangeSlide } from '../timeline'; interface SlidePropertiesPropsType { slide: State; global: State; player: TimedVideoPlayer; api: SpringRef; select: (slides: anySlide[]) => void; } export default function SlideProperties(props: SlidePropertiesPropsType) { function updateProp(key: keyof slideType, springKey?: keyof slideAPIprops) { return (newValue: any) => { // TODO: better typing here props.slide[key as keyof State].set(newValue); var sel = [props.slide.attach(Downgraded).value]; if (springKey) props.api.start({ [springKey]: newValue }); if (sel[0].type == 'loop') { sel.push(new loopBeginSlide(sel[0] as loopSlide)); sel.reverse(); } props.select(sel); props.global.update.refreshLiveTimeline.value(); }; } function SlideTimestamp() { return ; } return
Properties {{ 'default': <> , 'loop': <> ).frame.get() - (props.slide as State).beginFrame.get()} onChange={e => { var len = Number(e.target.value); var frame = (props.slide as State).beginFrame.get() + len; updateProp('frame', 'frame')(frame); }} />
).beginFrame.get()} update={updateProp('beginFrame', 'begin')} player={props.player} /> ).frame.get()} update={updateProp('frame', 'frame')} player={props.player} /> , 'delay': <>
}} InputLabelProps={{ shrink: true }} value={(props.slide as State).delay.get() / 1000} onChange={event => updateProp('delay')(Number(event.target.value) * 1000)} /> , 'speedChange': <>
}} value={(props.slide as State).newFramerate.get()} onChange={event => updateProp('newFramerate')(Number(event.target.value))} />
).newFramerate.get() / props.player.project.video.framerate} onChange={event => updateProp('newFramerate')( Number(event.target.value) * props.player.project.video.framerate, )} /> , }[props.slide.value.type]}
; }