From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 1ACD21FF0B4 for ; Fri, 27 Nov 2026 17:13:43 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id D406A217E5; Fri, 27 Nov 2026 17:13:13 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 29/38] widget: charts: map: draw a shadow below connections Date: Fri, 27 Nov 2026 17:12:26 +0100 Message-ID: <20261127161241.3713494-30-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261127161241.3713494-1-d.csapak@proxmox.com> References: <20261127161241.3713494-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.251 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: S4AJKAF54KRHTQ55UPMALL2EM7UCJ53O X-Message-ID-Hash: S4AJKAF54KRHTQ55UPMALL2EM7UCJ53O X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: with a flatter curve below each connection. That lets the connection look like it rises above the map, and makes it easier to tell connections from the lines of the map. Its look is defined in the style sheet with the new 'pwt-map-connection-shadow' class. Signed-off-by: Dominik Csapak --- src/widget/charts/map/mod.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/widget/charts/map/mod.rs b/src/widget/charts/map/mod.rs index 54e7f81..b35eb5a 100644 --- a/src/widget/charts/map/mod.rs +++ b/src/widget/charts/map/mod.rs @@ -120,6 +120,10 @@ const CONNECTION_CURVATURE: f64 = 0.2; // the length of the arrow head of a connection in screen pixels const CONNECTION_ARROW_SIZE: f64 = 9.0; +// How much the shadow of a connection bends, relative to the connection itself. The flatter +// shadow lets the connection look like it rises above the map. +const CONNECTION_SHADOW_BEND: f64 = 0.5; + // A pulse of a connection is drawn as several parts on top of each other that all end at its // head. These are their lengths relative to the whole pulse. The style sheet draws the shorter // ones stronger, so that the pulse fades out towards its tail. @@ -221,6 +225,22 @@ impl ConnectionCurve { ) } + /// The SVG path commands for the shadow of the curve, which bends less than the curve. + fn shadow_path(&self) -> String { + let bend = |from_chord: f64, control: f64| { + from_chord + (control - from_chord) * CONNECTION_SHADOW_BEND + }; + format!( + "M{:.2},{:.2} Q{:.2},{:.2} {:.2},{:.2}", + self.start.x, + self.start.y, + bend((self.start.x + self.end.x) / 2.0, self.control.x), + bend((self.start.y + self.end.y) / 2.0, self.control.y), + self.end.x, + self.end.y + ) + } + /// The point halfway along the curve. fn center(&self) -> Coordinates { Coordinates { @@ -594,7 +614,11 @@ impl MapComp { }; let path = curve.path(); - let mut connection = Group::new().class("pwt-map-connection"); + let mut connection = Group::new().class("pwt-map-connection").with_child( + Path::new() + .class("pwt-map-connection-shadow") + .d(curve.shadow_path()), + ); let tooltips: Vec = group .connections @@ -1176,6 +1200,9 @@ mod test { "M50.00,100.00 L45.00,90.00 L55.00,90.00 Z" ); assert_eq!(curve.span(), (50.0f64 * 50.0 + 100.0 * 100.0).sqrt()); + + // the shadow bends less, so its control point is closer to the middle of both ends + assert_eq!(curve.shadow_path(), "M0.00,0.00 Q37.50,25.00 50.00,100.00"); } #[test] -- 2.47.3