Browse Source

Added the rest of props

Krzysztof Krysiński 3 days ago
parent
commit
b82c615ebc

+ 19 - 3
src/PixiEditor/ViewModels/Nodes/Properties/VecDPropertyViewModel.cs

@@ -5,6 +5,7 @@ namespace PixiEditor.ViewModels.Nodes.Properties;
 
 internal class VecDPropertyViewModel : NodePropertyViewModel<VecD>
 {
+    private bool updateBlocker = false;
     public VecDPropertyViewModel(NodeViewModel node, Type valueType) : base(node, valueType)
     {
         PropertyChanged += OnPropertyChanged;
@@ -16,20 +17,35 @@ internal class VecDPropertyViewModel : NodePropertyViewModel<VecD>
         {
             return;
         }
+
+        updateBlocker = true;
         
         OnPropertyChanged(nameof(XValue));
         OnPropertyChanged(nameof(YValue));
+
+        updateBlocker = false;
     }
 
     public double XValue
     {
         get => Value.X;
-        set => Value = new VecD(value, Value.Y);
+        set
+        {
+            if (updateBlocker)
+                return;
+            Value = new VecD(value, Value.Y);
+        }
     }
-    
+
     public double YValue
     {
         get => Value.Y;
-        set => Value = new VecD(Value.X, value);
+        set
+        {
+            if (updateBlocker)
+                return;
+
+            Value = new VecD(Value.X, value);
+        }
     }
 }

+ 22 - 4
src/PixiEditor/ViewModels/Nodes/Properties/VecIPropertyViewModel.cs

@@ -5,6 +5,8 @@ namespace PixiEditor.ViewModels.Nodes.Properties;
 
 internal class VecIPropertyViewModel : NodePropertyViewModel<VecI>
 {
+    private bool updateBlocker = false;
+
     public VecIPropertyViewModel(NodeViewModel node, Type valueType) : base(node, valueType)
     {
         PropertyChanged += OnPropertyChanged;
@@ -16,20 +18,36 @@ internal class VecIPropertyViewModel : NodePropertyViewModel<VecI>
         {
             return;
         }
-        
+
+        updateBlocker = true;
+
         OnPropertyChanged(nameof(XValue));
         OnPropertyChanged(nameof(YValue));
+
+        updateBlocker = false;
     }
 
     public int XValue
     {
         get => Value.X;
-        set => Value = new VecI(value, Value.Y);
+        set
+        {
+            if (updateBlocker)
+                return;
+
+            Value = new VecI(value, Value.Y);
+        }
     }
-    
+
     public int YValue
     {
         get => Value.Y;
-        set => Value = new VecI(Value.X, value);
+        set
+        {
+            if (updateBlocker)
+                return;
+
+            Value = new VecI(Value.X, value);
+        }
     }
 }

+ 6 - 2
src/PixiEditor/Views/Nodes/Properties/VecDPropertyView.axaml

@@ -7,13 +7,17 @@
                              xmlns:ui="clr-namespace:PixiEditor.UI.Common.Localization;assembly=PixiEditor.UI.Common"
                              xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
                              xmlns:controls="clr-namespace:PixiEditor.UI.Common.Controls;assembly=PixiEditor.UI.Common"
+                             xmlns:properties1="clr-namespace:PixiEditor.ViewModels.Nodes.Properties"
                              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
                              x:Class="PixiEditor.Views.Nodes.Properties.VecDPropertyView">
+    <Design.DataContext>
+        <properties1:VecDPropertyViewModel />
+    </Design.DataContext>
     <StackPanel HorizontalAlignment="{Binding IsInput, Converter={converters:BoolToValueConverter FalseValue='Right', TrueValue='Stretch'}}">
         <TextBlock VerticalAlignment="Center" ui:Translator.Key="{Binding DisplayName}"/>
         <StackPanel IsVisible="{Binding ShowInputField}">
-            <controls:NumberInput EnableScrollChange="False" MinWidth="100" Value="{Binding XValue, Mode=TwoWay}" Margin="0,2" />
-            <controls:NumberInput EnableScrollChange="False" MinWidth="100" Value="{Binding YValue, Mode=TwoWay}" />
+            <controls:NumberInput DraggingGrabber="{Binding MergeChanges, Mode=OneWayToSource}" EnableScrollChange="False" MinWidth="100" Value="{Binding XValue, Mode=TwoWay}" Margin="0,2" />
+            <controls:NumberInput DraggingGrabber="{Binding MergeChanges, Mode=OneWayToSource}" EnableScrollChange="False" MinWidth="100" Value="{Binding YValue, Mode=TwoWay}" />
         </StackPanel>
     </StackPanel>
 </properties:NodePropertyView>

+ 6 - 2
src/PixiEditor/Views/Nodes/Properties/VecIPropertyView.axaml

@@ -7,15 +7,19 @@
                              xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
                              xmlns:input="clr-namespace:PixiEditor.Views.Input"
                              xmlns:controls="clr-namespace:PixiEditor.UI.Common.Controls;assembly=PixiEditor.UI.Common"
+                             xmlns:properties1="clr-namespace:PixiEditor.ViewModels.Nodes.Properties"
                              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
                              x:Class="PixiEditor.Views.Nodes.Properties.VecIPropertyView">
+    <Design.DataContext>
+        <properties1:VecIPropertyViewModel />
+    </Design.DataContext>
     <StackPanel
         HorizontalAlignment="{Binding IsInput, Converter={converters:BoolToValueConverter FalseValue='Right', TrueValue='Stretch'}}">
         <TextBlock VerticalAlignment="Center" ui:Translator.Key="{Binding DisplayName}" />
         <StackPanel IsVisible="{Binding ShowInputField}">
-            <controls:NumberInput EnableScrollChange="False" MinWidth="100" Decimals="0"
+            <controls:NumberInput DraggingGrabber="{Binding MergeChanges, Mode=OneWayToSource}" EnableScrollChange="False" MinWidth="100" Decimals="0"
                                   Value="{Binding XValue, Mode=TwoWay}" Margin="0,2" />
-            <controls:NumberInput EnableScrollChange="False" MinWidth="100" Decimals="0"
+            <controls:NumberInput DraggingGrabber="{Binding MergeChanges, Mode=OneWayToSource}" EnableScrollChange="False" MinWidth="100" Decimals="0"
                                   Value="{Binding YValue, Mode=TwoWay}" />
         </StackPanel>
     </StackPanel>