[ElmSharp] Add ItemFocused/Unfocused to GenGrid 33/160033/1
authorKangho Hur <kangho.hur@samsung.com>
Tue, 14 Nov 2017 07:40:36 +0000 (16:40 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Tue, 14 Nov 2017 07:40:36 +0000 (16:40 +0900)
Change-Id: I77f41a6830b95ef06f0b58715a57e46a27007bdd

src/ElmSharp/ElmSharp/GenGrid.cs [changed mode: 0755->0644]
test/ElmSharp.Test/TC/GenGridTest2.cs

old mode 100755 (executable)
new mode 100644 (file)
index e9ec144..d493fa2
@@ -60,6 +60,8 @@ namespace ElmSharp
         SmartEvent<GenGridItemEventArgs> _realized;
         SmartEvent<GenGridItemEventArgs> _unrealized;
         SmartEvent<GenGridItemEventArgs> _longpressed;
+        SmartEvent<GenGridItemEventArgs> _focused;
+        SmartEvent<GenGridItemEventArgs> _unfocused;
         SmartEvent _changed;
 
         /// <summary>
@@ -126,6 +128,18 @@ namespace ElmSharp
         /// <since_tizen> preview </since_tizen>
         public event EventHandler<GenGridItemEventArgs> ItemLongPressed;
 
+        /// <summary>
+        /// ItemFocussed is raised when a gengrid item has received focus.
+        /// </summary>
+        /// <since_tizen> preview </since_tizen>
+        public event EventHandler<GenGridItemEventArgs> ItemFocused;
+
+        /// <summary>
+        /// ItemUnfocussed is raised when a gengrid item has lost focus.
+        /// </summary>
+        /// <since_tizen> preview </since_tizen>
+        public event EventHandler<GenGridItemEventArgs> ItemUnfocused;
+
         /// <summary>
         ///  Changed is raised when an item is added, removed, resized or moved and when the gengrid is resized or gets "horizontal" property changes.
         /// </summary>
@@ -623,6 +637,8 @@ namespace ElmSharp
             _realized = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "realized", GenGridItemEventArgs.CreateFromSmartEvent);
             _unrealized = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "unrealized", GenGridItemEventArgs.CreateFromSmartEvent);
             _longpressed = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "longpressed", GenGridItemEventArgs.CreateFromSmartEvent);
+            _focused = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "item,focused", GenGridItemEventArgs.CreateFromSmartEvent);
+            _unfocused = new SmartEvent<GenGridItemEventArgs>(this, this.RealHandle, "item,unfocused", GenGridItemEventArgs.CreateFromSmartEvent);
             _changed = new SmartEvent(this, this.RealHandle, "changed");
 
             _selected.On += (s, e) => { if (e.Item != null) ItemSelected?.Invoke(this, e); };
@@ -634,6 +650,8 @@ namespace ElmSharp
             _realized.On += (s, e) => { if (e.Item != null) ItemRealized?.Invoke(this, e); };
             _unrealized.On += (s, e) => { if (e.Item != null) ItemUnrealized?.Invoke(this, e); };
             _longpressed.On += (s, e) => { if (e.Item != null) ItemLongPressed?.Invoke(this, e); };
+            _focused.On += (s, e) => { if (e.Item != null) ItemFocused?.Invoke(this, e); };
+            _unfocused.On += (s, e) => { if (e.Item != null) ItemUnfocused?.Invoke(this, e); };
             _changed.On += (s, e) => { Changed?.Invoke(this, e); };
         }
 
index c8de4b19f102c8e400b59968ccb3b124050476a0..472c97810ec4fa4c2ba3535a9fe89bd2bacca9c5 100644 (file)
@@ -126,6 +126,21 @@ namespace ElmSharp.Test
             grid.ItemReleased += Grid_ItemReleased;
             grid.ItemLongPressed += Grid_ItemLongPressed;
             grid.ItemDoubleClicked += Grid_ItemDoubleClicked;
+            grid.ItemFocused += Grid_ItemFocused;
+            grid.ItemUnfocused += Grid_ItemUnfocused;
+        }
+
+        private void Grid_ItemUnfocused(object sender, GenGridItemEventArgs e)
+        {
+            Color color = (Color)e.Item.Data;
+            Console.WriteLine("#{0:X}{1:X}{2:X} has lost focus", color.R, color.G, color.B);
+        }
+
+        private void Grid_ItemFocused(object sender, GenGridItemEventArgs e)
+        {
+            e.Item.IsSelected = false;
+            Color color = (Color)e.Item.Data;
+            Console.WriteLine("#{0:X}{1:X}{2:X} has received focus", color.R, color.G, color.B);
         }
 
         private void Grid_ItemDoubleClicked(object sender, GenGridItemEventArgs e)