11import { type FC , type MouseEvent , useCallback , useEffect , useState } from 'react' ;
2+ import { toast } from 'react-toastify' ;
23import { Actor } from 'xstate' ;
34import { COLOR_LIST } from '../App.consts' ;
45import { HtmlEvent , type Layer } from '../App.types' ;
@@ -7,10 +8,10 @@ import {exportEntitiesToLocalStorage} from '../helpers/import-export-handlers/ex
78import { exportEntitiesToPdfFile } from '../helpers/import-export-handlers/export-entities-to-pdf.ts' ;
89import { exportEntitiesToPngFile } from '../helpers/import-export-handlers/export-entities-to-png' ;
910import { exportEntitiesToSvgFile } from '../helpers/import-export-handlers/export-entities-to-svg' ;
11+ import { importEntitiesFromDxfFile } from '../helpers/import-export-handlers/import-entities-from-dxf' ;
1012import { importEntitiesFromJsonFile } from '../helpers/import-export-handlers/import-entities-from-json' ;
1113import { importEntitiesFromSvgFile } from '../helpers/import-export-handlers/import-entities-from-svg.ts' ;
1214import { importImageFromFile } from '../helpers/import-export-handlers/import-image-from-file' ;
13- import { importEntitiesFromDxfFile } from '../helpers/import-export-handlers/import-entities-from-dxf' ;
1415import { times } from '../helpers/times' ;
1516import {
1617 getActiveLayerId ,
@@ -36,7 +37,7 @@ import {TOOL_STATE_MACHINES} from '../tools/tool.consts';
3637import { ActorEvent } from '../tools/tool.types' ;
3738import { Button } from './Button.tsx' ;
3839import { DropdownButton } from './DropdownButton.tsx' ;
39- import { IconName } from './Icon/Icon.tsx' ;
40+ import { Icon , IconName } from './Icon/Icon.tsx' ;
4041import { LayerManager } from './LayerManager.tsx' ;
4142
4243export const Toolbar : FC = ( ) => {
@@ -219,6 +220,18 @@ export const Toolbar: FC = () => {
219220 active = { activeToolLocal === Tool . ARRAY }
220221 label = "Array copy"
221222 />
223+ < Button
224+ className = "w-full"
225+ title = "Create polyline lines and arcs"
226+ dataId = "pedit-button"
227+ iconComponent = { < Icon name = { IconName . HomeAlt } className = "rotate-270" /> }
228+ onClick = { ( evt ) => {
229+ evt . stopPropagation ( ) ;
230+ handleToolClick ( Tool . PEDIT ) ;
231+ } }
232+ active = { activeToolLocal === Tool . PEDIT }
233+ label = "Polyline edit"
234+ />
222235
223236 < Button
224237 className = "mt-2 w-full"
@@ -458,8 +471,20 @@ export const Toolbar: FC = () => {
458471 } }
459472 active = { zoom === screenZoomLocal }
460473 />
461- // TODO add option to fit screen
462474 ) ) }
475+ < Button
476+ key = "zoom-level--fit"
477+ title = "Zoom fit screen"
478+ dataId = "zoom-level-fit-button"
479+ label = "Fit screen"
480+ style = { { width : 'calc(60% - 2px)' , padding : '8px' } }
481+ onClick = { ( evt ) => {
482+ evt . stopPropagation ( ) ;
483+ getScreenCanvasDrawController ( ) . zoomToFitScreen ( ) ;
484+ setScreenZoomLocal ( getScreenCanvasDrawController ( ) . getScreenScale ( ) ) ;
485+ } }
486+ active = { false }
487+ />
463488 </ DropdownButton >
464489
465490 < Button
@@ -470,6 +495,7 @@ export const Toolbar: FC = () => {
470495 onClick = { async ( evt ) => {
471496 evt . stopPropagation ( ) ;
472497 await exportEntitiesToLocalStorage ( ) ;
498+ toast . success ( 'Saved' ) ;
473499 } }
474500 label = "Save drawing"
475501 />
0 commit comments