Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Nov 13, 2024
1 parent 9d30da0 commit 4289e3f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/eez-studio-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ interface AssetsMap {
displayHeight: number;
bitmaps: string[];
lvglWidgetIndexes: { [identifier: string]: number };
lvglWidgetGeneratedIdentifiers: { [objId: string]: string };
}

export interface ScpiCommand {
Expand Down
3 changes: 2 additions & 1 deletion packages/project-editor/build/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ export class Assets {
displayWidth: this.displayWidth,
displayHeight: this.displayHeight,
bitmaps: [],
lvglWidgetIndexes: {}
lvglWidgetIndexes: {},
lvglWidgetGeneratedIdentifiers: {}
};

dashboardComponentClassNameToComponentIdMap: {
Expand Down
27 changes: 17 additions & 10 deletions packages/project-editor/lvgl/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -205,7 +212,7 @@ export class LVGLBuild extends Build {
}
}
}
}
};

const addIdentifiersForUserWidget = (
prefix: string,
Expand Down
13 changes: 11 additions & 2 deletions packages/project-editor/lvgl/page-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down

0 comments on commit 4289e3f

Please sign in to comment.