Disable view control menu items and gizmo clicks conditionally (#5537)

* Disable view control menu items and gizmo clicks conditionally

* Actually just turn off all mouse events, moves too

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* fix gizmo flickering

* fmt

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

* Add test step for disabling gizmo in sketch mode

* Use grayscale to indicate disabled state?

@max-mrgrsk feel free to discard if you prefer the opacity, I don't have
a strong opinion at the moment.

* A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores)

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: max-mrgrsk <156543465+max-mrgrsk@users.noreply.github.com>
This commit is contained in:
Frank Noirot
2025-02-28 17:27:35 -05:00
committed by GitHub
parent f238f3882b
commit 9ce591a1a1
10 changed files with 78 additions and 18 deletions

View File

@ -10,9 +10,14 @@ import { AxisNames, VIEW_NAMES_SEMANTIC } from 'lib/constants'
import { useModelingContext } from 'hooks/useModelingContext'
import { useMemo } from 'react'
import { sceneInfra } from 'lib/singletons'
import { useSettings } from 'machines/appMachine'
export function useViewControlMenuItems() {
const { send: modelingSend } = useModelingContext()
const { state: modelingState, send: modelingSend } = useModelingContext()
const settings = useSettings()
const shouldLockView =
modelingState.matches('Sketch') &&
!settings.app.allowOrbitInSketchMode.current
const menuItems = useMemo(
() => [
...Object.entries(VIEW_NAMES_SEMANTIC).map(([axisName, axisSemantic]) => (
@ -23,6 +28,7 @@ export function useViewControlMenuItems() {
.updateCameraToAxis(axisName as AxisNames)
.catch(reportRejection)
}}
disabled={shouldLockView}
>
{axisSemantic} view
</ContextMenuItem>
@ -32,6 +38,7 @@ export function useViewControlMenuItems() {
onClick={() => {
sceneInfra.camControls.resetCameraPosition().catch(reportRejection)
}}
disabled={shouldLockView}
>
Reset view
</ContextMenuItem>,
@ -39,13 +46,14 @@ export function useViewControlMenuItems() {
onClick={() => {
modelingSend({ type: 'Center camera on selection' })
}}
disabled={shouldLockView}
>
Center view on selection
</ContextMenuItem>,
<ContextMenuDivider />,
<ContextMenuItemRefresh />,
],
[VIEW_NAMES_SEMANTIC]
[VIEW_NAMES_SEMANTIC, shouldLockView]
)
return menuItems
}