Phase 3.5a: place imported images on the canvas (image-filled rect)

Replaces the DCEL "not yet supported" stubs so importing/dropping an image actually
puts it in the vector scene.

- AddShapeAction gains an `image_fill` + `AddShapeAction::image_rect(...)` constructor:
  a borderless rectangle (invisible edges) whose enclosed region is paint-bucketed and
  tagged with an image asset id. The renderer already prioritises `image_fill`.
- Direct import (auto_place_asset): an imported image is placed centered on the canvas
  at native size on a vector layer.
- Drag from the asset library onto the stage: image-filled rect at the drop point
  (centered), native size, using the asset's dimensions.

Next: SetImageFillAction + an Info-Panel image-fill picker for existing shapes; then
3.5b container persistence.
This commit is contained in:
Skyler Lehmkuhl
2026-06-21 00:22:17 -04:00
parent aea26f6192
commit 6c9fcb1921
3 changed files with 87 additions and 21 deletions
@@ -4921,15 +4921,22 @@ impl EditorApp {
// Add clip instance or shape to the target layer
if let Some(layer_id) = target_layer_id {
// For images, create a shape with image fill instead of a clip instance
// For images, create an image-filled rectangle on the (vector) layer,
// centered on the canvas at native size.
if asset_info.clip_type == panes::DragClipType::Image {
// Get image dimensions
let (width, height) = asset_info.dimensions.unwrap_or((100.0, 100.0));
// TODO: Image fills on DCEL faces are a separate feature.
// For now, just log a message.
let _ = (layer_id, width, height);
eprintln!("Image drop to canvas not yet supported with DCEL backend");
let (img_w, img_h) = asset_info.dimensions.unwrap_or((100.0, 100.0));
let (doc_w, doc_h) = {
let d = self.action_executor.document();
(d.width as f64, d.height as f64)
};
let x = (doc_w - img_w) / 2.0;
let y = (doc_h - img_h) / 2.0;
let action = lightningbeam_core::actions::AddShapeAction::image_rect(
layer_id, self.playback_time, x, y, img_w, img_h, asset_info.clip_id,
);
if let Err(e) = self.action_executor.execute(Box::new(action)) {
eprintln!("Failed to place image: {}", e);
}
} else {
// For clips, create a clip instance
let mut clip_instance = ClipInstance::new(asset_info.clip_id)
@@ -11780,9 +11780,18 @@ impl PaneRenderer for StagePane {
if let Some(layer_id) = target_layer_id {
// For images, create a shape with image fill instead of a clip instance
if dragging.clip_type == DragClipType::Image {
// TODO: Image fills on DCEL faces are a separate feature.
let _ = (layer_id, world_pos);
eprintln!("Image drag to stage not yet supported with DCEL backend");
// Image-filled rectangle at the drop point (centered), native size.
let dims = shared.action_executor.document()
.get_image_asset(&dragging.clip_id)
.map(|a| (a.width as f64, a.height as f64));
if let Some((img_w, img_h)) = dims {
let x = world_pos.x as f64 - img_w / 2.0;
let y = world_pos.y as f64 - img_h / 2.0;
let action = lightningbeam_core::actions::AddShapeAction::image_rect(
layer_id, drop_time, x, y, img_w, img_h, dragging.clip_id,
);
let _ = shared.action_executor.execute(Box::new(action));
}
} else if dragging.clip_type == DragClipType::Effect {
// Handle effect drops specially
// Get effect definition from registry or document