From: Seoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com> Date: Mon, 10 May 2021 06:18:06 +0000 (+0900) Subject: [NUI] Update Slider sample to test touch event (#2996) X-Git-Tag: accepted/tizen/unified/20231205.024657~1887 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b5269df0a22b57793190d2a4503c4a9009cbfd1e;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Update Slider sample to test touch event (#2996) - 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 --- diff --git a/src/Tizen.NUI.Components/Controls/Slider.Internal.cs b/src/Tizen.NUI.Components/Controls/Slider.Internal.cs index b2c3bdd..5c7614e 100755 --- a/src/Tizen.NUI.Components/Controls/Slider.Internal.cs +++ b/src/Tizen.NUI.Components/Controls/Slider.Internal.cs @@ -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; diff --git a/src/Tizen.NUI.Components/Controls/Slider.cs b/src/Tizen.NUI.Components/Controls/Slider.cs index 2036369..701fc9d 100755 --- a/src/Tizen.NUI.Components/Controls/Slider.cs +++ b/src/Tizen.NUI.Components/Controls/Slider.cs @@ -929,7 +929,7 @@ namespace Tizen.NUI.Components } /// - /// 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. /// @@ -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) diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SliderSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SliderSample.cs index 584f5df..1b357a3 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SliderSample.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/SliderSample.cs @@ -49,7 +49,7 @@ namespace Tizen.NUI.Samples // Style construction SliderStyle st = new SliderStyle { - TrackThickness = 4, + TrackThickness = 5, Track = new ImageViewStyle { BackgroundColor = new Selector @@ -76,7 +76,7 @@ namespace Tizen.NUI.Samples }, BackgroundImage = new Selector { - 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 { - 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;