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

Make Button rendering consistent #4246

Merged
merged 10 commits into from
Sep 21, 2023
Merged

Make Button rendering consistent #4246

merged 10 commits into from
Sep 21, 2023

Conversation

pbrown12303
Copy link
Contributor

@pbrown12303 pbrown12303 commented Sep 13, 2023

Description:

Changed the default rendering of Button so that the animation background rectangle starts off with the same rendering as it has after the button has been clicked

Unfortunately, this affected all of the xml testdata files that contain buttons (87 of them). All test result files have been updated and the full fyne test suite passed with the excaption of some errors in internal/driver/glfw which do not appear to have anything to do with this change.

Fixes #4243

Checklist:

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

Where applicable:

For the docTabs.current < 0 case, modified this function to  call docTabsRenderer.moveIndicator (pos 0,0, size 0,0) to give consistent rendering when first drawn and after all tabs have been removed.
Changed initial rendering to match the result after a button click
@pbrown12303
Copy link
Contributor Author

This is strange. There is only one source file that got changed - all the rest are testdata .xml files. It's acting as if the test data did not get pushed before the tests were run.

@andydotxyz
Copy link
Member

Should "dialog-custom-custom-buttons.xml" be present?

@Jacalz
Copy link
Member

Jacalz commented Sep 14, 2023

@pbrown12303 Would you mind giving the PR a more descriptive title?

widget/button.go Outdated
Comment on lines 101 to 102
tapBG := canvas.NewRectangle(color.Transparent)
tapBG.FillColor = &color.NRGBA{R: 0, G: 0, B: 0, A: 0}
Copy link
Member

Choose a reason for hiding this comment

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

This seems strange. The canvas.NewRectangle() constructor already sets FillColor. Is this line really needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. The tap animation does not return the color to transparent (a nil color). It explicitly sets it to this value. The other alternative would be to alter the animation logic to return the color to nil at the end, but I think this would be a Pandora's box. I certainly do not know enough about animation to even begin to assess the feasibility of this kind of change.

Copy link
Member

Choose a reason for hiding this comment

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

What I am trying to say is that you can replace color.Transparent on the line above instead of setting the field directly after.

However, if this is just a workaround for the animation doing strange things it seems like we ought to fix the animation instead? We are using color.Transparent all over the place and if we need this workaround everywhere then something seems very wrong.

Thoughts? @andydotxyz

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I see. I didn't realize that the value supplied to the NewRectangle() function was the background color - I thought it was the line (edge) color.

With respect to the use of color.Transparent, I suspect it is only an issue with animation. I'll let you and @andydotxyz discuss and draw conclusions - I'll go with whatever you decide.

Copy link
Member

Choose a reason for hiding this comment

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

Colour.Transparent is not nil...

https://cs.opensource.google/go/go/+/refs/tags/go1.21.1:src/image/color/color.go%3Bl=345

not sure what nil is being referenced!

Copy link
Member

Choose a reason for hiding this comment

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

Indeed. That was my though as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I was wrong about transparent being nil: it is a struct with only the A value specified. In any case, I found a better fix. I modified the Button animation so that if the fade (i.e. the A value of the color) reaches zero, the assigned value for the bg.FillColor is color.Transparent, which was the default initial value. Updated test results accordingly.

@pbrown12303 pbrown12303 changed the title Develop Make Button rendering consistent Sep 14, 2023
@pbrown12303
Copy link
Contributor Author

@andydotxyz Added missing dialog-custom-custom-buttons.xml

Removed explicit setting of tapBG.FillColor in CreateRenderer
Changed bg.FillColor assignment logic in newButtonTabAnimation so that if the fade reaches zero, the assigned color is color.Transparent
Updated xml rendering test results to reflect this change.
@pbrown12303
Copy link
Contributor Author

Looks like the expected test results did not get pushed before the tests were run.

@andydotxyz
Copy link
Member

Looks like the expected test results did not get pushed before the tests were run.

GitHub doesn't usually get the order wrong. Are you sure all the fixes are pushed?

@pbrown12303
Copy link
Contributor Author

Everything is pushed. GitHub has no way of knowing the relationship between the _test.go files and the .xml test results. The only linkages are the quoted text strings that are the arguments to the test.Assert... functions.

@Jacalz
Copy link
Member

Jacalz commented Sep 19, 2023

GitHub has no way of knowing the relationship between the _test.go files and the .xml test results. The only linkages are the quoted text strings that are the arguments to the test.Assert... functions

That doesn't seem very likely. All other tests (except for a few spurious tests failing sometimes) are passing

@andydotxyz
Copy link
Member

Everything is pushed. GitHub has no way of knowing the relationship between the _test.go files and the .xml test results. The only linkages are the quoted text strings that are the arguments to the test.Assert... functions.

GitHub doesn't understand it true - but it does know when a commit has been pushed and will clearly wait for all the files to be present before it starts the CI run...

@andydotxyz
Copy link
Member

It looks to me that both failures came from the same test case. I have asked it to re-run just in case, but it seems to me that "go test -tags mobile ./..." is failing every time and for the same reason.

@pbrown12303
Copy link
Contributor Author

Interesting - although the mobile tests showed PASS on windows 10, the tests were never executed. I updated the test results manually - I hope I got all of them. Is there a mechanism for running the mobile tests on a Windows 10 platform?

@Jacalz
Copy link
Member

Jacalz commented Sep 20, 2023

I don't think the mobile driver supports running in Windows?

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.

Great thanks for the tidy here

@andydotxyz
Copy link
Member

Looks good to me - @Jacalz ?

Copy link
Member

@Jacalz Jacalz 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. Thanks

@Jacalz Jacalz merged commit 6fe81db into fyne-io:develop Sep 21, 2023
andydotxyz pushed a commit that referenced this pull request Nov 17, 2023
Changed the default rendering of Button so that the animation background rectangle starts off with the same rendering as it has after the button has been clicked
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.

3 participants