/// <since_tizen> 3 </since_tizen>
public class VisualView : CustomView
{
- //private LinkedList<VisualBase> _visualList = null;
+ private Dictionary<int, string> visualNameDictionary = null;
private Dictionary<int, VisualBase> visualDictionary = null;
private Dictionary<int, PropertyMap> tranformDictionary = null;
private PropertyArray animateArray = null;
base.OnInitialize();
//Initialize empty
+ visualNameDictionary = new Dictionary<int, string>();
visualDictionary = new Dictionary<int, VisualBase>();
tranformDictionary = new Dictionary<int, PropertyMap>();
animateArray = new PropertyArray();
/// <since_tizen> 3 </since_tizen>
public void AddVisual(string visualName, VisualMap visualMap)
{
- VisualBase visual = null;
int visualIndex = -1;
/* If the visual had added, then replace it using RegisterVusal. */
//visual.Name = name;
- foreach (var item in visualDictionary)
+ foreach (var item in visualNameDictionary)
{
- if (item.Value.Name == visualName)
+ if (item.Value == visualName)
{
/* Find a existed visual, its key also exited. */
visualIndex = item.Key;
UnregisterVisual(visualIndex);
+ visualNameDictionary.Remove(visualIndex);
visualDictionary.Remove(visualIndex);
tranformDictionary.Remove(visualIndex);
break;
{
throw new ArgumentNullException(nameof(visualMap));
}
- visual = VisualFactory.Instance.CreateVisual(visualMap.OutputVisualMap); // Create a visual for the new one.
- visual.Name = visualName;
- visual.DepthIndex = visualMap.DepthIndex;
-
- RegisterVisual(visualIndex, visual);
-
- visualDictionary.Add(visualIndex, visual);
- tranformDictionary.Add(visualIndex, visualMap.OutputTransformMap);
visualMap.VisualIndex = visualIndex;
visualMap.Name = visualName;
visualMap.Parent = this;
- RelayoutRequest();
+ // Register index and name
+ UpdateVisual(visualIndex, visualName, visualMap);
}
}
/// <since_tizen> 3 </since_tizen>
public void RemoveVisual(string visualName)
{
- foreach (var item in visualDictionary)
+ foreach (var item in visualNameDictionary)
{
- if (item.Value.Name == visualName)
+ if (item.Value == visualName)
{
EnableVisual(item.Key, false);
UnregisterVisual(item.Key);
tranformDictionary.Remove(item.Key);
visualDictionary.Remove(item.Key);
+ visualNameDictionary.Remove(item.Key);
RelayoutRequest();
break;
/// <since_tizen> 3 </since_tizen>
public void RemoveAll()
{
- foreach (var item in visualDictionary)
+ foreach (var item in visualNameDictionary)
{
EnableVisual(item.Key, false);
UnregisterVisual(item.Key);
}
visualDictionary.Clear();
tranformDictionary.Clear();
+ visualNameDictionary.Clear();
RelayoutRequest();
}
{
foreach (var item in visualDictionary)
{
- item.Value.SetTransformAndSize(tranformDictionary[item.Key], size);
- EnableVisual(item.Key, true);
+ if(item.Value != null)
+ {
+ item.Value.SetTransformAndSize(tranformDictionary[item.Key], size);
+ EnableVisual(item.Key, true);
+ }
}
}
string strAlpha = alphaFunction?.GetDescription();
- foreach (var item in visualDictionary.ToList())
+ foreach (var item in visualNameDictionary.ToList())
{
- if (item.Value.Name == target.Name)
+ if (item.Value == target.Name)
{
using (PropertyMap animator = new PropertyMap())
using (PropertyMap timePeriod = new PropertyMap())
string strAlpha = alphaFunction?.GetDescription();
- foreach (var item in visualDictionary.ToList())
+ foreach (var item in visualNameDictionary.ToList())
{
- if (item.Value.Name == target.Name)
+ if (item.Value == target.Name)
{
using (PropertyMap animator = new PropertyMap())
using (PropertyMap timePeriod = new PropertyMap())
throw new ArgumentNullException(nameof(visualMap));
}
- foreach (var item in visualDictionary.ToList())
+ foreach (var item in visualNameDictionary.ToList())
{
- if (item.Value.Name == visualMap.Target)
+ if (item.Value == visualMap.Target)
{
using (TransitionData transitionData = new TransitionData(visualMap.OutputVisualMap))
{
internal void UpdateVisual(int visualIndex, string visualName, VisualMap visualMap)
{
- VisualBase visual = null;
-
- visual = VisualFactory.Instance.CreateVisual(visualMap.OutputVisualMap);
- visual.Name = visualName;
- visual.DepthIndex = visualMap.DepthIndex;
-
- RegisterVisual(visualIndex, visual);
+ VisualBase visual = VisualFactory.Instance.CreateVisual(visualMap.OutputVisualMap);
+ visualNameDictionary[visualIndex] = visualName;
visualDictionary[visualIndex] = visual;
tranformDictionary[visualIndex] = visualMap.OutputTransformMap;
- RelayoutRequest();
- NUILog.Debug("UpdateVisual() name=" + visualName);
+ if(visual != null)
+ {
+ visual.Name = visualName;
+ visual.DepthIndex = visualMap.DepthIndex;
+
+ RegisterVisual(visualIndex, visual);
+
+ RelayoutRequest();
+ NUILog.Debug("UpdateVisual() name=" + visualName);
+ }
+ else
+ {
+ NUILog.Debug("UpdateVisual() FAIL! visual create failed name=" + visualName);
+ }
}
static CustomView CreateInstance()