diff --git a/src/fontra/views/editor/scene-controller.js b/src/fontra/views/editor/scene-controller.js index 1e2f31338..49eda4749 100644 --- a/src/fontra/views/editor/scene-controller.js +++ b/src/fontra/views/editor/scene-controller.js @@ -295,6 +295,9 @@ export class SceneController { this.sceneSettingsController.addKeyListener( ["selection", "hoverSelection"], (event) => { + if (event.key === "selection") { + this._checkSelectionForLockedItems(); + } this.sceneSettings.combinedSelection = union( this.sceneSettings.selection, this.sceneSettings.hoverSelection @@ -336,6 +339,17 @@ export class SceneController { }); } + _checkSelectionForLockedItems() { + if ( + this.sceneSettings.backgroundImagesAreLocked && + this.sceneSettings.selection.has("backgroundImage/0") + ) { + this.sceneSettings.selection = difference(this.sceneSettings.selection, [ + "backgroundImage/0", + ]); + } + } + setupChangeListeners() { this.fontController.addChangeListener({ glyphMap: null }, () => { this.sceneModel.updateGlyphLinesCharacterMapping(); diff --git a/src/fontra/views/editor/visualization-layer-definitions.js b/src/fontra/views/editor/visualization-layer-definitions.js index 26fe4130e..c726725ee 100644 --- a/src/fontra/views/editor/visualization-layer-definitions.js +++ b/src/fontra/views/editor/visualization-layer-definitions.js @@ -418,8 +418,8 @@ registerVisualizationLayerDefinition({ screenParameters: { strokeWidth: 2, }, - colors: { strokeColor: "#888" }, - colorsDarkMode: { strokeColor: "#FFF" }, + colors: { strokeColor: "#888", hoverStrokeColor: "#8885" }, + colorsDarkMode: { strokeColor: "#FFF", hoverStrokeColor: "#FFF5" }, draw: (context, positionedGlyph, parameters, model, controller) => { const backgroundImage = positionedGlyph.glyph.backgroundImage; @@ -466,8 +466,12 @@ registerVisualizationLayerDefinition({ const rectPoly = rectToPoints(backgroundImageBounds); const polygon = rectPoly.map((point) => affine.transformPointObject(point)); - if (model.selection.has("backgroundImage/0")) { - context.strokeStyle = parameters.strokeColor; + const isSelected = model.selection.has("backgroundImage/0"); + const isHovered = model.hoverSelection.has("backgroundImage/0"); + + if (isSelected || isHovered) { + context.strokeStyle = + isHovered && !isSelected ? parameters.hoverStrokeColor : parameters.strokeColor; context.lineWidth = parameters.strokeWidth; context.lineJoin = "round"; strokePolygon(context, polygon);