Skip to content

Conversation

@lyndon-unity
Copy link
Collaborator

@lyndon-unity lyndon-unity commented Feb 8, 2024

Description

Implemented UI TK version of the matching control bindings recently added to the IMGUI editor
#1672

Example of it working in the project wide input actions. This is the same UX used in the individual assets.
image

Changes made

The code to populate the UX is the same as the IMGUI code - but split out to generate a tree before then generating the UI specific tree.

Also fixed up some styling on the control scheme info which is in the binding UI to be more consistent with the IMGUI version. Bolded and fixed margins.

Notes

Note this version doesn't store the full tree state - just the expanded/not level.
This means I didn't need to add the static dictionary which was present in the IMGUI version.
I didn't feel this was critical and reduced static state.

I also had to make the top level expansion based on e checkbox rather than a 'fold out' / top of tree as the UI TK treeView doesn't have API to react to the expand/collapse state.
^ This comment is old - I've added a Foldout to replace the Toggle now

Checklist

Before review:

  • Changelog entry added.
  • No tests added/changed
  • No new doc

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

Tightened up layout of control scheme text and the matching paths tree view labels
Removed the 'show matching paths' checkbox
Attempted to save and restore expansion of the 'Derived Paths' but waiting on feedback on how to respond to expand/collapse from UI TK team.
Moved some more of the style to uss file
Changed a label to a HelpBox to match UGUI version
Switched to toggle/checkbox for the main "Show matching bindings" part as we can't detect expand/collapse in tree
Removed an unused callback
Renamed some functions to be clearer
@Pauliusd01 Pauliusd01 changed the title Add UI Toolkit matching control bindings UX Add UI Toolkit matching control bindings UI Feb 8, 2024
Copy link
Collaborator

@ritamerkl ritamerkl left a comment

Choose a reason for hiding this comment

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

Good to see this working!
I just have one major point- I think it could be worth outsourcing the biggest part of the DrawMatchingControlPath and connected methods to an external script (or other related existing classes). Like that we could keep the PropertiesView clean and "logic free".
I also added one minor comment on a potential unused method to remove.

@lyndon-unity
Copy link
Collaborator Author

Good to see this working! I just have one major point- I think it could be worth outsourcing the biggest part of the DrawMatchingControlPath and connected methods to an external script (or other related existing classes). Like that we could keep the PropertiesView clean and "logic free". I also added one minor comment on a potential unused method to remove.

Yes I agree I can take a look at spitting those out

Copy link
Collaborator

@ritamerkl ritamerkl left a comment

Choose a reason for hiding this comment

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

LGTM now

@Pauliusd01
Copy link
Collaborator

Is the style used wrong? Why is the derived binding text selectable? It wasn't like that in the IMGUI version and I don't see why that should be changed

@Pauliusd01
Copy link
Collaborator

Unity_2024-02-09_13-47-02.mp4

Since this is a toggle now I think its state should be saved, seems annoying to have to re-enable it between window restarts

Copy link
Collaborator

@Pauliusd01 Pauliusd01 left a comment

Choose a reason for hiding this comment

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

Just minor notes from me. Functionality seems the same and works without issues

@lyndon-unity
Copy link
Collaborator Author

Is the style used wrong? Why is the derived binding text selectable? It wasn't like that in the IMGUI version and I don't see why that should be changed

I've fixed that - it was just the default for the UI TK tree view.
I've set it to none to match IMGUI version

@lyndon-unity
Copy link
Collaborator Author

I think its state should be saved

I'd like to do that but I don't have a quick fix for that so might land the update so far and look at that later.

@Pauliusd01 Pauliusd01 self-requested a review February 12, 2024 12:06
@Pauliusd01
Copy link
Collaborator

I think its state should be saved

I'd like to do that but I don't have a quick fix for that so might land the update so far and look at that later.

Does it have to be a toggle then? If a foldout would solve this issue I'd prefer that, and later on we can switch it to a toggle once state saving is there

@lyndon-unity
Copy link
Collaborator Author

I think its state should be saved

I'd like to do that but I don't have a quick fix for that so might land the update so far and look at that later.

Does it have to be a toggle then? If a foldout would solve this issue I'd prefer that, and later on we can switch it to a toggle once state saving is there

State is now maintained over open/close to match IMGUI.
I've just switched to a foldout now too.

Copy link
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

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

LGTM, is all logic in MatchingControlPaths new? If it is then its fine as-is, otherwise it might be worthwhile avoiding duplicating logic with existing feature implementation for IMGUI? It seems like MatchingControlPaths is not tied to UI framework and would be possible to cover with unit tests?

@lyndon-unity
Copy link
Collaborator Author

lyndon-unity commented Feb 12, 2024

LGTM, is all logic in MatchingControlPaths new? If it is then its fine as-is, otherwise it might be worthwhile avoiding duplicating logic with existing feature implementation for IMGUI? It seems like MatchingControlPaths is not tied to UI framework and would be possible to cover with unit tests?

The MatchingControlPaths isn't all new code - its adapted from the IMGUI version. It drops some of the code for retaining the expand/collapse state of individual parts of the hierarchy as that had a static dictionary that seemed lower priority for the memory overheads. To use in IMGUI directly we would have to add back in the static dictionary and store extra state in the returned data. I decided to duplicate as the IMGUI version would be deprecated in future.
^ but I have now removed duplicated code and refactored a little so it can be shared with IMGUI and UI TK.

Tests should be added but I felt given time constraints that part could be added later.

…d UITK editors

And fixed the foldout callback to only trigger on the foldout and not its children
Copy link
Collaborator

@Pauliusd01 Pauliusd01 left a comment

Choose a reason for hiding this comment

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

LGTM, checked that the matching bindings are correct for different bindings in both ProjectWideActions and custom action assets.

@ekcoh
Copy link
Collaborator

ekcoh commented Feb 13, 2024

LGTM, is all logic in MatchingControlPaths new? If it is then its fine as-is, otherwise it might be worthwhile avoiding duplicating logic with existing feature implementation for IMGUI? It seems like MatchingControlPaths is not tied to UI framework and would be possible to cover with unit tests?

The MatchingControlPaths isn't all new code - its adapted from the IMGUI version. It drops some of the code for retaining the expand/collapse state of individual parts of the hierarchy as that had a static dictionary that seemed lower priority for the memory overheads. To use in IMGUI directly we would have to add back in the static dictionary and store extra state in the returned data. I decided to duplicate as the IMGUI version would be deprecated in future. ^ but I have now removed duplicated code and refactored a little so it can be shared with IMGUI and UI TK.

Tests should be added but I felt given time constraints that part could be added later.

I see, great to avoid duplicating too much. OK to postpone the test part temporarily but in that case please file a ticket on the remaining part from your perspective.

@lyndon-unity lyndon-unity merged commit d46ba1a into develop Feb 14, 2024
@lyndon-unity lyndon-unity deleted the add_ui_tk_matching_controls branch February 14, 2024 08:31
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.

5 participants