diff --git a/src/App.tsx b/src/App.tsx index 490acb072..a24dc0d67 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -73,7 +73,9 @@ export function App() { streamDimensions, setIsExecuting, defferedCode, + guiMode, } = useStore((s) => ({ + guiMode: s.guiMode, addLog: s.addLog, defferedCode: s.defferedCode, setCode: s.setCode, @@ -181,7 +183,18 @@ export function App() { const asyncWrap = async () => { try { if (!defferedCode) { - setAst(null) + setAst({ + start: 0, + end: 0, + body: [], + nonCodeMeta: { + noneCodeNodes: {}, + start: null, + }, + }) + setProgramMemory({ root: {} }) + engineCommandManager.endSession() + engineCommandManager.startNewSession() return } const _ast = await asyncParser(defferedCode) @@ -223,6 +236,9 @@ export function App() { const { artifactMap, sourceRangeMap } = await engineCommandManager.waitForAllCommands() setIsExecuting(false) + if (programMemory !== undefined) { + setProgramMemory(programMemory) + } setArtifactMap({ artifactMap, sourceRangeMap }) const unSubHover = engineCommandManager.subscribeToUnreliable({ @@ -251,9 +267,6 @@ export function App() { }, }) unsubFn.push(unSubHover, unSubClick) - if (programMemory !== undefined) { - setProgramMemory(programMemory) - } setError() } catch (e: any) { @@ -287,8 +300,42 @@ export function App() { }) const newCmdId = uuidv4() - - if (buttonDownInStream !== undefined) { + if (buttonDownInStream === undefined) { + if ( + guiMode.mode === 'sketch' && + guiMode.sketchMode === ('sketch_line' as any) + ) { + debounceSocketSend({ + type: 'modeling_cmd_req', + cmd_id: newCmdId, + cmd: { + type: 'mouse_move', + window: { x, y }, + }, + }) + } else if ( + guiMode.mode === 'sketch' && + guiMode.sketchMode === ('move' as any) + ) { + debounceSocketSend({ + type: 'modeling_cmd_req', + cmd_id: newCmdId, + cmd: { + type: 'handle_mouse_drag_move', + window: { x, y }, + }, + }) + } else { + debounceSocketSend({ + type: 'modeling_cmd_req', + cmd: { + type: 'highlight_set_entity', + selected_at_window: { x, y }, + }, + cmd_id: newCmdId, + }) + } + } else { const interactionGuards = cameraMouseDragGuards[cameraControls] let interaction: CameraDragInteractionType_type @@ -301,6 +348,7 @@ export function App() { } else if (interactionGuards.zoom.dragCallback(eWithButton)) { interaction = 'zoom' } else { + console.log('none') return } @@ -313,15 +361,6 @@ export function App() { }, cmd_id: newCmdId, }) - } else { - debounceSocketSend({ - type: 'modeling_cmd_req', - cmd: { - type: 'highlight_set_entity', - selected_at_window: { x, y }, - }, - cmd_id: newCmdId, - }) } } @@ -350,11 +389,11 @@ export function App() { paneOpacity } defaultSize={{ - width: '400px', + width: '550px', height: 'auto', }} minWidth={200} - maxWidth={600} + maxWidth={800} minHeight={'auto'} maxHeight={'auto'} handleClasses={{ diff --git a/src/Toolbar.tsx b/src/Toolbar.tsx index 85b4c7512..5442c199a 100644 --- a/src/Toolbar.tsx +++ b/src/Toolbar.tsx @@ -1,4 +1,4 @@ -import { useStore, toolTips } from './useStore' +import { useStore, toolTips, Selections } from './useStore' import { extrudeSketch, sketchOnExtrudedFace } from './lang/modifyAst' import { getNodePathFromSourceRange } from './lang/queryAst' import { HorzVert } from './components/Toolbar/HorzVert' @@ -15,6 +15,8 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faSearch, faX } from '@fortawesome/free-solid-svg-icons' import { Popover, Transition } from '@headlessui/react' import styles from './Toolbar.module.css' +import { v4 as uuidv4 } from 'uuid' +import { useAppMode } from 'hooks/useAppMode' export const Toolbar = () => { const { @@ -24,6 +26,7 @@ export const Toolbar = () => { ast, updateAst, programMemory, + engineCommandManager, } = useStore((s) => ({ guiMode: s.guiMode, setGuiMode: s.setGuiMode, @@ -31,7 +34,9 @@ export const Toolbar = () => { ast: s.ast, updateAst: s.updateAst, programMemory: s.programMemory, + engineCommandManager: s.engineCommandManager, })) + useAppMode() useEffect(() => { console.log('guiMode', guiMode) @@ -39,7 +44,7 @@ export const Toolbar = () => { function ToolbarButtons() { return ( - <> + {guiMode.mode === 'default' && ( )} - {(guiMode.mode === 'canEditSketch' || false) && ( + {guiMode.mode === 'canEditSketch' && ( )} {toolTips .filter( // (sketchFnName) => !['angledLineThatIntersects'].includes(sketchFnName) - (sketchFnName) => ['line'].includes(sketchFnName) + (sketchFnName) => ['sketch_line', 'move'].includes(sketchFnName) ) .map((sketchFnName) => { if ( @@ -143,7 +166,18 @@ export const Toolbar = () => { return (