azul icon indicating copy to clipboard operation
azul copied to clipboard

Window transparency

Open Weasy666 opened this issue 6 years ago • 5 comments

Description

Version / OS

  • azul version: 741e3e9

  • Operating system: Windows 10 1809

  • rust toolchain:

    • nightly-x86_64-pc-windows-msvc (default)
    • rustc 1.32.0-nightly (6b9b97bd9 2018-11-15)

Steps to Reproduce

Create a new azul app and replace the code in main.rs with the following:

extern crate azul;
use azul::prelude::*;


fn main() {
    let mut app_data = AppData {};

    let app = App::new(app_data, AppConfig::default());

    let mut create = WindowCreateOptions::<AppData>::default();
    create.state.is_transparent = true;
    create.background = ColorF { r: 1.0, g: 1.0, b: 1.0, a: 0.0 };
    let window = Window::new(create, Css::native()).unwrap();
    app.run(window).unwrap();
}

pub struct AppData {}
impl Layout for AppData {
    fn layout(&self, _: WindowInfo<Self>) -> Dom<Self> {
        Dom::new(NodeType::Div)
    }
}

Expected Behavior

Window background should correctly render the background color given in WindowCreateOptions.

Actual Behavior

Colors are rendered like seen in the following examples: ColorF { r: 1.0, g: 1.0, b: 1.0, a: 0.0 }

anmerkung 2018-11-19 230724

ColorF { r: 0.5, g: 0.5, b: 0.5, a: 0.0 }

anmerkung 2018-11-19 230325

ColorF { r: 0.0, g: 0.0, b: 0.0, a: 0.0 }

anmerkung 2018-11-19 223020

Additional Information

Weasy666 avatar Nov 19 '18 22:11 Weasy666

Ok, I think I know where the issue is: The RendererOptions always has a clear color, if I disable this line:

https://github.com/maps4print/azul/blob/ca9f8a2785478ee38c51cf141092b0cdfa0f8057/src/window.rs#L786

I get a transparent window:

image

fschutt avatar Dec 06 '18 08:12 fschutt

Hm...i looked a bit at the code and i'm still wondering why it didn't work with ColorF { r: 0.0, g: 0.0, b: 0.0, a: 0.0 } as the background in WindowCreateOptions. As i see it, WindowCreateOptions is handed over as a parameter in the Windows::new() function and inside the new-function you use its backround variable as the clear_color parameter for get_renderer_opts. So shouldn't it produce the same result with ColorF { r: 0.0, g: 0.0, b: 0.0, a: 0.0 } as WindowCreateOptions.background, as it does with the hard coded clear_color value of ColorF { r: 0.0, g: 0.0, b: 0.0, a: 0.0 }? 😕

Weasy666 avatar Dec 13 '18 22:12 Weasy666

I tried this code because I want to create a fullscreen transparent overlay but the code does not compile anymore. The fields background and state.is_transparent don't exist anymore.

@fschutt Is there a way of achieving transparency on the current master branch?

MrMinimal avatar Apr 20 '19 13:04 MrMinimal

No, it's because of how window transparency works. This requires changes in winit - right now winit only allows a window to be 100% transparent or 100% opaque, it doesn't allow parts of the window to be opaque.

fschutt avatar Apr 20 '19 13:04 fschutt

Thanks for the quick input, given the screenshots in this issue I thought transparency was currently possible. So you're saying as soon as winit allows it, azul will support it as well? Any links for tracking progress in that regard?

MrMinimal avatar Apr 20 '19 14:04 MrMinimal