~eliasnaur/gio-patches

gio: widget, widget/material: paint scrollbar as hovered while dragging it v1 PROPOSED

Dominik Honnef: 1
 widget, widget/material: paint scrollbar as hovered while dragging it

 2 files changed, 8 insertions(+), 2 deletions(-)
#790922 apple.yml success
#790923 freebsd.yml success
#790924 linux.yml success
#790925 openbsd.yml success
"Elias Naur" <mail@eliasnaur.com> writes:
Next
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~eliasnaur/gio-patches/patches/33398/mbox | git am -3
Learn more about email & git

[PATCH gio] widget, widget/material: paint scrollbar as hovered while dragging it Export this patch

Scrollbar.IndicatorHovered returns false while the scrollbar is being
dragged because Scrollbar.drag is grabbing the pointer while dragging.
Add a new method Dragging and use that. This would allow us to render
the indicator differently for hovering and dragging, but for now we just
draw it as hovered while it's being dragged.

Signed-off-by: Dominik Honnef <dominik@honnef.co>
---
 widget/list.go          | 8 +++++++-
 widget/material/list.go | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/widget/list.go b/widget/list.go
index ae395736..9c442943 100644
--- a/widget/list.go
+++ b/widget/list.go
@@ -163,7 +163,8 @@ func (s *Scrollbar) AddDrag(ops *op.Ops) {
}

// IndicatorHovered returns whether the scroll indicator is currently being
// hovered by the pointer.
// hovered by the pointer. Note that this returns false while the scrollbar
// is being dragged.
func (s *Scrollbar) IndicatorHovered() bool {
	return s.indicator.Hovered()
}
@@ -174,6 +175,11 @@ func (s *Scrollbar) ScrollDistance() float32 {
	return s.delta
}

// Dragging returns whether the scroll indicator is currently being dragged.
func (s *Scrollbar) Dragging() bool {
	return s.dragging
}

// List holds the persistent state for a layout.List that has a
// scrollbar attached.
type List struct {
diff --git a/widget/material/list.go b/widget/material/list.go
index 81a7c984..cc1a2b01 100644
--- a/widget/material/list.go
+++ b/widget/material/list.go
@@ -126,7 +126,7 @@ func (s ScrollbarStyle) Layout(gtx layout.Context, axis layout.Axis, viewportSta
	s.Scrollbar.Layout(gtx, axis, viewportStart, viewportEnd)

	// Darken indicator if hovered.
	if s.Scrollbar.IndicatorHovered() {
	if s.Scrollbar.IndicatorHovered() || s.Scrollbar.Dragging() {
		s.Indicator.Color = s.Indicator.HoverColor
	}

-- 
2.36.1
gio/patches: SUCCESS in 19m38s

[widget, widget/material: paint scrollbar as hovered while dragging it][0] from [Dominik Honnef][1]

[0]: https://lists.sr.ht/~eliasnaur/gio-patches/patches/33398
[1]: mailto:dominik@honnef.co

✓ #790923 SUCCESS gio/patches/freebsd.yml https://builds.sr.ht/~eliasnaur/job/790923
✓ #790924 SUCCESS gio/patches/linux.yml   https://builds.sr.ht/~eliasnaur/job/790924
✓ #790925 SUCCESS gio/patches/openbsd.yml https://builds.sr.ht/~eliasnaur/job/790925
✓ #790922 SUCCESS gio/patches/apple.yml   https://builds.sr.ht/~eliasnaur/job/790922