From: xb.teng Date: Mon, 10 Oct 2016 08:16:25 +0000 (+0800) Subject: This patch is for refining dali application to support tizen c# application. X-Git-Tag: dali_1.2.10~4^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=refs%2Fchanges%2F66%2F91566%2F4 This patch is for refining dali application to support tizen c# application. Change-Id: Iaced0cfddde8b9f9c45371b8f63cc9bd3cef1fb3 Signed-off-by: xb.teng --- diff --git a/plugins/dali-swig/SWIG/dali-adaptor.i b/plugins/dali-swig/SWIG/dali-adaptor.i old mode 100644 new mode 100755 index affa265..3ce308e --- a/plugins/dali-swig/SWIG/dali-adaptor.i +++ b/plugins/dali-swig/SWIG/dali-adaptor.i @@ -25,6 +25,7 @@ %include %include %include +%include %include #if defined(SWIGCSHARP) diff --git a/plugins/dali-swig/SWIG/dali.i b/plugins/dali-swig/SWIG/dali.i old mode 100644 new mode 100755 index 781a4ba..e76ba22 --- a/plugins/dali-swig/SWIG/dali.i +++ b/plugins/dali-swig/SWIG/dali.i @@ -57,6 +57,7 @@ #include #include #include +#include #include diff --git a/plugins/dali-swig/examples/hello-test.cs b/plugins/dali-swig/examples/hello-test.cs new file mode 100755 index 0000000..61726aa --- /dev/null +++ b/plugins/dali-swig/examples/hello-test.cs @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * 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.Runtime.InteropServices; +using Dali; +using Tizen.Applications; + +//------------------------------------------------------------------------------ +// +// +// This file can only run on Tizen target. You should compile it with DaliApplication.cs, and +// add tizen c# application related library as reference. +//------------------------------------------------------------------------------ +namespace MyCSharpExample +{ + class Example : DaliApplication + { + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate void CallbackDelegate(IntPtr data); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate void TouchCallbackDelegate(IntPtr data); + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate void AnimationCallbackDelegate(IntPtr data); + + private Animation _animation; + private TextLabel _text; + + public Example():base() + { + } + + private void Initialize() + { + // Connect the signal callback for stage touched signal + TouchCallbackDelegate stageTouchedCallback = new TouchCallbackDelegate(OnStageTouched); + stage.TouchSignal().Connect(stageTouchedCallback); + + // Add a _text label to the stage + _text = new TextLabel("Hello Mono World"); + _text.ParentOrigin = NDalic.ParentOriginCenter; + _text.AnchorPoint = NDalic.AnchorPointCenter; + _text.HorizontalAlignment = "CENTER"; + _text.PointSize = 32.0f; + + stage.Add(_text); + } + + // Callback for _animation finished signal handling + private void AnimationFinished(IntPtr data) + { + Animation _animation = Animation.GetAnimationFromPtr( data ); + Console.WriteLine("Animation finished: duration = " + _animation.GetDuration()); + } + + // Callback for stage touched signal handling + private void OnStageTouched(IntPtr data) + { + TouchData touchData = TouchData.GetTouchDataFromPtr( data ); + + // Only animate the _text label when touch down happens + if (touchData.GetState(0) == PointStateType.DOWN) + { + // Create a new _animation + if (_animation) + { + _animation.Reset(); + } + + _animation = new Animation(1.0f); // 1 second of duration + + _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion(new Radian(new Degree(180.0f)), Vector3.XAXIS)), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.0f, 0.5f)); + _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion(new Radian(new Degree(0.0f)), Vector3.XAXIS)), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.5f, 0.5f)); + + // Connect the signal callback for animaiton finished signal + AnimationCallbackDelegate animFinishedDelegate = new AnimationCallbackDelegate(AnimationFinished); + _animation.FinishedSignal().Connect(animFinishedDelegate); + + // Play the _animation + _animation.Play(); + } + } + + /// + /// The main entry point for the application. + /// + + [STAThread] + static void Main(string[] args) + { + Console.WriteLine("Hello mono world."); + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/plugins/dali-swig/manual/csharp/Tizen.Applications/DaliApplication.cs b/plugins/dali-swig/manual/csharp/Tizen.Applications/DaliApplication.cs new file mode 100755 index 0000000..06d7756 --- /dev/null +++ b/plugins/dali-swig/manual/csharp/Tizen.Applications/DaliApplication.cs @@ -0,0 +1,89 @@ +// Copyright 2016 by Samsung Electronics, Inc., +// +// This software is the confidential and proprietary information +// of Samsung Electronics, Inc. ("Confidential Information"). You +// shall not disclose such Confidential Information and shall use +// it only in accordance with the terms of the license agreement +// you entered into with Samsung. +using System; +using Dali; + +//------------------------------------------------------------------------------ +// +// +// This file can only run on Tizen target. You should compile it with hello-test.cs, and +// add tizen c# application related library as reference. +//------------------------------------------------------------------------------ +namespace Tizen.Applications +{ + /// + /// Represents an application that have UI screen. The DaliApplication class has a default stage. + /// + public class DaliApplication : CoreUIApplication + { + /// + /// The instance of the Dali Application. + /// + /// + /// This application is created before OnCreate() or created event. And the DaliApplication will be terminated when this application is closed. + /// + protected Dali.Application application; + protected Dali.ApplicationExtensions applicationExt; + + /// + /// The instance of the Dali Stage. + /// + public Stage stage { get; private set; } + + + /// + /// Overrides this method if want to handle behavior before calling OnCreate(). + /// stage property is initialized in this overrided method. + /// + protected override void OnPreCreate() + { + application = Dali.Application.NewApplication(); + applicationExt = new Dali::ApplicationExtensions(application); + applicationExt.Init(); + + stage = Stage.GetCurrent(); + stage.SetBackgroundColor( NDalic.WHITE ); + } + + /// + /// Overrides this method if want to handle behavior. + /// + protected override void OnTerminate() + { + base.OnTerminate(); + applicationExt.Terminate(); + } + + /// + /// Overrides this method if want to handle behavior. + /// + protected override void OnPause() + { + base.OnPause(); + applicationExt.Pause(); + } + + /// + /// Overrides this method if want to handle behavior. + /// + protected override void OnResume() + { + base.OnResume(); + applicationExt.Resume(); + } + + /// + /// Overrides this method if want to handle behavior. + /// + protected override void OnLocaleChanged(LocaleChangedEventArgs e) + { + base.OnLocaleChanged(e); + applicationExt.LanguageChange(); + } + } +}