Add new internal APIs for layout/label
authorSungtaek Hong <sth253.hong@samsung.com>
Thu, 1 Jun 2017 11:35:32 +0000 (20:35 +0900)
committerSungtaek Hong <sth253.hong@samsung.com>
Thu, 8 Jun 2017 06:59:30 +0000 (15:59 +0900)
added APIs:
 - elm_layout_text_valign_set
 - elm_layout_text_valign_get
 - elm_label_text_style_user_peek
 - elm_label_text_style_user_push
 - elm_label_text_style_user_pop

Change-Id: I98ade8b726dae66185093217bfe277d19c33665f
Signed-off-by: Sungtaek Hong <sth253.hong@samsung.com>
src/ElmSharp/ElmSharp/Label.cs
src/ElmSharp/ElmSharp/Layout.cs
src/ElmSharp/Interop/Interop.Elementary.Label.cs [changed mode: 0644->0755]
src/ElmSharp/Interop/Interop.Elementary.cs [changed mode: 0644->0755]
test/ElmSharp.Test/ElmSharp.Test.csproj
test/ElmSharp.Test/TC/LabelTest2.cs
test/ElmSharp.Test/TC/LabelTest3.cs
test/ElmSharp.Test/TC/LabelValignTest1.cs [new file with mode: 0644]

index 48fa897..68b7486 100755 (executable)
@@ -144,6 +144,32 @@ namespace ElmSharp
         }
 
         /// <summary>
+        /// Sets or gets the style of the label text.
+        /// </summary>
+        /// <remarks>
+        /// APIs, elm_label_text_style_user_peek/pop/push, are internal APIs only in Tizen. Avalilable since Tizen_4.0.
+        /// </remarks>
+        /// 
+        public string TextStyle
+        {
+            get
+            {
+                return Interop.Elementary.elm_label_text_style_user_peek(RealHandle);
+            }
+            set
+            {
+                if (!string.IsNullOrEmpty(value))
+                {
+                    Interop.Elementary.elm_label_text_style_user_pop(RealHandle);
+                }
+                else
+                {
+                    Interop.Elementary.elm_label_text_style_user_push(RealHandle, value);
+                }
+            }
+        }
+
+        /// <summary>
         /// Start slide effect.
         /// </summary>
         public void PlaySlide()
index c7382f1..4c92402 100755 (executable)
@@ -113,6 +113,28 @@ namespace ElmSharp
         }
 
         /// <summary>
+        /// Sets the vertical text alignment of layout's text part
+        /// </summary>
+        /// <remarks>
+        /// API, elm_layout_text_valign_set, is an internal API only in Tizen. Avalilable since Tizen_4.0.
+        /// </remarks>
+        public virtual void SetVerticalTextAlignment(string part, double valign)
+        {
+            Interop.Elementary.elm_layout_text_valign_set(RealHandle, part, valign);
+        }
+
+        /// <summary>
+        /// Gets the vertical text alignment of layout's text part
+        /// </summary>
+        /// <remarks>
+        /// API, elm_layout_text_valign_get, is internal API only in Tizen. Avalilable since Tizen_4.0.
+        /// </remarks>
+        public virtual double GetVerticalTextAlignment(string part)
+        {
+            return Interop.Elementary.elm_layout_text_valign_get(RealHandle, part);
+        }
+
+        /// <summary>
         /// Sets the content at a part of a given container widget.
         /// </summary>
         /// <param name="parent">The parent is a given container which will be attached by Layout as a child. It's <see cref="EvasObject"/> type.</param>
old mode 100644 (file)
new mode 100755 (executable)
index d326fc2..bf5c2d5
@@ -62,5 +62,19 @@ internal static partial class Interop
 
         [DllImport(Libraries.Elementary)]
         internal static extern bool elm_label_ellipsis_get(IntPtr obj);
+
+        [DllImport(Libraries.Elementary, EntryPoint = "elm_label_text_style_user_peek", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true, CharSet = CharSet.Ansi)]
+        internal static extern IntPtr _elm_label_text_style_user_peek(IntPtr obj);
+        internal static string elm_label_text_style_user_peek(IntPtr obj)
+        {
+            var text = _elm_label_text_style_user_peek(obj);
+            return Marshal.PtrToStringAnsi(text);
+        }
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_label_text_style_user_push(IntPtr obj, string style);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_label_text_style_user_pop(IntPtr obj);
     }
 }
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
index 1071b13..da07a4a
@@ -283,6 +283,12 @@ internal static partial class Interop
         internal static extern string elm_layout_data_get(IntPtr obj, string key);
 
         [DllImport(Libraries.Elementary)]
+        internal static extern void elm_layout_text_valign_set(IntPtr obj, string part, double valign);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern double elm_layout_text_valign_get(IntPtr obj, string part);
+
+        [DllImport(Libraries.Elementary)]
         internal static extern IntPtr elm_notify_add(IntPtr obj);
 
         [DllImport(Libraries.Elementary)]
index 7c54640..e7347fb 100755 (executable)
@@ -96,6 +96,7 @@
     <Compile Include="TC\IndexTest1.cs" />
     <Compile Include="TC\IndexTest2.cs" />
     <Compile Include="TC\LabelTest1.cs" />
+    <Compile Include="TC\LabelValignTest1.cs" />
     <Compile Include="TC\ListTest1.cs" />
     <Compile Include="TC\NaviframeTest1.cs" />
     <Compile Include="TC\NaviframeTest2.cs" />
index 5d837d6..25a2b56 100644 (file)
@@ -34,7 +34,7 @@ namespace ElmSharp.Test
 
             Label label1 = new Label(window);
             label1.Text = "[default valign=top] gyj <span valign=bottom>[bottom gyp]</span>, <span valign=top>[top gyp]</span>, <span valign=middle>[middle gyp]</span>";
-            label1.EdjeObject["elm.text"].TextStyle = "DEFAULT = 'color=#000000FF backing_color=#ff0000 backing=on font_size=25 align=left valign=top wrap=word'";
+            label1.TextStyle = "DEFAULT = 'color=#000000FF backing_color=#ff0000 backing=on font_size=25 align=left valign=top wrap=word'";
             label1.Resize(650, 0);
             var size = label1.EdjeObject["elm.text"].TextBlockFormattedSize;
             label1.Show();
@@ -44,7 +44,7 @@ namespace ElmSharp.Test
             Label label2 = new Label(window);
             label2.Move(0, size.Height + 10);
             label2.Text = "[default valign=middle] gyj <span valign=bottom>[bottom gyp]</span>, <span valign=top>[top gyp]</span>, <span valign=middle>[middle gyp]</span>";
-            label2.EdjeObject["elm.text"].TextStyle = "DEFAULT = 'color=#000000FF backing_color=#ff0000 backing=on font_size=25 align=left valign=middle wrap=word'";
+            label2.TextStyle = "DEFAULT = 'color=#000000FF backing_color=#ff0000 backing=on font_size=25 align=left valign=middle wrap=word'";
             label2.Resize(650, 0);
             size = label2.EdjeObject["elm.text"].TextBlockFormattedSize;
             label2.Show();
@@ -53,7 +53,7 @@ namespace ElmSharp.Test
             Label label3 = new Label(window);
             label3.Move(0, label2.Geometry.Y + size.Height + 10);
             label3.Text = "[default valign=bottom] gyj <span valign=bottom>[bottom gyp]</span>, <span valign=top>[top gyp]</span>, <span valign=middle>[middle gyp]</span>";
-            label3.EdjeObject["elm.text"].TextStyle = "DEFAULT = 'color=#000000FF backing_color=#ff0000 backing=on font_size=25 align=left valign=bottom wrap=word'";
+            label3.TextStyle = "DEFAULT = 'color=#000000FF backing_color=#ff0000 backing=on font_size=25 align=left valign=bottom wrap=word'";
             label3.Resize(650, 0);
             size = label3.EdjeObject["elm.text"].TextBlockFormattedSize;
             label3.Show();
index 55374cc..eaf5aeb 100644 (file)
@@ -57,16 +57,14 @@ namespace ElmSharp.Test
 
 
             label1.Text = "Jo Ann Buckner";
-            label1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#000000FF font_size=24 align=left valign=bottom wrap=word'";
-            label1.EdjeObject.EmitSignal("elm,state,text,visible", "elm");
+            label1.TextStyle = "DEFAULT='color=#000000FF font_size=24 align=left valign=bottom wrap=word'";
             label1.Show();
             label1.Resize(100000, 0);
             size = label1.EdjeObject["elm.text"].TextBlockFormattedSize;
             label1.Geometry = new Rect(55, 213, size.Width, size.Height);
 
             label2.Text = "Customer Success Engineer";
-            label2.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#000000FF font_size=16 align=left valign=bottom wrap=word'";
-            label2.EdjeObject.EmitSignal("elm,state,text,visible", "elm");
+            label2.TextStyle = "DEFAULT='color=#000000FF font_size=16 align=left valign=bottom wrap=word'";
             label2.Show();
 
             label2.Resize(100000, 0);
diff --git a/test/ElmSharp.Test/TC/LabelValignTest1.cs b/test/ElmSharp.Test/TC/LabelValignTest1.cs
new file mode 100644 (file)
index 0000000..a104a82
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * 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 LabelValignTest1 : TestCaseBase
+    {
+        public override string TestName => "LabelValignTest1";
+        public override string TestDescription => "To test Vertical align of Label";
+
+        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);
+
+            Conformant conformant = new Conformant(window);
+            conformant.Show();
+            Box box = new Box(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1
+            };
+            box.Show();
+            conformant.SetContent(box);
+
+            Box labelBox = new Box(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+                MinimumHeight = 400,
+                BackgroundColor = Color.Blue,
+            };
+            labelBox.Show();
+
+
+
+            Label label1 = new Label(window)
+            {
+                Text = "Align Test",
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1
+            };
+            label1.TextStyle = "DEFAULT = 'color=#000000FF font_size=100 align=center wrap=word'";
+            label1.Show();
+            labelBox.PackEnd(label1);
+
+            Button top = new Button(window)
+            {
+                Text = "Top",
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+            };
+
+            Button middle = new Button(window)
+            {
+                Text = "Middle",
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+            };
+            Button bottom = new Button(window)
+            {
+                Text = "bottom",
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+            };
+
+            top.Clicked += (s, e) =>
+            {
+                label1.SetPartValign("elm.text", 0);
+            };
+
+            middle.Clicked += (s, e) =>
+            {
+                label1.SetPartValign("elm.text", 0.5);
+            };
+
+            bottom.Clicked += (s, e) =>
+            {
+                label1.SetPartValign("elm.text", 1.0);
+            };
+
+            top.Show();
+            labelBox.Show();
+            middle.Show();
+            bottom.Show();
+            box.PackEnd(labelBox);
+            box.PackEnd(top);
+            box.PackEnd(middle);
+            box.PackEnd(bottom);
+        }
+    }
+}