Skip to content

Commit

Permalink
Make edit source properties set locationBase
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Oct 4, 2024
1 parent 30fd72b commit 09f6326
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/fontra/views/editor/panel-designspace-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,14 +888,19 @@ export default class DesignspaceNavigationPanel extends Panel {
return;
}

const filteredLocation = stripLocation(newLocation, locationBase, glyph);

await this.sceneController.editGlyphAndRecordChanges((glyph) => {
const source = glyph.sources[sourceIndex];
if (!objectsEqual(source.location, newLocation)) {
source.location = newLocation;
if (!objectsEqual(source.location, filteredLocation)) {
source.location = filteredLocation;
}
if (sourceName !== source.name) {
source.name = sourceName;
}

source.locationBase = locationBase;

const oldLayerName = source.layerName;
if (layerName !== oldLayerName) {
source.layerName = layerName;
Expand Down Expand Up @@ -968,7 +973,7 @@ export default class DesignspaceNavigationPanel extends Panel {
validateInput();
});

const glyphAxisNames = new Set(glyph.axes.map((axis) => axis.name));
const glyphAxisNames = getGlyphAxisNamesSet(glyph);

nameController.addKeyListener("locationBase", (event) => {
if (!event.newValue) {
Expand Down Expand Up @@ -1072,10 +1077,10 @@ export default class DesignspaceNavigationPanel extends Panel {
}

_sourcePropertiesLocationAxes(glyph) {
const glyphAxisNames = glyph.axes.map((axis) => axis.name);
const glyphAxisNames = getGlyphAxisNamesSet(glyph);
const fontAxes = mapAxesFromUserSpaceToSourceSpace(
// Don't include font axes that also exist as glyph axes
this.fontController.fontAxes.filter((axis) => !glyphAxisNames.includes(axis.name))
this.fontController.fontAxes.filter((axis) => !glyphAxisNames.has(axis.name))
);
return [
...fontAxes,
Expand Down Expand Up @@ -1319,6 +1324,17 @@ function suggestedSourceNameFromLocation(location) {
);
}

function getGlyphAxisNamesSet(glyph) {
return new Set(glyph.axes.map((axis) => axis.name));
}

function stripLocation(location, locationBase, glyph) {
const glyphAxisNames = getGlyphAxisNamesSet(glyph);
return locationBase
? filterObject(location, (name, value) => !glyphAxisNames.has(name))
: location;
}

function makeIconCellFactory(
iconPaths,
triggerOnDoubleClick = false,
Expand Down

0 comments on commit 09f6326

Please sign in to comment.