From 03843deb5705a40ceccb9b33cb780f64b1a79b57 Mon Sep 17 00:00:00 2001 From: Ravi Nanjundappa Date: Thu, 6 Oct 2016 12:09:43 +0530 Subject: [PATCH] DALi C# binding - Change methods into Properties Inserted the property related code changes through swig .i files. Modified the examples accordingly. Change-Id: I659c3e8e3bef5a455b60405459b2744d77cc4fa4 Signed-off-by: Ravi Nanjundappa --- plugins/dali-swig/SWIG/events/actor-event.i | 61 +++++++++++++++++-- .../dali-swig/SWIG/events/animation-event.i | 59 ++++++++++++++---- plugins/dali-swig/SWIG/events/stage-event.i | 22 +++++++ plugins/dali-swig/examples/dali-test.cs | 4 +- plugins/dali-swig/examples/hello-world.cs | 4 +- plugins/dali-swig/examples/scroll-view.cs | 4 +- 6 files changed, 130 insertions(+), 24 deletions(-) diff --git a/plugins/dali-swig/SWIG/events/actor-event.i b/plugins/dali-swig/SWIG/events/actor-event.i index e325613713..634a753171 100644 --- a/plugins/dali-swig/SWIG/events/actor-event.i +++ b/plugins/dali-swig/SWIG/events/actor-event.i @@ -603,18 +603,67 @@ { return (IntPtr)swigCPtr; } - %} - %enddef + public Actor Parent + { + get + { + Actor parent = GetParent(); + return parent; + } + } + + public bool Vibility + { + get + { + bool visibility = IsVisible(); + return visibility; + } + } + + public float Opacity + { + set + { + SetOpacity(value); + } + } + + public float CurrentOpacity + { + get + { + float ret = GetCurrentOpacity(); + return ret; + } + } + + public bool StateFocusEnable + { + set + { + SetKeyboardFocusable(value); + } + get + { + bool focusable = IsKeyboardFocusable(); + return focusable; + } + } + +%} + +%enddef %define DALI_ACTOR_EVENTHANDLER_PARAM( NameSpace, ClassName) - ACTOR_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName); - ACTOR_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName); +ACTOR_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName); +ACTOR_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName); - %enddef +%enddef - namespace Dali +namespace Dali { DALI_ACTOR_EVENTHANDLER_PARAM( Dali, Actor); } diff --git a/plugins/dali-swig/SWIG/events/animation-event.i b/plugins/dali-swig/SWIG/events/animation-event.i index 8639532403..4415479021 100644 --- a/plugins/dali-swig/SWIG/events/animation-event.i +++ b/plugins/dali-swig/SWIG/events/animation-event.i @@ -16,17 +16,16 @@ */ %define Animation_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName) - %typemap(csimports) NameSpace::ClassName %{ - using System; - using System.Runtime.InteropServices; +%typemap(csimports) NameSpace::ClassName %{ +using System; +using System.Runtime.InteropServices; +%} - %} - %enddef +%enddef %define Animation_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName) %typemap(cscode) NameSpace::ClassName %{ - /** * @brief Event arguments that passed via Finished signal * @@ -112,15 +111,51 @@ } - public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) { - ClassName ret = new ClassName(cPtr, false); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; + public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) { + ClassName ret = new ClassName(cPtr, false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + + public float Duration + { + set + { + SetDuration(value); + } + get + { + float ret = GetDuration(); + return ret; + } + } + + public AlphaFunction DefaultAlphaFunction + { + set + { + SetDefaultAlphaFunction(value); + } + get + { + AlphaFunction ret = GetDefaultAlphaFunction(); + return ret; + } + } + + public Animation.State Status + { + get + { + Animation.State ret = GetState(); + return ret; } + } - %} +%} - %enddef +%enddef %define DALI_animation_EVENTHANDLER_PARAM( NameSpace, ClassName) diff --git a/plugins/dali-swig/SWIG/events/stage-event.i b/plugins/dali-swig/SWIG/events/stage-event.i index 5cdecafc31..62f372a0a2 100644 --- a/plugins/dali-swig/SWIG/events/stage-event.i +++ b/plugins/dali-swig/SWIG/events/stage-event.i @@ -544,6 +544,28 @@ public class SceneCreatedEventArgs : EventArgs } } + public Vector2 Size + { + get + { + Vector2 ret = GetSize(); + return ret; + } + } + + public Vector4 BackgroundColor + { + set + { + SetBackgroundColor(value); + } + get + { + Vector4 ret = GetBackgroundColor(); + return ret; + } + } + %} %enddef diff --git a/plugins/dali-swig/examples/dali-test.cs b/plugins/dali-swig/examples/dali-test.cs index 2e01c0216e..98eaab5839 100644 --- a/plugins/dali-swig/examples/dali-test.cs +++ b/plugins/dali-swig/examples/dali-test.cs @@ -59,9 +59,9 @@ namespace MyCSharpExample Console.WriteLine("Actor name: " + actor.Name); Stage stage = Stage.GetCurrent(); - stage.SetBackgroundColor( NDalic.WHITE ); + stage.BackgroundColor = NDalic.WHITE ; - Vector2 stageSize = stage.GetSize(); + Vector2 stageSize = stage.Size; Console.WriteLine("Stage size: " + stageSize.x + ", " + stageSize.y); stage.Add(actor); diff --git a/plugins/dali-swig/examples/hello-world.cs b/plugins/dali-swig/examples/hello-world.cs index 0a5a841254..c2caeb524b 100755 --- a/plugins/dali-swig/examples/hello-world.cs +++ b/plugins/dali-swig/examples/hello-world.cs @@ -47,7 +47,7 @@ namespace MyCSharpExample { Console.WriteLine("Customized Application Initialize event handler"); Stage stage = Stage.GetCurrent(); - stage.SetBackgroundColor( NDalic.WHITE ); + stage.BackgroundColor = NDalic.WHITE; stage.Touched += new Dali.Stage.TouchEventHandler(OnStageTouched); @@ -65,7 +65,7 @@ namespace MyCSharpExample public void AnimationFinished(object source, Animation.FinishedEventArgs e) { Console.WriteLine("Customized Animation Finished Event handler"); - Console.WriteLine("Animation finished: duration = " + e.Animation.GetDuration()); + Console.WriteLine("Animation finished: duration = " + e.Animation.Duration); } // Callback for stage touched signal handling diff --git a/plugins/dali-swig/examples/scroll-view.cs b/plugins/dali-swig/examples/scroll-view.cs index f8ea8c8f6c..09b6d4d563 100644 --- a/plugins/dali-swig/examples/scroll-view.cs +++ b/plugins/dali-swig/examples/scroll-view.cs @@ -48,11 +48,11 @@ namespace MyCSharpExample private void CreateScrollView() { Stage stage = Stage.GetCurrent(); - stage.SetBackgroundColor(NDalic.WHITE); + stage.BackgroundColor = NDalic.WHITE; // Create a scroll view _scrollView = new ScrollView(); - Vector2 stageSize = stage.GetSize(); + Vector2 stageSize = stage.Size; _scrollView.Size = new Vector3(stageSize.x, stageSize.y, 0.0f); _scrollView.ParentOrigin = NDalic.ParentOriginCenter; _scrollView.AnchorPoint = NDalic.AnchorPointCenter; -- 2.34.1