Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions fyne-gui/NetworkDiagram.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,26 +188,31 @@ func (networkDiag *NetworkDiagram) refreshNodes(
for i, p := range points {
// needs an inital size because its not set for the widget on the
// initial pass
diagWidth := diag.Size().Width
diagWidth := diag.Size().Width // TODO : larger than expected, why ? try container for diag ? temp fix : /2
if diagWidth == 0 {
diagWidth = 800
diagWidth = InitialWindowSize.Width / 2
}

diagHeight := diag.Size().Height
if diagHeight == 0 {
diagHeight = 1200
diagHeight = InitialWindowSize.Height // TODO : InitialWindowSize disregards the top bar above the diagram
}

ratiow := diagWidth / 100
ratioh := diagHeight / 100

// draw node
x := ratiow * float32(p.x*.5)
y := ratioh * float32(p.y*.5)
x := ratiow * float32(p.x)
y := ratioh * float32(p.y)

nodeName := "Node" + strconv.Itoa(i)
nodeButton := networkDiag.buttons[i]
diagNode := diagramwidget.NewDiagramNode(diag, nodeButton, "Id:"+nodeName)

// anchor nodes at their center
x -= nodeButton.Size().Width / 2
y -= nodeButton.Size().Height / 2

diagNode.Move(fyne.Position{X: x, Y: y})
newNode := node{diagNode, false, false}
networkDiag.nodes = append(networkDiag.nodes, newNode)
Expand Down