marc2332 / freya

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

bug: The `overflow` attribute does not take into account the value of the `corner_radius` attribute. #767

Closed Aiving closed 1 month ago

Aiving commented 1 month ago

I have recently started using the library and am generally very satisfied! However, while trying to implement the ripple effect from Material Design, I came across the fact that the overflow attribute ignores the value of the corner_radius attribute. Regardless of its value, clipping is always done using a simple rectangle.

Sample code showing this bug:

use freya::prelude::*;

fn main() {
    launch(app);
}

fn app() -> Element {
    rsx! {
        rect {
            width: "fill",
            height: "fill",
            main_align: "center",
            cross_align: "center",

            rect {
                width: "200",
                height: "200",
                corner_radius: "12",
                overflow: "clip",

                // Should be clipped by a rounded rectangle
                rect {
                    width: "fill",
                    height: "fill",
                    background: "green"
                }
            }
        }
    }
}
marc2332 commented 1 month ago

Already have an idea on how to fix it, will open a PR soon

Aiving commented 1 month ago

Good to know!

marc2332 commented 1 month ago

image

Already got it working, just need to clean up the code 😄

marc2332 commented 1 month ago

Got a PR on draft here https://github.com/marc2332/freya/pull/768 in case you want to give it a try @Aiving