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

Add option to make the transparent window blurry #2728

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rhysd
Copy link

@rhysd rhysd commented Jan 13, 2025

This PR adds blur option to the iced::window::Settings struct. When enabling it, the window has a blurry effect. The option value will be passed to winit.

Here is a screenshot of example:

image
use iced::theme::Style;
use iced::widget::{container, text};
use iced::window::Settings;
use iced::{Color, Element, Length::Fill, Theme};

pub fn main() -> iced::Result {
    iced::application("Test", Test::update, Test::view)
        .window(Settings {
            transparent: true,
            blur: true,
            ..Default::default()
        })
        .style(Test::style)
        .run()
}

#[derive(Default)]
struct Test;

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

    fn view(&self) -> impl Into<Element<()>> {
        container(text("This is test")).center(Fill).style(|_| {
            container::Style::default()
                .background(Color::from_rgba(0.0, 0.0, 0.0, 0.3))
        })
    }

    fn style(&self, theme: &Theme) -> Style {
        Style {
            background_color: Color::TRANSPARENT,
            text_color: theme.palette().text,
        }
    }
}

(To make this example work on macOS, the change for #2727 is also needed.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant