-
Notifications
You must be signed in to change notification settings - Fork 634
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
AGD-2199 - custom dropdown node #11958
Conversation
Co-authored-by: Craig Long <[email protected]>
* Fix broken tests * Remove temp test files Co-authored-by: Craig Long <[email protected]>
…2199 � Conflicts: � src/Libraries/CoreNodeModels/Properties/Resources.en-US.resx � src/Libraries/CoreNodeModels/Properties/Resources.resx
@LongNguyenP @saintentropy There is a regression |
# Conflicts: # src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs
Merge conflicts with the current master has been resolved. LGTM |
@@ -0,0 +1,6 @@ | |||
## In Depth | |||
The Custom Dropdown node allows a user to create a dropdown selection input with custom labels and values. If all values are numbers, the output will be a double, and if all values are integers the output will be an integer. In the example below, "Two" is selected in the Custom Dropdown Menu node, making the output of that node the integer `2`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if the types are mixed? Can you use strings? What are valid value types etc?
Is this dynamic behavior important - I ask this because as we're working on the MSIL compiler - it's very hard to determine the output types of nodes that have dynamic behavior like this - not super important but I imagine that if we move forward with that work outside of a POC we're going to need some principles around not introducing dynamic behavior without a really good reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Immediate answers: values default to strings unless the criteria are met. So, anything's valid, it will just be a string unless we can make everything numbers. I'll add that, or whatever we decide here, to the description.
I'm definitely open to alternatives, though I think this behavior is pretty convenient, intuiting a user's expectations in most common scenarios. I'm not sure what the alternative to dynamic behavior here is. Separate String custom selection and Number custom selection nodes sounds awkward for the user. I imagine the original inspiration for this part may have been the experience in Grasshopper. Though there it's less a feature of the custom selection node itself and more of the global type coercion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's put this on the back burner.
xmlns:dynui="clr-namespace:Dynamo.UI.Controls;assembly=DynamoCoreWpf" | ||
xmlns:fa="clr-namespace:FontAwesome.WPF;assembly=FontAwesome.WPF" | ||
xmlns:nodes="clr-namespace:Dynamo.Nodes;assembly=DynamoCore" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so was this just incorrect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah. The removed line was unused. I needed a reference to DynamoCoreWpf's Dynamo.Nodes, which still made sense to call nodes
.
@@ -1414,61 +1414,53 @@ | |||
</Style> | |||
|
|||
<Style x:Key="SNodeTextButton" TargetType="{x:Type Button}"> | |||
<Setter Property="FontSize" Value="17px"/> | |||
<Setter Property="Foreground" Value="{StaticResource Blue300Brush}" /> | |||
<Setter Property="Background" Value="#4D4D4D" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this color reused in a lot of places? Can it be pulled out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's used in 5 places in DynamoModern. It already exists in ColorsAndBrushes, but for more specific uses. I wasn't sure how far to take a style revision, so I defaulted to just making the changes necessary to use the styles for the new component. From my interaction so far it looks like there are a lot of optimization opportunities like this: unnecessary styles, duplicated sections, hard-coded colors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, yes, definitely could be, just let me know if you want that level of change to be in this PR
FontWeight="Bold" | ||
Style="{StaticResource SZoomFadeText}" | ||
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" /> | ||
</Border> | ||
</Grid> | ||
<ControlTemplate.Triggers> | ||
<Trigger Property="Button.IsMouseOver" Value="true"> | ||
<Setter TargetName="roundedBorder" Property="Background" Value="#535353" /> | ||
<Setter TargetName="text" Property="Foreground" Value="{StaticResource Blue300Brush}" /> | ||
<Setter Property="Background" Value="#535353" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same color question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A popular color used in 7 places in DynamoModern, already has a color in ColorsAndBrushes, and used by 3 different brushes in ColorsAndBrushes. Also used directly in 2 other view files.
<Style TargetType="{x:Type nodes:DynamoNodeButton}" BasedOn="{StaticResource SNodeTextButton}" /> | ||
|
||
<Style x:Key="SingleCharButton" TargetType="{x:Type Button}" BasedOn="{StaticResource SNodeTextButton}"> | ||
<Setter Property="Foreground" Value="#999999" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
color reuse question
return SelectionState.Restore; | ||
} | ||
|
||
[OnSerializing] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this attribute do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a Newtonsoft pre-serialization hook. https://www.newtonsoft.com/json/help/html/SerializationCallbacks.htm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few questions / comments
src/Libraries/CoreNodeModelsWpf/Controls/CustomSelectionControl.xaml.cs
Outdated
Show resolved
Hide resolved
src/Libraries/CoreNodeModelsWpf/Controls/CustomSelectionControl.xaml.cs
Outdated
Show resolved
Hide resolved
|
||
if (e.Key == Key.Tab) | ||
{ | ||
int offset = e.KeyboardDevice.Modifiers == System.Windows.Input.ModifierKeys.Shift ? 0 : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am usually not a stickler for style stuff besides if(){ }
- but the whitespace seems a bit confusing to the eye.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More than happy to oblige. I miss Prettier. Is this what you had in mind?
src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs
Outdated
Show resolved
Hide resolved
src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs
Show resolved
Hide resolved
@@ -443,6 +443,9 @@ | |||
}, | |||
{ | |||
"path": "Core.Input.Output" | |||
}, | |||
{ | |||
"path": "Core.Input.Custom Dropdown Menu" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't die on this hill, but is this really a dropdown menu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, nope it isn't. I had provisionally renamed things to "Custom Selection", but missed this one. While we're here though, is that the right name? "Custom Dropdown"? "Custom Selection List"? I guess I'd still vote "Custom Selection", but I won't even risk injury on that hill.
test/Tools/docGeneratorTestFiles/sampledictionarycontent/Dynamo_Nodes_Documentation.json
Outdated
Show resolved
Hide resolved
also kicked off: https://master-15.jenkins.autodesk.com/view/DYN/job/DYN-DevCI_Self_Service/1083/ on the serial tests just to see if anything unexpected happens there. tests pass there - another good practice would be to pull master into your branch, this is already done on the parallel tests, but for the serial tests, it's not done with the job I linked above, so we could still find some unexpected behavior on master-15 when we merge. I don't think it's necessary here, but good for next time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! I've fixed most things (I think!), a few might be worth further discussion.
FontWeight="Bold" | ||
Style="{StaticResource SZoomFadeText}" | ||
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" /> | ||
</Border> | ||
</Grid> | ||
<ControlTemplate.Triggers> | ||
<Trigger Property="Button.IsMouseOver" Value="true"> | ||
<Setter TargetName="roundedBorder" Property="Background" Value="#535353" /> | ||
<Setter TargetName="text" Property="Foreground" Value="{StaticResource Blue300Brush}" /> | ||
<Setter Property="Background" Value="#535353" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A popular color used in 7 places in DynamoModern, already has a color in ColorsAndBrushes, and used by 3 different brushes in ColorsAndBrushes. Also used directly in 2 other view files.
return SelectionState.Restore; | ||
} | ||
|
||
[OnSerializing] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a Newtonsoft pre-serialization hook. https://www.newtonsoft.com/json/help/html/SerializationCallbacks.htm
src/Libraries/CoreNodeModelsWpf/Controls/CustomSelectionControl.xaml.cs
Outdated
Show resolved
Hide resolved
|
||
if (e.Key == Key.Tab) | ||
{ | ||
int offset = e.KeyboardDevice.Modifiers == System.Windows.Input.ModifierKeys.Shift ? 0 : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More than happy to oblige. I miss Prettier. Is this what you had in mind?
src/Libraries/CoreNodeModelsWpf/NodeViewCustomizations/CustomSelection.cs
Show resolved
Hide resolved
@@ -443,6 +443,9 @@ | |||
}, | |||
{ | |||
"path": "Core.Input.Output" | |||
}, | |||
{ | |||
"path": "Core.Input.Custom Dropdown Menu" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, nope it isn't. I had provisionally renamed things to "Custom Selection", but missed this one. While we're here though, is that the right name? "Custom Dropdown"? "Custom Selection List"? I guess I'd still vote "Custom Selection", but I won't even risk injury on that hill.
test/Tools/docGeneratorTestFiles/sampledictionarycontent/Dynamo_Nodes_Documentation.json
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @twastvedt looks good to me.
Purpose
This PR addresses JIRA task AGD-2199: A node that allows user to pre-define a dropdown menu with an arbitrary number of customizable menu items
Declarations
Check these if you believe they are true
*.resx
filesReviewers
(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)
(FILL ME IN, optional) Any additional notes to reviewers or testers.
FYIs
(FILL ME IN, Optional) Names of anyone else you wish to be notified of