From 542ec113d15948221287b8223cc4f93ebda45e4e Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Sat, 16 May 2026 10:00:50 +0800 Subject: [PATCH] feat(panels): wire the Effects section "+" to add a drop shadow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../openpencil-shell-core/src/widgets/property_panel.rs | 3 +++ .../src/widgets/property_panel_layout.rs | 8 ++++++++ .../src/widget_host/property_dispatch.rs | 3 +++ crates/openpencil-shell-web/src/widget_host.rs | 3 +++ 4 files changed, 17 insertions(+) diff --git a/crates/openpencil-shell-core/src/widgets/property_panel.rs b/crates/openpencil-shell-core/src/widgets/property_panel.rs index ced8eccd2..5323bb31e 100644 --- a/crates/openpencil-shell-core/src/widgets/property_panel.rs +++ b/crates/openpencil-shell-core/src/widgets/property_panel.rs @@ -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. diff --git a/crates/openpencil-shell-core/src/widgets/property_panel_layout.rs b/crates/openpencil-shell-core/src/widgets/property_panel_layout.rs index 6c34c4c5b..c629db2ee 100644 --- a/crates/openpencil-shell-core/src/widgets/property_panel_layout.rs +++ b/crates/openpencil-shell-core/src/widgets/property_panel_layout.rs @@ -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; diff --git a/crates/openpencil-shell-native/src/widget_host/property_dispatch.rs b/crates/openpencil-shell-native/src/widget_host/property_dispatch.rs index 80a190cde..ec2a29f86 100644 --- a/crates/openpencil-shell-native/src/widget_host/property_dispatch.rs +++ b/crates/openpencil-shell-native/src/widget_host/property_dispatch.rs @@ -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(); + } } } diff --git a/crates/openpencil-shell-web/src/widget_host.rs b/crates/openpencil-shell-web/src/widget_host.rs index 4fe73e6af..afeca0d82 100644 --- a/crates/openpencil-shell-web/src/widget_host.rs +++ b/crates/openpencil-shell-web/src/widget_host.rs @@ -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(); + } } }