Skip to content

Commit

Permalink
osx: add gesture support
Browse files Browse the repository at this point in the history
  • Loading branch information
sqweek committed Apr 16, 2016
1 parent 805bb27 commit 780d12d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sqribe_wde.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ func event(win wde.Window, redraw chan Widget, done chan bool, wg *sync.WaitGrou
cur = G.ww.MouseMoved(e.Where)
}
win.SetCursor(cur)
case wde.ScrollEvent:
G.ww.ScrollPixels(-e.Delta.X)
case wde.MagnifyEvent:
G.ww.Zoom(1.0 / e.Magnification)
case wde.KeyDownEvent:
switch e.Key {
case wde.KeyLeftShift, wde.KeyRightShift:
Expand Down
7 changes: 7 additions & 0 deletions ww.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,13 @@ func (ww *WaveWidget) ScrollPixels(dx int) int {

func (ww *WaveWidget) Zoom(factor float64) float64 {
fpp := int(float64(ww.frames_per_pixel) * factor)
if fpp == ww.frames_per_pixel {
if factor < 1.0 {
fpp--
} else if factor > 1.0 {
fpp++
}
}
if fpp < 1 {
fpp = 1
}
Expand Down

0 comments on commit 780d12d

Please sign in to comment.