Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement focus and keyboard controls for slider #3531

Merged
merged 18 commits into from
Feb 28, 2023

Conversation

Jacalz
Copy link
Member

@Jacalz Jacalz commented Jan 2, 2023

Description:

This implements focus and hover for the slider widget to make it follow the material design guidelines better.
I have also added support for moving the slider using the arrow keys.

For #1515

Opening as draft for now until I have fixed some things and added tests.

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

@coveralls
Copy link

coveralls commented Jan 2, 2023

Coverage Status

Coverage: 61.685% (+0.06%) from 61.623% when pulling 108c364 on Jacalz:slider-navigation into ce3e287 on fyne-io:develop.

@andydotxyz
Copy link
Member

This is really nice.
Not sure about the gap in the middle of the focused indicator - is that according to material, or could we make it solid and/or a wider gap in the middle?

@Jacalz
Copy link
Member Author

Jacalz commented Jan 3, 2023

Hmm. I don't know why there is a gap in the middle. I am just using the circle stroke. Shouldn't that just be outside of the fill?

@andydotxyz
Copy link
Member

Stroke is half inside half outside the fill. To make it fully outside set the stroke to half the size and increase the circle diameter by stroke (and move it up/left by stroke/2)

@Jacalz
Copy link
Member Author

Jacalz commented Jan 8, 2023

Hmm. I don't think that will work as the stroke colour is partly transparent. Will revert back to using two circles instead.

@Jacalz Jacalz marked this pull request as ready for review January 8, 2023 17:34
@Jacalz
Copy link
Member Author

Jacalz commented Jan 8, 2023

I have one strange issue that I don't know why it is happening. The focus circle seems to be one pixel too far to the right on my screen. Any ideas why? Rounding error?

@andydotxyz
Copy link
Member

I have one strange issue that I don't know why it is happening. The focus circle seems to be one pixel too far to the right on my screen. Any ideas why? Rounding error?

Looking at the markup test files they don't have the same centre point

@andydotxyz
Copy link
Member

I see an off-by-one but only because it's not possible to align centrally with current numbers I think?

slidezoom

@@ -321,6 +387,11 @@ func (s *sliderRenderer) Layout(size fyne.Size) {

s.thumb.Move(thumbPos)
s.thumb.Resize(fyne.NewSize(diameter, diameter))

focusIndicatorSize := fyne.NewSize(theme.IconInlineSize()+theme.InnerPadding(), theme.IconInlineSize()+theme.InnerPadding())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe if this was coded relative to the calculated diameter (i.e. diameter+theme.InnerPadding()) the issue may be resolved? Just wondering as it could be a rounding error somewhere and that might work around it...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that initially but had some issues with getting the size to match the radio buttons. Will have a shot at it again though :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried a lot of things to work around the possible rounding error but to no avail (even tried using theme.InnerPadding() + 1.75 which the delta variable becomes if simplified). I have no idea how to take this further with this issue unfortunately. I would appreciate some help if you have the time 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that the code should be mostly fine in all other areas though. I have just added the remaining comments, moved some methods around to be in alphabetical order and fixed tap focus to work correctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks to be solved now thanks to your slider wobble fix :)

@Jacalz
Copy link
Member Author

Jacalz commented Feb 12, 2023

I will rebase (and fix the merge conflicts) once #3651 has landed :)

andydotxyz
andydotxyz previously approved these changes Feb 20, 2023
Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now thanks.
I wonder though - should we have "since" headers on methods that are just added for getting signals from the driver? Not sure so accepting in case it's not a thing to add.

@Jacalz
Copy link
Member Author

Jacalz commented Feb 26, 2023

I had to rebase onto develop to get the workflows to pass. I also added the "Since 2.4" comments. I think it makes sense to be consistent even though they are mostly meant to be used by the driver :)

@Jacalz Jacalz merged commit 4cb4e93 into fyne-io:develop Feb 28, 2023
@Jacalz Jacalz deleted the slider-navigation branch February 28, 2023 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants