-
Notifications
You must be signed in to change notification settings - Fork 11
/
InspectorBeat.tsx
74 lines (66 loc) · 1.97 KB
/
InspectorBeat.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { BoolParam } from './BoolParam';
import { InspectorHeader } from './InspectorHeader';
import { InspectorHr } from './InspectorHr';
import { InspectorItem } from './InspectorItem';
import { NumberParam } from './NumberParam';
import { useSelector } from '../states/store';
import React from 'react';
// == component ====================================================================================
const InspectorBeat = (): JSX.Element | null => {
const { automaton, guiSettings } = useSelector( ( state ) => ( {
automaton: state.automaton.instance,
guiSettings: state.automaton.guiSettings
} ) );
return ( automaton && <>
<InspectorHeader text="Beat" />
<InspectorHr />
<InspectorItem
name="BPM"
description="Beat per minute of the song."
>
<NumberParam
type="float"
value={ guiSettings.bpm }
onChange={ ( value ) => {
automaton.setGUISettings( 'bpm', Math.max( 0.0, value ) );
} }
/>
</InspectorItem>
<InspectorItem
name="Beat Offset"
description="Offset from the beginning of the beat."
>
<NumberParam
type="float"
value={ guiSettings.beatOffset }
onChange={ ( value ) => {
automaton.setGUISettings( 'beatOffset', value );
} }
/>
</InspectorItem>
<InspectorHr />
<InspectorItem
name="Beat Snap"
description="Make items snap to the beat."
>
<BoolParam
value={ guiSettings.snapBeatActive }
onChange={ ( value ) => {
automaton.setGUISettings( 'snapBeatActive', value );
} }
/>
</InspectorItem>
<InspectorItem
name="Use Beat in GUI"
description="Show beat instead of time in GUI."
>
<BoolParam
value={ guiSettings.useBeatInGUI }
onChange={ ( value ) => {
automaton.setGUISettings( 'useBeatInGUI', value );
} }
/>
</InspectorItem>
</> ) ?? null;
};
export { InspectorBeat };