Skip to content

Commit ebe3015

Browse files
committed
1 parent f719719 commit ebe3015

File tree

7 files changed

+91
-51
lines changed

7 files changed

+91
-51
lines changed

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

+12
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,12 @@
13641364
marker-end: url(#seqLineEnd);
13651365
}
13661366

1367+
&.disabled {
1368+
stroke: @disabledConnectionLineColor;
1369+
marker-start: url(#disabledLineStart);
1370+
marker-end: url(#disabledLineEnd);
1371+
}
1372+
13671373
&.selected {
13681374
stroke: @selectedConnectionLineColor;
13691375
marker-start: url(#selectedLineStart);
@@ -1488,6 +1494,12 @@
14881494
marker-end: url(#seqLineEnd);
14891495
}
14901496

1497+
&.disabled {
1498+
stroke: @disabledConnectionLineColor;
1499+
marker-start: url(#disabledLineStart);
1500+
marker-end: url(#disabledLineEnd);
1501+
}
1502+
14911503
&.selected {
14921504
stroke: @selectionBackgroundColor;
14931505
marker-start: url(#selectedLineStartInViewer);

packages/eez-studio-ui/_stylesheets/vars-dark.less

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
@activeConnectionLineColor: rgb(18, 18, 48);
3636
@connectionLineInTheMakingColor: #337bb7;
3737
@activeTabBackgroundColor: #666666;
38+
@disabledConnectionLineColor: #999;
3839

3940
@actionSelectedTextColor: white;
4041
@actionDisabledColor: #666;

packages/eez-studio-ui/_stylesheets/vars.less

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
@activeConnectionLineColor: blue;
3636
@connectionLineInTheMakingColor: #337bb7;
3737
@activeTabBackgroundColor: #ffffff;
38+
@disabledConnectionLineColor: #aaa;
3839

3940
@actionSelectedTextColor: white;
4041
@actionDisabledColor: #ccc;

packages/eez-studio-ui/theme.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface ThemeInterface {
99
selectedConnectionLineColor: string;
1010
seqConnectionLineColor: string;
1111
activeConnectionLineColor: string;
12+
disabledLineColor: string;
1213
}
1314

1415
export const lightTheme: ThemeInterface = {
@@ -19,7 +20,8 @@ export const lightTheme: ThemeInterface = {
1920
connectionLineColor: "#999",
2021
selectedConnectionLineColor: "red",
2122
seqConnectionLineColor: "#3FADB5",
22-
activeConnectionLineColor: "blue"
23+
activeConnectionLineColor: "blue",
24+
disabledLineColor: "#aaa"
2325
};
2426

2527
export const darkTheme: ThemeInterface = {
@@ -30,7 +32,8 @@ export const darkTheme: ThemeInterface = {
3032
connectionLineColor: "#999",
3133
selectedConnectionLineColor: "red",
3234
seqConnectionLineColor: "#3FADB5",
33-
activeConnectionLineColor: "blue"
35+
activeConnectionLineColor: "blue",
36+
disabledLineColor: "#999"
3437
};
3538

3639
export const theme = () =>

packages/project-editor/build/flows.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ function buildComponent(
282282
const connectionLines = flow.connectionLines.filter(
283283
connectionLine =>
284284
connectionLine.sourceComponent === component &&
285-
connectionLine.output == output.name
285+
connectionLine.output == output.name &&
286+
!connectionLine.disabled
286287
);
287288

288289
const connectionLinesMap: {

packages/project-editor/flow/connection-line/ConnectionLineComponent.tsx

+57-48
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const lineColor = () => theme().connectionLineColor;
2525
const seqLineColor = () => theme().seqConnectionLineColor;
2626
const selectedLineColor = () => theme().selectedConnectionLineColor;
2727
const selectedLineColorInViewer = () => theme().selectionBackgroundColor;
28+
const disabledLineColor = () => theme().disabledLineColor;
2829

2930
export const strokeWidth = 1.2;
3031
const seqStrokeWidth = 1.2;
@@ -221,61 +222,68 @@ const ConnectionLineDebugValue = observer(
221222
}
222223
);
223224

224-
class VisiblePath extends React.Component<{
225-
lineShape: string;
226-
selected: boolean;
227-
connectionLine: ConnectionLine;
228-
context: IFlowContext;
229-
targetInput: ComponentInput | undefined;
230-
shadow: { color: string } | undefined;
231-
}> {
232-
ref = React.createRef<SVGPathElement>();
233-
234-
componentDidMount() {
235-
if (this.ref.current) {
236-
registerPath(this.props.connectionLine, this.ref.current);
225+
const VisiblePath = observer(
226+
class VisiblePath extends React.Component<{
227+
lineShape: string;
228+
selected: boolean;
229+
connectionLine: ConnectionLine;
230+
context: IFlowContext;
231+
targetInput: ComponentInput | undefined;
232+
shadow: { color: string } | undefined;
233+
}> {
234+
ref = React.createRef<SVGPathElement>();
235+
236+
componentDidMount() {
237+
if (this.ref.current) {
238+
registerPath(this.props.connectionLine, this.ref.current);
239+
}
237240
}
238-
}
239241

240-
componentWillUnmount() {
241-
if (this.ref.current) {
242-
unregisterPath(this.props.connectionLine, this.ref.current);
242+
componentWillUnmount() {
243+
if (this.ref.current) {
244+
unregisterPath(this.props.connectionLine, this.ref.current);
245+
}
243246
}
244-
}
245247

246-
render() {
247-
const { lineShape, selected, connectionLine, targetInput } = this.props;
248+
render() {
249+
const { lineShape, selected, connectionLine, targetInput } =
250+
this.props;
248251

249-
const seq =
250-
targetInput?.isSequenceInput &&
251-
!(
252-
connectionLine.targetComponent instanceof
253-
ProjectEditor.OutputActionComponentClass
254-
);
252+
const seq =
253+
targetInput?.isSequenceInput &&
254+
!(
255+
connectionLine.targetComponent instanceof
256+
ProjectEditor.OutputActionComponentClass
257+
);
255258

256-
return (
257-
<path
258-
ref={this.ref}
259-
d={lineShape}
260-
style={{
261-
fill: "none",
262-
strokeWidth: this.props.shadow
263-
? 2
264-
: seq
265-
? seqStrokeWidth
266-
: strokeWidth,
267-
strokeLinecap: "round",
268-
stroke: this.props.shadow?.color
269-
}}
270-
className={classNames("connection-line-path", {
271-
selected,
272-
seq
273-
})}
274-
vectorEffect={selected ? "non-scaling-stroke" : "none"}
275-
></path>
276-
);
259+
return (
260+
<path
261+
ref={this.ref}
262+
d={lineShape}
263+
style={{
264+
fill: "none",
265+
strokeWidth: this.props.shadow
266+
? 2
267+
: seq
268+
? seqStrokeWidth
269+
: strokeWidth,
270+
strokeLinecap: "round",
271+
strokeDasharray: connectionLine.disabled
272+
? "5.5"
273+
: undefined,
274+
stroke: this.props.shadow?.color
275+
}}
276+
className={classNames("connection-line-path", {
277+
selected,
278+
disabled: connectionLine.disabled,
279+
seq
280+
})}
281+
vectorEffect={selected ? "non-scaling-stroke" : "none"}
282+
></path>
283+
);
284+
}
277285
}
278-
}
286+
);
279287

280288
const DebugValue = observer(
281289
({
@@ -351,6 +359,7 @@ export const LineMarkers = () => (
351359
id="selectedLineEndInViewer"
352360
color={selectedLineColorInViewer()}
353361
/>
362+
<LineEndMarker id="disabledLineEnd" color={disabledLineColor()} />
354363
<AnimationCurveEndMarker />
355364
<pattern
356365
id="page-background"

packages/project-editor/flow/connection-line/connection-line.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class ConnectionLine extends EezObject {
2727
output: string;
2828
target: string;
2929
input: string;
30+
disabled: boolean;
3031

3132
_active: boolean;
3233

@@ -83,9 +84,20 @@ export class ConnectionLine extends EezObject {
8384
name: "input",
8485
type: PropertyType.String,
8586
hideInPropertyGrid: true
87+
},
88+
{
89+
name: "disabled",
90+
type: PropertyType.Boolean,
91+
checkboxStyleSwitch: true
8692
}
8793
],
8894

95+
beforeLoadHook(object, jsObject) {
96+
if (jsObject.disabled == "undefined") {
97+
jsObject.disabled = false;
98+
}
99+
},
100+
89101
isSelectable: () => true,
90102

91103
deleteObjectFilterHook: (connectionLine: ConnectionLine) => {
@@ -218,6 +230,7 @@ export class ConnectionLine extends EezObject {
218230
target: observable,
219231
input: observable,
220232
_active: observable,
233+
disabled: observable,
221234
isVisible: computed
222235
});
223236
}

0 commit comments

Comments
 (0)