Skip to content

Commit

Permalink
fixed button enabled property
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Oct 22, 2021
1 parent b2b142b commit c9229e3
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 34 deletions.
16 changes: 6 additions & 10 deletions packages/eez-studio-ui/_stylesheets/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,16 @@ input[type="color"] {
}

.EezStudio_IconAction {
color: @actionTextColor;
fill: @actionTextColor;
color: @selectionBackgroundColor;
fill: @selectionBackgroundColor;
background: transparent;
border: 1px solid transparent;

padding: 0;
}

.EezStudio_TextAction {
color: @actionTextColor;
color: @selectionBackgroundColor;
background: transparent;
border: none;
}
Expand Down Expand Up @@ -2747,7 +2747,7 @@ button.EezStudio_Action {
cursor: pointer;
float: right;
visibility: hidden;
color: @actionTextColor;
color: @selectionBackgroundColor;
&:hover {
color: @actionHoverColor;
}
Expand Down Expand Up @@ -3544,7 +3544,6 @@ button.EezStudio_Action {
flex-direction: column;

background-color: @componentBackgroundColor;
border: 1px solid @componentBackgroundColor;
border-radius: 4px;

box-shadow: @componentShadow;
Expand Down Expand Up @@ -3796,18 +3795,15 @@ button.EezStudio_Action {
&.active {
stroke: @activeConnectionLineColor;
stroke-dasharray: 10;
animation: dash 10s linear infinite;
animation: dash 100000s linear infinite;
marker-start: url(#activeLineStart);
marker-end: url(#activeLineEnd);
}
}

@keyframes dash {
from {
stroke-dashoffset: 0;
}
to {
stroke-dashoffset: -600;
stroke-dashoffset: -12000000;
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions packages/eez-studio-ui/_stylesheets/vars-dark.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
@dropPlaceColor: #7c4dff;
@errorColor: #dc3545;
@warningColor: #ffc107;
@actionTextColor: #007bff;
@actionHoverColor: #0056b3;
@connectionLineColor: #999;

Expand All @@ -35,7 +34,6 @@
@connectionLineInTheMakingColor: #337bb7;
@activeTabBackgroundColor: #666666;

@actionSelectedBackgroundColor: @actionTextColor;
@actionSelectedTextColor: white;
@actionDisabledColor: #ddd;

Expand Down
2 changes: 0 additions & 2 deletions packages/eez-studio-ui/_stylesheets/vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
@dropPlaceColor: #7c4dff;
@errorColor: #dc3545;
@warningColor: #ffc107;
@actionTextColor: #007bff;
@actionHoverColor: #0056b3;
@connectionLineColor: #999;

Expand All @@ -35,7 +34,6 @@
@connectionLineInTheMakingColor: #337bb7;
@activeTabBackgroundColor: #ffffff;

@actionSelectedBackgroundColor: @actionTextColor;
@actionSelectedTextColor: white;
@actionDisabledColor: #ddd;

Expand Down
49 changes: 39 additions & 10 deletions packages/project-editor/flow/components/widgets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,9 @@ export class TextWidget extends EmbeddedWidget {
}
});

getText(flowContext: IFlowContext): React.ReactNode {
getText(
flowContext: IFlowContext
): { text: string; node: React.ReactNode } | string {
if (
flowContext.DocumentStore.project.isDashboardProject ||
flowContext.DocumentStore.project.isAppletProject
Expand Down Expand Up @@ -1772,7 +1774,10 @@ export class TextWidget extends EmbeddedWidget {
}
} catch (err) {}

return <span className="expression">{this.data}</span>;
return {
text: this.data,
node: <span className="expression">{this.data}</span>
};
}

if (flowContext.flowState) {
Expand Down Expand Up @@ -1806,19 +1811,28 @@ export class TextWidget extends EmbeddedWidget {
}

render(flowContext: IFlowContext) {
const text = this.getText(flowContext);
const result = this.getText(flowContext);
let text: string;
let node: React.ReactNode | null;
if (typeof result == "string") {
text = result;
node = null;
} else {
text = result.text;
node = result.node;
}

return (
<>
{flowContext.DocumentStore.project.isDashboardProject ? (
text
node || text
) : (
<ComponentCanvas
component={this}
draw={(ctx: CanvasRenderingContext2D) => {
drawText(
ctx,
typeof text == "string" ? text : "err!",
text,
0,
0,
this.width,
Expand Down Expand Up @@ -2639,6 +2653,7 @@ export class ButtonWidget extends EmbeddedWidget {
);
}
}),
makeDataPropertyInfo("enabled"),
makeStylePropertyInfo("disabledStyle")
],

Expand Down Expand Up @@ -2690,7 +2705,9 @@ export class ButtonWidget extends EmbeddedWidget {
}
});

getText(flowContext: IFlowContext): React.ReactNode {
getText(
flowContext: IFlowContext
): { text: string; node: React.ReactNode } | string {
if (
flowContext.DocumentStore.project.isDashboardProject ||
flowContext.DocumentStore.project.isAppletProject
Expand Down Expand Up @@ -2723,7 +2740,10 @@ export class ButtonWidget extends EmbeddedWidget {
}
} catch (err) {}

return <span className="expression">{this.data}</span>;
return {
text: this.data,
node: <span className="expression">{this.data}</span>
};
}

if (flowContext.flowState) {
Expand All @@ -2749,7 +2769,16 @@ export class ButtonWidget extends EmbeddedWidget {
}

render(flowContext: IFlowContext) {
const text = this.getText(flowContext);
const result = this.getText(flowContext);
let text: string;
let node: React.ReactNode | null;
if (typeof result == "string") {
text = result;
node = null;
} else {
text = result.text;
node = result.node;
}

let buttonEnabled;
if (flowContext.flowState) {
Expand Down Expand Up @@ -2786,15 +2815,15 @@ export class ButtonWidget extends EmbeddedWidget {
}
}}
>
{text}
{node || text}
</button>
) : (
<ComponentCanvas
component={this}
draw={(ctx: CanvasRenderingContext2D) => {
drawText(
ctx,
typeof text == "string" ? text : "err!",
text,
0,
0,
this.width,
Expand Down
10 changes: 4 additions & 6 deletions packages/project-editor/flow/debugger/QueuePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,14 @@ export class QueuePanel extends React.Component<{
strokeLinecap="round"
strokeLinejoin="round"
>
<path
stroke="none"
d="M0 0h24v24H0z"
fill="none"
></path>
<path d="M4.05 11a8 8 0 1 1 .5 4m-.5 5v-5h5"></path>
</svg>
}
iconSize={18}
style={{ marginTop: 4, color: "green" }}
style={{
marginTop: 4,
color: this.props.runtime.isPaused ? "green" : ""
}}
title="Restart"
onClick={
this.props.runtime.DocumentStore
Expand Down
14 changes: 10 additions & 4 deletions packages/project-editor/flow/editor/ConnectionLineComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,26 @@ const VisiblePath = observer(
connectionLine.input === "@seqin" &&
!(connectionLine.targetComponent instanceof OutputActionComponent);

const active =
connectionLine.active && context.document.DocumentStore.runtime;

return (
<path
d={lineShape}
style={{
fill: "none",
strokeWidth: seq ? seqStrokeWidth : strokeWidth,
strokeLinecap: "round"
strokeLinecap: "round",
strokeDashoffset: active
? Math.ceil(
((performance.now() / 1000) * 120) % 12000000
) * -1
: undefined
}}
className={classNames("connection-line-path", {
selected,
seq,
active:
connectionLine.active &&
context.document.DocumentStore.runtime
active
})}
vectorEffect={selected ? "non-scaling-stroke" : "none"}
></path>
Expand Down

0 comments on commit c9229e3

Please sign in to comment.