Code cleanup around the input mapper system
This commit is contained in:
parent
41ee1cf8bc
commit
0cda8e2bb4
|
|
@ -74,7 +74,6 @@ pub fn input_mappings() -> Mapping {
|
|||
entry!(KeyDown(KeyH); modifiers=[Accel], action_dispatch=NodeGraphMessage::ToggleSelectedVisibility),
|
||||
entry!(KeyDown(KeyL); modifiers=[Accel], action_dispatch=NodeGraphMessage::ToggleSelectedLocked),
|
||||
entry!(KeyDown(KeyL); modifiers=[Alt], action_dispatch=NodeGraphMessage::ToggleSelectedAsLayersOrNodes),
|
||||
entry!(KeyDown(KeyC); modifiers=[Shift], action_dispatch=NodeGraphMessage::PrintSelectedNodeCoordinates),
|
||||
entry!(KeyDown(KeyC); modifiers=[Alt], action_dispatch=NodeGraphMessage::SendClickTargets),
|
||||
entry!(KeyDown(KeyM); modifiers=[Accel], action_dispatch=NodeGraphMessage::MergeSelectedNodes),
|
||||
entry!(KeyUp(KeyC); action_dispatch=NodeGraphMessage::EndSendClickTargets),
|
||||
|
|
@ -321,7 +320,6 @@ pub fn input_mappings() -> Mapping {
|
|||
entry!(KeyUp(Escape); action_dispatch=DocumentMessage::Escape),
|
||||
entry!(KeyDown(Delete); action_dispatch=DocumentMessage::DeleteSelectedLayers),
|
||||
entry!(KeyDown(Backspace); action_dispatch=DocumentMessage::DeleteSelectedLayers),
|
||||
entry!(KeyDown(KeyP); modifiers=[Alt], action_dispatch=DocumentMessage::DebugPrintDocument),
|
||||
entry!(KeyDown(KeyO); modifiers=[Alt], action_dispatch=DocumentMessage::ToggleOverlaysVisibility),
|
||||
entry!(KeyDown(KeyS); modifiers=[Alt], action_dispatch=DocumentMessage::ToggleSnapping),
|
||||
entry!(KeyDown(KeyH); modifiers=[Accel], action_dispatch=DocumentMessage::ToggleSelectedVisibility),
|
||||
|
|
@ -427,23 +425,26 @@ pub fn input_mappings() -> Mapping {
|
|||
entry!(KeyDown(Comma); modifiers=[Accel], action_dispatch=DialogMessage::RequestPreferencesDialog),
|
||||
//
|
||||
// DebugMessage
|
||||
entry!(KeyDown(KeyT); modifiers=[Alt], action_dispatch=DebugMessage::ToggleTraceLogs),
|
||||
entry!(KeyDown(Digit0); modifiers=[Alt], action_dispatch=DebugMessage::MessageOff),
|
||||
entry!(KeyDown(Digit1); modifiers=[Alt], action_dispatch=DebugMessage::MessageNames),
|
||||
entry!(KeyDown(Digit2); modifiers=[Alt], action_dispatch=DebugMessage::MessageContents),
|
||||
];
|
||||
let (mut key_up, mut key_down, mut key_up_no_repeat, mut key_down_no_repeat, mut double_click, mut wheel_scroll, mut pointer_move) = mappings;
|
||||
|
||||
let sort = |list: &mut KeyMappingEntries| list.0.sort_by(|u, v| v.modifiers.ones().cmp(&u.modifiers.ones()));
|
||||
let sort = |list: &mut KeyMappingEntries| list.0.sort_by(|a, b| b.modifiers.count_ones().cmp(&a.modifiers.count_ones()));
|
||||
// Sort the sublists of `key_up`, `key_down`, `key_up_no_repeat`, and `key_down_no_repeat`
|
||||
for list in [&mut key_up, &mut key_down, &mut key_up_no_repeat, &mut key_down_no_repeat] {
|
||||
for sublist in list {
|
||||
sort(sublist);
|
||||
}
|
||||
}
|
||||
// Sort the sublists of `double_click`
|
||||
for sublist in &mut double_click {
|
||||
sort(sublist)
|
||||
}
|
||||
// Sort `wheel_scroll`
|
||||
sort(&mut wheel_scroll);
|
||||
// Sort `pointer_move`
|
||||
sort(&mut pointer_move);
|
||||
|
||||
Mapping {
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ impl<const LENGTH: usize> BitVector<LENGTH> {
|
|||
result == 0
|
||||
}
|
||||
|
||||
pub fn ones(&self) -> u32 {
|
||||
pub fn count_ones(&self) -> u32 {
|
||||
let mut result = 0;
|
||||
|
||||
for storage in self.0.iter() {
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ pub enum NodeGraphMessage {
|
|||
PointerOutsideViewport {
|
||||
shift: Key,
|
||||
},
|
||||
PrintSelectedNodeCoordinates,
|
||||
RemoveImport {
|
||||
import_index: usize,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1229,44 +1229,6 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphHandlerData<'a>> for NodeGrap
|
|||
self.auto_panning.stop(&messages, responses);
|
||||
}
|
||||
}
|
||||
NodeGraphMessage::PrintSelectedNodeCoordinates => {
|
||||
// TODO: This will also have to print all metadata
|
||||
// for (_, node_to_print) in network
|
||||
// .nodes
|
||||
// .iter()
|
||||
// .filter(|node_id| selected_nodes.selected_nodes().any(|selected_id| selected_id == node_id.0))
|
||||
// {
|
||||
// if let DocumentNodeImplementation::Network(network) = &node_to_print.implementation {
|
||||
// let mut output = "\r\n\r\n".to_string();
|
||||
// output += &node_to_print.name;
|
||||
// output += ":\r\n\r\n";
|
||||
// let mut nodes = network.nodes.iter().collect::<Vec<_>>();
|
||||
// nodes.sort_by_key(|(a, _)| a.0);
|
||||
// output += &nodes
|
||||
// .iter()
|
||||
// .map(|(_, node)| {
|
||||
// format!(
|
||||
// "metadata: DocumentNodeMetadata {{ position: glam::IVec2::new({}, {}) }}, // {}",
|
||||
// node.metadata().position.x, node.metadata().position.y, node.name
|
||||
// )
|
||||
// })
|
||||
// .collect::<Vec<_>>()
|
||||
// .join("\r\n");
|
||||
// output += "\r\n";
|
||||
// output += &format!(
|
||||
// "imports_metadata: (NodeId::new(), ({}, {}).into()),\r\n",
|
||||
// network.imports_metadata.1.x, network.imports_metadata.1.y
|
||||
// );
|
||||
// output += &format!(
|
||||
// "exports_metadata: (NodeId::new(), ({}, {}).into()),",
|
||||
// network.exports_metadata.1.x, network.exports_metadata.1.y
|
||||
// );
|
||||
// output += "\r\n\r\n";
|
||||
// // KEEP THIS `debug!()` - Someday we can remove this once this development utility is no longer needed
|
||||
// log::debug!("{output}");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
NodeGraphMessage::RemoveImport { import_index: usize } => {
|
||||
network_interface.remove_import(usize, selection_network_path);
|
||||
responses.add(NodeGraphMessage::SendGraph);
|
||||
|
|
@ -1738,7 +1700,6 @@ impl NodeGraphMessageHandler {
|
|||
ToggleSelectedAsLayersOrNodes,
|
||||
ToggleSelectedLocked,
|
||||
ToggleSelectedVisibility,
|
||||
PrintSelectedNodeCoordinates,
|
||||
ShiftSelectedNodes,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -466,13 +466,11 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||
MenuBarEntry {
|
||||
label: "Debug: Print Trace Logs".into(),
|
||||
icon: Some(if log::max_level() == log::LevelFilter::Trace { "CheckboxChecked" } else { "CheckboxUnchecked" }.into()),
|
||||
shortcut: action_keys!(DebugMessageDiscriminant::ToggleTraceLogs),
|
||||
action: MenuBarEntry::create_action(|_| DebugMessage::ToggleTraceLogs.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuBarEntry {
|
||||
label: "Debug: Print Document".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::DebugPrintDocument),
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::DebugPrintDocument.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue