Rename Layer to VectorLayer

This commit is contained in:
Skyler Lehmkuhl 2025-11-05 19:18:11 -05:00
parent 5320e14745
commit 07dc7efbe4
3 changed files with 12 additions and 12 deletions

View File

@ -93,7 +93,7 @@ import {
AnimationData AnimationData
} from "./models/animation.js"; } from "./models/animation.js";
import { import {
Layer, VectorLayer,
AudioTrack, AudioTrack,
initializeLayerDependencies initializeLayerDependencies
} from "./models/layer.js"; } from "./models/layer.js";
@ -638,7 +638,7 @@ function redo() {
// ============================================================================ // ============================================================================
// ============================================================================ // ============================================================================
// Layer system classes (Layer, AudioTrack) // Layer system classes (VectorLayer, AudioTrack, VideoLayer)
// have been moved to src/models/layer.js and are imported at the top of this file // have been moved to src/models/layer.js and are imported at the top of this file
// ============================================================================ // ============================================================================

View File

@ -1,7 +1,7 @@
// GraphicsObject model: Main container for layers and animation // GraphicsObject model: Main container for layers and animation
import { context, config, pointerList, startProps } from '../state.js'; import { context, config, pointerList, startProps } from '../state.js';
import { Layer, AudioTrack } from './layer.js'; import { VectorLayer, AudioTrack } from './layer.js';
import { TempShape } from './shapes.js'; import { TempShape } from './shapes.js';
import { AnimationCurve, Keyframe } from './animation.js'; import { AnimationCurve, Keyframe } from './animation.js';
import { Widget } from '../widgets.js'; import { Widget } from '../widgets.js';
@ -54,7 +54,7 @@ class GraphicsObject extends Widget {
this.audioTracks = []; this.audioTracks = [];
if (initialChildType === 'layer') { if (initialChildType === 'layer') {
this.children = [new Layer(uuid + "-L1", this)]; this.children = [new VectorLayer(uuid + "-L1", this)];
this.currentLayer = 0; // Set first layer as active this.currentLayer = 0; // Set first layer as active
} else if (initialChildType === 'midi') { } else if (initialChildType === 'midi') {
const midiTrack = new AudioTrack(uuid + "-M1", "MIDI 1", 'midi'); const midiTrack = new AudioTrack(uuid + "-M1", "MIDI 1", 'midi');
@ -103,7 +103,7 @@ class GraphicsObject extends Widget {
graphicsObject.parent = pointerList[json.parent] graphicsObject.parent = pointerList[json.parent]
} }
for (let layer of json.layers) { for (let layer of json.layers) {
graphicsObject.layers.push(Layer.fromJSON(layer, graphicsObject)); graphicsObject.layers.push(VectorLayer.fromJSON(layer, graphicsObject));
} }
// Handle audioTracks (may not exist in older files) // Handle audioTracks (may not exist in older files)
if (json.audioTracks) { if (json.audioTracks) {

View File

@ -1,4 +1,4 @@
// Layer models: Layer and AudioLayer classes // Layer models: VectorLayer, AudioTrack, and VideoLayer classes
import { context, config, pointerList } from '../state.js'; import { context, config, pointerList } from '../state.js';
import { Frame, AnimationData, Keyframe, tempFrame } from './animation.js'; import { Frame, AnimationData, Keyframe, tempFrame } from './animation.js';
@ -65,7 +65,7 @@ export function initializeLayerDependencies(deps) {
actions = deps.actions; actions = deps.actions;
} }
class Layer extends Widget { class VectorLayer extends Widget {
constructor(uuid, parentObject = null) { constructor(uuid, parentObject = null) {
super(0,0) super(0,0)
if (!uuid) { if (!uuid) {
@ -73,7 +73,7 @@ class Layer extends Widget {
} else { } else {
this.idx = uuid; this.idx = uuid;
} }
this.name = "Layer"; this.name = "VectorLayer";
// LEGACY: Keep frames array for backwards compatibility during migration // LEGACY: Keep frames array for backwards compatibility during migration
this.frames = [new Frame("keyframe", this.idx + "-F1")]; this.frames = [new Frame("keyframe", this.idx + "-F1")];
this.animationData = new AnimationData(this); this.animationData = new AnimationData(this);
@ -86,7 +86,7 @@ class Layer extends Widget {
this.shapes = [] this.shapes = []
} }
static fromJSON(json, parentObject = null) { static fromJSON(json, parentObject = null) {
const layer = new Layer(json.idx, parentObject); const layer = new VectorLayer(json.idx, parentObject);
for (let i in json.children) { for (let i in json.children) {
const child = json.children[i]; const child = json.children[i];
const childObject = GraphicsObject.fromJSON(child); const childObject = GraphicsObject.fromJSON(child);
@ -136,7 +136,7 @@ class Layer extends Widget {
} }
toJSON(randomizeUuid = false) { toJSON(randomizeUuid = false) {
const json = {}; const json = {};
json.type = "Layer"; json.type = "VectorLayer";
if (randomizeUuid) { if (randomizeUuid) {
json.idx = uuidv4(); json.idx = uuidv4();
json.name = this.name + " copy"; json.name = this.name + " copy";
@ -468,7 +468,7 @@ class Layer extends Widget {
} }
} }
copy(idx) { copy(idx) {
let newLayer = new Layer(idx.slice(0, 8) + this.idx.slice(8)); let newLayer = new VectorLayer(idx.slice(0, 8) + this.idx.slice(8));
let idxMapping = {}; let idxMapping = {};
for (let child of this.children) { for (let child of this.children) {
let newChild = child.copy(idx); let newChild = child.copy(idx);
@ -1245,4 +1245,4 @@ class AudioTrack {
} }
} }
export { Layer, AudioTrack }; export { VectorLayer, AudioTrack };