-
Notifications
You must be signed in to change notification settings - Fork 328
PoC for device flag clarity #2039
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,136 @@ | ||||||
| using UnityEditor; | ||||||
| using UnityEditor.IMGUI.Controls; | ||||||
|
|
||||||
| #if UNITY_EDITOR | ||||||
|
|
||||||
| namespace UnityEngine.InputSystem.Editor | ||||||
| { | ||||||
| public class DeviceFlagsTreeView : TreeView | ||||||
| { | ||||||
| private InputDevice m_Device; | ||||||
|
|
||||||
| private enum ColumnId | ||||||
| { | ||||||
| Name, | ||||||
| Value, | ||||||
| COUNT | ||||||
| } | ||||||
|
|
||||||
| public static DeviceFlagsTreeView Create(InputDevice device, ref TreeViewState treeState, ref MultiColumnHeaderState headerState) | ||||||
| { | ||||||
| if (treeState == null) | ||||||
| treeState = new TreeViewState(); | ||||||
|
|
||||||
| var newHeaderState = CreateHeaderState(); | ||||||
| if (headerState != null) | ||||||
| MultiColumnHeaderState.OverwriteSerializedFields(headerState, newHeaderState); | ||||||
| headerState = newHeaderState; | ||||||
|
|
||||||
| var header = new MultiColumnHeader(headerState); | ||||||
| return new DeviceFlagsTreeView(treeState, header, device); | ||||||
| } | ||||||
|
|
||||||
| private static MultiColumnHeaderState CreateHeaderState() | ||||||
| { | ||||||
| var columns = new MultiColumnHeaderState.Column[(int)ColumnId.COUNT]; | ||||||
|
|
||||||
| columns[(int)ColumnId.Name] = new MultiColumnHeaderState.Column() | ||||||
| { | ||||||
| width = 320, | ||||||
| minWidth = 60, | ||||||
| headerContent = new GUIContent("Name"), | ||||||
| canSort = false | ||||||
| }; | ||||||
| columns[(int)ColumnId.Value] = new MultiColumnHeaderState.Column() | ||||||
| { | ||||||
| width = 80, | ||||||
| minWidth = 60, | ||||||
| headerContent = new GUIContent("Value"), | ||||||
| canSort = false | ||||||
| }; | ||||||
|
|
||||||
| return new MultiColumnHeaderState(columns); | ||||||
| } | ||||||
|
|
||||||
| private DeviceFlagsTreeView(TreeViewState state, MultiColumnHeader multiColumnHeader, InputDevice device) | ||||||
| : base(state, multiColumnHeader) | ||||||
| { | ||||||
| m_Device = device; | ||||||
| Reload(); | ||||||
| } | ||||||
|
|
||||||
| private void AddFlag(TreeViewItem root, InputDevice.DeviceFlags flag) | ||||||
| { | ||||||
| root.AddChild(new FlagItem() | ||||||
| { | ||||||
| id = 1, | ||||||
|
||||||
| id = 1, | |
| id = m_NextId++, |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
[nitpick] Typo found in the label text "DisabledWWhileInBackground". It should likely be corrected to "DisabledWhileInBackground".