-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Simplifying StyleSheet implementations #755
Comments
I think it's a good idea.
No particular reason. In fact, the If anyone wants to give this a shot, feel free! |
I will open a PR for this later this week. |
How would you want to do default styles which can be extended? What if any function that returns a |
I don't think that is how |
If you are talking about my previous comment then because I don't know how to override the active style of a button for example without having to set each field. Example: impl button::StyleSheet for Style {
fn active(&self) -> button::Style {
// here I have to create the whole button::Style struct which requires me to know about the default values
}
} After thinking about this some more I discovered that Example: impl button::StyleSheet for Style {
fn active(&self) -> button::Style {
let mut style = button::DefaultStyle.active(); // renamed to DefaultStyle for clarity
// do something with style
style
}
} |
Maybe this is something that could be solved with code generation? Something like?
|
I created a draft PR which prototypes the idea I mentioned above using a button. |
Right now any
StyleSheet
has a list of functions without a default implementation. Implementing aStyleSheet
is really annoying, because you have to override all of the functions and not just the thing you want to change.I recently wanted to just change the border_radius of a text_input and I had to write the following code.
As you can see I mostly just copied your sourcecode.
If StyleSheets would have these default styles as default implementation like this:
Implementing StyleSheets would be way more easy. Changing the border_radius would now only require the following code:
Is there a reason why StyleSheets are implemented like this right now?
The text was updated successfully, but these errors were encountered: