Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't allow guideline selection, if they are hidden. #1766

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions src/fontra/views/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,24 @@ export class EditorController {
async (...args) => await this.editListenerCallback(...args)
);

this.visualizationLayers = new VisualizationLayers(
visualizationLayerDefinitions,
this.isThemeDark
);

this.visualizationLayersSettings = newVisualizationLayersSettings(
this.visualizationLayers
);
this.visualizationLayersSettings.addListener((event) => {
this.visualizationLayers.toggle(event.key, event.newValue);
this.canvasController.requestUpdate();
}, true);

this.sceneController = new SceneController(
this.fontController,
canvasController,
applicationSettingsController
applicationSettingsController,
this.visualizationLayersSettings
);

this.sceneSettingsController = this.sceneController.sceneSettingsController;
Expand Down Expand Up @@ -164,19 +178,6 @@ export class EditorController {

this.cjkDesignFrame = new CJKDesignFrame(this);

this.visualizationLayers = new VisualizationLayers(
visualizationLayerDefinitions,
this.isThemeDark
);

this.visualizationLayersSettings = newVisualizationLayersSettings(
this.visualizationLayers
);
this.visualizationLayersSettings.addListener((event) => {
this.visualizationLayers.toggle(event.key, event.newValue);
this.canvasController.requestUpdate();
}, true);

const sceneView = new SceneView(this.sceneModel, (model, controller) =>
this.visualizationLayers.drawVisualizationLayers(model, controller)
);
Expand Down Expand Up @@ -2782,7 +2783,10 @@ export class EditorController {
}
}

if (selectGuidelines) {
if (
selectGuidelines &&
this.visualizationLayersSettings.model["fontra.guidelines"]
) {
for (const guidelineIndex of range(positionedGlyph.glyph.guidelines.length)) {
const guideline = positionedGlyph.glyph.guidelines[guidelineIndex];
if (!guideline.locked) {
Expand Down
10 changes: 8 additions & 2 deletions src/fontra/views/editor/scene-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ import { translate, translatePlural } from "/core/localization.js";
import { dialog, message } from "/web-components/modal-dialog.js";

export class SceneController {
constructor(fontController, canvasController, applicationSettingsController) {
constructor(
fontController,
canvasController,
applicationSettingsController,
visualizationLayersSettings
) {
this.canvasController = canvasController;
this.applicationSettings = applicationSettingsController.model;
this.fontController = fontController;
Expand All @@ -53,7 +58,8 @@ export class SceneController {
this.sceneModel = new SceneModel(
fontController,
this.sceneSettingsController,
isPointInPath
isPointInPath,
visualizationLayersSettings
);

this.selectedTool = undefined;
Expand Down
12 changes: 11 additions & 1 deletion src/fontra/views/editor/scene-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ import * as vector from "../core/vector.js";
import { loaderSpinner } from "/core/loader-spinner.js";

export class SceneModel {
constructor(fontController, sceneSettingsController, isPointInPath) {
constructor(
fontController,
sceneSettingsController,
isPointInPath,
visualizationLayersSettings
) {
this.fontController = fontController;
this.sceneSettingsController = sceneSettingsController;
this.sceneSettings = sceneSettingsController.model;
this.isPointInPath = isPointInPath;
this.visualizationLayersSettings = visualizationLayersSettings;
this.hoveredGlyph = undefined;
this._glyphLocations = {}; // glyph name -> glyph location
this.longestLineLength = 0;
Expand Down Expand Up @@ -681,6 +687,10 @@ export class SceneModel {
}

guidelineSelectionAtPoint(point, size, parsedCurrentSelection) {
if (!this.visualizationLayersSettings.model["fontra.guidelines"]) {
// If guidelines are hidden, don't allow selection
return new Set();
}
const positionedGlyph = this.getSelectedPositionedGlyph();
if (!positionedGlyph) {
return new Set();
Expand Down