Add Hoversel to implement DropdownList 14/115914/4
authorjh5.cho <jh5.cho@samsung.com>
Wed, 22 Feb 2017 04:59:25 +0000 (13:59 +0900)
committerjh5.cho <jh5.cho@samsung.com>
Fri, 10 Mar 2017 01:36:00 +0000 (10:36 +0900)
    - RFC: http://suprem.sec.samsung.net/confluence/pages/viewpage.action?pageId=73052518
    - Add Interop, Hoversel / HoverselItem / HoverselTest1

Change-Id: I69ce9f0cc22c4e8346a49011b051e571234afb77

ElmSharp.Test/ElmSharp.Test.csproj
ElmSharp.Test/TC/HoverselTest1.cs [new file with mode: 0755]
ElmSharp/ElmSharp.csproj
ElmSharp/ElmSharp/Hoversel.cs [new file with mode: 0755]
ElmSharp/ElmSharp/HoverselItem.cs [new file with mode: 0755]
ElmSharp/Interop/Interop.Elementary.Hoversel.cs [new file with mode: 0755]

index 219b24d..ac57622 100644 (file)
@@ -48,6 +48,7 @@
     <Compile Include="TC\FlipSelectorTest.cs" />
     <Compile Include="TC\GenListTest9.cs" />
     <Compile Include="TC\FocusTest1.cs" />
+    <Compile Include="TC\HoverselTest1.cs" />
     <Compile Include="TC\NaviframeTest3.cs" />
     <Compile Include="TC\ScreenInformationTest.cs" />
     <Compile Include="TC\BoxLayoutTest1.cs" />
diff --git a/ElmSharp.Test/TC/HoverselTest1.cs b/ElmSharp.Test/TC/HoverselTest1.cs
new file mode 100755 (executable)
index 0000000..01dd1ef
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using ElmSharp;
+using System.Collections.Generic;
+
+namespace ElmSharp.Test
+{
+    public class HoverselTest1 : TestCaseBase
+    {
+        public override string TestName => "HoverselTest1";
+        public override string TestDescription => "To test basic operation of Hoversel";
+
+        public override void Run(Window window)
+        {
+            Background bg = new Background(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+                Color = Color.White
+            };
+            bg.Show();
+            window.AddResizeObject(bg);
+
+            Hoversel hoversel = new Hoversel(window)
+            {
+                IsHorizontal = false,
+                HoverParent = window,
+                Text = "Hoversel"
+            };
+            hoversel.ItemSelected += (s, e) =>
+            {
+                Console.WriteLine("ItemSelected : " + e.Item.Label);
+            };
+
+            HoverselItem item1 = hoversel.AddItem("item1");
+            HoverselItem item2 = hoversel.AddItem("item2");
+            HoverselItem item3 = hoversel.AddItem("item3");
+
+            EventHandler handler = (s, e) =>
+            {
+                var item = s as HoverselItem;
+                Console.WriteLine($"{item?.Label} is selected");
+            };
+            item1.ItemSelected += handler;
+            item2.ItemSelected += handler;
+            item3.ItemSelected += handler;
+
+            hoversel.Resize(200, 100);
+            hoversel.Move(100, 100);
+            hoversel.Show();
+
+            Button beginButton = new Button(window)
+            {
+                Text = "Begin"
+            };
+            beginButton.Clicked += (s, e) =>
+            {
+                hoversel.HoverBegin();
+            };
+            beginButton.Resize(200, 100);
+            beginButton.Move(100, 500);
+            beginButton.Show();
+        }
+    }
+}
index 4f35a2a..c135b7c 100755 (executable)
@@ -53,6 +53,7 @@
     <Compile Include="ElmSharp\Color.cs" />
     <Compile Include="ElmSharp\ColorChangedEventArgs.cs" />
     <Compile Include="ElmSharp\ColorSelector.cs" />
+    <Compile Include="ElmSharp\HoverselItem.cs" />
     <Compile Include="ElmSharp\Conformant.cs" />
     <Compile Include="ElmSharp\Container.cs" />
     <Compile Include="ElmSharp\ContextPopup.cs" />
@@ -82,6 +83,7 @@
     <Compile Include="ElmSharp\GenList.cs" />
     <Compile Include="ElmSharp\GenListItem.cs" />
     <Compile Include="ElmSharp\GestureLayer.cs" />
+    <Compile Include="ElmSharp\Hoversel.cs" />
     <Compile Include="ElmSharp\Icon.cs" />
     <Compile Include="ElmSharp\Image.cs" />
     <Compile Include="ElmSharp\Index.cs" />
     <Compile Include="ElmSharp\Window.cs" />
     <Compile Include="ElmSharp\WrapType.cs" />
     <Compile Include="Interop\Interop.Eina.cs" />
+    <Compile Include="Interop\Interop.Elementary.Hoversel.cs" />
     <Compile Include="Interop\Interop.Elementary.FlipSelector.cs" />
     <Compile Include="Interop\Interop.Eo.cs" />
     <Compile Include="Interop\Interop.Ecore.cs" />
     <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>
     <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>
   </PropertyGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/ElmSharp/ElmSharp/Hoversel.cs b/ElmSharp/ElmSharp/Hoversel.cs
new file mode 100755 (executable)
index 0000000..cf214e9
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace ElmSharp
+{
+    public class HoverselItemEventArgs : EventArgs
+    {
+        public HoverselItem Item { get; set; }
+
+        internal static HoverselItemEventArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
+        {
+            HoverselItem item = ItemObject.GetItemByHandle(info) as HoverselItem;
+            return new HoverselItemEventArgs() { Item = item };
+        }
+    }
+
+    public class Hoversel : Layout
+    {
+        SmartEvent<HoverselItemEventArgs> _selected;
+        Interop.Evas.SmartCallback _onItemSelected;
+
+        public Hoversel(EvasObject parent) : base(parent)
+        {
+            _selected = new SmartEvent<HoverselItemEventArgs>(this, RealHandle, "selected", HoverselItemEventArgs.CreateFromSmartEvent);
+            _selected.On += (s, e) =>
+            {
+                if (e.Item != null) ItemSelected?.Invoke(this, e);
+            };
+            _onItemSelected = (data, obj, info) =>
+            {
+                HoverselItem item = ItemObject.GetItemById((int)data) as HoverselItem;
+                item?.SendItemSelected();
+            };
+        }
+
+        public event EventHandler<HoverselItemEventArgs> ItemSelected;
+
+        public bool IsHorizontal
+        {
+            get
+            {
+                return Interop.Elementary.elm_hoversel_horizontal_get(RealHandle);
+            }
+            set
+            {
+                Interop.Elementary.elm_hoversel_horizontal_set(RealHandle, value);
+            }
+        }
+
+        public IntPtr HoverParent
+        {
+            get
+            {
+                return Interop.Elementary.elm_hoversel_hover_parent_get(RealHandle);
+            }
+            set
+            {
+                Interop.Elementary.elm_hoversel_hover_parent_set(RealHandle, value);
+            }
+        }
+
+        public bool IsExpanded
+        {
+            get
+            {
+                return Interop.Elementary.elm_hoversel_expanded_get(RealHandle);
+            }
+        }
+
+        public bool AutoUpdate
+        {
+            get
+            {
+                return Interop.Elementary.elm_hoversel_auto_update_get(RealHandle);
+            }
+            set
+            {
+                Interop.Elementary.elm_hoversel_auto_update_set(RealHandle, value);
+            }
+        }
+
+        public void HoverBegin()
+        {
+            Interop.Elementary.elm_hoversel_hover_begin(RealHandle);
+        }
+
+        public void HoverEnd()
+        {
+            Interop.Elementary.elm_hoversel_hover_end(RealHandle);
+        }
+
+        public void Clear()
+        {
+            Interop.Elementary.elm_hoversel_clear(RealHandle);
+        }
+
+        public HoverselItem AddItem(string label)
+        {
+            HoverselItem item = new HoverselItem();
+            item.Label = label;
+            item.Handle = Interop.Elementary.elm_hoversel_item_add(RealHandle, label, null, 0, _onItemSelected, (IntPtr)item.Id);
+            return item;
+        }
+
+        protected override IntPtr CreateHandle(EvasObject parent)
+        {
+            IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
+            Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default");
+
+            RealHandle = Interop.Elementary.elm_hoversel_add(handle);
+            Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
+
+            return handle;
+        }
+    }
+}
diff --git a/ElmSharp/ElmSharp/HoverselItem.cs b/ElmSharp/ElmSharp/HoverselItem.cs
new file mode 100755 (executable)
index 0000000..de88cbc
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace ElmSharp
+{
+    public class HoverselItem : ItemObject
+    {
+        internal HoverselItem() : base(IntPtr.Zero)
+        {
+        }
+
+        public string Label { get; internal set; }
+
+        public event EventHandler ItemSelected;
+
+        internal void SendItemSelected()
+        {
+            ItemSelected?.Invoke(this, EventArgs.Empty);
+        }
+    }
+}
diff --git a/ElmSharp/Interop/Interop.Elementary.Hoversel.cs b/ElmSharp/Interop/Interop.Elementary.Hoversel.cs
new file mode 100755 (executable)
index 0000000..ca8cefe
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Elementary
+    {
+        [DllImport(Libraries.Elementary)]
+        internal static extern IntPtr elm_hoversel_add(IntPtr obj);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_hoversel_horizontal_set(IntPtr obj, bool horizontal);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern bool elm_hoversel_horizontal_get(IntPtr obj);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_hoversel_hover_parent_set(IntPtr obj, IntPtr parent);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern IntPtr elm_hoversel_hover_parent_get(IntPtr obj);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern bool elm_hoversel_expanded_get(IntPtr obj);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_hoversel_auto_update_set(IntPtr obj, bool auto_update);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern bool elm_hoversel_auto_update_get(IntPtr obj);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_hoversel_hover_begin(IntPtr obj);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_hoversel_clear(IntPtr obj);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_hoversel_hover_end(IntPtr obj);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern IntPtr elm_hoversel_item_add(IntPtr obj, string label, string icon_file, int icon_type, Evas.SmartCallback func, IntPtr data);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_hoversel_item_icon_set(IntPtr obj, string icon_file, string icon_group, int icon_type);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_hoversel_item_icon_get(IntPtr obj, out string icon_file, out string icon_group, int icon_type);
+    }
+}
+