Place assets by dragging them from the panel into the view

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.
This commit is contained in:
root committed 2026-09-09 13:09:13 +02:00
1 parent 14562cf157
commit 75d377af39
18 files changed
+545 -77

No files matched your search

+22 -4
View File
@@ -2,7 +2,18 @@ import { Graphics } from 'pixi.js';
import type { ContainerAsset } from '../../core/model/Asset';
import type { Vec2 } from '../../core/model/Properties';
import { findAsset, listContainers } from '../../core/model/Project';
import { Button, Dropdown, HStack, Label, Menu, type MenuItem, Spacer, Theme, VStack } from '../../ui';
import {
activeDrag,
Button,
Dropdown,
HStack,
Label,
Menu,
type MenuItem,
Spacer,
Theme,
VStack,
} from '../../ui';
import type { EditorState } from '../state';
import { ContainerCanvas } from './ContainerCanvas';
@@ -63,7 +74,12 @@ export class ContainerEditor extends VStack {
this.refresh();
}
/** Middle of the view – where the Assets panel drops what is placed into this template. */
/** The pending drop of an asset dragged over the template (test hook). */
dropInfo(): ReturnType<ContainerCanvas['dropInfo']> {
return this.canvas.dropInfo();
}
/** Middle of the view – where a double-click in the Assets panel places into this template. */
worldCenter(): Vec2 {
return this.canvas.worldCenter();
}
@@ -81,8 +97,10 @@ export class ContainerEditor extends VStack {
private followSelection(): void {
const id = this.state.selectedContainerId;
// Null merely means "the selection is about something else"; the tab keeps its subject.
if (id) this.canvas.show(id);
// A dragged row selects on release, and whether that lands before or after the drop is up
// to Pixi's event order. Following it in between would swap the tab to the very container
// being dragged, which would then nest in itself, so the target stays put while a drag runs.
if (id && !activeDrag()) this.canvas.show(id);
this.refresh();
}