Skip to content

Commit

Permalink
Plug in select-next-source-layer functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Nov 27, 2024
1 parent 1459cbe commit a071c4f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/fontra/views/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 14 additions & 0 deletions src/fontra/views/editor/panel-designspace-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
boolInt,
enumerate,
escapeHTMLCharacters,
modulo,
objectsEqual,
range,
rgbaToCSS,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a071c4f

Please sign in to comment.