[NUI] VisualMap, friend assembly, InputMethodContext related changes (#406)
authordongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 22 Aug 2018 08:14:41 +0000 (17:14 +0900)
committerGitHub <noreply@github.com>
Wed, 22 Aug 2018 08:14:41 +0000 (17:14 +0900)
* [NUI] Add DestroyContext call before disposing TextField/TextEditor

In order to speed up IME hide, temporarily add DestroyContext call.

Change-Id: Id93c99f4d45061d4e406d36ced7a0ec09c8f2c34

* [NUI] VisualMap revising

Here are some changes:
Add VisualFittingMode property
Add Atlasing property
Add Shadow,Underline,Outline,Background property
Add RenderIfTransparent property

Change-Id: I8d85f9d1a438cb6fbb636f79c7438e9134e1df8f

* [NUI] Add visual test example

Change-Id: I25f41d969f7b98a494a4fa1716b0335c09ab5026

* [NUI] Add friend assembly for Tizen.TV.NUI.Component

Change-Id: I2fdc02205c03aa98260035fb81998d68514c030e

src/Tizen.NUI/src/internal/FriendAssembly.cs
src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs
src/Tizen.NUI/src/public/BaseComponents/TextField.cs
src/Tizen.NUI/src/public/NUIConstants.cs
src/Tizen.NUI/src/public/VisualMaps.cs
test/NUITestSample/NUITestSample/examples/visual-test.cs [new file with mode: 0755]

index b531205..86651d3 100755 (executable)
 
 using System.Runtime.CompilerServices;
 [assembly: InternalsVisibleTo("Tizen.Multimedia, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d115b1004248416b12d21b626cfb17149c9303fe394693fd3b32d7872e89559a4fa96c98110c2e62eea48aca693bddbe17094ca8ea2e2cd79970ca590fb672b9b371b5d7002076817321f62d6483ea50c56dbd1f37b185a4c24c47718876e6ae6d266508c551170d4cbdda3f82edaff9405ee3d7857282d8269e8e518d2f0fb2")]
-[assembly: InternalsVisibleTo("Tizen.TV.NUI, PublicKey=0024000004800000940000000602000000240000525341310004000001000100ed445c2a988d35b99e5766f42eef33d89d1f67225db051f011abcfce47a4788875c39750a2e5695f1ec117f41d96610419811762669f98131db30a6e64c6bb8fde3731f373f6cda4c0087d121f5108559f216dc015807dc46ec5a4d1b63f5deff64c01754a0db0dc849bc300672572cbd2697432ab6c193ebf9fade6bf0f2aad")]
 [assembly: InternalsVisibleTo("Tizen.NUI.Wearable, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d115b1004248416b12d21b626cfb17149c9303fe394693fd3b32d7872e89559a4fa96c98110c2e62eea48aca693bddbe17094ca8ea2e2cd79970ca590fb672b9b371b5d7002076817321f62d6483ea50c56dbd1f37b185a4c24c47718876e6ae6d266508c551170d4cbdda3f82edaff9405ee3d7857282d8269e8e518d2f0fb2")]
 
+[assembly: InternalsVisibleTo("Tizen.TV.NUI, PublicKey=0024000004800000940000000602000000240000525341310004000001000100ed445c2a988d35b99e5766f42eef33d89d1f67225db051f011abcfce47a4788875c39750a2e5695f1ec117f41d96610419811762669f98131db30a6e64c6bb8fde3731f373f6cda4c0087d121f5108559f216dc015807dc46ec5a4d1b63f5deff64c01754a0db0dc849bc300672572cbd2697432ab6c193ebf9fade6bf0f2aad")]
+[assembly: InternalsVisibleTo("Tizen.TV.NUI.Component, PublicKey=0024000004800000940000000602000000240000525341310004000001000100ed445c2a988d35b99e5766f42eef33d89d1f67225db051f011abcfce47a4788875c39750a2e5695f1ec117f41d96610419811762669f98131db30a6e64c6bb8fde3731f373f6cda4c0087d121f5108559f216dc015807dc46ec5a4d1b63f5deff64c01754a0db0dc849bc300672572cbd2697432ab6c193ebf9fade6bf0f2aad")]
+
 //This is for Layout development and test. snk file will be shared internally. This will be removed at 2018-09-30.
-[assembly: InternalsVisibleTo("Tizen.TV.NUI.Example, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a5bcf6fb6095141fa8146ec74d5b0be8b09a063f8f1f32604b10df6e498788182840bd15c93ba1a5c0b9aeee8fe2be42ea9c0b5fe32e1d6d5602b2a4fa813114fd58c4b2910d93e5181b90925458b4b8b003c30d97830a17ad90a92f34f60a11f67a78757e6b2035e799be5ab69a41ede17cad2e2b7967fbf49b685452496be0")]
+[assembly: InternalsVisibleTo("Tizen.TV.NUI.Example, PublicKey=0024000004800000940000000602000000240000525341310004000001000100ed445c2a988d35b99e5766f42eef33d89d1f67225db051f011abcfce47a4788875c39750a2e5695f1ec117f41d96610419811762669f98131db30a6e64c6bb8fde3731f373f6cda4c0087d121f5108559f216dc015807dc46ec5a4d1b63f5deff64c01754a0db0dc849bc300672572cbd2697432ab6c193ebf9fade6bf0f2aad")]
 [assembly: InternalsVisibleTo("NuiSample, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a5bcf6fb6095141fa8146ec74d5b0be8b09a063f8f1f32604b10df6e498788182840bd15c93ba1a5c0b9aeee8fe2be42ea9c0b5fe32e1d6d5602b2a4fa813114fd58c4b2910d93e5181b90925458b4b8b003c30d97830a17ad90a92f34f60a11f67a78757e6b2035e799be5ab69a41ede17cad2e2b7967fbf49b685452496be0")]
 
 namespace Tizen.NUI
index ff796af..f799f74 100755 (executable)
@@ -965,6 +965,8 @@ namespace Tizen.NUI.BaseComponents
                 if (swigCMemOwn)
                 {
                     swigCMemOwn = false;
+                    // In order to speed up IME hide, temporarily add
+                    GetInputMethodContext()?.DestroyContext();
                     NDalicPINVOKE.delete_TextEditor(swigCPtr);
                 }
                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
index 412267d..103901e 100755 (executable)
@@ -1025,6 +1025,8 @@ namespace Tizen.NUI.BaseComponents
                 if (swigCMemOwn)
                 {
                     swigCMemOwn = false;
+                    // In order to speed up IME hide, temporarily add
+                    GetInputMethodContext()?.DestroyContext();
                     NDalicPINVOKE.delete_TextField(swigCPtr);
                 }
                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
index 7f8f468..153412a 100755 (executable)
@@ -809,6 +809,28 @@ namespace Tizen.NUI
     }
 
     /// <summary>
+    /// The values of this enum determine how the visual should be fit to the view.
+    /// </summary>
+    /// <since_tizen> 5 </since_tizen>
+    /// 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 enum VisualFittingModeType
+    {
+        /// <summary>
+        /// The visual should be scaled to fit, preserving aspect ratio.
+        /// </summary>
+        /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        FitKeepAspectRatio,
+        /// <summary>
+        /// The visual should be stretched to fill, not preserving aspect ratio.
+        /// </summary>
+        /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        Fill
+    }
+
+    /// <summary>
     /// This specifies sampling mode types. Filtering options are used when resizing images to sample original pixels.<br />
     /// A SamplingMode controls how pixels in an input image are sampled and combined to generate each pixel of a destination image during scaling.<br />
     /// NoFilter and Box modes do not guarantee that the output pixel array exactly matches the rectangle specified by the desired dimensions and the FittingMode,<br />
@@ -991,6 +1013,13 @@ namespace Tizen.NUI
             /// </summary>
             /// <since_tizen> 3 </since_tizen>
             public static readonly int Opacity = NDalic.VISUAL_PROPERTY_MIX_COLOR + 1;
+            /// <summary>
+            /// The fitting mode of the visual.
+            /// </summary>
+            /// <since_tizen> 5 </since_tizen>
+            /// 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 static readonly int VisualFittingMode = NDalic.VISUAL_PROPERTY_MIX_COLOR + 2;
         }
 
         /// <summary>
@@ -1114,6 +1143,13 @@ namespace Tizen.NUI
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         public static readonly int MixColor = NDalic.COLOR_VISUAL_MIX_COLOR;
+        /// <summary>
+        /// Whether to render if the MixColor is transparent.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 static readonly int RenderIfTransparent = NDalic.COLOR_VISUAL_MIX_COLOR + 1;
     }
 
     /// <summary>
@@ -1231,6 +1267,13 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static readonly int Border = NDalic.IMAGE_VISUAL_BORDER;
         /// <summary>
+        /// Whether to use the texture atlas.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 static readonly int Atlasing = NDalic.IMAGE_VISUAL_BORDER + 1;
+        /// <summary>
         /// The scale factor to apply to the content image before masking.
         /// </summary>
         /// <since_tizen> 4 </since_tizen>
@@ -1450,6 +1493,34 @@ namespace Tizen.NUI
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         public static readonly int EnableMarkup = NDalic.TEXT_VISUAL_ENABLE_MARKUP;
+        /// <summary>
+        /// The shadow parameters.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 static readonly int Shadow = NDalic.TEXT_VISUAL_ENABLE_MARKUP + 1;
+        /// <summary>
+        /// The default underline parameters.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 static readonly int Underline = NDalic.TEXT_VISUAL_ENABLE_MARKUP + 2;
+        /// <summary>
+        /// The default outline parameters.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 static readonly int Outline = NDalic.TEXT_VISUAL_ENABLE_MARKUP + 3;
+        /// <summary>
+        /// The default text background parameters.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 static readonly int Background = NDalic.TEXT_VISUAL_ENABLE_MARKUP + 4;
     }
 
     /// <summary>
index 229be55..da62412 100755 (executable)
@@ -532,6 +532,12 @@ namespace Tizen.NUI
         protected float? _opacity = null;
 
         /// <summary>
+        /// The FittingMode of the visual.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        protected VisualFittingModeType? _visualFittingMode = null;
+
+        /// <summary>
         /// The map for visual.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
@@ -606,6 +612,21 @@ namespace Tizen.NUI
             }
         }
 
+        /// <summary>
+        /// The fitting mode of the visual.
+        /// The default is defined by the type of visual (if it's suitable to be stretched or not).
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 VisualFittingModeType VisualFittingMode
+        {
+            set
+            {
+                _visualFittingMode = value;
+                UpdateVisual();
+            }
+        }
     }
 
     /// <summary>
@@ -640,6 +661,7 @@ namespace Tizen.NUI
         private ReleasePolicyType? _releasePolicy = null;
         private LoadPolicyType? _loadPolicy = null;
         private bool? _orientationCorrection = true;
+        private bool? _atlasing = false;
 
         /// <summary>
         /// Gets or sets the URL of the image.<br />
@@ -989,6 +1011,25 @@ namespace Tizen.NUI
             }
         }
 
+        /// <summary>
+        /// Whether to use the texture atlas.
+        /// Optional. By default atlasing is off.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 Atlasing
+        {
+            get
+            {
+                return _atlasing ?? (false);
+            }
+            set
+            {
+                _atlasing = value;
+                UpdateVisual();
+            }
+        }
 
         /// <summary>
         /// Compose the out visual map.
@@ -1022,6 +1063,8 @@ namespace Tizen.NUI
                 if (_releasePolicy != null) { _outputVisualMap.Add( ImageVisualProperty.ReleasePolicy , new PropertyValue((int)_releasePolicy)); }
                 if (_loadPolicy != null) { _outputVisualMap.Add( ImageVisualProperty.LoadPolicy, new PropertyValue((int)_loadPolicy)); }
                 if (_orientationCorrection != null) { _outputVisualMap.Add( ImageVisualProperty.OrientationCorrection, new PropertyValue((bool)_orientationCorrection)); }
+                if (_atlasing != null) { _outputVisualMap.Add( ImageVisualProperty.Atlasing, new PropertyValue((bool)_atlasing)); }
+                if (_visualFittingMode != null) { _outputVisualMap.Add((int)Visual.Property.VisualFittingMode, new PropertyValue((int)_visualFittingMode)); }
             }
         }
     }
@@ -1049,6 +1092,10 @@ namespace Tizen.NUI
         private string _verticalAlignment = null;
         private Color _textColor = null;
         private bool? _enableMarkup = null;
+        private PropertyMap _shadow = null;
+        private PropertyMap _underline = null;
+        private PropertyMap _outline = null;
+        private PropertyMap _background = null;
 
         /// <summary>
         /// Gets or sets the text to display in the UTF-8 format.<br />
@@ -1280,6 +1327,82 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Gets or sets the shadow parameters.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 PropertyMap Shadow
+        {
+            get
+            {
+                return _shadow;
+            }
+            set
+            {
+                _shadow = value;
+                UpdateVisual();
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the Underline parameters.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 PropertyMap Underline
+        {
+            get
+            {
+                return _underline;
+            }
+            set
+            {
+                _underline = value;
+                UpdateVisual();
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the Outline parameters.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 PropertyMap Outline
+        {
+            get
+            {
+                return _outline;
+            }
+            set
+            {
+                _outline = value;
+                UpdateVisual();
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets the Background parameters.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 PropertyMap Background
+        {
+            get
+            {
+                return _background;
+            }
+            set
+            {
+                _background = value;
+                UpdateVisual();
+            }
+        }
+
+        /// <summary>
         /// Compose the out visual map.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
@@ -1302,6 +1425,10 @@ namespace Tizen.NUI
                 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
                 if (_mixColor != null) { _outputVisualMap.Add((int)Visual.Property.MixColor, new PropertyValue(_mixColor)); }
                 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
+                if (_shadow != null) { _outputVisualMap.Add(TextVisualProperty.Shadow, new PropertyValue(_shadow)); }
+                if (_underline != null) { _outputVisualMap.Add(TextVisualProperty.Underline, new PropertyValue(_underline)); }
+                if (_outline != null) { _outputVisualMap.Add(TextVisualProperty.Outline, new PropertyValue(_outline)); }
+                if (_background != null) { _outputVisualMap.Add(TextVisualProperty.Background, new PropertyValue(_background)); }
             }
         }
     }
@@ -1415,6 +1542,7 @@ namespace Tizen.NUI
         }
 
         private Color _mixColorForColorVisual = null;
+        private bool? _renderIfTransparent = false;
 
         /// <summary>
         /// Gets or sets the solid color required.<br />
@@ -1435,6 +1563,26 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Gets or sets whether to render if the MixColor is transparent.
+        /// By default it's false, i.e. ColorVisual will not render if the MIX_COLOR is transparent.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        /// 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 RenderIfTransparent
+        {
+            get
+            {
+                return _renderIfTransparent ?? (false);
+            }
+            set
+            {
+                _renderIfTransparent = value;
+                UpdateVisual();
+            }
+        }
+
+        /// <summary>
         /// Compose the out visual map.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
@@ -1448,6 +1596,7 @@ namespace Tizen.NUI
                 if (_shader != null) { _outputVisualMap.Add((int)Visual.Property.Shader, new PropertyValue(_shader)); }
                 if (_premultipliedAlpha != null) { _outputVisualMap.Add((int)Visual.Property.PremultipliedAlpha, new PropertyValue((bool)_premultipliedAlpha)); }
                 if (_opacity != null) { _outputVisualMap.Add((int)Visual.Property.Opacity, new PropertyValue((float)_opacity)); }
+                if (_renderIfTransparent != null) { _outputVisualMap.Add(ColorVisualProperty.RenderIfTransparent, new PropertyValue((bool)_renderIfTransparent)); }
             }
         }
     }
diff --git a/test/NUITestSample/NUITestSample/examples/visual-test.cs b/test/NUITestSample/NUITestSample/examples/visual-test.cs
new file mode 100755 (executable)
index 0000000..9ce5e94
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+* 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.
+* 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.NUI;
+using Tizen.NUI.BaseComponents;
+
+namespace VisualTest
+{
+    class Example : NUIApplication
+    {
+        private static string resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+
+        protected override void OnCreate()
+        {
+            base.OnCreate();
+            Initialize();
+        }
+
+        public void Initialize()
+        {
+            Window window = Window.Instance;
+            window.BackgroundColor = Color.White;
+
+            ImageVisual image = new ImageVisual()
+            {
+                URL = resourcePath + "/images/gallery-5.jpg",
+                FittingMode = FittingModeType.ShrinkToFit,
+                DesiredWidth = 400,
+                DesiredHeight = 300,
+                VisualFittingMode = VisualFittingModeType.FitKeepAspectRatio,
+            };
+
+            ImageView imageV = new ImageView()
+            {
+                Size2D = new Size2D(500, 400),
+                BackgroundColor = Color.Cyan,
+                Image = image.OutputVisualMap,
+                ParentOrigin = ParentOrigin.Center,
+                PivotPoint = PivotPoint.Center,
+                Position2D = new Position2D(-300, 0),
+                PositionUsesPivotPoint = true,
+            };
+
+            window.Add(imageV);
+
+            PropertyMap outline = new PropertyMap();
+            outline.Add("color", new PropertyValue(Color.Red));
+            outline.Add("width", new PropertyValue(2.0f));
+
+            PropertyMap underline = new PropertyMap();
+            underline.Add("enable", new PropertyValue(true));
+            underline.Add("color", new PropertyValue("blue"));
+            underline.Add("height", new PropertyValue(2));
+
+            PropertyMap shadow = new PropertyMap();
+            shadow.Add("offset", new PropertyValue(new Vector2(2.0f, 2.0f)));
+            shadow.Add("color", new PropertyValue(Color.Green));
+            shadow.Add("blurRadius", new PropertyValue(5.0f));
+
+            PropertyMap bg = new PropertyMap();
+            bg.Add("enable", new PropertyValue(true));
+            bg.Add("color", new PropertyValue(Color.Cyan));
+
+            TextVisual text = new TextVisual()
+            {
+                Text = "I'm a text visual",
+                PointSize = 52,
+                Outline = outline,
+                Underline = underline,
+                Shadow = shadow,
+                Background = bg,
+            };
+
+            View view = new View()
+            {
+                Size2D = new Size2D(500, 400),
+                ParentOrigin = ParentOrigin.Center,
+                PivotPoint = PivotPoint.Center,
+                PositionUsesPivotPoint = true,
+                Background = text.OutputVisualMap,
+                Position2D = new Position2D(300, 0),
+            };
+            window.Add(view);
+        }
+    }
+}