import { useStore, toolTips, ToolTip } from './useStore' import { extrudeSketch, sketchOnExtrudedFace } from './lang/modifyAst' import { getNodePathFromSourceRange } from './lang/queryAst' import { HorzVert } from './components/Toolbar/HorzVert' import { RemoveConstrainingValues } from './components/Toolbar/RemoveConstrainingValues' import { EqualLength } from './components/Toolbar/EqualLength' import { EqualAngle } from './components/Toolbar/EqualAngle' import { Intersect } from './components/Toolbar/Intersect' import { SetHorzVertDistance } from './components/Toolbar/SetHorzVertDistance' import { SetAngleLength } from './components/Toolbar/setAngleLength' import { SetAbsDistance } from './components/Toolbar/SetAbsDistance' import { SetAngleBetween } from './components/Toolbar/SetAngleBetween' import { Fragment, WheelEvent, useRef } from 'react' 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' import { ActionIcon } from 'components/ActionIcon' import { engineCommandManager } from './lang/std/engineConnection' export const sketchButtonClassnames = { background: 'bg-chalkboard-100 group-hover:bg-chalkboard-90 hover:bg-chalkboard-90 dark:bg-fern-20 dark:group-hover:bg-fern-10 dark:hover:bg-fern-10 group-disabled:bg-chalkboard-50 dark:group-disabled:bg-chalkboard-60 group-hover:group-disabled:bg-chalkboard-50 dark:group-hover:group-disabled:bg-chalkboard-50', icon: 'text-fern-20 h-auto group-hover:text-fern-10 hover:text-fern-10 dark:text-chalkboard-100 dark:group-hover:text-chalkboard-100 dark:hover:text-chalkboard-100 group-disabled:bg-chalkboard-60 hover:group-disabled:text-inherit', } const sketchFnLabels: Record = { sketch_line: 'Line', line: 'Line', move: 'Move', angledLine: 'Angled Line', angledLineThatIntersects: 'Angled Line That Intersects', angledLineOfXLength: 'Angled Line Of X Length', angledLineOfYLength: 'Angled Line Of Y Length', angledLineToX: 'Angled Line To X', angledLineToY: 'Angled Line To Y', lineTo: 'Line to Point', xLine: 'Horizontal Line', yLine: 'Vertical Line', xLineTo: 'Horizontal Line to Point', yLineTo: 'Vertical Line to Point', } export const Toolbar = () => { const { setGuiMode, guiMode, selectionRanges, ast, updateAst, programMemory, executeAst, } = useStore((s) => ({ guiMode: s.guiMode, setGuiMode: s.setGuiMode, selectionRanges: s.selectionRanges, ast: s.ast, updateAst: s.updateAst, programMemory: s.programMemory, executeAst: s.executeAst, })) useAppMode() const toolbarButtonsRef = useRef(null) function handleToolbarButtonsWheelEvent(ev: WheelEvent) { const span = toolbarButtonsRef.current if (!span) { return } span.scrollLeft = span.scrollLeft += ev.deltaY } function ToolbarButtons({ className }: React.HTMLAttributes) { return ( {guiMode.mode === 'default' && ( )} {guiMode.mode === 'canEditExtrude' && ( )} {guiMode.mode === 'canEditSketch' && ( )} {guiMode.mode === 'canEditSketch' && ( <> )} {guiMode.mode === 'sketch' && ( )} {toolTips .filter( // (sketchFnName) => !['angledLineThatIntersects'].includes(sketchFnName) (sketchFnName) => ['sketch_line', 'move'].includes(sketchFnName) ) .map((sketchFnName) => { if ( guiMode.mode !== 'sketch' || !('isTooltip' in guiMode || guiMode.sketchMode === 'sketchEdit') ) return null return ( ) })} ) } return (
{guiMode.mode === 'sketch' ? '2D' : '3D'}

You're in {guiMode.mode === 'sketch' ? '2D' : '3D'}

) }