From 6f40261cc2e1ac7edcaca251706b7cb179f586ca Mon Sep 17 00:00:00 2001 From: "minho.sun" Date: Tue, 1 Aug 2017 10:18:39 +0900 Subject: [PATCH] Revert "[Tizen] Revert "Delete elementary dependency of ui_app_main"" This reverts commit a1024c90249fa288c76481aa1cb5b9b1bc244520. Change-Id: I66f6d96b85c4d1633a36fcb33c9bd778dadd6065 --- packaging/csapi-nui.spec | 2 +- src/Tizen.NUI/Tizen.NUI.csproj | 4 +- src/Tizen.NUI/src/internal/Application.cs | 4 +- src/Tizen.NUI/src/internal/NUICoreBackend.cs | 247 ++++++++++++++++++++++++ src/Tizen.NUI/src/internal/NUIEventType.cs | 47 +++++ src/Tizen.NUI/src/public/BaseComponents/View.cs | 12 +- src/Tizen.NUI/src/public/NUIApplication.cs | 190 ++++++------------ 7 files changed, 372 insertions(+), 134 deletions(-) create mode 100755 src/Tizen.NUI/src/internal/NUICoreBackend.cs create mode 100755 src/Tizen.NUI/src/internal/NUIEventType.cs diff --git a/packaging/csapi-nui.spec b/packaging/csapi-nui.spec index c59f6d7..3f444eb 100755 --- a/packaging/csapi-nui.spec +++ b/packaging/csapi-nui.spec @@ -1,6 +1,6 @@ Name: csapi-nui Summary: dali-NUI -Version: 0.2.49 +Version: 0.2.48.pre1 Release: 1 Group: Development/Libraries License: Apache-2.0 and BSD-3-Clause and MIT diff --git a/src/Tizen.NUI/Tizen.NUI.csproj b/src/Tizen.NUI/Tizen.NUI.csproj index 63d87d8..99e5b91 100755 --- a/src/Tizen.NUI/Tizen.NUI.csproj +++ b/src/Tizen.NUI/Tizen.NUI.csproj @@ -1,7 +1,7 @@  - 0.2.49 + 0.2.48-pre1 Samsung Electronics © Samsung Electronics Co., Ltd All Rights Reserved @@ -25,7 +25,7 @@ - + diff --git a/src/Tizen.NUI/src/internal/Application.cs b/src/Tizen.NUI/src/internal/Application.cs index 105b893..4e68bfe 100755 --- a/src/Tizen.NUI/src/internal/Application.cs +++ b/src/Tizen.NUI/src/internal/Application.cs @@ -25,10 +25,10 @@ namespace Tizen.NUI { public const int ver1 = 1; public const int ver2 = 2; - public const int ver3 = 49; + public const int ver3 = 46; public const int nuiVer1 = 0; public const int nuiVer2 = 2; - public const int nuiVer3 = 49; + public const int nuiVer3 = 47; public const string nuiRelease = ""; } diff --git a/src/Tizen.NUI/src/internal/NUICoreBackend.cs b/src/Tizen.NUI/src/internal/NUICoreBackend.cs new file mode 100755 index 0000000..20dff95 --- /dev/null +++ b/src/Tizen.NUI/src/internal/NUICoreBackend.cs @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2017 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.Collections.Generic; + +using Tizen.Applications.CoreBackend; +using Tizen.Applications; +using Tizen.NUI; + +namespace Tizen.NUI +{ + class NUICoreBackend : ICoreBackend + { + /// + /// Application instance to connect event. + /// + protected Application _application; + + /// + /// Dictionary to contain each type of event callback. + /// + protected IDictionary Handlers = new Dictionary(); + + /// + /// The default Constructor. + /// + public NUICoreBackend() + { + _application = Application.NewApplication(); + } + + /// + /// The constructor with stylesheet. + /// + public NUICoreBackend(string stylesheet) + { + _application = Application.NewApplication(stylesheet); + } + + /// + /// The constructor with stylesheet and window mode. + /// + public NUICoreBackend(string stylesheet, NUIApplication.WindowMode windowMode) + { + _application = Application.NewApplication(stylesheet, (Application.WindowMode)windowMode ); + } + + /// + /// Add NUIApplication event to Application. + /// Put each type of event callback in Dictionary. + /// + /// Type of event + /// Event callback + public void AddEventHandler(EventType evType, Action handler) + { + Handlers.Add(evType, handler); + } + + /// + /// Add NUIApplication event to Application. + /// Put each type of event callback in Dictionary. + /// + /// Argument type for the event + /// Type of event + /// Event callback + public void AddEventHandler(EventType evType, Action handler) where TEventArgs : EventArgs + { + Handlers.Add(evType, handler); + } + + + /// + /// Dispose function. + /// + public void Dispose() + { + _application.Dispose(); + } + + /// + /// Exit Application. + /// + public void Exit() + { + _application.Quit(); + } + + /// + /// Run Application. + /// + /// Arguments from commandline. + public void Run(string[] args) + { + _application.BatteryLow += OnBatteryLow; + _application.LanguageChanged += OnLanguageChanged; + _application.MemoryLow += OnMemoryLow; + _application.RegionChanged += OnRegionChanged; + + _application.Initialized += OnInitialized; + _application.Resumed += OnResumed; + _application.Terminating += OnTerminated; + _application.Paused += OnPaused; + _application.AppControl += OnAppControl; + + _application.MainLoop(); + } + + /// + /// Region changed event callback function. + /// + /// Application instance + /// Event argument for RegionChanged + private void OnRegionChanged(object source, NUIApplicationRegionChangedEventArgs e) + { + Log.Debug("NUI", "NUICorebackend OnRegionChanged Called"); + var handler = Handlers[EventType.RegionFormatChanged] as Action; + // Need to make new signal return in native to return right value. + handler?.Invoke( new RegionFormatChangedEventArgs("")); + } + + /// + /// Memory Low event callback function. + /// + /// Application instance + /// Event argument for MemoryLow + private void OnMemoryLow(object source, NUIApplicationMemoryLowEventArgs e) + { + Log.Debug("NUI", "NUICorebackend OnMemoryLow Called"); + var handler = Handlers[EventType.LowMemory] as Action; + // Need to make new signal return in native to return right value. + handler?.Invoke( new LowMemoryEventArgs(LowMemoryStatus.None)); + } + + /// + /// Language changed event callback function. + /// + /// Application instance + /// Event argument for LanguageChanged + private void OnLanguageChanged(object source, NUIApplicationLanguageChangedEventArgs e) + { + Log.Debug("NUI", "NUICorebackend OnLanguageChanged Called"); + var handler = Handlers[EventType.LocaleChanged] as Action; + // Need to make new signal return in native to return right value. + handler?.Invoke( new LocaleChangedEventArgs("")); + } + + /// + /// Battery low event callback function. + /// + /// Application instance + /// Event argument for BatteryLow + private void OnBatteryLow(object source, NUIApplicationBatteryLowEventArgs e) + { + Log.Debug("NUI", "NUICorebackend OnBatteryLow Called"); + var handler = Handlers[EventType.LowBattery] as Action; + // Need to make new signal return in native to return right value. + handler?.Invoke(new LowBatteryEventArgs(LowBatteryStatus.None)); + } + + /// + /// Initialized event callback function. + /// + /// Application instance + /// Event argument for Initialized + private void OnInitialized(object source, NUIApplicationInitEventArgs e) + { + Log.Debug("NUI", "NUICorebackend OnInitialized Called"); + var handler = Handlers[EventType.Created] as Action; + handler?.Invoke(); + } + + /// + /// Terminated event callback function. + /// + /// Application instance + /// Event argument for Terminated + private void OnTerminated(object source, NUIApplicationTerminatingEventArgs e) + { + Log.Debug("NUI", "NUICorebackend OnTerminated Called"); + var handler = Handlers[EventType.Terminated] as Action; + handler?.Invoke(); + } + + /// + /// Resumed event callback function. + /// + /// Application instance + /// Event argument for Resumed + private void OnResumed(object source, NUIApplicationResumedEventArgs e) + { + Log.Debug("NUI", "NUICorebackend OnResumed Called"); + var handler = Handlers[EventType.Resumed] as Action; + handler?.Invoke(); + } + + /// + /// App control event callback function. + /// + /// Application instance + /// Event argument for AppControl + private void OnAppControl(object source, NUIApplicationAppControlEventArgs e) + { + Log.Debug("NUI", "NUICorebackend OnAppControl Called"); + /* can invoke after making new api which getting control handle at application. + var handler = Handlers[EventType.AppControlReceived] as Action; + handler?.Invoke(); + */ + } + + /// + /// Paused event callback function. + /// + /// Application instance + /// Event argument for Paused + private void OnPaused(object source, NUIApplicationPausedEventArgs e) + { + Log.Debug("NUI", "NUICorebackend OnPaused Called"); + var handler = Handlers[EventType.Paused] as Action; + handler?.Invoke(); + } + + + internal Application ApplicationHandle + { + get + { + return _application; + } + } + + } +} diff --git a/src/Tizen.NUI/src/internal/NUIEventType.cs b/src/Tizen.NUI/src/internal/NUIEventType.cs new file mode 100755 index 0000000..a9ee287 --- /dev/null +++ b/src/Tizen.NUI/src/internal/NUIEventType.cs @@ -0,0 +1,47 @@ +/* Copyright(c) 2017 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 Tizen.Applications.CoreBackend; + +namespace Tizen.NUI +{ + /// + /// Class that represents the type of NUI event for backends. This class can be converted from string type. + /// + public class NUIEventType : EventType + { + /// + /// Initializes the EventType class. + /// + /// The name of event type. + public NUIEventType(string name) : base(name) + { + } + + /// + /// Pre-defined event type. "Reset" + /// + public static readonly NUIEventType Reset = "Reset"; + + /// + /// Converts a string to NUIEventType instance. + /// + public static implicit operator NUIEventType(string value) + { + return new NUIEventType(value); + } + } +} diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 7646242..b9ff096 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -2125,9 +2125,19 @@ namespace Tizen.NUI.BaseComponents /*internal View GetParent() { + View ret; IntPtr cPtr = NDalicPINVOKE.Actor_GetParent(swigCPtr); - View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View; + BaseHandle basehandle = Registry.GetManagedBaseHandleFromNativePtr(cPtr); + + if(basehandle is Layer) + { + ret = new View(cPtr,false); + } + else + { + ret = basehandle as View; + } if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); diff --git a/src/Tizen.NUI/src/public/NUIApplication.cs b/src/Tizen.NUI/src/public/NUIApplication.cs index 6f2fda0..b5bdacb 100755 --- a/src/Tizen.NUI/src/public/NUIApplication.cs +++ b/src/Tizen.NUI/src/public/NUIApplication.cs @@ -17,6 +17,7 @@ using System; using Tizen.Applications; +using Tizen.Applications.CoreBackend; using Tizen.NUI; namespace Tizen.NUI @@ -25,203 +26,145 @@ namespace Tizen.NUI /// /// Represents an application that have UI screen. The NUIApplication class has a default stage. /// - public class NUIApplication : CoreUIApplication + public class NUIApplication : CoreApplication { /// - /// The instance of the Application. - /// - /// - /// This application is created before OnCreate() or created event. And the NUIApplication will be terminated when this application is closed. - /// - private Application _application; - - /// - /// The instance of the Dali Application extension. - /// - private ApplicationExtensions _applicationExt; - - /// - /// Store the stylesheet value. - /// - private string _stylesheet; - - /// - /// Store the window mode value. - /// - private Application.WindowMode _windowMode; - - /// - /// Store the app mode value. - /// - private AppMode _appMode; - - /// - /// The instance of the Dali Stage. - /// - private Window _window; - - /// /// The default constructor. /// - public NUIApplication() : base() + public NUIApplication() : base(new NUICoreBackend()) { - _appMode = AppMode.Default; } /// /// The constructor with stylesheet. /// - public NUIApplication(string stylesheet) : base() + public NUIApplication(string stylesheet) : base(new NUICoreBackend(stylesheet)) { - //handle the stylesheet - _appMode = AppMode.StyleSheetOnly; - _stylesheet = stylesheet; } /// /// The constructor with stylesheet and window mode. /// - public NUIApplication(string stylesheet, WindowMode windowMode) : base() + public NUIApplication(string stylesheet, WindowMode windowMode) : base(new NUICoreBackend(stylesheet,windowMode)) { - //handle the stylesheet and windowMode - _appMode = AppMode.StyleSheetWithWindowMode; - _stylesheet = stylesheet; - _windowMode = (Application.WindowMode)windowMode; } /// /// Overrides this method if want to handle behavior. /// - protected override void OnPause() + protected override void OnLocaleChanged(LocaleChangedEventArgs e) { - base.OnPause(); - _applicationExt.Pause(); - NUILog.Debug("OnPause() is called!"); } /// - /// Overrides this method if want to handle behavior before calling OnCreate().
- /// stage property is initialized in this overrided method.
+ /// Overrides this method if want to handle behavior. ///
- protected override void OnPreCreate() + protected override void OnLowBattery(LowBatteryEventArgs e) { - // Initialize DisposeQueue Singleton class. - DisposeQueue disposeQ = DisposeQueue.Instance; - NUILog.Debug("1) DisposeQueue.Instance.Initialize()!"); - switch (_appMode) - { - case AppMode.Default: - _application = Tizen.NUI.Application.NewApplication(); - break; - case AppMode.StyleSheetOnly: - _application = Tizen.NUI.Application.NewApplication(_stylesheet); - break; - case AppMode.StyleSheetWithWindowMode: - _application = Tizen.NUI.Application.NewApplication(_stylesheet, _windowMode); - break; - default: - break; - } - _applicationExt = new ApplicationExtensions(_application); - _applicationExt.Init(); - _applicationExt.Start(); - - // This is also required to create DisposeQueue on main thread. - disposeQ.Initialize(); - NUILog.Debug("2) DisposeQueue.Instance.Initialize()!"); - _window = Window.Instance; - _window.SetBackgroundColor(Color.White); - NUILog.Debug("OnPreCreate() is called!"); + Log.Debug("NUI", "OnLowBattery() is called!"); } /// /// Overrides this method if want to handle behavior. /// - protected override void OnResume() + protected override void OnLowMemory(LowMemoryEventArgs e) { - base.OnResume(); - _applicationExt.Resume(); - NUILog.Debug("OnResume() is called!"); + Log.Debug("NUI", "OnLowMemory() is called!"); } /// /// Overrides this method if want to handle behavior. /// - protected override void OnAppControlReceived(AppControlReceivedEventArgs e) + protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e) { - base.OnAppControlReceived(e); - NUILog.Debug("OnAppControlReceived() is called!"); - if (e != null) - { - NUILog.Debug("OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId); - NUILog.Debug("CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest); - } + Log.Debug("NUI", "OnRegionFormatChanged() is called!"); } /// /// Overrides this method if want to handle behavior. /// - protected override void OnCreate() + protected override void OnTerminate() { - base.OnCreate(); - NUILog.Debug("OnCreate() is called!"); + Log.Debug("NUI", "OnTerminate() is called!"); } /// /// Overrides this method if want to handle behavior. /// - protected override void OnLocaleChanged(LocaleChangedEventArgs e) + protected void OnPause() { - base.OnLocaleChanged(e); - _applicationExt.LanguageChange(); - NUILog.Debug("OnLocaleChanged() is called!"); } /// /// Overrides this method if want to handle behavior. /// - protected override void OnLowBattery(LowBatteryEventArgs e) + protected void OnResume() { - base.OnLowBattery(e); - NUILog.Debug("OnLowBattery() is called!"); + Log.Debug("NUI", "OnResume() is called!"); } /// /// Overrides this method if want to handle behavior. /// - protected override void OnLowMemory(LowMemoryEventArgs e) + protected override void OnAppControlReceived(AppControlReceivedEventArgs e) { - base.OnLowMemory(e); - NUILog.Debug("OnLowMemory() is called!"); + Log.Debug("NUI", "OnAppControlReceived() is called!"); + if (e != null) + { + Log.Debug("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId); + Log.Debug("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest); + } } /// /// Overrides this method if want to handle behavior. /// - protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e) + protected override void OnCreate() { - base.OnRegionFormatChanged(e); - NUILog.Debug("OnRegionFormatChanged() is called!"); + // This is also required to create DisposeQueue on main thread. + DisposeQueue disposeQ = DisposeQueue.Instance; + disposeQ.Initialize(); + Log.Debug("NUI","OnCreate() is called!"); } /// - /// Overrides this method if want to handle behavior. + /// Run NUIApplication. /// - protected override void OnTerminate() + /// Arguments from commandline. + public override void Run(string[] args) { - base.OnTerminate(); - _applicationExt.Terminate(); - NUILog.Debug("OnTerminate() is called!"); + string[] argsClone = null; + + if (args == null) + { + argsClone = new string[1]; + } + else + { + argsClone = new string[args.Length + 1]; + args.CopyTo(argsClone, 1); + } + argsClone[0] = string.Empty; + + Backend.AddEventHandler(EventType.Resumed, OnResume); + Backend.AddEventHandler(EventType.AppControlReceived, OnAppControlReceived); + Backend.AddEventHandler(EventType.Paused, OnPause); + Backend.AddEventHandler(EventType.Terminated, OnTerminate); + Backend.AddEventHandler(EventType.RegionFormatChanged, OnRegionFormatChanged); + Backend.AddEventHandler(EventType.LowMemory, OnLowMemory); + Backend.AddEventHandler(EventType.LowBattery, OnLowBattery); + Backend.AddEventHandler(EventType.LocaleChanged, OnLocaleChanged); + Backend.AddEventHandler(EventType.Created, OnCreate); + + Backend.Run(argsClone); } /// - /// The mode of creating NUI application. + /// Exit NUIApplication. /// - private enum AppMode + public override void Exit() { - Default = 0, - StyleSheetOnly = 1, - StyleSheetWithWindowMode = 2 + Backend.Exit(); } /// @@ -233,23 +176,14 @@ namespace Tizen.NUI Transparent = 1 } - /// - /// Get the window instance. - /// - public Window Window - { - get - { - return _application.GetWindow(); - } - } internal Application ApplicationHandle { get { - return _application; + return ((NUICoreBackend)this.Backend).ApplicationHandle; } } + } } -- 2.7.4