diff --git a/packages/eez-studio-types/index.d.ts b/packages/eez-studio-types/index.d.ts index 5bcb028f..8e45c611 100644 --- a/packages/eez-studio-types/index.d.ts +++ b/packages/eez-studio-types/index.d.ts @@ -511,6 +511,7 @@ interface AssetsMap { displayHeight: number; bitmaps: string[]; lvglWidgetIndexes: { [identifier: string]: number }; + lvglWidgetGeneratedIdentifiers: { [objId: string]: string }; } export interface ScpiCommand { diff --git a/packages/project-editor/build/assets.ts b/packages/project-editor/build/assets.ts index 70b36787..a55f7609 100644 --- a/packages/project-editor/build/assets.ts +++ b/packages/project-editor/build/assets.ts @@ -161,7 +161,8 @@ export class Assets { displayWidth: this.displayWidth, displayHeight: this.displayHeight, bitmaps: [], - lvglWidgetIndexes: {} + lvglWidgetIndexes: {}, + lvglWidgetGeneratedIdentifiers: {} }; dashboardComponentClassNameToComponentIdMap: { diff --git a/packages/project-editor/lvgl/build.ts b/packages/project-editor/lvgl/build.ts index 603039bf..ef23b9e8 100644 --- a/packages/project-editor/lvgl/build.ts +++ b/packages/project-editor/lvgl/build.ts @@ -152,24 +152,31 @@ export class LVGLBuild extends Build { return GENERATED_NAME_PREFIX + genIndex++; } - function addPageIdentifiers( + const addPageIdentifiers = ( widgets: LVGLWidget[], pageIdentifiers: Identifiers, prefix: string, isUserWidget: boolean - ) { + ) => { let startIndex = isUserWidget ? pageIdentifiers.identifiers.length : 0; for (const widget of widgets) { - const identifier = widget.identifier - ? getName( - "", - widget.identifier, - NamingConvention.UnderscoreLowerCase - ) - : generateUniqueObjectName(); + let identifier; + + if (widget.identifier) { + identifier = getName( + "", + widget.identifier, + NamingConvention.UnderscoreLowerCase + ); + } else { + identifier = generateUniqueObjectName(); + this.assets.map.lvglWidgetGeneratedIdentifiers[ + widget.objID + ] = identifier; + } pageIdentifiers.widgetToIdentifier.set( widget, @@ -205,7 +212,7 @@ export class LVGLBuild extends Build { } } } - } + }; const addIdentifiersForUserWidget = ( prefix: string, diff --git a/packages/project-editor/lvgl/page-runtime.ts b/packages/project-editor/lvgl/page-runtime.ts index d970e273..4fcd3f6a 100644 --- a/packages/project-editor/lvgl/page-runtime.ts +++ b/packages/project-editor/lvgl/page-runtime.ts @@ -1148,9 +1148,18 @@ export class LVGLPageViewerRuntime extends LVGLPageRuntime { override getWidgetIndex(object: LVGLWidget | Page) { const identifier = [ - ...this.userWidgetsStack.map(widget => widget.identifier), + ...this.userWidgetsStack.map( + widget => + widget.identifier || + this.runtime.assetsMap.lvglWidgetGeneratedIdentifiers[ + widget.objID + ] + ), object instanceof ProjectEditor.LVGLWidgetClass - ? object.identifier + ? object.identifier || + this.runtime.assetsMap.lvglWidgetGeneratedIdentifiers[ + object.objID + ] : object.name ] .map(identifier =>