The context menu entry is gone; dragging replaces it entirely. The drop target is the view under the pointer, not the active tab, so the same gesture works for scenes and for container templates. While dragging, an outline shows the footprint the object will have plus a crosshair on its origin, turning red when the drop would be refused. Preview and command share one function (placementRejection), so the outline cannot promise something the drop then rejects. A left-press used to select the list row immediately. Since the container tab follows the selection, it switched to the very container being dragged and every drop would have nested it inside itself. The list now selects on release without a drag: picking something up is not the same as choosing it.
17 lines
793 B
TypeScript
17 lines
793 B
TypeScript
import type { Asset } from './Asset';
|
|
import { isPlaceableType } from './AssetTypes';
|
|
import { containerReaches } from './container';
|
|
import type { ObjectHolder, Project } from './Project';
|
|
|
|
/**
|
|
* Why `asset` cannot be placed into `holder`, or '' when it can. A drag needs the answer while
|
|
* it hovers, `PlaceAssetCommand` needs it at the drop; both ask here so the preview cannot
|
|
* promise a placement the command then refuses.
|
|
*/
|
|
export function placementRejection(project: Project, holder: ObjectHolder, asset: Asset): string {
|
|
if (!isPlaceableType(asset.type)) return 'A scene cannot be placed into a scene';
|
|
if (asset.type === 'container' && containerReaches(project, asset, holder.id))
|
|
return `${asset.name} cannot contain ${holder.name}: that nests forever`;
|
|
return '';
|
|
}
|