From caf0e2fd12e80bab6ddd93f2729d7ef1863b52ea Mon Sep 17 00:00:00 2001 From: salam dalloul Date: Mon, 8 Jul 2024 15:18:22 +0300 Subject: [PATCH] add missing viewer icons + add tooltips + 3D viewer settings popover --- .../viewers/ThreeD/CustomFormControlLabel.tsx | 57 +++++++++ .../viewers/ThreeD/SceneControls.tsx | 117 ++++++++++++++++-- .../src/components/viewers/TwoD/TwoDMenu.tsx | 58 +++++---- 3 files changed, 202 insertions(+), 30 deletions(-) create mode 100644 applications/visualizer/frontend/src/components/viewers/ThreeD/CustomFormControlLabel.tsx diff --git a/applications/visualizer/frontend/src/components/viewers/ThreeD/CustomFormControlLabel.tsx b/applications/visualizer/frontend/src/components/viewers/ThreeD/CustomFormControlLabel.tsx new file mode 100644 index 00000000..5fab2296 --- /dev/null +++ b/applications/visualizer/frontend/src/components/viewers/ThreeD/CustomFormControlLabel.tsx @@ -0,0 +1,57 @@ +import { FormControlLabel, Tooltip, Box, Stack, Typography } from '@mui/material'; +import CustomSwitch from "../../ViewerContainer/CustomSwitch.tsx"; +import HelpOutlineIcon from '@mui/icons-material/HelpOutline'; +import {vars} from "../../../theme/variables.ts"; // Adjust the import path as needed + +const {gray50, gray600, gray400B} = vars +const CustomFormControlLabel = ({ label, tooltipTitle, helpText }) => { + return ( + } + sx={{ + width: '100%', + p: '.5rem .5rem .5rem .5rem', + margin: 0, + alignItems: "baseline", + '&:hover': { + background: gray50, + borderRadius: '.5rem', + }, + "& .MuiFormControlLabel-label": { + width: "100%", + }, + "& .MuiIconButton-root": { + borderRadius: '.25rem', + } + }} + label={ + + + + {label} + + + + + + + } + value={undefined} + /> + ); +}; + +export default CustomFormControlLabel; diff --git a/applications/visualizer/frontend/src/components/viewers/ThreeD/SceneControls.tsx b/applications/visualizer/frontend/src/components/viewers/ThreeD/SceneControls.tsx index 2fbc4203..08a18b01 100644 --- a/applications/visualizer/frontend/src/components/viewers/ThreeD/SceneControls.tsx +++ b/applications/visualizer/frontend/src/components/viewers/ThreeD/SceneControls.tsx @@ -1,10 +1,39 @@ import ZoomInIcon from '@mui/icons-material/ZoomIn'; import ZoomOutIcon from '@mui/icons-material/ZoomOut'; -import {Box, Divider, IconButton} from "@mui/material"; -import {GridOffOutlined, GridOnOutlined, HomeOutlined} from "@mui/icons-material"; +import { + Box, + Divider, + IconButton, Popover, Typography, +} from "@mui/material"; +import { + GetAppOutlined, + HomeOutlined, + PlayArrowOutlined, + RadioButtonCheckedOutlined, + SettingsOutlined, + TonalityOutlined +} from "@mui/icons-material"; +import Tooltip from "@mui/material/Tooltip"; +import {useState} from "react"; +import {vars} from "../../../theme/variables.ts"; +import CustomFormControlLabel from "./CustomFormControlLabel.tsx"; + +const {gray500} = vars function SceneControls({cameraControlRef, isWireframe, setIsWireframe}) { - return ( + const [anchorEl, setAnchorEl] = useState(null); + + const open = Boolean(anchorEl); + const id = open ? 'settings-popover' : undefined; + const handleOpenSettings = (event) => { + setAnchorEl(event.currentTarget); + }; + + const handleCloseSettings = () => { + setAnchorEl(null); + }; + + return ( + + + + + + + + 3D viewer settings + + + + + + + + setIsWireframe(!isWireframe)}> + + + + + { cameraControlRef.current?.zoom(cameraControlRef.current?._camera.zoom / 2, true); }} title="Zoom In"> + + { cameraControlRef.current?.reset(true); }} title="Reset"> + + { cameraControlRef.current?.zoom(-cameraControlRef.current?._camera.zoom / 2, true); }} title="Zoom Out"> + - setIsWireframe(!isWireframe)} - title="Toggle Wireframe" - > - {isWireframe ? : } + + + + + + + + + + + + + + ); } diff --git a/applications/visualizer/frontend/src/components/viewers/TwoD/TwoDMenu.tsx b/applications/visualizer/frontend/src/components/viewers/TwoD/TwoDMenu.tsx index 83ae8840..ade83321 100644 --- a/applications/visualizer/frontend/src/components/viewers/TwoD/TwoDMenu.tsx +++ b/applications/visualizer/frontend/src/components/viewers/TwoD/TwoDMenu.tsx @@ -17,10 +17,15 @@ import ZoomOutIcon from '@mui/icons-material/ZoomOut'; import { GRAPH_LAYOUTS, ZOOM_DELTA } from "../../../settings/twoDSettings.tsx"; import { applyLayout } from "../../../helpers/twoD/twoDHelpers.ts"; import { ColoringOptions } from "../../../helpers/twoD/coloringStrategy/ColoringStrategy.ts"; -import {FileDownloadOutlined, HomeOutlined, TuneOutlined, VisibilityOutlined} from "@mui/icons-material"; +import { + GetAppOutlined, + HomeOutlined, + TuneOutlined, + VisibilityOutlined +} from "@mui/icons-material"; import { vars } from "../../../theme/variables.ts"; import QuantityInput from "./NumberInput.tsx"; -import CustomSwitch from "../../ViewerContainer/CustomSwitch.tsx"; // Import NumberInput component +import CustomSwitch from "../../ViewerContainer/CustomSwitch.tsx"; const { gray500 } = vars; @@ -102,20 +107,27 @@ const TwoDMenu = ({ padding: '0.25rem', zIndex: 1, }}> - - - - - - - - - + + + + + + + + + + + + + + + - - - - + + + + + - - - + + + + + - - - + + + + + ); };