From 41affeb68f90da9836c038f884f5465fe2833df4 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 29 Aug 2022 17:12:11 +0200 Subject: [PATCH] Fix element rotation when the element is translated For example Image { x: 150px; y: 50px; rotation-angle: 45deg; } will end up rendering as if x and y are zero. This is because during the injection we "move" x and y to the Rotate element as bindings, but due to the lack of built-in x/y properties, dummy properties are materialized and they are not applied for the regular per-item translation. Add x/y to the Rotate element and then it works. --- internal/compiler/builtins.slint | 2 ++ internal/core/items.rs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/compiler/builtins.slint b/internal/compiler/builtins.slint index 2f66d3040..bfe82b395 100644 --- a/internal/compiler/builtins.slint +++ b/internal/compiler/builtins.slint @@ -64,6 +64,8 @@ export ClippedImage := ImageItem { export { ClippedImage as Image } export Rotate := _ { + property x; + property y; property rotation-angle; property rotation-origin-x; property rotation-origin-y; diff --git a/internal/core/items.rs b/internal/core/items.rs index 106e0ce43..10b2d9b3e 100644 --- a/internal/core/items.rs +++ b/internal/core/items.rs @@ -918,6 +918,8 @@ declare_item_vtable! { #[pin] /// The implementation of the `Rotate` element pub struct Rotate { + pub x: Property, + pub y: Property, pub rotation_angle: Property, pub rotation_origin_x: Property, pub rotation_origin_y: Property, @@ -930,7 +932,7 @@ impl Item for Rotate { fn init(self: Pin<&Self>, _window_adapter: &Rc) {} fn geometry(self: Pin<&Self>) -> Rect { - euclid::rect(0 as _, 0 as _, self.width(), self.height()) + euclid::rect(self.x(), self.y(), self.width(), self.height()) } fn layout_info(