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

Button text_color should be an Option<Color> #2711

Open
4 tasks done
DJ-Laser opened this issue Dec 31, 2024 · 0 comments
Open
4 tasks done

Button text_color should be an Option<Color> #2711

DJ-Laser opened this issue Dec 31, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@DJ-Laser
Copy link

DJ-Laser commented Dec 31, 2024

Is your issue REALLY a bug?

  • My issue is indeed a bug!
  • I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

I am making an app launcher for my custom linux DE, and so to make everything look consistent I made a custom Theme struct based on the base16 style scheme. My problem was that all text inside of a button was black, even when i set the app theme to use white text. All other text was fine.

Screenshot from 2024-12-31 11-23-46

After some painful debugging I realized my mistake. I was implementing Catalog for container like this:

// use container::{...}
impl Catalog for Base16Theme {
  type Class<'a> = StyleFn<'a, Self>;

  fn default<'a>() -> Self::Class<'a> {
    Box::new(|_theme| Style::default())
  }

  fn style(&self, class: &Self::Class<'_>) -> Style {
    class(self)
  }
}

This had the expected behavior because by default the text_color is none, making the text inherit it's color.
I slightly modified this to get my button Catalog impl.

// use button::{...}
impl Catalog for Base16Theme {
  type Class<'a> = StyleFn<'a, Self>;

  fn default<'a>() -> Self::Class<'a> {
    Box::new(|_theme, _status| Style::default())
  }

  fn style(&self, class: &Self::Class<'_>, status: Status) -> Style {
    class(self, status)
  }
}

The problem was that for button, text_color::default is black, not none, overriding the default styles for the widgets placed inside.
I believe that button should behave the same as text and container, and allow inheriting the base text color style from it's parent

What is the expected behavior?

I expected button to behave the same as container, and inherit the text styling from the parent

Version

crates.io release

Operating System

Linux

Do you have any log output?

No response

@DJ-Laser DJ-Laser added the bug Something isn't working label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant