Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-4308 Input and output port menu Y location #13683

Merged
merged 2 commits into from
Jan 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/DynamoCoreWpf/ViewModels/Core/PortViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
Expand Down Expand Up @@ -347,11 +347,12 @@ 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;

double x;
var scaledWidth = autocompletePopupSpacing * targetSize.Width / node.ActualWidth;
var scaledHeight = targetSize.Height / node.ActualHeight;

if (PortModel.PortType == PortType.Input)
{
Expand All @@ -363,10 +364,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);

Expand Down