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

Remove the need to hook resources in for overriding in theme override #4926

Merged
merged 10 commits into from
Jun 14, 2024

Conversation

andydotxyz
Copy link
Member

@andydotxyz andydotxyz commented Jun 11, 2024

Description:

Fixes #4596

Checklist:

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

@coveralls
Copy link

Coverage Status

coverage: 65.636% (+0.07%) from 65.57%
when pulling 4a3c3bd on andydotxyz:fix/overrideicon
into 55b4f95 on fyne-io:develop.

canvas/image.go Outdated
return io.NopCloser(bytes.NewReader(i.Resource.Content())), nil
content := i.Resource.Content()
if res, ok := i.Resource.(fyne.ThemedResource); i.isSVG && ok {

Copy link
Member

Choose a reason for hiding this comment

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

I think, this empty line can be deleted.

o.Refresh()
changed := w.Canvas().Capture().(*image.NRGBA)

assert.NotEqual(t, plain.Pix, changed.Pix)
Copy link
Member

Choose a reason for hiding this comment

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

Tests only containing NotEqual are always a little strange. I think an image comparison or at least a markup comparison would have been better here (and in the text test below).

Copy link
Member Author

Choose a reason for hiding this comment

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

at least a markup comparison would have been better here (and in the text test below).

Unfortunately a markup comparison won't show the differences because the widget state is identical, it is the theme context applied that changes. So no markup difference - only render pixel colour.

Copy link
Member

Choose a reason for hiding this comment

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

Then, we should add this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added image tests as requested

Copy link
Member

@toaster toaster left a comment

Choose a reason for hiding this comment

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

  • verify that no longer theme some icons is really intended
  • remove stray empty line

In general: The PR was quite hard to grasp despite it isn’t that big. It would have helped to have commits organized like so:

  1. Add the new param to GetSvg and SetSvg in a first commit without using them yet but including all the necessary test adjustments.
  2. Move the logic and include the necessary tests and test adjustments.

In short, a commit should be focused (only address a single aspect) and complete (in the sense that it does not fail nor miss tests).

@@ -8,15 +8,15 @@
<widget pos="32,8" size="9x20" type="*widget.RichText">
<text alignment="center" bold size="9x19">A</text>
</widget>
<image fillMode="contain" pos="8,8" rsc="menuDropDownIcon" size="iconInlineSize" themed="foreground"/>
Copy link
Member

Choose a reason for hiding this comment

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

AFAICS, this (and other) previously were explicitly themed with the (default) foreground color. Now, it says that it is no longer themed anymore and thus will use the image’s colors, right? Is this really wanted?

Copy link
Member Author

@andydotxyz andydotxyz Jun 14, 2024

Choose a reason for hiding this comment

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

There was inconsistency before - named resources did not seem to have theme information (at least not some of them?) for example this happened on one test:

	<image pos="66,7" rsc="menuExpandIcon" size="iconInlineSize"/>
	<image pos="8,7" rsc="account.svg" size="iconInlineSize" themed="default"/>

I have updated the markup test renderer to be more consistent which has added changes. A smaller change set than before which seems promising - but overall it is now explicit about what theme is applied on all resources I think...

dweymouth
dweymouth previously approved these changes Jun 13, 2024
Copy link
Contributor

@dweymouth dweymouth left a comment

Choose a reason for hiding this comment

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

LGTM with addressing Tilo's comments

@andydotxyz
Copy link
Member Author

In short, a commit should be focused (only address a single aspect) and complete (in the sense that it does not fail nor miss tests).

I agree, and sorry for the lack of cleanliness - I have been travelling and desperately trying to get the required work done between flights, presentations and other commitments during this release process.

toaster
toaster previously approved these changes Jun 14, 2024
toaster
toaster previously approved these changes Jun 14, 2024
@coveralls
Copy link

Coverage Status

coverage: 65.638% (+0.07%) from 65.57%
when pulling 24241cc on andydotxyz:fix/overrideicon
into 55b4f95 on fyne-io:develop.

@coveralls
Copy link

Coverage Status

coverage: 65.654% (+0.08%) from 65.57%
when pulling 24241cc on andydotxyz:fix/overrideicon
into 55b4f95 on fyne-io:develop.

@andydotxyz andydotxyz merged commit b47ed17 into fyne-io:develop Jun 14, 2024
12 checks passed
@andydotxyz andydotxyz deleted the fix/overrideicon branch June 14, 2024 12:49
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.

4 participants