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

Is it currently possible to create a (semi-)transparent window on native platforms? #272

Closed
oliver-moeller opened this issue Apr 7, 2020 · 6 comments · Fixed by #484
Closed
Labels
feature New feature or request question Further information is requested
Milestone

Comments

@oliver-moeller
Copy link

oliver-moeller commented Apr 7, 2020

I am currently working on a fullscreen overlay on Windows.
There are a few things I am still trying to figure out. That includes:

  • most importantly: making a window transparent and / or semi-transparent while keeping it's widgets visible (maybe through iced_native or iced_winit?)
  • starting a window in fullscreen mode
  • getting the window handle (that is specifically the hwnd in Windows)

If anybody could lend a hand, thank you very much!

@hecrj
Copy link
Member

hecrj commented Apr 8, 2020

making a window transparent and / or semi-transparent while keeping it's widgets visible

This is not possible yet, but I believe it should be a matter of adding a transparent setting to window::Settings (winit supports this) and then clearing the frame with a transparent background color when the option is enabled.

starting a window in fullscreen mode

Returning Mode::Fullscreen in Application::mode should do the trick. However, we need to rethink this design. The mode can currently fall out of sync with the actual window state.

getting the window handle

What would be the use case for this?


Until these features are implemented, you can achieve all of this by building your event loop on top of winit directly. The integration example showcases how to do this.

@hecrj hecrj added feature New feature or request question Further information is requested labels Apr 8, 2020
@oliver-moeller
Copy link
Author

oliver-moeller commented Apr 8, 2020

I am unsure whether Linux and Mac would achieve anything by it, but under Windows it would allow access to a lot of features in the winapi, which are not currently implemented in iced (e.g. transparency). My thought was, that exposing the window handle immutably would be easier / faster than implementing everything directly.

However if I can build the loop on winit that covers my use case for the handle, I did not find a way to do that by myself.

Thank you for taking the time!

@valpackett
Copy link
Contributor

Please reopen the issue, this feature is generally useful and is not implemented.

So actually, wgpu doesn't support window transparency yet: gfx-rs/wgpu#687

But I guess that's not an issue with the GL backend.

should be a matter of adding a transparent setting to window::Settings

I'll try implementing that.

valpackett added a commit to valpackett/iced that referenced this issue May 31, 2020
…fixes iced-rs#272

wgpu would currently ignore the alpha: gfx-rs/wgpu#687

glow (and naively patched wgpu) requires premultiplied alpha, so if you don't
multiply the RGB by the A right now, the semi-transparent color would be wrong
(too bright).

winit with_transparent doesn't seem necessary.
valpackett added a commit to valpackett/iced that referenced this issue Jun 1, 2020
…fixes iced-rs#272

wgpu would currently ignore the alpha: gfx-rs/wgpu#687

glow (and naively patched wgpu) requires premultiplied alpha, so if you don't
multiply the RGB by the A right now, the semi-transparent color would be wrong
(too bright).

winit with_transparent doesn't seem necessary.
@hecrj hecrj closed this as completed in a65d6a1 Jun 1, 2020
hecrj added a commit that referenced this issue Jun 1, 2020
Add custom window background/clear color (incl. transparency) support, fixes #272
hecrj added a commit that referenced this issue Jun 1, 2020
valpackett added a commit to valpackett/iced that referenced this issue Jun 5, 2020
…fixes iced-rs#272

wgpu would currently ignore the alpha: gfx-rs/wgpu#687

glow (and naively patched wgpu) requires premultiplied alpha, so if you don't
multiply the RGB by the A right now, the semi-transparent color would be wrong
(too bright).

winit with_transparent doesn't seem necessary.
valpackett added a commit to valpackett/iced that referenced this issue Jun 9, 2020
…fixes iced-rs#272

wgpu would currently ignore the alpha: gfx-rs/wgpu#687

glow (and naively patched wgpu) requires premultiplied alpha, so if you don't
multiply the RGB by the A right now, the semi-transparent color would be wrong
(too bright).

winit with_transparent doesn't seem necessary.
@maroider
Copy link

The assumption made about with_transparent being unnecessary in 0fdc4e0 does not hold true for me (on Windows 10). Transparency refuses to work for me until I add .with_transparent(true) here.

@atsuzaki
Copy link
Contributor

atsuzaki commented Aug 17, 2020

The assumption made about with_transparent being unnecessary in 0fdc4e0 does not hold true for me (on Windows 10). Transparency refuses to work for me until I add .with_transparent(true) here.

It seems to not work on MacOS without .with_transparent(true) as well.

should be a matter of adding a transparent setting to window::Settings

I can open a PR to add this, but I'm not too sure since wgpu still doesn't support it. Maybe I could just add a note for people to switch to GL if they need transparency? cc: @hecrj

@hecrj
Copy link
Member

hecrj commented Aug 17, 2020

@atsuzaki Sounds good. No need to worry about wgpu for now. Once it's supported, it shouldn't affect the public API.

@hecrj hecrj reopened this Aug 17, 2020
@hecrj hecrj added this to the 0.2.0 milestone Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants