diff --git a/sixtyfps_runtime/corelib/item_rendering.rs b/sixtyfps_runtime/corelib/item_rendering.rs index 48c71d2c3..b48113238 100644 --- a/sixtyfps_runtime/corelib/item_rendering.rs +++ b/sixtyfps_runtime/corelib/item_rendering.rs @@ -13,7 +13,7 @@ LICENSE END */ use super::graphics::RenderingCache; use super::items::*; use crate::component::ComponentRc; -use crate::graphics::Point; +use crate::graphics::{Point, Rect}; use crate::item_tree::ItemVisitorResult; use core::pin::Pin; use std::cell::{Cell, RefCell}; @@ -107,7 +107,7 @@ pub trait ItemRenderer { fn draw_text_input(&mut self, pos: Point, text_input: Pin<&TextInput>); fn draw_path(&mut self, pos: Point, path: Pin<&Path>); fn draw_box_shadow(&mut self, pos: Point, box_shadow: Pin<&BoxShadow>); - fn combine_clip(&mut self, pos: Point, clip: Pin<&Clip>); + fn combine_clip(&mut self, pos: Point, rect: Rect); fn save_state(&mut self); fn restore_state(&mut self); diff --git a/sixtyfps_runtime/corelib/items.rs b/sixtyfps_runtime/corelib/items.rs index 55680e40b..ff88771a2 100644 --- a/sixtyfps_runtime/corelib/items.rs +++ b/sixtyfps_runtime/corelib/items.rs @@ -534,7 +534,7 @@ impl Item for Clip { fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn render(self: Pin<&Self>, pos: Point, backend: &mut ItemRendererRef) { - (*backend).combine_clip(pos, self) + (*backend).combine_clip(pos, self.geometry()) } } @@ -668,7 +668,9 @@ impl Item for Flickable { fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} - fn render(self: Pin<&Self>, _pos: Point, _backend: &mut ItemRendererRef) {} + fn render(self: Pin<&Self>, pos: Point, backend: &mut ItemRendererRef) { + (*backend).combine_clip(pos, self.geometry()) + } } impl ItemConsts for Flickable { diff --git a/sixtyfps_runtime/rendering_backends/gl/lib.rs b/sixtyfps_runtime/rendering_backends/gl/lib.rs index f0404dbaa..22ea5746f 100644 --- a/sixtyfps_runtime/rendering_backends/gl/lib.rs +++ b/sixtyfps_runtime/rendering_backends/gl/lib.rs @@ -1062,8 +1062,8 @@ impl ItemRenderer for GLItemRenderer { }) } - fn combine_clip(&mut self, pos: Point, clip: std::pin::Pin<&sixtyfps_corelib::items::Clip>) { - let clip_rect = clip.geometry().translate([pos.x, pos.y].into()); + fn combine_clip(&mut self, pos: Point, rect: Rect) { + let clip_rect = rect.translate([pos.x, pos.y].into()); self.shared_data.canvas.borrow_mut().intersect_scissor( clip_rect.min_x(), clip_rect.min_y(), diff --git a/sixtyfps_runtime/rendering_backends/qt/qt_window.rs b/sixtyfps_runtime/rendering_backends/qt/qt_window.rs index e1eb55300..ddb467a64 100644 --- a/sixtyfps_runtime/rendering_backends/qt/qt_window.rs +++ b/sixtyfps_runtime/rendering_backends/qt/qt_window.rs @@ -10,7 +10,7 @@ LICENSE END */ use cpp::*; use items::{ImageFit, TextHorizontalAlignment, TextVerticalAlignment}; -use sixtyfps_corelib::graphics::{Color, FontRequest, Point, RenderingCache}; +use sixtyfps_corelib::graphics::{Color, FontRequest, Point, Rect, RenderingCache}; use sixtyfps_corelib::input::{InternalKeyCode, KeyEvent, KeyEventType, MouseEventType}; use sixtyfps_corelib::item_rendering::{CachedRenderingData, ItemRenderer}; use sixtyfps_corelib::items::{self, ItemRef, TextOverflow, TextWrap}; @@ -439,12 +439,12 @@ impl ItemRenderer for QtItemRenderer<'_> { ); } - fn combine_clip(&mut self, pos: Point, clip: Pin<&items::Clip>) { + fn combine_clip(&mut self, pos: Point, rect: Rect) { let clip_rect = qttypes::QRectF { - x: (clip.x() + pos.x as f32) as _, - y: (clip.y() + pos.y as f32) as _, - width: clip.width() as _, - height: clip.height() as _, + x: (rect.min_x() + pos.x as f32) as _, + y: (rect.min_y() + pos.y as f32) as _, + width: rect.width() as _, + height: rect.height() as _, }; let painter: &mut QPainter = &mut *self.painter; cpp! { unsafe [painter as "QPainter*", clip_rect as "QRectF"] {