Skip to content

how to set color of progress bar? #1503

Answered by m4b
m4b asked this question in Q&A
Discussion options

You must be logged in to vote

Ok so as of the recent changes, which are in 0.5, because a Box<dyn is now there, instead of a function pointer, we can change colors like this without using a wholesale theme, which is great!

https://docs.rs/iced_style/latest/iced_style/theme/enum.ProgressBar.html#variant.Custom

Something like this is possible (adapted from the 0.4 and lesser mod based styles, and not guaranteed to compile as is, just an example):

mod style {
    use super::*;
    use iced::progress_bar::StyleSheet;
    use iced_style::progress_bar;

    pub struct ProgressBar(pub(super) [f32; 3]);

    impl StyleSheet for ProgressBar {
        type Style = iced_style::Theme;

        fn appearance(&self, _style: &Self::S…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by m4b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants