izapple2/frontend/a2fyne/toolbar.go

76 lines
2.1 KiB
Go
Raw Normal View History

2020-10-15 22:38:15 +00:00
package main
import (
"fmt"
"github.com/ivanizag/izapple2"
2020-10-16 18:41:34 +00:00
"github.com/ivanizag/izapple2/screen"
2020-10-15 22:38:15 +00:00
2021-03-06 19:23:17 +00:00
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
2020-10-15 22:38:15 +00:00
)
func buildCommandToolbar(s *state, icon fyne.Resource, command int) widget.ToolbarItem {
return widget.NewToolbarAction(
2021-03-06 19:23:17 +00:00
theme.NewThemedResource(icon), func() {
2020-10-15 22:38:15 +00:00
s.a.SendCommand(command)
})
}
func buildToolbar(s *state) *widget.Toolbar {
tb := widget.NewToolbar()
tb.Append(buildCommandToolbar(s, resourceRestartSvg, izapple2.CommandReset))
tb.Append(buildCommandToolbar(s, resourcePauseSvg, izapple2.CommandPauseUnpauseEmulator))
tb.Append(buildCommandToolbar(s, resourceFastForwardSvg, izapple2.CommandToggleSpeed))
tb.Append(widget.NewToolbarSeparator())
tb.Append(newToolbarScreen(s))
tb.Append(widget.NewToolbarSeparator())
tb.Append(widget.NewToolbarAction(
2021-03-06 19:23:17 +00:00
theme.NewThemedResource(resourceLayersTripleSvg), func() {
2020-10-15 22:38:15 +00:00
s.showPages = !s.showPages
if !s.showPages {
2020-11-03 01:26:56 +00:00
s.win.SetTitle(s.DefaultTitle())
2020-10-15 22:38:15 +00:00
}
}))
tb.Append(widget.NewToolbarAction(
2021-03-06 19:23:17 +00:00
theme.NewThemedResource(resourceCameraSvg), func() {
2020-10-16 18:41:34 +00:00
err := screen.SaveSnapshot(s.a, s.screenMode, "snapshot.png")
2020-10-15 22:38:15 +00:00
if err != nil {
s.app.SendNotification(fyne.NewNotification(
s.win.Title(),
fmt.Sprintf("Error saving snapshoot: %v.\n.", err)))
} else {
s.app.SendNotification(fyne.NewNotification(
s.win.Title(),
"Snapshot saved on 'snapshot.png'"))
}
}))
2020-11-03 01:26:56 +00:00
tb.Append(widget.NewToolbarSeparator())
tb.Append(widget.NewToolbarAction(
2021-03-06 19:23:17 +00:00
theme.NewThemedResource(resourceCapsLockSvg), func() {
2020-11-03 01:26:56 +00:00
s.a.SetForceCaps(!s.a.IsForceCaps())
s.win.SetTitle(s.DefaultTitle())
}))
2020-10-15 22:38:15 +00:00
//tb.Append(widget.NewToolbarSeparator())
//tb.Append(newToolbarDisk("S6D1")
tb.Append(widget.NewToolbarSpacer())
tb.Append(widget.NewToolbarAction(
theme.ViewFullScreenIcon(),
func() {
s.win.SetFullScreen(!s.win.FullScreen())
}))
tb.Append(widget.NewToolbarAction(
2021-03-06 19:23:17 +00:00
theme.NewThemedResource(resourcePageLayoutSidebarRightSvg),
2020-10-15 22:38:15 +00:00
func() {
w := s.devices.w
if w.Visible() {
w.Hide()
} else {
w.Show()
}
}))
return tb
}