First commit.
This commit is contained in:
@@ -0,0 +1,262 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { createStyles, withStyles, WithStyles, Theme } from '@material-ui/core/styles';
|
||||
import { PiPedalModel, PiPedalModelFactory } from './PiPedalModel';
|
||||
import { UiPlugin } from './Lv2Plugin';
|
||||
import {
|
||||
PedalBoard, PedalBoardSplitItem, ControlValue,
|
||||
} from './PedalBoard';
|
||||
import PluginControl from './PluginControl';
|
||||
import ResizeResponsiveComponent from './ResizeResponsiveComponent';
|
||||
import VuMeter from './VuMeter';
|
||||
import { SplitAbControl, SplitTypeControl, SplitMixControl, SplitPanLeftControl,SplitVolLeftControl,SplitPanRightControl,SplitVolRightControl } from './SplitUiControls';
|
||||
|
||||
|
||||
const LANDSCAPE_HEIGHT_BREAK = 500;
|
||||
|
||||
const styles = (theme: Theme) => createStyles({
|
||||
frame: {
|
||||
display: "block",
|
||||
position: "relative",
|
||||
flexDirection: "row",
|
||||
flexWrap: "nowrap",
|
||||
paddingTop: "8px",
|
||||
paddingBottom: "0px",
|
||||
height: "100%",
|
||||
overflowX: "auto",
|
||||
overflowY: "auto"
|
||||
},
|
||||
vuMeterL: {
|
||||
position: "fixed",
|
||||
paddingLeft: 12,
|
||||
paddingRight: 12,
|
||||
left: 0,
|
||||
background: "white",
|
||||
zIndex: 3
|
||||
|
||||
},
|
||||
vuMeterR: {
|
||||
position: "fixed",
|
||||
right: 0,
|
||||
marginRight: 22,
|
||||
paddingLeft: 12,
|
||||
background: "white",
|
||||
zIndex: 3
|
||||
|
||||
},
|
||||
vuMeterRLandscape: {
|
||||
position: "fixed",
|
||||
right: 0,
|
||||
paddingRight: 22,
|
||||
paddingLeft: 12,
|
||||
background: "white",
|
||||
zIndex: 3
|
||||
|
||||
},
|
||||
|
||||
normalGrid: {
|
||||
position: "relative",
|
||||
paddingLeft: 40,
|
||||
paddingRight: 40,
|
||||
flex: "1 1 auto",
|
||||
display: "flex", flexDirection: "row", flexWrap: "wrap",
|
||||
justifyContent: "flex-start", alignItems: "flex_start"
|
||||
|
||||
},
|
||||
landscapeGrid: {
|
||||
paddingLeft: 40,
|
||||
marginRight: 40,
|
||||
display: "inline-flex", flexDirection: "row", flexWrap: "nowrap",
|
||||
justifyContent: "flex-start", alignItems: "flex_start",
|
||||
height: "100%"
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
interface SplitControlViewProps extends WithStyles<typeof styles> {
|
||||
theme: Theme;
|
||||
instanceId: number;
|
||||
item: PedalBoardSplitItem;
|
||||
};
|
||||
type SplitControlViewState = {
|
||||
landscapeGrid: boolean;
|
||||
};
|
||||
|
||||
const SplitControlView =
|
||||
withStyles(styles, { withTheme: true })(
|
||||
class extends ResizeResponsiveComponent<SplitControlViewProps, SplitControlViewState>
|
||||
{
|
||||
model: PiPedalModel;
|
||||
|
||||
constructor(props: SplitControlViewProps) {
|
||||
super(props);
|
||||
this.model = PiPedalModelFactory.getInstance();
|
||||
|
||||
this.state = {
|
||||
landscapeGrid: false
|
||||
|
||||
}
|
||||
this.onPedalBoardChanged = this.onPedalBoardChanged.bind(this);
|
||||
this.onValueChanged = this.onValueChanged.bind(this);
|
||||
this.onPreviewChange = this.onPreviewChange.bind(this);
|
||||
}
|
||||
|
||||
|
||||
onPreviewChange(key: string, value: number): void {
|
||||
this.model.previewPedalBoardValue(this.props.instanceId, key, value);
|
||||
}
|
||||
|
||||
onValueChanged(key: string, value: number): void {
|
||||
this.model.setPedalBoardControlValue(this.props.instanceId, key, value);
|
||||
}
|
||||
|
||||
onPedalBoardChanged(value?: PedalBoard) {
|
||||
//let item = this.model.pedalBoard.get().maybeGetItem(this.props.instanceId);
|
||||
//this.setState({ pedalBoardItem: item });
|
||||
}
|
||||
|
||||
|
||||
componentDidMount() {
|
||||
super.componentDidMount();
|
||||
this.model.pedalBoard.addOnChangedHandler(this.onPedalBoardChanged);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this.model.pedalBoard.removeOnChangedHandler(this.onPedalBoardChanged);
|
||||
super.componentWillUnmount();
|
||||
}
|
||||
|
||||
renderControl(plugin: UiPlugin, controlValue: ControlValue): ReactNode {
|
||||
return (
|
||||
<div style={{ display: "flex", flexDirection: "row", alignContent: "center", justifyContent: "flex-start" }}>
|
||||
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
onWindowSizeChanged(width: number, height: number): void {
|
||||
this.setState({ landscapeGrid: height < LANDSCAPE_HEIGHT_BREAK });
|
||||
}
|
||||
|
||||
|
||||
render(): ReactNode {
|
||||
let classes = this.props.classes;
|
||||
let pedalBoardItem = this.model.pedalBoard.get().getItem(this.props.instanceId);
|
||||
|
||||
if (!pedalBoardItem)
|
||||
return (<div className={classes.frame}></div>);
|
||||
|
||||
|
||||
let gridClass = this.state.landscapeGrid ? classes.landscapeGrid : classes.normalGrid;
|
||||
let vuMeterRClass = this.state.landscapeGrid ? classes.vuMeterRLandscape : classes.vuMeterR;
|
||||
let typeValue = pedalBoardItem.getControl(PedalBoardSplitItem.TYPE_KEY);
|
||||
let mixValue = pedalBoardItem.getControl(PedalBoardSplitItem.MIX_KEY);
|
||||
let selectValue = pedalBoardItem.getControl(PedalBoardSplitItem.SELECT_KEY);
|
||||
let panLValue = pedalBoardItem.getControl(PedalBoardSplitItem.PANL_KEY);
|
||||
let volumeLValue = pedalBoardItem.getControl(PedalBoardSplitItem.VOLL_KEY);
|
||||
let panRValue = pedalBoardItem.getControl(PedalBoardSplitItem.PANR_KEY);
|
||||
let volumeRValue = pedalBoardItem.getControl(PedalBoardSplitItem.VOLR_KEY);
|
||||
|
||||
return (
|
||||
<div className={classes.frame}>
|
||||
<div className={classes.vuMeterL}>
|
||||
<VuMeter display="input" instanceId={pedalBoardItem.instanceId} />
|
||||
</div>
|
||||
<div className={vuMeterRClass}>
|
||||
<VuMeter display="output" instanceId={pedalBoardItem.instanceId} />
|
||||
</div>
|
||||
<div className={gridClass} >
|
||||
<div style={{ flex: "0 0 auto" }}>
|
||||
<PluginControl uiControl={SplitTypeControl} value={typeValue.value}
|
||||
onChange={(value: number) => { this.onValueChanged(typeValue.key, value) }}
|
||||
onPreviewChange={(value: number) => { this.onPreviewChange(typeValue.key, value) }}
|
||||
requestIMEEdit={(uiControl, value) => { }}
|
||||
|
||||
/>
|
||||
</div>
|
||||
{
|
||||
typeValue.value === 0 && (
|
||||
<div style={{ flex: "0 0 auto" }}>
|
||||
<PluginControl uiControl={SplitAbControl} value={selectValue.value}
|
||||
onChange={(value: number) => { this.onValueChanged(selectValue.key, value) }}
|
||||
onPreviewChange={(value: number) => { this.onPreviewChange(selectValue.key, value) }}
|
||||
requestIMEEdit={(uiControl, value) => { }}
|
||||
|
||||
/>
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
{
|
||||
typeValue.value === 1 && (
|
||||
<div style={{ flex: "0 0 auto" }}>
|
||||
<PluginControl uiControl={SplitMixControl} value={mixValue.value}
|
||||
onChange={(value: number) => { this.onValueChanged(mixValue.key, value) }}
|
||||
onPreviewChange={(value: number) => { this.onPreviewChange(mixValue.key, value) }}
|
||||
requestIMEEdit={(uiControl, value) => { }}
|
||||
|
||||
/>
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
{
|
||||
typeValue.value === 2 && (
|
||||
<div style={{ flex: "0 0 auto" }}>
|
||||
<PluginControl uiControl={SplitPanLeftControl} value={panLValue.value}
|
||||
onChange={(value: number) => { this.onValueChanged(panLValue.key, value) }}
|
||||
onPreviewChange={(value: number) => { this.onPreviewChange(panLValue.key, value) }}
|
||||
requestIMEEdit={(uiControl, value) => { }}
|
||||
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
{
|
||||
typeValue.value === 2 && (
|
||||
<div style={{ flex: "0 0 auto" }}>
|
||||
<PluginControl uiControl={SplitVolLeftControl} value={volumeLValue.value}
|
||||
onChange={(value: number) => { this.onValueChanged(volumeLValue.key, value) }}
|
||||
onPreviewChange={(value: number) => { this.onPreviewChange(volumeLValue.key, value) }}
|
||||
requestIMEEdit={(uiControl, value) => { }}
|
||||
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
{
|
||||
typeValue.value === 2 && (
|
||||
<div style={{ flex: "0 0 auto" }}>
|
||||
<PluginControl uiControl={SplitPanRightControl} value={panRValue.value}
|
||||
onChange={(value: number) => { this.onValueChanged(panRValue.key, value) }}
|
||||
onPreviewChange={(value: number) => { this.onPreviewChange(panRValue.key, value) }}
|
||||
requestIMEEdit={(uiControl, value) => { }}
|
||||
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
{
|
||||
typeValue.value === 2 && (
|
||||
<div style={{ flex: "0 0 auto" }}>
|
||||
<PluginControl uiControl={SplitVolRightControl} value={volumeRValue.value}
|
||||
onChange={(value: number) => { this.onValueChanged(volumeRValue.key, value) }}
|
||||
onPreviewChange={(value: number) => { this.onPreviewChange(volumeRValue.key, value) }}
|
||||
requestIMEEdit={(uiControl, value) => { }}
|
||||
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
</div>
|
||||
</div >
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
export default SplitControlView;
|
||||
|
||||
Reference in New Issue
Block a user