Compare commits
8 Commits
2722d19ecd
...
v0.20.1
| Author | SHA1 | Date | |
|---|---|---|---|
| e0f4ecb509 | |||
| fc51ffe33c | |||
| 987f4bfc4a | |||
| b883542f3b | |||
| c8d33a0ef4 | |||
| 9fa764c7b9 | |||
| 84ab0895f8 | |||
| b9c77fd5f7 |
12
.editorconfig
Normal file
12
.editorconfig
Normal 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
2
go.mod
@@ -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
4
go.sum
@@ -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=
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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 ++
|
||||
|
||||
21
scrollbar.go
21
scrollbar.go
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user