[NUI] Make the velocity of slider as 1%
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 22 Jun 2022 11:38:43 +0000 (20:38 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 28 Jun 2022 10:14:54 +0000 (19:14 +0900)
Previous code can move only 1 units when we try to change value
by Key event.

This patch make the value moved for 1%. It will change as same lates
even min/max value difference is big, or small.

TODO : Currently, we make it as const value 1%.
Should we need to make this value as property?

Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI.Components/Controls/Slider.cs

index 95a830e..4374902 100755 (executable)
@@ -1467,23 +1467,26 @@ namespace Tizen.NUI.Components
 
             if (key.State == Key.StateType.Down)
             {
+                float valueDiff;
+                if (IsDiscrete)
+                {
+                    valueDiff = discreteValue;
+                }
+                else
+                {
+                    /// TODO : Currently we set the velocity of value as 1% hardly.
+                    /// Can we use AccessibilityGetMinimumIncrement?
+                    valueDiff = (maxValue - minValue) * 0.01f;
+                }
                 if ((direction == DirectionType.Horizontal && key.KeyPressedName == "Left") ||
                     (direction == DirectionType.Vertical && key.KeyPressedName == "Down"))
                 {
                     if (editMode)
                     {
-                        if (MinValue < CurrentValue)
+                        if (minValue < curValue)
                         {
                             isPressed = true;
-                            if (IsDiscrete)
-                            {
-                                float value = curValue - discreteValue;
-                                CurrentValue = value;
-                            }
-                            else
-                            {
-                                CurrentValue -= 1;
-                            }
+                            CurrentValue -= valueDiff;
                         }
                         return true; // Consumed
                     }
@@ -1493,18 +1496,10 @@ namespace Tizen.NUI.Components
                 {
                     if (editMode)
                     {
-                        if (MaxValue > CurrentValue)
+                        if (maxValue > curValue)
                         {
                             isPressed = true;
-                            if (IsDiscrete)
-                            {
-                                float value = curValue + discreteValue;
-                                CurrentValue = value;
-                            }
-                            else
-                            {
-                                CurrentValue += 1;
-                            }
+                            CurrentValue += valueDiff;
                         }
                         return true; // Consumed
                     }