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

AGD-2199 - custom dropdown node #11958

Merged
merged 101 commits into from
Aug 19, 2022
Merged

AGD-2199 - custom dropdown node #11958

merged 101 commits into from
Aug 19, 2022

Conversation

LongNguyenP
Copy link
Contributor

@LongNguyenP LongNguyenP commented Aug 23, 2021

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

image

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated

Reviewers

(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

@QilongTang QilongTang added this to the 2.13.0 milestone Nov 30, 2021
…2199

� Conflicts:
�	src/Libraries/CoreNodeModels/Properties/Resources.en-US.resx
�	src/Libraries/CoreNodeModels/Properties/Resources.resx
@QilongTang
Copy link
Contributor

@LongNguyenP @saintentropy There is a regression NodeDocumentationMarkdownGeneratorTests.MarkdownGeneratorCommandTests.ProducesCorrectOutputFromCoreDirectory

@QilongTang QilongTang removed this from the 2.13.0 milestone Dec 8, 2021
@LongNguyenP
Copy link
Contributor Author

LongNguyenP commented Jan 31, 2022

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`.
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member

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"
Copy link
Member

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?

Copy link
Contributor

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" />
Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Contributor

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" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same color question

Copy link
Contributor

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" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

color reuse question

src/Libraries/CoreNodeModels/Input/CustomSelection.cs Outdated Show resolved Hide resolved
src/Libraries/CoreNodeModels/Input/CustomSelection.cs Outdated Show resolved Hide resolved
src/Libraries/CoreNodeModels/Input/CustomSelection.cs Outdated Show resolved Hide resolved
return SelectionState.Restore;
}

[OnSerializing]
Copy link
Member

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?

Copy link
Contributor

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

Copy link
Member

@mjkkirschner mjkkirschner left a 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


if (e.Key == Key.Tab)
{
int offset = e.KeyboardDevice.Modifiers == System.Windows.Input.ModifierKeys.Shift ? 0 : 1;
Copy link
Member

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.

Copy link
Contributor

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?

@@ -443,6 +443,9 @@
},
{
"path": "Core.Input.Output"
},
{
"path": "Core.Input.Custom Dropdown Menu"
Copy link
Member

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?

Copy link
Contributor

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.

@mjkkirschner
Copy link
Member

mjkkirschner commented Aug 18, 2022

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.

@mjkkirschner mjkkirschner changed the title AGD-2199 AGD-2199 - custom dropdown node Aug 18, 2022
Copy link
Contributor

@twastvedt twastvedt left a 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" />
Copy link
Contributor

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.

src/Libraries/CoreNodeModels/Input/CustomSelection.cs Outdated Show resolved Hide resolved
return SelectionState.Restore;
}

[OnSerializing]
Copy link
Contributor

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


if (e.Key == Key.Tab)
{
int offset = e.KeyboardDevice.Modifiers == System.Windows.Input.ModifierKeys.Shift ? 0 : 1;
Copy link
Contributor

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?

@@ -443,6 +443,9 @@
},
{
"path": "Core.Input.Output"
},
{
"path": "Core.Input.Custom Dropdown Menu"
Copy link
Contributor

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.

Copy link
Member

@mjkkirschner mjkkirschner left a 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. :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants