Bind using local bindables to avoid potentially event pollution

This commit is contained in:
Dean Herbert 2024-04-02 13:04:34 +08:00
parent 1adba68357
commit ed5dd5c8cd
No known key found for this signature in database
1 changed files with 8 additions and 2 deletions

View File

@ -22,6 +22,9 @@ public partial class TransformToolboxGroup : EditorToolboxGroup, IKeyBindingHand
private EditorToolButton rotateButton = null!;
private Bindable<bool> canRotatePlayfieldOrigin = null!;
private Bindable<bool> canRotateSelectionOrigin = null!;
public SelectionRotationHandler RotationHandler { get; init; } = null!;
public TransformToolboxGroup()
@ -52,8 +55,11 @@ protected override void LoadComplete()
base.LoadComplete();
// aggregate two values into canRotate
RotationHandler.CanRotatePlayfieldOrigin.BindValueChanged(_ => updateCanRotateAggregate());
RotationHandler.CanRotateSelectionOrigin.BindValueChanged(_ => updateCanRotateAggregate());
canRotatePlayfieldOrigin = RotationHandler.CanRotatePlayfieldOrigin.GetBoundCopy();
canRotatePlayfieldOrigin.BindValueChanged(_ => updateCanRotateAggregate());
canRotateSelectionOrigin = RotationHandler.CanRotateSelectionOrigin.GetBoundCopy();
canRotateSelectionOrigin.BindValueChanged(_ => updateCanRotateAggregate());
void updateCanRotateAggregate()
{