[NUI] Update Slider sample to test touch event (#2996)
authorSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Mon, 10 May 2021 06:18:06 +0000 (15:18 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 21 May 2021 07:37:43 +0000 (16:37 +0900)
- Updated Slider sample to test touch event.
- To move the exact position of slided track and thumb by touch event,
 TouchEvent should be connected with Slider control.

Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
src/Tizen.NUI.Components/Controls/Slider.Internal.cs
src/Tizen.NUI.Components/Controls/Slider.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SliderSample.cs

index b2c3bdd..5c7614e 100755 (executable)
@@ -107,6 +107,8 @@ namespace Tizen.NUI.Components
             isPressed = false;
             LayoutDirectionChanged += OnLayoutDirectionChanged;
 
+            this.TouchEvent += OnTouchEventForTrack;
+
             panGestureDetector = new PanGestureDetector();
             panGestureDetector.Attach(this);
             panGestureDetector.Detected += OnPanGestureDetected;
@@ -241,8 +243,6 @@ namespace Tizen.NUI.Components
                     bgTrackImage.Add(thumbImage);
                     thumbImage.RaiseToTop();
                 }
-
-                bgTrackImage.TouchEvent += OnTouchEventForBgTrack;
             }
 
             return bgTrackImage;
index 2036369..701fc9d 100755 (executable)
@@ -929,7 +929,7 @@ namespace Tizen.NUI.Components
         }
 
         /// <summary>
-        /// Flag to decide whether the thumb snap to the nearest discrete value when the user drags the thumb or taps.
+        /// Flag to decide whether the thumb snaps to the nearest discrete value when the user drags the thumb or taps.
         ///
         /// The default value is false.
         /// </summary>
@@ -1279,17 +1279,15 @@ namespace Tizen.NUI.Components
                 Utility.Dispose(warningSlidedTrackImage);
                 Utility.Dispose(warningTrackImage);
                 Utility.Dispose(slidedTrackImage);
-                if (null != bgTrackImage)
-                {
-                    bgTrackImage.TouchEvent -= OnTouchEventForBgTrack;
-                    Utility.Dispose(bgTrackImage);
-                }
+                Utility.Dispose(bgTrackImage);
                 Utility.Dispose(lowIndicatorImage);
                 Utility.Dispose(highIndicatorImage);
                 Utility.Dispose(lowIndicatorText);
                 Utility.Dispose(highIndicatorText);
                 Utility.Dispose(valueIndicatorImage);
                 Utility.Dispose(valueIndicatorText);
+
+                this.TouchEvent -= OnTouchEventForTrack;
             }
 
             base.Dispose(type);
@@ -1353,7 +1351,7 @@ namespace Tizen.NUI.Components
             }
         }
 
-        private bool OnTouchEventForBgTrack(object source, TouchEventArgs e)
+        private bool OnTouchEventForTrack(object source, TouchEventArgs e)
         {
             PointStateType state = e.Touch.GetState(0);
             if (state == PointStateType.Down)
index 584f5df..1b357a3 100755 (executable)
@@ -49,7 +49,7 @@ namespace Tizen.NUI.Samples
             // Style construction
             SliderStyle st = new SliderStyle
             {
-                TrackThickness = 4,
+                TrackThickness = 5,
                 Track = new ImageViewStyle
                 {
                     BackgroundColor = new Selector<Color>
@@ -76,7 +76,7 @@ namespace Tizen.NUI.Samples
                     },
                     BackgroundImage = new Selector<string>
                     {
-                        Normal = "",
+                        Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_normal.png",
                         Pressed = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_effect.png",
                     }
                 }
@@ -93,7 +93,7 @@ namespace Tizen.NUI.Samples
 
         private void CreateTopView()
         {
-            top_parent = new View() { Size = new Size(1920, 240) };
+            top_parent = new View() { Size = new Size(1920, 340) };
             top_parent.Layout = new GridLayout() { Rows = 2, GridOrientation = GridLayout.Orientation.Horizontal };
             root.Add(top_parent);
 
@@ -128,29 +128,26 @@ namespace Tizen.NUI.Samples
 
         private void CreateBottomView()
         {
-            bottom_parent = new View() { Size = new Size(1920, 840) };
-            bottom_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, CellPadding = new Size2D(0, 0) };
+            bottom_parent = new View() { Size = new Size(1920, 740) };
+            bottom_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, CellPadding = new Size2D(0, 0) };
             root.Add(bottom_parent);
 
             // Init Sliders
             InitSliders();
 
             // Add Horizontal Slider
-            hori_slider_parent = new View() { Size = new Size(1920, 160) };
-            hori_slider_parent.Layout = new GridLayout() { Rows = 2, GridOrientation = GridLayout.Orientation.Horizontal };
+            hori_slider_parent = new View() { Size = new Size(960, 740) };
+            hori_slider_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, LinearAlignment = LinearLayout.Alignment.Bottom, CellPadding = new Size2D(0, 50) };
             bottom_parent.Add(hori_slider_parent);
-            slider_null_style[0].Margin = new Extents(100, 0, 30, 0);
             hori_slider_parent.Add(slider_null_style[0]);
             hori_slider_parent.Add(slider_null_style[1]);
             hori_slider_parent.Add(slider_style[0]);
             hori_slider_parent.Add(slider_style[1]);
 
             // Add vertical Slider
-            ver_slider_parent = new View() { Size = new Size(1920, 680) };
-            ver_slider_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.CenterVertical, CellPadding = new Size2D(200, 0) };
+            ver_slider_parent = new View() { Size = new Size(960, 740) };
+            ver_slider_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(100, 0) };
             bottom_parent.Add(ver_slider_parent);
-            slider_null_style[2].Margin = new Extents(350, 0, 0, 0);
-            slider_style[2].Margin = new Extents(400, 0, 0, 0);
             ver_slider_parent.Add(slider_null_style[2]);
             ver_slider_parent.Add(slider_null_style[3]);
             ver_slider_parent.Add(slider_style[2]);
@@ -234,13 +231,13 @@ namespace Tizen.NUI.Samples
                     },
                     BackgroundImage = new Selector<string>
                     {
-                        Normal = "",
+                        Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_normal.png",
                         Pressed = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_slide_handler_effect.png",
                     }
                 }
             };
             Slider source = new Slider(st);
-            source.TrackThickness = 4;
+            source.TrackThickness = 5;
             source.ThumbSize = new Size(60, 60);
             source.BgTrackColor = new Color(0, 0, 0, 0.1f);
             source.SlidedTrackColor = new Color(0.05f, 0.63f, 0.9f, 1);
@@ -262,7 +259,6 @@ namespace Tizen.NUI.Samples
             // input style in construction
             Slider source = new Slider(st);
             source.Direction = dir;
-            root.Add(source);
             source.Focusable = true;
             source.MinValue = MIN_VALUE;
             source.MaxValue = MAX_VALUE;