Sidebar
This commit is contained in:
parent
9395c2ffb3
commit
91e6eb6f6d
3
go.mod
3
go.mod
|
@ -11,6 +11,5 @@ require (
|
||||||
github.com/veandco/go-sdl2 v0.4.0
|
github.com/veandco/go-sdl2 v0.4.0
|
||||||
)
|
)
|
||||||
|
|
||||||
replace fyne.io/fyne => github.com/ivanizag/fyne v1.3.4-0.20201010160818-ed5402384cff
|
//replace fyne.io/fyne => github.com/ivanizag/fyne v1.3.4-0.20201010160818-ed5402384cff
|
||||||
|
|
||||||
// replace fyne.io/fyne => ../../fyne/fyne
|
// replace fyne.io/fyne => ../../fyne/fyne
|
||||||
|
|
|
@ -28,13 +28,15 @@ type joystickInfo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type joysticks struct {
|
type joysticks struct {
|
||||||
|
s *state
|
||||||
info [2]*joystickInfo
|
info [2]*joystickInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
const unplugged = uint8(255) // Max resistance when unplugged
|
const unplugged = uint8(255) // Max resistance when unplugged
|
||||||
|
|
||||||
func newJoysticks() *joysticks {
|
func newJoysticks(s *state) *joysticks {
|
||||||
var j joysticks
|
var j joysticks
|
||||||
|
j.s = s
|
||||||
return &j
|
return &j
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +50,9 @@ func (j *joysticks) start() {
|
||||||
case <-pool.C:
|
case <-pool.C:
|
||||||
j.info[0] = j.queryJoystick(glfw.Joystick1)
|
j.info[0] = j.queryJoystick(glfw.Joystick1)
|
||||||
j.info[1] = j.queryJoystick(glfw.Joystick2)
|
j.info[1] = j.queryJoystick(glfw.Joystick2)
|
||||||
|
|
||||||
|
j.s.devices.joystick.updateJoy1(j.info[0])
|
||||||
|
j.s.devices.joystick.updateJoy2(j.info[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
|
@ -113,20 +113,17 @@ func (k *keyboard) putKey(keyEvent *fyne.KeyEvent) {
|
||||||
case fyne.KeyF11:
|
case fyne.KeyF11:
|
||||||
k.s.a.SendCommand(izapple2.CommandToggleCPUTrace)
|
k.s.a.SendCommand(izapple2.CommandToggleCPUTrace)
|
||||||
case fyne.KeyF12:
|
case fyne.KeyF12:
|
||||||
case fyne.KeyPrintScreen:
|
//case fyne.KeyPrintScreen:
|
||||||
err := izapple2.SaveSnapshot(k.s.a, "snapshot.png")
|
err := izapple2.SaveSnapshot(k.s.a, "snapshot.png")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error saving snapshoot: %v.\n.", err)
|
fmt.Printf("Error saving snapshoot: %v.\n.", err)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Saving snapshot")
|
fmt.Println("Saving snapshot")
|
||||||
}
|
}
|
||||||
case fyne.KeyPause:
|
//case fyne.KeyPause:
|
||||||
k.s.a.SendCommand(izapple2.CommandPauseUnpauseEmulator)
|
// k.s.a.SendCommand(izapple2.CommandPauseUnpauseEmulator)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Missing values 91 to 95. Usually control for [\]^_
|
|
||||||
// On the Base64A it's control for \]./
|
|
||||||
|
|
||||||
if result != 0 {
|
if result != 0 {
|
||||||
k.keyChannel.PutChar(result)
|
k.keyChannel.PutChar(result)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ type state struct {
|
||||||
app fyne.App
|
app fyne.App
|
||||||
win fyne.Window
|
win fyne.Window
|
||||||
|
|
||||||
|
devices *panelDevices
|
||||||
|
|
||||||
showPages bool
|
showPages bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,11 +44,66 @@ func main() {
|
||||||
|
|
||||||
func fyneRun(s *state) {
|
func fyneRun(s *state) {
|
||||||
s.app = app.New()
|
s.app = app.New()
|
||||||
// app.SetIcon(xxx)
|
s.app.SetIcon(resourceApple2Png)
|
||||||
s.win = s.app.NewWindow("iz-" + s.a.Name)
|
s.win = s.app.NewWindow("iz-" + s.a.Name)
|
||||||
// window.SetIcon(xxx)
|
s.win.SetIcon(resourceApple2Png)
|
||||||
|
|
||||||
bottom := widget.NewToolbar(
|
s.devices = newPanelDevices(s)
|
||||||
|
toolbar := buildToolbar(s)
|
||||||
|
screen := canvas.NewImageFromImage(nil)
|
||||||
|
//screen.SetMinSize(fyne.NewSize(380, 192))
|
||||||
|
screen.SetMinSize(fyne.NewSize(280*2, 192*2))
|
||||||
|
|
||||||
|
container := fyne.NewContainerWithLayout(
|
||||||
|
layout.NewBorderLayout(nil, toolbar, nil, s.devices.w),
|
||||||
|
screen, toolbar, s.devices.w,
|
||||||
|
)
|
||||||
|
s.win.SetContent(container)
|
||||||
|
s.win.SetPadded(false)
|
||||||
|
|
||||||
|
registerKeyboardEvents(s)
|
||||||
|
j := newJoysticks(s)
|
||||||
|
j.start()
|
||||||
|
s.a.SetJoysticksProvider(j)
|
||||||
|
|
||||||
|
go s.a.Run()
|
||||||
|
|
||||||
|
ticker := time.NewTicker(60 * time.Millisecond)
|
||||||
|
done := make(chan bool)
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
case <-ticker.C:
|
||||||
|
if !s.a.IsPaused() {
|
||||||
|
var img *image.RGBA
|
||||||
|
if s.showPages {
|
||||||
|
img = s.a.SnapshotParts()
|
||||||
|
s.win.SetTitle(fmt.Sprintf("%v %v %vx%v", s.a.Name, s.a.VideoModeName(), img.Rect.Dx()/2, img.Rect.Dy()/2))
|
||||||
|
} else {
|
||||||
|
img = s.a.Snapshot()
|
||||||
|
}
|
||||||
|
screen.Image = img
|
||||||
|
canvas.Refresh(screen)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
s.win.SetOnClosed(func() {
|
||||||
|
done <- true
|
||||||
|
})
|
||||||
|
|
||||||
|
s.win.Show()
|
||||||
|
|
||||||
|
fmt.Printf("%v\n", s.win.Canvas().Scale())
|
||||||
|
|
||||||
|
s.app.Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildToolbar(s *state) *widget.Toolbar {
|
||||||
|
return widget.NewToolbar(
|
||||||
widget.NewToolbarAction(
|
widget.NewToolbarAction(
|
||||||
theme.NewThemedResource(resourceRestartSvg, nil), func() {
|
theme.NewThemedResource(resourceRestartSvg, nil), func() {
|
||||||
s.a.SendCommand(izapple2.CommandReset)
|
s.a.SendCommand(izapple2.CommandReset)
|
||||||
|
@ -88,54 +145,16 @@ func fyneRun(s *state) {
|
||||||
widget.NewToolbarAction(theme.ViewFullScreenIcon(), func() {
|
widget.NewToolbarAction(theme.ViewFullScreenIcon(), func() {
|
||||||
s.win.SetFullScreen(!s.win.FullScreen())
|
s.win.SetFullScreen(!s.win.FullScreen())
|
||||||
}),
|
}),
|
||||||
)
|
widget.NewToolbarAction(
|
||||||
|
theme.NewThemedResource(resourcePageLayoutSidebarRightSvg, nil), func() {
|
||||||
screen := canvas.NewImageFromImage(nil)
|
w := s.devices.w
|
||||||
screen.SetMinSize(fyne.NewSize(380, 192))
|
if w.Visible() {
|
||||||
container := fyne.NewContainerWithLayout(
|
w.Hide()
|
||||||
layout.NewBorderLayout(nil, bottom, nil, nil),
|
} else {
|
||||||
screen, bottom,
|
w.Show()
|
||||||
)
|
|
||||||
s.win.SetContent(container)
|
|
||||||
s.win.SetPadded(false)
|
|
||||||
|
|
||||||
registerKeyboardEvents(s)
|
|
||||||
j := newJoysticks()
|
|
||||||
j.start()
|
|
||||||
s.a.SetJoysticksProvider(j)
|
|
||||||
|
|
||||||
go s.a.Run()
|
|
||||||
|
|
||||||
ticker := time.NewTicker(60 * time.Millisecond)
|
|
||||||
done := make(chan bool)
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
return
|
|
||||||
case <-ticker.C:
|
|
||||||
if !s.a.IsPaused() {
|
|
||||||
var img *image.RGBA
|
|
||||||
if s.showPages {
|
|
||||||
img = s.a.SnapshotParts()
|
|
||||||
s.win.SetTitle(fmt.Sprintf("%v %v %vx%v", s.a.Name, s.a.VideoModeName(), img.Rect.Dx()/2, img.Rect.Dy()/2))
|
|
||||||
} else {
|
|
||||||
img = s.a.Snapshot()
|
|
||||||
}
|
|
||||||
screen.Image = img
|
|
||||||
canvas.Refresh(screen)
|
|
||||||
}
|
}
|
||||||
}
|
}),
|
||||||
}
|
)
|
||||||
}()
|
|
||||||
|
|
||||||
s.win.SetOnClosed(func() {
|
|
||||||
done <- true
|
|
||||||
})
|
|
||||||
|
|
||||||
s.win.Show()
|
|
||||||
s.app.Run()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerKeyboardEvents(s *state) {
|
func registerKeyboardEvents(s *state) {
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fyne.io/fyne"
|
||||||
|
"fyne.io/fyne/widget"
|
||||||
|
)
|
||||||
|
|
||||||
|
type panelDevices struct {
|
||||||
|
s *state
|
||||||
|
w fyne.Widget
|
||||||
|
joystick *panelJoystick
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPanelDevices(s *state) *panelDevices {
|
||||||
|
var pd panelDevices
|
||||||
|
pd.s = s
|
||||||
|
|
||||||
|
pd.joystick = newPanelJoystick()
|
||||||
|
|
||||||
|
pd.w = widget.NewVBox(pd.joystick.w)
|
||||||
|
|
||||||
|
return &pd
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fyne.io/fyne"
|
||||||
|
"fyne.io/fyne/widget"
|
||||||
|
)
|
||||||
|
|
||||||
|
type panelJoystick struct {
|
||||||
|
w fyne.Widget
|
||||||
|
labelJoy1 *widget.Label
|
||||||
|
labelJoy2 *widget.Label
|
||||||
|
}
|
||||||
|
|
||||||
|
const textJoystickNotAvailable = "unplugged"
|
||||||
|
|
||||||
|
func newPanelJoystick() *panelJoystick {
|
||||||
|
var pj panelJoystick
|
||||||
|
|
||||||
|
pj.labelJoy1 = widget.NewLabel("")
|
||||||
|
pj.labelJoy2 = widget.NewLabel("")
|
||||||
|
widget.NewForm()
|
||||||
|
pj.w = widget.NewGroup(
|
||||||
|
"Joysticks",
|
||||||
|
widget.NewForm(
|
||||||
|
widget.NewFormItem("Joystick 1", pj.labelJoy1),
|
||||||
|
widget.NewFormItem("Joystick 2", pj.labelJoy2),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
return &pj
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pj *panelJoystick) updateJoy1(info *joystickInfo) {
|
||||||
|
newName := textJoystickNotAvailable
|
||||||
|
if info != nil {
|
||||||
|
newName = info.name
|
||||||
|
}
|
||||||
|
if newName != pj.labelJoy1.Text {
|
||||||
|
pj.labelJoy1.SetText(newName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pj *panelJoystick) updateJoy2(info *joystickInfo) {
|
||||||
|
newName := textJoystickNotAvailable
|
||||||
|
if info != nil {
|
||||||
|
newName = info.name
|
||||||
|
}
|
||||||
|
if newName != pj.labelJoy2.Text {
|
||||||
|
pj.labelJoy2.SetText(newName)
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
|
@ -0,0 +1 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M14,8V16H18V8H14Z" /></svg>
|
After Width: | Height: | Size: 386 B |
|
@ -10,6 +10,9 @@
|
||||||
- layers-triple
|
- layers-triple
|
||||||
- format-font
|
- format-font
|
||||||
- camera
|
- camera
|
||||||
|
- page-layout-sidebar-right
|
||||||
|
|
||||||
|
- https://www.iconfinder.com/icons/281710/rainbow_apple_icon
|
||||||
|
|
||||||
## Building resources.go
|
## Building resources.go
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue