Skip to content

Commit

Permalink
add id to page, variable, action, bitmap and color
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Mar 15, 2022
1 parent 1185039 commit bc0c73a
Show file tree
Hide file tree
Showing 57 changed files with 9,017 additions and 2,238 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ circular.txt
!resources/project-templates/*.eez-project-ui-state

packages/project-editor/flow/runtime/cpp/build
!packages/project-editor/flow/runtime/flow_runtime.js
!packages/project-editor/flow/runtime/cpp/src/platform/simulator/emscripten/pre.js
17 changes: 15 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@
"configurations": [
{
"name": "Win32",
"includePath": [],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"includePath": [
"./packages/project-editor/flow/runtime/cpp",
"./packages/project-editor/flow/runtime/cpp/src",
"./packages/project-editor/flow/runtime/cpp/src/conf",
"./packages/project-editor/flow/runtime/cpp/eez/platform/simulator",
"./packages/project-editor/flow/runtime/cpp/eez/libs/agg"
],
"defines": [
"DEBUG",
"OPTION_DISPLAY",
"EEZ_PLATFORM_SIMULATOR",
"__EMSCRIPTEN__",
"OPTION_ENCODER",
"OPTION_ETHERNET"
],
"windowsSdkVersion": "10.0.17134.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
Expand Down
8 changes: 2 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,12 @@ gulp.task("copy", function () {
return gulp
.src([
SRC + "/**/*.*",
"!" + SRC + "/project-editor/flow/runtime/cpp/**/*.*",
"!" + SRC + "/**/*.ts",
"!" + SRC + "/**/*.tsx",
"!" + SRC + "/**/*.less",
"!" + SRC + "/tsconfig.json",
"!" + SRC + "/tsconfig.dev.json",
// SRC folder must not contain *.js or *.js.map anymore,
// we add these two just in case there is some remains from
// the past when *.js is outputed in SRC folder
"!" + SRC + "/**/*.js",
"!" + SRC + "/**/*.js.map"
"!" + SRC + "/tsconfig.dev.json"
])
.pipe(gulp.dest(DST));
});
Expand Down
12 changes: 0 additions & 12 deletions packages/eez-studio-shared/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,3 @@ declare class GoldenLayout {
}

declare module "xml-formatter";

declare const WasmFlowRuntime: {
HEAPU8: Uint8Array;
_malloc(size: number): number;
_free(ptr: number): void;

_mainLoop();
_getSyncedBuffer(): number;
_onMouseWheelEvent(wheelDeltaY: number, wheelClicked: number);
_onPointerEvent(x: number, y: number, pressed: number);
_loadAssets(assets: number, assetsSize: number);
};
14 changes: 14 additions & 0 deletions packages/eez-studio-shared/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ export const validators = {
unique: (origObject: any, collection: any, message?: string) => {
return function (object: any, ruleName: string) {
const value = object[ruleName];
if (value == undefined) {
return null;
}
if (
collection.find(
(element: any) =>
Expand All @@ -110,6 +113,17 @@ export const validators = {
return null;
},

optionalInteger: (object: any, ruleName: string) => {
if (object[ruleName] == undefined) {
return null;
}
let value = filterInteger(object[ruleName]);
if (isNaN(value) || typeof value !== "number") {
return VALIDATION_MESSAGE_INVALID_VALUE;
}
return null;
},

unit: (unit: keyof typeof UNITS) => {
return function (object: any, ruleName: string) {
let value = UNITS[unit].parseValue(object[ruleName]);
Expand Down
15 changes: 14 additions & 1 deletion packages/eez-studio-ui/generic-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface IFieldProperties {
displayName?: string;
type?:
| "integer"
| "optional-integer"
| "number"
| "string"
| "password"
Expand Down Expand Up @@ -223,6 +224,13 @@ export const GenericDialog = observer(
values[fieldProperties.name] = parseInt(
this.fieldValues[fieldProperties.name]
);
} else if (fieldProperties.type === "optional-integer") {
const value = this.fieldValues[fieldProperties.name].trim();
if (value) {
values[fieldProperties.name] = parseInt(value);
} else {
values[fieldProperties.name] = undefined;
}
} else if (fieldProperties.type === "number") {
values[fieldProperties.name] = parseFloat(
this.fieldValues[fieldProperties.name]
Expand Down Expand Up @@ -323,6 +331,10 @@ export const GenericDialog = observer(
fieldValidators = fieldValidators.concat([
validators.integer
]);
} else if (fieldProperties.type === "optional-integer") {
fieldValidators = fieldValidators.concat([
validators.optionalInteger
]);
}

if (fieldProperties.unit) {
Expand All @@ -339,7 +351,7 @@ export const GenericDialog = observer(

fieldValidators.forEach(validator => {
let message = validator(
this.fieldValues,
this.values,
fieldProperties.name
);
if (message) {
Expand Down Expand Up @@ -428,6 +440,7 @@ export const GenericDialog = observer(

if (
fieldProperties.type === "integer" ||
fieldProperties.type === "optional-integer" ||
fieldProperties.type === "number" ||
fieldProperties.type === "string" ||
!fieldProperties.type ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
import type { BuildResult } from "project-editor/core/extensions";

import type {
Project,
BuildConfiguration
} from "project-editor/project/project";
import * as projectBuild from "project-editor/project/build";
import { TAB, NamingConvention, getName } from "project-editor/build/helper";

import type { Action } from "project-editor/features/action/action";
import type { Assets, DataBuffer } from "project-editor/build/assets";

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

function buildActionsEnum(projectActions: Action[]) {
let actions = projectActions.map(
(action, i) =>
`${projectBuild.TAB}${projectBuild.getName(
`${TAB}${getName(
"ACTION_ID_",
action,
projectBuild.NamingConvention.UnderscoreUpperCase
NamingConvention.UnderscoreUpperCase
)} = ${i + 1}`
);

actions.unshift(`${projectBuild.TAB}ACTION_ID_NONE = 0`);
actions.unshift(`${TAB}ACTION_ID_NONE = 0`);

return `enum ActionsEnum {\n${actions.join(",\n")}\n};`;
}

function buildActionsFuncsDecl(projectActions: Action[]) {
let actions = projectActions.map(action => {
return `void ${projectBuild.getName(
return `void ${getName(
"action_",
action,
projectBuild.NamingConvention.UnderscoreLowerCase
NamingConvention.UnderscoreLowerCase
)}();`;
});

Expand All @@ -45,16 +42,16 @@ function buildActionsFuncsDef(projectActions: Action[]) {
implementationCode = implementationCode
.trim()
.split("\n")
.map(line => projectBuild.TAB + line)
.map(line => TAB + line)
.join("\n");
} else {
implementationCode = "";
}

return `void ${projectBuild.getName(
return `void ${getName(
"action_",
action,
projectBuild.NamingConvention.UnderscoreLowerCase
NamingConvention.UnderscoreLowerCase
)}() {\n${implementationCode}\n}\n`;
});

Expand All @@ -68,47 +65,28 @@ function buildActionsArrayDecl() {
function buildActionsArrayDef(projectActions: Action[]) {
let actions = projectActions.map(
action =>
`${projectBuild.TAB}${projectBuild.getName(
`${TAB}${getName(
"action_",
action,
projectBuild.NamingConvention.UnderscoreLowerCase
NamingConvention.UnderscoreLowerCase
)}`
);

return `ActionExecFunc g_actionExecFunctions[] = {\n${
projectBuild.TAB
}0,\n${actions.join(",\n")}\n};`;
return `ActionExecFunc g_actionExecFunctions[] = {\n${TAB}0,\n${actions.join(
",\n"
)}\n};`;
}

export function build(
project: Project,
sectionNames: string[] | undefined,
buildConfiguration: BuildConfiguration | undefined
export function buildActions(
assets: Assets,
sectionNames: string[] | undefined
): Promise<BuildResult> {
return new Promise((resolve, reject) => {
const result: any = {};

let projectActions = project.actions.filter(
action =>
!buildConfiguration ||
!action.usedIn ||
action.usedIn.indexOf(buildConfiguration.name) !== -1
);
for (const importDirective of project.settings.general.imports) {
if (importDirective.project) {
projectActions.push(
...importDirective.project.actions.filter(
action =>
!buildConfiguration ||
!action.usedIn ||
action.usedIn.indexOf(buildConfiguration.name) !==
-1
)
);
}
}
let projectActions = assets.actions;

if (project.isFirmwareWithFlowSupportProject) {
if (assets.DocumentStore.project.isFirmwareWithFlowSupportProject) {
// only native
projectActions = projectActions.filter(
action => action.implementationType == "native"
Expand Down Expand Up @@ -144,3 +122,12 @@ export function build(
resolve(result);
});
}

export function buildActionNames(assets: Assets, dataBuffer: DataBuffer) {
dataBuffer.writeArray(
assets.DocumentStore.masterProject ? assets.actions : [],
action => {
dataBuffer.writeString(action.name);
}
);
}
Loading

0 comments on commit bc0c73a

Please sign in to comment.