mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 10:25:37 +00:00
ui/layout: rename List.Invert to ScrollToEnd
Much clearer. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+7
-8
@@ -22,9 +22,10 @@ type scrollChild struct {
|
|||||||
// the subsection.
|
// the subsection.
|
||||||
type List struct {
|
type List struct {
|
||||||
Axis Axis
|
Axis Axis
|
||||||
// Inverted lists stay scrolled to the far end position
|
// ScrollToEnd instructs the list to stay scrolled to the far end position
|
||||||
// until the user scrolls away.
|
// once reahed. A List with ScrollToEnd enabled also align its content to
|
||||||
Invert bool
|
// the end.
|
||||||
|
ScrollToEnd bool
|
||||||
// Alignment is the cross axis alignment of list elements.
|
// Alignment is the cross axis alignment of list elements.
|
||||||
Alignment Alignment
|
Alignment Alignment
|
||||||
|
|
||||||
@@ -78,8 +79,6 @@ func (l *List) Init(cfg ui.Config, q input.Queue, ops *ui.Ops, cs Constraints, l
|
|||||||
l.children = l.children[:0]
|
l.children = l.children[:0]
|
||||||
l.cs = cs
|
l.cs = cs
|
||||||
l.len = len
|
l.len = len
|
||||||
// Inverted lists scroll to the very end as long as the user hasn't
|
|
||||||
// scrolled away.
|
|
||||||
if l.scrollToEnd() {
|
if l.scrollToEnd() {
|
||||||
l.offset = 0
|
l.offset = 0
|
||||||
l.first = len
|
l.first = len
|
||||||
@@ -93,7 +92,7 @@ func (l *List) Init(cfg ui.Config, q input.Queue, ops *ui.Ops, cs Constraints, l
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *List) scrollToEnd() bool {
|
func (l *List) scrollToEnd() bool {
|
||||||
return l.Invert && !l.beforeEnd
|
return l.ScrollToEnd && !l.beforeEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dragging reports whether the List is being dragged.
|
// Dragging reports whether the List is being dragged.
|
||||||
@@ -217,8 +216,8 @@ func (l *List) Layout() Dimensions {
|
|||||||
}
|
}
|
||||||
ops := l.ops
|
ops := l.ops
|
||||||
pos := -l.offset
|
pos := -l.offset
|
||||||
// Inverted lists are end aligned.
|
// ScrollToEnd lists lists are end aligned.
|
||||||
if space := mainc.Max - size; l.Invert && space > 0 {
|
if space := mainc.Max - size; l.ScrollToEnd && space > 0 {
|
||||||
pos += space
|
pos += space
|
||||||
}
|
}
|
||||||
for _, child := range children {
|
for _, child := range children {
|
||||||
|
|||||||
Reference in New Issue
Block a user