Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Sep 27, 2024
1 parent c17c919 commit f2426be
Show file tree
Hide file tree
Showing 5 changed files with 236 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/project-editor/flow/runtime/lvgl_runtime_v8.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -4831,6 +4831,8 @@ var _lvglSetTimelinePosition = Module['_lvglSetTimelinePosition'] = createExport
var _lvglClearTimeline = Module['_lvglClearTimeline'] = createExportWrapper('lvglClearTimeline');
var _lvglSetScrollBarMode = Module['_lvglSetScrollBarMode'] = createExportWrapper('lvglSetScrollBarMode');
var _lvglSetScrollDir = Module['_lvglSetScrollDir'] = createExportWrapper('lvglSetScrollDir');
var _lvglSetScrollSnapX = Module['_lvglSetScrollSnapX'] = createExportWrapper('lvglSetScrollSnapX');
var _lvglSetScrollSnapY = Module['_lvglSetScrollSnapY'] = createExportWrapper('lvglSetScrollSnapY');
var _lvglTabviewSetActive = Module['_lvglTabviewSetActive'] = createExportWrapper('lvglTabviewSetActive');
var _lvglTabviewGetTabBar = Module['_lvglTabviewGetTabBar'] = createExportWrapper('lvglTabviewGetTabBar');
var _lvglTabviewGetTabContent = Module['_lvglTabviewGetTabContent'] = createExportWrapper('lvglTabviewGetTabContent');
Expand Down
Binary file modified packages/project-editor/flow/runtime/lvgl_runtime_v8.3.wasm
Binary file not shown.
Binary file modified packages/project-editor/flow/runtime/lvgl_runtime_v9.0.wasm
Binary file not shown.
234 changes: 233 additions & 1 deletion packages/project-editor/lvgl/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ import {
} from "project-editor/lvgl/expression-property";
import { buildExpression } from "project-editor/flow/expression";
import { escapeCString } from "./widget-common";
import { getLvglFlagCodes } from "./lvgl-versions";
import { LVGL_FLAG_CODES } from "./lvgl-constants";

////////////////////////////////////////////////////////////////////////////////

Expand All @@ -69,7 +71,9 @@ const LVGL_ACTIONS = {
SET_PROPERTY: 2,
ADD_STYLE: 3,
REMOVE_STYLE: 4,
GROUP: 5
ADD_FLAG: 5,
CLEAR_FLAG: 6,
GROUP: 7
};

////////////////////////////////////////////////////////////////////////////////
Expand All @@ -89,6 +93,10 @@ export class LVGLActionType extends EezObject {
return LVGLAddStyleActionType;
else if (jsObject.action == "REMOVE_STYLE")
return LVGLRemoveStyleActionType;
else if (jsObject.action == "ADD_FLAG")
return LVGLAddFlagActionType;
else if (jsObject.action == "CLEAR_FLAG")
return LVGLClearFlagActionType;
else return LVGLGroupActionType;
},

Expand Down Expand Up @@ -186,6 +194,24 @@ export class LVGLActionType extends EezObject {
),
LVGLRemoveStyleActionType
);
} else if (result.values.action == "ADD_FLAG") {
actionTypeObject = createObject<LVGLAddFlagActionType>(
project._store,
Object.assign(
actionTypeProperties,
LVGLAddFlagActionType.classInfo.defaultValue
),
LVGLAddFlagActionType
);
} else if (result.values.action == "CLEAR_FLAG") {
actionTypeObject = createObject<LVGLClearFlagActionType>(
project._store,
Object.assign(
actionTypeProperties,
LVGLClearFlagActionType.classInfo.defaultValue
),
LVGLClearFlagActionType
);
} else if (result.values.action == "GROUP") {
actionTypeObject = createObject<LVGLGroupActionType>(
project._store,
Expand Down Expand Up @@ -1325,6 +1351,212 @@ registerClass("LVGLRemoveStyleActionType", LVGLRemoveStyleActionType);

////////////////////////////////////////////////////////////////////////////////

export class LVGLAddFlagActionType extends LVGLActionType {
target: string;
flag: keyof typeof LVGL_FLAG_CODES;

override makeEditable() {
super.makeEditable();

makeObservable(this, {
target: observable,
flag: observable
});
}

static classInfo = makeDerivedClassInfo(LVGLActionType.classInfo, {
properties: [
{
name: "target",
displayName: "Target",
type: PropertyType.Enum,
enumItems: (actionType: LVGLAddFlagActionType) => {
const lvglIdentifiers = ProjectEditor.getProjectStore(
actionType
).lvglIdentifiers.getIdentifiersVisibleFromFlow(
ProjectEditor.getFlow(actionType)
);

return lvglIdentifiers.map(lvglIdentifier => ({
id: lvglIdentifier.identifier,
label: lvglIdentifier.identifier
}));
}
},
{
name: "flag",
type: PropertyType.Enum,
enumItems: (actionType: LVGLAddFlagActionType) => {
return Object.keys(getLvglFlagCodes(actionType)).map(
flag => ({
id: flag,
label: flag
})
);
}
}
],
defaultValue: {},
listLabel: (action: LVGLAddFlagActionType, collapsed: boolean) => {
if (!collapsed) {
return "Add flag";
}
let singleItem =
(getParent(action) as LVGLActionType[]).length == 1;
if (singleItem) {
return (
<>
{action.flag} in {action.target}
</>
);
} else {
return (
<>
Add flag {action.flag} in {action.target}
</>
);
}
},
check: (object: LVGLAddFlagActionType, 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
);

// flag
dataBuffer.writeUint32(getLvglFlagCodes(this)[this.flag] ?? 0);
}
}

registerClass("LVGLAddFlagActionType", LVGLAddFlagActionType);

////////////////////////////////////////////////////////////////////////////////

export class LVGLClearFlagActionType extends LVGLActionType {
target: string;
flag: keyof typeof LVGL_FLAG_CODES;

override makeEditable() {
super.makeEditable();

makeObservable(this, {
target: observable,
flag: observable
});
}

static classInfo = makeDerivedClassInfo(LVGLActionType.classInfo, {
properties: [
{
name: "target",
displayName: "Target",
type: PropertyType.Enum,
enumItems: (actionType: LVGLClearFlagActionType) => {
const lvglIdentifiers = ProjectEditor.getProjectStore(
actionType
).lvglIdentifiers.getIdentifiersVisibleFromFlow(
ProjectEditor.getFlow(actionType)
);

return lvglIdentifiers.map(lvglIdentifier => ({
id: lvglIdentifier.identifier,
label: lvglIdentifier.identifier
}));
}
},
{
name: "flag",
type: PropertyType.Enum,
enumItems: (actionType: LVGLClearFlagActionType) => {
return Object.keys(getLvglFlagCodes(actionType)).map(
flag => ({
id: flag,
label: flag
})
);
}
}
],
defaultValue: {},
listLabel: (action: LVGLClearFlagActionType, collapsed: boolean) => {
if (!collapsed) {
return "Clear flag";
}
let singleItem =
(getParent(action) as LVGLActionType[]).length == 1;
if (singleItem) {
return (
<>
{action.flag} in {action.target}
</>
);
} else {
return (
<>
Clear flag {action.flag} in {action.target}
</>
);
}
},
check: (object: LVGLClearFlagActionType, 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
);

// flag
dataBuffer.writeUint32(getLvglFlagCodes(this)[this.flag] ?? 0);
}
}

registerClass("LVGLClearFlagActionType", LVGLClearFlagActionType);

////////////////////////////////////////////////////////////////////////////////

const GROUP_ACTIONS = {
SET_WRAP: 0,
FOCUS_OBJ: 1,
Expand Down

0 comments on commit f2426be

Please sign in to comment.