reconstruct ccTUI, add Button component

This commit is contained in:
2025-10-10 21:43:24 +08:00
parent 61baedb606
commit 8e95fe8ad1
14 changed files with 1292 additions and 1162 deletions

32
src/lib/ccTUI/UIObject.ts Normal file
View File

@@ -0,0 +1,32 @@
import { CCLog } from "../ccLog";
export abstract class UIObject {
readonly objectName: string;
private parent?: UIObject;
private children: Record<string, UIObject> = {};
public log?: CCLog;
constructor(name: string, parent?: UIObject, log?: CCLog) {
this.objectName = name;
this.parent = parent;
this.log = log;
}
public setParent(parent: UIObject) {
this.parent = parent;
this.log ??= parent.log;
}
public addChild(child: UIObject) {
this.children[child.objectName] = child;
}
public removeChild(child: UIObject) {
Object.entries(this.children).forEach(([key, value]) => {
if (value === child) {
delete this.children[key];
}
});
}
}