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

Font overview phase 1 #1849

Merged
merged 91 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
3c759f4
First basic skeleton for font overview
ollimeier Dec 10, 2024
8b45948
Update HTML title
ollimeier Dec 10, 2024
27523b4
First draft of 'Font overview'
ollimeier Dec 11, 2024
3709484
Fix userLocation + add comments for TODOs
ollimeier Dec 11, 2024
a22e41d
Bugfix: open slash via double click within font overview
ollimeier Dec 15, 2024
de2e1b2
Rebase with main and make use of fontController.getSortedSourceIdenti…
ollimeier Dec 15, 2024
3bcd081
Make the code more equal to 'Related glyphs' eg. include accordion fo…
ollimeier Dec 15, 2024
31e44a5
Removing obsolete CSS
ollimeier Dec 15, 2024
788ff52
Font overview: add multi glyph selection
ollimeier Dec 16, 2024
d510469
Fix lazy loading, and removing the need for a weird extra margin by m…
justvanrossum Dec 16, 2024
86eef76
Use String.fromCodePoint() instead of .fromCharCode(), whcih supports…
justvanrossum Dec 16, 2024
e26dc44
By default, the default source should be selected.
ollimeier Dec 16, 2024
25a20d9
Rework how font overview selection via click works
ollimeier Dec 17, 2024
7972440
Update TODO comments
ollimeier Dec 17, 2024
137d23f
Bugfix: if glyphSelection is empty
ollimeier Dec 17, 2024
6978496
Remove unnecessary preventDefault, improve handleDoubleClick, add mis…
ollimeier Dec 17, 2024
c4134d1
Extend TODO comment
ollimeier Dec 17, 2024
ebf14a8
First draft of handleArrowKeys
ollimeier Dec 17, 2024
f928fce
Removing hash from font overview URL
ollimeier Dec 17, 2024
6c28035
add cell-selected-color and adjust colors of GlyphCell
ollimeier Dec 17, 2024
ae52bb2
Fix view with scrollIntoView when arrow-keying
ollimeier Dec 17, 2024
461387b
Add multi-selection with arrowKey left and right
ollimeier Dec 17, 2024
0341f39
Refactoring
ollimeier Dec 18, 2024
46370bf
commit work in progress of handling arrowKeys
ollimeier Dec 18, 2024
ba24a39
Un-refactor findParentWithClass in the hope we can merge from main mo…
justvanrossum Dec 19, 2024
3079ad8
Merge branch 'main' into issue-102-font-overview
justvanrossum Dec 19, 2024
f01883b
Apply refactorings from main
justvanrossum Dec 19, 2024
ee023d1
Use GlyphsSearchField
justvanrossum Dec 19, 2024
8d34f30
Clean up imports
justvanrossum Dec 19, 2024
23da0db
Use new view-controller superclass; use loaderSpinner
justvanrossum Dec 19, 2024
bdee151
Merge branch 'main' into issue-102-font-overview
justvanrossum Dec 19, 2024
6ea86d1
Make font overview respond to changes in other windows
justvanrossum Dec 19, 2024
7bf1d32
This is handled by the superclass
justvanrossum Dec 19, 2024
0dd403f
Make 'selected' a property of the glyph cell, instead of using a method
justvanrossum Dec 19, 2024
82c95bb
Fix typo
justvanrossum Dec 19, 2024
5b6b2b8
Remove unused funcs
justvanrossum Dec 19, 2024
fa8b18d
Add convenience method for querySelectorAll
justvanrossum Dec 19, 2024
d92b836
More cleanup
justvanrossum Dec 19, 2024
a83bd5c
Cleanup imports
justvanrossum Dec 19, 2024
fcc8594
Reworking glyph selection
justvanrossum Dec 19, 2024
af50847
Fix double click
justvanrossum Dec 19, 2024
8a8cf67
Remove debug log
justvanrossum Dec 19, 2024
dff9ee0
Only reset autoViewBox if the selected glyph is the same
justvanrossum Dec 19, 2024
0f2e95c
Ignore dbl click in single click handler
justvanrossum Dec 19, 2024
c8278ef
Make handleDoubleClick signature consistent with handleSingleClick
justvanrossum Dec 19, 2024
de30284
Add cells lazily, avoiding adding all cells at once, which is slow fo…
justvanrossum Dec 20, 2024
b5cd930
Merge branch 'main' into issue-102-font-overview
justvanrossum Dec 20, 2024
36864ad
Don't handle arrow keys if the focus is not on the cell view
justvanrossum Dec 20, 2024
dec0bbc
Factor out GlyphCellView into its own web component
justvanrossum Dec 21, 2024
fc906bf
Fix imports; remove some code-to-be-rewritten
justvanrossum Dec 21, 2024
f3bd361
Fix double click on selection
justvanrossum Dec 21, 2024
1306692
Remove unneeded async qualifier
justvanrossum Dec 21, 2024
38593ab
Minor refactor
justvanrossum Dec 21, 2024
4d4dcc0
Use ObservableController for glyph selection
justvanrossum Dec 21, 2024
45044bd
Rename class and variable to make more sense
justvanrossum Dec 21, 2024
e65396e
Factor out location getting
justvanrossum Dec 21, 2024
c47cb1f
Factor out openGlyphs() func
justvanrossum Dec 21, 2024
cb86e01
Factor out navigation
justvanrossum Dec 21, 2024
87ab2fe
Remove redundant comment and async qualifier
justvanrossum Dec 21, 2024
0f0cef6
Move view setup closer to sidebar setup
justvanrossum Dec 21, 2024
ee641ae
whitespace
justvanrossum Dec 21, 2024
39703ea
Rename function name
justvanrossum Dec 21, 2024
b1237f1
Fix layout
justvanrossum Dec 21, 2024
5ac7b01
Prevent adding the same style multiple times by calling the correct m…
justvanrossum Dec 21, 2024
7e565cc
Make glyph cell size dynamic via CSS var
justvanrossum Dec 21, 2024
2b85015
Make glyph cell size resizable via external CSS var
justvanrossum Dec 21, 2024
3e937a7
Set svg width also to 100% to avoid unneeded cropping along side bear…
justvanrossum Dec 21, 2024
c30ce8d
Merge branch 'main' into issue-102-font-overview
justvanrossum Dec 22, 2024
404fe05
Don't put glyph in edit mode if it doesn't exist
justvanrossum Dec 22, 2024
f7ce489
Remove unneeded property
justvanrossum Dec 22, 2024
eb2992d
Remove redundant line
justvanrossum Dec 22, 2024
a4f8b38
Remove unneeded async/await
justvanrossum Dec 22, 2024
ad31271
Respond to changes in the glyph map
justvanrossum Dec 22, 2024
2baa5ea
Merge branch 'main' into issue-102-font-overview
justvanrossum Dec 22, 2024
8de4774
Move creating glyph items list to search field
justvanrossum Dec 22, 2024
a15d577
Adapt to glyphs-search-* changes
justvanrossum Dec 22, 2024
09d94c3
Add helper func to turn a glyphMap into a list of {glyphName, codePoi…
justvanrossum Dec 22, 2024
0738c63
Remove non-redundant func, refactor to use new func
justvanrossum Dec 22, 2024
5f26590
Adapt to new glyphMapToItemList func, avoid peeking too deeply into t…
justvanrossum Dec 22, 2024
6f25061
Make sidebar narrower, use em instead of px
justvanrossum Dec 22, 2024
c8f66c9
Update selection if glyphMap changes; set selection on cell construct…
justvanrossum Dec 22, 2024
bf5dd8c
Merge branch 'main' into issue-102-font-overview
justvanrossum Dec 22, 2024
3a2e8c7
Fiddle with UI strings
justvanrossum Dec 22, 2024
d2819f9
forgotten unicode -> codePoints change
justvanrossum Dec 22, 2024
ffe88a6
Fix cell width glitch with zero-wwidth glyphs
justvanrossum Dec 22, 2024
5494e56
Improve method name
justvanrossum Dec 22, 2024
dc6dc79
Remove redundant class
justvanrossum Dec 22, 2024
7793ad1
Reset scroll after changing glyph set
justvanrossum Dec 22, 2024
08ed0c3
Add test for glyphMapToItemList
justvanrossum Dec 22, 2024
1b6e89f
Improve comment
justvanrossum Dec 22, 2024
eb66d35
Disable Window / Font overview menu for now
justvanrossum Dec 22, 2024
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fontra-workflow = "fontra.workflow.command:main"

[project.entry-points."fontra.views"]
editor = "fontra.views.editor"
fontoverview = "fontra.views.fontoverview"
fontinfo = "fontra.views.fontinfo"
applicationsettings = "fontra.views.applicationsettings"

Expand Down
2 changes: 1 addition & 1 deletion src/fontra/client/core/font-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class FontController {
return this._rootObject.sources;
}

async getSortedSourceIdentifiers() {
getSortedSourceIdentifiers() {
const fontAxesSourceSpace = mapAxesFromUserSpaceToSourceSpace(this.fontAxes);
const sortFunc = (identifierA, identifierB) => {
for (const axis of fontAxesSourceSpace) {
Expand Down
2 changes: 1 addition & 1 deletion src/fontra/client/core/html-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class SimpleElement extends HTMLElement {

_attachStyles() {
if (this.constructor.styles) {
this.appendStyle(this.constructor.styles);
this._appendStyle(this.constructor.styles);
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/fontra/client/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,3 +683,10 @@ export class FocusKeeper {
this._focusedElement?.focus();
}
}

export function glyphMapToItemList(glyphMap) {
return Object.entries(glyphMap).map(([glyphName, codePoints]) => ({
glyphName,
codePoints,
}));
}
3 changes: 3 additions & 0 deletions src/fontra/client/lang/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export const strings = {
"font-info.vendorid": "Hersteller ID",
"font-info.version.major": "Hauptversionsnummer",
"font-info.version.minor": "Nebenversionsnummer",
"font-overview.title": "Font overview",
"guideline.labels.angle": "Neigung",
"guideline.labels.locked": "Gesperrt",
"guideline.labels.name": "Name",
Expand Down Expand Up @@ -238,6 +239,7 @@ export const strings = {
"menubar.view.select-previous-glyph": "Vorheriger Glyph",
"menubar.view.select-previous-source": "Vorherige Source",
"menubar.view.select-previous-source-layer": "Select previous source layer",
"menubar.window": "Window",
"message.cancel-editing": "Jemand anderes hat vor dir etwas geändert.",
"message.edit-has-been-reverted": "Die Änderung wurde rückgängig gemacht.",
"message.glyph-could-not-be-saved": "Glyph konnte nicht gespeichert werden.",
Expand Down Expand Up @@ -301,6 +303,7 @@ export const strings = {
"Auch den dazugehörigen Layer %0 entfernen",
"sidebar.designspace-navigation.warning.delete-source":
"Bist du sicher, dass du Source %0 entfernen willst?",
"sidebar.font-overview.font-source": "Font source",
"sidebar.glyph-note": "Glyph-Notiz",
"sidebar.glyph-note.glyph-note-for-glyph": "Glyph-Notiz für %0",
"sidebar.glyph-note.no-glyph-selected": "(keine Glyphe ausgewählt)",
Expand Down
3 changes: 3 additions & 0 deletions src/fontra/client/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export const strings = {
"font-info.vendorid": "Vendor ID",
"font-info.version.major": "Version Major",
"font-info.version.minor": "Version Minor",
"font-overview.title": "Font overview",
"guideline.labels.angle": "Angle",
"guideline.labels.locked": "Locked",
"guideline.labels.name": "Name",
Expand Down Expand Up @@ -233,6 +234,7 @@ export const strings = {
"menubar.view.select-previous-glyph": "Select previous glyph",
"menubar.view.select-previous-source": "Select previous source",
"menubar.view.select-previous-source-layer": "Select previous source layer",
"menubar.window": "Window",
"message.cancel-editing": "Someone else made an edit just before you.",
"message.edit-has-been-reverted": "The edit has been reverted.",
"message.glyph-could-not-be-saved": "The glyph could not be saved.",
Expand Down Expand Up @@ -293,6 +295,7 @@ export const strings = {
"Also delete associated layer %0",
"sidebar.designspace-navigation.warning.delete-source":
"Are you sure you want to delete source %0?",
"sidebar.font-overview.font-source": "Font source",
"sidebar.glyph-note": "Glyph Note",
"sidebar.glyph-note.glyph-note-for-glyph": "Glyph Note for %0",
"sidebar.glyph-note.no-glyph-selected": "(No glyph selected)",
Expand Down
3 changes: 3 additions & 0 deletions src/fontra/client/lang/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export const strings = {
"font-info.vendorid": "Identifiant du vendeur",
"font-info.version.major": "Version Major",
"font-info.version.minor": "Version Minor",
"font-overview.title": "Font overview",
"guideline.labels.angle": "Angle",
"guideline.labels.locked": "Vérouillé",
"guideline.labels.name": "Nom",
Expand Down Expand Up @@ -238,6 +239,7 @@ export const strings = {
"menubar.view.select-previous-glyph": "Sélectionner le glyphe précédente",
"menubar.view.select-previous-source": "Sélectionner la source précédente",
"menubar.view.select-previous-source-layer": "Select previous source layer",
"menubar.window": "Window",
"message.cancel-editing": "Quelqu'un d'autre a édité juste avant vous",
"message.edit-has-been-reverted": "L'édition a été annulé",
"message.glyph-could-not-be-saved": "Le glyphe n'a pas pu être enregistré",
Expand Down Expand Up @@ -305,6 +307,7 @@ export const strings = {
"Also delete associated layer %0",
"sidebar.designspace-navigation.warning.delete-source":
"Êtes-vous sûr de vouloir supprimer la source %0",
"sidebar.font-overview.font-source": "Font source",
"sidebar.glyph-note": "Note du glyphe",
"sidebar.glyph-note.glyph-note-for-glyph": "Note du glyphe %0",
"sidebar.glyph-note.no-glyph-selected": "(aucun glyphe sélectionné)",
Expand Down
3 changes: 3 additions & 0 deletions src/fontra/client/lang/ja.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export const strings = {
"font-info.vendorid": "ベンダーID",
"font-info.version.major": "メジャーバージョン",
"font-info.version.minor": "マイナーバージョン",
"font-overview.title": "Font overview",
"guideline.labels.angle": "角度",
"guideline.labels.locked": "ロック",
"guideline.labels.name": "ガイド名",
Expand Down Expand Up @@ -236,6 +237,7 @@ export const strings = {
"menubar.view.select-previous-glyph": "前のグリフを選択",
"menubar.view.select-previous-source": "前のソースを選択",
"menubar.view.select-previous-source-layer": "前のソースレイヤーを選択",
"menubar.window": "Window",
"message.cancel-editing": "他のユーザーがあなたの直前に操作を行いました。",
"message.edit-has-been-reverted": "このグリフは前の状態に戻されました。",
"message.glyph-could-not-be-saved": "このグリフは保存されません。",
Expand Down Expand Up @@ -296,6 +298,7 @@ export const strings = {
"sidebar.designspace-navigation.warning.delete-associated-layer":
"同様にレイヤー%0も削除",
"sidebar.designspace-navigation.warning.delete-source": "ソース%0を削除しますか?",
"sidebar.font-overview.font-source": "Font source",
"sidebar.glyph-note": "グリフノート",
"sidebar.glyph-note.glyph-note-for-glyph": "%0のグリフノート",
"sidebar.glyph-note.no-glyph-selected": "(グリフが選択されていません)",
Expand Down
3 changes: 3 additions & 0 deletions src/fontra/client/lang/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export const strings = {
"font-info.vendorid": "Vendor ID",
"font-info.version.major": "Versie major",
"font-info.version.minor": "Versie minor",
"font-overview.title": "Font overview",
"guideline.labels.angle": "Angle",
"guideline.labels.locked": "Locked",
"guideline.labels.name": "Naam",
Expand Down Expand Up @@ -237,6 +238,7 @@ export const strings = {
"menubar.view.select-previous-glyph": "Select previous glyph",
"menubar.view.select-previous-source": "Selecteer de vorige source",
"menubar.view.select-previous-source-layer": "Select previous source layer",
"menubar.window": "Window",
"message.cancel-editing": "Someone else made an edit just before you.",
"message.edit-has-been-reverted": "The edit has been reverted.",
"message.glyph-could-not-be-saved": "The glyph could not be saved.",
Expand Down Expand Up @@ -297,6 +299,7 @@ export const strings = {
"Also delete associated layer %0",
"sidebar.designspace-navigation.warning.delete-source":
"Are you sure you want to delete source %0?",
"sidebar.font-overview.font-source": "Font source",
"sidebar.glyph-note": "Glyph notitie",
"sidebar.glyph-note.glyph-note-for-glyph": "Glyph Note for %0",
"sidebar.glyph-note.no-glyph-selected": "(No glyph selected)",
Expand Down
5 changes: 4 additions & 1 deletion src/fontra/client/lang/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const strings = {
"dialog.cant-edit-glyph.content.locked-glyph": "该字形已被锁定。",
"dialog.cant-edit-glyph.title": "无法编辑字形 “%0”",
"dialog.create": "创建",
"dialog.create-new-glyph.body": '如果你想%1创建一个新的字形 "%0",请点击 "创建"。',
"dialog.create-new-glyph.body": '如果你想创建一个新的字形 "%0"%1,请点击 "创建"。',
"dialog.create-new-glyph.body.2": '为字符 "%0" (%1)',
"dialog.create-new-glyph.title": '创建新字形 "%0"?',
"dialog.delete": "删除",
Expand Down Expand Up @@ -193,6 +193,7 @@ export const strings = {
"font-info.vendorid": "供应商 ID",
"font-info.version.major": "主要版本号",
"font-info.version.minor": "次要版本号",
"font-overview.title": "字体概览",
"guideline.labels.angle": "角度",
"guideline.labels.locked": "已锁定",
"guideline.labels.name": "名称",
Expand Down Expand Up @@ -224,6 +225,7 @@ export const strings = {
"menubar.view.select-previous-glyph": "选择上一个字形",
"menubar.view.select-previous-source": "选择上一个源",
"menubar.view.select-previous-source-layer": "选择上一个源图层",
"menubar.window": "窗口",
"message.cancel-editing": "有人在你之前做了编辑。",
"message.edit-has-been-reverted": "编辑将被复原。",
"message.glyph-could-not-be-saved": "该字形无法被保存。",
Expand Down Expand Up @@ -281,6 +283,7 @@ export const strings = {
"sidebar.designspace-navigation.warning.delete-associated-layer":
"并删除关联的图层 %0",
"sidebar.designspace-navigation.warning.delete-source": "你确定要删除源 “%0” 吗?",
"sidebar.font-overview.font-source": "字体源",
"sidebar.glyph-note": "字形备忘",
"sidebar.glyph-note.glyph-note-for-glyph": "0% 的字形备忘",
"sidebar.glyph-note.no-glyph-selected": "(无选中字形)",
Expand Down
208 changes: 208 additions & 0 deletions src/fontra/client/web-components/glyph-cell-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
import * as html from "/core/html-utils.js";
import { translate } from "/core/localization.js";
import { ObservableController } from "/core/observable-object.js";
import { difference, intersection, symmetricDifference, union } from "/core/set-ops.js";
import { enumerate } from "/core/utils.js";
import { GlyphCell } from "/web-components/glyph-cell.js";
import { Accordion } from "/web-components/ui-accordion.js";

export class GlyphCellView extends HTMLElement {
constructor(fontController, locationController) {
super();

this.fontController = fontController;
this.locationController = locationController;

this.glyphSelectionController = new ObservableController({ selection: new Set() });
this.glyphSelectionController.addKeyListener("selection", (event) => {
const selection = event.newValue;
const diff = symmetricDifference(selection, event.oldValue);
this.forEachGlyphCell((glyphCell) => {
if (diff.has(glyphCell.glyphName)) {
glyphCell.selected = selection.has(glyphCell.glyphName);
}
});
});

this.fontController.addChangeListener({ glyphMap: null }, (event) => {
this.glyphSelection = intersection(
this.glyphSelection,
Object.keys(this.fontController.glyphMap)
);
});

this._intersectionObserver = new IntersectionObserver((entries, observer) => {
entries.forEach((entry) => {
if (entry.intersectionRatio > 0) {
this._intersectionObserver.unobserve(entry.target);
entry.target.onBecomeVisible?.();
} else {
}
});
});

this.appendChild(this.getContentElement());
}

getContentElement() {
this.accordion = new Accordion();

this.accordion.appendStyle(`
.placeholder-label {
font-size: 0.9em;
opacity: 40%;
}

.font-overview-accordion-item {
height: 100%;
width: 100%;
overflow-y: scroll;
white-space: normal;
}
`);

// TODO: refactor this if we implement different sections. For now only one section.
this.accordion.items = [
{
label: "Glyphs",
open: true,
content: html.div({ class: "font-overview-accordion-item" }, []),
section: "Glyphs",
},
];

return html.div({}, [this.accordion]); // wrap in div for scroll behavior
}

setGlyphItems(glyphs) {
this.glyphs = glyphs;
const results = [];
for (const item of this.accordion.items) {
this._updateAccordionItem(item).then((hasResult) => {
this.accordion.showHideAccordionItem(item, hasResult);
results.push(hasResult);
});
}
}

async _updateAccordionItem(item) {
const element = item.content;

element.innerHTML = "";
let hideAccordionItem = true;

element.appendChild(
html.span({ class: "placeholder-label" }, [
translate("sidebar.related-glyphs.loading"), // TODO: general loading key.
])
);
const glyphs = await this.getGlyphs(item.section);

item.glyphsToAdd = [...glyphs];

if (glyphs?.length) {
element.innerHTML = "";
this._addCellsIfNeeded(item);
// At least in Chrome, we need to reset the scroll position, but it doesn't
// work if we do it right away, only after the next event iteration.
setTimeout(() => {
element.scrollTop = 0;
}, 0);

hideAccordionItem = false;
} else {
element.innerHTML = "";
}

return !hideAccordionItem;
}

_addCellsIfNeeded(item) {
if (!item.glyphsToAdd.length) {
return;
}
const CHUNK_SIZE = 200;
const ADD_CELLS_TRIGGER_INDEX = 150;
const chunkOfGlyphs = item.glyphsToAdd.splice(0, CHUNK_SIZE);
const documentFragment = document.createDocumentFragment();
for (const [index, { glyphName, codePoints }] of enumerate(chunkOfGlyphs)) {
const glyphCell = new GlyphCell(
this.fontController,
glyphName,
codePoints,
this.locationController,
"fontLocationSourceMapped"
);
glyphCell.onclick = (event) => {
this.handleSingleClick(event, glyphCell);
};

glyphCell.selected = this.glyphSelection.has(glyphName);

if (index == ADD_CELLS_TRIGGER_INDEX) {
glyphCell.onBecomeVisible = () => {
this._addCellsIfNeeded(item);
};
this._intersectionObserver.observe(glyphCell);
}

documentFragment.appendChild(glyphCell);
}
item.content.appendChild(documentFragment);
}

getSelectedGlyphInfo() {
return this.glyphs.filter((glyphInfo) =>
this.glyphSelection.has(glyphInfo.glyphName)
);
}

get glyphSelection() {
return this.glyphSelectionController.model.selection;
}

set glyphSelection(selection) {
this.glyphSelectionController.model.selection = selection;
}

forEachGlyphCell(func) {
for (const glyphCell of this.iterGlyphCells()) {
func(glyphCell);
}
}

*iterGlyphCells() {
for (const glyphCell of this.accordion.shadowRoot.querySelectorAll("glyph-cell")) {
yield glyphCell;
}
}

handleSingleClick(event, glyphCell) {
if (event.detail > 1) {
// Part of a double click, we should do nothing and let handleDoubleClick
// deal with the event
return;
}

const glyphName = glyphCell.glyphName;

if (this.glyphSelection.has(glyphName)) {
if (event.shiftKey) {
this.glyphSelection = difference(this.glyphSelection, [glyphName]);
}
} else {
if (event.shiftKey) {
this.glyphSelection = union(this.glyphSelection, [glyphName]);
} else {
this.glyphSelection = new Set([glyphName]);
}
}
}

async getGlyphs(section) {
// TODO: section. For now return all glyphs
return this.glyphs;
}
}

customElements.define("glyph-cell-view", GlyphCellView);
Loading
Loading