feat: ImageElement can rotate the image#3039
feat: ImageElement can rotate the image#3039laske185 wants to merge 9 commits intostride3d:masterfrom
Conversation
Add a rotation property to the ImageElement that allows to rotate the image in radians. Introduce AngleEditor control for editing rotation properties in degrees while storing values in radians.
sources/presentation/Stride.Core.Presentation.Wpf/Controls/AngleEditor.cs
Outdated
Show resolved
Hide resolved
| private void UpdateLocalMatrix() | ||
| { | ||
| if (Math.Abs(Rotation) < float.Epsilon) | ||
| { | ||
| LocalMatrix = Matrix.Identity; | ||
| } | ||
| else | ||
| { | ||
| LocalMatrix = Matrix.RotationZ(Rotation); | ||
| } | ||
| } |
There was a problem hiding this comment.
In this one however, I think the bot is wrong in supposing the local offset is lost,
The local matrix is taken in UIElement.UpdateWorldMatrix(), where the offsets are applied, and the result is used to compute the world-space matrix.
There was a problem hiding this comment.
The local position is stored in the RenderOffsets property of the UIElement. The world matrix is calculated in the UpdateWorldMatrix method that adds the local matrix with the render offsets and size.
So I agree that the bot comment is not valid.
Corrected a spelling error in method names across multiple files, renaming UpateValueFromFloat to UpdateValueFromFloat. Updated all declarations, overrides, and usages to improve code clarity and consistency. No functional changes were made.
|
Looks good to me. Good job! As the renaming was done in the |
|
I found one issue with the UI property editor I want to fix. |
…general template provider Replaced the custom RotationFloatPropertyTemplateProvider with a new, reusable TypeNameMatchTemplateProvider that matches both type and property name. Updated XAML to use this provider for "Rotation" float properties, simplifying and generalizing the approach for property-specific editors. This makes it easier to add similar editors in the future without extra provider classes.
|
I moved the registration of the property editor from |
Eideren
left a comment
There was a problem hiding this comment.
Cool stuff, some very minor issues.
I would like to have @Kryptos-FR look at this too, to let us know whether there's anything we should be careful wrt UI logic and the avalonia refactor
...ces/editor/Stride.Core.Assets.Editor/View/TemplateProviders/TypeNameMatchTemplateProvider.cs
Outdated
Show resolved
Hide resolved
Replaces TypeNameMatchTemplateProvider with TypeAndPropertyNameMatchTemplateProvider in both XAML and C# to clarify that matching is based on both type and property name, not just type and name. Updates all relevant usages and class definitions accordingly.
Refactored the Rotation property and UpdateLocalMatrix method to use direct equality checks (==) instead of Math.Abs(... - ...) < float.Epsilon. This streamlines the code but may affect floating-point precision handling.
Refactored GetDisplayValue to remove special handling for negative zero and instead round the degree value to four decimal places for cleaner display.
...Stride.Core.Assets.Editor/View/TemplateProviders/TypeAndPropertyNameMatchTemplateProvider.cs
Outdated
Show resolved
Hide resolved
sources/engine/Stride.UI.Tests/Layering/ImageElementRotationTests.cs
Outdated
Show resolved
Hide resolved
sources/presentation/Stride.Core.Presentation.Wpf/Controls/AngleEditor.cs
Outdated
Show resolved
Hide resolved
| </Grid.ColumnDefinitions> | ||
| <Border Grid.Column="0" CornerRadius="4" Background="{StaticResource NormalBrush}" BorderThickness="1" BorderBrush="{StaticResource NormalBorderBrush}"> | ||
| <DockPanel> | ||
| <TextBlock Text="°" Margin="0,0,3,0" MinWidth="12" VerticalAlignment="Center" TextAlignment="Center" Foreground="{StaticResource TextBrush}" /> |
There was a problem hiding this comment.
I'm not sure about that part. We have other places where angles can be edited (e.g. the transform component) but we don't display the ° symbol there. So it's not consistent.
There was a problem hiding this comment.
It's a good idea. But maybe we can discuss it on another PR after this one is merged. And propose a similar change for the RotationEditor (quaternion).
- Remove reference to "Silicon Studio Corp." in file headers. - Add notice about MIT license distribution and link to LICENSE.md. - Clarify licensing information; no functional code changes made.
- Update Rotation setter to use floating-point tolerance comparison. - Prevent unnecessary updates when new value is nearly equal to current. - Address floating-point precision issues for more reliable property changes.
- Removed Grid, Border, DockPanel, and degree symbol from the template. - Now uses only a NumericTextBox for a cleaner and more minimal UI. - Adjusted NumericTextBox margin from "3,0" to "2,0" for improved spacing. - Streamlines the AngleEditor appearance and reduces unnecessary elements.

PR Details
The UI-element
ImageElementhas a new propertyRotatethat allows the image to be rotated. This internal changes theLocalMatrixof the element to rotate it. The property expects the angle in radians.The GameStudio has a new editor control that allows the user to set the angle in degrees.
Related Issue
No issue created.
Types of changes
Checklist