Skip to content

Commit

Permalink
display [NATIVE] as badge
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Dec 6, 2024
1 parent 58c61d6 commit a4e6116
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 62 deletions.
21 changes: 21 additions & 0 deletions packages/eez-studio-ui/_stylesheets/project-editor.less
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,20 @@
white-space: nowrap;
text-overflow: ellipsis;

display: flex;
align-items: center;

& > img,
& > svg {
flex-shrink: 0;
height: 20px;
object-fit: contain;
margin-right: 4px;
}

& > i.material-icons {
margin-right: 4px;
}
}

.EezStudio_PropertiesPanel_Body {
Expand Down Expand Up @@ -3803,3 +3810,17 @@
}
}
}

.EezStudio_ListLabel_Badge {
margin-left: 8px;
transform: translateY(-1px);

display: inline-block;
padding: 0px 5px;
font-size: 80%;
font-weight: bold;
color: rgb(238, 238, 238);
background-color: var(--bs-secondary);
white-space: nowrap;
border-radius: var(--bs-border-radius);
}
29 changes: 19 additions & 10 deletions packages/project-editor/core/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,19 @@ import { observable, makeObservable } from "mobx";

import { humanize } from "eez-studio-shared/string";
import { Rect } from "eez-studio-shared/geometry";
import { isArray, objectClone } from "eez-studio-shared/util";

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

import {
import type { IResizeHandler } from "project-editor/flow/flow-interfaces";
import type { ValueType } from "project-editor/features/variable/value-type";
import type { Project } from "project-editor/project/project";
import type {
ProjectStore,
IContextMenuContext,
getClassInfo,
EezValueObject
} from "project-editor/store";

import type { IResizeHandler } from "project-editor/flow/flow-interfaces";

import type { ValueType } from "project-editor/features/variable/value-type";
import type { Project } from "project-editor/project/project";

import { isArray, objectClone } from "eez-studio-shared/util";
import { LVGLParts } from "project-editor/lvgl/lvgl-constants";

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

export const enum PropertyType {
Expand Down Expand Up @@ -323,6 +318,8 @@ export interface SerializedData {
objectsParentPath?: string[];
}

export type LVGLParts = string;

interface LVGLClassInfoProperties {
parts: LVGLParts[] | ((object: IEezObject) => LVGLParts[]);
defaultFlags: string;
Expand Down Expand Up @@ -643,6 +640,18 @@ export function isEezObject(object: any): object is IEezObject {

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

export function getClass(object: IEezObject) {
if (isArray(object)) {
return getPropertyInfo(object).typeClass!;
} else {
return object.constructor as EezClass;
}
}

export function getClassInfo(object: IEezObject): ClassInfo {
return getClass(object).classInfo;
}

export function findClass(className: string) {
return classNameToEezClassMap.get(className);
}
Expand Down
22 changes: 15 additions & 7 deletions packages/project-editor/features/action/action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,22 @@ export class Action extends Flow {
);
},
label: (action: Action) => {
const projectStore = getProjectStore(action);
if (
projectStore.projectTypeTraits.hasFlowSupport &&
action.implementationType == "native"
) {
return "[NATIVE] " + action.name;
}
return action.name;
},
listLabel: (action: Action) => {
const projectStore = getProjectStore(action);
return (
<>
<span>{action.name}</span>
{projectStore.projectTypeTraits.hasFlowSupport &&
action.implementationType == "native" && (
<span className="EezStudio_ListLabel_Badge">
NATIVE
</span>
)}
</>
);
},
beforeLoadHook: (action: Action, jsObject: any) => {
if (jsObject.page) {
jsObject.components = jsObject.page.components;
Expand Down Expand Up @@ -351,6 +358,7 @@ export class Action extends Flow {

return action;
},

icon: "material:code"
});

Expand Down
24 changes: 18 additions & 6 deletions packages/project-editor/features/variable/variable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ export class Variable extends EezObject {
variable
).projectTypeTraits.isVariableTypeSupportedAsNative(
variable.type
)
),
checkboxStyleSwitch: true
},
{
name: "nativeImplementationInfo",
Expand Down Expand Up @@ -490,13 +491,24 @@ export class Variable extends EezObject {

return (
<>
{projectStore.projectTypeTraits.hasFlowSupport &&
variable.native && <span>[NATIVE] </span>}
{variable.persistent && <span>[PERSISTENT] </span>}
<span>{variable.name} </span>
<em className="font-monospace" style={{ opacity: 0.5 }}>
<span>{variable.name}</span>
<em
className="font-monospace"
style={{ opacity: 0.5, marginLeft: 8 }}
>
{variable.type}
</em>
{projectStore.projectTypeTraits.hasFlowSupport &&
variable.native && (
<span className="EezStudio_ListLabel_Badge">
NATIVE
</span>
)}
{variable.persistent && (
<span className="EezStudio_ListLabel_Badge">
PERSISTENT
</span>
)}
</>
);
},
Expand Down
8 changes: 3 additions & 5 deletions packages/project-editor/lvgl/LVGLStylesDefinitionProperty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
getClassInfoLvglParts,
IEezObject,
PropertyInfo,
PropertyProps
PropertyProps,
LVGLParts
} from "project-editor/core/object";
import type { Page } from "project-editor/features/page/page";
import { ProjectEditor } from "project-editor/project-editor-interface";
Expand All @@ -31,10 +32,7 @@ import {
} from "project-editor/lvgl/page-runtime";
import { ITreeNode, Tree } from "eez-studio-ui/tree";
import { Checkbox } from "project-editor/ui-components/PropertyGrid/Checkbox";
import {
LVGL_STYLE_STATES,
LVGLParts
} from "project-editor/lvgl/lvgl-constants";
import { LVGL_STYLE_STATES } from "project-editor/lvgl/lvgl-constants";

type TreeNodeData =
| {
Expand Down
2 changes: 0 additions & 2 deletions packages/project-editor/lvgl/lvgl-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,6 @@ export const LVGL_PARTS_9: { [key: string]: number } = {
ANY: 0x0f0000 // LV_PART_ANY Special value can be used in some functions to target all parts
};

export type LVGLParts = string;

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

export const LV_EVENT_CHECKED = 0x7e;
Expand Down
8 changes: 6 additions & 2 deletions packages/project-editor/lvgl/style-helper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { IEezObject, PropertyType } from "project-editor/core/object";
import {
IEezObject,
LVGLParts,
PropertyType
} from "project-editor/core/object";

import {
BUILT_IN_FONTS,
Expand All @@ -7,7 +11,7 @@ import {
text_font_property_info
} from "project-editor/lvgl/style-catalog";
import type { LVGLPageRuntime } from "project-editor/lvgl/page-runtime";
import { LVGLParts, lvglStates } from "project-editor/lvgl/lvgl-constants";
import { lvglStates } from "project-editor/lvgl/lvgl-constants";
import { getLvglParts } from "project-editor/lvgl/lvgl-versions";

////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions packages/project-editor/lvgl/widgets/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { makeObservable } from "mobx";
import {
IMessage,
MessageType,
makeDerivedClassInfo
makeDerivedClassInfo,
LVGLParts
} from "project-editor/core/object";

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

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

import { LVGLTabviewWidget, LVGLTabWidget, LVGLWidget } from "./internal";
import { getDropdown, getTabview } from "../widget-common";
Expand Down
13 changes: 11 additions & 2 deletions packages/project-editor/project/ui/PropertiesPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { computed, makeObservable } from "mobx";
import { observer } from "mobx-react";

import { ProjectContext } from "project-editor/project/context";
import { getParent } from "project-editor/core/object";
import { getParent, IEezObject } from "project-editor/core/object";
import {
EezValueObject,
getAncestorOfType,
getClassInfo,
getLabel,
getObjectIcon,
getPropertiesPanelLabel,
isObjectExists
} from "project-editor/store";
import { PropertyGrid } from "project-editor/ui-components/PropertyGrid";
Expand Down Expand Up @@ -95,3 +96,11 @@ export const PropertiesPanel = observer(
}
}
);

function getPropertiesPanelLabel(object: IEezObject) {
const classInfo = getClassInfo(object);
if (classInfo.propertiesPanelLabel) {
return classInfo.propertiesPanelLabel(object);
}
return getLabel(object);
}
24 changes: 3 additions & 21 deletions packages/project-editor/store/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
isPropertyEnumerable,
getParent,
getKey,
EezClass,
isSubclassOf,
ClassInfo,
PropertyProps,
Expand Down Expand Up @@ -45,6 +44,9 @@ import type { Flow } from "project-editor/flow/flow";

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

import { getClass, getClassInfo } from "project-editor/core/object";
export { getClass, getClassInfo } from "project-editor/core/object";

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

export class EezValueObject extends EezObject {
Expand Down Expand Up @@ -308,18 +310,6 @@ export function getChildren(parent: IEezObject): IEezObject[] {
}
}

export function getClass(object: IEezObject) {
if (isArray(object)) {
return getPropertyInfo(object).typeClass!;
} else {
return object.constructor as EezClass;
}
}

export function getClassInfo(object: IEezObject): ClassInfo {
return getClass(object).classInfo;
}

export function getObjectIcon(object: IEezObject) {
const classInfo = getClassInfo(object);

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

export function getPropertiesPanelLabel(object: IEezObject) {
const classInfo = getClassInfo(object);
if (classInfo.propertiesPanelLabel) {
return classInfo.propertiesPanelLabel(object);
}
return getLabel(object);
}

export function getListLabel(object: IEezObject, collapsed: boolean) {
const listLabel = getClassInfo(object).listLabel;
if (listLabel) {
Expand Down
4 changes: 2 additions & 2 deletions packages/project-editor/store/output-sections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
PropertyInfo,
getParent,
getKey,
EezObject
EezObject,
LVGLParts
} from "project-editor/core/object";

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

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

import { isArray } from "eez-studio-shared/util";
import {
Expand Down
3 changes: 1 addition & 2 deletions packages/project-editor/store/ui-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { observable, extendObservable, action, toJS, runInAction } from "mobx";
import { each } from "lodash";

import * as notification from "eez-studio-ui/notification";
import { IEezObject } from "project-editor/core/object";
import { IEezObject, LVGLParts } from "project-editor/core/object";
import type { Component } from "project-editor/flow/component";
import { getObjectPathAsString } from "project-editor/store/helper";
import type { ProjectStore } from "project-editor/store";
import { Section } from "project-editor/store/output-sections";
import type { LVGLParts } from "project-editor/lvgl/lvgl-constants";
import { isScrapbookItemFilePath } from "project-editor/store/scrapbook";

////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion packages/project-editor/ui-components/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const TreeRow = observer(
style={{
paddingLeft:
treeAdapter.maxLevel === 0
? 0
? 4
: (triangle ? 0 : 18) + level * 18
}}
onMouseUp={this.props.onMouseUp}
Expand Down

0 comments on commit a4e6116

Please sign in to comment.