Skip to content

Commit f2426be

Browse files
committed
1 parent c17c919 commit f2426be

File tree

5 files changed

+236
-2
lines changed

5 files changed

+236
-2
lines changed

packages/project-editor/flow/runtime/lvgl_runtime_v8.3.js

+2
Original file line numberDiff line numberDiff line change
@@ -4831,6 +4831,8 @@ var _lvglSetTimelinePosition = Module['_lvglSetTimelinePosition'] = createExport
48314831
var _lvglClearTimeline = Module['_lvglClearTimeline'] = createExportWrapper('lvglClearTimeline');
48324832
var _lvglSetScrollBarMode = Module['_lvglSetScrollBarMode'] = createExportWrapper('lvglSetScrollBarMode');
48334833
var _lvglSetScrollDir = Module['_lvglSetScrollDir'] = createExportWrapper('lvglSetScrollDir');
4834+
var _lvglSetScrollSnapX = Module['_lvglSetScrollSnapX'] = createExportWrapper('lvglSetScrollSnapX');
4835+
var _lvglSetScrollSnapY = Module['_lvglSetScrollSnapY'] = createExportWrapper('lvglSetScrollSnapY');
48344836
var _lvglTabviewSetActive = Module['_lvglTabviewSetActive'] = createExportWrapper('lvglTabviewSetActive');
48354837
var _lvglTabviewGetTabBar = Module['_lvglTabviewGetTabBar'] = createExportWrapper('lvglTabviewGetTabBar');
48364838
var _lvglTabviewGetTabContent = Module['_lvglTabviewGetTabContent'] = createExportWrapper('lvglTabviewGetTabContent');
Binary file not shown.
Binary file not shown.

packages/project-editor/lvgl/actions.tsx

+233-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ import {
6060
} from "project-editor/lvgl/expression-property";
6161
import { buildExpression } from "project-editor/flow/expression";
6262
import { escapeCString } from "./widget-common";
63+
import { getLvglFlagCodes } from "./lvgl-versions";
64+
import { LVGL_FLAG_CODES } from "./lvgl-constants";
6365

6466
////////////////////////////////////////////////////////////////////////////////
6567

@@ -69,7 +71,9 @@ const LVGL_ACTIONS = {
6971
SET_PROPERTY: 2,
7072
ADD_STYLE: 3,
7173
REMOVE_STYLE: 4,
72-
GROUP: 5
74+
ADD_FLAG: 5,
75+
CLEAR_FLAG: 6,
76+
GROUP: 7
7377
};
7478

7579
////////////////////////////////////////////////////////////////////////////////
@@ -89,6 +93,10 @@ export class LVGLActionType extends EezObject {
8993
return LVGLAddStyleActionType;
9094
else if (jsObject.action == "REMOVE_STYLE")
9195
return LVGLRemoveStyleActionType;
96+
else if (jsObject.action == "ADD_FLAG")
97+
return LVGLAddFlagActionType;
98+
else if (jsObject.action == "CLEAR_FLAG")
99+
return LVGLClearFlagActionType;
92100
else return LVGLGroupActionType;
93101
},
94102

@@ -186,6 +194,24 @@ export class LVGLActionType extends EezObject {
186194
),
187195
LVGLRemoveStyleActionType
188196
);
197+
} else if (result.values.action == "ADD_FLAG") {
198+
actionTypeObject = createObject<LVGLAddFlagActionType>(
199+
project._store,
200+
Object.assign(
201+
actionTypeProperties,
202+
LVGLAddFlagActionType.classInfo.defaultValue
203+
),
204+
LVGLAddFlagActionType
205+
);
206+
} else if (result.values.action == "CLEAR_FLAG") {
207+
actionTypeObject = createObject<LVGLClearFlagActionType>(
208+
project._store,
209+
Object.assign(
210+
actionTypeProperties,
211+
LVGLClearFlagActionType.classInfo.defaultValue
212+
),
213+
LVGLClearFlagActionType
214+
);
189215
} else if (result.values.action == "GROUP") {
190216
actionTypeObject = createObject<LVGLGroupActionType>(
191217
project._store,
@@ -1325,6 +1351,212 @@ registerClass("LVGLRemoveStyleActionType", LVGLRemoveStyleActionType);
13251351

13261352
////////////////////////////////////////////////////////////////////////////////
13271353

1354+
export class LVGLAddFlagActionType extends LVGLActionType {
1355+
target: string;
1356+
flag: keyof typeof LVGL_FLAG_CODES;
1357+
1358+
override makeEditable() {
1359+
super.makeEditable();
1360+
1361+
makeObservable(this, {
1362+
target: observable,
1363+
flag: observable
1364+
});
1365+
}
1366+
1367+
static classInfo = makeDerivedClassInfo(LVGLActionType.classInfo, {
1368+
properties: [
1369+
{
1370+
name: "target",
1371+
displayName: "Target",
1372+
type: PropertyType.Enum,
1373+
enumItems: (actionType: LVGLAddFlagActionType) => {
1374+
const lvglIdentifiers = ProjectEditor.getProjectStore(
1375+
actionType
1376+
).lvglIdentifiers.getIdentifiersVisibleFromFlow(
1377+
ProjectEditor.getFlow(actionType)
1378+
);
1379+
1380+
return lvglIdentifiers.map(lvglIdentifier => ({
1381+
id: lvglIdentifier.identifier,
1382+
label: lvglIdentifier.identifier
1383+
}));
1384+
}
1385+
},
1386+
{
1387+
name: "flag",
1388+
type: PropertyType.Enum,
1389+
enumItems: (actionType: LVGLAddFlagActionType) => {
1390+
return Object.keys(getLvglFlagCodes(actionType)).map(
1391+
flag => ({
1392+
id: flag,
1393+
label: flag
1394+
})
1395+
);
1396+
}
1397+
}
1398+
],
1399+
defaultValue: {},
1400+
listLabel: (action: LVGLAddFlagActionType, collapsed: boolean) => {
1401+
if (!collapsed) {
1402+
return "Add flag";
1403+
}
1404+
let singleItem =
1405+
(getParent(action) as LVGLActionType[]).length == 1;
1406+
if (singleItem) {
1407+
return (
1408+
<>
1409+
{action.flag} in {action.target}
1410+
</>
1411+
);
1412+
} else {
1413+
return (
1414+
<>
1415+
Add flag {action.flag} in {action.target}
1416+
</>
1417+
);
1418+
}
1419+
},
1420+
check: (object: LVGLAddFlagActionType, messages: IMessage[]) => {
1421+
const projectStore = ProjectEditor.getProjectStore(object);
1422+
1423+
if (object.target) {
1424+
const lvglIdentifier =
1425+
projectStore.lvglIdentifiers.getIdentifierByName(
1426+
ProjectEditor.getFlow(object),
1427+
object.target
1428+
);
1429+
1430+
if (lvglIdentifier == undefined) {
1431+
messages.push(propertyNotFoundMessage(object, "target"));
1432+
}
1433+
} else {
1434+
messages.push(propertyNotSetMessage(object, "target"));
1435+
}
1436+
}
1437+
});
1438+
1439+
override build(assets: Assets, dataBuffer: DataBuffer) {
1440+
// target
1441+
dataBuffer.writeInt32(
1442+
assets.projectStore.lvglIdentifiers.getIdentifierByName(
1443+
ProjectEditor.getFlow(this),
1444+
this.target
1445+
)?.index ?? -1
1446+
);
1447+
1448+
// flag
1449+
dataBuffer.writeUint32(getLvglFlagCodes(this)[this.flag] ?? 0);
1450+
}
1451+
}
1452+
1453+
registerClass("LVGLAddFlagActionType", LVGLAddFlagActionType);
1454+
1455+
////////////////////////////////////////////////////////////////////////////////
1456+
1457+
export class LVGLClearFlagActionType extends LVGLActionType {
1458+
target: string;
1459+
flag: keyof typeof LVGL_FLAG_CODES;
1460+
1461+
override makeEditable() {
1462+
super.makeEditable();
1463+
1464+
makeObservable(this, {
1465+
target: observable,
1466+
flag: observable
1467+
});
1468+
}
1469+
1470+
static classInfo = makeDerivedClassInfo(LVGLActionType.classInfo, {
1471+
properties: [
1472+
{
1473+
name: "target",
1474+
displayName: "Target",
1475+
type: PropertyType.Enum,
1476+
enumItems: (actionType: LVGLClearFlagActionType) => {
1477+
const lvglIdentifiers = ProjectEditor.getProjectStore(
1478+
actionType
1479+
).lvglIdentifiers.getIdentifiersVisibleFromFlow(
1480+
ProjectEditor.getFlow(actionType)
1481+
);
1482+
1483+
return lvglIdentifiers.map(lvglIdentifier => ({
1484+
id: lvglIdentifier.identifier,
1485+
label: lvglIdentifier.identifier
1486+
}));
1487+
}
1488+
},
1489+
{
1490+
name: "flag",
1491+
type: PropertyType.Enum,
1492+
enumItems: (actionType: LVGLClearFlagActionType) => {
1493+
return Object.keys(getLvglFlagCodes(actionType)).map(
1494+
flag => ({
1495+
id: flag,
1496+
label: flag
1497+
})
1498+
);
1499+
}
1500+
}
1501+
],
1502+
defaultValue: {},
1503+
listLabel: (action: LVGLClearFlagActionType, collapsed: boolean) => {
1504+
if (!collapsed) {
1505+
return "Clear flag";
1506+
}
1507+
let singleItem =
1508+
(getParent(action) as LVGLActionType[]).length == 1;
1509+
if (singleItem) {
1510+
return (
1511+
<>
1512+
{action.flag} in {action.target}
1513+
</>
1514+
);
1515+
} else {
1516+
return (
1517+
<>
1518+
Clear flag {action.flag} in {action.target}
1519+
</>
1520+
);
1521+
}
1522+
},
1523+
check: (object: LVGLClearFlagActionType, messages: IMessage[]) => {
1524+
const projectStore = ProjectEditor.getProjectStore(object);
1525+
1526+
if (object.target) {
1527+
const lvglIdentifier =
1528+
projectStore.lvglIdentifiers.getIdentifierByName(
1529+
ProjectEditor.getFlow(object),
1530+
object.target
1531+
);
1532+
1533+
if (lvglIdentifier == undefined) {
1534+
messages.push(propertyNotFoundMessage(object, "target"));
1535+
}
1536+
} else {
1537+
messages.push(propertyNotSetMessage(object, "target"));
1538+
}
1539+
}
1540+
});
1541+
1542+
override build(assets: Assets, dataBuffer: DataBuffer) {
1543+
// target
1544+
dataBuffer.writeInt32(
1545+
assets.projectStore.lvglIdentifiers.getIdentifierByName(
1546+
ProjectEditor.getFlow(this),
1547+
this.target
1548+
)?.index ?? -1
1549+
);
1550+
1551+
// flag
1552+
dataBuffer.writeUint32(getLvglFlagCodes(this)[this.flag] ?? 0);
1553+
}
1554+
}
1555+
1556+
registerClass("LVGLClearFlagActionType", LVGLClearFlagActionType);
1557+
1558+
////////////////////////////////////////////////////////////////////////////////
1559+
13281560
const GROUP_ACTIONS = {
13291561
SET_WRAP: 0,
13301562
FOCUS_OBJ: 1,

0 commit comments

Comments
 (0)