Skip to content

Commit

Permalink
fix lvgl copy styles in paste with dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Nov 14, 2024
1 parent 555f423 commit 3c9e895
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/project-editor/store/paste-with-dependencies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import {
import { VALIDATION_MESSAGE_REQUIRED } from "eez-studio-shared/validation";
import { validators as validatorsRenderer } from "eez-studio-shared/validation-renderer";
import type { Style } from "project-editor/features/style/style";
import type { LVGLStyle } from "project-editor/lvgl/style";
import { LVGLStyle } from "project-editor/lvgl/style";
import {
type Theme,
type Color,
Expand Down Expand Up @@ -168,8 +168,16 @@ class PasteObject {
styleLevel: number = 0;

get destinationStyle(): CommonStyle | undefined {
let collection;
if (this.object instanceof LVGLStyle) {
collection =
this.model.destinationProjectStore.project.lvglStyles.styles;
} else {
collection = this.model.destinationProjectStore.project.styles;
}

if (this.styleLevel == 0) {
return this.model.destinationProjectStore.project.styles.find(
return collection.find(
destinationObject =>
destinationObject.name == (this.object as any).name
);
Expand Down Expand Up @@ -399,7 +407,7 @@ class PasteWithDependenciesModel {
} else if (object instanceof ProjectEditor.StyleClass) {
addObject(projectStore.project.styles, object);
} else if (object instanceof ProjectEditor.LVGLStyleClass) {
addObject(projectStore.project.lvglStyles, object);
addObject(projectStore.project.lvglStyles.styles, object);
} else if (object instanceof ProjectEditor.BitmapClass) {
addObject(projectStore.project.bitmaps, object);
} else if (object instanceof ProjectEditor.FontClass) {
Expand Down Expand Up @@ -1352,7 +1360,8 @@ class PasteWithDependenciesModel {
} else if (object instanceof ProjectEditor.LVGLStyleClass) {
if (pasteObject.styleLevel == 0) {
collection =
this.destinationProjectStore.project.lvglStyles;
this.destinationProjectStore.project.lvglStyles
.styles;
}
} else if (object instanceof ProjectEditor.BitmapClass) {
collection = this.destinationProjectStore.project.bitmaps;
Expand Down

0 comments on commit 3c9e895

Please sign in to comment.