Skip to content

Commit a4e6116

Browse files
committedDec 6, 2024
display [NATIVE] as badge
1 parent 58c61d6 commit a4e6116

File tree

13 files changed

+102
-62
lines changed

13 files changed

+102
-62
lines changed
 

‎packages/eez-studio-ui/_stylesheets/project-editor.less

+21
Original file line numberDiff line numberDiff line change
@@ -506,13 +506,20 @@
506506
white-space: nowrap;
507507
text-overflow: ellipsis;
508508

509+
display: flex;
510+
align-items: center;
511+
509512
& > img,
510513
& > svg {
511514
flex-shrink: 0;
512515
height: 20px;
513516
object-fit: contain;
514517
margin-right: 4px;
515518
}
519+
520+
& > i.material-icons {
521+
margin-right: 4px;
522+
}
516523
}
517524

518525
.EezStudio_PropertiesPanel_Body {
@@ -3803,3 +3810,17 @@
38033810
}
38043811
}
38053812
}
3813+
3814+
.EezStudio_ListLabel_Badge {
3815+
margin-left: 8px;
3816+
transform: translateY(-1px);
3817+
3818+
display: inline-block;
3819+
padding: 0px 5px;
3820+
font-size: 80%;
3821+
font-weight: bold;
3822+
color: rgb(238, 238, 238);
3823+
background-color: var(--bs-secondary);
3824+
white-space: nowrap;
3825+
border-radius: var(--bs-border-radius);
3826+
}

‎packages/project-editor/core/object.ts

+19-10
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,19 @@ import { observable, makeObservable } from "mobx";
33

44
import { humanize } from "eez-studio-shared/string";
55
import { Rect } from "eez-studio-shared/geometry";
6+
import { isArray, objectClone } from "eez-studio-shared/util";
67

78
import type { IDashboardComponentContext } from "eez-studio-types";
89

9-
import {
10+
import type { IResizeHandler } from "project-editor/flow/flow-interfaces";
11+
import type { ValueType } from "project-editor/features/variable/value-type";
12+
import type { Project } from "project-editor/project/project";
13+
import type {
1014
ProjectStore,
1115
IContextMenuContext,
12-
getClassInfo,
1316
EezValueObject
1417
} from "project-editor/store";
1518

16-
import type { IResizeHandler } from "project-editor/flow/flow-interfaces";
17-
18-
import type { ValueType } from "project-editor/features/variable/value-type";
19-
import type { Project } from "project-editor/project/project";
20-
21-
import { isArray, objectClone } from "eez-studio-shared/util";
22-
import { LVGLParts } from "project-editor/lvgl/lvgl-constants";
23-
2419
////////////////////////////////////////////////////////////////////////////////
2520

2621
export const enum PropertyType {
@@ -323,6 +318,8 @@ export interface SerializedData {
323318
objectsParentPath?: string[];
324319
}
325320

321+
export type LVGLParts = string;
322+
326323
interface LVGLClassInfoProperties {
327324
parts: LVGLParts[] | ((object: IEezObject) => LVGLParts[]);
328325
defaultFlags: string;
@@ -643,6 +640,18 @@ export function isEezObject(object: any): object is IEezObject {
643640

644641
////////////////////////////////////////////////////////////////////////////////
645642

643+
export function getClass(object: IEezObject) {
644+
if (isArray(object)) {
645+
return getPropertyInfo(object).typeClass!;
646+
} else {
647+
return object.constructor as EezClass;
648+
}
649+
}
650+
651+
export function getClassInfo(object: IEezObject): ClassInfo {
652+
return getClass(object).classInfo;
653+
}
654+
646655
export function findClass(className: string) {
647656
return classNameToEezClassMap.get(className);
648657
}

‎packages/project-editor/features/action/action.tsx

+15-7
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,22 @@ export class Action extends Flow {
273273
);
274274
},
275275
label: (action: Action) => {
276-
const projectStore = getProjectStore(action);
277-
if (
278-
projectStore.projectTypeTraits.hasFlowSupport &&
279-
action.implementationType == "native"
280-
) {
281-
return "[NATIVE] " + action.name;
282-
}
283276
return action.name;
284277
},
278+
listLabel: (action: Action) => {
279+
const projectStore = getProjectStore(action);
280+
return (
281+
<>
282+
<span>{action.name}</span>
283+
{projectStore.projectTypeTraits.hasFlowSupport &&
284+
action.implementationType == "native" && (
285+
<span className="EezStudio_ListLabel_Badge">
286+
NATIVE
287+
</span>
288+
)}
289+
</>
290+
);
291+
},
285292
beforeLoadHook: (action: Action, jsObject: any) => {
286293
if (jsObject.page) {
287294
jsObject.components = jsObject.page.components;
@@ -351,6 +358,7 @@ export class Action extends Flow {
351358

352359
return action;
353360
},
361+
354362
icon: "material:code"
355363
});
356364

‎packages/project-editor/features/variable/variable.tsx

+18-6
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ export class Variable extends EezObject {
423423
variable
424424
).projectTypeTraits.isVariableTypeSupportedAsNative(
425425
variable.type
426-
)
426+
),
427+
checkboxStyleSwitch: true
427428
},
428429
{
429430
name: "nativeImplementationInfo",
@@ -490,13 +491,24 @@ export class Variable extends EezObject {
490491

491492
return (
492493
<>
493-
{projectStore.projectTypeTraits.hasFlowSupport &&
494-
variable.native && <span>[NATIVE] </span>}
495-
{variable.persistent && <span>[PERSISTENT] </span>}
496-
<span>{variable.name} </span>
497-
<em className="font-monospace" style={{ opacity: 0.5 }}>
494+
<span>{variable.name}</span>
495+
<em
496+
className="font-monospace"
497+
style={{ opacity: 0.5, marginLeft: 8 }}
498+
>
498499
{variable.type}
499500
</em>
501+
{projectStore.projectTypeTraits.hasFlowSupport &&
502+
variable.native && (
503+
<span className="EezStudio_ListLabel_Badge">
504+
NATIVE
505+
</span>
506+
)}
507+
{variable.persistent && (
508+
<span className="EezStudio_ListLabel_Badge">
509+
PERSISTENT
510+
</span>
511+
)}
500512
</>
501513
);
502514
},

‎packages/project-editor/lvgl/LVGLStylesDefinitionProperty.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
getClassInfoLvglParts,
99
IEezObject,
1010
PropertyInfo,
11-
PropertyProps
11+
PropertyProps,
12+
LVGLParts
1213
} from "project-editor/core/object";
1314
import type { Page } from "project-editor/features/page/page";
1415
import { ProjectEditor } from "project-editor/project-editor-interface";
@@ -31,10 +32,7 @@ import {
3132
} from "project-editor/lvgl/page-runtime";
3233
import { ITreeNode, Tree } from "eez-studio-ui/tree";
3334
import { Checkbox } from "project-editor/ui-components/PropertyGrid/Checkbox";
34-
import {
35-
LVGL_STYLE_STATES,
36-
LVGLParts
37-
} from "project-editor/lvgl/lvgl-constants";
35+
import { LVGL_STYLE_STATES } from "project-editor/lvgl/lvgl-constants";
3836

3937
type TreeNodeData =
4038
| {

‎packages/project-editor/lvgl/lvgl-constants.ts

-2
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,6 @@ export const LVGL_PARTS_9: { [key: string]: number } = {
403403
ANY: 0x0f0000 // LV_PART_ANY Special value can be used in some functions to target all parts
404404
};
405405

406-
export type LVGLParts = string;
407-
408406
////////////////////////////////////////////////////////////////////////////////
409407

410408
export const LV_EVENT_CHECKED = 0x7e;

‎packages/project-editor/lvgl/style-helper.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { IEezObject, PropertyType } from "project-editor/core/object";
1+
import {
2+
IEezObject,
3+
LVGLParts,
4+
PropertyType
5+
} from "project-editor/core/object";
26

37
import {
48
BUILT_IN_FONTS,
@@ -7,7 +11,7 @@ import {
711
text_font_property_info
812
} from "project-editor/lvgl/style-catalog";
913
import type { LVGLPageRuntime } from "project-editor/lvgl/page-runtime";
10-
import { LVGLParts, lvglStates } from "project-editor/lvgl/lvgl-constants";
14+
import { lvglStates } from "project-editor/lvgl/lvgl-constants";
1115
import { getLvglParts } from "project-editor/lvgl/lvgl-versions";
1216

1317
////////////////////////////////////////////////////////////////////////////////

‎packages/project-editor/lvgl/widgets/Container.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { makeObservable } from "mobx";
44
import {
55
IMessage,
66
MessageType,
7-
makeDerivedClassInfo
7+
makeDerivedClassInfo,
8+
LVGLParts
89
} from "project-editor/core/object";
910

1011
import { ProjectType } from "project-editor/project/project";
1112

1213
import { LVGLPageRuntime } from "project-editor/lvgl/page-runtime";
1314
import type { LVGLBuild } from "project-editor/lvgl/build";
14-
import { LVGLParts } from "project-editor/lvgl/lvgl-constants";
1515

1616
import { LVGLTabviewWidget, LVGLTabWidget, LVGLWidget } from "./internal";
1717
import { getDropdown, getTabview } from "../widget-common";

‎packages/project-editor/project/ui/PropertiesPanel.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import { computed, makeObservable } from "mobx";
33
import { observer } from "mobx-react";
44

55
import { ProjectContext } from "project-editor/project/context";
6-
import { getParent } from "project-editor/core/object";
6+
import { getParent, IEezObject } from "project-editor/core/object";
77
import {
88
EezValueObject,
99
getAncestorOfType,
10+
getClassInfo,
11+
getLabel,
1012
getObjectIcon,
11-
getPropertiesPanelLabel,
1213
isObjectExists
1314
} from "project-editor/store";
1415
import { PropertyGrid } from "project-editor/ui-components/PropertyGrid";
@@ -95,3 +96,11 @@ export const PropertiesPanel = observer(
9596
}
9697
}
9798
);
99+
100+
function getPropertiesPanelLabel(object: IEezObject) {
101+
const classInfo = getClassInfo(object);
102+
if (classInfo.propertiesPanelLabel) {
103+
return classInfo.propertiesPanelLabel(object);
104+
}
105+
return getLabel(object);
106+
}

‎packages/project-editor/store/helper.ts

+3-21
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
isPropertyEnumerable,
1010
getParent,
1111
getKey,
12-
EezClass,
1312
isSubclassOf,
1413
ClassInfo,
1514
PropertyProps,
@@ -45,6 +44,9 @@ import type { Flow } from "project-editor/flow/flow";
4544

4645
import { isArray } from "eez-studio-shared/util";
4746

47+
import { getClass, getClassInfo } from "project-editor/core/object";
48+
export { getClass, getClassInfo } from "project-editor/core/object";
49+
4850
////////////////////////////////////////////////////////////////////////////////
4951

5052
export class EezValueObject extends EezObject {
@@ -308,18 +310,6 @@ export function getChildren(parent: IEezObject): IEezObject[] {
308310
}
309311
}
310312

311-
export function getClass(object: IEezObject) {
312-
if (isArray(object)) {
313-
return getPropertyInfo(object).typeClass!;
314-
} else {
315-
return object.constructor as EezClass;
316-
}
317-
}
318-
319-
export function getClassInfo(object: IEezObject): ClassInfo {
320-
return getClass(object).classInfo;
321-
}
322-
323313
export function getObjectIcon(object: IEezObject) {
324314
const classInfo = getClassInfo(object);
325315

@@ -369,14 +359,6 @@ export function getLabel(object: IEezObject): string {
369359
return getClass(object).name;
370360
}
371361

372-
export function getPropertiesPanelLabel(object: IEezObject) {
373-
const classInfo = getClassInfo(object);
374-
if (classInfo.propertiesPanelLabel) {
375-
return classInfo.propertiesPanelLabel(object);
376-
}
377-
return getLabel(object);
378-
}
379-
380362
export function getListLabel(object: IEezObject, collapsed: boolean) {
381363
const listLabel = getClassInfo(object).listLabel;
382364
if (listLabel) {

‎packages/project-editor/store/output-sections.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
PropertyInfo,
1313
getParent,
1414
getKey,
15-
EezObject
15+
EezObject,
16+
LVGLParts
1617
} from "project-editor/core/object";
1718

1819
import {
@@ -27,7 +28,6 @@ import { ProjectStore, getLabel } from "project-editor/store";
2728
import { ProjectEditor } from "project-editor/project-editor-interface";
2829

2930
import type { LVGLStylesDefinition } from "project-editor/lvgl/style-definition";
30-
import type { LVGLParts } from "project-editor/lvgl/lvgl-constants";
3131

3232
import { isArray } from "eez-studio-shared/util";
3333
import {

‎packages/project-editor/store/ui-state.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import { observable, extendObservable, action, toJS, runInAction } from "mobx";
44
import { each } from "lodash";
55

66
import * as notification from "eez-studio-ui/notification";
7-
import { IEezObject } from "project-editor/core/object";
7+
import { IEezObject, LVGLParts } from "project-editor/core/object";
88
import type { Component } from "project-editor/flow/component";
99
import { getObjectPathAsString } from "project-editor/store/helper";
1010
import type { ProjectStore } from "project-editor/store";
1111
import { Section } from "project-editor/store/output-sections";
12-
import type { LVGLParts } from "project-editor/lvgl/lvgl-constants";
1312
import { isScrapbookItemFilePath } from "project-editor/store/scrapbook";
1413

1514
////////////////////////////////////////////////////////////////////////////////

‎packages/project-editor/ui-components/Tree.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const TreeRow = observer(
133133
style={{
134134
paddingLeft:
135135
treeAdapter.maxLevel === 0
136-
? 0
136+
? 4
137137
: (triangle ? 0 : 18) + level * 18
138138
}}
139139
onMouseUp={this.props.onMouseUp}

0 commit comments

Comments
 (0)