Skip to content

Commit 8ce8a94

Browse files
committed
Rename scale* property to transform-scale*
This is to avoid reserving the `scale` property on every element which is a common property name
1 parent 90b9872 commit 8ce8a94

File tree

11 files changed

+34
-38
lines changed

11 files changed

+34
-38
lines changed

demos/home-automation/ui/components/mainView/widgetLoader.slint

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ export component WidgetLoader {
192192
id: AppState.component-details[root.index].id;
193193
width: root.width;
194194
height: root.height;
195-
scale-x: scaler;
196-
scale-y: scaler;
195+
transform-scale: scaler;
197196
}
198197

199198
if root.type == WidgetType.powerInfo: PowerInfo {

demos/home-automation/ui/components/mainView/widgetLoaderSoftwareRenderer.slint

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ export component WidgetLoaderSoftwareRenderer {
128128
id: AppState.component-details[root.index].id;
129129
width: root.width;
130130
height: root.height;
131-
scale-x: scaler;
132-
scale-y: scaler;
131+
transform-scale: scaler;
133132
}
134133

135134
if root.type == WidgetType.powerInfo && root.is-visible: PowerInfo {

docs/astro/src/content/docs/reference/common.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,20 @@ The y component of the origin to rotate and scale around.
7373
In the future this will be deprecated in favour of a transform-origin property.
7474
</SlintProperty>
7575

76-
#### scale
77-
<SlintProperty propName="scale" typeName="float" defaultValue='100%'>
76+
#### transform-scale
77+
<SlintProperty propName="transform-scale" typeName="float" defaultValue='100%'>
7878
The scale factor to apply to the element and all its children.
7979

8080
This doesn't affect the geometry (width, height) of the element, but affects the rendering.
8181
The scale is done around the `rotation-origin` point.
8282

83-
It is also possible to use the `scale-x` and `scale-y` properties to specify the scale factors for the x and y axis.
83+
It is also possible to use the `transform-scale-x` and `transform-scale-y` properties to specify the scale factors for the x and y axis.
8484
</SlintProperty>
8585

86-
#### scale-x
87-
<SlintProperty propName="scale-x" typeName="float" defaultValue='self.scale'/>
88-
#### scale-y
89-
<SlintProperty propName="scale-y" typeName="float" defaultValue='self.scale'/>
86+
#### transform-scale-x
87+
<SlintProperty propName="transform-scale-x" typeName="float" defaultValue='self.scale'/>
88+
#### transform-scale-y
89+
<SlintProperty propName="transform-scale-y" typeName="float" defaultValue='self.scale'/>
9090

9191
### opacity
9292
<CodeSnippetMD imagePath="/src/assets/generated/rectangle-opacity.png" scale="3" imageWidth="100" imageHeight="310" imageAlt='rectangle opacity'>

examples/fancy-switches/DarkModeSwitch.slint

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,13 @@ export component DarkModeSwitch {
123123
frameBacker.background: #2A2A2A;
124124
moon.rotation-angle: -20deg;
125125
sun.color: #fc7a10;
126-
sun.scale-x: 0.8;
127-
sun.scale-y: 0.8;
126+
sun.transform-scale: 0.8;
128127
in {
129128
animate thumb.x, thumb.background, frameBacker.background, sun.color {
130129
duration: 200ms;
131130
easing: ease-out-sine;
132131
}
133-
animate moon.rotation-angle, sun.scale-x, sun.scale-y {
132+
animate moon.rotation-angle, sun.transform-scale {
134133
duration: 1200ms;
135134
easing: ease-out-elastic;
136135
}
@@ -143,14 +142,13 @@ export component DarkModeSwitch {
143142
frameBacker.background: transparent;
144143
moon.rotation-angle: 20deg;
145144
sun.color: #2A2A2A;
146-
sun.scale-x: 1;
147-
sun.scale-y: 1;
145+
sun.transform-scale: 1;
148146
in {
149147
animate thumb.x, thumb.background, frameBacker.background, moon.rotation-angle {
150148
duration: 200ms;
151149
easing: ease-out-sine;
152150
}
153-
animate sun.scale-x, sun.scale-y {
151+
animate sun.transform-scale {
154152
duration: 1200ms;
155153
easing: ease-out-elastic;
156154
}

internal/compiler/builtins.slint

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ export component ComponentContainer inherits Empty {
8383

8484
export component Transform inherits Empty {
8585
in property <angle> rotation-angle;
86-
in property <percent> scale-x;
87-
in property <percent> scale-y;
86+
in property <percent> transform-scale-x;
87+
in property <percent> transform-scale-y;
8888
in property <length> rotation-origin-x;
8989
in property <length> rotation-origin-y;
9090
//-default_size_binding:expands_to_parent_geometry

internal/compiler/passes/lower_property_to_element.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,17 @@ pub fn lower_transform_properties(
150150
match prop {
151151
"rotation-origin-x" => prop_div_2("width"),
152152
"rotation-origin-y" => prop_div_2("height"),
153-
"scale-x" | "scale-y" => {
154-
if e.borrow().is_binding_set("scale", true) {
153+
"transform-scale-x" | "transform-scale-y" => {
154+
if e.borrow().is_binding_set("transform-scale", true) {
155155
Some(Expression::PropertyReference(NamedReference::new(
156156
e,
157-
SmolStr::new_static("scale"),
157+
SmolStr::new_static("transform-scale"),
158158
)))
159159
} else {
160160
Some(Expression::NumberLiteral(1., Default::default()))
161161
}
162162
}
163-
"scale" => None,
163+
"transform-scale" => None,
164164
"rotation-angle" => Some(Expression::NumberLiteral(0., Default::default())),
165165
_ => unreachable!(),
166166
}

internal/compiler/typeregister.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ pub const RESERVED_DROP_SHADOW_PROPERTIES: &[(&str, Type)] = &[
177177

178178
pub const RESERVED_TRANSFORM_PROPERTIES: &[(&str, Type)] = &[
179179
("rotation-angle", Type::Angle),
180-
("scale-x", Type::Float32),
181-
("scale-y", Type::Float32),
182-
("scale", Type::Float32),
180+
("transform-scale-x", Type::Float32),
181+
("transform-scale-y", Type::Float32),
182+
("transform-scale", Type::Float32),
183183
("rotation-origin-x", Type::LogicalLength),
184184
("rotation-origin-y", Type::LogicalLength),
185185
];

internal/core/item_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,8 @@ impl ItemRc {
825825
ItemTransform::translation(-origin.x, -origin.y)
826826
.cast()
827827
.then_scale(
828-
transform_item.as_pin_ref().scale_x(),
829-
transform_item.as_pin_ref().scale_y(),
828+
transform_item.as_pin_ref().transform_scale_x(),
829+
transform_item.as_pin_ref().transform_scale_y(),
830830
)
831831
.then_rotate(euclid::Angle {
832832
radians: transform_item.as_pin_ref().rotation_angle().to_radians(),

internal/core/items.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,8 +1027,8 @@ declare_item_vtable! {
10271027
/// The implementation of the `Rotate` element
10281028
pub struct Transform {
10291029
pub rotation_angle: Property<f32>,
1030-
pub scale_x: Property<f32>,
1031-
pub scale_y: Property<f32>,
1030+
pub transform_scale_x: Property<f32>,
1031+
pub transform_scale_y: Property<f32>,
10321032
pub rotation_origin_x: Property<LogicalLength>,
10331033
pub rotation_origin_y: Property<LogicalLength>,
10341034
pub cached_rendering_data: CachedRenderingData,
@@ -1100,7 +1100,7 @@ impl Item for Transform {
11001100
let origin =
11011101
LogicalVector::from_lengths(self.rotation_origin_x(), self.rotation_origin_y());
11021102
(*backend).translate(origin);
1103-
(*backend).scale(self.scale_x(), self.scale_y());
1103+
(*backend).scale(self.transform_scale_x(), self.transform_scale_y());
11041104
(*backend).rotate(self.rotation_angle());
11051105
(*backend).translate(-origin);
11061106
RenderingResult::ContinueRenderingChildren

tests/cases/elements/event_scaling.slint

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export component TestCase {
2020
y: 0px;
2121
width: 50px;
2222
height: 50px;
23-
scale-x: 200%;
24-
scale-y: 400%;
23+
transform-scale-x: 200%;
24+
transform-scale-y: 400%;
2525
rotation-origin-x: 0px;
2626
rotation-origin-y: 0px;
2727
area1 := TouchArea {

0 commit comments

Comments
 (0)