diff --git a/theatre/studio/src/UIRoot/UIRoot.tsx b/theatre/studio/src/UIRoot/UIRoot.tsx index b1f323d..2e980ed 100644 --- a/theatre/studio/src/UIRoot/UIRoot.tsx +++ b/theatre/studio/src/UIRoot/UIRoot.tsx @@ -1,7 +1,7 @@ import getStudio from '@theatre/studio/getStudio' -import {usePrism} from '@theatre/dataverse-react' +import {usePrism, useVal} from '@theatre/dataverse-react' import {val} from '@theatre/dataverse' -import React from 'react' +import React, {useEffect} from 'react' import styled, {createGlobalStyle, StyleSheetManager} from 'styled-components' import PanelsRoot from './PanelsRoot' import ProvideTheme from './ProvideTheme' @@ -39,6 +39,11 @@ const Container = styled(PointerEventsHandler)` right: 0px; bottom: 0px; left: 0px; + + &.invisible { + pointer-events: none !important; + opacity: 0; + } ` const PortalLayer = styled.div` @@ -61,12 +66,20 @@ export default function UIRoot() { ) useKeyboardShortcuts() + const visiblityState = useVal(studio.atomP.ahistoric.visibilityState) + useEffect(() => { + if (visiblityState === 'everythingIsHidden') { + console.warn( + `Theatre Studio is hidden. You can restore it by either hitting alt/option+\` or calling studio.ui.restore()`, + ) + } + return () => {} + }, [visiblityState]) + const inside = usePrism(() => { const visiblityState = val(studio.atomP.ahistoric.visibilityState) - const initialised = val(studio.atomP.ephemeral.initialised) - const shouldShowPanels = visiblityState === 'everythingIsVisible' - const shouldShowGlobalToolbar = visiblityState !== 'everythingIsHidden' + const initialised = val(studio.atomP.ephemeral.initialised) return !initialised ? null : ( - + - {shouldShowGlobalToolbar && } - {shouldShowPanels && } + {} + {} diff --git a/theatre/studio/src/UIRoot/useKeyboardShortcuts.ts b/theatre/studio/src/UIRoot/useKeyboardShortcuts.ts index b95ca3c..635ca6c 100644 --- a/theatre/studio/src/UIRoot/useKeyboardShortcuts.ts +++ b/theatre/studio/src/UIRoot/useKeyboardShortcuts.ts @@ -43,6 +43,14 @@ export default function useKeyboardShortcuts() { } else { return } + } else if (e.code === 'Backquote' && e.altKey) { + studio.transaction(({stateEditors, drafts}) => { + stateEditors.studio.ahistoric.setVisibilityState( + drafts.ahistoric.visibilityState === 'everythingIsHidden' + ? 'everythingIsVisible' + : 'everythingIsHidden', + ) + }) } else { return } diff --git a/theatre/studio/src/store/stateEditors.ts b/theatre/studio/src/store/stateEditors.ts index 28ce658..2ad51af 100644 --- a/theatre/studio/src/store/stateEditors.ts +++ b/theatre/studio/src/store/stateEditors.ts @@ -30,6 +30,7 @@ import type { OutlineSelectable, OutlineSelectionState, PanelPosition, + StudioAhistoricState, } from './types' import {uniq} from 'lodash-es' import { @@ -306,6 +307,11 @@ namespace stateEditors { } } export namespace ahistoric { + export function setVisibilityState( + visibilityState: StudioAhistoricState['visibilityState'], + ) { + drafts().ahistoric.visibilityState = visibilityState + } export namespace projects { export namespace stateByProjectId { export function _ensure(p: ProjectAddress) { diff --git a/theatre/studio/src/uiComponents/PointerEventsHandler.tsx b/theatre/studio/src/uiComponents/PointerEventsHandler.tsx index 06a0113..dbd97e4 100644 --- a/theatre/studio/src/uiComponents/PointerEventsHandler.tsx +++ b/theatre/studio/src/uiComponents/PointerEventsHandler.tsx @@ -56,7 +56,10 @@ const PointerEventsHandler: React.FC<{ return ( - + {props.children}