Skip to content
Prev Previous commit
Next Next commit
Every float cards moves together
  • Loading branch information
julien2512 committed Sep 11, 2024
commit 620ad26c849c14d8a79e9dae63dcc16dc26c18bb
4 changes: 3 additions & 1 deletion render.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ func newTableRender(table *Table) *tableRender {
render.appendStack(render.stack6)
render.appendStack(render.stack7)

render.objects = append(render.objects, container.NewWithoutLayout(table.float[0]))
for i:=0; i<len(table.float); i++ {
render.objects = append(render.objects, container.NewWithoutLayout(table.float[i]))
}
render.Refresh()
return render
}
Expand Down
26 changes: 17 additions & 9 deletions table.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ func (t *Table) Restart() {
func (t *Table) Dragged(event *fyne.DragEvent) {
t.floatPos = event.Position
if !t.float[0].Hidden { // existing drag
t.float[0].Move(t.float[0].Position().Add(event.Dragged))

for i:=0;i<len(t.float);i++ {
if (t.float[i] != nil && !t.float[i].Hidden) {
t.float[i].Move(t.float[i].Position().Add(event.Dragged))
}
}
return
}

Expand All @@ -137,18 +142,21 @@ func (t *Table) Dragged(event *fyne.DragEvent) {
return
}

t.floatSource[0] = source[0]
t.float[0].Resource = source[0].Resource
t.selected = card[0]
source[0].Resource = nil
if last {
source[0].Resource = faces.ForSpace()
}
source[0].Image = nil
source[0].Refresh()
t.float[0].Refresh()
t.float[0].Move(source[0].Position())
t.float[0].Show()

for i:=0;i<len(source);i++ {
t.floatSource[i] = source[i]
t.float[i].Resource = source[i].Resource
source[i].Resource = nil
source[i].Image = nil
source[i].Refresh()
t.float[i].Refresh()
updateCardPosition(t.float[i], source[i].Position().X, source[i].Position().Y)
t.float[i].Show()
}
}

// DragEnd is called when the user stops dragging on the table widget
Expand Down