mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 06:41:14 +00:00
Add support for clip on Path elements
This allows clipping the viewbox conveniently.
This commit is contained in:
parent
7de783bbe1
commit
cc9d5e09f0
7 changed files with 131 additions and 11 deletions
|
@ -776,6 +776,7 @@ pub struct Path {
|
|||
pub viewbox_y: Property<f32>,
|
||||
pub viewbox_width: Property<f32>,
|
||||
pub viewbox_height: Property<f32>,
|
||||
pub clip: Property<bool>,
|
||||
pub cached_rendering_data: CachedRenderingData,
|
||||
}
|
||||
|
||||
|
@ -783,7 +784,7 @@ impl Item for Path {
|
|||
fn init(self: Pin<&Self>, _window: &ComponentWindow) {}
|
||||
|
||||
fn geometry(self: Pin<&Self>) -> Rect {
|
||||
euclid::rect(self.x(), self.y(), 0., 0.)
|
||||
euclid::rect(self.x(), self.y(), self.width(), self.height())
|
||||
}
|
||||
|
||||
fn layouting_info(self: Pin<&Self>, _window: &ComponentWindow) -> LayoutInfo {
|
||||
|
@ -815,7 +816,15 @@ impl Item for Path {
|
|||
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {}
|
||||
|
||||
fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) {
|
||||
(*backend).draw_path(self)
|
||||
let clip = self.clip();
|
||||
if clip {
|
||||
(*backend).save_state();
|
||||
(*backend).combine_clip(self.geometry(), 0., 0.)
|
||||
}
|
||||
(*backend).draw_path(self);
|
||||
if clip {
|
||||
(*backend).restore_state();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue