|
1 | 1 | import Box from '@mui/material/Box'; |
2 | | -import Grid from '@mui/material/Grid2'; |
| 2 | +import Stack from '@mui/material/Stack'; |
| 3 | +import Drawer from '@mui/material/Drawer'; |
| 4 | +import IconButton from '@mui/material/IconButton'; |
| 5 | +import MenuIcon from '@mui/icons-material/Menu'; |
3 | 6 | import ConfigBar from './ConfigBar'; |
4 | 7 | import Visualizer from './Visualizer'; |
5 | 8 | import { Graph } from './Graph'; |
@@ -27,6 +30,7 @@ function App() { |
27 | 30 | const [showCellId, setShowCellId] = React.useState<boolean>(false); |
28 | 31 | const [showGoals, setShowGoals] = React.useState<boolean>(true); |
29 | 32 | const [showGoalVectors, setShowGoalVectors] = React.useState<boolean>(false); |
| 33 | + const [drawerOpen, setDrawerOpen] = React.useState<boolean>(true); |
30 | 34 |
|
31 | 35 | const handleSkipBackward = () => { |
32 | 36 | if (pixiAppRef.current?.skipBackward) { |
@@ -60,54 +64,77 @@ function App() { |
60 | 64 |
|
61 | 65 | return ( |
62 | 66 | <StrictMode> |
63 | | - <Box sx={{ flexGrow: 1 }}> |
64 | | - <Grid container spacing={0}> |
65 | | - <Grid size="grow"> |
66 | | - <Visualizer |
67 | | - pixiAppRef = {pixiAppRef} |
68 | | - graph={graph} |
69 | | - solution={solution} |
70 | | - playAnimation={playAnimation} |
71 | | - stepSize={stepSize} |
72 | | - loopAnimation={loopAnimation} |
73 | | - showAgentId={showAgentId} |
74 | | - tracePaths={tracePaths} |
75 | | - setCanScreenshot={setCanScreenshot} |
76 | | - showCellId={showCellId} |
77 | | - showGoals={showGoals} |
78 | | - showGoalVectors={showGoalVectors} |
79 | | - /> |
80 | | - </Grid> |
81 | | - <Grid size={4}> |
82 | | - <ConfigBar |
83 | | - graph={graph} |
84 | | - onGraphChange={useCallback((graph: Graph | null) => setGraph(graph), [])} |
85 | | - onSolutionChange={useCallback((solution: Solution | null) => setSolution(solution), [])} |
86 | | - playAnimation={playAnimation} |
87 | | - onPlayAnimationChange={setPlayAnimation} |
88 | | - onSkipBackward={handleSkipBackward} |
89 | | - onSkipForward={handleSkipForward} |
90 | | - onRestart={handleRestart} |
91 | | - stepSize={stepSize} |
92 | | - onStepSizeChange={setStepSize} |
93 | | - loopAnimation={loopAnimation} |
94 | | - onLoopAnimationChange={setLoopAnimation} |
95 | | - onFitView={handleFitView} |
96 | | - showAgentId={showAgentId} |
97 | | - onShowAgentIdChange={setShowAgentId} |
98 | | - tracePaths={tracePaths} |
99 | | - onTracePathsChange={setTracePaths} |
100 | | - canScreenshot={canScreenshot} |
101 | | - takeScreenshot={handleTakeScreenshot} |
102 | | - showCellId={showCellId} |
103 | | - setShowCellId={setShowCellId} |
104 | | - showGoals={showGoals} |
105 | | - setShowGoals={setShowGoals} |
106 | | - showGoalVectors={showGoalVectors} |
107 | | - setShowGoalVectors={setShowGoalVectors} |
108 | | - /> |
109 | | - </Grid> |
110 | | - </Grid> |
| 67 | + <Box sx={{ flexGrow: 1, position: 'relative' }}> |
| 68 | + <IconButton |
| 69 | + onClick={() => setDrawerOpen(true)} |
| 70 | + sx={{ |
| 71 | + position: 'absolute', |
| 72 | + top: 16, |
| 73 | + right: 16, |
| 74 | + zIndex: 1000, |
| 75 | + backgroundColor: 'background.paper', |
| 76 | + '&:hover': { |
| 77 | + backgroundColor: 'action.hover', |
| 78 | + }, |
| 79 | + }} |
| 80 | + > |
| 81 | + <MenuIcon /> |
| 82 | + </IconButton> |
| 83 | + <Stack sx={{ height: '100vh' }}> |
| 84 | + <Visualizer |
| 85 | + pixiAppRef = {pixiAppRef} |
| 86 | + graph={graph} |
| 87 | + solution={solution} |
| 88 | + playAnimation={playAnimation} |
| 89 | + stepSize={stepSize} |
| 90 | + loopAnimation={loopAnimation} |
| 91 | + showAgentId={showAgentId} |
| 92 | + tracePaths={tracePaths} |
| 93 | + setCanScreenshot={setCanScreenshot} |
| 94 | + showCellId={showCellId} |
| 95 | + showGoals={showGoals} |
| 96 | + showGoalVectors={showGoalVectors} |
| 97 | + /> |
| 98 | + </Stack> |
| 99 | + <Drawer |
| 100 | + anchor="right" |
| 101 | + open={drawerOpen} |
| 102 | + onClose={() => setDrawerOpen(false)} |
| 103 | + keepMounted |
| 104 | + sx={{ |
| 105 | + '& .MuiDrawer-paper': { |
| 106 | + width: 400, |
| 107 | + }, |
| 108 | + }} |
| 109 | + > |
| 110 | + <ConfigBar |
| 111 | + graph={graph} |
| 112 | + onGraphChange={useCallback((graph: Graph | null) => setGraph(graph), [])} |
| 113 | + onSolutionChange={useCallback((solution: Solution | null) => setSolution(solution), [])} |
| 114 | + playAnimation={playAnimation} |
| 115 | + onPlayAnimationChange={setPlayAnimation} |
| 116 | + onSkipBackward={handleSkipBackward} |
| 117 | + onSkipForward={handleSkipForward} |
| 118 | + onRestart={handleRestart} |
| 119 | + stepSize={stepSize} |
| 120 | + onStepSizeChange={setStepSize} |
| 121 | + loopAnimation={loopAnimation} |
| 122 | + onLoopAnimationChange={setLoopAnimation} |
| 123 | + onFitView={handleFitView} |
| 124 | + showAgentId={showAgentId} |
| 125 | + onShowAgentIdChange={setShowAgentId} |
| 126 | + tracePaths={tracePaths} |
| 127 | + onTracePathsChange={setTracePaths} |
| 128 | + canScreenshot={canScreenshot} |
| 129 | + takeScreenshot={handleTakeScreenshot} |
| 130 | + showCellId={showCellId} |
| 131 | + setShowCellId={setShowCellId} |
| 132 | + showGoals={showGoals} |
| 133 | + setShowGoals={setShowGoals} |
| 134 | + showGoalVectors={showGoalVectors} |
| 135 | + setShowGoalVectors={setShowGoalVectors} |
| 136 | + /> |
| 137 | + </Drawer> |
111 | 138 | </Box> |
112 | 139 | </StrictMode> |
113 | 140 | ); |
|
0 commit comments