From a071c4f8ad3c300aa1aad375d6644f4857f9d92a Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Wed, 27 Nov 2024 20:54:11 +0100 Subject: [PATCH] Plug in select-next-source-layer functionality --- src/fontra/views/editor/editor.js | 5 +++-- .../views/editor/panel-designspace-navigation.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/fontra/views/editor/editor.js b/src/fontra/views/editor/editor.js index 48edad73a..e52e7921f 100644 --- a/src/fontra/views/editor/editor.js +++ b/src/fontra/views/editor/editor.js @@ -1608,7 +1608,7 @@ export class EditorController { this.glyphSelectedContextMenuItems = []; this.glyphSelectedContextMenuItems.push({ - title: "Select glyph/source/layer", + title: translate("menubar.view.select-glyph-source-layer"), getItems: () => [ { actionIdentifier: "action.select-previous-glyph" }, { actionIdentifier: "action.select-next-glyph" }, @@ -3102,7 +3102,8 @@ export class EditorController { } async doSelectPreviousNextSourceLayer(selectPrevious) { - console.log("next source layer", selectPrevious); + const panel = this.getSidebarPanel("designspace-navigation"); + panel?.doSelectPreviousNextSourceLayer(selectPrevious); } async doSelectPreviousNextGlyph(selectPrevious) { diff --git a/src/fontra/views/editor/panel-designspace-navigation.js b/src/fontra/views/editor/panel-designspace-navigation.js index 19b7c4b8e..b7912d2ab 100644 --- a/src/fontra/views/editor/panel-designspace-navigation.js +++ b/src/fontra/views/editor/panel-designspace-navigation.js @@ -9,6 +9,7 @@ import { boolInt, enumerate, escapeHTMLCharacters, + modulo, objectsEqual, range, rgbaToCSS, @@ -870,6 +871,19 @@ export default class DesignspaceNavigationPanel extends Panel { } } + doSelectPreviousNextSourceLayer(selectPrevious) { + if (this.sourceLayersList.items.length < 2) { + return; + } + + const index = this.sourceLayersList.getSelectedItemIndex() || 0; + const newIndex = modulo( + index + (selectPrevious ? -1 : 1), + this.sourceLayersList.items.length + ); + this.sourceLayersList.setSelectedItemIndex(newIndex, true); + } + _updateRemoveSourceButtonState() { this.addRemoveSourceButtons.disableRemoveButton = this.sourcesList.getSelectedItemIndex() === undefined;