// Copyright (c) 2022 Robin Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of // the Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import React from 'react'; import { Theme } from '@mui/material/styles'; import { WithStyles } from '@mui/styles'; import createStyles from '@mui/styles/createStyles'; import withStyles from '@mui/styles/withStyles'; import Button from '@mui/material/Button'; import DialogEx from './DialogEx'; import MuiDialogTitle from '@mui/material/DialogTitle'; import MuiDialogContent from '@mui/material/DialogContent'; import MuiDialogActions from '@mui/material/DialogActions'; import IconButton from '@mui/material/IconButton'; import CloseIcon from '@mui/icons-material/Close'; import Typography from '@mui/material/Typography'; import Grid from '@mui/material/Grid'; import { PiPedalModelFactory } from "./PiPedalModel"; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import { UiPlugin, UiControl } from './Lv2Plugin'; import PluginIcon from './PluginIcon'; import { Remark } from 'react-remark'; /* eslint-disable */ let myTheme: Theme| undefined = undefined; const styles = (theme: Theme) => { myTheme = theme; return createStyles({ root: { margin: 0, padding: theme.spacing(2), }, closeButton: { position: 'absolute', right: theme.spacing(1), top: theme.spacing(1), color: theme.palette.grey[500], }, icon: { fill: theme.palette.text.primary, opacity: 0.6 } }); }; export interface PluginInfoDialogTitleProps extends WithStyles { id: string; children: React.ReactNode; onClose: () => void; } // const PluginInfoDialogTitle = withStyles(styles)((props: PluginInfoDialogTitleProps) => { // const { children, classes, onClose, ...other } = props; // return ( // //
// //
//
// {children} //
// handleClose()} // style={{ flex: "0 0 auto" }}> // // //
// ); // }); const PluginInfoDialogContent = withStyles((theme: Theme) => ({ root: { padding: theme.spacing(2), }, }))(MuiDialogContent); const PluginInfoDialogActions = withStyles((theme: Theme) => ({ root: { margin: 0, padding: theme.spacing(1), }, }))(MuiDialogActions); export interface PluginInfoProps extends WithStyles { plugin_uri: string } function displayChannelCount(count: number): string { if (count === 0) return "None"; if (count === 1) return "Mono"; if (count === 2) return "Stereo"; return count + " channels"; } function ioDescription(plugin: UiPlugin): string { let result = "Input: " + displayChannelCount(plugin.audio_inputs) + ". Output: " + displayChannelCount(plugin.audio_outputs) + "."; if (plugin.has_midi_input) { if (plugin.has_midi_output) { result += " Midi in/out."; } else { result += " Midi in."; } } else { if (plugin.has_midi_output) { result += "Midi out."; } } return result; } // function makeParagraphs(description: string) { // description = description.replaceAll('\r', ''); // description = description.replaceAll('\n\n', '\r'); // description = description.replaceAll('\n', ' '); // let paragraphs: string[] = description.split('\r'); // return ( //
// {paragraphs.map((para) => ( // // {para} // // ))} //
// ); // } function makeControls(controls: UiControl[]) { let hasComments = false; for (let i = 0; i < controls.length; ++i) { if (controls[i].comment !== "") { hasComments = true; break; } } if (hasComments) { let trs: React.ReactElement[] = []; for (let i = 0; i < controls.length; ++i) { let control = controls[i]; if (!(control.not_on_gui) && control.is_input) trs.push(( {control.name} {control.comment} )); } return ( { trs }
); } else { return ( { controls.map((control) => ( {control.name} )) } ); } } const PluginInfoDialog = withStyles(styles)((props: PluginInfoProps) => { let model = PiPedalModelFactory.getInstance(); const [open, setOpen] = React.useState(false); let { classes, plugin_uri } = props; const handleClickOpen = () => { setOpen(true); }; const handleClose = () => { setOpen(false); }; let uri = props.plugin_uri; let visible = true; if (uri === null || uri === "") { visible = false; } if (!visible) { return (
); }; let plugin = model.getUiPlugin(plugin_uri); if (plugin === null) { return (
) } return (
{open && (
{plugin.name}
handleClose()} style={{ flex: "0 0 auto" }} size="large">
Author:  {(plugin.author_homepage !== "") ? ( {plugin.author_name} ) : ( {plugin.author_name} ) }
{ioDescription(plugin)}
Controls: { makeControls(plugin.controls) } Description:
{ // return ( //

// ); return ( ); }, code: (props: any) => { return (); }, a: (props: any) => { return ( ); } }, }} > {plugin.description}

)}
); }); export default PluginInfoDialog;