-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WinUI] Optimize TransformationExtensions
#22481
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,6 @@ public static class TransformationExtensions | |
{ | ||
public static void UpdateTransformation(this FrameworkElement frameworkElement, IView view) | ||
{ | ||
double anchorX = view.AnchorX; | ||
double anchorY = view.AnchorY; | ||
double rotationX = view.RotationX; | ||
double rotationY = view.RotationY; | ||
double rotation = view.Rotation; | ||
|
@@ -18,9 +16,6 @@ public static void UpdateTransformation(this FrameworkElement frameworkElement, | |
double scaleX = view.Scale * view.ScaleX; | ||
double scaleY = view.Scale * view.ScaleY; | ||
|
||
frameworkElement.RenderTransformOrigin = new global::Windows.Foundation.Point(anchorX, anchorY); | ||
frameworkElement.RenderTransform = new ScaleTransform { ScaleX = scaleX, ScaleY = scaleY }; | ||
|
||
if (rotationX % 360 == 0 && rotationY % 360 == 0 && rotation % 360 == 0 && | ||
translationX == 0 && translationY == 0 && scaleX == 1 && scaleY == 1) | ||
Comment on lines
19
to
20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If these are all default, this But are there cases were we need to round? What if someone did some math in their code and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I'm not too sure what conventions MAUI or graphics libraries have in this regard. Naively I would say that 359.999999 is not really a big issue because it probably happens quite rarely and function-wise the result will be acceptable (yet slower in performance). If you have a specific suggestion, please suggest it here. Otherwise, I would like to avoid mixing multiple things in one PR (because it can add months to get this merged). This PR is mostly meant for elements that does no transformations at all (my use case) and I believe it's very very common. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe someone like @PureWeen or @mattleibow know of an example where we round on other platforms. I imagine an extension method for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sure, I understand the idea. I'm just not sure how exactly to implement it so that it can be considered "always correct" (like how many decimals, etc.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I filed #22513 for this. |
||
{ | ||
|
@@ -29,6 +24,12 @@ public static void UpdateTransformation(this FrameworkElement frameworkElement, | |
} | ||
else | ||
{ | ||
double anchorX = view.AnchorX; | ||
double anchorY = view.AnchorY; | ||
|
||
frameworkElement.RenderTransformOrigin = new global::Windows.Foundation.Point(anchorX, anchorY); | ||
frameworkElement.RenderTransform = new ScaleTransform { ScaleX = scaleX, ScaleY = scaleY }; | ||
MartyIX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// PlaneProjection removes touch and scrollwheel functionality on scrollable views such | ||
// as ScrollView, ListView, and TableView. If neither RotationX or RotationY are set | ||
// (i.e. their absolute value is 0), a CompositeTransform is instead used to allow for | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically this is set to be unset on L27 and L28.
Additionaly, my best guess is that unsetting
RenderTransformOrigin
is not necessary ifRenderTransform
is notnull
.