Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag variable and state variable support for [create_screen_...] functions #645

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add flow support for flag and state variable use in [create_screen_xx…
…x] function.
FourLeafTec committed Nov 25, 2024
commit 6bf77c3ed275ec1ca9b9ec752e91d4180087ad28
88 changes: 68 additions & 20 deletions packages/project-editor/lvgl/widgets/Base.tsx
Original file line number Diff line number Diff line change
@@ -1993,11 +1993,23 @@ export class LVGLWidget extends Widget {
build.line(`{`);
build.indent();

build.line(
`bool val = ${build.getVariableGetterFunctionName(
this.hiddenFlag as string
)}();`
);
if (build.assets.projectStore.projectTypeTraits.hasFlowSupport) {
let componentIndex = build.assets.getComponentIndex(this);
const propertyIndex = build.assets.getComponentPropertyIndex(
this,
"hiddenFlag"
);

build.line(
`bool val = evalBooleanProperty(flowState, ${componentIndex}, ${propertyIndex}, "Failed to evaluate Hidden flag");`
);
} else {
build.line(
`bool val = ${build.getVariableGetterFunctionName(
this.hiddenFlag as string
)}();`
);
}

build.line(`if (val) lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN);`);
build.line(`else lv_obj_clear_flag(obj, LV_OBJ_FLAG_HIDDEN);`);
@@ -2010,11 +2022,23 @@ export class LVGLWidget extends Widget {
build.line(`{`);
build.indent();

build.line(
`bool val = ${build.getVariableGetterFunctionName(
this.clickableFlag as string
)}();`
);
if (build.assets.projectStore.projectTypeTraits.hasFlowSupport) {
let componentIndex = build.assets.getComponentIndex(this);
const propertyIndex = build.assets.getComponentPropertyIndex(
this,
"clickableFlag"
);

build.line(
`bool val = evalBooleanProperty(flowState, ${componentIndex}, ${propertyIndex}, "Failed to evaluate Hidden flag");`
);
} else {
build.line(
`bool val = ${build.getVariableGetterFunctionName(
this.clickableFlag as string
)}();`
);
}

build.line(`if (val) lv_obj_add_flag(obj, LV_OBJ_FLAG_CLICKABLE);`);
build.line(`else lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICKABLE);`);
@@ -2068,11 +2092,23 @@ export class LVGLWidget extends Widget {
build.line(`{`);
build.indent();

build.line(
`bool val = ${build.getVariableGetterFunctionName(
this.checkedState as string
)}();`
);
if (build.assets.projectStore.projectTypeTraits.hasFlowSupport) {
let componentIndex = build.assets.getComponentIndex(this);
const propertyIndex = build.assets.getComponentPropertyIndex(
this,
"checkedState"
);

build.line(
`bool val = evalBooleanProperty(flowState, ${componentIndex}, ${propertyIndex}, "Failed to evaluate Checked state");`
);
} else {
build.line(
`bool val = ${build.getVariableGetterFunctionName(
this.checkedState as string
)}();`
);
}

build.line(`if (val) lv_obj_add_state(obj, LV_STATE_CHECKED);`);
build.line(`else lv_obj_clear_state(obj, LV_STATE_CHECKED);`);
@@ -2085,11 +2121,23 @@ export class LVGLWidget extends Widget {
build.line(`{`);
build.indent();

build.line(
`bool val = ${build.getVariableGetterFunctionName(
this.disabledState as string
)}();`
);
if (build.assets.projectStore.projectTypeTraits.hasFlowSupport) {
let componentIndex = build.assets.getComponentIndex(this);
const propertyIndex = build.assets.getComponentPropertyIndex(
this,
"disabledState"
);

build.line(
`bool val = evalBooleanProperty(flowState, ${componentIndex}, ${propertyIndex}, "Failed to evaluate Disabled state");`
);
} else {
build.line(
`bool val = ${build.getVariableGetterFunctionName(
this.disabledState as string
)}();`
);
}

build.line(`if (val) lv_obj_add_state(obj, LV_STATE_DISABLED);`);
build.line(`else lv_obj_clear_state(obj, LV_STATE_DISABLED);`);