[NUI] set default theme for TV profile
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Application / NUIApplication.cs
index 75f11ec..72b016c 100755 (executable)
@@ -14,6 +14,9 @@
  * limitations under the License.
  *
  */
+#if !PROFILE_TV
+#define ExternalThemeEnabled
+#endif
 
 using System;
 using System.ComponentModel;
@@ -37,6 +40,19 @@ namespace Tizen.NUI
         /// The instance of ResourceManager.
         /// </summary>
         private static System.Resources.ResourceManager resourceManager = null;
+        private static string currentLoadedXaml = null;
+
+        /// <summary>
+        /// The border window
+        /// </summary>
+        private bool borderEnabled = false;
+        private IBorderInterface borderInterface = null;
+
+        /// <summary>
+        /// Xaml loaded delegate.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public delegate void XamlLoadedHandler(string xamlName);
 
         static NUIApplication()
         {
@@ -124,7 +140,7 @@ namespace Tizen.NUI
         /// <param name="windowPosition"></param>
         /// <param name="styleSheet"></param>
         /// InhouseAPI, this could be opened in NextTizen
-        [Obsolete("Please do not use! This will be deprecated!")]
+        [Obsolete("Do not use! This will be deprecated!")]
         [EditorBrowsable(EditorBrowsableState.Never)]
         public NUIApplication(Graphics.BackendType backend, WindowMode windowMode = WindowMode.Opaque, Size2D windowSize = null, Position2D windowPosition = null, string styleSheet = "") : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
         {
@@ -158,22 +174,99 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// The constructor with a stylesheet, window mode, window size, position and default window type.
+        /// The constructor with a stylesheet, window mode and default window type.
+        /// It is the only way to create an IME window.
         /// </summary>
         /// <param name="styleSheet">The styleSheet URL.</param>
         /// <param name="windowMode">The windowMode.</param>
-        /// <param name="windowSize">The window size.</param>
-        /// <param name="windowPosition">The window position.</param>
         /// <param name="type">The default window type.</param>
         /// <since_tizen> 9 </since_tizen>
-        /// This should be hidden. Because the major purpose is to support IME window as keyboard application.
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public NUIApplication(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition, WindowType type) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition, type))
+        [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
+        public NUIApplication(string styleSheet, WindowMode windowMode, WindowType type) : base(new NUICoreBackend(styleSheet, windowMode, type))
         {
             ExternalThemeManager.Initialize();
         }
 
         /// <summary>
+        /// The constructor with a stylesheet, size, position, boderInterface and window mode
+        /// </summary>
+        /// <param name="styleSheet">The styleSheet URL.</param>
+        /// <param name="windowSize">The window size.</param>
+        /// <param name="windowPosition">The window position.</param>
+        /// <param name="borderInterface"><see cref="Tizen.NUI.IBorderInterface"/>If borderInterface is null, defaultBorder is enabled.</param>
+        /// <param name="windowMode">The windowMode.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
+        public NUIApplication(string styleSheet, Size2D windowSize, Position2D windowPosition, IBorderInterface borderInterface, WindowMode windowMode = WindowMode.Opaque) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
+        {
+            EnableBorder(borderInterface);
+        }
+
+        /// <summary>
+        /// The constructor with theme option and borderInterface.
+        /// </summary>
+        /// <param name="option">The theme option.</param>
+        /// <param name="borderInterface"><see cref="Tizen.NUI.IBorderInterface"/>If borderInterface is null, defaultBorder is enabled.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
+        public NUIApplication(ThemeOptions option, IBorderInterface borderInterface) : base(new NUICoreBackend())
+        {
+            EnableBorder(borderInterface);
+            ApplyThemeOption(option);
+        }
+
+        /// <summary>
+        /// The constructor with window size, position, theme option and borderInterface.
+        /// </summary>
+        /// <param name="windowSize">The window size.</param>
+        /// <param name="windowPosition">The window position.</param>
+        /// <param name="option">The theme option.</param>
+        /// <param name="borderInterface"><see cref="Tizen.NUI.IBorderInterface"/>If borderInterface is null, defaultBorder is enabled.</param>
+        [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public NUIApplication(Size2D windowSize, Position2D windowPosition, ThemeOptions option, IBorderInterface borderInterface) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition))
+        {
+            EnableBorder(borderInterface);
+            ApplyThemeOption(option);
+        }
+
+        /// <summary>
+        /// The constructor with a stylesheet, window mode, coretask
+        /// </summary>
+        /// <note>
+        /// There is the UI thread feature.
+        /// UI thread is an additional thread that an Application object creates. The thread is for UI events.
+        /// To enable the UI Thread, you have to pass CoreTask object using this contructor.
+        /// When the UI thread feature is enabled, The methods of CoreTask are emitted on the main thread,
+        /// and the NUIApplication's events are emitted on the UI thread.
+        /// If you want to handle windows or actors in cases like when the memory level of the device is low, you have to use the NUIApplication events, not the CoreTask methods.
+        /// The CoreTask is not for handling GUI.
+        /// Callbacks of the all events in NUIApplication except the CoreTask are emitted on the UI thread.
+        /// </note>
+        /// <param name="styleSheet">The styleSheet URL.</param>
+        /// <param name="windowMode">The windowMode.</param>
+        /// <param name="task">True If app creates a UI Thread</param>
+        [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public NUIApplication(string styleSheet, WindowMode windowMode, CoreTask task) : base(new NUICoreBackend(styleSheet, windowMode), task)
+        {
+        }
+
+        /// <summary>
+        /// The constructor with a stylesheet, window mode, window size, position, coretask
+        /// </summary>
+        /// <param name="styleSheet">The styleSheet URL.</param>
+        /// <param name="windowMode">The windowMode.</param>
+        /// <param name="windowSize">The window size.</param>
+        /// <param name="windowPosition">The window position.</param>
+        /// <param name="task">True If app creates a UI Thread</param>
+        [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public NUIApplication(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition, CoreTask task) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition), task)
+        {
+        }
+
+        /// <summary>
         /// Occurs whenever the application is resumed.
         /// </summary>
         /// <since_tizen> 4 </since_tizen>
@@ -186,6 +279,12 @@ namespace Tizen.NUI
         public event EventHandler Paused;
 
         /// <summary>
+        /// Xaml loaded event.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static event XamlLoadedHandler XamlLoaded;
+
+        /// <summary>
         /// Enumeration for deciding whether a NUI application window is opaque or transparent.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
@@ -232,6 +331,26 @@ namespace Tizen.NUI
         };
 
         /// <summary>
+        /// Current loaded xaml's full name.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static string CurrentLoadedXaml
+        {
+            get
+            {
+                return currentLoadedXaml;
+            }
+            set
+            {
+                if (currentLoadedXaml != value)
+                {
+                    currentLoadedXaml = value;
+                    XamlLoaded?.Invoke(value);
+                }
+            }
+        }
+
+        /// <summary>
         /// ResourceManager to handle multilingual.
         /// </summary>
         /// <since_tizen> 4 </since_tizen>
@@ -251,7 +370,7 @@ namespace Tizen.NUI
         /// Gets the window instance.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        [Obsolete("Please do not use! This will be deprecated!")]
+        [Obsolete("Do not use! This will be deprecated!")]
         [EditorBrowsable(EditorBrowsableState.Never)]
         public Window Window
         {
@@ -424,6 +543,14 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         protected virtual void OnPreCreate()
         {
+            Tizen.Tracer.Begin("[NUI] OnPreCreate()");
+
+            if (borderEnabled)
+            {
+                GetDefaultWindow().EnableBorder(borderInterface, new Window.BorderCloseDelegate(Exit));
+            }
+
+            Tizen.Tracer.End();
         }
 
         /// <summary>
@@ -446,7 +573,11 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         protected override void OnCreate()
         {
+            Tizen.Tracer.Begin("[NUI] OnCreate()");
+
             base.OnCreate();
+
+            Tizen.Tracer.End();
         }
 
         /// <summary>
@@ -456,26 +587,13 @@ namespace Tizen.NUI
         static public void Preload()
         {
             Interop.Application.PreInitialize();
+#if ExternalThemeEnabled
             ThemeManager.Preload();
+#endif
             IsPreload = true;
         }
 
         /// <summary>
-        /// This is used to improve application launch performance.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public void SendLaunchRequest(AppControl appControl)
-        {
-            TransitionOptions?.SendLaunchRequest(appControl);
-        }
-
-        /// <summary>
-        /// This is used to improve application launch performance.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public TransitionOptions TransitionOptions { get; set; }
-
-        /// <summary>
         /// Check if it is loaded as dotnet-loader-nui.
         /// </summary>
         static internal bool IsPreload { get; set; }
@@ -492,6 +610,12 @@ namespace Tizen.NUI
                 ThemeManager.ApplicationThemeChangeSensitive = true;
             }
         }
+
+        private void EnableBorder(IBorderInterface borderInterface)
+        {
+            borderEnabled = true;
+            this.borderInterface = borderInterface;
+        }
     }
 
     /// <summary>
@@ -499,7 +623,7 @@ namespace Tizen.NUI
     /// </summary>
     [SuppressMessage("Microsoft.Design", "CA1052:StaticHolderTypesShouldBeStaticOrNotInheritable")]
     [EditorBrowsable(EditorBrowsableState.Never)]
-    [Obsolete("Please do not use! This will be deprecated!")]
+    [Obsolete("Do not use! This will be deprecated!")]
     public class Graphics
     {
         /// <summary>