U: touchbar demo

This commit is contained in:
zhangli10 2023-12-06 17:59:55 +08:00
parent 6af7f2ba7d
commit 54459cd3cf
2 changed files with 7 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package bar
import (
"fmt"
"github.com/energye/energy/v2/cef/ipc"
"github.com/energye/energy/v2/pkgs/touchbar/barbuilder"
"github.com/energye/energy/v2/pkgs/touchbar/barutils"
@ -30,6 +31,7 @@ func makeSliderCatalog(switcher barutils.Switcher) barbuilder.Item {
MaximumValue: 100,
OnChange: func(value float64) {
result.Content = &barbuilder.ContentLabel{Text: fmt.Sprintf("value: %v", value)}
ipc.Emit("touchbar", 4, "touch bar Slider: "+fmt.Sprintf("%v", value))
switcher.Update()
},
},
@ -50,6 +52,7 @@ func makeSliderCatalog(switcher barutils.Switcher) barbuilder.Item {
AccessoryWidth: barbuilder.SliderAccessoryWide,
OnChange: func(value float64) {
result.Content = &barbuilder.ContentLabel{Text: fmt.Sprintf("value: %v", value)}
ipc.Emit("touchbar", 4, "touch bar All options: "+fmt.Sprintf("%v", value))
switcher.Update()
},
},

View File

@ -2,6 +2,7 @@ package bar
import (
"fmt"
"github.com/energye/energy/v2/cef/ipc"
"github.com/energye/energy/v2/pkgs/touchbar/barutils"
"sync"
"time"
@ -82,6 +83,8 @@ func MakeDemo(switcher barutils.Switcher) barbuilder.Item {
reel3.Content = &barbuilder.ContentLabel{Text: *value3}
switcher.Update()
ipc.Emit("touchbar", 5, "touch bar 🎰 Spin: "+fmt.Sprintf("%v %v %v", *value1, *value2, *value3))
time.Sleep(timeBetweenSpin)
if time.Since(start) >= 4*time.Second {
break
@ -111,6 +114,7 @@ func MakeDemo(switcher barutils.Switcher) barbuilder.Item {
Text: "🙁 Spin Again",
}
}
ipc.Emit("touchbar", 6, "touch bar 🎰 Spin: "+fmt.Sprintf("%v %v %v : %v", *value1, *value2, *value3, result.Content.(*barbuilder.ContentLabel).Text))
switcher.Update()
}