Skip to content
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

Optimize Visual size sync through RelativeSizeAdjustment over expression animations #4397

Merged

Conversation

Sergio0694
Copy link
Member

@Sergio0694 Sergio0694 commented Nov 25, 2021

PR Type

What kind of change does this PR introduce?

  • Optimization

What is the current behavior?

All Visual objects created through our pipeline system are kept in sync with target objects through an expression animation.

What is the new behavior?

We're now just using Visual.RelativeSizeAdjustment to achieve the same without the animation overhead.

I did test this in the sample app, but still adding the testing required tag as I'd like more validation on this.

Open questions

I'm wondering whether there's a way to also optimize this bit here by removing the animation:

Vector2 center = newValue.ToVector2();
Visual visual = element.GetVisual();
const string expression = "Vector2(this.Target.Size.X * X, this.Target.Size.Y * Y)";
ExpressionAnimation animation = visual.Compositor.CreateExpressionAnimation(expression);
animation.SetScalarParameter("X", center.X);
animation.SetScalarParameter("Y", center.Y);
visual.StopAnimation("CenterPoint.XY");
visual.StartAnimation("CenterPoint.XY", animation);

Haven't yet figured out a solution though 🤔

EDIT: spoke with Chris, yeah there isn't a way to do this, nevermind 🤣

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • New component
    • Pull Request has been submitted to the documentation repository instructions. Link:
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
    • If control, added to Visual Studio Design project
  • Sample in sample app has been added / updated (for bug fixes / features)
  • New major technical changes in the toolkit have or will be added to the Wiki e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

@ghost
Copy link

ghost commented Nov 25, 2021

Thanks Sergio0694 for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost requested review from michael-hawker and azchohfi November 25, 2021 13:28
@Sergio0694 Sergio0694 marked this pull request as ready for review November 25, 2021 17:45
@michael-hawker michael-hawker added the partner ⏹ Label for issues that are being depended on or blocking Toolkit partners. label Dec 2, 2021
@michael-hawker michael-hawker added the for-review 📖 To evaluate and validate the Issues or PR label Dec 16, 2021
@Sergio0694 Sergio0694 requested a review from Arlodotexe January 3, 2022 14:26
@Sergio0694 Sergio0694 force-pushed the optimization/relative-size-adjustment branch from 5ad632a to c991429 Compare January 4, 2022 12:48
@Sergio0694 Sergio0694 added auto merge ⚡ and removed for-review 📖 To evaluate and validate the Issues or PR labels Jan 4, 2022
@ghost
Copy link

ghost commented Jan 4, 2022

Hello @Sergio0694!

Because this pull request has the auto merge :zap: label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit c1cdfee into CommunityToolkit:main Jan 4, 2022
@Sergio0694 Sergio0694 deleted the optimization/relative-size-adjustment branch January 4, 2022 14:13
@michael-hawker michael-hawker modified the milestones: 8.0, 7.1.3 Jul 14, 2022
@michael-hawker
Copy link
Member

Ah, I was confused by the change of Visual from CompositionObject, but it's on an internal extension, so we're fine.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
animations 🏮 auto merge ⚡ brush 🖌️ functional testing required 📌 hotfix 🌶 optimization ☄ Performance or memory usage improvements partner ⏹ Label for issues that are being depended on or blocking Toolkit partners.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants