notations 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"shapes.js","sourceRoot":"","sources":["../../src/shapes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,iCAAqD;AASrD,MAAsB,KAAK;IAA3B;QAEW,YAAO,GAAW,KAAK,CAAC,SAAS,EAAE,CAAC;QASnC,OAAE,GAAkB,IAAI,CAAC;QACzB,OAAE,GAAkB,IAAI,CAAC;QACzB,WAAM,GAAkB,IAAI,CAAC;QAC7B,YAAO,GAAkB,IAAI,CAAC;QAG9B,gBAAW,GAAiB,IAAI,CAAC;QAE3C,aAAQ,GAAY,EAAE,CAAC;IAmPzB,CAAC;IA7OC,IAAI,IAAI;QACN,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAClC,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAMD,IAAI,OAAO;QACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACxC,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAmCD,gBAAgB;QACd,IAAI,CAAC,QAAQ,GAAG,IAAgC,CAAC;QACjD,IAAI,CAAC,KAAK,GAAG,IAAgC,CAAC;IAChD,CAAC;IAgBD,SAAS,CACP,CAAgB,EAChB,CAAgB,EAChB,CAAgB,EAChB,CAAgB,EAChB,WAAW,GAAG,KAAK;QAEnB,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;YACd,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;gBACb,IAAI,CAAC,EAAE,GAAG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AC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAMS,mBAAmB;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAMD,SAAS,CAAC,MAAW;QACnB,IAAI,aAAa,IAAI,MAAM;YAAE,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACnE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CACF;AAtLD,8BAsLC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { ZERO, Atom, LeafAtom, Group } from \"./core\";\n\n/**\n * Base class for all renderable objects.\n *\n * Shape caches properties like bounding boxes to improve performance,\n * since bounding box calculations can be expensive. This also allows\n * testing layouts and positioning without worrying about implementation details.\n */\nexport abstract class Shape {\n private static idCounter = 0;\n readonly shapeId: number = Shape.idCounter++;\n\n /**\n * Note that x and y coordinates are not always the x and y coordinates\n * of the bounding box.\n * E.g., a circle's x and y coordinates are its center point and not the\n * top left corner.\n * These \"main\" coordinates are referred to as control coordinates.\n */\n protected _x: number | null = null;\n protected _y: number | null = null;\n protected _width: number | null = null;\n protected _height: number | null = null;\n protected _bbox: TSU.Geom.Rect;\n protected _minSize: TSU.Geom.Size;\n protected parentShape: Shape | null = null;\n /** Child shapes contained within this shape */\n children: Shape[] = [];\n\n /**\n * Gets the bounding box of this shape.\n * Calculates it if it hasn't been calculated yet.\n */\n get bbox(): TSU.Geom.Rect {\n if (!this._bbox) {\n this._bbox = this.refreshBBox();\n }\n return this._bbox;\n }\n\n /**\n * Gets the minimum size of this shape.\n * This is usually the size of the bounding box.\n */\n get minSize(): TSU.Geom.Size {\n if (!this._minSize) {\n this._minSize = this.refreshMinSize();\n }\n return this._minSize;\n }\n\n /**\n * Refreshes the bounding box of this shape.\n * Called when the shape knows the bbox it is tracking cannot be trusted\n * and has to be refreshed by calling native methods.\n * @returns The refreshed bounding box\n */\n protected abstract refreshBBox(): TSU.Geom.Rect;\n\n /**\n * Refreshes the minimum size of this shape.\n * @returns The refreshed minimum size\n */\n protected abstract refreshMinSize(): TSU.Geom.Size;\n\n /**\n * Updates the bounds of this shape.\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @returns The updated bounds values\n */\n protected abstract updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null];\n\n /**\n * Invalidates the cached bounds of this shape.\n * Forces recalculation of bounding box and minimum size.\n */\n invalidateBounds(): void {\n this._minSize = null as unknown as TSU.Geom.Size;\n this._bbox = null as unknown as TSU.Geom.Rect;\n }\n\n /**\n * Sets the bounds of this shape.\n *\n * Note that null and NaN are valid values and mean the following:\n * - null: Don't change the value\n * - NaN: Set the value to null (use the bounding box's value)\n *\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @param applyLayout Whether to apply layout immediately\n * @returns The updated bounds values\n */\n setBounds(\n x: number | null,\n y: number | null,\n w: number | null,\n h: number | null,\n applyLayout = false,\n ): [number | null, number | null, number | null, number | null] {\n if (x != null) {\n if (isNaN(x)) {\n this._x = null;\n } else {\n this._x = x;\n }\n }\n if (y != null) {\n if (isNaN(y)) {\n this._y = null;\n } else {\n this._y = y;\n }\n }\n if (w != null) {\n if (isNaN(w)) {\n this._width = null;\n } else {\n this._width = w;\n }\n }\n if (h != null) {\n if (isNaN(h)) {\n this._height = null;\n } else {\n this._height = h;\n }\n }\n const [nx, ny, nw, nh] = this.updateBounds(x, y, w, h);\n if (nx != null) {\n if (isNaN(nx)) {\n this._x = null;\n } else {\n this._x = nx;\n }\n }\n if (ny != null) {\n if (isNaN(ny)) {\n this._y = null;\n } else {\n this._y = ny;\n }\n }\n if (nw != null) {\n if (isNaN(nw)) {\n this._width = null;\n } else {\n this._width = nw;\n }\n }\n if (nh != null) {\n if (isNaN(nh)) {\n this._height = null;\n } else {\n this._height = nh;\n }\n }\n if (applyLayout) this.refreshLayout();\n // this.resetBBox();\n return [nx, ny, nw, nh];\n }\n\n /**\n * Checks if this shape has an explicit x coordinate.\n */\n get hasX(): boolean {\n return this._x != null && !isNaN(this._x);\n }\n\n /**\n * Checks if this shape has an explicit y coordinate.\n */\n get hasY(): boolean {\n return this._y != null && !isNaN(this._y);\n }\n\n /**\n * Checks if this shape has an explicit width.\n */\n get hasWidth(): boolean {\n return this._width != null && !isNaN(this._width);\n }\n\n /**\n * Checks if this shape has an explicit height.\n */\n get hasHeight(): boolean {\n return this._height != null && !isNaN(this._height);\n }\n\n /**\n * Gets the x coordinate within the parent's coordinate system.\n */\n get x(): number {\n return this._x || 0;\n }\n\n /**\n * Sets the x coordinate within the parent's coordinate system.\n */\n set x(x: number | null) {\n // Here a manual x is being set - how does this interfere with the bounding box?\n // We should _x to the new value to indicate a manual value was set.\n // and reset bbox so that based on this x a new bbox may need to be calculated\n this.setBounds(x == null ? NaN : x, null, null, null);\n }\n\n /**\n * Gets the y coordinate within the parent's coordinate system.\n */\n get y(): number {\n if (this._y != null) return this._y;\n return 0; // this.bbox.y;\n }\n\n /**\n * Sets the y coordinate within the parent's coordinate system.\n */\n set y(y: number | null) {\n this.setBounds(null, y == null ? NaN : y, null, null);\n }\n\n /**\n * Gets the width of this shape.\n */\n get width(): number {\n if (this._width != null) return this._width;\n return 0; // this.bbox.width;\n }\n\n /**\n * Sets the width of this shape.\n */\n set width(w: number | null) {\n this.setBounds(null, null, w == null ? NaN : w, null);\n }\n\n /**\n * Gets the height of this shape.\n */\n get height(): number {\n if (this._height != null) return this._height;\n return 0; // this.bbox.height;\n }\n\n /**\n * Sets the height of this shape.\n */\n set height(h: number | null) {\n this.setBounds(null, null, null, h == null ? NaN : h);\n }\n\n /**\n * Refreshes the layout of this shape.\n * Called when bounds or other properties have changed to give the shape an\n * opportunity to layout its children. For shapes with no children this is a no-op.\n */\n refreshLayout(): void {\n // throw new Error(\"Implement this\");\n }\n}\n\n/**\n * Represents an embellishment applied to a musical element.\n */\nexport abstract class Embelishment extends Shape {}\n\n/**\n * A shape that wraps an SVG element.\n * ElementShape provides the base class for all shapes that are rendered as SVG elements.\n */\nexport class ElementShape<T extends SVGGraphicsElement = SVGGraphicsElement> extends Shape {\n /**\n * Creates a new ElementShape.\n * @param element The SVG element this shape wraps\n */\n constructor(public readonly element: T) {\n super();\n }\n\n /**\n * Refreshes the bounding box of this element.\n * @returns The refreshed bounding box\n */\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.element);\n }\n\n /**\n * Refreshes the minimum size of this element.\n * @returns The refreshed minimum size\n */\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.element);\n }\n\n /**\n * Updates the bounds of this element.\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @returns The updated bounds values\n */\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n /**\n * Refreshes the layout of this element.\n * Updates the element's attributes based on the shape's properties.\n */\n refreshLayout(): void {\n if (this.hasX) this.element.setAttribute(\"x\", \"\" + this._x);\n if (this.hasY) this.element.setAttribute(\"y\", \"\" + this._y);\n }\n}\n\n/**\n * Base class for views that represent atoms in the notation.\n * AtomView provides the visual representation of an atom.\n */\nexport abstract class AtomView extends Shape {\n /** Nesting depth of this atom in the structure */\n depth = 0;\n /** Index of the role containing this atom */\n roleIndex = 0;\n\n // LayoutMetrics for the AtomView so all atomviews laid out on the\n // same baseline will show up aligned vertically\n /** Baseline position for vertical alignment */\n baseline: number;\n /** Ascent (space above baseline) */\n ascent: number;\n /** Descent (space below baseline) */\n descent: number;\n /** Height of capital letters */\n capHeight: number;\n /** Space between lines */\n leading: number;\n\n /**\n * Checks if this atom view represents a leaf atom.\n */\n abstract isLeaf(): boolean;\n\n abstract get totalDuration(): TSU.Num.Fraction;\n\n /**\n * Creates the SVG elements needed for this atom view.\n * @param parent The parent SVG element to attach to\n */\n abstract createElements(parent: SVGGraphicsElement): void;\n}\n\n/**\n * A view for leaf atoms (those that cannot contain other atoms).\n */\nexport abstract class LeafAtomView extends AtomView {\n /**\n * Creates a new LeafAtomView.\n * @param leafAtom The leaf atom this view represents\n */\n constructor(public leafAtom: LeafAtom) {\n super();\n }\n\n /**\n * Leaf atom views always return true for isLeaf().\n */\n isLeaf(): boolean {\n return true;\n }\n\n /**\n * Gets a unique identifier for this view based on the atom's UUID.\n */\n get viewId(): number {\n return this.leafAtom.uuid;\n }\n\n /**\n * Returns the total duration of the atom rendered by this view.\n */\n get totalDuration(): TSU.Num.Fraction {\n return this.leafAtom.duration;\n }\n}\n\n/**\n * A view for group atoms that contain multiple child atoms.\n */\nexport abstract class GroupView extends AtomView {\n /** Space between atoms in this group */\n protected atomSpacing: number;\n /** The SVG group element for this view */\n protected groupElement: SVGGElement;\n /** Views for the atoms in this group */\n protected atomViews: AtomView[] = [];\n private _embelishments: Embelishment[];\n /** Whether this group represents notes by default */\n defaultToNotes = true;\n /** Whether this view needs layout */\n needsLayout = true;\n /** Scale factor for this group */\n scaleFactor = 1.0;\n\n /**\n * Creates a new GroupView.\n * @param group The group atom this view represents\n * @param config Optional configuration object\n */\n constructor(\n public group: Group,\n config?: any,\n ) {\n super();\n this.atomSpacing = 5;\n this.setStyles(config || {});\n }\n\n /**\n * Returns the total duration of the group rendered by this view.\n */\n get totalDuration(): TSU.Num.Fraction {\n return this.group.totalChildDuration;\n }\n\n /**\n * Creates the SVG elements needed for this group view.\n * @param parent The parent SVG element to attach to\n */\n createElements(parent: SVGGraphicsElement): void {\n this.groupElement = TSU.DOM.createSVGNode(\"g\", {\n parent: parent,\n attrs: {\n class: \"groupViewRoot\",\n id: \"groupViewRoot\" + this.group.uuid,\n },\n });\n\n // now create child atom views for each atom in this Group\n for (const atom of this.group.atoms.values()) {\n const atomView = this.createAtomView(atom);\n this.atomViews.push(atomView);\n }\n this.invalidateBounds();\n }\n\n /**\n * Group views always return false for isLeaf().\n */\n isLeaf(): boolean {\n return false;\n }\n\n /**\n * Refreshes the bounding box of this group.\n * @returns The refreshed bounding box\n */\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.groupElement);\n }\n\n /**\n * Refreshes the minimum size of this group.\n * @returns The refreshed minimum size\n */\n protected refreshMinSize(): TSU.Geom.Size {\n let totalWidth = 0;\n let maxHeight = 0;\n this.atomViews.forEach((av, index) => {\n const ms = av.minSize;\n totalWidth += ms.width + this.atomSpacing;\n maxHeight = Math.max(maxHeight, ms.height);\n });\n return new TSU.Geom.Size(totalWidth * this.scaleFactor, maxHeight * this.scaleFactor);\n }\n\n /**\n * Creates an atom view for a specific atom.\n * @param atom The atom to create a view for\n * @returns The created atom view\n */\n abstract createAtomView(atom: Atom): AtomView;\n\n /**\n * Updates the bounds of this group.\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @returns The updated bounds values\n */\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n /**\n * Refreshes the layout of this group.\n * Updates the position and size of the group and its child atoms.\n */\n refreshLayout(): void {\n let transform = \"translate(\" + this.x + \",\" + this.y + \")\";\n if (this.scaleFactor < 1) {\n transform += \" scale(\" + this.scaleFactor + \")\";\n }\n this.groupElement.setAttribute(\"transform\", transform);\n // if (this.widthChanged) {\n // All our atoms have to be laid out between startX and endX\n // old way of doing where we just set dx between atom views\n // this worked when atomviews were single glyphs. But\n // as atomViews can be complex (eg with accents and pre/post\n // spaces etc) explicitly setting x/y may be important\n let currX = 0;\n const currY = 0; // null; // this.y; // + 10;\n\n if (true) {\n this.atomViews.forEach((av, index) => {\n av.setBounds(currX, currY, null, null, true);\n currX += this.atomSpacing + av.minSize.width;\n });\n } else {\n // currently this is disabled because \"smaller\" beats are not EXPANDED to what they could be\n // smart alignment based layout where X = F(offset)\n // we want an atom's X offset to be something like (atom.timeOffset / group.duration) * groupWidth\n const totalDur = this.group.totalChildDuration;\n let currTime = ZERO;\n this.atomViews.forEach((av, index) => {\n const newX = currTime.timesNum(this.minSize.width).divby(this.group.duration).floor;\n if (newX >= currX) {\n currX = newX;\n }\n av.setBounds(currX, currY, null, null, true);\n currX += this.atomSpacing + av.minSize.width;\n currTime = currTime.plus(av.totalDuration);\n });\n }\n this.invalidateBounds();\n for (const e of this.embelishments) e.refreshLayout();\n this.invalidateBounds();\n }\n\n /**\n * Gets the embellishments for this group.\n */\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = this.createEmbelishments();\n }\n return this._embelishments;\n }\n\n /**\n * Creates the embellishments for this group.\n * @returns An array of embellishments\n */\n protected createEmbelishments(): Embelishment[] {\n return [];\n }\n\n /**\n * Sets the styles for this group.\n * @param config Style configuration object\n */\n setStyles(config: any): void {\n if (\"atomSpacing\" in config) this.atomSpacing = config.atomSpacing;\n this.needsLayout = true;\n }\n}\n"]}
1
+ {"version":3,"file":"shapes.js","sourceRoot":"","sources":["../../src/shapes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AACvC,iCAAqD;AASrD,MAAsB,KAAK;IAA3B;QAEW,YAAO,GAAW,KAAK,CAAC,SAAS,EAAE,CAAC;QASnC,OAAE,GAAkB,IAAI,CAAC;QACzB,OAAE,GAAkB,IAAI,CAAC;QACzB,WAAM,GAAkB,IAAI,CAAC;QAC7B,YAAO,GAAkB,IAAI,CAAC;QAG9B,gBAAW,GAAiB,IAAI,CAAC;QAE3C,aAAQ,GAAY,EAAE,CAAC;IAmPzB,CAAC;IA7OC,IAAI,IAAI;QACN,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,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IAMS,mBAAmB;QAC3B,OAAO,EAAE,CAAC;IACZ,CAAC;IAMD,SAAS,CAAC,MAAW;QACnB,IAAI,aAAa,IAAI,MAAM;YAAE,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACnE,IAAI,yBAAyB,IAAI,MAAM;YAAE,IAAI,CAAC,uBAAuB,GAAG,MAAM,CAAC,uBAAuB,CAAC;QACvG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;CACF;AAhUD,8BAgUC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { ZERO, Atom, LeafAtom, Group } from \"./core\";\n\n/**\n * Base class for all renderable objects.\n *\n * Shape caches properties like bounding boxes to improve performance,\n * since bounding box calculations can be expensive. This also allows\n * testing layouts and positioning without worrying about implementation details.\n */\nexport abstract class Shape {\n private static idCounter = 0;\n readonly shapeId: number = Shape.idCounter++;\n\n /**\n * Note that x and y coordinates are not always the x and y coordinates\n * of the bounding box.\n * E.g., a circle's x and y coordinates are its center point and not the\n * top left corner.\n * These \"main\" coordinates are referred to as control coordinates.\n */\n protected _x: number | null = null;\n protected _y: number | null = null;\n protected _width: number | null = null;\n protected _height: number | null = null;\n protected _bbox: TSU.Geom.Rect;\n protected _minSize: TSU.Geom.Size;\n protected parentShape: Shape | null = null;\n /** Child shapes contained within this shape */\n children: Shape[] = [];\n\n /**\n * Gets the bounding box of this shape.\n * Calculates it if it hasn't been calculated yet.\n */\n get bbox(): TSU.Geom.Rect {\n if (!this._bbox) {\n this._bbox = this.refreshBBox();\n }\n return this._bbox;\n }\n\n /**\n * Gets the minimum size of this shape.\n * This is usually the size of the bounding box.\n */\n get minSize(): TSU.Geom.Size {\n if (!this._minSize) {\n this._minSize = this.refreshMinSize();\n }\n return this._minSize;\n }\n\n /**\n * Refreshes the bounding box of this shape.\n * Called when the shape knows the bbox it is tracking cannot be trusted\n * and has to be refreshed by calling native methods.\n * @returns The refreshed bounding box\n */\n protected abstract refreshBBox(): TSU.Geom.Rect;\n\n /**\n * Refreshes the minimum size of this shape.\n * @returns The refreshed minimum size\n */\n protected abstract refreshMinSize(): TSU.Geom.Size;\n\n /**\n * Updates the bounds of this shape.\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @returns The updated bounds values\n */\n protected abstract updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null];\n\n /**\n * Invalidates the cached bounds of this shape.\n * Forces recalculation of bounding box and minimum size.\n */\n invalidateBounds(): void {\n this._minSize = null as unknown as TSU.Geom.Size;\n this._bbox = null as unknown as TSU.Geom.Rect;\n }\n\n /**\n * Sets the bounds of this shape.\n *\n * Note that null and NaN are valid values and mean the following:\n * - null: Don't change the value\n * - NaN: Set the value to null (use the bounding box's value)\n *\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @param applyLayout Whether to apply layout immediately\n * @returns The updated bounds values\n */\n setBounds(\n x: number | null,\n y: number | null,\n w: number | null,\n h: number | null,\n applyLayout = false,\n ): [number | null, number | null, number | null, number | null] {\n if (x != null) {\n if (isNaN(x)) {\n this._x = null;\n } else {\n this._x = x;\n }\n }\n if (y != null) {\n if (isNaN(y)) {\n this._y = null;\n } else {\n this._y = y;\n }\n }\n if (w != null) {\n if (isNaN(w)) {\n this._width = null;\n } else {\n this._width = w;\n }\n }\n if (h != null) {\n if (isNaN(h)) {\n this._height = null;\n } else {\n this._height = h;\n }\n }\n const [nx, ny, nw, nh] = this.updateBounds(x, y, w, h);\n if (nx != null) {\n if (isNaN(nx)) {\n this._x = null;\n } else {\n this._x = nx;\n }\n }\n if (ny != null) {\n if (isNaN(ny)) {\n this._y = null;\n } else {\n this._y = ny;\n }\n }\n if (nw != null) {\n if (isNaN(nw)) {\n this._width = null;\n } else {\n this._width = nw;\n }\n }\n if (nh != null) {\n if (isNaN(nh)) {\n this._height = null;\n } else {\n this._height = nh;\n }\n }\n if (applyLayout) this.refreshLayout();\n // this.resetBBox();\n return [nx, ny, nw, nh];\n }\n\n /**\n * Checks if this shape has an explicit x coordinate.\n */\n get hasX(): boolean {\n return this._x != null && !isNaN(this._x);\n }\n\n /**\n * Checks if this shape has an explicit y coordinate.\n */\n get hasY(): boolean {\n return this._y != null && !isNaN(this._y);\n }\n\n /**\n * Checks if this shape has an explicit width.\n */\n get hasWidth(): boolean {\n return this._width != null && !isNaN(this._width);\n }\n\n /**\n * Checks if this shape has an explicit height.\n */\n get hasHeight(): boolean {\n return this._height != null && !isNaN(this._height);\n }\n\n /**\n * Gets the x coordinate within the parent's coordinate system.\n */\n get x(): number {\n return this._x || 0;\n }\n\n /**\n * Sets the x coordinate within the parent's coordinate system.\n */\n set x(x: number | null) {\n // Here a manual x is being set - how does this interfere with the bounding box?\n // We should _x to the new value to indicate a manual value was set.\n // and reset bbox so that based on this x a new bbox may need to be calculated\n this.setBounds(x == null ? NaN : x, null, null, null);\n }\n\n /**\n * Gets the y coordinate within the parent's coordinate system.\n */\n get y(): number {\n if (this._y != null) return this._y;\n return 0; // this.bbox.y;\n }\n\n /**\n * Sets the y coordinate within the parent's coordinate system.\n */\n set y(y: number | null) {\n this.setBounds(null, y == null ? NaN : y, null, null);\n }\n\n /**\n * Gets the width of this shape.\n */\n get width(): number {\n if (this._width != null) return this._width;\n return 0; // this.bbox.width;\n }\n\n /**\n * Sets the width of this shape.\n */\n set width(w: number | null) {\n this.setBounds(null, null, w == null ? NaN : w, null);\n }\n\n /**\n * Gets the height of this shape.\n */\n get height(): number {\n if (this._height != null) return this._height;\n return 0; // this.bbox.height;\n }\n\n /**\n * Sets the height of this shape.\n */\n set height(h: number | null) {\n this.setBounds(null, null, null, h == null ? NaN : h);\n }\n\n /**\n * Refreshes the layout of this shape.\n * Called when bounds or other properties have changed to give the shape an\n * opportunity to layout its children. For shapes with no children this is a no-op.\n */\n refreshLayout(): void {\n // throw new Error(\"Implement this\");\n }\n}\n\n/**\n * Represents an embellishment applied to a musical element.\n */\nexport abstract class Embelishment extends Shape {}\n\n/**\n * A shape that wraps an SVG element.\n * ElementShape provides the base class for all shapes that are rendered as SVG elements.\n */\nexport class ElementShape<T extends SVGGraphicsElement = SVGGraphicsElement> extends Shape {\n /**\n * Creates a new ElementShape.\n * @param element The SVG element this shape wraps\n */\n constructor(public readonly element: T) {\n super();\n }\n\n /**\n * Refreshes the bounding box of this element.\n * @returns The refreshed bounding box\n */\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.element);\n }\n\n /**\n * Refreshes the minimum size of this element.\n * @returns The refreshed minimum size\n */\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.element);\n }\n\n /**\n * Updates the bounds of this element.\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @returns The updated bounds values\n */\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n /**\n * Refreshes the layout of this element.\n * Updates the element's attributes based on the shape's properties.\n */\n refreshLayout(): void {\n if (this.hasX) this.element.setAttribute(\"x\", \"\" + this._x);\n if (this.hasY) this.element.setAttribute(\"y\", \"\" + this._y);\n }\n}\n\n/**\n * Base class for views that represent atoms in the notation.\n * AtomView provides the visual representation of an atom.\n */\nexport abstract class AtomView extends Shape {\n /** Nesting depth of this atom in the structure */\n depth = 0;\n /** Index of the role containing this atom */\n roleIndex = 0;\n\n // LayoutMetrics for the AtomView so all atomviews laid out on the\n // same baseline will show up aligned vertically\n /** Baseline position for vertical alignment */\n baseline: number;\n /** Ascent (space above baseline) */\n ascent: number;\n /** Descent (space below baseline) */\n descent: number;\n /** Height of capital letters */\n capHeight: number;\n /** Space between lines */\n leading: number;\n\n /**\n * Checks if this atom view represents a leaf atom.\n */\n abstract isLeaf(): boolean;\n\n abstract get totalDuration(): TSU.Num.Fraction;\n\n /**\n * Returns the horizontal offset from the atom's origin to where the note glyph starts.\n * This accounts for left embellishments that appear before the note.\n * Used by GroupView to align note glyphs at their correct time positions.\n *\n * Default is 0 (glyph starts at origin). Subclasses with left embellishments\n * should override to return the width of left-side decorations.\n */\n get glyphOffset(): number {\n return 0;\n }\n\n /**\n * Creates the SVG elements needed for this atom view.\n * @param parent The parent SVG element to attach to\n */\n abstract createElements(parent: SVGGraphicsElement): void;\n}\n\n/**\n * A view for leaf atoms (those that cannot contain other atoms).\n */\nexport abstract class LeafAtomView extends AtomView {\n /**\n * Creates a new LeafAtomView.\n * @param leafAtom The leaf atom this view represents\n */\n constructor(public leafAtom: LeafAtom) {\n super();\n }\n\n /**\n * Leaf atom views always return true for isLeaf().\n */\n isLeaf(): boolean {\n return true;\n }\n\n /**\n * Gets a unique identifier for this view based on the atom's UUID.\n */\n get viewId(): number {\n return this.leafAtom.uuid;\n }\n\n /**\n * Returns the total duration of the atom rendered by this view.\n */\n get totalDuration(): TSU.Num.Fraction {\n return this.leafAtom.duration;\n }\n}\n\n/**\n * A view for group atoms that contain multiple child atoms.\n */\nexport abstract class GroupView extends AtomView {\n /** Space between atoms in this group */\n protected atomSpacing: number;\n /** The SVG group element for this view */\n protected groupElement: SVGGElement;\n /** Views for the atoms in this group */\n protected atomViews: AtomView[] = [];\n private _embelishments: Embelishment[];\n /** Whether this group represents notes by default */\n defaultToNotes = true;\n /** Whether this view needs layout */\n needsLayout = true;\n /** Scale factor for this group */\n scaleFactor = 1.0;\n /**\n * When true, shows continuation markers (\",\") for atoms with duration > 1\n * instead of just leaving empty space.\n */\n showContinuationMarkers = true;\n /** SVG elements for continuation markers */\n protected continuationMarkerElements: SVGTextElement[] = [];\n\n /**\n * Creates a new GroupView.\n * @param group The group atom this view represents\n * @param config Optional configuration object\n */\n constructor(\n public group: Group,\n config?: any,\n ) {\n super();\n this.atomSpacing = 5;\n this.setStyles(config || {});\n }\n\n /**\n * Returns the total duration of the group rendered by this view.\n */\n get totalDuration(): TSU.Num.Fraction {\n return this.group.totalChildDuration;\n }\n\n /**\n * Creates the SVG elements needed for this group view.\n * @param parent The parent SVG element to attach to\n */\n createElements(parent: SVGGraphicsElement): void {\n this.groupElement = TSU.DOM.createSVGNode(\"g\", {\n parent: parent,\n attrs: {\n class: \"groupViewRoot\",\n id: \"groupViewRoot\" + this.group.uuid,\n },\n });\n\n // now create child atom views for each atom in this Group\n for (const atom of this.group.atoms.values()) {\n const atomView = this.createAtomView(atom);\n this.atomViews.push(atomView);\n }\n this.invalidateBounds();\n }\n\n /**\n * Group views always return false for isLeaf().\n */\n isLeaf(): boolean {\n return false;\n }\n\n /**\n * Refreshes the bounding box of this group.\n * @returns The refreshed bounding box\n */\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.groupElement);\n }\n\n /**\n * Refreshes the minimum size of this group using duration-based width calculation.\n *\n * ## Duration-Based Width Algorithm\n *\n * This algorithm ensures atoms with extended durations receive proportionally\n * more horizontal space. For example, with `\\beatDuration(4)` and input `S 2 R G M`:\n * - S has duration 1, R has duration 2, G has duration 1\n * - R should visually occupy twice the horizontal space of S or G\n *\n * ### Algorithm Steps:\n *\n * 1. **Calculate width per duration unit**: For each atom, compute the visual width\n * needed per unit of duration: `(visualWidth + spacing) / duration`\n *\n * 2. **Find maximum**: Take the maximum width-per-duration across all atoms.\n * This ensures every atom has enough space for its visual content.\n *\n * 3. **Scale by total duration**: Multiply the max width-per-duration by the\n * group's total duration to get the final group width.\n *\n * ### Example:\n * ```\n * Atoms: S(dur=1, width=10px), R(dur=2, width=10px), G(dur=1, width=10px)\n * Spacing: 5px\n *\n * Width per duration:\n * S: (10 + 5) / 1 = 15 px/unit\n * R: (10 + 5) / 2 = 7.5 px/unit\n * G: (10 + 5) / 1 = 15 px/unit\n *\n * Max width per duration: 15 px/unit\n * Total duration: 1 + 2 + 1 = 4 units\n * Group width: 15 * 4 = 60px\n *\n * Positioning:\n * S at x=0 (time 0/4 * 60 = 0)\n * R at x=15 (time 1/4 * 60 = 15)\n * G at x=45 (time 3/4 * 60 = 45)\n * ```\n *\n * @returns The refreshed minimum size\n */\n protected refreshMinSize(): TSU.Geom.Size {\n let maxHeight = 0;\n\n // Step 1: Calculate width per duration unit for each atom\n let minWidthPerDuration = 0;\n this.atomViews.forEach((av) => {\n const ms = av.minSize;\n const dur = av.totalDuration;\n if (!dur.isZero) {\n const durValue = dur.num / dur.den;\n const widthPerDur = (ms.width + this.atomSpacing) / durValue;\n // Step 2: Track maximum width per duration\n minWidthPerDuration = Math.max(minWidthPerDuration, widthPerDur);\n }\n maxHeight = Math.max(maxHeight, ms.height);\n });\n\n // Step 3: Scale by total duration\n const totalDuration = this.group.totalChildDuration;\n const totalDurValue = totalDuration.num / totalDuration.den;\n const totalWidth = minWidthPerDuration * totalDurValue;\n\n return new TSU.Geom.Size(totalWidth * this.scaleFactor, maxHeight * this.scaleFactor);\n }\n\n /**\n * Creates an atom view for a specific atom.\n * @param atom The atom to create a view for\n * @returns The created atom view\n */\n abstract createAtomView(atom: Atom): AtomView;\n\n /**\n * Updates the bounds of this group.\n * @param x New x coordinate, or null to keep current value\n * @param y New y coordinate, or null to keep current value\n * @param w New width, or null to keep current value\n * @param h New height, or null to keep current value\n * @returns The updated bounds values\n */\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n /**\n * Refreshes the layout of this group using duration-based positioning.\n *\n * ## Duration-Based Positioning Algorithm\n *\n * Atoms are positioned at x-coordinates proportional to their time offset\n * within the group's total duration. This ensures that atoms with extended\n * durations visually occupy the correct amount of horizontal space.\n *\n * ### Width Source Priority:\n *\n * 1. **Column width** (preferred): If width was set via `setBounds()` from the\n * grid layout system (ColAlign), use that width. This enables global alignment\n * across all beats in the same column.\n *\n * 2. **Minimum size**: Fall back to `minSize.width` calculated by `refreshMinSize()`.\n *\n * ### Positioning Formula:\n * ```\n * xPosition = (timeOffset / totalDuration) * groupWidth\n * ```\n *\n * ### Continuation Markers:\n *\n * When `showContinuationMarkers` is true (default), atoms with duration > 1\n * will have \",\" markers rendered at each additional time slot. For example,\n * an atom with duration 2 will show \"R ,\" instead of \"R \".\n *\n * This helps users visually understand that the note continues through\n * multiple time slots without relying on empty space alone.\n *\n * ### Example:\n * ```\n * Input: S 2 R G (with beatDuration=4)\n * Group width: 60px, Total duration: 4 units\n *\n * Positioning:\n * S at x=0 (time 0, offset 0/4 * 60 = 0)\n * R at x=15 (time 1, offset 1/4 * 60 = 15)\n * \",\" at x=30 (continuation marker for R at time 2)\n * G at x=45 (time 3, offset 3/4 * 60 = 45)\n * ```\n */\n refreshLayout(): void {\n let transform = \"translate(\" + this.x + \",\" + this.y + \")\";\n if (this.scaleFactor < 1) {\n transform += \" scale(\" + this.scaleFactor + \")\";\n }\n this.groupElement.setAttribute(\"transform\", transform);\n\n const currY = 0;\n const totalDur = this.group.totalChildDuration;\n\n // Width source priority: column width (for global alignment) > minSize\n const unscaledMinWidth = this.minSize.width / this.scaleFactor;\n const groupWidth = this.hasWidth ? this.width / this.scaleFactor : unscaledMinWidth;\n\n // Clear existing continuation markers before re-rendering\n this.clearContinuationMarkers();\n\n // Position each atom based on its time offset\n let currTime = ZERO;\n this.atomViews.forEach((av, index) => {\n // Calculate where the NOTE GLYPH should appear based on time offset\n const glyphX = totalDur.isZero ? 0 : currTime.timesNum(groupWidth).divby(totalDur).floor;\n // Subtract glyphOffset so left embellishments don't push the glyph past its time position\n // The atom origin is placed earlier, so the glyph ends up at the correct time position\n const xPos = Math.max(0, glyphX - av.glyphOffset);\n av.setBounds(xPos, currY, null, null, true);\n\n // Render continuation markers for atoms with duration > 1\n if (this.showContinuationMarkers && !totalDur.isZero) {\n const atomDur = av.totalDuration;\n const durValue = atomDur.num / atomDur.den;\n if (durValue > 1) {\n // Render one marker at each additional time slot within the atom's duration\n const numMarkers = Math.floor(durValue) - 1;\n for (let i = 1; i <= numMarkers; i++) {\n // Marker time = currTime + (atomDuration * i / floor(duration))\n const markerTime = currTime.plus(atomDur.timesNum(i).divbyNum(Math.floor(durValue)));\n const markerX = markerTime.timesNum(groupWidth).divby(totalDur).floor;\n this.renderContinuationMarker(markerX, currY);\n }\n }\n }\n\n currTime = currTime.plus(av.totalDuration);\n });\n\n this.invalidateBounds();\n for (const e of this.embelishments) e.refreshLayout();\n this.invalidateBounds();\n }\n\n /**\n * Clears all continuation marker elements.\n */\n protected clearContinuationMarkers(): void {\n for (const el of this.continuationMarkerElements) {\n el.remove();\n }\n this.continuationMarkerElements = [];\n }\n\n /**\n * Renders a continuation marker (\",\") at the specified position.\n * @param x X position for the marker\n * @param y Y position for the marker\n */\n protected renderContinuationMarker(x: number, y: number): void {\n const marker = TSU.DOM.createSVGNode(\"text\", {\n parent: this.groupElement,\n attrs: {\n class: \"continuationMarker\",\n x: x.toString(),\n y: y.toString(),\n },\n text: \",\",\n }) as SVGTextElement;\n this.continuationMarkerElements.push(marker);\n }\n\n /**\n * Gets the embellishments for this group.\n */\n get embelishments(): Embelishment[] {\n if (!this._embelishments) {\n this._embelishments = this.createEmbelishments();\n }\n return this._embelishments;\n }\n\n /**\n * Creates the embellishments for this group.\n * @returns An array of embellishments\n */\n protected createEmbelishments(): Embelishment[] {\n return [];\n }\n\n /**\n * Sets the styles for this group.\n * @param config Style configuration object\n */\n setStyles(config: any): void {\n if (\"atomSpacing\" in config) this.atomSpacing = config.atomSpacing;\n if (\"showContinuationMarkers\" in config) this.showContinuationMarkers = config.showContinuationMarkers;\n this.needsLayout = true;\n }\n}\n"]}
@@ -16,6 +16,7 @@ export declare abstract class LeafAtomView extends LeafAtomViewBase {
16
16
  abstract get glyphLabel(): string;
17
17
  protected refreshBBox(): TSU.Geom.Rect;
18
18
  protected refreshMinSize(): TSU.Geom.Size;
19
+ get glyphOffset(): number;
19
20
  protected updateBounds(x: null | number, y: null | number, w: null | number, h: null | number): [number | null, number | null, number | null, number | null];
20
21
  protected layoutElements(): void;
21
22
  refreshLayout(): void;
@@ -31,6 +31,9 @@ export class LeafAtomView extends LeafAtomViewBase {
31
31
  out.height += totalHeight;
32
32
  return out;
33
33
  }
34
+ get glyphOffset() {
35
+ return (this.leftSlot.reduce((a, b) => a + b.minSize.width, 0) + this.leftSlot.length);
36
+ }
34
37
  updateBounds(x, y, w, h) {
35
38
  return [x, y, NaN, NaN];
36
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"atomviews.js","sourceRoot":"","sources":["../../../src/carnatic/atomviews.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAwB,QAAQ,EAAE,IAAI,EAAS,QAAQ,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EACL,YAAY,IAAI,gBAAgB,EAChC,SAAS,IAAI,aAAa,EAG1B,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,eAAe,EACf,SAAS,EACT,KAAK,EACL,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAK,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,OAAO,SAAU,SAAQ,aAAa;IAC1C,cAAc,CAAC,IAAU;QACvB,OAAO,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IAC3E,CAAC;CACF;AAED,MAAM,OAAgB,YAAa,SAAQ,gBAAgB;IAA3D;;QACE,aAAQ,GAAmB,EAAE,CAAC;QAC9B,YAAO,GAAmB,EAAE,CAAC;QAC7B,cAAS,GAAmB,EAAE,CAAC;QAC/B,eAAU,GAAmB,EAAE,CAAC;IA+NlC,CAAC;IAnNW,WAAW;QACnB,OAAO,GAAG,CAAC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AK,QAAQ,CAAC,IAAI;YAChB,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAY,CAAC,CAAC;YACjC,MAAM;QACR,KAAK,QAAQ,CAAC,OAAO;YACnB,IAAI,iBAAiB,EAAE,CAAC;gBACtB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAY,CAAC,CAAC;gBACvC,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAgB,CAAC,CAAC;gBAC/C,GAAG,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;YAC9B,CAAC;YACD,MAAM;QACR,KAAK,QAAQ,CAAC,KAAK;YACjB,GAAG,GAAG,IAAI,SAAS,CAAC,IAAa,CAAC,CAAC;YAClC,GAAiB,CAAC,cAAc,GAAG,iBAAiB,CAAC;YACrD,GAAiB,CAAC,WAAW,GAAG,cAAc,CAAC;YAChD,MAAM;QACR;YAGE,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IACD,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom, Group, Literal, AtomType, Note, Space, Syllable } from \"../core\";\nimport {\n LeafAtomView as LeafAtomViewBase,\n GroupView as GroupViewBase,\n AtomView,\n Embelishment,\n ElementShape,\n} from \"../shapes\";\nimport {\n OctaveIndicator,\n Kampitham,\n Nokku,\n Spuritham,\n Prathyagatham,\n Orikkai,\n Odukkal,\n Raavi,\n Kandippu,\n Vaali,\n Jaaru,\n} from \"./embelishments\";\nimport { GamakaType } from \"./gamakas\";\n\nexport class GroupView extends GroupViewBase {\n createAtomView(atom: Atom): AtomView {\n return createAtomView(this.groupElement, atom, this.defaultToNotes, 0.7);\n }\n}\n\nexport abstract class LeafAtomView extends LeafAtomViewBase {\n leftSlot: Embelishment[] = [];\n topSlot: Embelishment[] = [];\n rightSlot: Embelishment[] = [];\n bottomSlot: Embelishment[] = [];\n glyph: ElementShape;\n\n // Spaces required before and after to accomodate for left and right slots\n protected postSpacingSpan: SVGTSpanElement;\n // Sometimes this.element may not be the root element if we need spacings\n // the rootElement is the top of the chain\n protected rootGroup: ElementShape;\n protected rootText: ElementShape;\n\n abstract get glyphLabel(): string;\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.rootGroup.element);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const out = { ...this.rootText.minSize };\n const totalWidth =\n this.leftSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.rightSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.leftSlot.length + // Padding of 1\n this.rightSlot.length; // Padding of 1\n const totalHeight =\n this.topSlot.reduce((a, b) => a + b.minSize.height, 0) +\n this.bottomSlot.reduce((a, b) => a + b.minSize.height, 0);\n out.width += totalWidth;\n out.height += totalHeight;\n // if (this.postSpacingSpan) out.width += this.postSpacingSpan.getBBox().width;\n return out;\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, NaN, NaN];\n }\n\n protected layoutElements(): void {\n // Lays out all the child elements locally\n const textSize = this.rootText.minSize;\n // assume text is at 0,0 and lay things around it\n\n // now layout leftSlots\n let currX = 0;\n let currY = this.hasY ? this.y : 0;\n // place left embelishments\n for (const emb of this.leftSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // now place the text\n const textX = currX;\n this.rootText.x = currX;\n this.rootText.refreshLayout();\n\n // And right embelishments\n currX += this.rootText.minSize.width;\n for (const emb of this.rightSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // layout top and bottom if x or y has changed\n const gminSize = this.glyph.minSize;\n\n // top embelishments\n const glyphX = textX + this.glyph.x;\n const glyphY = this.glyph.y;\n currY = glyphY - this.glyph.minSize.height + 5;\n for (const emb of this.topSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);\n currY = emb.y;\n }\n\n // bottom embelishments\n currY = glyphY + 7;\n for (const emb of this.bottomSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);\n currY = emb.y + bb.height;\n }\n this.invalidateBounds();\n }\n\n refreshLayout(): void {\n // TODO - move this code out to refreshLayout?\n // set the glyphs Y first so we can layout others\n this.layoutElements();\n this.rootGroup.element.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n\n protected addEmbelishment(slot: Embelishment[], emb: Embelishment): void {\n slot.push(emb);\n // this.addShape(emb);\n }\n\n /**\n * Orders embelishments and creates their views.\n */\n orderEmbelishments(): void {\n const atom = this.leafAtom;\n if (atom.TYPE != AtomType.SYLLABLE && atom.TYPE != AtomType.NOTE) {\n return;\n }\n const lit = atom as Literal;\n if (lit.embelishments.length == 0) return;\n for (const emb of lit.embelishments) {\n switch (emb.type) {\n case GamakaType.Kampitham:\n this.addEmbelishment(this.topSlot, new Kampitham(this));\n break;\n case GamakaType.Nokku:\n this.addEmbelishment(this.topSlot, new Nokku(this));\n break;\n case GamakaType.Spuritham:\n this.addEmbelishment(this.topSlot, new Spuritham(this));\n break;\n case GamakaType.Prathyagatham:\n this.addEmbelishment(this.topSlot, new Prathyagatham(this));\n break;\n case GamakaType.Orikkai:\n this.addEmbelishment(this.topSlot, new Orikkai(this));\n break;\n case GamakaType.Odukkal:\n this.addEmbelishment(this.topSlot, new Odukkal(this));\n break;\n case GamakaType.Aahaatam_Raavi:\n this.addEmbelishment(this.topSlot, new Raavi(this));\n break;\n case GamakaType.Aahaatam_Kandippu:\n this.addEmbelishment(this.topSlot, new Kandippu(this));\n break;\n case GamakaType.Vaali:\n this.addEmbelishment(this.topSlot, new Vaali(this));\n break;\n case GamakaType.Jaaru_Eetra:\n case GamakaType.Jaaru_Irakka:\n this.addEmbelishment(this.leftSlot, new Jaaru(emb, this));\n break;\n }\n }\n }\n\n embRoot(): SVGGraphicsElement {\n return this.rootGroup.element;\n }\n\n needsRootElement(): boolean {\n return true; // this.rightSlot.length > 0 || this.leafAtom.beforeRest;\n }\n\n createElements(parent: SVGGraphicsElement): void {\n // Create the glyph element first before anything\n // this allows embelishments to get early access to this element\n this.createGlyphRoot(parent);\n this.createGlyphElement();\n // Order embelishments (without creating any views)\n this.orderEmbelishments();\n this.createPostSpacingElement();\n this.invalidateBounds();\n }\n\n protected createGlyphRoot(parent: SVGGraphicsElement): void {\n this.rootGroup = new ElementShape(\n TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: parent,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewRootGroup\",\n id: \"atomViewRootGroup\" + this.leafAtom.uuid,\n },\n }),\n );\n this.rootText = new ElementShape(\n TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: this.rootGroup.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewTextRoot\",\n id: \"atomViewTextRoot\" + this.leafAtom.uuid,\n },\n }),\n );\n }\n\n protected createGlyphElement(): void {\n const atom = this.leafAtom;\n this.glyph = new ElementShape(\n TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: atom.uuid,\n id: \"atomGlyph\" + atom.uuid,\n },\n text: this.glyphLabel, // + (note.beforeRest ? \" - \" : \" \"),\n }),\n );\n }\n\n protected createPostSpacingElement(): void {\n if (this.leafAtom.beforeRest) {\n this.postSpacingSpan = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n id: \"postSpacing\" + this.leafAtom.uuid,\n },\n text: this.leafAtom.beforeRest ? \" - \" : \" \",\n });\n }\n }\n}\n\nclass SpaceView extends LeafAtomView {\n get glyphLabel(): string {\n if (this.space.isSilent) return \" \";\n if (this.space.duration.isOne) return \",\";\n if (this.space.duration.cmpNum(2) == 0) return \";\";\n return \"_\";\n }\n\n get space(): Space {\n return this.leafAtom as Space;\n }\n}\n\nclass NoteView extends LeafAtomView {\n protected shiftElement: SVGTSpanElement;\n get glyphLabel(): string {\n return this.note.value;\n }\n\n needsRootElement(): boolean {\n return true; // this.note.shift == true || this.note.shift != 0 || super.needsRootElement();\n }\n\n protected createGlyphElement(): void {\n super.createGlyphElement();\n if (this.note.shift == true || this.note.shift != 0) {\n this.shiftElement = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.note.uuid,\n class: \"noteShiftTSpan\",\n id: \"noteShift\" + this.note.uuid,\n \"baseline-shift\": \"sub\",\n },\n text: (this.note.shift == true ? \"*\" : this.note.shift) + \" \",\n });\n }\n }\n\n protected moveGlyphToRoot(): void {\n // super.moveGlyphToRoot();\n if (this.shiftElement) {\n this.rootGroup.element.appendChild(this.shiftElement);\n }\n }\n\n orderEmbelishments(): void {\n const note = this.note;\n // create the embelishments if needed\n if (note.octave > 0) {\n this.topSlot.push(new OctaveIndicator(this, note));\n } else if (this.note.octave < 0) {\n this.bottomSlot.push(new OctaveIndicator(this, note));\n }\n super.orderEmbelishments();\n }\n\n get note(): Note {\n return this.leafAtom as Note;\n }\n}\n\nclass SyllableView extends LeafAtomView {\n get glyphLabel(): string {\n return this.syllable.value;\n }\n\n get syllable(): Syllable {\n return this.leafAtom as Syllable;\n }\n}\n\nexport function createAtomView(\n parent: SVGGraphicsElement,\n atom: Atom,\n litDefaultsToNote = false,\n groupViewScale = 1.0,\n): AtomView {\n let out: AtomView;\n switch (atom.TYPE) {\n // Dealing with leaf atoms\n case AtomType.SPACE:\n out = new SpaceView(atom as Space);\n break;\n case AtomType.SYLLABLE:\n out = new SyllableView(atom as Syllable);\n break;\n case AtomType.NOTE:\n out = new NoteView(atom as Note);\n break;\n case AtomType.LITERAL:\n if (litDefaultsToNote) {\n const lit = Note.fromLit(atom as Note);\n out = new NoteView(lit);\n } else {\n const lit = Syllable.fromLit(atom as Syllable);\n out = new SyllableView(lit);\n }\n break;\n case AtomType.GROUP:\n out = new GroupView(atom as Group);\n (out as GroupView).defaultToNotes = litDefaultsToNote;\n (out as GroupView).scaleFactor = groupViewScale;\n break;\n default:\n // We should never get a group as we are iterating\n // at leaf atom levels\n throw new Error(\"Invalid atom type: \" + atom.TYPE);\n }\n out.createElements(parent);\n return out;\n}\n"]}
1
+ {"version":3,"file":"atomviews.js","sourceRoot":"","sources":["../../../src/carnatic/atomviews.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAwB,QAAQ,EAAE,IAAI,EAAS,QAAQ,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EACL,YAAY,IAAI,gBAAgB,EAChC,SAAS,IAAI,aAAa,EAG1B,YAAY,GACb,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,eAAe,EACf,SAAS,EACT,KAAK,EACL,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAK,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,OAAO,SAAU,SAAQ,aAAa;IAC1C,cAAc,CAAC,IAAU;QACvB,OAAO,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IAC3E,CAAC;CACF;AAED,MAAM,OAAgB,YAAa,SAAQ,gBAAgB;IAA3D;;QACE,aAAQ,GAAmB,EAAE,CAAC;QAC9B,YAAO,GAAmB,EAAE,CAAC;QAC7B,cAAS,GAAmB,EAAE,CAAC;QAC/B,eA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,GAAG,KAAK,EACzB,cAAc,GAAG,GAAG;IAEpB,IAAI,GAAa,CAAC;IAClB,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAElB,KAAK,QAAQ,CAAC,KAAK;YACjB,GAAG,GAAG,IAAI,SAAS,CAAC,IAAa,CAAC,CAAC;YACnC,MAAM;QACR,KAAK,QAAQ,CAAC,QAAQ;YACpB,GAAG,GAAG,IAAI,YAAY,CAAC,IAAgB,CAAC,CAAC;YACzC,MAAM;QACR,KAAK,QAAQ,CAAC,IAAI;YAChB,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAY,CAAC,CAAC;YACjC,MAAM;QACR,KAAK,QAAQ,CAAC,OAAO;YACnB,IAAI,iBAAiB,EAAE,CAAC;gBACtB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAY,CAAC,CAAC;gBACvC,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAgB,CAAC,CAAC;gBAC/C,GAAG,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;YAC9B,CAAC;YACD,MAAM;QACR,KAAK,QAAQ,CAAC,KAAK;YACjB,GAAG,GAAG,IAAI,SAAS,CAAC,IAAa,CAAC,CAAC;YAClC,GAAiB,CAAC,cAAc,GAAG,iBAAiB,CAAC;YACrD,GAAiB,CAAC,WAAW,GAAG,cAAc,CAAC;YAChD,MAAM;QACR;YAGE,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;IACD,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Atom, Group, Literal, AtomType, Note, Space, Syllable } from \"../core\";\nimport {\n LeafAtomView as LeafAtomViewBase,\n GroupView as GroupViewBase,\n AtomView,\n Embelishment,\n ElementShape,\n} from \"../shapes\";\nimport {\n OctaveIndicator,\n Kampitham,\n Nokku,\n Spuritham,\n Prathyagatham,\n Orikkai,\n Odukkal,\n Raavi,\n Kandippu,\n Vaali,\n Jaaru,\n} from \"./embelishments\";\nimport { GamakaType } from \"./gamakas\";\n\nexport class GroupView extends GroupViewBase {\n createAtomView(atom: Atom): AtomView {\n return createAtomView(this.groupElement, atom, this.defaultToNotes, 0.7);\n }\n}\n\nexport abstract class LeafAtomView extends LeafAtomViewBase {\n leftSlot: Embelishment[] = [];\n topSlot: Embelishment[] = [];\n rightSlot: Embelishment[] = [];\n bottomSlot: Embelishment[] = [];\n glyph: ElementShape;\n\n // Spaces required before and after to accomodate for left and right slots\n protected postSpacingSpan: SVGTSpanElement;\n // Sometimes this.element may not be the root element if we need spacings\n // the rootElement is the top of the chain\n protected rootGroup: ElementShape;\n protected rootText: ElementShape;\n\n abstract get glyphLabel(): string;\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.rootGroup.element);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const out = { ...this.rootText.minSize };\n const totalWidth =\n this.leftSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.rightSlot.reduce((a, b) => a + b.minSize.width, 0) +\n this.leftSlot.length + // Padding of 1\n this.rightSlot.length; // Padding of 1\n const totalHeight =\n this.topSlot.reduce((a, b) => a + b.minSize.height, 0) +\n this.bottomSlot.reduce((a, b) => a + b.minSize.height, 0);\n out.width += totalWidth;\n out.height += totalHeight;\n // if (this.postSpacingSpan) out.width += this.postSpacingSpan.getBBox().width;\n return out;\n }\n\n /**\n * Returns the horizontal offset from the atom's origin to where the note glyph starts.\n * This is the total width of left embellishments (e.g., Jaaru symbols).\n */\n get glyphOffset(): number {\n return (\n this.leftSlot.reduce((a, b) => a + b.minSize.width, 0) + this.leftSlot.length // Padding of 1 per embellishment\n );\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, NaN, NaN];\n }\n\n protected layoutElements(): void {\n // Lays out all the child elements locally\n const textSize = this.rootText.minSize;\n // assume text is at 0,0 and lay things around it\n\n // now layout leftSlots\n let currX = 0;\n let currY = this.hasY ? this.y : 0;\n // place left embelishments\n for (const emb of this.leftSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // now place the text\n const textX = currX;\n this.rootText.x = currX;\n this.rootText.refreshLayout();\n\n // And right embelishments\n currX += this.rootText.minSize.width;\n for (const emb of this.rightSlot) {\n emb.x = currX;\n emb.refreshLayout();\n currX += emb.minSize.width + 1;\n }\n\n // layout top and bottom if x or y has changed\n const gminSize = this.glyph.minSize;\n\n // top embelishments\n const glyphX = textX + this.glyph.x;\n const glyphY = this.glyph.y;\n currY = glyphY - this.glyph.minSize.height + 5;\n for (const emb of this.topSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY - bb.height, null, null, true);\n currY = emb.y;\n }\n\n // bottom embelishments\n currY = glyphY + 7;\n for (const emb of this.bottomSlot) {\n const bb = emb.minSize;\n emb.setBounds(glyphX + (gminSize.width - bb.width) / 2, currY, null, null, true);\n currY = emb.y + bb.height;\n }\n this.invalidateBounds();\n }\n\n refreshLayout(): void {\n // TODO - move this code out to refreshLayout?\n // set the glyphs Y first so we can layout others\n this.layoutElements();\n this.rootGroup.element.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n\n protected addEmbelishment(slot: Embelishment[], emb: Embelishment): void {\n slot.push(emb);\n // this.addShape(emb);\n }\n\n /**\n * Orders embelishments and creates their views.\n */\n orderEmbelishments(): void {\n const atom = this.leafAtom;\n if (atom.TYPE != AtomType.SYLLABLE && atom.TYPE != AtomType.NOTE) {\n return;\n }\n const lit = atom as Literal;\n if (lit.embelishments.length == 0) return;\n for (const emb of lit.embelishments) {\n switch (emb.type) {\n case GamakaType.Kampitham:\n this.addEmbelishment(this.topSlot, new Kampitham(this));\n break;\n case GamakaType.Nokku:\n this.addEmbelishment(this.topSlot, new Nokku(this));\n break;\n case GamakaType.Spuritham:\n this.addEmbelishment(this.topSlot, new Spuritham(this));\n break;\n case GamakaType.Prathyagatham:\n this.addEmbelishment(this.topSlot, new Prathyagatham(this));\n break;\n case GamakaType.Orikkai:\n this.addEmbelishment(this.topSlot, new Orikkai(this));\n break;\n case GamakaType.Odukkal:\n this.addEmbelishment(this.topSlot, new Odukkal(this));\n break;\n case GamakaType.Aahaatam_Raavi:\n this.addEmbelishment(this.topSlot, new Raavi(this));\n break;\n case GamakaType.Aahaatam_Kandippu:\n this.addEmbelishment(this.topSlot, new Kandippu(this));\n break;\n case GamakaType.Vaali:\n this.addEmbelishment(this.topSlot, new Vaali(this));\n break;\n case GamakaType.Jaaru_Eetra:\n case GamakaType.Jaaru_Irakka:\n this.addEmbelishment(this.leftSlot, new Jaaru(emb, this));\n break;\n }\n }\n }\n\n embRoot(): SVGGraphicsElement {\n return this.rootGroup.element;\n }\n\n needsRootElement(): boolean {\n return true; // this.rightSlot.length > 0 || this.leafAtom.beforeRest;\n }\n\n createElements(parent: SVGGraphicsElement): void {\n // Create the glyph element first before anything\n // this allows embelishments to get early access to this element\n this.createGlyphRoot(parent);\n this.createGlyphElement();\n // Order embelishments (without creating any views)\n this.orderEmbelishments();\n this.createPostSpacingElement();\n this.invalidateBounds();\n }\n\n protected createGlyphRoot(parent: SVGGraphicsElement): void {\n this.rootGroup = new ElementShape(\n TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: parent,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewRootGroup\",\n id: \"atomViewRootGroup\" + this.leafAtom.uuid,\n },\n }),\n );\n this.rootText = new ElementShape(\n TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: this.rootGroup.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n class: \"atomViewTextRoot\",\n id: \"atomViewTextRoot\" + this.leafAtom.uuid,\n },\n }),\n );\n }\n\n protected createGlyphElement(): void {\n const atom = this.leafAtom;\n this.glyph = new ElementShape(\n TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: atom.uuid,\n id: \"atomGlyph\" + atom.uuid,\n },\n text: this.glyphLabel, // + (note.beforeRest ? \" - \" : \" \"),\n }),\n );\n }\n\n protected createPostSpacingElement(): void {\n if (this.leafAtom.beforeRest) {\n this.postSpacingSpan = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.leafAtom.uuid,\n id: \"postSpacing\" + this.leafAtom.uuid,\n },\n text: this.leafAtom.beforeRest ? \" - \" : \" \",\n });\n }\n }\n}\n\nclass SpaceView extends LeafAtomView {\n get glyphLabel(): string {\n if (this.space.isSilent) return \" \";\n if (this.space.duration.isOne) return \",\";\n if (this.space.duration.cmpNum(2) == 0) return \";\";\n return \"_\";\n }\n\n get space(): Space {\n return this.leafAtom as Space;\n }\n}\n\nclass NoteView extends LeafAtomView {\n protected shiftElement: SVGTSpanElement;\n get glyphLabel(): string {\n return this.note.value;\n }\n\n needsRootElement(): boolean {\n return true; // this.note.shift == true || this.note.shift != 0 || super.needsRootElement();\n }\n\n protected createGlyphElement(): void {\n super.createGlyphElement();\n if (this.note.shift == true || this.note.shift != 0) {\n this.shiftElement = TSU.DOM.createSVGNode(\"tspan\", {\n doc: document,\n parent: this.rootText.element,\n attrs: {\n atomid: this.note.uuid,\n class: \"noteShiftTSpan\",\n id: \"noteShift\" + this.note.uuid,\n \"baseline-shift\": \"sub\",\n },\n text: (this.note.shift == true ? \"*\" : this.note.shift) + \" \",\n });\n }\n }\n\n protected moveGlyphToRoot(): void {\n // super.moveGlyphToRoot();\n if (this.shiftElement) {\n this.rootGroup.element.appendChild(this.shiftElement);\n }\n }\n\n orderEmbelishments(): void {\n const note = this.note;\n // create the embelishments if needed\n if (note.octave > 0) {\n this.topSlot.push(new OctaveIndicator(this, note));\n } else if (this.note.octave < 0) {\n this.bottomSlot.push(new OctaveIndicator(this, note));\n }\n super.orderEmbelishments();\n }\n\n get note(): Note {\n return this.leafAtom as Note;\n }\n}\n\nclass SyllableView extends LeafAtomView {\n get glyphLabel(): string {\n return this.syllable.value;\n }\n\n get syllable(): Syllable {\n return this.leafAtom as Syllable;\n }\n}\n\nexport function createAtomView(\n parent: SVGGraphicsElement,\n atom: Atom,\n litDefaultsToNote = false,\n groupViewScale = 1.0,\n): AtomView {\n let out: AtomView;\n switch (atom.TYPE) {\n // Dealing with leaf atoms\n case AtomType.SPACE:\n out = new SpaceView(atom as Space);\n break;\n case AtomType.SYLLABLE:\n out = new SyllableView(atom as Syllable);\n break;\n case AtomType.NOTE:\n out = new NoteView(atom as Note);\n break;\n case AtomType.LITERAL:\n if (litDefaultsToNote) {\n const lit = Note.fromLit(atom as Note);\n out = new NoteView(lit);\n } else {\n const lit = Syllable.fromLit(atom as Syllable);\n out = new SyllableView(lit);\n }\n break;\n case AtomType.GROUP:\n out = new GroupView(atom as Group);\n (out as GroupView).defaultToNotes = litDefaultsToNote;\n (out as GroupView).scaleFactor = groupViewScale;\n break;\n default:\n // We should never get a group as we are iterating\n // at leaf atom levels\n throw new Error(\"Invalid atom type: \" + atom.TYPE);\n }\n out.createElements(parent);\n return out;\n}\n"]}
@@ -55,6 +55,10 @@ export class BeatView extends BeatViewBase {
55
55
  const newX = this.hasX ? this._x : 0;
56
56
  const newY = this.hasY ? this._y : 0;
57
57
  this.element.setAttribute("transform", "translate(" + newX + "," + newY + ")");
58
+ if (this.hasWidth && this.atomView) {
59
+ this.atomView.setBounds(0, 0, this.width, null, false);
60
+ this.atomView.refreshLayout();
61
+ }
58
62
  this.invalidateBounds();
59
63
  for (const e of this.embelishments)
60
64
  e.refreshLayout();
@@ -1 +1 @@
1
- {"version":3,"file":"beatviews.js","sourceRoot":"","sources":["../../../src/carnat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AAC,GAAG,CAAC,CAAC;oBACxB,CAAC;yBAAM,CAAC;wBAEN,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;wBAChD,aAAa,GAAG,CAAC,GAAG,CAAC,CAAC;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Embelishment } from \"../shapes\";\nimport { GridCell, GridCellView } from \"../grids\";\nimport { ElementShape } from \"../shapes\";\nimport { createAtomView } from \"./atomviews\";\nimport { Marker } from \"../core\";\nimport { Beat } from \"../beats\";\nimport { BeatView as BeatViewBase } from \"../beatview\";\nimport { BeatStartLines, BeatEndLines } from \"./embelishments\";\n\nexport class MarkerView extends ElementShape<SVGGElement> implements GridCellView {\n needsLayout = true;\n rootGroup: SVGGElement;\n textElement: SVGTextElement;\n constructor(\n public readonly cell: GridCell,\n public readonly beat: Beat,\n public readonly markers: Marker[],\n public readonly isPreMarker: boolean,\n public readonly rootElement: SVGGraphicsElement,\n config?: any,\n ) {\n const rootGroup = TSU.DOM.createSVGNode(\"g\", {\n parent: rootElement,\n attrs: {\n class: \"markerView\",\n pre: isPreMarker,\n roleName: beat.role.name,\n beatIndex: \"\" + beat.index,\n gridRow: cell.rowIndex,\n gridCol: cell.colIndex,\n },\n });\n super(rootGroup);\n this.rootGroup = rootGroup as SVGGElement;\n this.textElement = TSU.DOM.createSVGNode(\"text\", {\n parent: rootGroup,\n attrs: {\n class: \"markerText\",\n pre: isPreMarker,\n dx: isPreMarker ? 0 : 15,\n },\n text: this.markers[0].text,\n });\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const ts = TSU.DOM.svgBBox(this.textElement);\n const totalWidth = ts.width;\n const maxHeight = ts.height;\n return new TSU.Geom.Size(totalWidth + 5, maxHeight + 5);\n }\n\n refreshLayout(): void {\n // TODO - move this code out to refreshLayout?\n // set the glyphs Y first so we can layout others\n this.rootGroup.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, NaN, NaN];\n }\n}\n\nexport class BeatView extends BeatViewBase {\n createAtomView() {\n return createAtomView(this.element, this.beat.atom, this.beat.role.defaultToNotes);\n }\n\n refreshLayout(): void {\n const newX = this.hasX ? this._x : 0;\n const newY = this.hasY ? this._y : 0;\n this.element.setAttribute(\"transform\", \"translate(\" + newX + \",\" + newY + \")\");\n this.invalidateBounds();\n for (const e of this.embelishments) e.refreshLayout();\n this.invalidateBounds();\n }\n\n protected createEmbelishments(): Embelishment[] {\n let embelishments: Embelishment[] = [];\n const beat = this.beat;\n // TODO - Should this be the group's parent element?\n const rootElement = this.rootElement;\n if (beat.beatIndex == 0 && beat.barIndex == 0 && beat.instance == 0) {\n // first beat in bar - Do a BarStart\n const emb = new BeatStartLines(this, rootElement);\n embelishments = [emb];\n } else {\n const cycle = this.cycle;\n const bar = cycle.bars[beat.barIndex];\n if (beat.beatIndex == bar.beatCount - 1) {\n // It is important that we are not just looking at the last beat of the bar\n // but also in the last \"instance\" of the beat in this bar to account for\n // kalais\n if (beat.instance == bar.instanceCount(beat.beatIndex) - 1) {\n if (beat.barIndex == cycle.bars.length - 1) {\n // last beat in last bar so - do a thalam end (2 lines)\n const emb = new BeatEndLines(this, rootElement, 2);\n embelishments = [emb];\n } else {\n // end of a bar so single line end\n const emb = new BeatEndLines(this, rootElement);\n embelishments = [emb];\n }\n }\n }\n }\n return embelishments;\n }\n}\n"]}
1
+ {"version":3,"file":"beatviews.js","sourceRoot":"","sources":["../../../src/carnatic/beatviews.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MA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,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;wBACnD,aAAa,GAAG,CAAC,GAAG,CAAC,CAAC;oBACxB,CAAC;yBAAM,CAAC;wBAEN,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;wBAChD,aAAa,GAAG,CAAC,GAAG,CAAC,CAAC;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Embelishment } from \"../shapes\";\nimport { GridCell, GridCellView } from \"../grids\";\nimport { ElementShape } from \"../shapes\";\nimport { createAtomView } from \"./atomviews\";\nimport { Marker } from \"../core\";\nimport { Beat } from \"../beats\";\nimport { BeatView as BeatViewBase } from \"../beatview\";\nimport { BeatStartLines, BeatEndLines } from \"./embelishments\";\n\nexport class MarkerView extends ElementShape<SVGGElement> implements GridCellView {\n needsLayout = true;\n rootGroup: SVGGElement;\n textElement: SVGTextElement;\n constructor(\n public readonly cell: GridCell,\n public readonly beat: Beat,\n public readonly markers: Marker[],\n public readonly isPreMarker: boolean,\n public readonly rootElement: SVGGraphicsElement,\n config?: any,\n ) {\n const rootGroup = TSU.DOM.createSVGNode(\"g\", {\n parent: rootElement,\n attrs: {\n class: \"markerView\",\n pre: isPreMarker,\n roleName: beat.role.name,\n beatIndex: \"\" + beat.index,\n gridRow: cell.rowIndex,\n gridCol: cell.colIndex,\n },\n });\n super(rootGroup);\n this.rootGroup = rootGroup as SVGGElement;\n this.textElement = TSU.DOM.createSVGNode(\"text\", {\n parent: rootGroup,\n attrs: {\n class: \"markerText\",\n pre: isPreMarker,\n dx: isPreMarker ? 0 : 15,\n },\n text: this.markers[0].text,\n });\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const ts = TSU.DOM.svgBBox(this.textElement);\n const totalWidth = ts.width;\n const maxHeight = ts.height;\n return new TSU.Geom.Size(totalWidth + 5, maxHeight + 5);\n }\n\n refreshLayout(): void {\n // TODO - move this code out to refreshLayout?\n // set the glyphs Y first so we can layout others\n this.rootGroup.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, NaN, NaN];\n }\n}\n\nexport class BeatView extends BeatViewBase {\n createAtomView() {\n return createAtomView(this.element, this.beat.atom, this.beat.role.defaultToNotes);\n }\n\n /**\n * Refreshes the layout of this beat view.\n *\n * This method propagates the column width from the grid layout system to\n * the atomView, enabling duration-based positioning within beats to use\n * consistent widths across the entire column.\n *\n * ### Width Propagation Flow:\n * ```\n * ColAlign.setOffset() → BeatView.setBounds(width) → atomView.setBounds(width)\n * → atomView.refreshLayout()\n * ```\n *\n * This ensures that atoms within different beats of the same column are\n * aligned based on their time offset, creating a visually consistent grid.\n */\n refreshLayout(): void {\n const newX = this.hasX ? this._x : 0;\n const newY = this.hasY ? this._y : 0;\n this.element.setAttribute(\"transform\", \"translate(\" + newX + \",\" + newY + \")\");\n\n // Propagate column width to atomView for duration-based layout\n // This enables global alignment across beats in the same column\n if (this.hasWidth && this.atomView) {\n this.atomView.setBounds(0, 0, this.width, null, false);\n this.atomView.refreshLayout();\n }\n\n this.invalidateBounds();\n for (const e of this.embelishments) e.refreshLayout();\n this.invalidateBounds();\n }\n\n protected createEmbelishments(): Embelishment[] {\n let embelishments: Embelishment[] = [];\n const beat = this.beat;\n // TODO - Should this be the group's parent element?\n const rootElement = this.rootElement;\n if (beat.beatIndex == 0 && beat.barIndex == 0 && beat.instance == 0) {\n // first beat in bar - Do a BarStart\n const emb = new BeatStartLines(this, rootElement);\n embelishments = [emb];\n } else {\n const cycle = this.cycle;\n const bar = cycle.bars[beat.barIndex];\n if (beat.beatIndex == bar.beatCount - 1) {\n // It is important that we are not just looking at the last beat of the bar\n // but also in the last \"instance\" of the beat in this bar to account for\n // kalais\n if (beat.instance == bar.instanceCount(beat.beatIndex) - 1) {\n if (beat.barIndex == cycle.bars.length - 1) {\n // last beat in last bar so - do a thalam end (2 lines)\n const emb = new BeatEndLines(this, rootElement, 2);\n embelishments = [emb];\n } else {\n // end of a bar so single line end\n const emb = new BeatEndLines(this, rootElement);\n embelishments = [emb];\n }\n }\n }\n }\n return embelishments;\n }\n}\n"]}
@@ -17,7 +17,7 @@ export declare class OctaveIndicator extends LeafAtomViewEmbelishment {
17
17
  constructor(noteView: LeafAtomView, note: Note);
18
18
  protected refreshBBox(): TSU.Geom.Rect;
19
19
  protected refreshMinSize(): TSU.Geom.Size;
20
- protected updateBounds(x: null | number, y: null | number, w: null | number, h: null | number): [number | null, number | null, number | null, number | null];
20
+ protected updateBounds(x: null | number, y: null | number, _w: null | number, _h: null | number): [number | null, number | null, number | null, number | null];
21
21
  refreshLayout(): void;
22
22
  }
23
23
  export declare class LabelEmbelishment extends LeafAtomViewEmbelishment {
@@ -52,7 +52,7 @@ export declare class BeatEndLines extends Embelishment {
52
52
  protected updatePosition(x: null | number, y: null | number): [number | null, number | null];
53
53
  barSpacing: number;
54
54
  refreshLayout(): void;
55
- protected updateBounds(x: null | number, y: null | number, w: null | number, h: null | number): [number | null, number | null, number | null, number | null];
55
+ protected updateBounds(_x: null | number, _y: null | number, _w: null | number, _h: null | number): [number | null, number | null, number | null, number | null];
56
56
  }
57
57
  export declare class Kampitham extends LabelEmbelishment {
58
58
  readonly atomView: LeafAtomView;
@@ -98,6 +98,6 @@ export declare class Jaaru extends LeafAtomViewEmbelishment {
98
98
  pathAttribute(x?: number): string;
99
99
  protected refreshMinSize(): TSU.Geom.Size;
100
100
  protected refreshBBox(): TSU.Geom.Rect;
101
- protected updateBounds(x: null | number, y: null | number, w: null | number, h: null | number): [number | null, number | null, number | null, number | null];
101
+ protected updateBounds(x: null | number, _y: null | number, _w: null | number, _h: null | number): [number | null, number | null, number | null, number | null];
102
102
  refreshLayout(): void;
103
103
  }
@@ -49,7 +49,7 @@ export class OctaveIndicator extends LeafAtomViewEmbelishment {
49
49
  height: this.dotRadius * 2,
50
50
  };
51
51
  }
52
- updateBounds(x, y, w, h) {
52
+ updateBounds(x, y, _w, _h) {
53
53
  if (x == null)
54
54
  x = this.x;
55
55
  if (y == null)
@@ -168,7 +168,7 @@ export class BeatEndLines extends Embelishment {
168
168
  line.setAttribute("y2", "" + (y + h));
169
169
  }
170
170
  }
171
- updateBounds(x, y, w, h) {
171
+ updateBounds(_x, _y, _w, _h) {
172
172
  return [null, null, null, null];
173
173
  }
174
174
  }
@@ -264,7 +264,7 @@ export class Jaaru extends LeafAtomViewEmbelishment {
264
264
  refreshBBox() {
265
265
  return TSU.DOM.svgBBox(this.pathElem);
266
266
  }
267
- updateBounds(x, y, w, h) {
267
+ updateBounds(x, _y, _w, _h) {
268
268
  return [x, null, null, null];
269
269
  }
270
270
  refreshLayout() {
@@ -1 +1 @@
1
- {"version":3,"file":"embelishments.js","sourceRoot":"","sources":["../../../src/carnatic/embelishments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAOzC,MAAM,OAAgB,wBAAyB,SAAQ,YAAY;IACjE,YAA4B,QAAsB;QAChD,KAAK,EAAE,CAAC;QADkB,aAAQ,GAAR,QAAQ,CAAc;IAElD,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,wBAAwB;IAK3D,YACkB,QAAsB,EACtB,IAAU;QAE1B,KAAK,CAAC,QAAQ,CAAC,CAAC;QAHA,aAAQ,GAAR,QAAQ,CAAc;QACtB,SAAI,GAAJ,IAAI,CAAM;QAN5B,cAAS,GAAG,CAAC,CAAC;QACd,eAAU,GAAG,GAAG,CAAC;QAQf,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACzC,MAAM,OAAO,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EAAE,GAAG,CAAC,CAAC;QACX,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAC7B,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxB,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;YACzB,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC;YACnB,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;QACd,CAAC;aAAM,CAAC;YACN,CAAC,IAAI,EAAE,CAAC;YACR,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;QACd,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,CAAC;IAES,cAAc;QACtB,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAES,WAAW;QACnB,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAES,YAAY,CACpB,CAAgB,EAChB,CAAgB,EAChB,CAAgB,EAChB,CAAgB;QAEhB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,aAAa;QACX,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Note } from \"../core\";\nimport { BeatView } from \"../beatview\";\nimport { Embelishment } from \"../shapes\";\nimport { LeafAtomView } from \"./atomviews\";\nimport { JaaruGamaka } from \"./gamakas\";\n\n/**\n * Embelishments specifically \"around\" a single atom view.\n */\nexport abstract class LeafAtomViewEmbelishment extends Embelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super();\n }\n}\n\nexport class OctaveIndicator extends LeafAtomViewEmbelishment {\n dotRadius = 1;\n dotSpacing = 2.5;\n dotsElem: SVGGElement;\n\n constructor(\n public readonly noteView: LeafAtomView,\n public readonly note: Note,\n ) {\n super(noteView);\n const rootElem = this.noteView.embRoot();\n const numDots = Math.abs(note.octave);\n this.dotsElem = TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: rootElem,\n attrs: {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n source: \"atom\" + this.noteView.leafAtom.uuid,\n },\n });\n let cx = 0;\n for (let i = 0; i < numDots; i++) {\n TSU.DOM.createSVGNode(\"circle\", {\n doc: document,\n parent: this.dotsElem,\n attrs: {\n cx: cx,\n cy: 0,\n r: this.dotRadius,\n class: \"notation-octave-dot\",\n },\n });\n cx += this.dotRadius + this.dotRadius + this.dotSpacing;\n }\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.dotsElem);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const numDots = Math.abs(this.note.octave);\n return {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n };\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n if (x == null) x = this.x;\n if (y == null) y = this.y;\n // cannot set w/h\n // this.bbox.x = x;\n // this.bbox.y = y;\n return [x, y, null, null];\n }\n\n refreshLayout(): void {\n this.dotsElem.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n}\n\n////////// Carnatic embelishments\nexport class LabelEmbelishment extends LeafAtomViewEmbelishment {\n labelElem: SVGTextElement;\n constructor(\n public readonly label: string,\n public readonly atomView: LeafAtomView,\n ) {\n super(atomView);\n const rootElem = this.atomView.embRoot();\n this.labelElem = TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: rootElem,\n text: label,\n attrs: {\n source: \"atom\" + this.atomView.leafAtom.uuid,\n class: \"notation-embelishment-label\",\n \"dominant-baseline\": \"hanging\",\n },\n });\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n refreshLayout(): void {\n this.labelElem.setAttribute(\"x\", \"\" + this.x);\n this.labelElem.setAttribute(\"y\", \"\" + this.y);\n }\n}\n\nexport class BeatStartLines extends Embelishment {\n barSpacing = 10;\n protected line: SVGLineElement;\n\n constructor(\n public readonly source: BeatView,\n public readonly rootElement: SVGGraphicsElement,\n ) {\n super();\n this.line = TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n parent: this.rootElement,\n attrs: {\n class: \"bar-start-line\",\n },\n });\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n refreshLayout(): void {\n const line = this.line;\n const x = this.source.x - this.barSpacing;\n line.setAttribute(\"x1\", \"\" + x);\n line.setAttribute(\"x2\", \"\" + x);\n const y = this.source.y + this.source.bbox.y;\n const h = this.source.bbox.height;\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, null, h];\n }\n}\n\nexport class BeatEndLines extends Embelishment {\n lineSpacing = 2;\n protected lines: SVGLineElement[];\n\n constructor(\n public readonly source: BeatView,\n public readonly rootElement: SVGGraphicsElement,\n nLines = 1,\n ) {\n super();\n this.lines = [];\n for (let i = 0; i < nLines; i++) {\n this.lines.push(\n TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n // parent: l2g,\n parent: this.rootElement,\n attrs: {\n class: \"bar-end-line\",\n },\n }),\n );\n }\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected updatePosition(x: null | number, y: null | number): [number | null, number | null] {\n return [x, y];\n }\n\n barSpacing = 0;\n\n refreshLayout(): void {\n // const x = this.source.width + this.barSpacing;\n // const y = 0;\n // const h = this.source.height;\n const x = this.source.x + this.source.width + this.barSpacing;\n const y = this.source.y + this.source.bbox.y;\n const h = this.source.bbox.height;\n let currX = x;\n for (const line of this.lines) {\n const lx = \"\" + currX;\n line.setAttribute(\"x1\", lx);\n line.setAttribute(\"x2\", lx);\n currX += 4;\n }\n for (const line of this.lines) {\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [null, null, null, null];\n }\n}\n\n/// Carnatic Embelishments\nexport class Kampitham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"~\", atomView);\n }\n}\n\nexport class Nokku extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"w\", atomView);\n }\n}\n\nexport class Prathyagatham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"∵\", atomView);\n }\n}\nexport class Spuritham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"∴\", atomView);\n }\n}\nexport class Raavi extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"^\", atomView);\n }\n}\nexport class Kandippu extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"✓\", atomView);\n }\n}\n\nexport class Vaali extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"⌒\", atomView);\n }\n}\nexport class Odukkal extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"x\", atomView);\n }\n}\nexport class Orikkai extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"γ\", atomView);\n }\n}\n\nexport class Jaaru extends LeafAtomViewEmbelishment {\n pathElem: SVGPathElement;\n constructor(\n public readonly jaaru: JaaruGamaka,\n public readonly atomView: LeafAtomView,\n ) {\n super(atomView);\n // TODO - Create the \"fancier\" view\n // for now represent this with just a slant line (like a slash)\n const rootElem = this.atomView.embRoot();\n this.pathElem = TSU.DOM.createSVGNode(\"path\", {\n doc: document,\n parent: rootElem,\n attrs: {\n source: \"atom\" + this.atomView.leafAtom.uuid,\n class: \"notation-jaaru-path\",\n d: this.pathAttribute(),\n },\n });\n }\n\n pathAttribute(x = 0): string {\n const avbbox = this.atomView.glyph.minSize;\n let y2 = 0;\n const h2 = avbbox.height / 2;\n const x2 = x + h2;\n let y = this.atomView.y;\n if (this.jaaru.ascending) {\n y += avbbox.height;\n y2 = y - h2;\n } else {\n y -= h2;\n y2 = y + h2;\n }\n return [`M ${x} ${y}`, `Q ${x2} ${y} ${x2} ${y2}`].join(\" \");\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, null, null, null];\n }\n\n refreshLayout(): void {\n this.pathElem.setAttribute(\"d\", this.p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,CAAC;IAC/D,CAAC;IAES,cAAc;QACtB,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAES,WAAW;QACnB,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAES,YAAY,CACpB,CAAgB,EAChB,EAAiB,EACjB,EAAiB,EACjB,EAAiB;QAEjB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,aAAa;QACX,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF","sourcesContent":["import * as TSU from \"@panyam/tsutils\";\nimport { Note } from \"../core\";\nimport { BeatView } from \"../beatview\";\nimport { Embelishment } from \"../shapes\";\nimport { LeafAtomView } from \"./atomviews\";\nimport { JaaruGamaka } from \"./gamakas\";\n\n/**\n * Embelishments specifically \"around\" a single atom view.\n */\nexport abstract class LeafAtomViewEmbelishment extends Embelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super();\n }\n}\n\nexport class OctaveIndicator extends LeafAtomViewEmbelishment {\n dotRadius = 1;\n dotSpacing = 2.5;\n dotsElem: SVGGElement;\n\n constructor(\n public readonly noteView: LeafAtomView,\n public readonly note: Note,\n ) {\n super(noteView);\n const rootElem = this.noteView.embRoot();\n const numDots = Math.abs(note.octave);\n this.dotsElem = TSU.DOM.createSVGNode(\"g\", {\n doc: document,\n parent: rootElem,\n attrs: {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n source: \"atom\" + this.noteView.leafAtom.uuid,\n },\n });\n let cx = 0;\n for (let i = 0; i < numDots; i++) {\n TSU.DOM.createSVGNode(\"circle\", {\n doc: document,\n parent: this.dotsElem,\n attrs: {\n cx: cx,\n cy: 0,\n r: this.dotRadius,\n class: \"notation-octave-dot\",\n },\n });\n cx += this.dotRadius + this.dotRadius + this.dotSpacing;\n }\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.dotsElem);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n const numDots = Math.abs(this.note.octave);\n return {\n width: this.dotRadius * 2 * numDots + (numDots - 1) * this.dotSpacing,\n height: this.dotRadius * 2,\n };\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n _w: null | number,\n _h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n if (x == null) x = this.x;\n if (y == null) y = this.y;\n // cannot set w/h\n // this.bbox.x = x;\n // this.bbox.y = y;\n return [x, y, null, null];\n }\n\n refreshLayout(): void {\n this.dotsElem.setAttribute(\"transform\", \"translate(\" + this.x + \",\" + this.y + \")\");\n }\n}\n\n////////// Carnatic embelishments\nexport class LabelEmbelishment extends LeafAtomViewEmbelishment {\n labelElem: SVGTextElement;\n constructor(\n public readonly label: string,\n public readonly atomView: LeafAtomView,\n ) {\n super(atomView);\n const rootElem = this.atomView.embRoot();\n this.labelElem = TSU.DOM.createSVGNode(\"text\", {\n doc: document,\n parent: rootElem,\n text: label,\n attrs: {\n source: \"atom\" + this.atomView.leafAtom.uuid,\n class: \"notation-embelishment-label\",\n \"dominant-baseline\": \"hanging\",\n },\n });\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.labelElem);\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, w, h];\n }\n\n refreshLayout(): void {\n this.labelElem.setAttribute(\"x\", \"\" + this.x);\n this.labelElem.setAttribute(\"y\", \"\" + this.y);\n }\n}\n\nexport class BeatStartLines extends Embelishment {\n barSpacing = 10;\n protected line: SVGLineElement;\n\n constructor(\n public readonly source: BeatView,\n public readonly rootElement: SVGGraphicsElement,\n ) {\n super();\n this.line = TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n parent: this.rootElement,\n attrs: {\n class: \"bar-start-line\",\n },\n });\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n refreshLayout(): void {\n const line = this.line;\n const x = this.source.x - this.barSpacing;\n line.setAttribute(\"x1\", \"\" + x);\n line.setAttribute(\"x2\", \"\" + x);\n const y = this.source.y + this.source.bbox.y;\n const h = this.source.bbox.height;\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n\n protected updateBounds(\n x: null | number,\n y: null | number,\n w: null | number,\n h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, y, null, h];\n }\n}\n\nexport class BeatEndLines extends Embelishment {\n lineSpacing = 2;\n protected lines: SVGLineElement[];\n\n constructor(\n public readonly source: BeatView,\n public readonly rootElement: SVGGraphicsElement,\n nLines = 1,\n ) {\n super();\n this.lines = [];\n for (let i = 0; i < nLines; i++) {\n this.lines.push(\n TSU.DOM.createSVGNode(\"line\", {\n doc: document,\n // parent: l2g,\n parent: this.rootElement,\n attrs: {\n class: \"bar-end-line\",\n },\n }),\n );\n }\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return new TSU.Geom.Rect(0, 0, 0, 0);\n }\n\n protected updatePosition(x: null | number, y: null | number): [number | null, number | null] {\n return [x, y];\n }\n\n barSpacing = 0;\n\n refreshLayout(): void {\n // const x = this.source.width + this.barSpacing;\n // const y = 0;\n // const h = this.source.height;\n const x = this.source.x + this.source.width + this.barSpacing;\n const y = this.source.y + this.source.bbox.y;\n const h = this.source.bbox.height;\n let currX = x;\n for (const line of this.lines) {\n const lx = \"\" + currX;\n line.setAttribute(\"x1\", lx);\n line.setAttribute(\"x2\", lx);\n currX += 4;\n }\n for (const line of this.lines) {\n line.setAttribute(\"y1\", \"\" + y);\n line.setAttribute(\"y2\", \"\" + (y + h));\n }\n }\n\n protected updateBounds(\n _x: null | number,\n _y: null | number,\n _w: null | number,\n _h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [null, null, null, null];\n }\n}\n\n/// Carnatic Embelishments\nexport class Kampitham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"~\", atomView);\n }\n}\n\nexport class Nokku extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"w\", atomView);\n }\n}\n\nexport class Prathyagatham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"∵\", atomView);\n }\n}\nexport class Spuritham extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"∴\", atomView);\n }\n}\nexport class Raavi extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"^\", atomView);\n }\n}\nexport class Kandippu extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"✓\", atomView);\n }\n}\n\nexport class Vaali extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"⌒\", atomView);\n }\n}\nexport class Odukkal extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"x\", atomView);\n }\n}\nexport class Orikkai extends LabelEmbelishment {\n constructor(public readonly atomView: LeafAtomView) {\n super(\"γ\", atomView);\n }\n}\n\nexport class Jaaru extends LeafAtomViewEmbelishment {\n pathElem: SVGPathElement;\n constructor(\n public readonly jaaru: JaaruGamaka,\n public readonly atomView: LeafAtomView,\n ) {\n super(atomView);\n // TODO - Create the \"fancier\" view\n // for now represent this with just a slant line (like a slash)\n const rootElem = this.atomView.embRoot();\n this.pathElem = TSU.DOM.createSVGNode(\"path\", {\n doc: document,\n parent: rootElem,\n attrs: {\n source: \"atom\" + this.atomView.leafAtom.uuid,\n class: \"notation-jaaru-path\",\n d: this.pathAttribute(),\n },\n });\n }\n\n pathAttribute(x = 0): string {\n const avbbox = this.atomView.glyph.minSize;\n let y2 = 0;\n const h2 = avbbox.height / 2;\n const x2 = x + h2;\n let y = this.atomView.y;\n if (this.jaaru.ascending) {\n y += avbbox.height;\n y2 = y - h2;\n } else {\n y -= h2;\n y2 = y + h2;\n }\n return [`M ${x} ${y}`, `Q ${x2} ${y} ${x2} ${y2}`].join(\" \");\n }\n\n protected refreshMinSize(): TSU.Geom.Size {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected refreshBBox(): TSU.Geom.Rect {\n return TSU.DOM.svgBBox(this.pathElem);\n }\n\n protected updateBounds(\n x: null | number,\n _y: null | number,\n _w: null | number,\n _h: null | number,\n ): [number | null, number | null, number | null, number | null] {\n return [x, null, null, null];\n }\n\n refreshLayout(): void {\n this.pathElem.setAttribute(\"d\", this.pathAttribute(this.x));\n }\n}\n"]}
@@ -52,6 +52,7 @@ export declare abstract class AtomView extends Shape {
52
52
  leading: number;
53
53
  abstract isLeaf(): boolean;
54
54
  abstract get totalDuration(): TSU.Num.Fraction;
55
+ get glyphOffset(): number;
55
56
  abstract createElements(parent: SVGGraphicsElement): void;
56
57
  }
57
58
  export declare abstract class LeafAtomView extends AtomView {
@@ -70,6 +71,8 @@ export declare abstract class GroupView extends AtomView {
70
71
  defaultToNotes: boolean;
71
72
  needsLayout: boolean;
72
73
  scaleFactor: number;
74
+ showContinuationMarkers: boolean;
75
+ protected continuationMarkerElements: SVGTextElement[];
73
76
  constructor(group: Group, config?: any);
74
77
  get totalDuration(): TSU.Num.Fraction;
75
78
  createElements(parent: SVGGraphicsElement): void;
@@ -79,6 +82,8 @@ export declare abstract class GroupView extends AtomView {
79
82
  abstract createAtomView(atom: Atom): AtomView;
80
83
  protected updateBounds(x: null | number, y: null | number, w: null | number, h: null | number): [number | null, number | null, number | null, number | null];
81
84
  refreshLayout(): void;
85
+ protected clearContinuationMarkers(): void;
86
+ protected renderContinuationMarker(x: number, y: number): void;
82
87
  get embelishments(): Embelishment[];
83
88
  protected createEmbelishments(): Embelishment[];
84
89
  setStyles(config: any): void;