@@ -6,18 +6,40 @@ import (
66 "github.com/fyne-io/refyne/internal/guidefs"
77)
88
9+ type WidgetInfo = guidefs.WidgetInfo
10+
911// CollectionClassList returns the list of supported collection widget classes.
1012// These can be used for passing to `CreateNew` or `EditorFor`.
1113func CollectionClassList () []string {
1214 return guidefs .CollectionNames
1315}
1416
17+ // RegisterCollection allows a 3rd party collection widget to be added to those recognised.
18+ // It is important that the Name field is populated with the typed name (i.e. *myPkg.MyWidget)
19+ // and your package should be returned in the list from Packages() as well.
20+ func RegisterCollection (info WidgetInfo ) {
21+ guidefs .InitOnce ()
22+
23+ guidefs .CollectionNames = append (guidefs .CollectionNames , info .Name )
24+ guidefs .Collections [info .Name ] = info
25+ }
26+
1527// ContainerClassList returns the list of supported container classes.
1628// These can be used for passing to `CreateNew` or `EditorFor`.
1729func ContainerClassList () []string {
1830 return guidefs .ContainerNames
1931}
2032
33+ // RegisterContainer allows a 3rd party container widget to be added to those recognised.
34+ // It is important that the Name field is populated with the typed name (i.e. *myPkg.MyWidget)
35+ // and your package should be returned in the list from Packages() as well.
36+ func RegisterContainer (info WidgetInfo ) {
37+ guidefs .InitOnce ()
38+
39+ guidefs .ContainerNames = append (guidefs .ContainerNames , info .Name )
40+ guidefs .Containers [info .Name ] = info
41+ }
42+
2143// GraphicsClassList returns the list of supported graphics primitives classes.
2244// These can be used for passing to `CreateNew` or `EditorFor`.
2345func GraphicsClassList () []string {
@@ -30,6 +52,16 @@ func WidgetClassList() []string {
3052 return guidefs .WidgetNames
3153}
3254
55+ // RegisterWidget allows a 3rd party Fyne widget to be added to those recognised.
56+ // It is important that the Name field is populated with the typed name (i.e. *myPkg.MyWidget)
57+ // and your package should be returned in the list from Packages() as well.
58+ func RegisterWidget (info WidgetInfo ) {
59+ guidefs .InitOnce ()
60+
61+ guidefs .WidgetNames = append (guidefs .WidgetNames , info .Name )
62+ guidefs .Widgets [info .Name ] = info
63+ }
64+
3365// DropZonesForObject returns the children of a container that can be used as drag and drop target zones
3466func DropZonesForObject (o fyne.CanvasObject ) []fyne.CanvasObject {
3567 class := guidefs .TypeName (o )
0 commit comments