From b5c04526e8e2551e5ef01a8a1f59aaeaae0aded0 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Sun, 17 Nov 2024 18:26:01 +0100 Subject: [PATCH 1/3] Make bg image show hover stroke --- .../views/editor/visualization-layer-definitions.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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); From 4edcd07ff45009c5705cb4c2175e0c2946f477d9 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Sun, 17 Nov 2024 18:52:00 +0100 Subject: [PATCH 2/3] Ensure the selection can't contain bg image if bg images are locked --- src/fontra/views/editor/scene-controller.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/fontra/views/editor/scene-controller.js b/src/fontra/views/editor/scene-controller.js index 1e2f31338..43e6d50db 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,18 @@ export class SceneController { }); } + _checkSelectionForLockedItems() { + if ( + this.sceneSettings.backgroundImagesAreLocked && + this.sceneSettings.selection.has("backgroundImage/0") + ) { + this.sceneSettings.selection = difference(this.sceneSettings.selection, [ + "backgroundImage/0", + ]); + console.log("did something"); + } + } + setupChangeListeners() { this.fontController.addChangeListener({ glyphMap: null }, () => { this.sceneModel.updateGlyphLinesCharacterMapping(); From 7ad8d6dd8b38efa7e2fab72d6a81a14aaf9a93aa Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Sun, 17 Nov 2024 18:53:16 +0100 Subject: [PATCH 3/3] Removed debug log --- src/fontra/views/editor/scene-controller.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fontra/views/editor/scene-controller.js b/src/fontra/views/editor/scene-controller.js index 43e6d50db..49eda4749 100644 --- a/src/fontra/views/editor/scene-controller.js +++ b/src/fontra/views/editor/scene-controller.js @@ -347,7 +347,6 @@ export class SceneController { this.sceneSettings.selection = difference(this.sceneSettings.selection, [ "backgroundImage/0", ]); - console.log("did something"); } }