From 0013866fe37797b51449d187acfeeb392f3a4a2b Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Wed, 17 May 2017 15:16:23 -0400 Subject: [PATCH] Put shortcuts into groups, add more shortcuts for operations --- css/80_app.css | 21 +++- data/core.yaml | 77 +++++++++----- data/shortcuts.json | 223 ++++++++++++++++++++++++++-------------- dist/locales/en.json | 85 ++++++++++----- modules/ui/shortcuts.js | 32 +++--- 5 files changed, 294 insertions(+), 144 deletions(-) diff --git a/css/80_app.css b/css/80_app.css index a3e757856..25ab000fd 100644 --- a/css/80_app.css +++ b/css/80_app.css @@ -3084,6 +3084,10 @@ img.tile-removing { /* Shortcuts Modal ------------------------------------------------------- */ +.modal-shortcuts { + width: 75%; + max-width: 800px; +} .modal-shortcuts .modal-section:last-child { padding-top: 10px; @@ -3112,12 +3116,23 @@ img.tile-removing { } .modal-shortcuts .shortcut-tab { + display: flex; + flex-flow: row wrap; +} + +.modal-shortcuts .shortcut-group { + padding: 10px; + flex: 0 0 50%; display: flex; flex-direction: column; - flex-grow: 1; +} + +.modal-shortcuts .shortcut-group h3 { + text-align: center; } .modal-shortcuts .shortcut-row { + flex: 0 0 auto; display: flex; flex-direction: row; } @@ -3127,12 +3142,12 @@ img.tile-removing { color: #767676; text-align: right; padding-bottom: 5px; - width: 50%; + flex: 1 1 40%; } .modal-shortcuts .shortcut-desc { padding-bottom: 5px; - width: 50%; + flex: 1 1 60%; } .modal-shortcuts kbd { diff --git a/data/core.yaml b/data/core.yaml index 24cdea271..a007e5f5d 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -1017,28 +1017,55 @@ en: save: "Don't forget to regularly save your changes!" start: "Start mapping!" shortcuts: - modal: - title: "Keyboard shortcuts" - display: - desc: "Display" - pan_map: "Pan map" - pan_map_screen: "Pan map by one screenful" - zoom: "Zoom in / Zoom out" - zoom_large: "Zoom in / Zoom out by a lot" - bg_switcher: "Display background layer switcher" - bg: "Switch between backgrounds" - wireframe: "Toggle wireframe mode" - help: "Show in-editor help/documentation" - minimap: "Toggle minimap" - infobox: "Toggle info/measurements box" - radial_menu: "Toggle radial menu for selected object" - edit: - desc: "Editing" - add_point: "Switch to 'add point' mode" - add_line: "Switch to 'add line' mode" - add_area: "Switch to 'add area' mode" - continue_line: "Continue drawing a line at the selected node" - stop_line: "Stop drawing of a line or area" - undo: "Undo last action" - redo: "Redo last action" - save: "Save changes" \ No newline at end of file + title: "Keyboard shortcuts" + browsing: + title: "Browsing" + navigation: + title: "Navigation" + pan_map: "Pan map" + pan_map_screen: "Pan map by one screenful" + zoom: "Zoom in / Zoom out" + zoom_large: "Zoom in / Zoom out by a lot" + display: + title: "Display" + background: "Background settings" + background_switch: "Switch back to last background" + toggle_minimap: "Toggle minimap" + map_data: "Map data settings" + wireframe: "Toggle wireframe mode" + help: + title: "Help" + help: "Show help/documentation" + selected: + title: "With selected" + toggle_infobox: "Toggle info box" + toggle_menu: "Toggle edit menu" + editing: + title: "Editing" + drawing: + title: "Drawing" + add_point: "'Add point' mode" + add_line: "'Add line' mode" + add_area: "'Add area' mode" + place_point: "Place a point" + stop_line: "Stop drawing of a line or area" + operations: + title: "Operations" + continue_line: "Continue a line at the selected node" + merge: "Combine (Merge) selected items" + disconnect: "Disconnect features at the selected node" + split: "Split a line into two at the selected node" + move: "Move selected items" + rotate: "Rotate selected items" + orthagonalize: "Straighten line / Square area corners" + circularize: "Circularize an area" + reflect_long: "Reflect items across the longer axis" + reflect_short: "Reflect items across the shorter axis" + reverse: "Reverse a line" + edit: + title: "Edit" + copy: "Copy map features" + paste: "Paste map features" + undo: "Undo last action" + redo: "Redo last action" + save: "Save changes" diff --git a/data/shortcuts.json b/data/shortcuts.json index 3fe790fbf..71874356c 100644 --- a/data/shortcuts.json +++ b/data/shortcuts.json @@ -1,89 +1,156 @@ { "dataShortcuts": [ { - "key": "display", - "desc": "shortcuts.display.desc", - "shortcuts": [ + "tab": "browsing", + "text": "shortcuts.browsing.title", + "groups": [ { - "shortcut": ["↓", "↑", "←", "→"], - "key": "shortcuts.display.pan_map" - }, - { - "shortcut": ["⇧↓", "⇧↑", "⇧←", "⇧→"], - "key": "shortcuts.display.pan_map_screen" - }, - { - "shortcut": ["+", "-"], - "key": "shortcuts.display.zoom" - }, - { - "shortcut": ["⌘+", "⌘-"], - "key": "shortcuts.display.zoom_large" - }, - { - "shortcut": ["B"], - "key": "shortcuts.display.bg_switcher" - }, - { - "shortcut": ["⌘B"], - "key": "shortcuts.display.bg" - }, - { - "shortcut": ["W"], - "key": "shortcuts.display.wireframe" - }, - { - "shortcut": ["H"], - "key": "shortcuts.display.help" - }, - { - "shortcut": ["/"], - "key": "shortcuts.display.minimap" - }, - { - "shortcut": ["⌘I"], - "key": "shortcuts.display.infobox" - }, - { - "shortcut": ["Space"], - "key": "shortcuts.display.radial_menu" + "group": "navigation", + "text": "shortcuts.browsing.navigation.title", + "shortcuts": [ + { + "shortcut": ["↓", "↑", "←", "→"], + "text": "shortcuts.browsing.navigation.pan_map" + }, { + "shortcut": ["⇧↓", "⇧↑", "⇧←", "⇧→"], + "text": "shortcuts.browsing.navigation.pan_map_screen" + }, { + "shortcut": ["+", "-"], + "text": "shortcuts.browsing.navigation.zoom" + }, { + "shortcut": ["⌘+", "⌘-"], + "text": "shortcuts.browsing.navigation.zoom_large" + } + ] + }, { + "group": "display", + "text": "shortcuts.browsing.display.title", + "shortcuts": [ + { + "shortcut": ["B"], + "text": "shortcuts.browsing.display.background" + }, { + "shortcut": ["⌘B"], + "text": "shortcuts.browsing.display.background_switch" + }, { + "shortcut": ["/"], + "text": "shortcuts.browsing.display.toggle_minimap" + }, { + "shortcut": ["F"], + "text": "shortcuts.browsing.display.map_data" + }, { + "shortcut": ["W"], + "text": "shortcuts.browsing.display.wireframe" + } + ] + }, { + "group": "help", + "text": "shortcuts.browsing.help.title", + "shortcuts": [ + { + "shortcut": ["H"], + "text": "shortcuts.browsing.help.help" + } + ] + }, { + "group": "selected", + "text": "shortcuts.browsing.selected.title", + "shortcuts": [ + { + "shortcut": ["⌘I"], + "text": "shortcuts.browsing.selected.toggle_infobox" + }, { + "shortcut": ["Space"], + "text": "shortcuts.browsing.selected.toggle_menu" + } + ] } ] }, { - "key": "edit", - "desc": "shortcuts.edit.desc", - "shortcuts": [ + "tab": "editing", + "text": "shortcuts.editing.title", + "groups": [ { - "shortcut": ["1"], - "key": "shortcuts.edit.add_point" - }, - { - "shortcut": ["2"], - "key": "shortcuts.edit.add_line" - }, - { - "shortcut": ["3"], - "key": "shortcuts.edit.add_area" - }, - { - "shortcut": ["A"], - "key": "shortcuts.edit.continue_line" - }, - { - "shortcut": ["↵ Enter", "Esc"], - "key": "shortcuts.edit.stop_line" - }, - { - "shortcut": ["⌘Z"], - "key": "shortcuts.edit.undo" - }, - { - "shortcut": ["⌘⇧Z"], - "key": "shortcuts.edit.redo" - }, - { - "shortcut": ["⌘S"], - "key": "shortcuts.edit.save" + "group": "drawing", + "text": "shortcuts.editing.drawing.title", + "shortcuts": [ + { + "shortcut": ["1"], + "text": "shortcuts.editing.drawing.add_point" + }, { + "shortcut": ["2"], + "text": "shortcuts.editing.drawing.add_line" + }, { + "shortcut": ["3"], + "text": "shortcuts.editing.drawing.add_area" + }, { + "shortcut": ["Space"], + "text": "shortcuts.editing.drawing.place_point" + }, { + "shortcut": ["↵ Enter", "Esc"], + "text": "shortcuts.editing.drawing.stop_line" + } + ] + }, { + "group": "operations", + "text": "shortcuts.editing.operations.title", + "shortcuts": [ + { + "shortcut": ["A"], + "text": "shortcuts.editing.operations.continue_line" + }, { + "shortcut": ["C"], + "text": "shortcuts.editing.operations.merge" + }, { + "shortcut": ["D"], + "text": "shortcuts.editing.operations.disconnect" + }, { + "shortcut": ["X"], + "text": "shortcuts.editing.operations.split" + }, { + "shortcut": ["M"], + "text": "shortcuts.editing.operations.move" + }, { + "shortcut": ["R"], + "text": "shortcuts.editing.operations.rotate" + }, { + "shortcut": ["S"], + "text": "shortcuts.editing.operations.orthagonalize" + }, { + "shortcut": ["O"], + "text": "shortcuts.editing.operations.circularize" + }, { + "shortcut": ["T"], + "text": "shortcuts.editing.operations.reflect_long" + }, { + "shortcut": ["Y"], + "text": "shortcuts.editing.operations.reflect_short" + }, { + "shortcut": ["V"], + "text": "shortcuts.editing.operations.reverse" + } + ] + }, { + "group": "edit", + "text": "shortcuts.editing.edit.title", + "shortcuts": [ + { + "shortcut": ["⌘C"], + "text": "shortcuts.editing.edit.copy" + }, { + "shortcut": ["⌘V"], + "text": "shortcuts.editing.edit.paste" + }, { + "shortcut": ["⌘Z"], + "text": "shortcuts.editing.edit.undo" + }, { + "shortcut": ["⌘⇧Z"], + "text": "shortcuts.editing.edit.redo" + }, { + "shortcut": ["⌘S"], + "text": "shortcuts.editing.edit.save" + } + ] } ] } diff --git a/dist/locales/en.json b/dist/locales/en.json index 59b3e21bc..9151864d2 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -884,33 +884,66 @@ } }, "shortcuts": { - "modal": { - "title": "Keyboard shortcuts" + "title": "Keyboard shortcuts", + "browsing": { + "title": "Browsing", + "navigation": { + "title": "Navigation", + "pan_map": "Pan map", + "pan_map_screen": "Pan map by one screenful", + "zoom": "Zoom in / Zoom out", + "zoom_large": "Zoom in / Zoom out by a lot" + }, + "display": { + "title": "Display", + "background": "Background settings", + "background_switch": "Switch back to last background", + "toggle_minimap": "Toggle minimap", + "map_data": "Map data settings", + "wireframe": "Toggle wireframe mode" + }, + "help": { + "title": "Help", + "help": "Show help/documentation" + }, + "selected": { + "title": "With selected", + "toggle_infobox": "Toggle info box", + "toggle_menu": "Toggle edit menu" + } }, - "display": { - "desc": "Display", - "pan_map": "Pan map", - "pan_map_screen": "Pan map by one screenful", - "zoom": "Zoom in / Zoom out", - "zoom_large": "Zoom in / Zoom out by a lot", - "bg_switcher": "Display background layer switcher", - "bg": "Switch between backgrounds", - "wireframe": "Toggle wireframe mode", - "help": "Show in-editor help/documentation", - "minimap": "Toggle minimap", - "infobox": "Toggle info/measurements box", - "radial_menu": "Toggle radial menu for selected object" - }, - "edit": { - "desc": "Editing", - "add_point": "Switch to 'add point' mode", - "add_line": "Switch to 'add line' mode", - "add_area": "Switch to 'add area' mode", - "continue_line": "Continue drawing a line at the selected node", - "stop_line": "Stop drawing of a line or area", - "undo": "Undo last action", - "redo": "Redo last action", - "save": "Save changes" + "editing": { + "title": "Editing", + "drawing": { + "title": "Drawing", + "add_point": "'Add point' mode", + "add_line": "'Add line' mode", + "add_area": "'Add area' mode", + "place_point": "Place a point", + "stop_line": "Stop drawing of a line or area" + }, + "operations": { + "title": "Operations", + "continue_line": "Continue a line at the selected node", + "merge": "Combine (Merge) selected items", + "disconnect": "Disconnect features at the selected node", + "split": "Split a line into two at the selected node", + "move": "Move selected items", + "rotate": "Rotate selected items", + "orthagonalize": "Straighten line / Square area corners", + "circularize": "Circularize an area", + "reflect_long": "Reflect items across the longer axis", + "reflect_short": "Reflect items across the shorter axis", + "reverse": "Reverse a line" + }, + "edit": { + "title": "Edit", + "copy": "Copy map features", + "paste": "Paste map features", + "undo": "Undo last action", + "redo": "Redo last action", + "save": "Save changes" + } } }, "presets": { diff --git a/modules/ui/shortcuts.js b/modules/ui/shortcuts.js index 3b20ecf33..abe7385a5 100644 --- a/modules/ui/shortcuts.js +++ b/modules/ui/shortcuts.js @@ -36,14 +36,14 @@ export function uiShortcuts() { .append('div') .attr('class', 'modal-section') .append('h3') - .text(t('shortcuts.modal.title')); + .text(t('shortcuts.title')); shortcutsModal - .call(renderTabs); + .call(render); } - function renderTabs(selection) { + function render(selection) { var wrapper = selection .selectAll('.wrapper') .data([0]); @@ -73,12 +73,12 @@ export function uiShortcuts() { .attr('class', 'tab') .on('click', function (d, i) { activeTab = i; - renderTabs(selection); + render(selection); }); tabsEnter .append('span') - .text(function (d) { return t(d.desc); }); + .text(function (d) { return t(d.text); }); tabs = tabs .merge(tabsEnter); @@ -97,13 +97,21 @@ export function uiShortcuts() { var shortcutsEnter = shortcuts .enter() .append('div') - .attr('class', 'shortcut-tab') - .on('click', function (d, i) { - activeTab = i; - renderTabs(selection); - }); + .attr('class', 'shortcut-tab'); - var row = shortcutsEnter + + var groupsEnter = shortcutsEnter + .selectAll('.shortcut-group') + .data(function (d) { return d.groups; }) + .enter() + .append('div') + .attr('class', 'shortcut-group'); + + groupsEnter + .append('h3') + .text(function(d) { return t(d.text); }); + + var row = groupsEnter .selectAll('.shortcut-row') .data(function (d) { return d.shortcuts; }) .enter() @@ -124,7 +132,7 @@ export function uiShortcuts() { row .append('div') .attr('class', 'shortcut-desc') - .text(function (d) { return t(d.key); }); + .text(function (d) { return t(d.text); }); shortcuts = shortcuts .merge(shortcutsEnter);