Fix issue magnifier window does not change after pressing the key for a long time 71/288071/1
authorInHong Han <inhong1.han@samsung.com>
Fri, 10 Feb 2023 05:29:39 +0000 (14:29 +0900)
committerInHong Han <inhong1.han@samsung.com>
Fri, 10 Feb 2023 05:29:39 +0000 (14:29 +0900)
Change-Id: I4a8acc6e040f6bc1c3d2fcf6314247e0220bd0a7

ISEDefaultNUI/MagnifierWindow.cs
ISEDefaultNUI/SCLNUI.cs

index 1f7fc7d517f70289d9f3cba2d508e29b5a6f7329..ecce8c39005fe65cfb0af79b7c581d23da2c5f28 100644 (file)
@@ -14,6 +14,7 @@ namespace ISEDefaultNUI
         private WindowAttribute.Position position;
         private Size2D size;
         private Window magnifierWindow;
+        private bool visible;
 
         private MagnifierWindow()
         {
@@ -21,11 +22,12 @@ namespace ISEDefaultNUI
             timer.Tick += TimerTick;
             imageList = new List<ImageView>();
             labelList = new List<TextLabel>();
+            visible = false;
         }
 
         private bool TimerTick(object source, Timer.TickEventArgs e)
         {
-            if (IsExists())
+            if (visible)
                 Hide();
 
             return true;
@@ -42,8 +44,16 @@ namespace ISEDefaultNUI
             }
         }
 
+        public bool IsVisible
+        {
+            get => visible;
+        }
+
         public void Show()
         {
+            if (timer.IsRunning())
+                timer.Stop();
+
             magnifierWindow = new Window("MagnifierWindow", new Rectangle(position.X, position.Y, size.Width, size.Height), false);
             magnifierWindow.BackgroundColor = Color.Transparent;
 
@@ -53,13 +63,11 @@ namespace ISEDefaultNUI
             magnifierWindow.SetAcceptFocus(false);
             magnifierWindow.Raise();
 
-            timer.Start();
+            visible = true;
         }
 
         public void Hide()
         {
-            timer.Stop();
-
             labelList.ForEach(label =>
             {
                 label.Unparent();
@@ -76,6 +84,7 @@ namespace ISEDefaultNUI
             imageList.Clear();
 
             magnifierWindow?.Dispose();
+            visible = false;
         }
 
         public void SetPosition(WindowAttribute.Position newPosition)
@@ -110,17 +119,10 @@ namespace ISEDefaultNUI
             labelList.Add(textLabel);
         }
 
-        public bool IsExists()
-        {
-            if (imageList.Count != 0 || labelList.Count != 0)
-                return true;
-
-            return false;
-        }
-
-        public bool IsRunning()
+        public void StartHideTimer()
         {
-            return timer.IsRunning();
+            if (!timer.IsRunning())
+                timer.Start();
         }
     }
 }
index 1fc3633fd08c62765cf2e4ac0a82d40908cac63e..39d4d2e4eea17925cadd7f8c27463492963b1d53 100644 (file)
@@ -151,6 +151,9 @@ namespace ISEDefaultNUI
                                                                 keystr, magnifierPosition.X, magnifierPosition.Y, width, height,
                                                                 align, padding_x, padding_y, inner_width, inner_height);
                             magnifier.AddLabel(magnifierText);
+
+                            if (!magnifier.IsVisible)
+                                magnifier.Show();
                             break;
                         }
                     case WindowAttribute.WindowType.Popup:
@@ -271,14 +274,17 @@ namespace ISEDefaultNUI
                                 dispose_all_objects();
                             break;
                         }
+                    case WindowAttribute.WindowType.Magnifier:
+                        {
+                            if (magnifier.IsVisible)
+                                magnifier.Hide();
+                            break;
+                        }
                     case WindowAttribute.WindowType.AutoPopup:
                         {
                             break;
                         }
                 }
-
-                if (magnifier.IsExists() && !magnifier.IsRunning())
-                    magnifier.Show();
             };
             SclNuiUpdateWindowCb(_update_window_cb, (IntPtr)null);
 
@@ -507,6 +513,23 @@ namespace ISEDefaultNUI
 
             _onDragStateChangedEvent = (IntPtr key_value, int key_event, int key_type, int event_type, int current_x, int current_y) =>
             {
+                SclNuiEventType type = (SclNuiEventType)event_type;
+
+                if (type == SclNuiEventType.Move)
+                {
+
+                }
+                else if (type == SclNuiEventType.Release)
+                {
+                    if (magnifier.IsVisible)
+                        magnifier.StartHideTimer();
+                }
+                else if (type == SclNuiEventType.Press)
+                {
+                    if (magnifier.IsVisible)
+                        magnifier.Hide();
+                }
+
                 return (int)SclNuiEventReturnType.PassOn;
             };
             SclNuiDragStateChangedCb(_onDragStateChangedEvent);
@@ -794,9 +817,6 @@ namespace ISEDefaultNUI
                 // - Set the mTouchedInButton to false
                 case PointStateType.Down:
                     {
-                        if (magnifier.IsExists())
-                            magnifier.Hide();
-
                         Log.Info("NUIIME", "[MOUSE DOWN] x=" + e.Touch.GetScreenPosition(0).X + ", y=" + e.Touch.GetScreenPosition(0).Y);
                         if (popup.IsShowing())
                             SclControllerMousePress((int)WindowAttribute.WindowType.Popup, (int)e.Touch.GetScreenPosition(0).X, (int)e.Touch.GetScreenPosition(0).Y);