Skip to content

Commit 2c68e5a

Browse files
committed
improvements and bug fixes for the eez-gui and eez-gui-lite projects
1 parent f2b1b29 commit 2c68e5a

41 files changed

Lines changed: 821 additions & 384 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

installation/make-electron-builder-yml.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@ async function getExtraResource() {
1414
to: path.basename(extraResourcePath)
1515
}));
1616

17-
let eezframeworkAmalgamation = (
17+
let eezFrameworkAmalgamation = (
1818
await fs.promises.readdir("./resources/eez-framework-amalgamation")
1919
).map(file => ({
2020
from: "./resources/eez-framework-amalgamation/" + file,
2121
to: "eez-framework-amalgamation/" + file
2222
}));
2323

24+
let eezGuiLite = (
25+
await fs.promises.readdir("./resources/eez-gui-lite")
26+
).map(file => ({
27+
from: "./resources/eez-gui-lite/" + file,
28+
to: "eez-gui-lite/" + file
29+
}));
30+
2431
let dockerBuild = (
2532
await fs.promises.readdir("./resources/docker-build")
2633
).map(file => ({
@@ -30,7 +37,8 @@ async function getExtraResource() {
3037

3138
return [
3239
...extraResources,
33-
...eezframeworkAmalgamation,
40+
...eezFrameworkAmalgamation,
41+
...eezGuiLite,
3442
...dockerBuild,
3543
...[
3644
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"author": "Envox <eez@envox.hr>",
44
"description": "Cross-platform visual development tool and SCPI instrument controller",
55
"homepage": "https://www.envox.hr/eez/studio/studio-introduction.html",
6-
"version": "0.27.1",
6+
"version": "0.28.0",
77
"revision": "1",
88
"license": "GPL-3.0-only",
99
"repository": "https://github.com/eez-open/studio",

packages/eez-studio-shared/color.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,12 @@ export function strToColor16(colorStr: string) {
475475
return color16;
476476
}
477477

478+
export function strToColor32(colorStr: string) {
479+
const rgb = getColorRGB(colorStr);
480+
let color32 = (rgb.r | (rgb.g << 8) | (rgb.b << 16) | (Math.round(rgb.a * 255) << 24)) >>> 0;
481+
return color32;
482+
}
483+
478484
export function to16bitsColor(colorStr: string) {
479485
const parsed = getColorRGB(colorStr);
480486
const r = parsed.r & 0b11111000;

packages/eez-studio-types/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ export interface IWasmFlowRuntime {
766766
_setWidgetVisible(widgetPtr: number, isVisible: number): void;
767767
_setTextWidgetText(widgetPtr: number, textProp: number): void;
768768
_setButtonWidgetText(widgetPtr: number, textProp: number): void;
769+
_setButtonWidgetEnabled(widgetPtr: number, isEnabled: number): void;
770+
_setButtonWidgetDisabledStyle(widgetPtr: number, disabledStyle: number): void;
769771
_setSwitchWidgetChecked(widgetPtr: number, isCheckedProp: number): void;
770772

771773
// EEZ-GUI Lite — page rendering

packages/project-editor/build/assets.ts

Lines changed: 107 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ import type { AssetsMap } from "eez-studio-types";
9292
import { isDashboardProject } from "project-editor/project/project-type-traits";
9393
import type { LVGLStyle } from "project-editor/lvgl/style";
9494
import { BuildEezGuiLite } from "project-editor/eez-gui-lite/build";
95+
import { ColorFormat } from "project-editor/features/style/color-format";
9596

9697
export { DummyDataBuffer, DataBuffer } from "project-editor/build/data-buffer";
9798

@@ -101,6 +102,8 @@ export class Assets {
101102
projects: Project[];
102103

103104
globalVariables: Variable[];
105+
nativeGlobalVariables: Variable[];
106+
104107
actions: Action[];
105108
pages: (Page | undefined)[];
106109
styles: Style[];
@@ -343,6 +346,7 @@ export class Assets {
343346
// than native
344347
...nativeVariables
345348
];
349+
this.nativeGlobalVariables = nativeVariables;
346350

347351
//
348352
// actions
@@ -616,86 +620,111 @@ export class Assets {
616620
return this.getAssetIndex(object, propertyName, findPage, this.pages);
617621
}
618622

623+
styleCache: any;
624+
619625
doGetStyleIndex(
620626
project: Project,
621627
styleNameOrObject: string | Style
622628
): number {
623-
if (typeof styleNameOrObject === "string") {
624-
const styleName = styleNameOrObject;
629+
const find = () => {
630+
if (typeof styleNameOrObject === "string") {
631+
const styleName = styleNameOrObject;
632+
633+
for (let i = 0; i < this.styles.length; i++) {
634+
const style = this.styles[i];
635+
if (style && style.name == styleName) {
636+
return this.projectStore.masterProject ? -(i + 1) : i + 1;
637+
}
638+
}
625639

626-
for (let i = 0; i < this.styles.length; i++) {
627-
const style = this.styles[i];
628-
if (style && style.name == styleName) {
629-
return this.projectStore.masterProject ? -(i + 1) : i + 1;
640+
const style = findStyle(project, styleName);
641+
if (style) {
642+
if (style.id != undefined) {
643+
return style.id;
644+
}
645+
646+
const isMasterProjectStyle =
647+
this.projectStore.masterProject &&
648+
getProject(style) == this.projectStore.masterProject;
649+
if (isMasterProjectStyle) {
650+
this.projectStore.outputSectionsStore.write(
651+
Section.OUTPUT,
652+
MessageType.WARNING,
653+
`master project style without ID can not be used`,
654+
style
655+
);
656+
} else {
657+
this.styles.push(style);
658+
return this.projectStore.masterProject
659+
? -this.styles.length
660+
: this.styles.length;
661+
}
662+
}
663+
} else {
664+
const style = styleNameOrObject;
665+
666+
const parentStyle = style.parentStyle;
667+
if (parentStyle) {
668+
if (style.compareTo(parentStyle)) {
669+
if (style.id != undefined) {
670+
return style.id;
671+
}
672+
return this.doGetStyleIndex(project, parentStyle.name);
673+
}
630674
}
631-
}
632675

633-
const style = findStyle(project, styleName);
634-
if (style) {
635-
if (style.id != undefined) {
636-
return style.id;
676+
for (let i = 0; i < this.styles.length; i++) {
677+
const s = this.styles[i];
678+
if (s && style.compareTo(s)) {
679+
return this.projectStore.masterProject ? -(i + 1) : i + 1;
680+
}
637681
}
638682

639683
const isMasterProjectStyle =
640684
this.projectStore.masterProject &&
641685
getProject(style) == this.projectStore.masterProject;
642686
if (isMasterProjectStyle) {
643-
this.projectStore.outputSectionsStore.write(
644-
Section.OUTPUT,
645-
MessageType.WARNING,
646-
`master project style without ID can not be used`,
647-
style
648-
);
687+
if (style.id) {
688+
return style.id;
689+
} else {
690+
this.projectStore.outputSectionsStore.write(
691+
Section.OUTPUT,
692+
MessageType.WARNING,
693+
`master project style without ID can not be used`,
694+
style
695+
);
696+
}
649697
} else {
650698
this.styles.push(style);
651699
return this.projectStore.masterProject
652700
? -this.styles.length
653701
: this.styles.length;
654702
}
655703
}
656-
} else {
657-
const style = styleNameOrObject;
658704

659-
const parentStyle = style.parentStyle;
660-
if (parentStyle) {
661-
if (style.compareTo(parentStyle)) {
662-
if (style.id != undefined) {
663-
return style.id;
664-
}
665-
return this.doGetStyleIndex(project, parentStyle.name);
666-
}
667-
}
705+
return 0;
706+
}
668707

669-
for (let i = 0; i < this.styles.length; i++) {
670-
const s = this.styles[i];
671-
if (s && style.compareTo(s)) {
672-
return this.projectStore.masterProject ? -(i + 1) : i + 1;
673-
}
674-
}
708+
if (!this.styleCache) {
709+
this.styleCache = new Map();
710+
}
675711

676-
const isMasterProjectStyle =
677-
this.projectStore.masterProject &&
678-
getProject(style) == this.projectStore.masterProject;
679-
if (isMasterProjectStyle) {
680-
if (style.id) {
681-
return style.id;
682-
} else {
683-
this.projectStore.outputSectionsStore.write(
684-
Section.OUTPUT,
685-
MessageType.WARNING,
686-
`master project style without ID can not be used`,
687-
style
688-
);
689-
}
690-
} else {
691-
this.styles.push(style);
692-
return this.projectStore.masterProject
693-
? -this.styles.length
694-
: this.styles.length;
695-
}
712+
let projectMap = this.styleCache.get(project);
713+
if (!projectMap) {
714+
projectMap = new Map();
715+
this.styleCache.set(project, projectMap);
696716
}
697717

698-
return 0;
718+
let styleIndex = projectMap.get(styleNameOrObject);
719+
if (styleIndex != undefined) {
720+
return styleIndex;
721+
}
722+
723+
styleIndex = find();
724+
725+
projectMap.set(styleNameOrObject, styleIndex);
726+
727+
return styleIndex;
699728
}
700729

701730
getStyleIndex(object: any, propertyName: string): number {
@@ -851,6 +880,12 @@ export class Assets {
851880
| "borderColor"
852881
) {
853882
let color = getStyleProperty(style, propertyName, false);
883+
if (color != "transparent") {
884+
const colorFormat = ColorFormat.parse(color, this.projectStore.project);
885+
if (!colorFormat.isUsingThemeColor) {
886+
color = colorFormat.getHexString();
887+
}
888+
}
854889
return this.getColorIndexFromColorValue(color);
855890
}
856891

@@ -1095,6 +1130,15 @@ export class Assets {
10951130
flowState.flowWidgetDataIndexes.set(path, index);
10961131
flowState.flowWidgetFromDataIndex.set(index, widget);
10971132
}
1133+
1134+
if (this.projectStore.projectTypeTraits.isFirmware) {
1135+
let expression = getProperty(widget, propertyName).trim();
1136+
const globalVariableIndex = this.nativeGlobalVariables.findIndex(globalVariable => globalVariable.name == expression);
1137+
if (globalVariableIndex != -1) {
1138+
return globalVariableIndex + 1;
1139+
}
1140+
}
1141+
10981142
return -(index + 1);
10991143
}
11001144

@@ -1397,9 +1441,9 @@ function buildHeaderData(
13971441
dataBuffer.writeUint8Array(tag);
13981442

13991443
// projectMajorVersion
1400-
dataBuffer.writeUint8(3); // PROJECT MAJOR VERSION: 3
1444+
dataBuffer.writeUint8(3);
14011445
// projectMinorVersion
1402-
dataBuffer.writeUint8(0); // PROJECT MINOR VERSION: 0
1446+
dataBuffer.writeUint8(assets.projectStore.project.settings.general.colorBpp == "16" ? 0 : 1);
14031447

14041448
// assetsType
14051449
dataBuffer.writeUint8(assets.projectStore.projectTypeTraits.id);
@@ -1448,7 +1492,10 @@ function buildLanguages(assets: Assets, dataBuffer: DataBuffer) {
14481492
);
14491493
}
14501494

1451-
export async function buildGuiAssetsData(assets: Assets) {
1495+
export async function buildGuiAssetsData(
1496+
assets: Assets,
1497+
option: "check" | "buildAssets" | "buildFiles"
1498+
) {
14521499
const dataBuffer = new DataBuffer(assets.utf8Support);
14531500

14541501
// settings
@@ -1465,7 +1512,7 @@ export async function buildGuiAssetsData(assets: Assets) {
14651512
// fonts
14661513
await buildGuiFontsData(assets, dataBuffer);
14671514
// bitmaps
1468-
await buildGuiBitmapsData(assets, dataBuffer);
1515+
await buildGuiBitmapsData(assets, dataBuffer, option);
14691516
}
14701517
// colorsDefinition
14711518
buildGuiColors(assets, dataBuffer);
@@ -1657,7 +1704,7 @@ export async function buildAssets(
16571704
) {
16581705
// build all assets as single data chunk
16591706
const { uncompressedData, compressedData } = await buildGuiAssetsData(
1660-
assets
1707+
assets, option
16611708
);
16621709

16631710
if (option != "buildAssets") {

packages/project-editor/build/bitmaps.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ export function buildGuiBitmapsEnum(assets: Assets) {
1717
return `enum BitmapsEnum {\n${bitmaps.join(",\n")}\n};`;
1818
}
1919

20-
async function buildGuiBitmaps(assets: Assets) {
20+
async function buildGuiBitmaps(
21+
assets: Assets,
22+
option: "check" | "buildAssets" | "buildFiles"
23+
) {
2124
if (assets.bitmaps.length === 0) {
2225
return null;
2326
}
@@ -30,10 +33,23 @@ async function buildGuiBitmaps(assets: Assets) {
3033
pixels: Uint8Array;
3134
}[] = [];
3235

33-
Promise.all(assets.bitmaps.map(bitmap => getBitmapDataAsync(bitmap)));
36+
const bitmapColorFormat =
37+
option == "buildAssets"
38+
? "RGB"
39+
: assets.projectStore.project.settings.general.bitmapColorFormat;
40+
41+
Promise.all(
42+
assets.bitmaps.map(bitmap =>
43+
getBitmapDataAsync(bitmap, undefined, bitmapColorFormat)
44+
)
45+
);
3446

3547
for (let i = 0; i < assets.bitmaps.length; i++) {
36-
const bitmapsData = await getBitmapDataAsync(assets.bitmaps[i]);
48+
const bitmapsData = await getBitmapDataAsync(
49+
assets.bitmaps[i],
50+
undefined,
51+
bitmapColorFormat
52+
);
3753

3854
bitmaps.push({
3955
name: assets.bitmaps[i].name,
@@ -49,9 +65,10 @@ async function buildGuiBitmaps(assets: Assets) {
4965

5066
export async function buildGuiBitmapsData(
5167
assets: Assets,
52-
dataBuffer: DataBuffer
68+
dataBuffer: DataBuffer,
69+
option: "check" | "buildAssets" | "buildFiles"
5370
) {
54-
const bitmaps = await buildGuiBitmaps(assets);
71+
const bitmaps = await buildGuiBitmaps(assets, option);
5572

5673
dataBuffer.writeArray(bitmaps || [], bitmap => {
5774
dataBuffer.writeInt16(bitmap.width);

packages/project-editor/build/themes.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { strToColor16 } from "eez-studio-shared/color";
1+
import { strToColor16, strToColor32 } from "eez-studio-shared/color";
22
import { TAB, NamingConvention, getName } from "project-editor/build/helper";
33
import {
44
Theme,
@@ -46,7 +46,11 @@ export function buildGuiColorsEnum(assets: Assets) {
4646

4747
export function buildGuiColors(assets: Assets, dataBuffer: DataBuffer) {
4848
function buildColor(color: string) {
49-
dataBuffer.writeUint16(strToColor16(color));
49+
if (assets.projectStore.project.settings.general.colorBpp == "16") {
50+
dataBuffer.writeUint16(strToColor16(color));
51+
} else {
52+
dataBuffer.writeUint32(strToColor32(color));
53+
}
5054
}
5155

5256
function buildTheme(theme: Theme) {

0 commit comments

Comments
 (0)