mirror of
https://github.com/ehang-io/nps.git
synced 2026-11-01 01:02:12 +08:00
test gui
This commit is contained in:
1 parent
d930d9f003
commit
90ff08ed98
13 files changed
+877
No files matched your search
@@ -0,0 +1,14 @@
|
||||
// **** THIS FILE IS AUTO-GENERATED, PLEASE DO NOT EDIT IT **** //
|
||||
|
||||
package data
|
||||
|
||||
import "fyne.io/fyne"
|
||||
|
||||
var fynescenedark = &fyne.StaticResource{
|
||||
StaticName: "fyne_scene_dark.png",
|
||||
StaticContent: []byte{
|
||||
137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 1, 201, 0, 0, 1, 79, 8, 6, 0, 0, 0, 38, 214, 53, 180, 0, 0, 0, 1, 115, 82, 71, 66, 0, 174, 206, 28, 233, 0, 0, 0, 150, 101, 88, 73, 102, 77, 77, 0, 42, 0, 0, 0, 8, 0, 5, 1, 18, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 1, 26, 0, 5, 0, 0, 0, 1, 0, 0, 0, 74, 1, 27, 0, 5, 0, 0, 0, 1, 0, 0, 0, 82, 1, 49, 0, 2, 0, 0, 0, 17, 0, 0, 0, 90, 135, 105, 0, 4, 0, 0, 0, 1, 0, 0, 0, 108, 0, 0, 0, 0, 0, 0, 0, 120, 0, 0, 0, 1, 0, 0, 0, 120, 0, 0, 0, 1, 119, 119, 119, 46, 105, 110, 107, 115, 99, 97, 112, 101, 46, 111, 114, 103, 0, 0, 0, 3, 160, 1, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 160, 2, 0, 4, 0, 0, 0, 1, 0, 0, 1, 201, 160, 3, 0, 4, 0, 0, 0, 1, 0, 0, 1, 79, 0, 0, 0, 0, 52, 31, 119, 147, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 18, 116, 0, 0, 18, 116, 1, 222, 102, 31, 120, 0, 0, 1, 203, 105, 84, 88, 116, 88, 77, 76, 58, 99, 111, 109, 46, 97, 100, 111, 98, 101, 46, 120, 109, 112, 0, 0, 0, 0, 0, 60, 120, 58, 120, 109, 112, 109, 101, 116, 97, 32, 120, 109, 108, 110, 115, 58, 120, 61, 34, 97, 100, 111, 98, 101, 58, 110, 115, 58, 109, 101, 116, 97, 47, 34, 32, 120, 58, 120, 109, 112, 116, 107, 61, 34, 88, 77, 80, 32, 67, 111, 114, 101, 32, 53, 46, 52, 46, 48, 34, 62, 10, 32, 32, 32, 60, 114, 100, 102, 58, 82, 68, 70, 32, 120, 109, 108, 110, 115, 58, 114, 100, 102, 61, 34, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 119, 51, 46, 111, 114, 103, 47, 49, 57, 57, 57, 47, 48, 50, 47, 50, 50, 45, 114, 100, 102, 45, 115, 121, 110, 116, 97, 120, 45, 110, 115, 35, 34, 62, 10, 32, 32, 32, 32, 32, 32, 60, 114, 100, 102, 58, 68, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 32, 114, 100, 102, 58, 97, 98, 111, 117, 116, 61, 34, 34, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 120, 109, 108, 110, 115, 58, 120, 109, 112, 61, 34, 104, 116, 116, 112, 58, 47, 47, 110, 115, 46, 97, 100, 111, 98, 101, 46, 99, 111, 109, 47, 120, 97, 112, 47, 49, 46, 48, 47, 34, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 120, 109, 108, 110, 115, 58, 116, 105, 102, 102, 61, 34, 104, 116, 116, 112, 58, 47, 47, 110, 115, 46, 97, 100, 111, 98, 101, 46, 99, 111, 109, 47, 116, 105, 102, 102, 47, 49, 46, 48, 47, 34, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 120, 109, 112, 58, 67, 114, 101, 97, 116, 111, 114, 84, 111, 111, 108, 62, 119, 119, 119, 46, 105, 110, 107, 115, 99, 97, 112, 101, 46, 111, 114, 103, 60, 47, 120, 109, 112, 58, 67, 114, 101, 97, 116, 111, 114, 84, 111, 111, 108, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 116, 105, 102, 102, 58, 79, 114, 105, 101, 110, 116, 97, 116, 105, 111, 110, 62, 49, 60, 47, 116, 105, 102, 102, 58, 79, 114, 105, 101, 110, 116, 97, 116, 105, 111, 110, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 114, 100, 102, 58, 68, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 62, 10, 32, 32, 32, 60, 47, 114, 100, 102, 58, 82, 68, 70, 62, 10, 60, 47, 120, 58, 120, 109, 112, 109, 101, 116, 97, 62, 10, 24, 203, 85, 88, 0, 0, 163, 196, 73, 68, 65, 84, 120, 218, 236, 93, 7, 124, 20, 69, 251, 62, 154, 88, 63, 253, 252, 44, 127, 123, 239, 138, 5, 20, 129, 16, 58, 82, 44, 32, 32, 189, 215, 16, 16, 66, 239, 6, 164, 131, 32, 69, 148, 222, 68, 16, 164, 73, 239, 72, 239, 189, 247, 78, 32, 189, 222, 237, 109, 153, 255, 188, 115, 51, 199, 176, 94, 114, 151, 100, 47, 112, 199, 251, 252, 126, 227, 197, 144, 219, 219, 155, 221, 157, 103, 222, 246, 188, 54, 27, 2, 129, 64, 220, 33, 16, 66, 114, 209, 145, 143, 142, 252, 116, 220, 71, 71, 110, 47, 127, 251, 56, 29, 111, 208, 81, 140, 142, 234, 116, 180, 166, 163, 47, 29, 227, 232, 152, 77, 199, 74, 58, 182, 210, 177, 159, 142, 147, 116, 92, 162, 35, 150, 142, 84, 58, 20, 58, 52, 58, 116, 254, 115, 10, 29, 209, 116, 92, 160, 227, 40, 29, 123, 232, 216, 64, 199, 98, 58, 166, 209, 241, 19, 29, 61, 232, 104, 74, 199, 87, 116, 124, 206, 63, 251, 81, 58, 242, 192, 57, 227, 21, 68, 32, 16, 8, 132, 213, 196, 152, 155, 19, 226, 125, 233, 252, 59, 252, 219, 43, 116, 148, 161, 35, 140, 147, 213, 223, 156, 248, 162, 232, 80, 201, 157, 3, 144, 109, 28, 39, 223, 138, 252, 124, 243, 224, 85, 69, 32, 16, 8, 68, 86, 45, 197, 92, 220, 242, 202, 235, 201, 82, 164, 191, 123, 158, 142, 202, 116, 244, 161, 227, 47, 58, 142, 209, 145, 236, 133, 172, 12, 78, 150, 138, 105, 56, 249, 80, 37, 171, 81, 231, 127, 111, 120, 56, 134, 206, 255, 78, 227, 239, 113, 74, 199, 114, 240, 225, 228, 255, 174, 72, 239, 13, 147, 191, 35, 94, 105, 4, 2, 129, 64, 100, 134, 28, 243, 112, 55, 106, 30, 15, 255, 246, 28, 119, 149, 142, 166, 99, 55, 29, 73, 25, 144, 161, 42, 17, 150, 34, 145, 159, 145, 131, 214, 163, 46, 17, 228, 121, 58, 62, 64, 130, 68, 32, 16, 8, 68, 86, 172, 70, 112, 149, 230, 51, 253, 30, 126, 247, 25, 29, 189, 233, 216, 204, 99, 129, 233, 89, 134, 178, 37, 168, 231, 48, 25, 154, 207, 135, 72, 164, 12, 88, 67, 199, 127, 248, 119, 202, 159, 81, 252, 20, 129, 64, 32, 16, 8, 51, 57, 230, 146, 126, 7, 36, 82, 138, 199, 19, 143, 167, 99, 33, 202, 46, 81, 227, 14, 18, 98, 122, 112, 74, 63, 255, 36, 147, 62, 94, 117, 4, 2, 129, 64, 120, 35, 70, 72, 192, 201, 107, 250,Line truncated
|
||||
var fynescenelight = &fyne.StaticResource{
|
||||
StaticName: "fyne_scene_light.png",
|
||||
StaticContent: []byte{
|
||||
137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 1, 201, 0, 0, 1, 79, 8, 6, 0, 0, 0, 38, 214, 53, 180, 0, 0, 0, 1, 115, 82, 71, 66, 0, 174, 206, 28, 233, 0, 0, 0, 150, 101, 88, 73, 102, 77, 77, 0, 42, 0, 0, 0, 8, 0, 5, 1, 18, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 1, 26, 0, 5, 0, 0, 0, 1, 0, 0, 0, 74, 1, 27, 0, 5, 0, 0, 0, 1, 0, 0, 0, 82, 1, 49, 0, 2, 0, 0, 0, 17, 0, 0, 0, 90, 135, 105, 0, 4, 0, 0, 0, 1, 0, 0, 0, 108, 0, 0, 0, 0, 0, 0, 0, 120, 0, 0, 0, 1, 0, 0, 0, 120, 0, 0, 0, 1, 119, 119, 119, 46, 105, 110, 107, 115, 99, 97, 112, 101, 46, 111, 114, 103, 0, 0, 0, 3, 160, 1, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 160, 2, 0, 4, 0, 0, 0, 1, 0, 0, 1, 201, 160, 3, 0, 4, 0, 0, 0, 1, 0, 0, 1, 79, 0, 0, 0, 0, 52, 31, 119, 147, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 18, 116, 0, 0, 18, 116, 1, 222, 102, 31, 120, 0, 0, 1, 203, 105, 84, 88, 116, 88, 77, 76, 58, 99, 111, 109, 46, 97, 100, 111, 98, 101, 46, 120, 109, 112, 0, 0, 0, 0, 0, 60, 120, 58, 120, 109, 112, 109, 101, 116, 97, 32, 120, 109, 108, 110, 115, 58, 120, 61, 34, 97, 100, 111, 98, 101, 58, 110, 115, 58, 109, 101, 116, 97, 47, 34, 32, 120, 58, 120, 109, 112, 116, 107, 61, 34, 88, 77, 80, 32, 67, 111, 114, 101, 32, 53, 46, 52, 46, 48, 34, 62, 10, 32, 32, 32, 60, 114, 100, 102, 58, 82, 68, 70, 32, 120, 109, 108, 110, 115, 58, 114, 100, 102, 61, 34, 104, 116, 116, 112, 58, 47, 47, 119, 119, 119, 46, 119, 51, 46, 111, 114, 103, 47, 49, 57, 57, 57, 47, 48, 50, 47, 50, 50, 45, 114, 100, 102, 45, 115, 121, 110, 116, 97, 120, 45, 110, 115, 35, 34, 62, 10, 32, 32, 32, 32, 32, 32, 60, 114, 100, 102, 58, 68, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 32, 114, 100, 102, 58, 97, 98, 111, 117, 116, 61, 34, 34, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 120, 109, 108, 110, 115, 58, 120, 109, 112, 61, 34, 104, 116, 116, 112, 58, 47, 47, 110, 115, 46, 97, 100, 111, 98, 101, 46, 99, 111, 109, 47, 120, 97, 112, 47, 49, 46, 48, 47, 34, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 120, 109, 108, 110, 115, 58, 116, 105, 102, 102, 61, 34, 104, 116, 116, 112, 58, 47, 47, 110, 115, 46, 97, 100, 111, 98, 101, 46, 99, 111, 109, 47, 116, 105, 102, 102, 47, 49, 46, 48, 47, 34, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 120, 109, 112, 58, 67, 114, 101, 97, 116, 111, 114, 84, 111, 111, 108, 62, 119, 119, 119, 46, 105, 110, 107, 115, 99, 97, 112, 101, 46, 111, 114, 103, 60, 47, 120, 109, 112, 58, 67, 114, 101, 97, 116, 111, 114, 84, 111, 111, 108, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 116, 105, 102, 102, 58, 79, 114, 105, 101, 110, 116, 97, 116, 105, 111, 110, 62, 49, 60, 47, 116, 105, 102, 102, 58, 79, 114, 105, 101, 110, 116, 97, 116, 105, 111, 110, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, 114, 100, 102, 58, 68, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 62, 10, 32, 32, 32, 60, 47, 114, 100, 102, 58, 82, 68, 70, 62, 10, 60, 47, 120, 58, 120, 109, 112, 109, 101, 116, 97, 62, 10, 24, 203, 85, 88, 0, 0, 160, 86, 73, 68, 65, 84, 120, 218, 236, 125, 7, 152, 28, 89, 121, 237, 40, 108, 208, 42, 167, 201, 221, 85, 93, 85, 157, 195, 116, 79, 206, 26, 173, 178, 180, 74, 43, 141, 114, 206, 57, 172, 36, 150, 93, 130, 215, 126, 126, 14, 96, 63, 12, 216, 60, 112, 224, 225, 128, 177, 1, 155, 140, 201, 24, 131, 31, 54, 193, 192, 51, 209, 54, 94, 88, 50, 44, 11, 108, 82, 231, 122, 255, 185, 93, 213, 83, 211, 234, 153, 233, 158, 169, 25, 105, 90, 255, 249, 190, 187, 163, 149, 122, 170, 171, 110, 85, 221, 115, 255, 116, 254, 170, 42, 6, 131, 193, 184, 125, 152, 209, 210, 210, 114, 143, 166, 105, 247, 5, 131, 193, 123, 233, 255, 103, 142, 246, 217, 198, 198, 198, 37, 138, 162, 184, 85, 85, 237, 113, 185, 92, 59, 233, 207, 231, 104, 252, 186, 44, 203, 111, 160, 159, 111, 163, 191, 251, 16, 253, 252, 103, 250, 249, 37, 26, 223, 162, 241, 20, 141, 159, 211, 120, 129, 70, 130, 70, 154, 70, 198, 248, 243, 243, 52, 126, 70, 227, 59, 244, 59, 95, 163, 159, 95, 160, 241, 73, 26, 239, 161, 241, 22, 26, 191, 79, 227, 113, 26, 199, 105, 108, 166, 239, 232, 196, 119, 211, 88, 72, 231, 50, 11, 231, 204, 183, 143, 193, 96, 48, 24, 118, 99, 38, 8, 209, 32, 197, 91, 128, 191, 151, 36, 201, 69, 100, 180, 138, 198, 89, 131, 172, 222, 107, 16, 223, 143, 105, 164, 232, 239, 117, 34, 74, 157, 136, 42, 63, 240, 255, 214, 129, 207, 152, 131, 126, 167, 232, 176, 126, 198, 250, 187, 197, 142, 107, 28, 7, 100, 251, 12, 200, 151, 206, 113, 131, 113, 202, 179, 248, 150, 50, 24, 12, 6, 99, 92, 150, 162, 49, 102, 13, 12, 12, 204, 46, 102, 41, 18, 17, 53, 18, 1, 109, 34, 75, 237, 149, 68, 62, 239, 164, 241, 117, 26, 207, 89, 137, 176, 128, 168, 48, 178, 32, 75, 195, 34, 180, 142, 36, 6, 125, 46, 101, 177, 26, 51, 198, 231, 179, 5, 36, 153, 53, 254, 45, 109, 140, 148, 241, 251, 230, 177, 226, 198, 72, 26, 255, 158, 176, 144, 239, 217, 130, 107, 100, 48, 24, 12, 6, 163, 100, 204, 130, 27, 181, 152, 149, 213, 216, 216, 216, 0, 87, 41, 141, 215, 209, 248, 60, 141, 103, 11, 45, 57, 11, 25, 166, 44, 132, 149, 48, 254, 63, 93, 132, 240, 38, 115, 100, 76, 130, 164, 159, 79, 210, 185, 133, 153, 32, 25,Line truncated
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
@@ -0,0 +1,57 @@
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
|
||||
"fyne.io/fyne"
|
||||
)
|
||||
|
||||
func bundleFile(name string, filepath string, f *os.File) {
|
||||
res, err := fyne.LoadResourceFromPath(filepath)
|
||||
if err != nil {
|
||||
fyne.LogError("Unable to load file "+filepath, err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = f.WriteString(fmt.Sprintf("var %s = %#v\n", name, res))
|
||||
if err != nil {
|
||||
fyne.LogError("Unable to write to bundled file", err)
|
||||
}
|
||||
}
|
||||
|
||||
func openFile(filename string) *os.File {
|
||||
os.Remove(filename)
|
||||
_, dirname, _, _ := runtime.Caller(0)
|
||||
f, err := os.Create(path.Join(path.Dir(dirname), filename))
|
||||
if err != nil {
|
||||
fyne.LogError("Unable to open file "+filename, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err = f.WriteString("// **** THIS FILE IS AUTO-GENERATED, PLEASE DO NOT EDIT IT **** //\n\npackage data\n\nimport \"fyne.io/fyne\"\n\n")
|
||||
if err != nil {
|
||||
fyne.LogError("Unable to write file "+filename, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
func iconDir() string {
|
||||
_, dirname, _, _ := runtime.Caller(0)
|
||||
return path.Join(path.Dir(dirname), "icons")
|
||||
}
|
||||
|
||||
func main() {
|
||||
f := openFile("bundled-scene.go")
|
||||
|
||||
bundleFile("fynescenedark", "fyne_scene_dark.png", f)
|
||||
bundleFile("fynescenelight", "fyne_scene_light.png", f)
|
||||
|
||||
f.Close()
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package data
|
||||
|
||||
import (
|
||||
"fyne.io/fyne"
|
||||
)
|
||||
|
||||
// ThemedResource is a resource wrapper that will return an appropriate resource
|
||||
// for the currently selected theme.
|
||||
type ThemedResource struct {
|
||||
dark, light fyne.Resource
|
||||
}
|
||||
|
||||
func isLight() bool {
|
||||
r, g, b, _ := fyne.CurrentApp().Settings().Theme().TextColor().RGBA()
|
||||
return r < 0xaaaa && g < 0xaaaa && b < 0xaaaa
|
||||
}
|
||||
|
||||
// Name returns the underlying resource name (used for caching)
|
||||
func (res *ThemedResource) Name() string {
|
||||
if isLight() {
|
||||
return res.light.Name()
|
||||
}
|
||||
return res.dark.Name()
|
||||
}
|
||||
|
||||
// Content returns the underlying content of the correct resource for the current theme
|
||||
func (res *ThemedResource) Content() []byte {
|
||||
if isLight() {
|
||||
return res.light.Content()
|
||||
}
|
||||
return res.dark.Content()
|
||||
}
|
||||
|
||||
// NewThemedResource creates a resource that adapts to the current theme setting.
|
||||
func NewThemedResource(dark, light fyne.Resource) *ThemedResource {
|
||||
return &ThemedResource{dark, light}
|
||||
}
|
||||
|
||||
// FyneScene contains the full fyne logo with background design
|
||||
var FyneScene = NewThemedResource(fynescenedark, fynescenelight)
|
||||
@@ -0,0 +1,76 @@
|
||||
// Package main provides various examples of Fyne API capabilities
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"fyne.io/fyne"
|
||||
"fyne.io/fyne/app"
|
||||
"fyne.io/fyne/canvas"
|
||||
"fyne.io/fyne/layout"
|
||||
"fyne.io/fyne/theme"
|
||||
"fyne.io/fyne/widget"
|
||||
"github.com/cnlh/nps/gui/fyne_demo/data"
|
||||
"github.com/cnlh/nps/gui/fyne_demo/screens"
|
||||
)
|
||||
|
||||
const preferenceCurrentTab = "currentTab"
|
||||
|
||||
func welcomeScreen(a fyne.App) fyne.CanvasObject {
|
||||
logo := canvas.NewImageFromResource(data.FyneScene)
|
||||
logo.SetMinSize(fyne.NewSize(228, 167))
|
||||
|
||||
link, err := url.Parse("https://fyne.io/")
|
||||
if err != nil {
|
||||
fyne.LogError("Could not parse URL", err)
|
||||
}
|
||||
|
||||
return widget.NewVBox(
|
||||
widget.NewLabelWithStyle("Welcome to the Fyne toolkit demo app", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}),
|
||||
layout.NewSpacer(),
|
||||
widget.NewHBox(layout.NewSpacer(), logo, layout.NewSpacer()),
|
||||
widget.NewHyperlinkWithStyle("fyne.io", link, fyne.TextAlignCenter, fyne.TextStyle{}),
|
||||
layout.NewSpacer(),
|
||||
|
||||
widget.NewGroup("Theme",
|
||||
fyne.NewContainerWithLayout(layout.NewGridLayout(2),
|
||||
widget.NewButton("Dark", func() {
|
||||
a.Settings().SetTheme(theme.DarkTheme())
|
||||
}),
|
||||
widget.NewButton("Light", func() {
|
||||
a.Settings().SetTheme(theme.LightTheme())
|
||||
}),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func main() {
|
||||
a := app.NewWithID("io.fyne.demo")
|
||||
a.SetIcon(theme.FyneLogo())
|
||||
|
||||
w := a.NewWindow("Fyne Demo")
|
||||
w.SetMainMenu(fyne.NewMainMenu(fyne.NewMenu("File",
|
||||
fyne.NewMenuItem("New", func() { fmt.Println("Menu New") }),
|
||||
// a quit item will be appended to our first menu
|
||||
), fyne.NewMenu("Edit",
|
||||
fyne.NewMenuItem("Cut", func() { fmt.Println("Menu Cut") }),
|
||||
fyne.NewMenuItem("Copy", func() { fmt.Println("Menu Copy") }),
|
||||
fyne.NewMenuItem("Paste", func() { fmt.Println("Menu Paste") }),
|
||||
)))
|
||||
w.SetMaster()
|
||||
|
||||
tabs := widget.NewTabContainer(
|
||||
widget.NewTabItemWithIcon("Welcome", theme.HomeIcon(), welcomeScreen(a)),
|
||||
widget.NewTabItemWithIcon("Widgets", theme.ContentCopyIcon(), screens.WidgetScreen()),
|
||||
widget.NewTabItemWithIcon("Graphics", theme.DocumentCreateIcon(), screens.GraphicsScreen()),
|
||||
widget.NewTabItemWithIcon("Windows", theme.ViewFullScreenIcon(), screens.DialogScreen(w)),
|
||||
widget.NewTabItemWithIcon("Advanced", theme.SettingsIcon(), screens.AdvancedScreen(w)))
|
||||
tabs.SetTabLocation(widget.TabLocationLeading)
|
||||
tabs.SelectTabIndex(a.Preferences().Int(preferenceCurrentTab))
|
||||
w.SetContent(tabs)
|
||||
|
||||
w.ShowAndRun()
|
||||
a.Preferences().SetInt(preferenceCurrentTab, tabs.CurrentTabIndex())
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package screens
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"fyne.io/fyne"
|
||||
"fyne.io/fyne/driver/desktop"
|
||||
"fyne.io/fyne/layout"
|
||||
"fyne.io/fyne/widget"
|
||||
)
|
||||
|
||||
func scaleString(c fyne.Canvas) string {
|
||||
return fmt.Sprintf("%0.2f", c.Scale())
|
||||
}
|
||||
|
||||
func prependTo(g *widget.Group, s string) {
|
||||
g.Prepend(widget.NewLabel(s))
|
||||
}
|
||||
|
||||
// AdvancedScreen loads a panel that shows details and settings that are a bit
|
||||
// more detailed than normally needed.
|
||||
func AdvancedScreen(win fyne.Window) fyne.CanvasObject {
|
||||
scale := widget.NewLabel("")
|
||||
|
||||
screen := widget.NewGroup("Screen", widget.NewForm(
|
||||
&widget.FormItem{Text: "Scale", Widget: scale},
|
||||
))
|
||||
|
||||
scale.SetText(scaleString(win.Canvas()))
|
||||
|
||||
label := widget.NewLabel("Just type...")
|
||||
generic := widget.NewGroupWithScroller("Generic")
|
||||
desk := widget.NewGroupWithScroller("Desktop")
|
||||
|
||||
win.Canvas().SetOnTypedRune(func(r rune) {
|
||||
prependTo(generic, "Rune: "+string(r))
|
||||
})
|
||||
win.Canvas().SetOnTypedKey(func(ev *fyne.KeyEvent) {
|
||||
prependTo(generic, "Key : "+string(ev.Name))
|
||||
})
|
||||
if deskCanvas, ok := win.Canvas().(desktop.Canvas); ok {
|
||||
deskCanvas.SetOnKeyDown(func(ev *fyne.KeyEvent) {
|
||||
prependTo(desk, "KeyDown: "+string(ev.Name))
|
||||
})
|
||||
deskCanvas.SetOnKeyUp(func(ev *fyne.KeyEvent) {
|
||||
prependTo(desk, "KeyUp : "+string(ev.Name))
|
||||
})
|
||||
}
|
||||
|
||||
return widget.NewHBox(widget.NewVBox(screen,
|
||||
widget.NewButton("Custom Theme", func() {
|
||||
fyne.CurrentApp().Settings().SetTheme(newCustomTheme())
|
||||
}),
|
||||
widget.NewButton("Fullscreen", func() {
|
||||
win.SetFullScreen(!win.FullScreen())
|
||||
}),
|
||||
),
|
||||
|
||||
fyne.NewContainerWithLayout(layout.NewBorderLayout(label, nil, nil, nil),
|
||||
label,
|
||||
fyne.NewContainerWithLayout(layout.NewGridLayout(2),
|
||||
generic, desk,
|
||||
),
|
||||
))
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package screens
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne"
|
||||
"fyne.io/fyne/canvas"
|
||||
"fyne.io/fyne/layout"
|
||||
"fyne.io/fyne/theme"
|
||||
)
|
||||
|
||||
func rgbGradient(x, y, w, h int) color.Color {
|
||||
g := int(float32(x) / float32(w) * float32(255))
|
||||
b := int(float32(y) / float32(h) * float32(255))
|
||||
|
||||
return color.RGBA{uint8(255 - b), uint8(g), uint8(b), 0xff}
|
||||
}
|
||||
|
||||
// GraphicsScreen loads a graphics example panel for the demo app
|
||||
func GraphicsScreen() fyne.CanvasObject {
|
||||
gradient := canvas.NewHorizontalGradient(color.RGBA{0x80, 0, 0, 0xff}, color.RGBA{0, 0x80, 0, 0xff})
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(time.Second)
|
||||
|
||||
gradient.Angle += 45
|
||||
if gradient.Angle >= 360 {
|
||||
gradient.Angle -= 360
|
||||
}
|
||||
canvas.Refresh(gradient)
|
||||
}
|
||||
}()
|
||||
content := fyne.NewContainerWithLayout(layout.NewFixedGridLayout(fyne.NewSize(90, 90)),
|
||||
&canvas.Rectangle{FillColor: color.RGBA{0x80, 0, 0, 0xff},
|
||||
StrokeColor: color.RGBA{0xff, 0xff, 0xff, 0xff},
|
||||
StrokeWidth: 1},
|
||||
canvas.NewImageFromResource(theme.FyneLogo()),
|
||||
&canvas.Line{StrokeColor: color.RGBA{0, 0, 0x80, 0xff}, StrokeWidth: 5},
|
||||
&canvas.Circle{StrokeColor: color.RGBA{0, 0, 0x80, 0xff},
|
||||
FillColor: color.RGBA{0x30, 0x30, 0x30, 0x60},
|
||||
StrokeWidth: 2},
|
||||
canvas.NewText("Text", color.RGBA{0, 0x80, 0, 0xff}),
|
||||
canvas.NewRasterWithPixels(rgbGradient),
|
||||
gradient,
|
||||
canvas.NewRadialGradient(color.RGBA{0x80, 0, 0, 0xff}, color.RGBA{0, 0x80, 0x80, 0xff}),
|
||||
)
|
||||
|
||||
return fyne.NewContainerWithLayout(layout.NewAdaptiveGridLayout(2), content, IconsPanel())
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package screens
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"fyne.io/fyne"
|
||||
"fyne.io/fyne/canvas"
|
||||
"fyne.io/fyne/layout"
|
||||
"fyne.io/fyne/theme"
|
||||
"fyne.io/fyne/widget"
|
||||
)
|
||||
|
||||
type browser struct {
|
||||
current int
|
||||
|
||||
name *widget.Select
|
||||
icon *widget.Icon
|
||||
}
|
||||
|
||||
func (b *browser) setIcon(index int) {
|
||||
if index < 0 || index > len(icons)-1 {
|
||||
return
|
||||
}
|
||||
b.current = index
|
||||
|
||||
b.name.SetSelected(icons[index].name)
|
||||
b.icon.SetResource(icons[index].icon)
|
||||
}
|
||||
|
||||
// IconsPanel loads a panel that shows the various icons available in Fyne
|
||||
func IconsPanel() fyne.CanvasObject {
|
||||
b := &browser{}
|
||||
|
||||
prev := widget.NewButtonWithIcon("", theme.NavigateBackIcon(), func() {
|
||||
b.setIcon(b.current - 1)
|
||||
})
|
||||
next := widget.NewButtonWithIcon("", theme.NavigateNextIcon(), func() {
|
||||
b.setIcon(b.current + 1)
|
||||
})
|
||||
b.name = widget.NewSelect(iconList(), func(name string) {
|
||||
for i, icon := range icons {
|
||||
if icon.name == name {
|
||||
if b.current != i {
|
||||
b.setIcon(i)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
b.name.SetSelected(icons[b.current].name)
|
||||
bar := widget.NewHBox(prev, next, b.name)
|
||||
|
||||
background := canvas.NewRasterWithPixels(checkerPattern)
|
||||
background.SetMinSize(fyne.NewSize(280, 280))
|
||||
b.icon = widget.NewIcon(icons[b.current].icon)
|
||||
|
||||
return fyne.NewContainerWithLayout(layout.NewBorderLayout(
|
||||
bar, nil, nil, nil), bar, background, b.icon)
|
||||
}
|
||||
|
||||
func checkerPattern(x, y, _, _ int) color.Color {
|
||||
x /= 20
|
||||
y /= 20
|
||||
|
||||
if x%2 == y%2 {
|
||||
return theme.BackgroundColor()
|
||||
}
|
||||
|
||||
return theme.ButtonColor()
|
||||
}
|
||||
|
||||
func iconList() []string {
|
||||
var ret []string
|
||||
for _, icon := range icons {
|
||||
ret = append(ret, icon.name)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
var icons = []struct {
|
||||
name string
|
||||
icon fyne.Resource
|
||||
}{
|
||||
{"CancelIcon", theme.CancelIcon()},
|
||||
{"ConfirmIcon", theme.ConfirmIcon()},
|
||||
{"DeleteIcon", theme.DeleteIcon()},
|
||||
{"SearchIcon", theme.SearchIcon()},
|
||||
{"SearchReplaceIcon", theme.SearchReplaceIcon()},
|
||||
|
||||
{"CheckButtonIcon", theme.CheckButtonIcon()},
|
||||
{"CheckButtonCheckedIcon", theme.CheckButtonCheckedIcon()},
|
||||
{"RadioButtonIcon", theme.RadioButtonIcon()},
|
||||
{"RadioButtonCheckedIcon", theme.RadioButtonCheckedIcon()},
|
||||
|
||||
{"ContentAddIcon", theme.ContentAddIcon()},
|
||||
{"ContentRemoveIcon", theme.ContentRemoveIcon()},
|
||||
{"ContentClearIcon", theme.ContentClearIcon()},
|
||||
{"ContentCutIcon", theme.ContentCutIcon()},
|
||||
{"ContentCopyIcon", theme.ContentCopyIcon()},
|
||||
{"ContentPasteIcon", theme.ContentPasteIcon()},
|
||||
{"ContentRedoIcon", theme.ContentRedoIcon()},
|
||||
{"ContentUndoIcon", theme.ContentUndoIcon()},
|
||||
|
||||
{"InfoIcon", theme.InfoIcon()},
|
||||
{"QuestionIcon", theme.QuestionIcon()},
|
||||
{"WarningIcon", theme.WarningIcon()},
|
||||
|
||||
{"DocumentCreateIcon", theme.DocumentCreateIcon()},
|
||||
{"DocumentPrintIcon", theme.DocumentPrintIcon()},
|
||||
{"DocumentSaveIcon", theme.DocumentSaveIcon()},
|
||||
|
||||
{"FolderIcon", theme.FolderIcon()},
|
||||
{"FolderNewIcon", theme.FolderNewIcon()},
|
||||
{"FolderOpenIcon", theme.FolderOpenIcon()},
|
||||
{"HomeIcon", theme.HomeIcon()},
|
||||
{"HelpIcon", theme.HelpIcon()},
|
||||
{"SettingsIcon", theme.SettingsIcon()},
|
||||
|
||||
{"ViewFullScreenIcon", theme.ViewFullScreenIcon()},
|
||||
{"ViewRestoreIcon", theme.ViewRestoreIcon()},
|
||||
{"ViewRefreshIcon", theme.ViewRefreshIcon()},
|
||||
{"VisibilityIcon", theme.VisibilityIcon()},
|
||||
{"VisibilityOffIcon", theme.VisibilityOffIcon()},
|
||||
{"ZoomFitIcon", theme.ZoomFitIcon()},
|
||||
{"ZoomInIcon", theme.ZoomInIcon()},
|
||||
{"ZoomOutIcon", theme.ZoomOutIcon()},
|
||||
|
||||
{"MoveDownIcon", theme.MoveDownIcon()},
|
||||
{"MoveUpIcon", theme.MoveUpIcon()},
|
||||
|
||||
{"NavigateBackIcon", theme.NavigateBackIcon()},
|
||||
{"NavigateNextIcon", theme.NavigateNextIcon()},
|
||||
|
||||
{"MenuDropDown", theme.MenuDropDownIcon()},
|
||||
{"MenuDropUp", theme.MenuDropUpIcon()},
|
||||
|
||||
{"MailAttachmentIcon", theme.MailAttachmentIcon()},
|
||||
{"MailComposeIcon", theme.MailComposeIcon()},
|
||||
{"MailForwardIcon", theme.MailForwardIcon()},
|
||||
{"MailReplyIcon", theme.MailReplyIcon()},
|
||||
{"MailReplyAllIcon", theme.MailReplyAllIcon()},
|
||||
{"MailSendIcon", theme.MailSendIcon()},
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package screens
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"fyne.io/fyne"
|
||||
"fyne.io/fyne/canvas"
|
||||
"fyne.io/fyne/layout"
|
||||
"fyne.io/fyne/widget"
|
||||
)
|
||||
|
||||
func makeCell() fyne.CanvasObject {
|
||||
rect := canvas.NewRectangle(&color.RGBA{128, 128, 128, 255})
|
||||
rect.SetMinSize(fyne.NewSize(30, 30))
|
||||
return rect
|
||||
}
|
||||
|
||||
func makeBorderLayout() *fyne.Container {
|
||||
top := makeCell()
|
||||
bottom := makeCell()
|
||||
left := makeCell()
|
||||
right := makeCell()
|
||||
middle := widget.NewLabelWithStyle("BorderLayout", fyne.TextAlignCenter, fyne.TextStyle{})
|
||||
|
||||
borderLayout := layout.NewBorderLayout(top, bottom, left, right)
|
||||
return fyne.NewContainerWithLayout(borderLayout,
|
||||
top, bottom, left, right, middle)
|
||||
}
|
||||
|
||||
func makeBoxLayout() *fyne.Container {
|
||||
top := makeCell()
|
||||
bottom := makeCell()
|
||||
middle := widget.NewLabel("BoxLayout")
|
||||
center := makeCell()
|
||||
right := makeCell()
|
||||
|
||||
col := fyne.NewContainerWithLayout(layout.NewVBoxLayout(),
|
||||
top, middle, bottom)
|
||||
|
||||
return fyne.NewContainerWithLayout(layout.NewHBoxLayout(),
|
||||
col, center, right)
|
||||
}
|
||||
|
||||
func makeFixedGridLayout() *fyne.Container {
|
||||
box1 := makeCell()
|
||||
box2 := widget.NewLabel("FixedGrid")
|
||||
box3 := makeCell()
|
||||
box4 := makeCell()
|
||||
|
||||
return fyne.NewContainerWithLayout(layout.NewFixedGridLayout(fyne.NewSize(75, 75)),
|
||||
box1, box2, box3, box4)
|
||||
}
|
||||
|
||||
func makeGridLayout() *fyne.Container {
|
||||
box1 := makeCell()
|
||||
box2 := widget.NewLabel("Grid")
|
||||
box3 := makeCell()
|
||||
box4 := makeCell()
|
||||
|
||||
return fyne.NewContainerWithLayout(layout.NewGridLayout(2),
|
||||
box1, box2, box3, box4)
|
||||
}
|
||||
|
||||
// LayoutPanel loads a panel that shows the layouts available for a container
|
||||
func LayoutPanel() fyne.CanvasObject {
|
||||
return widget.NewTabContainer(
|
||||
widget.NewTabItem("Border", makeBorderLayout()),
|
||||
widget.NewTabItem("Box", makeBoxLayout()),
|
||||
widget.NewTabItem("Fixed Grid", makeFixedGridLayout()),
|
||||
widget.NewTabItem("Grid", makeGridLayout()),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package screens
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"fyne.io/fyne"
|
||||
"fyne.io/fyne/theme"
|
||||
)
|
||||
|
||||
var (
|
||||
purple = &color.RGBA{R: 128, G: 0, B: 128, A: 255}
|
||||
orange = &color.RGBA{R: 198, G: 123, B: 0, A: 255}
|
||||
grey = &color.Gray{Y: 123}
|
||||
)
|
||||
|
||||
// customTheme is a simple demonstration of a bespoke theme loaded by a Fyne app.
|
||||
type customTheme struct {
|
||||
}
|
||||
|
||||
func (customTheme) BackgroundColor() color.Color {
|
||||
return purple
|
||||
}
|
||||
|
||||
func (customTheme) ButtonColor() color.Color {
|
||||
return color.Black
|
||||
}
|
||||
|
||||
func (customTheme) DisabledButtonColor() color.Color {
|
||||
return color.White
|
||||
}
|
||||
|
||||
func (customTheme) HyperlinkColor() color.Color {
|
||||
return orange
|
||||
}
|
||||
|
||||
func (customTheme) TextColor() color.Color {
|
||||
return color.White
|
||||
}
|
||||
|
||||
func (customTheme) DisabledTextColor() color.Color {
|
||||
return color.Black
|
||||
}
|
||||
|
||||
func (customTheme) IconColor() color.Color {
|
||||
return color.White
|
||||
}
|
||||
|
||||
func (customTheme) DisabledIconColor() color.Color {
|
||||
return color.Black
|
||||
}
|
||||
|
||||
func (customTheme) PlaceHolderColor() color.Color {
|
||||
return grey
|
||||
}
|
||||
|
||||
func (customTheme) PrimaryColor() color.Color {
|
||||
return orange
|
||||
}
|
||||
|
||||
func (customTheme) HoverColor() color.Color {
|
||||
return orange
|
||||
}
|
||||
|
||||
func (customTheme) FocusColor() color.Color {
|
||||
return orange
|
||||
}
|
||||
|
||||
func (customTheme) ScrollBarColor() color.Color {
|
||||
return grey
|
||||
}
|
||||
|
||||
func (customTheme) ShadowColor() color.Color {
|
||||
return &color.RGBA{0xcc, 0xcc, 0xcc, 0xcc}
|
||||
}
|
||||
|
||||
func (customTheme) TextSize() int {
|
||||
return 12
|
||||
}
|
||||
|
||||
func (customTheme) TextFont() fyne.Resource {
|
||||
return theme.DefaultTextBoldFont()
|
||||
}
|
||||
|
||||
func (customTheme) TextBoldFont() fyne.Resource {
|
||||
return theme.DefaultTextBoldFont()
|
||||
}
|
||||
|
||||
func (customTheme) TextItalicFont() fyne.Resource {
|
||||
return theme.DefaultTextBoldItalicFont()
|
||||
}
|
||||
|
||||
func (customTheme) TextBoldItalicFont() fyne.Resource {
|
||||
return theme.DefaultTextBoldItalicFont()
|
||||
}
|
||||
|
||||
func (customTheme) TextMonospaceFont() fyne.Resource {
|
||||
return theme.DefaultTextMonospaceFont()
|
||||
}
|
||||
|
||||
func (customTheme) Padding() int {
|
||||
return 10
|
||||
}
|
||||
|
||||
func (customTheme) IconInlineSize() int {
|
||||
return 20
|
||||
}
|
||||
|
||||
func (customTheme) ScrollBarSize() int {
|
||||
return 10
|
||||
}
|
||||
|
||||
func (customTheme) ScrollBarSmallSize() int {
|
||||
return 5
|
||||
}
|
||||
|
||||
func newCustomTheme() fyne.Theme {
|
||||
return &customTheme{}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package screens
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne"
|
||||
"fyne.io/fyne/canvas"
|
||||
"fyne.io/fyne/layout"
|
||||
"fyne.io/fyne/theme"
|
||||
"fyne.io/fyne/widget"
|
||||
)
|
||||
|
||||
func makeButtonTab() fyne.Widget {
|
||||
disabled := widget.NewButton("Disabled", func() {})
|
||||
disabled.Disable()
|
||||
|
||||
return widget.NewVBox(
|
||||
widget.NewLabel("Text label"),
|
||||
widget.NewButton("Text button", func() { fmt.Println("tapped text button") }),
|
||||
widget.NewButtonWithIcon("With icon", theme.ConfirmIcon(), func() { fmt.Println("tapped icon button") }),
|
||||
disabled,
|
||||
)
|
||||
}
|
||||
|
||||
func makeInputTab() fyne.Widget {
|
||||
entry := widget.NewEntry()
|
||||
entry.SetPlaceHolder("Entry")
|
||||
entryReadOnly := widget.NewEntry()
|
||||
entryReadOnly.SetText("Entry (disabled)")
|
||||
entryReadOnly.Disable()
|
||||
|
||||
disabledCheck := widget.NewCheck("Disabled check", func(bool) {})
|
||||
disabledCheck.Disable()
|
||||
radio := widget.NewRadio([]string{"Radio Item 1", "Radio Item 2"}, func(s string) { fmt.Println("selected", s) })
|
||||
radio.Horizontal = true
|
||||
disabledRadio := widget.NewRadio([]string{"Disabled radio"}, func(string) {})
|
||||
disabledRadio.Disable()
|
||||
|
||||
return widget.NewVBox(
|
||||
entry,
|
||||
entryReadOnly,
|
||||
widget.NewSelect([]string{"Option 1", "Option 2", "Option 3"}, func(s string) { fmt.Println("selected", s) }),
|
||||
widget.NewCheck("Check", func(on bool) { fmt.Println("checked", on) }),
|
||||
disabledCheck,
|
||||
radio,
|
||||
disabledRadio,
|
||||
widget.NewSlider(0, 100),
|
||||
)
|
||||
}
|
||||
|
||||
func makeProgressTab() fyne.Widget {
|
||||
progress := widget.NewProgressBar()
|
||||
infProgress := widget.NewProgressBarInfinite()
|
||||
|
||||
go func() {
|
||||
num := 0.0
|
||||
for num < 1.0 {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
progress.SetValue(num)
|
||||
num += 0.01
|
||||
}
|
||||
|
||||
progress.SetValue(1)
|
||||
}()
|
||||
|
||||
return widget.NewVBox(
|
||||
widget.NewLabel("Percent"), progress,
|
||||
widget.NewLabel("Infinite"), infProgress)
|
||||
}
|
||||
|
||||
func makeFormTab() fyne.Widget {
|
||||
name := widget.NewEntry()
|
||||
name.SetPlaceHolder("John Smith")
|
||||
email := widget.NewEntry()
|
||||
email.SetPlaceHolder("test@example.com")
|
||||
password := widget.NewPasswordEntry()
|
||||
password.SetPlaceHolder("Password")
|
||||
largeText := widget.NewMultiLineEntry()
|
||||
|
||||
form := &widget.Form{
|
||||
OnCancel: func() {
|
||||
fmt.Println("Cancelled")
|
||||
},
|
||||
OnSubmit: func() {
|
||||
fmt.Println("Form submitted")
|
||||
fmt.Println("Name:", name.Text)
|
||||
fmt.Println("Email:", email.Text)
|
||||
fmt.Println("Password:", password.Text)
|
||||
fmt.Println("Message:", largeText.Text)
|
||||
},
|
||||
}
|
||||
form.Append("Name", name)
|
||||
form.Append("Email", email)
|
||||
form.Append("Password", password)
|
||||
form.Append("Message", largeText)
|
||||
|
||||
return form
|
||||
}
|
||||
|
||||
func makeScrollTab() fyne.CanvasObject {
|
||||
logo := canvas.NewImageFromResource(theme.FyneLogo())
|
||||
logo.SetMinSize(fyne.NewSize(320, 320))
|
||||
list := widget.NewHBox()
|
||||
list2 := widget.NewVBox()
|
||||
|
||||
for i := 1; i <= 20; i++ {
|
||||
index := i // capture
|
||||
list.Append(widget.NewButton(fmt.Sprintf("Button %d", index), func() {
|
||||
fmt.Println("Tapped", index)
|
||||
}))
|
||||
list2.Append(widget.NewButton(fmt.Sprintf("Button %d", index), func() {
|
||||
fmt.Println("Tapped", index)
|
||||
}))
|
||||
}
|
||||
|
||||
scroll := widget.NewScrollContainer(list)
|
||||
scroll.Resize(fyne.NewSize(200, 300))
|
||||
|
||||
scroll2 := widget.NewScrollContainer(list2)
|
||||
scroll2.Resize(fyne.NewSize(200, 100))
|
||||
|
||||
return fyne.NewContainerWithLayout(layout.NewGridLayout(1), scroll, scroll2)
|
||||
}
|
||||
|
||||
func makeScrollBothTab() fyne.CanvasObject {
|
||||
logo := canvas.NewImageFromResource(theme.FyneLogo())
|
||||
logo.SetMinSize(fyne.NewSize(800, 800))
|
||||
|
||||
scroll := widget.NewScrollContainer(logo)
|
||||
scroll.Resize(fyne.NewSize(400, 400))
|
||||
|
||||
return scroll
|
||||
}
|
||||
|
||||
// WidgetScreen shows a panel containing widget demos
|
||||
func WidgetScreen() fyne.CanvasObject {
|
||||
toolbar := widget.NewToolbar(widget.NewToolbarAction(theme.MailComposeIcon(), func() { fmt.Println("New") }),
|
||||
widget.NewToolbarSeparator(),
|
||||
widget.NewToolbarSpacer(),
|
||||
widget.NewToolbarAction(theme.ContentCutIcon(), func() { fmt.Println("Cut") }),
|
||||
widget.NewToolbarAction(theme.ContentCopyIcon(), func() { fmt.Println("Copy") }),
|
||||
widget.NewToolbarAction(theme.ContentPasteIcon(), func() { fmt.Println("Paste") }),
|
||||
)
|
||||
|
||||
return fyne.NewContainerWithLayout(layout.NewBorderLayout(toolbar, nil, nil, nil),
|
||||
toolbar,
|
||||
widget.NewTabContainer(
|
||||
widget.NewTabItem("Buttons", makeButtonTab()),
|
||||
widget.NewTabItem("Input", makeInputTab()),
|
||||
widget.NewTabItem("Progress", makeProgressTab()),
|
||||
widget.NewTabItem("Form", makeFormTab()),
|
||||
widget.NewTabItem("Scroll", makeScrollTab()),
|
||||
widget.NewTabItem("Full Scroll", makeScrollBothTab()),
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package screens
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne"
|
||||
"fyne.io/fyne/dialog"
|
||||
"fyne.io/fyne/layout"
|
||||
"fyne.io/fyne/widget"
|
||||
)
|
||||
|
||||
func confirmCallback(response bool) {
|
||||
fmt.Println("Responded with", response)
|
||||
}
|
||||
|
||||
// DialogScreen loads a panel that lists the dialog windows that can be tested.
|
||||
func DialogScreen(win fyne.Window) fyne.CanvasObject {
|
||||
dialogs := widget.NewGroup("Dialogs",
|
||||
widget.NewButton("Info", func() {
|
||||
dialog.ShowInformation("Information", "You should know this thing...", win)
|
||||
}),
|
||||
widget.NewButton("Error", func() {
|
||||
err := errors.New("A dummy error message")
|
||||
dialog.ShowError(err, win)
|
||||
}),
|
||||
widget.NewButton("Confirm", func() {
|
||||
cnf := dialog.NewConfirm("Confirmation", "Are you enjoying this demo?", confirmCallback, win)
|
||||
cnf.SetDismissText("Nah")
|
||||
cnf.SetConfirmText("Oh Yes!")
|
||||
cnf.Show()
|
||||
}),
|
||||
widget.NewButton("Progress", func() {
|
||||
prog := dialog.NewProgress("MyProgress", "Nearly there...", win)
|
||||
|
||||
go func() {
|
||||
num := 0.0
|
||||
for num < 1.0 {
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
prog.SetValue(num)
|
||||
num += 0.01
|
||||
}
|
||||
|
||||
prog.SetValue(1)
|
||||
prog.Hide()
|
||||
}()
|
||||
|
||||
prog.Show()
|
||||
}),
|
||||
widget.NewButton("Custom", func() {
|
||||
content := widget.NewEntry()
|
||||
content.SetPlaceHolder("Type something here")
|
||||
content.OnChanged = func(text string) {
|
||||
fmt.Println("Entered", text)
|
||||
}
|
||||
dialog.ShowCustom("Custom dialog", "Done", content, win)
|
||||
}),
|
||||
)
|
||||
|
||||
windows := widget.NewVBox(dialogs, widget.NewGroup("Windows",
|
||||
widget.NewButton("New window", func() {
|
||||
w := fyne.CurrentApp().NewWindow("Hello")
|
||||
w.SetContent(widget.NewLabel("Hello World!"))
|
||||
w.Show()
|
||||
}),
|
||||
widget.NewButton("Fixed size window", func() {
|
||||
w := fyne.CurrentApp().NewWindow("Fixed")
|
||||
w.SetContent(fyne.NewContainerWithLayout(layout.NewCenterLayout(), widget.NewLabel("Hello World!")))
|
||||
|
||||
w.Resize(fyne.NewSize(240, 180))
|
||||
w.SetFixedSize(true)
|
||||
w.Show()
|
||||
}),
|
||||
widget.NewButton("Centered window", func() {
|
||||
w := fyne.CurrentApp().NewWindow("Central")
|
||||
w.SetContent(fyne.NewContainerWithLayout(layout.NewCenterLayout(), widget.NewLabel("Hello World!")))
|
||||
|
||||
w.CenterOnScreen()
|
||||
w.Show()
|
||||
})))
|
||||
|
||||
return fyne.NewContainerWithLayout(layout.NewAdaptiveGridLayout(2), windows, LayoutPanel())
|
||||
}
|
||||
Reference in new issue
Block a user