2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.ComponentModel;
24 /// GraphicsTypeManager class to manage various types.
26 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
27 [EditorBrowsable(EditorBrowsableState.Never)]
28 public class GraphicsTypeManager
32 /// Creates private GraphicsTypeManager object.
34 private GraphicsTypeManager()
36 _typeConverter = new GraphicsTypeConverter();
40 /// An unique Singleton Instance of GraphicsTypeManager
42 /// <value>Singleton instance of GraphicsTypeManager</value>
43 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
44 [EditorBrowsable(EditorBrowsableState.Never)]
45 public static GraphicsTypeManager Instance
49 if (_graphicsTypeManager == null)
51 _graphicsTypeManager = new GraphicsTypeManager();
54 return _graphicsTypeManager;
60 /// Sets the custom GraphicsTypeConverter.
62 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
63 [EditorBrowsable(EditorBrowsableState.Never)]
64 public void SetTypeConverter(GraphicsTypeConverter typeConverter)
66 _typeConverter = typeConverter;
70 /// Converts script to px
72 /// <returns>Pixel value that is converted from input string</returns>
73 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
74 [EditorBrowsable(EditorBrowsableState.Never)]
75 public float ConvertScriptToPixel(string scriptValue)
77 return _typeConverter.ConvertScriptToPixel(scriptValue);
81 /// Converts other type to px
83 /// <returns>Pixel value that is converted by the the display matric</returns>
84 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
85 [EditorBrowsable(EditorBrowsableState.Never)]
86 public virtual float ConvertToPixel(float value)
88 return _typeConverter.ConvertToPixel(value);
92 /// Converts px to other type
94 /// <returns>An converted value from pixel</returns>
95 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
96 [EditorBrowsable(EditorBrowsableState.Never)]
97 public virtual float ConvertFromPixel(float value)
99 return _typeConverter.ConvertFromPixel(value);
102 internal void RegisterCustomConverterForDynamicResourceBinding(global::System.Type type, Tizen.NUI.Binding.TypeConverter userConverter)
104 if (Tizen.NUI.Binding.BindableProperty.UserCustomConvertTypes.ContainsKey(type) == false)
106 Tizen.NUI.Binding.BindableProperty.UserCustomConvertTypes.Add(type, userConverter);
108 //NUILog.Error($"user custom converter ditionary count={Tizen.NUI.Binding.BindableProperty.UserCustomConvertTypes.Count}");
111 private volatile static GraphicsTypeManager _graphicsTypeManager;
112 private GraphicsTypeConverter _typeConverter;