marc2332 / freya

Cross-platform GUI library for 🦀 Rust powered by 🧬 Dioxus and 🎨 Skia.
https://freyaui.dev/
MIT License
1.46k stars 63 forks source link

enhancement: Layers levels and mouse pass through problem #465

Closed baleksey closed 5 months ago

baleksey commented 8 months ago

There are several cases when we need to place some temporary popup element on top of current rendered scene:

  1. Drop down list
  2. Modal dialog
  3. Popup color picker etc

But we have a problems with it right now: Elements under that element (with layer: "-99") still react on mouse move/click/wheel etc. So we easily can click on invisible element behind our modal dialog accidently.

Is there a way right now to "don't allow pass through mouse events" for "rect"? So we can assign this property to our popup element background or the whole screen overlay to stop that behaviour for elements behind.

marc2332 commented 8 months ago

Yeah... This is caused by the lack of event bubbling. When Dioxus 0.5 gets released ( a matter of weeks from what they have said in the discord) I should be able to fix this :cry:

marc2332 commented 8 months ago

I am sorry I cannot fix this right now, I wish I could, it has prevented me from developing new features such as popups and other ideas... But again, once Dioxus 0.5 gets released, I should be able to implement a proper event bubbling system, which should fix this cross-layer issues :pray:

baleksey commented 8 months ago

Omg, this issue exist for too long already... The one way I thought it can be hacked (for example in case of modal dialog):

  1. Just before we are going to invoke popup element we capture the whole gui skia canvas and store it as image etc.
  2. Then we rerender all gui, but leave only 2 layers: background "rect" with image from step 1 (dimmed or blurred, or just as is) and draw our dialog rect on top of it.

In this way we "see" our background gui and think it still there :) but no more worries about clicks etc.

What do you think? Can this workaround can be done the easiest possible way?

marc2332 commented 8 months ago

Thats very inefficient and the problems isn't about rendering, it's not even related to skia, is just that event bubbling across different components in Dioxus is currently broken in the latest stable release

baleksey commented 8 months ago

I got it. I just thinking about how to make current project working (with all that popup things) while we are waiting for the fix for an known issue since july...

marc2332 commented 8 months ago

I have gotten a decent implementation in https://github.com/marc2332/freya/pull/268, so when Dioxus 0.5 goes out I will release Freya 0.2 shortly after

marc2332 commented 8 months ago

This is fixed in the main branch btw

marc2332 commented 5 months ago

Fixed in 0.2 :)

baleksey commented 5 months ago

Thanks, mate! Started making my own Skia based gui while tired of waiting for Dioxus to update things. Not an easiest way but pretty interesting :)