--- /dev/null
+/*
+ * Copyright(c) 2024 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 Tizen.Applications.ComponentBased.Common;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// Window information class for ComponentApplication
+ /// </summary>
+ internal class NUIWindowProxy : IWindowProxy
+ {
+ private const string logTag = "Tizen.NUI";
+ private Window window;
+ private int resourceId;
+ private bool disposed = false;
+
+ /// <summary>
+ /// Initializes the NUI Window class.
+ /// </summary>
+ /// <param name="win">The window object of component.</param>
+ internal NUIWindowProxy(Window win)
+ {
+ window = win;
+ }
+
+ /// <summary>
+ /// Gets the resource ID of window
+ /// </summary>
+ /// <returns>The native handle of window</returns>
+ public int ResourceId
+ {
+ get
+ {
+ if (resourceId == 0)
+ {
+ resourceId = window.GetNativeId();
+ if (resourceId != 0)
+ Log.Info(logTag, "Fail to get resource ID");
+ }
+
+ return resourceId;
+ }
+ }
+
+ public void InitializeWindow(int width, int height)
+ {
+ window.WindowSize = new Size(width, height);
+ }
+
+ /// <summary>
+ /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
+ /// </summary>
+ /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposed)
+ return;
+
+ if (disposing)
+ {
+ window.Dispose();
+ window = null;
+ }
+ disposed = true;
+ }
+
+ /// <summary>
+ /// Dispose the window resources
+ /// </summary>
+ /// <returns></returns>
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ }
+}
+
using System.ComponentModel;
using Tizen.Applications;
using Tizen.Applications.ComponentBased.Common;
+using System.Threading;
namespace Tizen.NUI
{
[EditorBrowsable(EditorBrowsableState.Never)]
public NUIComponentApplication(IDictionary<Type, string> typeInfo) : base(new NUIComponentCoreBackend())
{
+ Registry.Instance.SavedApplicationThread = Thread.CurrentThread;
if (typeInfo != null)
{
foreach (var component in typeInfo)
{
componentFactories.Add(compType, new ServiceComponentStateManager(compType, compId, null));
}
+ else if (typeof(WidgetComponent).IsAssignableFrom(compType))
+ {
+ componentFactories.Add(compType, new WidgetComponentStateManager(compType, compId, null));
+ }
else
{
throw new ArgumentException("compType must be sub type of FrameComponent or ServiceComponent", nameof(compType));
--- /dev/null
+/*
+ * Copyright (c) 2024 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.ComponentModel;
+using Tizen.Applications;
+using Tizen.Applications.ComponentBased.Common;
+
+namespace Tizen.NUI
+{
+ /// <summary>
+ /// The class for showing UI module
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class NUIWidgetComponent : WidgetComponent
+ {
+ private bool defaultWindowSet = false;
+ internal NUIWindowProxy NUIWindowProxy
+ {
+ get;
+ set;
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Window Window
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Overrides this method to create window. It will be called before OnCreate method.
+ /// </summary>
+ /// <returns>Window object to use</returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override IWindowProxy CreateWindowInfo(int width, int height)
+ {
+ ComponentApplication instance = ComponentApplication.Instance as ComponentApplication;
+ if (instance != null)
+ {
+ if (!defaultWindowSet)
+ {
+ instance.GetWindow().WindowPositionSize = new Rectangle(0, 0, 1, 1);
+ instance.GetWindow().BackgroundColor = new Color(0, 0, 0, 0);
+ instance.GetWindow().Hide();
+ defaultWindowSet = true;
+ }
+
+ Window = new Window(new Rectangle(0, 0, width, height), false);
+ Window.Show();
+ }
+ NUIWindowProxy = new NUIWindowProxy(Window);
+ return NUIWindowProxy;
+ }
+
+ /// <summary>
+ /// Overrides this method to handle behavior when the component is launched.
+ /// </summary>
+ /// <returns>True if a service component is successfully created</returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool OnCreate(int width, int height)
+ {
+ return true;
+ }
+
+ /// <summary>
+ /// Overrides this method if you want to handle behavior when the component receives the appcontrol message.
+ /// </summary>
+ /// <param name="restarted">True if it was restarted</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnStart(bool restarted)
+ {
+ base.OnStart(restarted);
+ }
+
+ /// <summary>
+ /// Overrides this method if you want to handle the behavior when the component is resumed.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnResume()
+ {
+ base.OnResume();
+ }
+
+ /// <summary>
+ /// Overrides this method if you want to handle the behavior when the component is paused.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnPause()
+ {
+ base.OnPause();
+ }
+
+ /// <summary>
+ /// Overrides this method if you want to handle the behavior when the component is stopped.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnStop()
+ {
+ base.OnStop();
+ }
+
+ /// <summary>
+ /// Overrides this method if want to handle behavior when the component is destroyed.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnDestroy(bool permanent)
+ {
+ base.OnDestroy(permanent);
+ }
+ }
+}
+
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using Tizen.Applications;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+
+namespace NUIWidgetComponentApplicationSample
+{
+ public class Program : NUIComponentApplication
+ {
+ public static MyWidgetComponent myWidget = null;
+
+ public Program(IDictionary<Type, string> typeInfo) : base(typeInfo)
+ {
+ }
+
+ public class MyWidgetComponent : NUIWidgetComponent
+ {
+ private TextLabel text;
+ private Animation animation;
+
+ public override bool OnCreate(int width, int height)
+ {
+ myWidget = this;
+ Tizen.Log.Error("MYLOG", "MyWidgetComponent OnCreate .. START ,size:" + width +"x"+height);
+ Window.BackgroundColor = Color.Yellow;
+ Window.WindowSize = new Size(width, height);
+ text = new TextLabel("Widget Component");
+ text.HorizontalAlignment = HorizontalAlignment.Center;
+ text.VerticalAlignment = VerticalAlignment.Center;
+ text.TextColor = Color.Black;
+ text.PointSize = 20.0f;
+ text.HeightResizePolicy = ResizePolicyType.FillToParent;
+ text.WidthResizePolicy = ResizePolicyType.FillToParent;
+ Window.Add(text);
+ Tizen.Log.Error("MYLOG", "MyWidgetComponent OnCreate.. DONE");
+
+ animation = new Animation(3000);
+ animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
+ animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
+ animation.Looping = true;
+ animation.Play();
+ return true;
+ }
+
+ public override void OnDestroy(bool permanent)
+ {
+ Tizen.Log.Error("MYLOG", "MyWidgetComponent OnDestroy");
+ text.Dispose();
+ animation.Dispose();
+ }
+
+ public override void OnPause()
+ {
+ Tizen.Log.Error("MYLOG", "MyWidgetComponent OnPause");
+ }
+
+ public override void OnResume()
+ {
+ Tizen.Log.Error("MYLOG", "MyWidgetComponent OnResume");
+ }
+
+ public override void OnStart(bool restarted)
+ {
+ Tizen.Log.Error("MYLOG", "MyWidgetComponent OnStart");
+ }
+
+ public override void OnStop()
+ {
+ Tizen.Log.Error("MYLOG", "MyWidgetComponent OnStop");
+ }
+ }
+
+ static void Main(string[] args)
+ {
+ Dictionary<Type, string> dict = new Dictionary<Type, string>();
+ dict.Add(typeof(MyWidgetComponent), "csharp_widget");
+ var app = new Program(dict);
+ app.Run(args);
+ app.Dispose();
+ }
+ }
+}
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>net6.0</TargetFramework>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugType>portable</DebugType>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>None</DebugType>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Folder Include="lib\" />
+ <Folder Include="res\" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\..\src\Tizen.NUI\Tizen.NUI.csproj" />
+ <PackageReference Include="Tizen.NET.Sdk" Version="1.0.0" />
+ </ItemGroup>
+
+</Project>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="5" package="org.tizen.example.NUIWidgetComponentApplication" version="1.0.0">
+ <profile name="common" />
+ <component-based-application appid="org.tizen.example.NUIWidgetComponentApplication"
+ exec="NUIWidgetComponentApplication.dll"
+ type="dotnet-nui"
+ multiple="false"
+ taskmanage="true"
+ nodisplay="false"
+ launch_mode="single">
+ <label>NUIWidgetComponentApplication</label>
+ <icon>NUIWidgetComponentApplication.png</icon>
+ <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
+ <widget-component id="csharp_widget" launch_mode="caller" main="false" icon-display="false" taskmanage="true" update-period="0">
+ <icon>org.tizen.sample.png</icon>
+ <label>WidgetComponent</label>
+ <label xml:lang="en-us">WidgetComponent</label>
+ <label xml:lang="ko-kr">WidgetComponent[KOR]</label>
+ <support-size preview="org.tizen.sample.png">4x4</support-size>
+ </widget-component>
+ </component-based-application >
+</manifest>
--- /dev/null
+/*
+ * Copyright (c) 2024 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 Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.Applications;
+namespace WidgetApplicationTemplate
+{
+ class Program : NUIApplication
+ {
+ protected override void OnCreate()
+ {
+ base.OnCreate();
+ Initialize();
+ }
+ void Initialize()
+ {
+ Window window = GetDefaultWindow();
+
+ window.KeyEvent += OnKeyEvent;
+ window.TouchEvent += OnTouchEvent;
+
+ rootView = new View();
+ rootView.BackgroundColor = Color.White;
+ rootView.Size = Window.Instance.Size;
+ rootView.PivotPoint = PivotPoint.Center;
+ window.GetDefaultLayer().Add(rootView);
+
+ TextLabel sampleLabel = new TextLabel("Widget Viewer ");
+ sampleLabel.FontFamily = "SamsungOneUI 500";
+ sampleLabel.PointSize = 8;
+ sampleLabel.TextColor = Color.Black;
+ sampleLabel.SizeWidth = 300;
+ sampleLabel.PivotPoint = PivotPoint.Center;
+ rootView.Add(sampleLabel);
+
+ Bundle bundle = new Bundle();
+ bundle.AddItem("COUNT", "1");
+ String encodedBundle = bundle.Encode();
+
+ widgetWidth = 500;
+ widgetHeight = 500;
+ mWidgetView = WidgetViewManager.Instance.AddWidget("csharp_widget@org.tizen.example.NUIWidgetComponentApplication", encodedBundle, widgetWidth, widgetHeight, 0.0f);
+ mWidgetView.Position = new Position(100,100);
+ window.GetDefaultLayer().Add(mWidgetView);
+ }
+
+ public void OnKeyEvent(object sender, Window.KeyEventArgs e)
+ {
+ if (e.Key.State == Key.StateType.Down )
+ {
+ Tizen.Log.Info("NUI", "OnKeyEvent(View-Window) : " + e.Key.KeyPressedName + "\n");
+ if (e.Key.KeyPressedName == "1")
+ {
+ widgetWidth += 200;
+ widgetHeight += 200;
+ if(widgetWidth > 1000 || widgetHeight > 1000)
+ {
+ widgetWidth = 200;
+ widgetHeight = 200;
+ }
+ mWidgetView.Size2D = new Size2D(widgetWidth, widgetHeight);
+ }
+
+ }
+ }
+ private void OnTouchEvent(object source, Window.TouchEventArgs e)
+ {
+ }
+
+ static void Main(string[] args)
+ {
+ var app = new Program();
+ app.Run(args);
+ }
+
+ private View rootView;
+ WidgetView mWidgetView;
+
+ int widgetWidth;
+ int widgetHeight;
+
+ Window mWindow;
+ }
+}
+
+
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>net6.0</TargetFramework>
+ <AssemblyName>Tizen.NUI.WidgetViewTest</AssemblyName>
+ <SignAssembly>true</SignAssembly>
+ <PackageId>Tizen.NUI.WidgetViewTest</PackageId>
+ <Authors>Tizen.NUI.WidgetViewTest</Authors>
+ <Company>Tizen.NUI.WidgetViewTest</Company>
+ <Product>Tizen.NUI.WidgetViewTest</Product>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugType>portable</DebugType>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>None</DebugType>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="../../../../src/Tizen.NUI/Tizen.NUI.csproj" />
+ <PackageReference Include="Tizen.NET.Sdk" Version="1.0.9" />
+ </ItemGroup>
+
+</Project>
+
--- /dev/null
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30309.148
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI.WidgetViewTest", "Tizen.NUI.WidgetViewTest.csproj", "{3C6CE4CE-9D35-42C9-B23D-BBFFA96B3955}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {3C6CE4CE-9D35-42C9-B23D-BBFFA96B3955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3C6CE4CE-9D35-42C9-B23D-BBFFA96B3955}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3C6CE4CE-9D35-42C9-B23D-BBFFA96B3955}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3C6CE4CE-9D35-42C9-B23D-BBFFA96B3955}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {355D568D-D02A-490A-A6AC-FD6C7D97457A}
+ EndGlobalSection
+EndGlobal
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest package="Tizen.NUI.WidgetViewTest" version="1.0.0" api-version="4" xmlns="http://tizen.org/ns/packages">
+ <profile name="tv" />
+ <ui-application appid="Tizen.NUI.WidgetViewTest" exec="Tizen.NUI.WidgetViewTest.dll" multiple="false" nodisplay="false" taskmanage="true"
+ splash-screen-display="true"
+ type="dotnet-nui"
+ launch_mode="single">
+ <label>Tizen.NUI.WidgetViewTest</label>
+ <icon>Tizen.NUI.WidgetViewTest.png</icon>
+ <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
+ <splash-screens />
+ </ui-application>
+ <privileges>
+ <privilege>http://tizen.org/privilege/widget.viewer</privilege>
+ <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ <privilege>http://tizen.org/privilege/datasharing</privilege>
+ </privileges>
+</manifest>