Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Feb 6, 2025
1 parent f719719 commit ebe3015
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 51 deletions.
12 changes: 12 additions & 0 deletions packages/eez-studio-ui/_stylesheets/project-editor.less
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,12 @@
marker-end: url(#seqLineEnd);
}

&.disabled {
stroke: @disabledConnectionLineColor;
marker-start: url(#disabledLineStart);
marker-end: url(#disabledLineEnd);
}

&.selected {
stroke: @selectedConnectionLineColor;
marker-start: url(#selectedLineStart);
Expand Down Expand Up @@ -1488,6 +1494,12 @@
marker-end: url(#seqLineEnd);
}

&.disabled {
stroke: @disabledConnectionLineColor;
marker-start: url(#disabledLineStart);
marker-end: url(#disabledLineEnd);
}

&.selected {
stroke: @selectionBackgroundColor;
marker-start: url(#selectedLineStartInViewer);
Expand Down
1 change: 1 addition & 0 deletions packages/eez-studio-ui/_stylesheets/vars-dark.less
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@activeConnectionLineColor: rgb(18, 18, 48);
@connectionLineInTheMakingColor: #337bb7;
@activeTabBackgroundColor: #666666;
@disabledConnectionLineColor: #999;

@actionSelectedTextColor: white;
@actionDisabledColor: #666;
Expand Down
1 change: 1 addition & 0 deletions packages/eez-studio-ui/_stylesheets/vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@activeConnectionLineColor: blue;
@connectionLineInTheMakingColor: #337bb7;
@activeTabBackgroundColor: #ffffff;
@disabledConnectionLineColor: #aaa;

@actionSelectedTextColor: white;
@actionDisabledColor: #ccc;
Expand Down
7 changes: 5 additions & 2 deletions packages/eez-studio-ui/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ThemeInterface {
selectedConnectionLineColor: string;
seqConnectionLineColor: string;
activeConnectionLineColor: string;
disabledLineColor: string;
}

export const lightTheme: ThemeInterface = {
Expand All @@ -19,7 +20,8 @@ export const lightTheme: ThemeInterface = {
connectionLineColor: "#999",
selectedConnectionLineColor: "red",
seqConnectionLineColor: "#3FADB5",
activeConnectionLineColor: "blue"
activeConnectionLineColor: "blue",
disabledLineColor: "#aaa"
};

export const darkTheme: ThemeInterface = {
Expand All @@ -30,7 +32,8 @@ export const darkTheme: ThemeInterface = {
connectionLineColor: "#999",
selectedConnectionLineColor: "red",
seqConnectionLineColor: "#3FADB5",
activeConnectionLineColor: "blue"
activeConnectionLineColor: "blue",
disabledLineColor: "#999"
};

export const theme = () =>
Expand Down
3 changes: 2 additions & 1 deletion packages/project-editor/build/flows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ function buildComponent(
const connectionLines = flow.connectionLines.filter(
connectionLine =>
connectionLine.sourceComponent === component &&
connectionLine.output == output.name
connectionLine.output == output.name &&
!connectionLine.disabled
);

const connectionLinesMap: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const lineColor = () => theme().connectionLineColor;
const seqLineColor = () => theme().seqConnectionLineColor;
const selectedLineColor = () => theme().selectedConnectionLineColor;
const selectedLineColorInViewer = () => theme().selectionBackgroundColor;
const disabledLineColor = () => theme().disabledLineColor;

export const strokeWidth = 1.2;
const seqStrokeWidth = 1.2;
Expand Down Expand Up @@ -221,61 +222,68 @@ const ConnectionLineDebugValue = observer(
}
);

class VisiblePath extends React.Component<{
lineShape: string;
selected: boolean;
connectionLine: ConnectionLine;
context: IFlowContext;
targetInput: ComponentInput | undefined;
shadow: { color: string } | undefined;
}> {
ref = React.createRef<SVGPathElement>();

componentDidMount() {
if (this.ref.current) {
registerPath(this.props.connectionLine, this.ref.current);
const VisiblePath = observer(
class VisiblePath extends React.Component<{
lineShape: string;
selected: boolean;
connectionLine: ConnectionLine;
context: IFlowContext;
targetInput: ComponentInput | undefined;
shadow: { color: string } | undefined;
}> {
ref = React.createRef<SVGPathElement>();

componentDidMount() {
if (this.ref.current) {
registerPath(this.props.connectionLine, this.ref.current);
}
}
}

componentWillUnmount() {
if (this.ref.current) {
unregisterPath(this.props.connectionLine, this.ref.current);
componentWillUnmount() {
if (this.ref.current) {
unregisterPath(this.props.connectionLine, this.ref.current);
}
}
}

render() {
const { lineShape, selected, connectionLine, targetInput } = this.props;
render() {
const { lineShape, selected, connectionLine, targetInput } =
this.props;

const seq =
targetInput?.isSequenceInput &&
!(
connectionLine.targetComponent instanceof
ProjectEditor.OutputActionComponentClass
);
const seq =
targetInput?.isSequenceInput &&
!(
connectionLine.targetComponent instanceof
ProjectEditor.OutputActionComponentClass
);

return (
<path
ref={this.ref}
d={lineShape}
style={{
fill: "none",
strokeWidth: this.props.shadow
? 2
: seq
? seqStrokeWidth
: strokeWidth,
strokeLinecap: "round",
stroke: this.props.shadow?.color
}}
className={classNames("connection-line-path", {
selected,
seq
})}
vectorEffect={selected ? "non-scaling-stroke" : "none"}
></path>
);
return (
<path
ref={this.ref}
d={lineShape}
style={{
fill: "none",
strokeWidth: this.props.shadow
? 2
: seq
? seqStrokeWidth
: strokeWidth,
strokeLinecap: "round",
strokeDasharray: connectionLine.disabled
? "5.5"
: undefined,
stroke: this.props.shadow?.color
}}
className={classNames("connection-line-path", {
selected,
disabled: connectionLine.disabled,
seq
})}
vectorEffect={selected ? "non-scaling-stroke" : "none"}
></path>
);
}
}
}
);

const DebugValue = observer(
({
Expand Down Expand Up @@ -351,6 +359,7 @@ export const LineMarkers = () => (
id="selectedLineEndInViewer"
color={selectedLineColorInViewer()}
/>
<LineEndMarker id="disabledLineEnd" color={disabledLineColor()} />
<AnimationCurveEndMarker />
<pattern
id="page-background"
Expand Down
13 changes: 13 additions & 0 deletions packages/project-editor/flow/connection-line/connection-line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class ConnectionLine extends EezObject {
output: string;
target: string;
input: string;
disabled: boolean;

_active: boolean;

Expand Down Expand Up @@ -83,9 +84,20 @@ export class ConnectionLine extends EezObject {
name: "input",
type: PropertyType.String,
hideInPropertyGrid: true
},
{
name: "disabled",
type: PropertyType.Boolean,
checkboxStyleSwitch: true
}
],

beforeLoadHook(object, jsObject) {
if (jsObject.disabled == "undefined") {
jsObject.disabled = false;
}
},

isSelectable: () => true,

deleteObjectFilterHook: (connectionLine: ConnectionLine) => {
Expand Down Expand Up @@ -218,6 +230,7 @@ export class ConnectionLine extends EezObject {
target: observable,
input: observable,
_active: observable,
disabled: observable,
isVisible: computed
});
}
Expand Down

0 comments on commit ebe3015

Please sign in to comment.