Skip to content

Render border above active progress for progress_bar widget.#2443

Merged
hecrj merged 3 commits into
iced-rs:masterfrom
B0ney:progress-bar-border-fix
Sep 10, 2024
Merged

Render border above active progress for progress_bar widget.#2443
hecrj merged 3 commits into
iced-rs:masterfrom
B0ney:progress-bar-border-fix

Conversation

@B0ney

@B0ney B0ney commented May 18, 2024

Copy link
Copy Markdown
Contributor

Before:
Screenshot 2024-05-18 140250

After:
Screenshot 2024-05-18 140125

Comment thread widget/src/progress_bar.rs Outdated
@B0ney

B0ney commented May 20, 2024

Copy link
Copy Markdown
Contributor Author

Looks like I discovered a transparency bug in tiny-skia:

Screenshot 2024-05-20 133400

wgpu:
Screenshot 2024-05-20 132308

sscce:

use iced::widget::container;
use iced::widget::progress_bar::Style;
use iced::widget::progress_bar;
use iced::{Border, Color, Element, Length};

pub fn main() -> iced::Result {
    iced::program("Progress Bar - Iced", Progress::update, Progress::view)
        .theme(|_| iced::Theme::Light)
        .run()
}

#[derive(Default)]
struct Progress;

impl Progress {
    fn update(&mut self, _: ()) {}

    fn view(&self) -> Element<()> {
        container(progress_bar(0.0..=100.0, 50.0).style(|_| Style {
            background: Color::BLACK.into(),
            bar: Color::from_rgb8(0, 255, 0).into(),

            border: Border {
                color: Color::from_rgba8(0, 0, 127, 0.5),
                width: 4.0,
                ..Default::default()
            },
        }))
        .padding(20)
        .center_x(Length::Fill)
        .center_y(Length::Fill)
        .into()
    }
}

@hecrj hecrj force-pushed the progress-bar-border-fix branch from b0e6523 to be85d9e Compare September 10, 2024 20:48
@hecrj hecrj added this to the 0.13 milestone Sep 10, 2024
@hecrj hecrj added bug Something isn't working fix widget labels Sep 10, 2024

@hecrj hecrj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@hecrj hecrj enabled auto-merge September 10, 2024 20:51
@hecrj hecrj disabled auto-merge September 10, 2024 20:51
@hecrj hecrj enabled auto-merge (squash) September 10, 2024 20:51
@hecrj hecrj merged commit ae58a40 into iced-rs:master Sep 10, 2024
@B0ney B0ney deleted the progress-bar-border-fix branch August 10, 2025 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix widget

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants