Skip to content

Commit

Permalink
Allow other libs/apps to interact with the container-ish items Split …
Browse files Browse the repository at this point in the history
…and Scroll

Simplify for now by adding Stack container as a child in every drop spot.
  • Loading branch information
andydotxyz committed Jul 31, 2024
1 parent 375d63b commit ed66dd1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
10 changes: 2 additions & 8 deletions internal/guidefs/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ func initWidgets() {
split.Refresh()
},
Create: func() fyne.CanvasObject {
return container.NewScroll(&dropZone{})
return container.NewScroll(container.NewStack())
},
Edit: func(obj fyne.CanvasObject, props map[string]string) []*widget.FormItem {
return []*widget.FormItem{}
Expand All @@ -789,15 +789,13 @@ func initWidgets() {
split := parent.(*container.Split)
if split.Leading == nil {
split.Leading = o
} else if _, ok := split.Leading.(*dropZone); ok {
split.Leading = o
} else {
split.Trailing = o
}
split.Refresh()
},
Create: func() fyne.CanvasObject {
return container.NewHSplit(container.NewStack(), container.NewStack()) //&dropZone{}, &dropZone{})
return container.NewHSplit(container.NewStack(), container.NewStack())
},
Edit: func(obj fyne.CanvasObject, _ map[string]string) []*widget.FormItem {
split := obj.(*container.Split)
Expand Down Expand Up @@ -866,7 +864,3 @@ func InitOnce() {
initWidgets()
})
}

type dropZone struct {
canvas.Rectangle
}
18 changes: 17 additions & 1 deletion pkg/gui/widget.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
package gui

import "github.com/fyne-io/defyne/internal/guidefs"
import (
"reflect"

"fyne.io/fyne/v2"
"github.com/fyne-io/defyne/internal/guidefs"
)

// WidgetClassList returns the list of supported widget & container classes.
// These can be used for passing to `CreateNew` or `EditorFor`.
func WidgetClassList() []string {
return guidefs.WidgetNames
}

func DropZonesForObject(o fyne.CanvasObject) []fyne.CanvasObject {
class := reflect.TypeOf(o).String()
info := guidefs.Widgets[class]

if !info.IsContainer() {
return nil
}

return info.Children(o)
}

0 comments on commit ed66dd1

Please sign in to comment.