From b1ce59a97f0fd20ccd031a11f0d0f5c2f8345d36 Mon Sep 17 00:00:00 2001 From: dongsug-song <35130733+dongsug-song@users.noreply.github.com> Date: Mon, 17 Dec 2018 12:09:35 +0900 Subject: [PATCH] [NUI] Sync with API5 (#617) * [NUI] Sync with API5 * Update View.cs Edit indent * Update SynchronizedList.cs Edit indent --- src/Tizen.NUI/src/internal/Application.cs | 139 +++++++-------------- src/Tizen.NUI/src/internal/DisposeQueue.cs | 2 +- .../src/internal/Layouting/LayoutGroup.cs | 46 +++---- src/Tizen.NUI/src/internal/NDalicPINVOKE.cs | 18 +++ src/Tizen.NUI/src/internal/NUICoreBackend.cs | 8 +- src/Tizen.NUI/src/internal/WatchApplication.cs | 21 +--- .../Xaml/MarkupExtensions/StaticExtension.cs | 4 +- src/Tizen.NUI/src/internal/XamlBinding/Binding.cs | 2 +- .../src/internal/XamlBinding/SynchronizedList.cs | 12 +- .../src/public/BaseComponents/ImageView.cs | 24 ++-- src/Tizen.NUI/src/public/BaseComponents/View.cs | 79 ++++++++++-- src/Tizen.NUI/src/public/Window.cs | 110 +++++++++++++++- 12 files changed, 292 insertions(+), 173 deletions(-) mode change 100644 => 100755 src/Tizen.NUI/src/internal/WatchApplication.cs diff --git a/src/Tizen.NUI/src/internal/Application.cs b/src/Tizen.NUI/src/internal/Application.cs index 0904b95..e7cc4a9 100755 --- a/src/Tizen.NUI/src/internal/Application.cs +++ b/src/Tizen.NUI/src/internal/Application.cs @@ -426,7 +426,7 @@ namespace Tizen.NUI ResourceDictionary _resources; public bool IsResourcesCreated => _resources != null; - public delegate void resChangeCb (object sender, ResourcesChangedEventArgs e); + public delegate void resChangeCb(object sender, ResourcesChangedEventArgs e); static private Dictionary> resourceChangeCallbackDict = new Dictionary>(); static public void AddResourceChangedCallback(object handle, resChangeCb cb) @@ -955,17 +955,12 @@ namespace Tizen.NUI // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread. DisposeQueue.Instance.Initialize(); - NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs(); - // Populate all members of "e" (NUIApplicationInitEventArgs) with real data - using (e.Application = Application.GetApplicationFromPtr(data)) + if (_applicationInitEventHandler != null) { - if (_applicationInitEventHandler != null) - { - //here we send all data to user event handlers - _applicationInitEventHandler(this, e); - } + NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs(); + e.Application = this; + _applicationInitEventHandler.Invoke(this, e); } - } /** @@ -1006,17 +1001,14 @@ namespace Tizen.NUI // Callback for Application TerminateSignal private void OnNUIApplicationTerminate(IntPtr data) { - NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs(); - - // Populate all members of "e" (NUIApplicationTerminateEventArgs) with real data - using (e.Application = Application.GetApplicationFromPtr(data)) + if (_applicationTerminateEventHandler != null) { - if (_applicationTerminateEventHandler != null) - { - //here we send all data to user event handlers - _applicationTerminateEventHandler(this, e); - } + NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs(); + e.Application = this; + _applicationTerminateEventHandler.Invoke(this, e); } + + Window.Instance.DisconnectNativeSignals(); } /** @@ -1057,16 +1049,11 @@ namespace Tizen.NUI // Callback for Application PauseSignal private void OnNUIApplicationPause(IntPtr data) { - NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs(); - - // Populate all members of "e" (NUIApplicationPauseEventArgs) with real data - using (e.Application = Application.GetApplicationFromPtr(data)) + if (_applicationPauseEventHandler != null) { - if (_applicationPauseEventHandler != null) - { - //here we send all data to user event handlers - _applicationPauseEventHandler(this, e); - } + NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs(); + e.Application = this; + _applicationPauseEventHandler.Invoke(this, e); } } @@ -1108,16 +1095,11 @@ namespace Tizen.NUI // Callback for Application ResumeSignal private void OnNUIApplicationResume(IntPtr data) { - NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs(); - - // Populate all members of "e" (NUIApplicationResumeEventArgs) with real data - using (e.Application = Application.GetApplicationFromPtr(data)) + if (_applicationResumeEventHandler != null) { - if (_applicationResumeEventHandler != null) - { - //here we send all data to user event handlers - _applicationResumeEventHandler(this, e); - } + NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs(); + e.Application = this; + _applicationResumeEventHandler.Invoke(this, e); } } @@ -1159,16 +1141,11 @@ namespace Tizen.NUI // Callback for Application ResetSignal private void OnNUIApplicationReset(IntPtr data) { - NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs(); - - // Populate all members of "e" (NUIApplicationResetEventArgs) with real data - using (e.Application = Application.GetApplicationFromPtr(data)) + if (_applicationResetEventHandler != null) { - if (_applicationResetEventHandler != null) - { - //here we send all data to user event handlers - _applicationResetEventHandler(this, e); - } + NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs(); + e.Application = this; + _applicationResetEventHandler.Invoke(this, e); } } @@ -1210,16 +1187,11 @@ namespace Tizen.NUI // Callback for Application ResizeSignal private void OnNUIApplicationResize(IntPtr data) { - NUIApplicationResizedEventArgs e = new NUIApplicationResizedEventArgs(); - - // Populate all members of "e" (NUIApplicationResizeEventArgs) with real data - using (e.Application = Application.GetApplicationFromPtr(data)) + if (_applicationResizeEventHandler != null) { - if (_applicationResizeEventHandler != null) - { - //here we send all data to user event handlers - _applicationResizeEventHandler(this, e); - } + NUIApplicationResizedEventArgs e = new NUIApplicationResizedEventArgs(); + e.Application = this; + _applicationResizeEventHandler.Invoke(this, e); } } @@ -1261,16 +1233,11 @@ namespace Tizen.NUI // Callback for Application LanguageChangedSignal private void OnNUIApplicationLanguageChanged(IntPtr data) { - NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs(); - - // Populate all members of "e" (NUIApplicationLanguageChangedEventArgs) with real data - using (e.Application = Application.GetApplicationFromPtr(data)) + if (_applicationLanguageChangedEventHandler != null) { - if (_applicationLanguageChangedEventHandler != null) - { - //here we send all data to user event handlers - _applicationLanguageChangedEventHandler(this, e); - } + NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs(); + e.Application = this; + _applicationLanguageChangedEventHandler.Invoke(this, e); } } @@ -1312,16 +1279,11 @@ namespace Tizen.NUI // Callback for Application RegionChangedSignal private void OnNUIApplicationRegionChanged(IntPtr data) { - NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs(); - - // Populate all members of "e" (NUIApplicationRegionChangedEventArgs) with real data - using (e.Application = Application.GetApplicationFromPtr(data)) + if (_applicationRegionChangedEventHandler != null) { - if (_applicationRegionChangedEventHandler != null) - { - //here we send all data to user event handlers - _applicationRegionChangedEventHandler(this, e); - } + NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs(); + e.Application = this; + _applicationRegionChangedEventHandler.Invoke(this, e); } } @@ -1367,12 +1329,7 @@ namespace Tizen.NUI // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data e.BatteryStatus = status; - - if (_applicationBatteryLowEventHandler != null) - { - //here we send all data to user event handlers - _applicationBatteryLowEventHandler(this, e); - } + _applicationBatteryLowEventHandler?.Invoke(this, e); } /** @@ -1417,12 +1374,7 @@ namespace Tizen.NUI // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data e.MemoryStatus = status; - - if (_applicationMemoryLowEventHandler != null) - { - //here we send all data to user event handlers - _applicationMemoryLowEventHandler(this, e); - } + _applicationMemoryLowEventHandler?.Invoke(this, e); } /** @@ -1463,17 +1415,12 @@ namespace Tizen.NUI // Callback for Application AppControlSignal private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp) { - NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs(); - e.VoidP = voidp; - - // Populate all members of "e" (NUIApplicationAppControlEventArgs) with real data - using (e.Application = Application.GetApplicationFromPtr(application)) + if (_applicationAppControlEventHandler != null) { - if (_applicationAppControlEventHandler != null) - { - //here we send all data to user event handlers - _applicationAppControlEventHandler(this, e); - } + NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs(); + e.VoidP = voidp; + e.Application = this; + _applicationAppControlEventHandler.Invoke(this, e); } } @@ -1494,7 +1441,7 @@ namespace Tizen.NUI return null; } - Application ret = new Application(cPtr, false); + Application ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Application; if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } diff --git a/src/Tizen.NUI/src/internal/DisposeQueue.cs b/src/Tizen.NUI/src/internal/DisposeQueue.cs index dc75e9c..cde10b2 100755 --- a/src/Tizen.NUI/src/internal/DisposeQueue.cs +++ b/src/Tizen.NUI/src/internal/DisposeQueue.cs @@ -58,7 +58,7 @@ namespace Tizen.NUI } } - private void ProcessDisposables() + internal void ProcessDisposables() { lock (_listLock) { diff --git a/src/Tizen.NUI/src/internal/Layouting/LayoutGroup.cs b/src/Tizen.NUI/src/internal/Layouting/LayoutGroup.cs index 5efe006..a30d7d0 100755 --- a/src/Tizen.NUI/src/internal/Layouting/LayoutGroup.cs +++ b/src/Tizen.NUI/src/internal/Layouting/LayoutGroup.cs @@ -85,36 +85,36 @@ namespace Tizen.NUI protected override void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec) { Log.Info("NUI", "OnMeasure\n"); - LayoutLength childWidth = new LayoutLength( 0 ); - LayoutLength childHeight = new LayoutLength( 0 ); + LayoutLength childWidth = new LayoutLength(0); + LayoutLength childHeight = new LayoutLength(0); LayoutLength measuredWidth = childWidth; LayoutLength measuredHeight = childHeight; - for( uint i = 0; i < ChildCount; ++i ) + for (uint i = 0; i < ChildCount; ++i) { - var childLayout = GetChildAt( i ); + var childLayout = GetChildAt(i); - if( childLayout ) + if (childLayout) { - MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec ); + MeasureChild(childLayout, widthMeasureSpec, heightMeasureSpec); childWidth = childLayout.MeasuredWidth; childHeight = childLayout.MeasuredHeight; // Layout takes size of largest width and height dimension of children - measuredWidth.Value = System.Math.Max( measuredWidth.Value, childWidth.Value ); - measuredHeight.Value = System.Math.Max( measuredHeight.Value, childHeight.Value ); + measuredWidth.Value = System.Math.Max(measuredWidth.Value, childWidth.Value); + measuredHeight.Value = System.Math.Max(measuredHeight.Value, childHeight.Value); } } - if( 0 == ChildCount ) + if (0 == ChildCount) { // Must be a leaf as has no children - measuredWidth = GetDefaultSize( SuggestedMinimumWidth, widthMeasureSpec ); - measuredHeight = GetDefaultSize( SuggestedMinimumHeight, heightMeasureSpec ); + measuredWidth = GetDefaultSize(SuggestedMinimumWidth, widthMeasureSpec); + measuredHeight = GetDefaultSize(SuggestedMinimumHeight, heightMeasureSpec); } - SetMeasuredDimensions( new MeasuredSize( measuredWidth ), - new MeasuredSize( measuredHeight ) ); + SetMeasuredDimensions(new MeasuredSize(measuredWidth), + new MeasuredSize(measuredHeight)); } /// @@ -130,29 +130,29 @@ namespace Tizen.NUI { Log.Info("NUI", "OnLayout\n"); - for( uint i = 0; i < ChildCount; ++i ) + for (uint i = 0; i < ChildCount; ++i) { - var childLayout = GetChildAt( i ); - if( childLayout ) + var childLayout = GetChildAt(i); + if (childLayout) { View childOwner = childLayout.GetOwner(); // Use position if explicitly set to child otherwise will be top left. - var childLeft = new LayoutLength( childOwner.Position2D.X ); - var childTop = new LayoutLength( childOwner.Position2D.Y ); + var childLeft = new LayoutLength(childOwner.Position2D.X); + var childTop = new LayoutLength(childOwner.Position2D.Y); View owner = GetOwner(); - if ( owner ) + if (owner) { // Margin and Padding only supported when child anchor point is TOP_LEFT. - if ( owner.PivotPoint == PivotPoint.TopLeft || ( owner.PositionUsesPivotPoint == false ) ) + if (owner.PivotPoint == PivotPoint.TopLeft || (owner.PositionUsesPivotPoint == false)) { - childLeft = childLeft + owner.Padding.Start + childOwner.Margin.Start; - childTop = childTop + owner.Padding.Top + childOwner.Margin.Top; + childLeft = childLeft + owner.Padding.Start + childOwner.Margin.Start; + childTop = childTop + owner.Padding.Top + childOwner.Margin.Top; } } - childLayout.Layout( childLeft, childTop, childLeft + childLayout.MeasuredWidth, childTop + childLayout.MeasuredHeight ); + childLayout.Layout(childLeft, childTop, childLeft + childLayout.MeasuredWidth, childTop + childLayout.MeasuredHeight); } } } diff --git a/src/Tizen.NUI/src/internal/NDalicPINVOKE.cs b/src/Tizen.NUI/src/internal/NDalicPINVOKE.cs index 25de721..8e47d7d 100755 --- a/src/Tizen.NUI/src/internal/NDalicPINVOKE.cs +++ b/src/Tizen.NUI/src/internal/NDalicPINVOKE.cs @@ -36828,6 +36828,24 @@ namespace Tizen.NUI } } + [global::System.Runtime.InteropServices.DllImport(Graphics.GlesCSharpBinder, EntryPoint = "CSharp_Dali_Window_SetPositionSize")] + public static extern void Window_SetPositionSize_gl(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport(Graphics.VulkanCSharpBinder, EntryPoint = "CSharp_Dali_Window_SetPositionSize")] + public static extern void Window_SetPositionSize_vulkan(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + public static void Window_SetPositionSize(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2) + { + if (Tizen.NUI.Graphics.Backend == Tizen.NUI.Graphics.BackendType.Vulkan) + { + Window_SetPositionSize_vulkan(jarg1, jarg2); + } + else + { + Window_SetPositionSize_gl(jarg1, jarg2); + } + } + [global::System.Runtime.InteropServices.DllImport(Graphics.GlesCSharpBinder, EntryPoint = "CSharp_Dali_Application_New__SWIG_0")] public static extern global::System.IntPtr Application_New__SWIG_0_gl(); diff --git a/src/Tizen.NUI/src/internal/NUICoreBackend.cs b/src/Tizen.NUI/src/internal/NUICoreBackend.cs index cd0a16d..f7c31ac 100755 --- a/src/Tizen.NUI/src/internal/NUICoreBackend.cs +++ b/src/Tizen.NUI/src/internal/NUICoreBackend.cs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -147,7 +147,9 @@ namespace Tizen.NUI _application.AppControl += OnAppControl; _application.MainLoop(); + _application.Dispose(); + } /// @@ -159,7 +161,7 @@ namespace Tizen.NUI { Log.Info("NUI", "NUICorebackend OnRegionChanged Called"); var handler = Handlers[EventType.RegionFormatChanged] as Action; - handler?.Invoke( new RegionFormatChangedEventArgs(e.Application.GetRegion())); + handler?.Invoke( new RegionFormatChangedEventArgs((source as Application)?.GetRegion())); } /// @@ -201,7 +203,7 @@ namespace Tizen.NUI { Log.Info("NUI", "NUICorebackend OnLanguageChanged Called"); var handler = Handlers[EventType.LocaleChanged] as Action; - handler?.Invoke( new LocaleChangedEventArgs(e.Application.GetLanguage())); + handler?.Invoke( new LocaleChangedEventArgs((source as Application)?.GetLanguage())); } /// diff --git a/src/Tizen.NUI/src/internal/WatchApplication.cs b/src/Tizen.NUI/src/internal/WatchApplication.cs old mode 100644 new mode 100755 index 32f1a73..921573e --- a/src/Tizen.NUI/src/internal/WatchApplication.cs +++ b/src/Tizen.NUI/src/internal/WatchApplication.cs @@ -209,13 +209,10 @@ namespace Tizen.NUI private void OnTimeTick(IntPtr application, IntPtr watchTime) { TimeTickEventArgs e = new TimeTickEventArgs(); - using (e.Application = Application.GetApplicationFromPtr(application)) - { - using (e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime)) - { + e.Application = this; + e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime); + _timeTickEventHandler?.Invoke(this, e); - } - } } @@ -289,14 +286,10 @@ namespace Tizen.NUI { AmbientTickEventArgs e = new AmbientTickEventArgs(); - using (e.Application = Application.GetApplicationFromPtr(application)) - { - using (e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime)) - { + e.Application = this; + e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime); _ambientTickEventHandler?.Invoke(this, e); } - } - } internal WatchTimeSignal AmbientTickSignal() { @@ -367,12 +360,10 @@ namespace Tizen.NUI private void OnAmbientChanged(IntPtr application, bool changed) { AmbientChangedEventArgs e = new AmbientChangedEventArgs(); - using (e.Application = Application.GetApplicationFromPtr(application)) - { + e.Application = this; e.Changed = changed; _ambientChangedEventHandler?.Invoke(this, e); } - } internal WatchBoolSignal AmbientChangedSignal() { diff --git a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StaticExtension.cs b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StaticExtension.cs index 629cf1d..d22e0ed 100755 --- a/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StaticExtension.cs +++ b/src/Tizen.NUI/src/internal/Xaml/MarkupExtensions/StaticExtension.cs @@ -36,9 +36,9 @@ namespace Tizen.NUI.Xaml var type = typeResolver.Resolve(typename, serviceProvider); - var pinfo = type.GetRuntimeProperties().FirstOrDefault(pi => pi.Name == membername && pi.GetMethod.IsStatic); + var pinfo = type.GetRuntimeProperties().FirstOrDefault(pi => pi.GetMethod != null && pi.Name == membername && pi.GetMethod.IsStatic); if (pinfo != null) - return pinfo.GetMethod.Invoke(null, new object[] { }); + return pinfo.GetMethod?.Invoke(null, Array.Empty()); var finfo = type.GetRuntimeFields().FirstOrDefault(fi => fi.Name == membername && fi.IsStatic); if (finfo != null) diff --git a/src/Tizen.NUI/src/internal/XamlBinding/Binding.cs b/src/Tizen.NUI/src/internal/XamlBinding/Binding.cs index be4bfaa..6debd8c 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/Binding.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/Binding.cs @@ -200,7 +200,7 @@ namespace Tizen.NUI.Binding string indexerName = defaultMember != null ? defaultMember.MemberName : "Item"; MethodInfo getterInfo = - declarerType.GetProperties().Where(pi => pi.Name == indexerName && pi.CanRead && pi.GetMethod.IsPublic && !pi.GetMethod.IsStatic).Select(pi => pi.GetMethod).FirstOrDefault(); + declarerType.GetProperties().Where(pi => (pi.GetMethod != null) && pi.Name == indexerName && pi.CanRead && pi.GetMethod.IsPublic && !pi.GetMethod.IsStatic).Select(pi => pi.GetMethod).FirstOrDefault(); if (getterInfo != null) { if (getterInfo == methodCall.Method) diff --git a/src/Tizen.NUI/src/internal/XamlBinding/SynchronizedList.cs b/src/Tizen.NUI/src/internal/XamlBinding/SynchronizedList.cs index d0829e4..a0761b4 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/SynchronizedList.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/SynchronizedList.cs @@ -75,14 +75,15 @@ namespace Tizen.NUI.Binding public IEnumerator GetEnumerator() { - ReadOnlyCollection snap = _snapshot; - if (snap == null) + lock (_list) { - lock (_list) + ReadOnlyCollection snap = _snapshot; + if (snap == null) + { _snapshot = snap = new ReadOnlyCollection(_list.ToList()); + } + return snap?.GetEnumerator(); } - - return snap?.GetEnumerator(); } public int IndexOf(T item) @@ -112,7 +113,6 @@ namespace Tizen.NUI.Binding return _list[index]; } - } set diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index 1a4829d..639b19e 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -34,25 +34,22 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty ResourceUrlProperty = BindableProperty.Create(nameof(ImageView.ResourceUrl), typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) => { var imageView = (ImageView)bindable; - imageView._url = (string)newValue; - - if (imageView._url != null) + if (newValue != null) { - if (imageView.IsCreateByXaml && imageView._url.Contains("*Resource*")) + string url = (string)newValue; + if (imageView.IsCreateByXaml && url.Contains("*Resource*")) { string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource; - imageView._url = imageView._url.Replace("*Resource*", resource); + url = url.Replace("*Resource*", resource); } + imageView._url = url; + imageView.UpdateImage(); } - imageView.UpdateImage(); }, defaultValueCreator:(bindable) => { var imageView = (ImageView)bindable; - if(imageView._url != null) - { Tizen.NUI.Object.GetProperty(imageView.swigCPtr, ImageView.Property.IMAGE).Get(out imageView._url); - } return imageView._url; }); /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -481,6 +478,8 @@ namespace Tizen.NUI.BaseComponents /// /// ImageView ResourceUrl, type string. + /// This is one of mandatory property. Even if not set or null set, it sets empty string ("") internally. + /// When it is set as null, it gives empty string ("") to be read. /// /// 3 public string ResourceUrl @@ -491,7 +490,8 @@ namespace Tizen.NUI.BaseComponents } set { - SetValue(ResourceUrlProperty, value); + _url = (value == null? "" : value); + SetValue(ResourceUrlProperty, _url); NotifyPropertyChanged(); } } @@ -732,10 +732,6 @@ namespace Tizen.NUI.BaseComponents SetProperty(ImageView.Property.IMAGE, new PropertyValue(_url)); } } - else - { - SetProperty(ImageView.Property.IMAGE, new PropertyValue("")); - } } private Rectangle _border = null; diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 69f25c6..79c45d7 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -27,6 +27,11 @@ namespace Tizen.NUI.BaseComponents /// 3 public class View : Container, IResourcesProvider { + /// Flag to allow Layouting to be disabled for Views. + /// Once a View has a Layout set then any children added to Views from then on will receive + /// automatic Layouts. + private static bool layoutingDisabled = true; + /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public bool IsResourcesCreated @@ -1301,8 +1306,9 @@ namespace Tizen.NUI.BaseComponents // Only give children a layout if their parent is an explicit container or a pure View. // Pure View meaning not derived from a View, e.g a Legacy container. - // layoutSet flag is true when the View became a layout using the SetLayout API - if (true == layoutSet && null == child.Layout) + // layoutSet flag is true when the View became a layout using the set Layout API opposed to automatically due to it's parent. + // First time the set Layout API is used by any View the Window no longer has layoutingDisabled. + if ((true == layoutSet || GetType() == typeof(View)) && null == child.Layout && false == layoutingDisabled ) { Log.Info("NUI", "Parent[" + Name + "] Layout set[" + layoutSet.ToString() + "] Pure View[" + (!layoutSet).ToString() + "]\n"); // If child is a View or explicitly set to require layouting then set child as a LayoutGroup. @@ -1310,14 +1316,14 @@ namespace Tizen.NUI.BaseComponents if( child.GetType() == typeof(View) || true == child.LayoutingRequired ) { Log.Info("NUI", "Creating LayoutGroup for " + child.Name + " LayoutingRequired[" + child.LayoutingRequired.ToString() + "]\n"); - child.Layout = new LayoutGroup(); + child.SetLayout( new LayoutGroup() ); } else { // Adding child as a leaf, layouting will not propagate past this child. // Legacy containers will be a LayoutItems too and layout their children how they wish. Log.Info("NUI", "Creating LayoutItem for " + child.Name + "\n"); - child.Layout = new LayoutItem(); + child.SetLayout( new LayoutItem() ); } } @@ -3459,13 +3465,20 @@ namespace Tizen.NUI.BaseComponents } set { - Tizen.NUI.NDalicManualPINVOKE.SetLayout__SWIG_1(View.getCPtr(this), LayoutItem.getCPtr(value)); - value.LayoutChildren.Clear(); + Log.Info("NUI", "Set Layout on:" + Name + "\n"); + layoutingDisabled = false; layoutSet = true; - foreach (View view in Children) - { - value.LayoutChildren.Add(view.Layout); - } + SetLayout( value ); + } + } + + internal void SetLayout( LayoutItem layout ) + { + Tizen.NUI.NDalicManualPINVOKE.SetLayout__SWIG_1(View.getCPtr(this), LayoutItem.getCPtr(layout) ); + layout.LayoutChildren.Clear(); + foreach (View view in Children) + { + layout.LayoutChildren.Add(view.Layout); } } @@ -4628,6 +4641,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(SizeWidthProperty, value); + SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue(value)); NotifyPropertyChanged(); } } @@ -4645,6 +4659,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(SizeHeightProperty, value); + SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue(value)); NotifyPropertyChanged(); } } @@ -5084,6 +5099,28 @@ namespace Tizen.NUI.BaseComponents set { SetValue(WidthResizePolicyProperty, value); + // Match ResizePolicy to new Layouting. + // Parent relative policies can not be mapped at this point as parent size unknown. + switch( value ) + { + case ResizePolicyType.UseNaturalSize : + { + SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue( (int)ChildLayoutData.WrapContent ) ); + break; + } + case ResizePolicyType.FillToParent : + { + SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue( (int)ChildLayoutData.MatchParent ) ); + break; + } + case ResizePolicyType.FitToChildren : + { + SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue( (int)ChildLayoutData.WrapContent ) ); + break; + } + default: + break; + } NotifyPropertyChanged(); } } @@ -5101,6 +5138,28 @@ namespace Tizen.NUI.BaseComponents set { SetValue(HeightResizePolicyProperty, value); + // Match ResizePolicy to new Layouting. + // Parent relative policies can not be mapped at this point as parent size unknown. + switch( value ) + { + case ResizePolicyType.UseNaturalSize : + { + SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue( (int)ChildLayoutData.WrapContent ) ); + break; + } + case ResizePolicyType.FillToParent : + { + SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue( (int)ChildLayoutData.MatchParent ) ); + break; + } + case ResizePolicyType.FitToChildren : + { + SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue( (int)ChildLayoutData.WrapContent ) ); + break; + } + default: + break; + } NotifyPropertyChanged(); } } diff --git a/src/Tizen.NUI/src/public/Window.cs b/src/Tizen.NUI/src/public/Window.cs index 606292f..09e3d8c 100755 --- a/src/Tizen.NUI/src/public/Window.cs +++ b/src/Tizen.NUI/src/public/Window.cs @@ -31,10 +31,10 @@ namespace Tizen.NUI { private global::System.Runtime.InteropServices.HandleRef swigCPtr; private global::System.Runtime.InteropServices.HandleRef stageCPtr; - private global::System.Runtime.InteropServices.HandleRef rootLayoutCPtr; - private global::System.IntPtr rootLayoutIntPtr; + private readonly global::System.Runtime.InteropServices.HandleRef rootLayoutCPtr; private Layer _rootLayer; private string _windowTitle; + private readonly LayoutItem rootLayoutItem; private List _childLayers = new List(); internal List LayersChildren @@ -50,6 +50,7 @@ namespace Tizen.NUI swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); if (NDalicPINVOKE.Stage_IsInstalled()) { + global::System.IntPtr rootLayoutIntPtr; stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, NDalicPINVOKE.Stage_GetCurrent()); // Create a root layout (AbsoluteLayout) that is invisible to the user but enables layouts added to the Window // Enables layouts added to the Window to have a parent layout. As parent layout is needed to store measure spec properties. @@ -60,6 +61,12 @@ namespace Tizen.NUI Layer rootLayer = GetRootLayer(); // Add the root layout created above to the root layer. NDalicPINVOKE.Actor_Add( Layer.getCPtr(rootLayer), rootLayoutCPtr ); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + global::System.IntPtr rootControlLayoutIntPtr = Tizen.NUI.NDalicManualPINVOKE.GetLayout__SWIG_1(rootLayoutCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + rootLayoutItem = new LayoutItem(rootControlLayoutIntPtr, true); } } @@ -1467,6 +1474,11 @@ namespace Tizen.NUI NDalicManualPINVOKE.SetSize(swigCPtr, Uint16Pair.getCPtr(val)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + if(rootLayoutItem != null) + { + rootLayoutItem.RequestLayout(); + } } internal Size2D GetWindowSize() @@ -1484,6 +1496,11 @@ namespace Tizen.NUI NDalicManualPINVOKE.SetPosition(swigCPtr, Uint16Pair.getCPtr(val)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + if(rootLayoutItem != null) + { + rootLayoutItem.RequestLayout(); + } } internal Position2D GetPosition() @@ -1495,6 +1512,17 @@ namespace Tizen.NUI return ret; } + internal void SetPositionSize(Rectangle positionSize) + { + NDalicPINVOKE.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + if(rootLayoutItem != null) + { + rootLayoutItem.RequestLayout(); + } + } + /// /// Sets whether the window is transparent or not. /// @@ -1694,6 +1722,26 @@ namespace Tizen.NUI } /// + /// Sets position and size of the window. This API guarantees that + /// both moving and resizing of window will appear on the screen at once. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Rectangle WindowPositionSize + { + get + { + Position2D position = GetPosition(); + Size2D size = GetSize(); + Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height); + return ret; + } + set + { + SetPositionSize(value); + } + } + + /// /// Feeds a key event into the window. /// /// The key event to feed. @@ -1763,5 +1811,63 @@ namespace Tizen.NUI } } + /// + /// Disconnect all native signals + /// + /// 5 + internal void DisconnectNativeSignals() + { + if( _windowFocusChangedEventCallback != null ) + { + WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback); + } + + if( _rootLayerTouchDataCallback != null ) + { + TouchDataSignal().Disconnect(_rootLayerTouchDataCallback); + } + + if( _wheelEventCallback != null ) + { + StageWheelEventSignal().Disconnect(_wheelEventCallback); + } + + if( _stageKeyCallbackDelegate != null ) + { + KeyEventSignal().Disconnect(_stageKeyCallbackDelegate); + } + + if( _stageEventProcessingFinishedEventCallbackDelegate != null ) + { + EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate); + } + + if( _stageContextLostEventCallbackDelegate != null ) + { + ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate); + } + + if( _stageContextRegainedEventCallbackDelegate != null ) + { + ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate); + } + + if( _stageSceneCreatedEventCallbackDelegate != null ) + { + SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate); + } + + if( _windowResizedEventCallback != null ) + { + ResizedSignal().Disconnect(_windowResizedEventCallback); + } + + if( _windowFocusChangedEventCallback2 != null ) + { + WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2); + } + + } + } } -- 2.7.4