From 2041a3c23b5918b4a4a26412e01590f37786737e Mon Sep 17 00:00:00 2001 From: Martin Vladic Date: Tue, 1 Oct 2024 11:37:43 +0200 Subject: [PATCH] #564 --- .../flow/runtime/cpp/eez-framework | 2 +- .../cpp/lvgl-runtime/common/src/flow.cpp | 2 +- .../flow/runtime/lvgl_runtime_v8.3.wasm | Bin 1894080 -> 1895038 bytes .../flow/runtime/lvgl_runtime_v9.0.wasm | Bin 1856433 -> 1857391 bytes packages/project-editor/lvgl/actions.tsx | 228 +++++++++++++++++- packages/project-editor/lvgl/page-runtime.ts | 3 +- .../eez-framework-amalgamation/eez-flow.cpp | 28 ++- .../eez-framework-amalgamation/eez-flow.h | 14 +- 8 files changed, 270 insertions(+), 7 deletions(-) diff --git a/packages/project-editor/flow/runtime/cpp/eez-framework b/packages/project-editor/flow/runtime/cpp/eez-framework index ca74f143..1f54d734 160000 --- a/packages/project-editor/flow/runtime/cpp/eez-framework +++ b/packages/project-editor/flow/runtime/cpp/eez-framework @@ -1 +1 @@ -Subproject commit ca74f143c589ae87fb5617d7799d5cc418c825b0 +Subproject commit 1f54d7345540e8962cd3b52f3a7d48b1fc5a5f3d diff --git a/packages/project-editor/flow/runtime/cpp/lvgl-runtime/common/src/flow.cpp b/packages/project-editor/flow/runtime/cpp/lvgl-runtime/common/src/flow.cpp index e345b9da..626f8488 100644 --- a/packages/project-editor/flow/runtime/cpp/lvgl-runtime/common/src/flow.cpp +++ b/packages/project-editor/flow/runtime/cpp/lvgl-runtime/common/src/flow.cpp @@ -951,7 +951,7 @@ EM_PORT_API(lv_group_t *) lvglCreateGroup() { } EM_PORT_API(void) lvglAddScreenLoadedEventHandler(lv_obj_t *screenObj) { - lv_obj_add_event_cb(screenObj, screen_loaded_event_callback, LV_EVENT_SCREEN_LOADED, 0); + lv_obj_add_event_cb(screenObj, screen_loaded_event_callback, LV_EVENT_SCREEN_LOAD_START, 0); } EM_PORT_API(void) lvglGroupAddObject(lv_obj_t *screenObj, lv_group_t *groupObj, lv_obj_t *obj) { diff --git a/packages/project-editor/flow/runtime/lvgl_runtime_v8.3.wasm b/packages/project-editor/flow/runtime/lvgl_runtime_v8.3.wasm index 7a47df9a9b01d1e881700f2a02892a5715b667ea..5f37d99ff1a09849fdb7ab1917776b4b00618e4f 100644 GIT binary patch delta 4527 zcmY*dYj9LW7S8RPnd#0$M#4)(I1K^=NV&U(;jti&7#1}sYEZU{wb)%mq_PEwwaX8! zQ0pT=5B4kldN6sxm{Rd-Tx{87 ztA(fZi;&EJG;)Q1MBMoDNQxvYo|WO#$I2t6i(EbyBi(vg7AZaCCXe@IXUT!%@vJ0_ z6C`|Ww2U%1WmSs4yol*V5nHkEjX^FWs=ro>hr1Rs_5^#venP7Xne3%MOVsj8F*K

ah%WOAR6Rj5puBhM}uP{G#=_9fDMUf zc?OoJ;;O`Bujes2jE4Cbmyc-_mhlv?GaDXSj-U}f=9MGqF&a)Iy{%nhtmx3zC>rHs zk@C->{)US&5?6yu6JLo z-VQMNCcWunJ>)!py_!@l9&l$d`5(x$AzJ~ps9FrQ>QzCtpuPaVZ_)dfF2V;^$UN1e zRA{_%p#`fO)uJD)9;y+;VKuo%kQY{~ELsIj7pXMneQ1H%RwIT1Q(1#D22^xV`0z0- zXbh8sqBr)^f;S*E?YsFwsm047& zDYasxRiu{VVTJ3R@f9rZkAa42Y{MHr{B8Lp}0xlHvqBSu+4 z_0k!UfR8n2#AMCpvPG8-n=8gcP+4^%!Gmb1bcLE&XV|3TL$gUU2LNo+89`2GnoS0j zl)>(0v&7)QW+@|#CD;tJS?0Jd5%0Zmx@+ zd-{u2O1nNDMuE!pFZF zh4ko-`q0kIMlrchu_db+VVq|7M?}aP9j6A_1`H^mM3WfZ3t2W9o&ifXGlJaAyycyA zmc{DtO`>}g+_V}*q55x=80STb7tI=_zJv_a&rM=r6#QH>+G6Ey7Nf0VHLh9w37r4k zES~IEX2~=g;nVC{GTo+hTV~k)EOodU&-!*lC(Dv6ZQMmG?S$9}U6xFZ&jfyzO{;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mfq@lm(h zn$H2!=k6D`ra<#h^)WZ$D!}C6)*QD|$ZwwUm{Bk3cQi?qx~bIdEgY;fSq|;zNzk~i zA5|nODTy+ppT|ZfiYhl%xxJ-7d|#5~1&cdl0Nez{O^_=Gz)cY6-E`jVJ@Eqf_X9j> zaqc_+iO}(`C2D#} z_V<`xA_lB!8D)e9eidf_DFS{Rr+e^8-Q}Tl5AE`75WCR=+Kqo>3R!qaSconi{okWI zgPvx12;&ToH+Mu>pb|gM6h9MzSsuztPjQCA!eHUB2-r)oAuum&C~O!k5*7s;4jTa* U2^$4_88#aBlT#_qG2`0*5BYGuX#fBK diff --git a/packages/project-editor/flow/runtime/lvgl_runtime_v9.0.wasm b/packages/project-editor/flow/runtime/lvgl_runtime_v9.0.wasm index af979221f6e9a423df9732f11e28f16a8eb32ee1..7fad0fbb941c38d472958b9489c913fbbd4efcd3 100644 GIT binary patch delta 4624 zcmY*c3sjZG7UrMx_-6#`?}Cp^bC0DRF|TX26w^#QweYTG)U_3LyKCh$R6LQQp`xJ& zUx|W>ijE~d$`__72r6kIiVsXuQrDGLR<6XNqQulpE4|;$IY*2&!@pL@A+r` zQ?hx&rR@`n-}bSezADY}u~k;r*|}Boa;q$KhVDXlqkGW3==Pr6D&FUvmUEM>Q#|-k zlw|%U_p%o?P#i5Bo`W zriZC>Kz0cu9-%Juh_fS3`ViEYz|I)QXPE3tU41M{#%q5R-!e+$q3#A)w**#eV702> zP|>SnEt5T|r;l;jOQSGMpai|L-e#!shl+OpgtjmB^)a`6A`I$B{j|-K;bDL3uWbf| zZ0d%J9@ZJfhlyU@5%xKReJ+93Fn^SMo}Txy@~i#jzcmzj9880KEJ?nghczlNOpsk| z_*JVV!$dcvNi9ChJE`--1b-U%6b(eeM^Orma*E^RXm}r;09>@5LEgsb=Q$=*DV4?~ zFcicD8fy$y{BRLJw8@g=VKzP>(OiX76*)%{7tIU2=S0rqXv!;y;+l`{Ox&c`{fobwVYichfJ=pXax-7q|yf4M+kz! z$q}L_!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D_i)9B*> z?g&i)`=dpBZ-Ik|RzwtAid!P_mZvE$nRyF(0|$1`Bg$mmG<5FRT&)eTWb?q z6(-}`ex2(=Wh@s%dvq~>)5)^hrfS<+9bcV@DqSve!LfNcvY4b}PEt3Pi;*dl z+s;cO$vdASYV-<`J0K#D*>ud-tNoTuXh&`R2so~}9Y^?F?Ic&7SOF)w@{~=dZ0F^> zocLCnfRk1tV2;M-sHH1WwjBAfAskVsSBj?*<_nv?Fk!y52`y&AT+(4KAxyS5%~m5; z!8BW5^-LG965+{7-cKX&q`zk4>b`E%HJh&6QF%jqxB(AMJUJmL!99BM&@dkKL&GNY zf3%&m-SD)b;j8FXc=7+4sKpro diff --git a/packages/project-editor/lvgl/actions.tsx b/packages/project-editor/lvgl/actions.tsx index 7c374b26..e5038f96 100644 --- a/packages/project-editor/lvgl/actions.tsx +++ b/packages/project-editor/lvgl/actions.tsx @@ -61,7 +61,7 @@ import { import { buildExpression } from "project-editor/flow/expression"; import { escapeCString } from "./widget-common"; import { getLvglFlagCodes } from "./lvgl-versions"; -import { LVGL_FLAG_CODES } from "./lvgl-constants"; +import { LVGL_FLAG_CODES, LVGL_STATE_CODES } from "./lvgl-constants"; //////////////////////////////////////////////////////////////////////////////// @@ -73,6 +73,8 @@ const LVGL_ACTIONS = { REMOVE_STYLE: 4, ADD_FLAG: 5, CLEAR_FLAG: 6, + ADD_STATE: 8, + CLEAR_STATE: 9, GROUP: 7 }; @@ -97,6 +99,10 @@ export class LVGLActionType extends EezObject { return LVGLAddFlagActionType; else if (jsObject.action == "CLEAR_FLAG") return LVGLClearFlagActionType; + else if (jsObject.action == "ADD_STATE") + return LVGLAddStateActionType; + else if (jsObject.action == "CLEAR_STATE") + return LVGLClearStateActionType; else return LVGLGroupActionType; }, @@ -212,6 +218,24 @@ export class LVGLActionType extends EezObject { ), LVGLClearFlagActionType ); + } else if (result.values.action == "ADD_STATE") { + actionTypeObject = createObject( + project._store, + Object.assign( + actionTypeProperties, + LVGLAddStateActionType.classInfo.defaultValue + ), + LVGLAddStateActionType + ); + } else if (result.values.action == "CLEAR_STATE") { + actionTypeObject = createObject( + project._store, + Object.assign( + actionTypeProperties, + LVGLClearStateActionType.classInfo.defaultValue + ), + LVGLClearStateActionType + ); } else if (result.values.action == "GROUP") { actionTypeObject = createObject( project._store, @@ -1557,6 +1581,208 @@ registerClass("LVGLClearFlagActionType", LVGLClearFlagActionType); //////////////////////////////////////////////////////////////////////////////// +export class LVGLAddStateActionType extends LVGLActionType { + target: string; + state: keyof typeof LVGL_STATE_CODES; + + override makeEditable() { + super.makeEditable(); + + makeObservable(this, { + target: observable, + state: observable + }); + } + + static classInfo = makeDerivedClassInfo(LVGLActionType.classInfo, { + properties: [ + { + name: "target", + displayName: "Target", + type: PropertyType.Enum, + enumItems: (actionType: LVGLAddStateActionType) => { + const lvglIdentifiers = ProjectEditor.getProjectStore( + actionType + ).lvglIdentifiers.getIdentifiersVisibleFromFlow( + ProjectEditor.getFlow(actionType) + ); + + return lvglIdentifiers.map(lvglIdentifier => ({ + id: lvglIdentifier.identifier, + label: lvglIdentifier.identifier + })); + } + }, + { + name: "state", + type: PropertyType.Enum, + enumItems: (actionType: LVGLAddStateActionType) => { + return Object.keys(LVGL_STATE_CODES).map(state => ({ + id: state, + label: state + })); + } + } + ], + defaultValue: {}, + listLabel: (action: LVGLAddStateActionType, collapsed: boolean) => { + if (!collapsed) { + return "Add state"; + } + let singleItem = + (getParent(action) as LVGLActionType[]).length == 1; + if (singleItem) { + return ( + <> + {action.state} in {action.target} + + ); + } else { + return ( + <> + Add state {action.state} in {action.target} + + ); + } + }, + check: (object: LVGLAddStateActionType, messages: IMessage[]) => { + const projectStore = ProjectEditor.getProjectStore(object); + + if (object.target) { + const lvglIdentifier = + projectStore.lvglIdentifiers.getIdentifierByName( + ProjectEditor.getFlow(object), + object.target + ); + + if (lvglIdentifier == undefined) { + messages.push(propertyNotFoundMessage(object, "target")); + } + } else { + messages.push(propertyNotSetMessage(object, "target")); + } + } + }); + + override build(assets: Assets, dataBuffer: DataBuffer) { + // target + dataBuffer.writeInt32( + assets.projectStore.lvglIdentifiers.getIdentifierByName( + ProjectEditor.getFlow(this), + this.target + )?.index ?? -1 + ); + + // state + dataBuffer.writeUint32(LVGL_STATE_CODES[this.state] ?? 0); + } +} + +registerClass("LVGLAddStateActionType", LVGLAddStateActionType); + +//////////////////////////////////////////////////////////////////////////////// + +export class LVGLClearStateActionType extends LVGLActionType { + target: string; + state: keyof typeof LVGL_STATE_CODES; + + override makeEditable() { + super.makeEditable(); + + makeObservable(this, { + target: observable, + state: observable + }); + } + + static classInfo = makeDerivedClassInfo(LVGLActionType.classInfo, { + properties: [ + { + name: "target", + displayName: "Target", + type: PropertyType.Enum, + enumItems: (actionType: LVGLClearStateActionType) => { + const lvglIdentifiers = ProjectEditor.getProjectStore( + actionType + ).lvglIdentifiers.getIdentifiersVisibleFromFlow( + ProjectEditor.getFlow(actionType) + ); + + return lvglIdentifiers.map(lvglIdentifier => ({ + id: lvglIdentifier.identifier, + label: lvglIdentifier.identifier + })); + } + }, + { + name: "state", + type: PropertyType.Enum, + enumItems: (actionType: LVGLClearStateActionType) => { + return Object.keys(LVGL_STATE_CODES).map(state => ({ + id: state, + label: state + })); + } + } + ], + defaultValue: {}, + listLabel: (action: LVGLClearStateActionType, collapsed: boolean) => { + if (!collapsed) { + return "Clear state"; + } + let singleItem = + (getParent(action) as LVGLActionType[]).length == 1; + if (singleItem) { + return ( + <> + {action.state} in {action.target} + + ); + } else { + return ( + <> + Clear state {action.state} in {action.target} + + ); + } + }, + check: (object: LVGLClearStateActionType, messages: IMessage[]) => { + const projectStore = ProjectEditor.getProjectStore(object); + + if (object.target) { + const lvglIdentifier = + projectStore.lvglIdentifiers.getIdentifierByName( + ProjectEditor.getFlow(object), + object.target + ); + + if (lvglIdentifier == undefined) { + messages.push(propertyNotFoundMessage(object, "target")); + } + } else { + messages.push(propertyNotSetMessage(object, "target")); + } + } + }); + + override build(assets: Assets, dataBuffer: DataBuffer) { + // target + dataBuffer.writeInt32( + assets.projectStore.lvglIdentifiers.getIdentifierByName( + ProjectEditor.getFlow(this), + this.target + )?.index ?? -1 + ); + + // state + dataBuffer.writeUint32(LVGL_STATE_CODES[this.state] ?? 0); + } +} + +registerClass("LVGLClearStateActionType", LVGLClearStateActionType); + +//////////////////////////////////////////////////////////////////////////////// + const GROUP_ACTIONS = { SET_WRAP: 0, FOCUS_OBJ: 1, diff --git a/packages/project-editor/lvgl/page-runtime.ts b/packages/project-editor/lvgl/page-runtime.ts index 89600abd..09a9a86d 100644 --- a/packages/project-editor/lvgl/page-runtime.ts +++ b/packages/project-editor/lvgl/page-runtime.ts @@ -762,7 +762,6 @@ export class LVGLPageViewerRuntime extends LVGLPageRuntime { // add widgets to groups for (const page of this.pages) { if (page._lvglObj) { - this.wasm._lvglAddScreenLoadedEventHandler(page._lvglObj); for ( let i = 0; i < this.project.lvglGroups.groups.length; @@ -829,6 +828,8 @@ export class LVGLPageViewerRuntime extends LVGLPageRuntime { const pageObj = this.page.lvglCreate(this, 0); + this.wasm._lvglAddScreenLoadedEventHandler(pageObj); + runInAction(() => { this.page._lvglObj = pageObj; }); diff --git a/resources/eez-framework-amalgamation/eez-flow.cpp b/resources/eez-framework-amalgamation/eez-flow.cpp index c934991b..838602c1 100644 --- a/resources/eez-framework-amalgamation/eez-flow.cpp +++ b/resources/eez-framework-amalgamation/eez-flow.cpp @@ -1,4 +1,4 @@ -/* Autogenerated on September 27, 2024 2:31:05 PM from eez-framework commit ca74f143c589ae87fb5617d7799d5cc418c825b0 */ +/* Autogenerated on October 1, 2024 11:29:42 AM from eez-framework commit ca74f143c589ae87fb5617d7799d5cc418c825b0 */ /* * eez-framework * @@ -4066,6 +4066,32 @@ void executeLVGLComponent(FlowState *flowState, unsigned componentIndex) { lv_group_set_editing(target, specific->enable ? true : false); } } + } else if (general->action == ADD_STATE) { + auto specific = (LVGLComponent_AddState_ActionType *)general; + auto target = getLvglObjectFromIndexHook(flowState->lvglWidgetStartIndex + specific->target); + if (!target) { + if (!executionState) { + executionState = allocateComponentExecutionState(flowState, componentIndex); + } + executionState->actionIndex = actionIndex; + addToQueue(flowState, componentIndex, -1, -1, -1, true); + return; + } else { + lv_obj_add_state(target, (lv_state_t)specific->state); + } + } else if (general->action == CLEAR_STATE) { + auto specific = (LVGLComponent_ClearState_ActionType *)general; + auto target = getLvglObjectFromIndexHook(flowState->lvglWidgetStartIndex + specific->target); + if (!target) { + if (!executionState) { + executionState = allocateComponentExecutionState(flowState, componentIndex); + } + executionState->actionIndex = actionIndex; + addToQueue(flowState, componentIndex, -1, -1, -1, true); + return; + } else { + lv_obj_clear_state(target, (lv_state_t)specific->state); + } } } propagateValueThroughSeqout(flowState, componentIndex); diff --git a/resources/eez-framework-amalgamation/eez-flow.h b/resources/eez-framework-amalgamation/eez-flow.h index c7dcb6aa..95cafcdc 100644 --- a/resources/eez-framework-amalgamation/eez-flow.h +++ b/resources/eez-framework-amalgamation/eez-flow.h @@ -1,4 +1,4 @@ -/* Autogenerated on September 27, 2024 2:31:05 PM from eez-framework commit ca74f143c589ae87fb5617d7799d5cc418c825b0 */ +/* Autogenerated on October 1, 2024 11:29:42 AM from eez-framework commit ca74f143c589ae87fb5617d7799d5cc418c825b0 */ /* * eez-framework * @@ -2653,7 +2653,9 @@ enum LVGL_ACTIONS { REMOVE_STYLE, ADD_FLAG, CLEAR_FLAG, - GROUP + GROUP, + ADD_STATE, + CLEAR_STATE, }; struct LVGLComponent_ActionType { uint32_t action; @@ -2717,6 +2719,14 @@ struct LVGLComponent_Group_ActionType : public LVGLComponent_ActionType { int32_t target; uint32_t enable; }; +struct LVGLComponent_AddState_ActionType : public LVGLComponent_ActionType { + int32_t target; + uint32_t state; +}; +struct LVGLComponent_ClearState_ActionType : public LVGLComponent_ActionType { + int32_t target; + uint32_t state; +}; struct LVGLComponent : public Component { ListOfAssetsPtr actions; };