Add FlipSelector
authorsung-su.kim <sung-su.kim@samsung.com>
Thu, 9 Feb 2017 07:55:31 +0000 (16:55 +0900)
committersung-su.kim <sung-su.kim@samsung.com>
Mon, 20 Feb 2017 08:29:00 +0000 (17:29 +0900)
Change-Id: I946f39e91986680d50af8d5f0fb6490cf4b3dbff

src/ElmSharp/ElmSharp.Net45.csproj [changed mode: 0644->0755]
src/ElmSharp/ElmSharp.csproj
src/ElmSharp/ElmSharp/FlipSelector.cs [new file with mode: 0644]
src/ElmSharp/ElmSharp/FlipSelectorItem.cs [new file with mode: 0644]
src/ElmSharp/Interop/Interop.Elementary.FlipSelector.cs [new file with mode: 0644]
test/ElmSharp.Test/ElmSharp.Test.csproj [changed mode: 0644->0755]
test/ElmSharp.Test/TC/FlipSelectorTest.cs [new file with mode: 0644]

old mode 100644 (file)
new mode 100755 (executable)
index 9d53b09..0a80aac
@@ -74,6 +74,8 @@
     <Compile Include="ElmSharp\EvasMap.cs" />
     <Compile Include="ElmSharp\EvasObject.cs" />
     <Compile Include="ElmSharp\EvasObjectEvent.cs" />
+    <Compile Include="ElmSharp\FlipSelector.cs" />
+    <Compile Include="ElmSharp\FlipSelectorItem.cs" />
     <Compile Include="ElmSharp\GenGrid.cs" />
     <Compile Include="ElmSharp\GenGridItem.cs" />
     <Compile Include="ElmSharp\GenItem.cs" />
     <Compile Include="Interop\Interop.Elementary.CtxPopup.cs" />
     <Compile Include="Interop\Interop.Elementary.DateTimePicker.cs" />
     <Compile Include="Interop\Interop.Elementary.Entry.cs" />
+    <Compile Include="Interop\Interop.Elementary.FlipSelector.cs" />
     <Compile Include="Interop\Interop.Elementary.GenGridView.cs" />
     <Compile Include="Interop\Interop.Elementary.GenListView.cs" />
     <Compile Include="Interop\Interop.Elementary.GestureLayer.cs" />
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
+</Project>
\ No newline at end of file
index 463f68a..3cef166 100755 (executable)
@@ -71,6 +71,8 @@
     <Compile Include="ElmSharp\EvasMap.cs" />
     <Compile Include="ElmSharp\EvasObject.cs" />
     <Compile Include="ElmSharp\EvasObjectEvent.cs" />
+    <Compile Include="ElmSharp\FlipSelector.cs" />
+    <Compile Include="ElmSharp\FlipSelectorItem.cs" />
     <Compile Include="ElmSharp\FloatingButton.cs" />
     <Compile Include="ElmSharp\GenGrid.cs" />
     <Compile Include="ElmSharp\GenGridItem.cs" />
     <Compile Include="ElmSharp\Window.cs" />
     <Compile Include="ElmSharp\WrapType.cs" />
     <Compile Include="Interop\Interop.Eina.cs" />
+    <Compile Include="Interop\Interop.Elementary.FlipSelector.cs" />
     <Compile Include="Interop\Interop.Eo.cs" />
     <Compile Include="Interop\Interop.Ecore.cs" />
     <Compile Include="Interop\Interop.Elementary.Bg.cs" />
diff --git a/src/ElmSharp/ElmSharp/FlipSelector.cs b/src/ElmSharp/ElmSharp/FlipSelector.cs
new file mode 100644 (file)
index 0000000..3a58f8e
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * 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.Collections.Generic;
+
+namespace ElmSharp
+{
+    public class FlipSelector : Layout
+    {
+        SmartEvent _selected;
+        SmartEvent _overflowed;
+        SmartEvent _underflowed;
+
+        public FlipSelector(EvasObject parent) : base(parent)
+        {
+            _selected = new SmartEvent(this, Handle, "selected");
+            _overflowed = new SmartEvent(this, Handle, "overflowed");
+            _underflowed = new SmartEvent(this, Handle, "underflowed");
+
+            _selected.On += SelectedChanged;
+            _overflowed.On += OverflowedChanged;
+            _underflowed.On += UnderflowedChanged;
+        }
+
+        public event EventHandler Selected;
+        public event EventHandler Overflowed;
+        public event EventHandler Underflowed;
+
+        public double Interval
+        {
+            get
+            {
+                return Interop.Elementary.elm_flipselector_first_interval_get(Handle);
+            }
+            set
+            {
+                Interop.Elementary.elm_flipselector_first_interval_set(Handle, value);
+            }
+        }
+
+        public FlipSelectorItem SelectedItem
+        {
+            get
+            {
+                IntPtr handle = Interop.Elementary.elm_flipselector_selected_item_get(Handle);
+                return ItemObject.GetItemByHandle(handle) as FlipSelectorItem;
+            }
+        }
+
+        public FlipSelectorItem FirstItem
+        {
+            get
+            {
+                IntPtr handle = Interop.Elementary.elm_flipselector_first_item_get(Handle);
+                return ItemObject.GetItemByHandle(handle) as FlipSelectorItem;
+            }
+        }
+
+        public FlipSelectorItem LastItem
+        {
+            get
+            {
+                IntPtr handle = Interop.Elementary.elm_flipselector_last_item_get(Handle);
+                return ItemObject.GetItemByHandle(handle) as FlipSelectorItem;
+            }
+        }
+
+        public FlipSelectorItem Append(string text)
+        {
+            FlipSelectorItem item = new FlipSelectorItem(text);
+            item.Handle = Interop.Elementary.elm_flipselector_item_append(Handle, text, null, (IntPtr)item.Id);
+            return item;
+        }
+
+        public FlipSelectorItem Prepend(string text)
+        {
+            FlipSelectorItem item = new FlipSelectorItem(text);
+            item.Handle = Interop.Elementary.elm_flipselector_item_prepend(Handle, text, null, (IntPtr)item.Id);
+            return item;
+        }
+
+        public void Remove(FlipSelectorItem item)
+        {
+            if (item as FlipSelectorItem != null)
+                item.Delete();
+        }
+
+        public void Next()
+        {
+            Interop.Elementary.elm_flipselector_flip_next(Handle);
+        }
+
+        public void Prev()
+        {
+            Interop.Elementary.elm_flipselector_flip_prev(Handle);
+        }
+
+        protected override IntPtr CreateHandle(EvasObject parent)
+        {
+            return Interop.Elementary.elm_flipselector_add(parent.Handle);
+        }
+
+        void SelectedChanged(object sender, EventArgs e)
+        {
+            SelectedItem?.SendSelected();
+            Selected?.Invoke(this, EventArgs.Empty);
+        }
+
+        void OverflowedChanged(object sender, EventArgs e)
+        {
+            Overflowed?.Invoke(this, e);
+        }
+
+        void UnderflowedChanged(object sender, EventArgs e)
+        {
+            Underflowed?.Invoke(this, e);
+        }
+    }
+}
diff --git a/src/ElmSharp/ElmSharp/FlipSelectorItem.cs b/src/ElmSharp/ElmSharp/FlipSelectorItem.cs
new file mode 100644 (file)
index 0000000..a957acf
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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 FlipSelectorItem : ItemObject
+    {
+        public string Text { get; private set; }
+
+        public event EventHandler Selected;
+
+        public FlipSelectorItem(string text) : base(IntPtr.Zero)
+        {
+            Text = text;
+        }
+
+        internal void SendSelected()
+        {
+            Selected?.Invoke(this, EventArgs.Empty);
+        }
+    }
+}
diff --git a/src/ElmSharp/Interop/Interop.Elementary.FlipSelector.cs b/src/ElmSharp/Interop/Interop.Elementary.FlipSelector.cs
new file mode 100644 (file)
index 0000000..9768571
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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_flipselector_add(IntPtr parent);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern double elm_flipselector_first_interval_get(IntPtr flipSelector);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_flipselector_first_interval_set(IntPtr flipSelector, double interval);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern IntPtr elm_flipselector_item_append(IntPtr flipSelector, string text, Evas.SmartCallback func, IntPtr data);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern IntPtr elm_flipselector_item_prepend(IntPtr flipSelector, string text, Evas.SmartCallback func, IntPtr data);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_flipselector_flip_next(IntPtr flipSelector);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_flipselector_flip_prev(IntPtr flipSelector);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern IntPtr elm_flipselector_selected_item_get(IntPtr flipSelector);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern IntPtr elm_flipselector_first_item_get(IntPtr flipSelector);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern IntPtr elm_flipselector_last_item_get(IntPtr flipSelector);
+    }
+}
old mode 100644 (file)
new mode 100755 (executable)
index 78f3556..74232bd
@@ -45,6 +45,7 @@
     <Compile Include="TC\BackgroundTest3.cs" />
     <Compile Include="TC\DateTimeSelectorTest2.cs" />
     <Compile Include="TC\EntryTest2.cs" />
+    <Compile Include="TC\FlipSelectorTest.cs" />
     <Compile Include="TC\GenListTest9.cs" />
     <Compile Include="TC\NaviframeTest3.cs" />
     <Compile Include="TC\ScreenInformationTest.cs" />
       </FlavorProperties>
     </VisualStudio>
   </ProjectExtensions>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/test/ElmSharp.Test/TC/FlipSelectorTest.cs b/test/ElmSharp.Test/TC/FlipSelectorTest.cs
new file mode 100644 (file)
index 0000000..0c2a85d
--- /dev/null
@@ -0,0 +1,113 @@
+using System;
+using ElmSharp;
+
+namespace ElmSharp.Test
+{
+    public class FlipSelectorTest : TestCaseBase
+    {
+        public override string TestName => "FlipSelectorTest";
+        public override string TestDescription => "To test FlipSelector";
+
+        public override void Run(Window window)
+        {
+            Conformant conformant = new Conformant(window);
+            conformant.Show();
+
+            Box outterBox = new Box(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+                IsHorizontal = false,
+            };
+            outterBox.Show();
+
+            Box box = new Box(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+                IsHorizontal = true,
+            };
+            box.Show();
+
+            FlipSelector flip = new FlipSelector(window)
+            {
+                Interval = 1.0,
+            };
+
+            flip.Append("two");
+            flip.Prepend("one");
+
+            flip.Show();
+            box.PackEnd(flip);
+
+            conformant.SetContent(outterBox);
+            outterBox.PackEnd(box);
+
+            Button prev = new Button(window)
+            {
+                AlignmentX = -1,
+                WeightX = 1,
+                Text = "Prev"
+            };
+            prev.Clicked += (s, e) => { flip.Prev(); };
+            prev.Show();
+
+            Button next = new Button(window)
+            {
+                AlignmentX = -1,
+                WeightX = 1,
+                Text = "next"
+            };
+            next.Clicked += (s, e) => { flip.Next(); };
+            next.Show();
+
+            Button prepend = new Button(window)
+            {
+                AlignmentX = -1,
+                WeightX = 1,
+                Text = "prepend"
+            };
+            prepend.Clicked += (s, e) => {
+
+                var random = new Random();
+                int value = random.Next(99);
+                flip.Prepend(value.ToString());
+            };
+            prepend.Show();
+
+            Button append = new Button(window)
+            {
+                AlignmentX = -1,
+                WeightX = 1,
+                Text = "append"
+            };
+            append.Clicked += (s, e) => {
+
+                var random = new Random();
+                int value = random.Next(99);
+                flip.Append(value.ToString());
+            };
+            append.Show();
+
+            Button remove = new Button(window)
+            {
+                AlignmentX = -1,
+                WeightX = 1,
+                Text = "remove"
+            };
+            remove.Clicked += (s, e) => { flip.Remove(flip.SelectedItem); };
+            remove.Show();
+
+            outterBox.PackEnd(box);
+            outterBox.PackEnd(prev);
+            outterBox.PackEnd(next);
+            outterBox.PackEnd(append);
+            outterBox.PackEnd(prepend);
+            outterBox.PackEnd(remove);
+        }
+    }
+}