From: Seungkeun Lee Date: Thu, 3 May 2018 08:10:54 +0000 (+0900) Subject: [ElmSharp] Add RenderOperation property in EvasObject (#220) X-Git-Tag: 5.0.0.14562~233 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bffa931559cb704cdb6c64fd802a84c0b432a9dc;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [ElmSharp] Add RenderOperation property in EvasObject (#220) --- diff --git a/src/ElmSharp/ElmSharp/EvasObject.cs b/src/ElmSharp/ElmSharp/EvasObject.cs old mode 100755 new mode 100644 index 15334eb..9a8f07a --- a/src/ElmSharp/ElmSharp/EvasObject.cs +++ b/src/ElmSharp/ElmSharp/EvasObject.cs @@ -110,6 +110,73 @@ namespace ElmSharp } /// + /// How the object should be rendered to output. + /// + /// 5 + public enum RenderOp + { + /// + /// default op: d = d * (1 - sa) + s + /// + Blend = 0, + + /// + /// d = d*(1 - sa) + s*da + /// + BlendRel = 1, + + /// + /// d = s + /// + Copy = 2, + + /// + /// d = s*da + /// + CopyRel = 3, + + /// + /// d = d + s + /// + Add = 4, + + /// + /// d = d + s*da + /// + AddRel = 5, + + /// + /// d = d - s + /// + Sub = 6, + + /// + /// d = d - s*da + /// + SubRel = 7, + + /// + /// d = d*s + d*(1 - sa) + s*(1 - da) + /// + Tint = 8, + + /// + /// d = d*(1 - sa + s) + /// + TintRel = 9, + + /// + /// d = d*sa + /// + Mask = 10, + + /// + /// d = d*s + /// + Mul = 11 + } + + /// /// The EvasObject is a base class for other widget classes. /// /// preview @@ -738,6 +805,23 @@ namespace ElmSharp } /// + /// Sets or gets the render operation to be used for rendering the Evas object. + /// + /// 5 + 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); + } + } + + + /// /// Clips one object to another. /// /// The object to clip object by. diff --git a/src/ElmSharp/Interop/Interop.Evas.cs b/src/ElmSharp/Interop/Interop.Evas.cs index af4e749..e0357c2 100644 --- a/src/ElmSharp/Interop/Interop.Evas.cs +++ b/src/ElmSharp/Interop/Interop.Evas.cs @@ -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 index 0000000..855778d --- /dev/null +++ b/test/ElmSharp.Test/TC/RenderOpTest.cs @@ -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; + }; + + } + } +}