-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Internal support for custom colored fyne.Resource theming. #4815
Comments
You can already do this by going through the Theme system. If you manually specify the custom colour directly then any theme change will potentially make it unreadable or ugly, which is why the theme system makes consistent use of standard colours. |
I do not want to change the theme. Or I should say, there might be cases in which it is not desired. But yes, it can definitely make it ugly when the theme changes, but in this regard it doesn't matter. |
I guess this opens up the question of whether this is related to the theme, the toolkit, or your app? Use-case is important here so we know what API is expected or where to place it. |
Yes you are right, it is not necessarily related to theme package. Maybe something like this can be added to the resource.go file: // Maybe a ColoredStaticResource struct should be returned which also stores the color
func NewColoredStaticResource(res Resource, color color.Color) *StaticResource {
arr := svg.Colorize(res.Content(), color)
ret := NewStaticResource(res.Name(), arr)
return ret
} The reason I am addressing this is mainly because the svg package is an internal fyne package so I cannot simply create this function (let's say as a utility function) without copying the code of the svg package into my application. |
This is one thing that would be solved by having the builtin theme be able to accept HTML-style |
It could be solved that way, but I don't see a problem exposing access to our Colorise functionality in the meantime. I'm not sure if it belongs at top level, in the canvas package or elsewhere though. |
I don't think it would go in the top-level package. Maybe canvas - |
I agree with exposing the svg package which includes the Colorize functionality. Maybe I would just place the svg package outside of internal so everything stays the same (except the fact it is exposed), but it's up to you to decide based on the fyne development philosophy. The second thing to decide is to create (or not) new initialization functions in:
Which would help users to easily create colored icons/resources. I would definitely do the svg package exposure, because it does not complicate project maintenance. |
There has to be a really good reason to introduce a new public package name, and I don't think the svg.Colorize is a big enough candidate to do so. I think we'll need to find a sensible place in one of the existing packages. The second thing you mention would be superseded by having the builtin theme support color hex strings color names, which I think is a quite important thing anyway to unlock full functionality of the RichText widget (right now having arbitrary colored text that supports wrapping, and all the other RichText niceties is impossible). So we'll hold off on that one perhaps. |
Sounds good
As @dweymouth says that is a huge change for a single function - there are already more than enough packages - every one added makes it harder to learn the toolkit.
No to this one, the widgets follow the theme and so you should not create a widget with a static colour. It will not update if user changes theme and could become unreadable by mistake. |
Checklist
Is your feature request related to a problem?
It is possible to change the color of fyne.Resource objects?
It is possible to do so, like this:
theme.NewErrorThemedResource(theme.AccountIcon())
Which makes the icon red, but I would like to able to define any kind of custom color for the resource.
Is it possible to construct a solution with the existing API?
It might be fairly simple to add this to the theme package.
For the code, I used the exact same approach as it is already present in the theme/icons.go file from the fyne internal library, but appended it with an additional
color
propertyDescribe the solution you'd like to see.
I would like to see something like this:
Do you think this would be a nice idea?
The text was updated successfully, but these errors were encountered: