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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
114 changes: 114 additions & 0 deletions packages/project-editor/lvgl/widgets/Base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,63 @@ export class LVGLWidget extends Widget {
);
}
}
if (this.hiddenFlagType == "expression") {
build.line(`{`);
build.indent();

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);`);

build.unindent();
build.line(`}`);
}

if (this.clickableFlagType == "expression") {
build.line(`{`);
build.indent();

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);`);

build.unindent();
build.line(`}`);
}

if (this.flagScrollbarMode) {
build.line(
Expand Down Expand Up @@ -2031,6 +2088,63 @@ export class LVGLWidget extends Widget {
);
}
}
if (this.checkedStateType == "expression") {
build.line(`{`);
build.indent();

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);`);

build.unindent();
build.line(`}`);
}

if (this.disabledStateType == "expression") {
build.line(`{`);
build.indent();

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);`);

build.unindent();
build.line(`}`);
}

const useStyle = this.styleTemplate;
if (useStyle) {
Expand Down