Skip to content

Commit 5254adb

Browse files
committed
Fix to @mekkablue’s issue of STAT composed name not having enough space
1 parent 8d2c259 commit 5254adb

1 file changed

Lines changed: 55 additions & 50 deletions

File tree

src/samsa-gui.html

Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,57 @@ <h2>Glyph info</h2>
163163
import { SamsaFont, SamsaInstance, SamsaGlyph, SamsaBuffer, SAMSAGLOBAL } from "./samsa-core.js";
164164
import { CONFIG } from "./samsa-config.js";
165165

166+
// shorthands and simple functions
167+
function Q (selector, root=document) {
168+
return root.querySelector(selector);
169+
}
170+
171+
function Qall (selector, root=document) {
172+
return root.querySelectorAll(selector);
173+
}
174+
175+
Element.prototype.attr = function(attrs) {
176+
// Element.prototype.attr = function (attrs) {
177+
// set multiple element attributes using the supplied attrs object
178+
for (const key in attrs) {
179+
this.setAttribute(key, attrs[key]);
180+
}
181+
};
182+
183+
SVGElement.prototype.attr = function(attrs) {
184+
// set multiple element attributes using the supplied attrs object
185+
// - example of attrs: { d: path, stroke: "black", "stroke-width": "2px", fill: "#eee" }
186+
for (const key in attrs) {
187+
this.setAttributeNS(null, key, attrs[key]);
188+
}
189+
};
190+
191+
function EL (tag, attrs={}, props={}) {
192+
let el = document.createElement(tag);
193+
el.attr(attrs);
194+
for (const prop in props)
195+
el[prop] = props[prop];
196+
return el;
197+
}
198+
199+
function SVG (tag) {
200+
return document.createElementNS("http://www.w3.org/2000/svg", tag);
201+
}
202+
203+
function clamp (num, min, max) {
204+
if (num < min)
205+
num = min;
206+
else if (num > max)
207+
num = max;
208+
return num;
209+
}
210+
211+
function htmlEntities(str) {
212+
// https://css-tricks.com/snippets/javascript/htmlentities-for-javascript/
213+
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
214+
}
215+
216+
166217
const GLOBAL = {
167218
vf: null, // maybe allow an array of fonts... select them with a drop down in info panel
168219
currentGlyphId: null,
@@ -606,44 +657,6 @@ <h2>Glyph info</h2>
606657
});
607658

608659

609-
// shorthands
610-
function Q (selector) {
611-
return document.querySelector(selector);
612-
}
613-
614-
function Qall (selector) {
615-
return document.querySelectorAll(selector);
616-
}
617-
618-
function EL (tag) {
619-
return document.createElement(tag);
620-
}
621-
622-
function SVG (tag) {
623-
return document.createElementNS("http://www.w3.org/2000/svg", tag);
624-
}
625-
626-
function clamp (num, min, max) {
627-
if (num < min)
628-
num = min;
629-
else if (num > max)
630-
num = max;
631-
return num;
632-
}
633-
634-
SVGElement.prototype.attr = function (attrs) {
635-
// set multiple SVG attributes using the attrs array
636-
// - example of attrs: { d: path, stroke: "black", "stroke-width": "2px", fill: "#eee" }
637-
for (const prop in attrs) {
638-
this.setAttributeNS(null, prop, attrs[prop]);
639-
}
640-
};
641-
642-
function htmlEntities(str) {
643-
// https://css-tricks.com/snippets/javascript/htmlentities-for-javascript/
644-
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
645-
}
646-
647660
// TODO: specify that this gets the current fvs from sliders
648661
function getCurrentFvs() {
649662
return {...GLOBAL.fvs};
@@ -1592,7 +1605,6 @@ <h2>Glyph info</h2>
15921605
option.value = -1;
15931606
option.innerText = "[no match]";
15941607
select.append(option)
1595-
15961608
selects.push(select);
15971609
}
15981610

@@ -1672,17 +1684,10 @@ <h2>Glyph info</h2>
16721684

16731685
});
16741686

1675-
label = EL("label");
1676-
let input = EL("input");
1677-
1678-
input.id = "stat-composed-name";
1679-
input.readOnly = true;
1680-
label.innerText = "Composed name";
1681-
1682-
// add grid to the panel
1683-
grid.append(label, input);
1684-
panel.append(grid);
1685-
1687+
label = EL("label", undefined, {innerText: "Composed name"});
1688+
const input = EL("input", {style: "grid-column: 2 / 4; width: 100%;"}, {id:"stat-composed-name", readOnly: true});
1689+
grid.append(label, input); // add label and input to the grid
1690+
panel.append(grid); // add grid to the panel
16861691
}
16871692

16881693
else {

0 commit comments

Comments
 (0)