UX improvements

* When clicking on empty space in the snapshot editor, the selection reverts to the sheet containing the scene
This commit is contained in:
Aria Minaei 2021-07-31 15:10:08 +02:00
parent 0f7d918547
commit 2daa270879
6 changed files with 65 additions and 43 deletions

View file

@ -10,11 +10,19 @@ import type {$IntentionalAny} from '@theatre/shared/utils/types'
const publicAPIToPrivateAPIMap = new WeakMap()
export function privateAPI(pub: IProject): Project
export function privateAPI(pub: ISheet): Sheet
export function privateAPI(pub: ISheetObject<$IntentionalAny>): SheetObject
export function privateAPI(pub: ISequence): Sequence
export function privateAPI(pub: {}): unknown {
export function privateAPI<
P extends IProject | ISheet | ISheetObject<$IntentionalAny> | ISequence,
>(
pub: P,
): P extends IProject
? Project
: P extends ISheet
? Sheet
: P extends ISheetObject<$IntentionalAny>
? SheetObject
: P extends ISequence
? Sequence
: never {
return publicAPIToPrivateAPIMap.get(pub)
}

View file

@ -5,6 +5,8 @@ import type Sequence from './Sequence'
import type {IPlaybackDirection, IPlaybackRange} from './Sequence'
export interface ISequence {
readonly type: 'Theatre_Sequence_PublicAPI'
/**
* Starts playback of a sequence.
* Returns a promise that either resolves to true when the playback completes,
@ -24,7 +26,11 @@ export interface ISequence {
time: number
}
export default class TheatreSequence {
export default class TheatreSequence implements ISequence {
get type(): 'Theatre_Sequence_PublicAPI' {
return 'Theatre_Sequence_PublicAPI'
}
/**
* @internal
*/

View file

@ -1,4 +1,4 @@
import type {ISheetObject} from '@theatre/core'
import type {ISheet, ISheetObject} from '@theatre/core'
import studioTicker from '@theatre/studio/studioTicker'
import type {IDerivation, Pointer} from '@theatre/dataverse'
import {prism} from '@theatre/dataverse'
@ -7,7 +7,10 @@ import type {$FixMe, $IntentionalAny, VoidFn} from '@theatre/shared/utils/types'
import type {IScrub} from '@theatre/studio/Scrub'
import type {Studio} from '@theatre/studio/Studio'
import {isSheetObjectPublicAPI} from '@theatre/shared/instanceTypes'
import {
isSheetObjectPublicAPI,
isSheetPublicAPI,
} from '@theatre/shared/instanceTypes'
import {getOutlineSelection} from './selectors'
import type SheetObject from '@theatre/core/sheetObjects/SheetObject'
import getStudio from './getStudio'
@ -68,7 +71,7 @@ export interface IStudio {
scrub(): IScrub
debouncedScrub(threshhold: number): Pick<IScrub, 'capture'>
__experimental_setSelection(selection: Array<ISheetObject>): void
__experimental_setSelection(selection: Array<ISheetObject | ISheet>): void
__experimental_onSelectionChange(
fn: (s: Array<ISheetObject>) => void,
): VoidFunction
@ -136,9 +139,9 @@ export default class TheatreStudio implements IStudio {
return this._getSelectionDerivation().getValue()
}
__experimental_setSelection(selection: Array<ISheetObject>): void {
__experimental_setSelection(selection: Array<ISheetObject | ISheet>): void {
const sanitizedSelection = [...selection]
.filter((s) => isSheetObjectPublicAPI(s))
.filter((s) => isSheetObjectPublicAPI(s) || isSheetPublicAPI(s))
.map((s) => getStudio().corePrivateAPI!(s))
getStudio().transaction(({stateEditors}) => {