slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.56k stars 604 forks source link

Slide puzzle demo, display/touch location offset #2479

Open Volapyl opened 1 year ago

Volapyl commented 1 year ago

Device: One plus 8t ROM: Oxygen OS 13.0 (stock) Browser: Chrome 111.0.5563.116

I just checked out some Slint demos from my phone. The slide puzzle seems to have an artefact where I need to press lower on the screen than where the GUI elements are displayed.

It seems like it is not just a fixed offset, the further up on the display the GUI element is, the further down I need to offset my input.

I haven't yet used Slint myself, and only have limited experience with GUI development in general.

If someone is willing to help me get started debugging this, I wouldn't mind attempting to fix it myself.

ogoffart commented 1 year ago

I can indeed reproduce that with Chrome on android. I think what's hapening there is that the size of the canvas is somehow not accurate

To debug this you may want to compile the demo for wasm.

  1. uncomment the line that starts with #wasm# from the examples/slide_puzzle/Cargo.toml
  2. run wasm-pack build --target web in the slide_puzzle directory
  3. serve that directory (eg: python3 -m http.server)

There is some code that resizes the view in https://github.com/slint-ui/slint/blob/08c0f1b34e948668c67601c305ac261d0cd188bb/examples/slide_puzzle/main.rs#L243 , this may or may not be the cause of the bug.

ogoffart commented 9 months ago

(still reproducable) image