summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangho Hur <kangho.hur@samsung.com>2017-05-25 05:52:53 +0000
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>2017-05-25 05:52:53 +0000
commit15b8e5a3cc8310151cdbd893bf1004274e486e19 (patch)
tree7a78c93742a6e78fc32e2eb285e489ac502832df
parent1d506cb6b4c6ab9523e71b9cd6bfb9807843393b (diff)
parenteda88f68fc6c1b3df24e2d77bd59043951525cad (diff)
downloadelm-sharp-15b8e5a3cc8310151cdbd893bf1004274e486e19.tar.gz
elm-sharp-15b8e5a3cc8310151cdbd893bf1004274e486e19.tar.bz2
elm-sharp-15b8e5a3cc8310151cdbd893bf1004274e486e19.zip
Merge "Add SetFormatCallback in MultiButtonEntry" into tizen
-rw-r--r--[-rwxr-xr-x]ElmSharp.Test/ElmSharp.Test.csproj5
-rw-r--r--ElmSharp.Test/TC/MultibuttonEntryTest2.cs114
-rwxr-xr-xElmSharp/ElmSharp/MultiButtonEntry.cs40
-rw-r--r--ElmSharp/Interop/Interop.Elementary.MultiButtonEntry.cs8
4 files changed, 157 insertions, 10 deletions
diff --git a/ElmSharp.Test/ElmSharp.Test.csproj b/ElmSharp.Test/ElmSharp.Test.csproj
index e2d2cfd..68c9815 100755..100644
--- a/ElmSharp.Test/ElmSharp.Test.csproj
+++ b/ElmSharp.Test/ElmSharp.Test.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -57,6 +57,7 @@
<Compile Include="TC\GenListTest9.cs" />
<Compile Include="TC\FocusTest1.cs" />
<Compile Include="TC\HoverselTest1.cs" />
+ <Compile Include="TC\MultibuttonEntryTest2.cs" />
<Compile Include="TC\NaviframeTest3.cs" />
<Compile Include="TC\ScreenInformationTest.cs" />
<Compile Include="TC\BoxLayoutTest1.cs" />
@@ -206,4 +207,4 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
-</Project>
+</Project> \ No newline at end of file
diff --git a/ElmSharp.Test/TC/MultibuttonEntryTest2.cs b/ElmSharp.Test/TC/MultibuttonEntryTest2.cs
new file mode 100644
index 0000000..8639099
--- /dev/null
+++ b/ElmSharp.Test/TC/MultibuttonEntryTest2.cs
@@ -0,0 +1,114 @@
+/*
+ * 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;
+using ElmSharp;
+
+namespace ElmSharp.Test
+{
+ class MultiButtonEntryTest2 : TestCaseBase
+ {
+ public override string TestName => "MultiButtonEntryTest2";
+ public override string TestDescription => "To test basic operation of MultiButtonEntry";
+
+ bool _setCallback = false;
+
+ public override void Run(Window window)
+ {
+ Background bg = new Background(window);
+ bg.Color = Color.White;
+ bg.Move(0, 0);
+ bg.Resize(window.ScreenSize.Width, window.ScreenSize.Height);
+ bg.Show();
+
+ MultiButtonEntry mbe = new MultiButtonEntry(window)
+ {
+ IsEditable = true,
+ IsExpanded = true,
+ Text = "To: "
+ };
+
+ mbe.Append("Append1");
+ mbe.Append("Append2");
+ mbe.Append("Append3");
+ mbe.Append("Append4");
+ mbe.Append("Append5");
+ mbe.Append("Append6");
+ mbe.Append("Append7");
+ mbe.Append("Append8");
+ mbe.Append("Append9");
+ mbe.Append("Append10");
+ mbe.Append("Append11");
+ mbe.Append("Append12");
+
+ Label label1 = new Label(window)
+ {
+ Text = "MultiButtonEntry Test",
+ Color = Color.Blue
+ };
+
+ var expandButton = new Button(window)
+ {
+ Text = "IsExpanded",
+ AlignmentX = -1,
+ WeightX = 1,
+ };
+
+ var formatButton = new Button(window)
+ {
+ Text = "format",
+ AlignmentX = -1,
+ WeightX = 1,
+ };
+
+ expandButton.Clicked += (sender, e) =>
+ {
+ mbe.IsExpanded = !mbe.IsExpanded;
+ };
+
+ formatButton.Clicked += (sender, e) =>
+ {
+ if (_setCallback)
+ {
+ mbe.SetFormatCallback(null);
+ _setCallback = false;
+ }
+ else
+ {
+ mbe.SetFormatCallback((count) => { return "(" + count + ")"; });
+ _setCallback = true;
+ }
+ };
+
+ label1.Resize(600, 100);
+ label1.Move(50, 50);
+ label1.Show();
+
+ mbe.Resize(600, 600);
+ mbe.Move(0, 100);
+ mbe.Show();
+
+ expandButton.Resize(200, 100);
+ expandButton.Move(50, 700);
+ expandButton.Show();
+
+ formatButton.Resize(200, 100);
+ formatButton.Move(300, 700);
+ formatButton.Show();
+ }
+ }
+} \ No newline at end of file
diff --git a/ElmSharp/ElmSharp/MultiButtonEntry.cs b/ElmSharp/ElmSharp/MultiButtonEntry.cs
index 475f01f..21d9a54 100755
--- a/ElmSharp/ElmSharp/MultiButtonEntry.cs
+++ b/ElmSharp/ElmSharp/MultiButtonEntry.cs
@@ -30,9 +30,11 @@ namespace ElmSharp
{
HashSet<MultiButtonEntryItem> _children = new HashSet<MultiButtonEntryItem>();
List<Func<string, bool>> _filters = new List<Func<string, bool>>();
+ Func<int, string> _formatFunc = null;
Entry _entry = null;
- Interop.Elementary.MultiButtonEntryItemFilterCallback _filtercallback;
+ Interop.Elementary.MultiButtonEntryItemFilterCallback _filterCallback;
+ Interop.Elementary.MultiButtonEntryFormatCallback _formatCallback;
SmartEvent _clicked;
SmartEvent _expanded;
@@ -59,7 +61,8 @@ namespace ElmSharp
_itemLongPressed = new SmartEvent<MultiButtonEntryItemEventArgs>(this, "item,longpressed", MultiButtonEntryItemEventArgs.CreateFromSmartEvent);
_itemAdded = new SmartEvent<MultiButtonEntryItemEventArgs>(this, "item,added", MultiButtonEntryItemEventArgs.CreateAndAddFromSmartEvent);
- _filtercallback = new Interop.Elementary.MultiButtonEntryItemFilterCallback(FilterCallbackHandler);
+ _filterCallback = new Interop.Elementary.MultiButtonEntryItemFilterCallback(FilterCallbackHandler);
+ _formatCallback = new Interop.Elementary.MultiButtonEntryFormatCallback(FormatCallbackHandler);
_clicked.On += (sender, e) => Clicked?.Invoke(this, EventArgs.Empty);
_expanded.On += (sender, e) => Expanded?.Invoke(this, EventArgs.Empty);
@@ -263,6 +266,10 @@ namespace ElmSharp
public void Clear()
{
Interop.Elementary.elm_multibuttonentry_clear(RealHandle);
+ foreach (var item in _children)
+ {
+ item.Deleted -= Item_Deleted;
+ }
_children.Clear();
}
@@ -275,7 +282,7 @@ namespace ElmSharp
_filters.Add(func);
if (_filters.Count == 1)
{
- Interop.Elementary.elm_multibuttonentry_item_filter_append(RealHandle, _filtercallback, IntPtr.Zero);
+ Interop.Elementary.elm_multibuttonentry_item_filter_append(RealHandle, _filterCallback, IntPtr.Zero);
}
}
@@ -288,7 +295,7 @@ namespace ElmSharp
_filters.Insert(0, func);
if (_filters.Count == 1)
{
- Interop.Elementary.elm_multibuttonentry_item_filter_prepend(RealHandle, _filtercallback, IntPtr.Zero);
+ Interop.Elementary.elm_multibuttonentry_item_filter_prepend(RealHandle, _filterCallback, IntPtr.Zero);
}
}
@@ -301,10 +308,33 @@ namespace ElmSharp
_filters.Remove(func);
if (_filters.Count == 0)
{
- Interop.Elementary.elm_multibuttonentry_item_filter_remove(RealHandle, _filtercallback, IntPtr.Zero);
+ Interop.Elementary.elm_multibuttonentry_item_filter_remove(RealHandle, _filterCallback, IntPtr.Zero);
+ }
+ }
+
+ /// <summary>
+ /// Set a function to format the string that will be used to display the hidden items counter.
+ /// If func is NULL, the default format will be used, which is "+ 'the hidden items counter'".
+ /// </summary>
+ /// <param name="func">The function to return string to show</param>
+ public void SetFormatCallback(Func<int, string> func)
+ {
+ if (func == null)
+ {
+ Interop.Elementary.elm_multibuttonentry_format_function_set(RealHandle, null, IntPtr.Zero);
+ }
+ else
+ {
+ _formatFunc = func;
+ Interop.Elementary.elm_multibuttonentry_format_function_set(RealHandle, _formatCallback, IntPtr.Zero);
}
}
+ string FormatCallbackHandler(int count, IntPtr data)
+ {
+ return _formatFunc(count);
+ }
+
void Item_Deleted(object sender, EventArgs e)
{
var removed = sender as MultiButtonEntryItem;
diff --git a/ElmSharp/Interop/Interop.Elementary.MultiButtonEntry.cs b/ElmSharp/Interop/Interop.Elementary.MultiButtonEntry.cs
index cf9e0db..0fa7ca5 100644
--- a/ElmSharp/Interop/Interop.Elementary.MultiButtonEntry.cs
+++ b/ElmSharp/Interop/Interop.Elementary.MultiButtonEntry.cs
@@ -23,6 +23,8 @@ internal static partial class Interop
{
public delegate bool MultiButtonEntryItemFilterCallback(IntPtr obj, string label, IntPtr itemData, IntPtr data);
+ public delegate string MultiButtonEntryFormatCallback(int count, IntPtr data);
+
[DllImport(Libraries.Elementary)]
internal static extern IntPtr elm_multibuttonentry_add(IntPtr obj);
@@ -54,9 +56,6 @@ internal static partial class Interop
internal static extern IntPtr elm_multibuttonentry_item_insert_after(IntPtr obj, IntPtr after, string label, Evas.SmartCallback func, IntPtr data);
[DllImport(Libraries.Elementary)]
- internal static extern IntPtr elm_multibuttonentry_items_get(IntPtr obj); //return list
-
- [DllImport(Libraries.Elementary)]
internal static extern IntPtr elm_multibuttonentry_first_item_get(IntPtr obj);
[DllImport(Libraries.Elementary)]
@@ -81,6 +80,9 @@ internal static partial class Interop
internal static extern IntPtr elm_multibuttonentry_item_next_get(IntPtr obj);
[DllImport(Libraries.Elementary)]
+ internal static extern void elm_multibuttonentry_format_function_set(IntPtr obj, MultiButtonEntryFormatCallback callback, IntPtr data);
+
+ [DllImport(Libraries.Elementary)]
internal static extern void elm_multibuttonentry_item_filter_append(IntPtr obj, MultiButtonEntryItemFilterCallback callback, IntPtr data);
[DllImport(Libraries.Elementary)]