Skip to content

Commit

Permalink
U: touchbar demo
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangli10 committed Dec 6, 2023
1 parent 6af7f2b commit 54459cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions example/macos/touchbar/bar/catalog_slider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
},
},
Expand All @@ -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()
},
},
Expand Down
4 changes: 4 additions & 0 deletions example/macos/touchbar/bar/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit 54459cd

Please sign in to comment.