8 Commits

Author SHA1 Message Date
e0f4ecb509 Update Tomo API to v0.41.1 2024-07-27 15:04:41 -04:00
fc51ffe33c Fix flow layout 2024-07-27 14:41:46 -04:00
987f4bfc4a Remove random semicolons 2024-07-27 02:17:41 -04:00
b883542f3b Add .editorconfig 2024-07-27 02:10:00 -04:00
c8d33a0ef4 Fix keys for Scrollbar 2024-07-27 00:54:40 -04:00
9fa764c7b9 ScrollContainer can step scroll with normal up/down 2024-07-27 00:35:17 -04:00
84ab0895f8 Fix TextView scrolling 2024-07-27 00:19:53 -04:00
b9c77fd5f7 ScrollContainer properly responds to pgup/down 2024-07-27 00:19:31 -04:00
8 changed files with 51 additions and 19 deletions

12
.editorconfig Normal file
View File

@@ -0,0 +1,12 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 8
charset = utf-8
[*.md]
indent_style = space
indent_size = 2

2
go.mod
View File

@@ -2,6 +2,6 @@ module git.tebibyte.media/tomo/objects
go 1.20
require git.tebibyte.media/tomo/tomo v0.41.0
require git.tebibyte.media/tomo/tomo v0.41.1
require golang.org/x/image v0.11.0 // indirect

4
go.sum
View File

@@ -1,5 +1,5 @@
git.tebibyte.media/tomo/tomo v0.41.0 h1:Z+7FHhbGiKjs+kQNvuJOfz47xIct5qxvSJqyDuoNIOs=
git.tebibyte.media/tomo/tomo v0.41.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
git.tebibyte.media/tomo/tomo v0.41.1 h1:XdbyF3VjsLj1Zppr70gUaufuh49hU32JQo2ENnw4PcA=
git.tebibyte.media/tomo/tomo v0.41.1/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=

View File

@@ -45,13 +45,14 @@ func (flow Flow) Arrange (hints tomo.LayoutHints, boxes tomo.BoxArranger) {
index := 0
for index < boxes.Len() {
// get a slice of boxes for this major step
stepIndexEnd := index + minorSteps
stepIndexStart := index
stepIndexEnd := index + minorSteps
if stepIndexEnd > boxes.Len() { stepIndexEnd = boxes.Len() }
index += minorSteps
// find a major size that will fit all boxes on this major step
majorSize := 0
for index := index; index < stepIndexEnd; index ++ {
for index := stepIndexStart; index < stepIndexEnd; index ++ {
boxSize := flow.major(boxes.MinimumSize(index))
if boxSize > majorSize { majorSize = boxSize }
}
@@ -61,7 +62,7 @@ func (flow Flow) Arrange (hints tomo.LayoutHints, boxes tomo.BoxArranger) {
var size image.Point
size = flow.incrMajor(size, majorSize)
size = flow.incrMinor(size, minorSize)
for index := index; index < stepIndexEnd; index ++ {
for index := stepIndexStart; index < stepIndexEnd; index ++ {
bounds := image.Rectangle { Min: point, Max: point.Add(size) }
boxes.SetBounds(index, bounds)

View File

@@ -50,7 +50,7 @@ func (column Column) Arrange (hints tomo.LayoutHints, boxes tomo.BoxArranger) {
if !hints.OverflowY {
gaps := boxes.Len() - 1
freeSpace := float64(hints.Bounds.Dy() - hints.Gap.Y * gaps)
nExpanding := 0;
nExpanding := 0
for index := 0; index < boxes.Len(); index ++ {
if expands(index) {
nExpanding ++
@@ -121,7 +121,7 @@ func (row Row) Arrange (hints tomo.LayoutHints, boxes tomo.BoxArranger) {
if !hints.OverflowY {
gaps := boxes.Len() - 1
freeSpace := float64(hints.Bounds.Dx() - hints.Gap.X * gaps)
nExpanding := 0;
nExpanding := 0
for index := 0; index < boxes.Len(); index ++ {
if expands(index) {
nExpanding ++

View File

@@ -141,19 +141,15 @@ func (this *Scrollbar) handleKeyUp (key input.Key, numpad bool) bool {
switch key {
case input.KeyUp, input.KeyLeft: return true
case input.KeyDown, input.KeyRight: return true
case input.KeyHome: return true
case input.KeyEnd: return true
case input.KeyPageUp: return true
case input.KeyPageDown: return true
case input.KeyHome: return true
case input.KeyEnd: return true
}
return false
}
func (this *Scrollbar) handleKeyDown (key input.Key, numpad bool) bool {
var increment float64; if this.layout.vertical {
increment = -0.05
} else {
increment = 0.05
}
modifiers := this.Window().Modifiers()
switch key {
@@ -161,15 +157,20 @@ func (this *Scrollbar) handleKeyDown (key input.Key, numpad bool) bool {
if modifiers.Alt {
this.SetValue(0)
} else {
this.SetValue(this.Value() - increment)
this.scrollBy(this.StepSize())
}
return true
case input.KeyDown, input.KeyRight:
if modifiers.Alt {
this.SetValue(1)
} else {
this.SetValue(this.Value() + increment)
this.scrollBy(-this.StepSize())
}
case input.KeyPageUp:
this.scrollBy(this.PageSize())
return true
case input.KeyPageDown:
this.scrollBy(-this.PageSize())
return true
case input.KeyHome:
this.SetValue(0)

View File

@@ -200,6 +200,7 @@ func (this *ScrollContainer) handleKeyDown (key input.Key, numpad bool) bool {
} else {
vector.Y -= this.PageSize().Y
}
this.scrollBy(vector)
return true
case input.KeyPageDown:
if modifiers.Shift {
@@ -207,6 +208,23 @@ func (this *ScrollContainer) handleKeyDown (key input.Key, numpad bool) bool {
} else {
vector.Y += this.PageSize().Y
}
this.scrollBy(vector)
return true
case input.KeyUp:
if modifiers.Shift {
vector.X -= this.StepSize().X
} else {
vector.Y -= this.StepSize().Y
}
this.scrollBy(vector)
return true
case input.KeyDown:
if modifiers.Shift {
vector.X += this.StepSize().X
} else {
vector.Y += this.StepSize().Y
}
this.scrollBy(vector)
return true
}
return false

View File

@@ -22,6 +22,6 @@ func NewTextView (text string) *TextView {
}
func (this *TextView) handleScroll (x, y float64) bool {
this.ScrollTo(this.ContentBounds().Min.Add(image.Pt(int(x), int(y))))
this.ScrollTo(this.ContentBounds().Min.Sub(image.Pt(int(x), int(y))))
return true
}