selectChild as standalone.

Keyboard shortcuts new section - way selected
Moved 'help' section to left in keyboard section
This commit is contained in:
Milos Brzakovic
2021-07-14 17:43:54 +02:00
parent c8f162b8f0
commit 416799ceb6
4 changed files with 47 additions and 18 deletions

View File

@@ -2300,8 +2300,10 @@ en:
first: "Jump to first node"
last: "Jump to last node"
parent: "Select parent way"
child: "Select child node"
change_parent: "Switch parent way"
way_selected:
title: "With way selected"
child: "Select child node"
editing:
title: "Editing"
drawing:

View File

@@ -85,11 +85,7 @@
{
"shortcuts": ["map_data.highlight_edits.key"],
"text": "shortcuts.browsing.display_options.highlight_edits"
}
]
},
{
"rows": [
},
{
"section": "help",
"text": "shortcuts.browsing.help.title"
@@ -101,7 +97,11 @@
{
"shortcuts": ["shortcuts.toggle.key", "?"],
"text": "shortcuts.browsing.help.keyboard"
},
}
]
},
{
"rows": [
{
"section": "selecting",
"text": "shortcuts.browsing.selecting.title"
@@ -163,14 +163,18 @@
"shortcuts": ["↑"],
"text": "shortcuts.browsing.vertex_selected.parent"
},
{
"modifiers": ["⌘"],
"shortcuts": ["↓"],
"text": "shortcuts.browsing.vertex_selected.child"
},
{
"shortcuts": ["\\", "shortcuts.key.pause"],
"text": "shortcuts.browsing.vertex_selected.change_parent"
},
{
"section": "way_selected",
"text": "shortcuts.browsing.way_selected.title"
},
{
"modifiers": ["⌘"],
"shortcuts": ["↓"],
"text": "shortcuts.browsing.way_selected.child"
}
]
}

File diff suppressed because one or more lines are too long

View File

@@ -113,6 +113,31 @@ export function modeSelect(context, selectedIDs) {
return parents;
}
// find the child nodes for selected ways
function childNodeIdsOfSelection(onlyCommon) {
var graph = context.graph();
var childs = [];
for (var i = 0; i < selectedIDs.length; i++) {
var entity = context.hasEntity(selectedIDs[i]);
if (!entity || !['area', 'line'].includes(entity.geometry(graph))){
return []; // selection includes non-area/non-line
}
var currChilds = graph.childNodes(entity).map(function(node) { return node.id; });
if (!childs.length) {
childs = currChilds;
continue;
}
childs = (onlyCommon ? utilArrayIntersection : utilArrayUnion)(childs, currChilds);
if (!childs.length) {
return [];
}
}
return childs;
}
function checkFocusedParent() {
if (_focusedParentWayId) {
@@ -590,16 +615,14 @@ export function modeSelect(context, selectedIDs) {
d3_event.preventDefault();
var currentSelectedIds = mode.selectedIDs();
var parentIds = _focusedParentWayId ? [_focusedParentWayId] : parentWaysIdsOfSelection(false);
if (parentIds.length) return;
var reselectIds = _focusedVertexIds && _focusedVertexIds.filter(id => context.hasEntity(id));
if (!reselectIds || !reselectIds.length) return;
var childIds = _focusedVertexIds ? _focusedVertexIds.filter(id => context.hasEntity(id)) : childNodeIdsOfSelection(true);
if (!childIds || !childIds.length) return;
if (currentSelectedIds.length === 1) _focusedParentWayId = currentSelectedIds[0];
context.enter(
mode.selectedIDs(_focusedVertexIds)
mode.selectedIDs(childIds)
);
}
};