feat(panels): wire the Effects section "+" to add a drop shadow

The property panel's 效果 header drew a "+" icon that did nothing.
Add a PropertyPanelAction::AddEffect, emit its hit rect over the
icon in the layout walker (no paint/layout change — the icon was
already painted), and dispatch it in both hosts to
Document::add_drop_shadow_to_selected. Clicking "+" now appends a
drop shadow that renders + persists.
This commit is contained in:
Kayshen-X 2026-05-16 10:00:50 +08:00
parent c0f503e99a
commit 542ec113d1
4 changed files with 17 additions and 0 deletions

View file

@ -53,6 +53,9 @@ pub enum PropertyPanelAction {
/// User clicked anywhere in the Export section — host queues
/// `FileAction::ExportImage` so the picker dialog opens.
OpenExportDialog,
/// User clicked the Effects section's "+" — host appends a
/// default drop shadow to the selected node.
AddEffect,
}
/// Per-NodeKind toggles for which property-panel sections render.

View file

@ -241,6 +241,14 @@ pub fn action_button_rects_with_fill_picker(
}
if visible.effects {
// Mirrors paint_effects_section: header + 8 px filler.
// The header's "+" button (drawn by
// `paint_section_label_with_add` at the right edge) maps to
// an `AddEffect` action.
let plus = Rect {
origin: Point2D::new(x0 + w - PAD_X - 22.0, y),
size: Point2D::new(28.0, SECTION_HEADER_HEIGHT),
};
out.push((PropertyPanelAction::AddEffect, plus));
y += SECTION_HEADER_HEIGHT;
y += 8.0;
y += SECTION_GAP;

View file

@ -46,6 +46,9 @@ impl WidgetHostNative {
self.document.ui.pending_file_action =
Some(openpencil_shell_core::document::FileAction::ExportImage);
}
A::AddEffect => {
self.document.add_drop_shadow_to_selected();
}
}
}

View file

@ -174,6 +174,9 @@ fn apply_property_action_impl(
A::OpenColorPicker(target) => {
let _ = document.open_color_picker(target, 0.0);
}
A::AddEffect => {
document.add_drop_shadow_to_selected();
}
}
}