Skip to content

Commit

Permalink
Add cursor hiding
Browse files Browse the repository at this point in the history
Update gotk3 dep

When in fullscreen the cursor will now hide when the hud hides
Updated gotk3 to get the latest changes
  • Loading branch information
mftb0 committed Feb 15, 2024
1 parent 1f0c5eb commit 95ed0a9
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/cbxv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

const (
NAME = "cbxv"
VERSION = "0.5.1"
VERSION = "0.5.2"
)

// Update listens for messages on the message channel and
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/gen2brain/go-unarr v0.2.0
github.com/gotk3/gotk3 v0.6.2
github.com/gotk3/gotk3 v0.6.3
github.com/pdfcpu/pdfcpu v0.6.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/gen2brain/go-unarr v0.2.0 h1:sYKSjbeNSuZgudd59iGAbMbr113XRFoA7Rt9XWA+QVE=
github.com/gen2brain/go-unarr v0.2.0/go.mod h1:hoHheVuf0KT8/hfvkEL7GMwj2h7fq0lF72NdyySdr3c=
github.com/gotk3/gotk3 v0.6.2 h1:sx/PjaKfKULJPTPq8p2kn2ZbcNFxpOJqi4VLzMbEOO8=
github.com/gotk3/gotk3 v0.6.2/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
github.com/gotk3/gotk3 v0.6.3 h1:+Ke4WkM1TQUNOlM2TZH6szqknqo+zNbX3BZWVXjSHYw=
github.com/gotk3/gotk3 v0.6.3/go.mod h1:/hqFpkNa9T3JgNAE2fLvCdov7c5bw//FHNZrZ3Uv9/Q=
github.com/hhrutter/lzw v1.0.0 h1:laL89Llp86W3rRs83LvKbwYRx6INE8gDn0XNb1oXtm0=
github.com/hhrutter/lzw v1.0.0/go.mod h1:2HC6DJSn/n6iAZfgM3Pg+cP1KxeWc3ezG8bBqW5+WEo=
github.com/hhrutter/tiff v1.0.1 h1:MIus8caHU5U6823gx7C6jrfoEvfSTGtEFRiM8/LOzC0=
Expand Down
7 changes: 7 additions & 0 deletions internal/ui/pageview.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func NewPageView(m *model.Model, u *UI, messenger util.Messenger) View {
if !v.hudHidden && !v.hudKeepAlive {
v.hdrControl.container.Hide()
v.navControl.container.Hide()
if m.Fullscreen {
v.ui.HideCursor()
}
u.MainWindow.QueueDraw()
v.hudHidden = true
} else {
Expand All @@ -82,6 +85,7 @@ func (v *PageView) newHUD(m *model.Model, u *UI) *gtk.Overlay {
v.navControl = NewNavControl(m, u)
o.AddOverlay(v.hdrControl.container)
o.AddOverlay(v.navControl.container)
v.ui.ShowCursor()
v.hudHidden = false

return o
Expand All @@ -103,6 +107,7 @@ func (v *PageView) Connect(m *model.Model, u *UI) {
}

v.hud.ShowAll()
v.ui.ShowCursor()
v.hudHidden = false
v.hudKeepAlive = true
return true
Expand Down Expand Up @@ -153,6 +158,7 @@ func (v *PageView) initRenderer(m *model.Model) {
//reset the hud hiding
v.hdrControl.container.Show()
v.navControl.container.Show()
v.ui.ShowCursor()
v.hudHidden = false
v.hudKeepAlive = true
}
Expand All @@ -173,6 +179,7 @@ func (v *PageView) initRenderer(m *model.Model) {
}
//reset the hud hiding
v.hud.ShowAll()
v.ui.ShowCursor()
v.hudHidden = false
v.hudKeepAlive = true
return r
Expand Down
6 changes: 6 additions & 0 deletions internal/ui/stripview.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func NewStripView(m *model.Model, u *UI) View {

v.scrollbars.Connect("scroll-event", func() {
v.hud.ShowAll()
v.ui.ShowCursor()
v.hudHidden = false
v.hudKeepAlive = true
})
Expand All @@ -63,6 +64,9 @@ func NewStripView(m *model.Model, u *UI) View {
v.hdrControl.container.Hide()
v.navControl.container.Hide()
u.MainWindow.QueueDraw()
if m.Fullscreen {
u.HideCursor()
}
v.hudHidden = true
} else {
v.hudKeepAlive = false
Expand All @@ -84,6 +88,7 @@ func (v *StripView) Connect(m *model.Model, u *UI) {
}

v.hud.ShowAll()
u.ShowCursor()
v.hudHidden = false
v.hudKeepAlive = true
})
Expand Down Expand Up @@ -142,6 +147,7 @@ func (v *StripView) newHUD(m *model.Model, u *UI) *gtk.Overlay {
v.navControl = NewStripViewNavControl(m, u)
o.AddOverlay(v.hdrControl.container)
o.AddOverlay(v.navControl.container)
u.ShowCursor()
v.hudHidden = false

return o
Expand Down
20 changes: 20 additions & 0 deletions internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ func (u *UI) DisplayErrorDlg(message string) {
dlg.Run()
}

func (u *UI) ShowCursor() {
d, _ := gdk.DisplayGetDefault()
c, _ := gdk.CursorNewFromName(d, "default")
w, err := u.MainWindow.GetWindow()
if err != nil {
return
}
w.SetCursor(c)
}

func (u *UI) HideCursor() {
d, _ := gdk.DisplayGetDefault()
c, _ := gdk.CursorNewFromName(d, "none")
w, err := u.MainWindow.GetWindow()
if err != nil {
return
}
w.SetCursor(c)
}

func (u *UI) Render(m *model.Model) {
glib.IdleAdd(func() {
u.View.Render(m)
Expand Down

0 comments on commit 95ed0a9

Please sign in to comment.