Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/eez-open/studio
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Oct 17, 2024
2 parents adb4ddc + 46ba3f4 commit f07d4f2
Show file tree
Hide file tree
Showing 15 changed files with 163 additions and 108 deletions.
4 changes: 2 additions & 2 deletions packages/project-editor/features/page/PageEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { computed, runInAction, makeObservable } from "mobx";
import { computed, runInAction, makeObservable, observable } from "mobx";
import { observer } from "mobx-react";
import { IEezObject } from "project-editor/core/object";
import { TreeObjectAdapter } from "project-editor/core/objectAdapter";
Expand Down Expand Up @@ -96,7 +96,7 @@ export class PageTabState extends FlowTabState {
super(object as Flow);

makeObservable(this, {
//_transform: observable,
_transform: observable,
transform: computed,
frontFace: computed
});
Expand Down
24 changes: 12 additions & 12 deletions packages/project-editor/features/page/PagesNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const PageStructure = observer(
);
}

onLockAll = () => {
onLockAll = action(() => {
if (!this.treeAdapter) {
return;
}
Expand All @@ -202,9 +202,9 @@ export const PageStructure = observer(
});

this.context.undoManager.setCombineCommands(false);
};
});

onUnlockAll = () => {
onUnlockAll = action(() => {
if (!this.treeAdapter) {
return;
}
Expand All @@ -221,7 +221,7 @@ export const PageStructure = observer(
});

this.context.undoManager.setCombineCommands(false);
};
});

get isAnyHidden() {
if (!this.treeAdapter) {
Expand All @@ -236,7 +236,7 @@ export const PageStructure = observer(
);
}

onHideAll = () => {
onHideAll = action(() => {
if (!this.treeAdapter) {
return;
}
Expand All @@ -253,9 +253,9 @@ export const PageStructure = observer(
});

this.context.undoManager.setCombineCommands(false);
};
});

onShowAll = () => {
onShowAll = action(() => {
if (!this.treeAdapter) {
return;
}
Expand All @@ -272,7 +272,7 @@ export const PageStructure = observer(
});

this.context.undoManager.setCombineCommands(false);
};
});

renderItem = (itemId: string) => {
if (!this.treeAdapter) {
Expand Down Expand Up @@ -302,11 +302,11 @@ export const PageStructure = observer(
: "Lock this widget"
}
iconSize={14}
onClick={() =>
onClick={action(() =>
this.context.updateObject(widget, {
locked: !widget.locked
})
}
)}
style={{
visibility: widget.locked ? "visible" : "hidden"
}}
Expand All @@ -319,7 +319,7 @@ export const PageStructure = observer(
}
title={widget.hiddenInEditor ? "Show" : "Hide"}
iconSize={14}
onClick={() => {
onClick={action(() => {
const hiddenInEditor = !widget.hiddenInEditor;

this.context.undoManager.setCombineCommands(
Expand Down Expand Up @@ -349,7 +349,7 @@ export const PageStructure = observer(
this.context.undoManager.setCombineCommands(
false
);
}}
})}
style={{
visibility: widget.hiddenInEditor
? "visible"
Expand Down
8 changes: 0 additions & 8 deletions packages/project-editor/features/page/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -999,10 +999,6 @@ export class Page extends Flow {
customWidget
);

this._lvglWidgetsIncludingUserWidgets.forEach(lvglWidget =>
lvglWidget.lvglPostCreate(runtime)
);

return lvglObj;
} else {
const obj = customWidget
Expand All @@ -1027,10 +1023,6 @@ export class Page extends Flow {
.filter(component => component instanceof Widget)
.map((widget: Widget) => widget.lvglCreate(runtime, obj));

this._lvglWidgetsIncludingUserWidgets.forEach(lvglWidget =>
lvglWidget.lvglPostCreate(runtime)
);

return obj;
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/project-editor/features/style/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,8 @@ export class Style extends EezObject {

cssDeclarations: computed,
cssPreview: computed,
classNames: computed
classNames: computed,
dynamicCSS: observable
});
}

Expand Down
2 changes: 0 additions & 2 deletions packages/project-editor/flow/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3897,8 +3897,6 @@ export class Widget extends Component {
) {
return 0;
}

lvglPostCreate(runtime: LVGLPageRuntime) {}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ export class TextDashboardWidget extends Widget {
<span
className={classNames(
this.style.classNames,
this.style.getConditionalClassNames(flowContext)
this.style.getConditionalClassNames(flowContext),
this.style.getDynamicCSSClassName(flowContext)
)}
onClick={this.onClick(flowContext)}
style={{ opacity: style.opacity }}
Expand Down Expand Up @@ -828,7 +829,8 @@ export class NumberInputDashboardWidget extends Widget {
<NumberInputDashboardWidgetElement
className={classNames(
this.style.classNames,
this.style.getConditionalClassNames(flowContext)
this.style.getConditionalClassNames(flowContext),
this.style.getDynamicCSSClassName(flowContext)
)}
component={this}
flowContext={flowContext}
Expand Down Expand Up @@ -975,7 +977,8 @@ export class CheckboxWidget extends Widget {
className={classNames(
"form-check",
this.style.classNames,
this.style.getConditionalClassNames(flowContext)
this.style.getConditionalClassNames(flowContext),
this.style.getDynamicCSSClassName(flowContext)
)}
style={{ opacity: style.opacity }}
>
Expand Down Expand Up @@ -1154,7 +1157,8 @@ export class RadioWidget extends Widget {
className={classNames(
"form-check",
this.style.classNames,
this.style.getConditionalClassNames(flowContext)
this.style.getConditionalClassNames(flowContext),
this.style.getDynamicCSSClassName(flowContext)
)}
style={{ opacity: style.opacity }}
>
Expand Down Expand Up @@ -1300,7 +1304,8 @@ export class SwitchDashboardWidget extends Widget {
className={classNames(
"form-check form-switch",
this.style.classNames,
this.style.getConditionalClassNames(flowContext)
this.style.getConditionalClassNames(flowContext),
this.style.getDynamicCSSClassName(flowContext)
)}
style={{ opacity: style.opacity }}
>
Expand Down Expand Up @@ -1993,7 +1998,8 @@ export class ButtonDashboardWidget extends Widget {
<button
className={classNames(
buttonStyle.classNames,
this.style.getConditionalClassNames(flowContext)
this.style.getConditionalClassNames(flowContext),
this.style.getDynamicCSSClassName(flowContext)
)}
style={{ opacity: style.opacity }}
disabled={!buttonEnabled}
Expand Down Expand Up @@ -2327,6 +2333,9 @@ const SliderDashboardWidgetElement = observer(
this.props.component.style.classNames,
this.props.component.style.getConditionalClassNames(
flowContext
),
this.props.component.style.getDynamicCSSClassName(
flowContext
)
)}
type="range"
Expand Down
24 changes: 19 additions & 5 deletions packages/project-editor/lvgl/page-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,20 @@ export abstract class LVGLPageRuntime {
}

registerGroupWidget(group: string, groupIndex: number, obj: number) {}

//
postCreateCallbacks: (() => void)[] = [];

addPostCreateCallback(callback: () => void) {
this.postCreateCallbacks.push(callback);
}

lvglCreatePage() {
const pageObj = this.page.lvglCreate(this, 0);
this.postCreateCallbacks.forEach(callback => callback());
this.postCreateCallbacks = [];
return pageObj;
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -596,7 +610,7 @@ export class LVGLPageEditorRuntime extends LVGLPageRuntime {

this.createStyles();

const pageObj = this.page.lvglCreate(this, 0);
const pageObj = this.lvglCreatePage();
if (!pageObj) {
console.error("pageObj is undefined");
}
Expand Down Expand Up @@ -776,7 +790,7 @@ export class LVGLNonActivePageViewerRuntime extends LVGLPageRuntime {

this.createStyles();

const pageObj = this.page.lvglCreate(this, 0);
const pageObj = this.lvglCreatePage();
this.wasm._lvglScreenLoad(-1, pageObj);
runInAction(() => {
this.page._lvglRuntime = this;
Expand Down Expand Up @@ -1062,7 +1076,7 @@ export class LVGLPageViewerRuntime extends LVGLPageRuntime {

this.createStyles();

const pageObj = this.page.lvglCreate(this, 0);
const pageObj = this.lvglCreatePage();
this.pageStates.get(this.page)!.pageObj = pageObj;

this.wasm._lvglAddScreenLoadedEventHandler(pageObj);
Expand Down Expand Up @@ -1360,7 +1374,7 @@ export class LVGLStylesEditorRuntime extends LVGLPageRuntime {
}
});

const pageObj = this.page.lvglCreate(this, 0);
const pageObj = this.lvglCreatePage();
if (!pageObj) {
console.error("pageObj is undefined");
return;
Expand Down Expand Up @@ -1574,7 +1588,7 @@ export class LVGLReflectEditorRuntime extends LVGLPageRuntime {
-(new Date().getTimezoneOffset() / 60) * 100
);

const pageObj = this.page.lvglCreate(this, 0);
const pageObj = this.lvglCreatePage();
if (!pageObj) {
console.error("pageObj is undefined");
return;
Expand Down
24 changes: 12 additions & 12 deletions packages/project-editor/lvgl/style-catalog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,9 @@ const grid_column_align_property_info: LVGLPropertyInfo = makeEnumPropertyInfo(
CENTER: LV_GRID_ALIGN_CENTER,
END: LV_GRID_ALIGN_END,
STRETCH: LV_GRID_ALIGN_STRETCH,
EVENLY: LV_GRID_ALIGN_SPACE_EVENLY,
AROUND: LV_GRID_ALIGN_SPACE_AROUND,
BETWEEN: LV_GRID_ALIGN_SPACE_BETWEEN
SPACE_EVENLY: LV_GRID_ALIGN_SPACE_EVENLY,
SPACE_AROUND: LV_GRID_ALIGN_SPACE_AROUND,
SPACE_BETWEEN: LV_GRID_ALIGN_SPACE_BETWEEN
},
"LV_GRID_ALIGN_"
);
Expand All @@ -683,9 +683,9 @@ const grid_row_align_property_info: LVGLPropertyInfo = makeEnumPropertyInfo(
CENTER: LV_GRID_ALIGN_CENTER,
END: LV_GRID_ALIGN_END,
STRETCH: LV_GRID_ALIGN_STRETCH,
EVENLY: LV_GRID_ALIGN_SPACE_EVENLY,
AROUND: LV_GRID_ALIGN_SPACE_AROUND,
BETWEEN: LV_GRID_ALIGN_SPACE_BETWEEN
SPACE_EVENLY: LV_GRID_ALIGN_SPACE_EVENLY,
SPACE_AROUND: LV_GRID_ALIGN_SPACE_AROUND,
SPACE_BETWEEN: LV_GRID_ALIGN_SPACE_BETWEEN
},
"LV_GRID_ALIGN_"
);
Expand Down Expand Up @@ -803,9 +803,9 @@ const grid_cell_x_align_property_info: LVGLPropertyInfo = makeEnumPropertyInfo(
CENTER: LV_GRID_ALIGN_CENTER,
END: LV_GRID_ALIGN_END,
STRETCH: LV_GRID_ALIGN_STRETCH,
EVENLY: LV_GRID_ALIGN_SPACE_EVENLY,
AROUND: LV_GRID_ALIGN_SPACE_AROUND,
BETWEEN: LV_GRID_ALIGN_SPACE_BETWEEN
SPACE_EVENLY: LV_GRID_ALIGN_SPACE_EVENLY,
SPACE_AROUND: LV_GRID_ALIGN_SPACE_AROUND,
SPACE_BETWEEN: LV_GRID_ALIGN_SPACE_BETWEEN
},
"LV_GRID_ALIGN_"
);
Expand Down Expand Up @@ -857,9 +857,9 @@ const grid_cell_y_align_property_info: LVGLPropertyInfo = makeEnumPropertyInfo(
CENTER: LV_GRID_ALIGN_CENTER,
END: LV_GRID_ALIGN_END,
STRETCH: LV_GRID_ALIGN_STRETCH,
EVENLY: LV_GRID_ALIGN_SPACE_EVENLY,
AROUND: LV_GRID_ALIGN_SPACE_AROUND,
BETWEEN: LV_GRID_ALIGN_SPACE_BETWEEN
SPACE_EVENLY: LV_GRID_ALIGN_SPACE_EVENLY,
SPACE_AROUND: LV_GRID_ALIGN_SPACE_AROUND,
SPACE_BETWEEN: LV_GRID_ALIGN_SPACE_BETWEEN
},
"LV_GRID_ALIGN_"
);
Expand Down
35 changes: 34 additions & 1 deletion packages/project-editor/lvgl/style-definition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,40 @@ export class LVGLStylesDefinition extends EezObject {
}
}
],
defaultValue: {}
defaultValue: {},

beforeLoadHook(object, jsObject) {
if (jsObject.definition) {
Object.keys(jsObject.definition).forEach(part => {
Object.keys(jsObject.definition[part]).forEach(state => {
Object.keys(jsObject.definition[part][state]).forEach(
propertyName => {
if (
propertyName == "grid_column_align" ||
propertyName == "grid_row_align" ||
propertyName == "grid_cell_x_align" ||
propertyName == "grid_cell_y_align"
) {
const value =
jsObject.definition[part][state][
propertyName
];
if (
value == "EVENLY" ||
value == "AROUND" ||
value == "BETWEEN"
) {
jsObject.definition[part][state][
propertyName
] = "SPACE_" + value;
}
}
}
);
});
});
}
}
};

override makeEditable() {
Expand Down
Loading

0 comments on commit f07d4f2

Please sign in to comment.