-
Notifications
You must be signed in to change notification settings - Fork 331
UITK drag and drop (ISX-1141) #1831
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
Changes from 35 commits
326a442
c8f3ea5
5d4ae4c
7c18777
083b4d3
6af4d0b
68565d2
5605382
b843619
5a4b176
d76cb23
420bf9e
30282e5
e9aaa22
d5500b7
9f1bf83
949077e
8a18181
e5f7d54
f9d2bea
0a6a44c
4e70360
23fef72
7fd0078
aa60f59
7f1dd90
0e0f1e7
1dbad3a
7c3660b
1ea2ba9
3d02a5d
cfbd28b
eeeb302
0582d99
32a3a64
8031068
30b7ed7
de92b06
2175b70
87faaef
7e507fb
b0f2c7d
b060518
a1816dc
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 |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ public ActionMapsView(VisualElement root, StateContainer stateContainer) | |
| { | ||
| m_ListView = root.Q<ListView>("action-maps-list-view"); | ||
| m_ListView.selectionType = UIElements.SelectionType.Single; | ||
|
|
||
| m_ListView.reorderable = true; | ||
| m_ListViewSelectionChangeFilter = new CollectionViewSelectionChangeFilter(m_ListView); | ||
| m_ListViewSelectionChangeFilter.selectedIndicesChanged += (selectedIndices) => | ||
| { | ||
|
|
@@ -34,6 +34,7 @@ public ActionMapsView(VisualElement root, StateContainer stateContainer) | |
| treeViewItem.DuplicateCallback = _ => DuplicateActionMap(i); | ||
| treeViewItem.OnDeleteItem += treeViewItem.DeleteCallback; | ||
| treeViewItem.OnDuplicateItem += treeViewItem.DuplicateCallback; | ||
| treeViewItem.userData = i; | ||
|
|
||
| ContextMenu.GetContextMenuForActionMapItem(treeViewItem); | ||
| }; | ||
|
|
@@ -55,6 +56,10 @@ public ActionMapsView(VisualElement root, StateContainer stateContainer) | |
|
|
||
| m_ListView.RegisterCallback<ExecuteCommandEvent>(OnExecuteCommand); | ||
| m_ListView.RegisterCallback<ValidateCommandEvent>(OnValidateCommand); | ||
| var treeView = root.Q<TreeView>("actions-tree-view"); | ||
| m_ListView.AddManipulator(new DropManipulator(OnDroppedHandler, treeView)); | ||
| m_ListView.itemIndexChanged += OnReorder; | ||
|
|
||
|
|
||
| CreateSelector(s => new ViewStateCollection<string>(Selectors.GetActionMapNames(s)), | ||
| (actionMapNames, state) => new ViewState(Selectors.GetSelectedActionMap(state), actionMapNames)); | ||
|
|
@@ -64,6 +69,17 @@ public ActionMapsView(VisualElement root, StateContainer stateContainer) | |
| ContextMenu.GetContextMenuForActionMapListView(this, m_ListView.parent); | ||
| } | ||
|
|
||
| void OnDroppedHandler(int mapIndex) | ||
| { | ||
| Dispatch(Commands.CutActionsOrBindings()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is likely fine but I would recommend when we do a sequence of commands like this that they are implemented as a single command instead but is the combination of the two underneath. Otherwise this would yield two Undo steps "Cut" and "Paste" which might be confusing for a Drop? Another aspect is that since dispatched, if CutActionsOrBindings() throws, the new state is not propagated and the Paste will execute on the previous state. I think I have seen this in more places so might be that we overlook all places at a later point for exception-safety and Undo convenience.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I think there your implementation of Dispatch(..,continueWith) would be a great solution, I would wait until this is landed and make use of this. |
||
| Dispatch(Commands.PasteActionIntoActionMap(mapIndex)); | ||
| } | ||
|
|
||
| void OnReorder(int oldIndex, int newIndex) | ||
| { | ||
| Dispatch(Commands.ReorderActionMap(oldIndex, newIndex)); | ||
| } | ||
|
|
||
| public override void RedrawUI(ViewState viewState) | ||
| { | ||
| m_ListView.itemsSource = viewState.actionMapNames?.ToList() ?? new List<string>(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.