From 67a012f7bfa95f1c419e55eb4b25a75da9dada9f Mon Sep 17 00:00:00 2001 From: Deyan Nenov Date: Tue, 17 Jan 2023 21:52:20 +0000 Subject: [PATCH 1/2] DYN-4308 Input and output port menu is tiny when zoomed in and gets bigger when zoomed out - redo of the Y position calculation --- .../ViewModels/Core/PortViewModel.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs index aa84dbece45..48a800d0949 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Windows; using System.Windows.Controls.Primitives; using System.Windows.Media; @@ -347,7 +347,10 @@ private CustomPopupPlacement[] PlaceAutocompletePopup(Size popupSize, Size targe private CustomPopupPlacement[] PlacePortContextMenu(Size popupSize, Size targetSize, Point offset) { + // The actual zoom here is confusing + // What matters is the zoom factor measured from the scaled : unscaled node size var zoom = node.WorkspaceViewModel.Zoom; + var zoomFactor = targetSize.Height / node.ActualHeight; double x; var scaledWidth = autocompletePopupSpacing * targetSize.Width / node.ActualWidth; @@ -363,10 +366,15 @@ private CustomPopupPlacement[] PlacePortContextMenu(Size popupSize, Size targetS // Offset popup to the right by node width and spacing from left edge of node. x = scaledWidth + targetSize.Width; } - // Offset popup down from the upper edge of the node by the node header and corresponding to the respective port. - // Scale the absolute heights by the target height (passed to the callback) and the actual height of the node. - var absoluteHeight = NodeModel.HeaderHeight + PortModel.Index * PortModel.Height; - var y = absoluteHeight * scaledHeight; + // Important - while zooming in and out, Node elements are scaled, while popup is not + // Calculate absolute popup halfheight to deduct from the overal y pos + // Then add the header, port height and port index position + var popupHeightOffset = - popupSize.Height * 0.5; + var headerHeightOffset = 2 * NodeModel.HeaderHeight * zoom; + var portHalfHeight = PortModel.Height * 0.5 * zoom; + var rowOffset = PortModel.Index * (1.5 * PortModel.Height) * zoom; + + var y = popupHeightOffset + headerHeightOffset + portHalfHeight + rowOffset; var placement = new CustomPopupPlacement(new Point(x, y), PopupPrimaryAxis.None); From 63b16b2d547c76d082eb9c773bcdbde30685943c Mon Sep 17 00:00:00 2001 From: Deyan Nenov Date: Fri, 20 Jan 2023 19:49:34 +0000 Subject: [PATCH 2/2] Removed unused variables - a small fix --- src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs b/src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs index 48a800d0949..447f6cf15a1 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs @@ -350,11 +350,9 @@ private CustomPopupPlacement[] PlacePortContextMenu(Size popupSize, Size targetS // The actual zoom here is confusing // What matters is the zoom factor measured from the scaled : unscaled node size var zoom = node.WorkspaceViewModel.Zoom; - var zoomFactor = targetSize.Height / node.ActualHeight; double x; var scaledWidth = autocompletePopupSpacing * targetSize.Width / node.ActualWidth; - var scaledHeight = targetSize.Height / node.ActualHeight; if (PortModel.PortType == PortType.Input) {