Skip to content

Commit

Permalink
[DYN-8026] Fix watch node which has corrupted size. (#15755)
Browse files Browse the repository at this point in the history
  • Loading branch information
reddyashish authored Jan 14, 2025
1 parent d1dd01f commit bf568b0
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public partial class WatchTree : UserControl
private readonly double widthPerCharacter = 7.5;
private static readonly int defaultHeightSize = 200;
private readonly int minWidthSize = 100;
private readonly int minHeightSize = 38;
private readonly int minHeightSize = 40;
private readonly int minHeightForList = 83;

public WatchTree(WatchViewModel vm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public void CustomizeView(Watch nodeModel, NodeView nodeView)

ResetWatch();

watchTree.Width = nodeModel.WatchWidth == 0 ? watchTree.Width : nodeModel.WatchWidth;
watchTree.Height = nodeModel.WatchHeight == 0 ? watchTree.Height : nodeModel.WatchHeight;
watchTree.Width = nodeModel.WatchWidth < watchTree.Width ? watchTree.Width : nodeModel.WatchWidth;
watchTree.Height = nodeModel.WatchHeight < watchTree.Height ? watchTree.Height : nodeModel.WatchHeight;

//Store width and height info of the node in the dictionary.
Watch.NodeSizes[watch.GUID] = new Tuple<double, double>(nodeModel.WatchWidth, nodeModel.WatchHeight);
Expand Down
13 changes: 13 additions & 0 deletions test/DynamoCoreWpfTests/WatchNodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,19 @@ public void WatchNestedDictionaryPreviewFromMlutiReturnNode()
}

[Test]
public void WatchNodeWithBadSize()
{
string openPath = Path.Combine(TestDirectory, @"core\watch\WatchNodeBadSize.dyn");
ViewModel.OpenCommand.Execute(openPath);
ViewModel.HomeSpace.Run();

var watchNode = ViewModel.Model.CurrentWorkspace.NodeFromWorkspace("355685ad-754c-400f-ac75-53a56c7d5423") as Watch;

Assert.AreEqual(100, watchNode.Width);
Assert.AreEqual(100, watchNode.Height);
}

[Test]
public void GetNodeLabelTree()
{
// Arrange
Expand Down
142 changes: 142 additions & 0 deletions test/core/watch/WatchNodeBadSize.dyn
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"Uuid": "2d99f611-7d17-4fbe-8e39-8fbd77cd1ecf",
"IsCustomNode": false,
"Description": "",
"Name": "WatchNodeBadSize",
"ElementResolver": {
"ResolutionMap": {}
},
"Inputs": [],
"Outputs": [],
"Nodes": [
{
"ConcreteType": "CoreNodeModels.Watch, CoreNodeModels",
"WatchWidth": 50.0,
"WatchHeight": 38.0,
"Id": "355685ad754c400fac7553a56c7d5423",
"NodeType": "ExtensionNode",
"Inputs": [
{
"Id": "7feffa6f77e34900b45cb33858ad4e7a",
"Name": "",
"Description": "Node to show output from",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Outputs": [
{
"Id": "1d550c1aba7845b0be174dedaae60253",
"Name": "",
"Description": "Node output",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Visualizes a node's output"
},
{
"ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore",
"Id": "ca31ea53b3b94751b7a5254fb6cdb7b9",
"NodeType": "CodeBlockNode",
"Inputs": [],
"Outputs": [
{
"Id": "1adc5b91c52c4f87bbb113222f5c760b",
"Name": "",
"Description": "Value of expression at line 1",
"UsingDefaultValue": false,
"Level": 2,
"UseLevels": false,
"KeepListStructure": false
}
],
"Replication": "Disabled",
"Description": "Allows for DesignScript code to be authored directly",
"Code": "1..10;"
}
],
"Connectors": [
{
"Start": "1adc5b91c52c4f87bbb113222f5c760b",
"End": "7feffa6f77e34900b45cb33858ad4e7a",
"Id": "0f111a8fa2d84185aeeeee4ba37c718a",
"IsHidden": "False"
}
],
"Dependencies": [],
"NodeLibraryDependencies": [],
"EnableLegacyPolyCurveBehavior": true,
"Thumbnail": "",
"GraphDocumentationURL": null,
"ExtensionWorkspaceData": [
{
"ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670",
"Name": "Properties",
"Version": "3.5",
"Data": {}
}
],
"Author": "",
"Linting": {
"activeLinter": "None",
"activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a",
"warningCount": 0,
"errorCount": 0
},
"Bindings": [],
"View": {
"Dynamo": {
"ScaleFactor": 1.0,
"HasRunWithoutCrash": true,
"IsVisibleInDynamoLibrary": true,
"Version": "3.4.1.7435",
"RunType": "Automatic",
"RunPeriod": "1000"
},
"Camera": {
"Name": "_Background Preview",
"EyeX": -17.0,
"EyeY": 24.0,
"EyeZ": 50.0,
"LookX": 12.0,
"LookY": -13.0,
"LookZ": -58.0,
"UpX": 0.0,
"UpY": 1.0,
"UpZ": 0.0
},
"ConnectorPins": [],
"NodeViews": [
{
"Id": "355685ad754c400fac7553a56c7d5423",
"Name": "Watch",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"ShowGeometry": true,
"X": 626.0,
"Y": 261.5
},
{
"Id": "ca31ea53b3b94751b7a5254fb6cdb7b9",
"Name": "Code Block",
"IsSetAsInput": false,
"IsSetAsOutput": false,
"Excluded": false,
"ShowGeometry": true,
"X": 268.0,
"Y": 267.0
}
],
"Annotations": [],
"X": 0.0,
"Y": 0.0,
"Zoom": 1.0
}
}

0 comments on commit bf568b0

Please sign in to comment.