mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
feat(tracker/gioui): using mouse to select rectangles in tables
This commit is contained in:
parent
04ca0a3f6e
commit
00b8e1872a
@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
|
- Dragging mouse to select rectangles in the tables
|
||||||
- The standalone tracker can open a MIDI port for receiving MIDI notes
|
- The standalone tracker can open a MIDI port for receiving MIDI notes
|
||||||
([#166][i166])
|
([#166][i166])
|
||||||
- Units can have comments, to make it easier to distinguish between units of
|
- Units can have comments, to make it easier to distinguish between units of
|
||||||
|
@ -26,6 +26,8 @@ type ScrollTable struct {
|
|||||||
requestFocus bool
|
requestFocus bool
|
||||||
cursorMoved bool
|
cursorMoved bool
|
||||||
eventFilters []event.Filter
|
eventFilters []event.Filter
|
||||||
|
drag bool
|
||||||
|
dragID pointer.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
type ScrollTableStyle struct {
|
type ScrollTableStyle struct {
|
||||||
@ -49,7 +51,7 @@ func NewScrollTable(table tracker.Table, vertList, horizList tracker.List) *Scro
|
|||||||
ret.eventFilters = []event.Filter{
|
ret.eventFilters = []event.Filter{
|
||||||
key.FocusFilter{Target: ret},
|
key.FocusFilter{Target: ret},
|
||||||
transfer.TargetFilter{Target: ret, Type: "application/text"},
|
transfer.TargetFilter{Target: ret, Type: "application/text"},
|
||||||
pointer.Filter{Target: ret, Kinds: pointer.Press},
|
pointer.Filter{Target: ret, Kinds: pointer.Press | pointer.Drag | pointer.Release | pointer.Cancel},
|
||||||
key.Filter{Focus: ret, Name: key.NameLeftArrow, Optional: key.ModShift | key.ModCtrl | key.ModAlt},
|
key.Filter{Focus: ret, Name: key.NameLeftArrow, Optional: key.ModShift | key.ModCtrl | key.ModAlt},
|
||||||
key.Filter{Focus: ret, Name: key.NameUpArrow, Optional: key.ModShift | key.ModCtrl | key.ModAlt},
|
key.Filter{Focus: ret, Name: key.NameUpArrow, Optional: key.ModShift | key.ModCtrl | key.ModAlt},
|
||||||
key.Filter{Focus: ret, Name: key.NameRightArrow, Optional: key.ModShift | key.ModCtrl | key.ModAlt},
|
key.Filter{Focus: ret, Name: key.NameRightArrow, Optional: key.ModShift | key.ModCtrl | key.ModAlt},
|
||||||
@ -138,6 +140,18 @@ func (s *ScrollTableStyle) handleEvents(gtx layout.Context, p image.Point) {
|
|||||||
case key.FocusEvent:
|
case key.FocusEvent:
|
||||||
s.ScrollTable.focused = e.Focus
|
s.ScrollTable.focused = e.Focus
|
||||||
case pointer.Event:
|
case pointer.Event:
|
||||||
|
switch e.Kind {
|
||||||
|
case pointer.Press:
|
||||||
|
if s.ScrollTable.drag {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
s.ScrollTable.dragID = e.PointerID
|
||||||
|
s.ScrollTable.drag = true
|
||||||
|
fallthrough
|
||||||
|
case pointer.Drag:
|
||||||
|
if s.ScrollTable.dragID != e.PointerID {
|
||||||
|
break
|
||||||
|
}
|
||||||
if int(e.Position.X) < p.X || int(e.Position.Y) < p.Y {
|
if int(e.Position.X) < p.X || int(e.Position.Y) < p.Y {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -150,11 +164,16 @@ func (s *ScrollTableStyle) handleEvents(gtx layout.Context, p image.Point) {
|
|||||||
dy := (e.Position.Y + float32(s.ScrollTable.RowTitleList.List.Position.Offset)) / float32(gtx.Dp(s.CellHeight))
|
dy := (e.Position.Y + float32(s.ScrollTable.RowTitleList.List.Position.Offset)) / float32(gtx.Dp(s.CellHeight))
|
||||||
x := dx + float32(s.ScrollTable.ColTitleList.List.Position.First)
|
x := dx + float32(s.ScrollTable.ColTitleList.List.Position.First)
|
||||||
y := dy + float32(s.ScrollTable.RowTitleList.List.Position.First)
|
y := dy + float32(s.ScrollTable.RowTitleList.List.Position.First)
|
||||||
|
s.ScrollTable.Table.SetCursor2(tracker.Point{X: int(x), Y: int(y)})
|
||||||
|
if e.Kind == pointer.Press && !e.Modifiers.Contain(key.ModShift) {
|
||||||
s.ScrollTable.Table.SetCursorFloat(x, y)
|
s.ScrollTable.Table.SetCursorFloat(x, y)
|
||||||
if !e.Modifiers.Contain(key.ModShift) {
|
|
||||||
s.ScrollTable.Table.SetCursor2(s.ScrollTable.Table.Cursor())
|
|
||||||
}
|
}
|
||||||
s.ScrollTable.cursorMoved = true
|
s.ScrollTable.cursorMoved = true
|
||||||
|
case pointer.Release:
|
||||||
|
fallthrough
|
||||||
|
case pointer.Cancel:
|
||||||
|
s.ScrollTable.drag = false
|
||||||
|
}
|
||||||
case key.Event:
|
case key.Event:
|
||||||
if e.State == key.Press {
|
if e.State == key.Press {
|
||||||
s.ScrollTable.command(gtx, e)
|
s.ScrollTable.command(gtx, e)
|
||||||
|
Loading…
Reference in New Issue
Block a user