Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Jul 14, 2024
1 parent b00ad6e commit f107b18
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
19 changes: 16 additions & 3 deletions packages/project-editor/lvgl/expression-property.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ export function expressionPropertyBuildTickSpecific<T extends LVGLWidget>(
getFunc: string,
setFunc: string,
setFuncOptArgs?: string,
arcRange?: "min" | "max"
arcRange?: "min" | "max",
checkStateEdited?: boolean
) {
if (getProperty(widget, propName + "Type") == "expression") {
const propertyInfo = findPropertyByNameInClassInfo(
Expand All @@ -236,6 +237,15 @@ export function expressionPropertyBuildTickSpecific<T extends LVGLWidget>(
build.line(`{`);
build.indent();

const objectAccessor = build.getLvglObjectAccessor(widget);

if (checkStateEdited) {
build.line(
`if (!(lv_obj_get_state(${objectAccessor}) & LV_STATE_EDITED)) {`
);
build.indent();
}

if (build.assets.projectStore.projectTypeTraits.hasFlowSupport) {
let componentIndex = build.assets.getComponentIndex(widget);
const propertyIndex = build.assets.getComponentPropertyIndex(
Expand Down Expand Up @@ -296,8 +306,6 @@ export function expressionPropertyBuildTickSpecific<T extends LVGLWidget>(
propertyInfo.expressionType == "string" ||
propertyInfo.expressionType == "array:string"
) {
const objectAccessor = build.getLvglObjectAccessor(widget);

if (widget instanceof ProjectEditor.LVGLTabWidgetClass) {
build.line(
`lv_obj_t *tabview = lv_obj_get_parent(lv_obj_get_parent(${objectAccessor}));`
Expand Down Expand Up @@ -422,6 +430,11 @@ export function expressionPropertyBuildTickSpecific<T extends LVGLWidget>(
return;
}

if (checkStateEdited) {
build.unindent();
build.line(`}`);
}

build.unindent();
build.line(`}`);
}
Expand Down
5 changes: 4 additions & 1 deletion packages/project-editor/lvgl/widgets/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ export class LVGLDropdownWidget extends LVGLWidget {
this,
"selected" as const,
"lv_dropdown_get_selected",
"lv_dropdown_set_selected"
"lv_dropdown_set_selected",
undefined,
undefined,
true
);
}

Expand Down
4 changes: 3 additions & 1 deletion packages/project-editor/lvgl/widgets/Roller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ export class LVGLRollerWidget extends LVGLWidget {
"selected" as const,
"lv_roller_get_selected",
"lv_roller_set_selected",
", LV_ANIM_OFF"
", LV_ANIM_OFF",
undefined,
true
);
}

Expand Down

0 comments on commit f107b18

Please sign in to comment.