[ElmSharp] Add RenderOperation property in EvasObject (#220)
authorSeungkeun Lee <sngn.lee@samsung.com>
Thu, 3 May 2018 08:10:54 +0000 (17:10 +0900)
committerKangho <rookiejava+github@gmail.com>
Thu, 3 May 2018 08:10:54 +0000 (17:10 +0900)
src/ElmSharp/ElmSharp/EvasObject.cs [changed mode: 0755->0644]
src/ElmSharp/Interop/Interop.Evas.cs
test/ElmSharp.Test/TC/RenderOpTest.cs [new file with mode: 0644]

old mode 100755 (executable)
new mode 100644 (file)
index 15334eb..9a8f07a
@@ -110,6 +110,73 @@ namespace ElmSharp
     }
 
     /// <summary>
+    /// How the object should be rendered to output.
+    /// </summary>
+    /// <since_tizen> 5 </since_tizen>
+    public enum RenderOp
+    {
+        /// <summary>
+        /// default op: d = d * (1 - sa) + s
+        /// </summary>
+        Blend = 0,
+
+        /// <summary>
+        /// d = d*(1 - sa) + s*da
+        /// </summary>
+        BlendRel = 1,
+
+        /// <summary>
+        /// d = s
+        /// </summary>
+        Copy = 2,
+
+        /// <summary>
+        /// d = s*da
+        /// </summary>
+        CopyRel = 3,
+
+        /// <summary>
+        /// d = d + s
+        /// </summary>
+        Add = 4,
+
+        /// <summary>
+        /// d = d + s*da
+        /// </summary>
+        AddRel = 5,
+
+        /// <summary>
+        /// d = d - s
+        /// </summary>
+        Sub = 6,
+
+        /// <summary>
+        /// d = d - s*da
+        /// </summary>
+        SubRel = 7,
+
+        /// <summary>
+        /// d = d*s + d*(1 - sa) + s*(1 - da)
+        /// </summary>
+        Tint = 8,
+
+        /// <summary>
+        /// d = d*(1 - sa + s)
+        /// </summary>
+        TintRel = 9,
+
+        /// <summary>
+        /// d = d*sa
+        /// </summary>
+        Mask = 10,
+
+        /// <summary>
+        /// d = d*s
+        /// </summary>
+        Mul = 11
+    }
+
+    /// <summary>
     /// The EvasObject is a base class for other widget classes.
     /// </summary>
     /// <since_tizen> preview </since_tizen>
@@ -738,6 +805,23 @@ namespace ElmSharp
         }
 
         /// <summary>
+        /// Sets or gets the render operation to be used for rendering the Evas object.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        public RenderOp RenderOperation
+        {
+            get
+            {
+                return (RenderOp)Interop.Evas.evas_object_render_op_get(RealHandle);
+            }
+            set
+            {
+                Interop.Evas.evas_object_render_op_set(RealHandle, (Interop.Evas.RenderOp)value);
+            }
+        }
+
+
+        /// <summary>
         /// Clips one object to another.
         /// </summary>
         /// <param name="clip">The object to clip object by.</param>
index af4e749..e0357c2 100644 (file)
@@ -495,6 +495,9 @@ internal static partial class Interop
         internal static extern void evas_object_render_op_set(IntPtr obj, RenderOp op);
 
         [DllImport(Libraries.Evas)]
+        internal static extern RenderOp evas_object_render_op_get(IntPtr obj);
+
+        [DllImport(Libraries.Evas)]
         internal static extern void evas_object_size_hint_aspect_set(IntPtr obj, int aspect, int w, int h);
 
         [DllImport(Libraries.Evas)]
diff --git a/test/ElmSharp.Test/TC/RenderOpTest.cs b/test/ElmSharp.Test/TC/RenderOpTest.cs
new file mode 100644 (file)
index 0000000..855778d
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * 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.IO;
+
+namespace ElmSharp.Test
+{
+    public class RenderOpTest : TestCaseBase
+    {
+
+        public override string TestName => "RenderOperationTest";
+        public override string TestDescription => "RenderOperation test";
+
+        public override void Run(Window window)
+        {
+            Conformant conformant = new Conformant(window);
+            conformant.Show();
+
+            RenderOp renderOp = RenderOp.Blend;
+
+            var box = new Box(window)
+            {
+                AlignmentX = -1,
+                AlignmentY = -1,
+                WeightX = 1,
+                WeightY = 1,
+                BackgroundColor = Color.FromHex("00A0DC"),
+            };
+            box.SetLayoutCallback(() => { });
+            box.Show();
+            conformant.SetContent(box);;
+
+
+            var label = new Label(window);
+            label.Show();
+            box.PackEnd(label);
+            label.Geometry = new Rect(10, 10, 800, 100);
+            label.Text = "RenderOperation : Blend(Default)";
+            label.TextStyle = "DEFAULT = 'color=#000000FF font_size=25'";
+            var size = label.EdjeObject["elm.text"].TextBlockFormattedSize;
+            label.Geometry = new Rect(10, 10, size.Width+300, size.Height);
+
+            var box11 = new Rectangle(window)
+            {
+                Color = Color.FromRgba(255, 0, 0, 200)
+            };
+            box.PackEnd(box11);
+            box11.Show();
+            box11.Geometry = new Rect(50, 70, 100, 300);
+
+            var box12 = new Rectangle(window)
+            {
+                Color = Color.FromRgba(0, 255, 0, 200)
+            };
+            box.PackEnd(box12);
+            box12.Show();
+            box12.Geometry = new Rect(50+100, 70, 100, 300);
+
+            var box13 = new Rectangle(window)
+            {
+                Color = Color.FromRgba(0, 0, 250, 200)
+            };
+            box.PackEnd(box13);
+            box13.Show();
+            box13.Geometry = new Rect(50+200, 70, 100, 300);
+
+            var box2 = new Rectangle(window)
+            {
+                Color = Color.FromRgba(0, 255, 100, 200)
+            };
+
+            box.PackEnd(box2);
+            box2.Show();
+            box2.Geometry = new Rect(50, 70 + 100, 300, 300);
+
+            box2.RenderOperation = renderOp;
+
+            var btn = new Button(window) { Text = "Change Render operation" };
+            box.PackEnd(btn);
+            btn.Show();
+
+            btn.Geometry = new Rect(50, 500, 600, 60);
+
+            btn.Clicked += (s, e) =>
+            {
+                renderOp += 1;
+                if (renderOp > RenderOp.Mul)
+                {
+                    renderOp = 0;
+                }
+                switch (renderOp)
+                {
+                    case RenderOp.Add:
+                        label.Text = "RenderOperation : Add (d = d + s)";
+                        break;
+                    case RenderOp.AddRel:
+                        label.Text = "RenderOperation : AddRel (d = d + s*da)";
+                        break;
+                    case RenderOp.Blend:
+                        label.Text = "RenderOperation : Blend (d = d * (1 - sa) + s) default";
+                        break;
+                    case RenderOp.BlendRel:
+                        label.Text = "RenderOperation : BlendRel (d = d*(1 - sa) + s*da)";
+                        break;
+                    case RenderOp.Copy:
+                        label.Text = "RenderOperation : Copy (d = s)";
+                        break;
+                    case RenderOp.CopyRel:
+                        label.Text = "RenderOperation : CopyRel (d = s*da)";
+                        break;
+                    case RenderOp.Mask:
+                        label.Text = "RenderOperation : Mask (d = d*sa)";
+                        break;
+                    case RenderOp.Mul:
+                        label.Text = "RenderOperation : Mul (d = d*s)";
+                        break;
+                    case RenderOp.Sub:
+                        label.Text = "RenderOperation : Sub (d = d - s)";
+                        break;
+                    case RenderOp.SubRel:
+                        label.Text = "RenderOperation : SubRel (d = d - s*da)";
+                        break;
+                    case RenderOp.Tint:
+                        label.Text = "RenderOperation : Tint (d = d*s + d*(1 - sa) + s*(1 - da))";
+                        break;
+                    case RenderOp.TintRel:
+                        label.Text = "RenderOperation : TintRel (d = d*(1 - sa + s))";
+                        break;
+                }
+                box2.RenderOperation = renderOp;
+            };
+
+        }
+    }
+}