Skip to content

Commit

Permalink
[shared-ui] Only show graph outline when there are multiple graphs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
paullewis authored Dec 17, 2024
1 parent 8619ff4 commit 502d1fe
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .changeset/old-cats-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@breadboard-ai/shared-ui": patch
"@google-labs/breadboard-website": patch
---

Only show graph outline when there are multiple graphs
1 change: 1 addition & 0 deletions packages/bbrt/src/components/board-visualizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class BBRTBoardVisualizer extends LitElement {
subGraphId: null,
minimized: false,
showNodePreviewValues: true,
showGraphOutline: false,
collapseNodesByDefault: false,
ports: ports,
typeMetadata,
Expand Down
7 changes: 3 additions & 4 deletions packages/shared-ui/src/elements/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@ export class Editor extends LitElement implements DragConnectorReceiver {
@property()
showBoardReferenceMarkers = false;

@property()
showMainGraphBorder = true;

@state()
showOverflowMenu = false;

Expand Down Expand Up @@ -475,6 +472,8 @@ export class Editor extends LitElement implements DragConnectorReceiver {
subGraphId ? subGraphId : MAIN_BOARD_ID
);

const hasSubGraphs = Object.keys(selectedGraph.graphs() ?? {}).length > 0;

return {
url,
title: subGraphId
Expand All @@ -490,6 +489,7 @@ export class Editor extends LitElement implements DragConnectorReceiver {
nodes: selectedGraph.nodes(),
modules: selectedGraph.modules(),
metadata: selectedGraph.metadata() || {},
showGraphOutline: subGraphId ? true : hasSubGraphs,
references,
selectionState: graphSelectionState ?? null,
};
Expand Down Expand Up @@ -1113,7 +1113,6 @@ export class Editor extends LitElement implements DragConnectorReceiver {
.selectionChangeId=${this.selectionState?.selectionChangeId}
.moveToSelection=${this.selectionState?.moveToSelection}
.showBoardReferenceMarkers=${this.showBoardReferenceMarkers}
.showMainGraphBorder=${this.showMainGraphBorder}
></bb-graph-renderer>
</div>`;

Expand Down
11 changes: 5 additions & 6 deletions packages/shared-ui/src/elements/editor/graph-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ export class GraphRenderer extends LitElement {
@property()
showSubgraphsInline = false;

@property()
showMainGraphBorder = true;

@property()
assetPrefix = "";

Expand Down Expand Up @@ -1092,12 +1089,13 @@ export class GraphRenderer extends LitElement {
}
}

#applyPositionDeltaToSelection(delta: PIXI.Point) {
#applyPositionDeltaToSelection(delta: PIXI.Point, settled = false) {
for (const child of this.#container.children) {
if (!(child instanceof Graph)) {
continue;
}
child.updateNodePositions(delta);

child.updateNodePositions(delta, settled);
}
}

Expand Down Expand Up @@ -2248,6 +2246,7 @@ export class GraphRenderer extends LitElement {
}
}

this.#applyPositionDeltaToSelection(delta, true);
this.#emitGraphVisualInformation();
}
);
Expand Down Expand Up @@ -2624,7 +2623,7 @@ export class GraphRenderer extends LitElement {

graph.subGraphId = subGraphId;
graph.graphTitle = opts.title ?? null;
graph.graphOutlineVisible = subGraphId !== null || this.showMainGraphBorder;
graph.graphOutlineVisible = opts.showGraphOutline ?? false;

return true;
}
Expand Down
13 changes: 12 additions & 1 deletion packages/shared-ui/src/elements/editor/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ export class Graph extends PIXI.Container {
}
}

updateNodePositions(delta: PIXI.Point) {
updateNodePositions(delta: PIXI.Point, settled = false) {
const selectionState = this.#selectionState;
if (!selectionState) {
return;
Expand All @@ -1206,6 +1206,9 @@ export class Graph extends PIXI.Container {
child.x = layout.x + delta.x;
child.y = layout.y + delta.y;

if (!settled) {
continue;
}
this.setNodeLayoutPosition(
node,
"node",
Expand All @@ -1229,6 +1232,9 @@ export class Graph extends PIXI.Container {
child.x = layout.x + delta.x;
child.y = layout.y + delta.y;

if (!settled) {
continue;
}
this.setNodeLayoutPosition(
comment,
"comment",
Expand Down Expand Up @@ -1655,6 +1661,10 @@ export class Graph extends PIXI.Container {
this.#graphOutlineMarker.clear();
this.#graphOutlineConnector.clear();

if (this.#graphOutlineTitleLabel) {
this.#graphOutlineTitleLabel.visible = false;
}

if (this.#graphOutlineConnectorIcon) {
this.#graphOutlineConnectorIcon.visible = false;
}
Expand Down Expand Up @@ -1757,6 +1767,7 @@ export class Graph extends PIXI.Container {

this.#graphOutlineTitleLabel.x = x + 14;
this.#graphOutlineTitleLabel.y = y + 8;
this.#graphOutlineTitleLabel.visible = true;

if (this.subGraphId) {
if (this.#graphOutlineConnectorIcon) {
Expand Down
1 change: 1 addition & 0 deletions packages/shared-ui/src/elements/editor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export interface GraphOpts {
title: string;
subGraphId: string | null;
showNodePreviewValues: boolean;
showGraphOutline: boolean;
collapseNodesByDefault: boolean;
ports: Map<string, InspectableNodePorts> | null;
typeMetadata: Map<string, NodeHandlerMetadata> | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ export class ModuleEditor extends LitElement {
minimized: false,
showNodePreviewValues: false,
collapseNodesByDefault: false,
showGraphOutline: false,
ports: ports,
typeMetadata,
edges: selectedGraph.edges(),
Expand Down Expand Up @@ -907,7 +908,6 @@ export class ModuleEditor extends LitElement {
.highlightInvalidWires=${false}
.showPortTooltips=${false}
.showSubgraphsInline=${false}
.showMainGraphBorder=${false}
.selectionChangeId=${null}
></bb-graph-renderer>
</div>
Expand Down
1 change: 0 additions & 1 deletion packages/website/src/js/board-embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export class BoardEmbed extends LitElement {
.showReadOnlyLabel=${false}
.readOnly=${true}
.hideRibbonMenu=${true}
.showMainGraphBorder=${false}
></bb-editor>
<div id="overlay"></div>
${this.url
Expand Down

0 comments on commit 502d1fe

Please sign in to comment.