dali ver 1.2.27 devel-master branch code sync
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / devel-src / visual-high-level / VisualView.cs
1 /*\r
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  * http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  *\r
16  */\r
17 \r
18 using System;\r
19 using System.Runtime.InteropServices;\r
20 using System.Collections.Generic;\r
21 using System.Linq;\r
22 using Tizen.NUI;\r
23 \r
24 namespace Tizen.NUI\r
25 {\r
26 public class VisualView : CustomView\r
27 {\r
28     //private LinkedList<VisualBase> _visualList = null;\r
29     private Dictionary<int, VisualBase> _visualDictionary = null;\r
30 \r
31     static CustomView CreateInstance()\r
32     {\r
33       return new VisualView();\r
34     }\r
35 \r
36     // static constructor registers the control type (only runs once)\r
37     static VisualView()\r
38     {\r
39       // ViewRegistry registers control type with DALi type registery\r
40       // also uses introspection to find any properties that need to be registered with type registry\r
41       ViewRegistry.Instance.Register(CreateInstance, typeof(VisualView) );\r
42     }\r
43 \r
44     public VisualView() : base(typeof(VisualView).Name, ViewWrapperImpl.CustomViewBehaviour.REQUIRES_KEYBOARD_NAVIGATION_SUPPORT | ViewWrapperImpl.CustomViewBehaviour.DISABLE_STYLE_CHANGE_SIGNALS)\r
45     {\r
46     }\r
47 \r
48     public override void OnInitialize()\r
49     {\r
50       //Initialize empty\r
51       _visualDictionary = new Dictionary<int, VisualBase>();\r
52     }\r
53 \r
54     //\r
55     public void AddVisual( VisualBase visual )\r
56     {\r
57         //_visualDictionary.Add( visual );\r
58         string visualViewProperty = "visualViewProperty" + _visualDictionary.Count;\r
59         Console.WriteLine ("--------------visualViewProperty name: "  + visualViewProperty );\r
60 \r
61         int visualViewPropertyIndex = RegisterProperty( visualViewProperty, new Tizen.NUI.Property.Value(visualViewProperty), Tizen.NUI.Property.AccessMode.READ_WRITE);\r
62         _visualDictionary.Add( visualViewPropertyIndex, visual );\r
63 \r
64         RegisterVisual( visualViewPropertyIndex, visual );\r
65     }\r
66 \r
67     public void RemoveVisual( VisualBase visual )\r
68     {\r
69         int foundIndex = -1;\r
70 \r
71         foreach (var item in _visualDictionary)\r
72         {\r
73             if (item.Value == visual) \r
74             {\r
75                 foundIndex = item.Key;\r
76                 EnableVisual(foundIndex, false);\r
77                 UnregisterVisual(foundIndex);\r
78                 _visualDictionary.Remove(foundIndex);\r
79             }\r
80         }\r
81     }\r
82 \r
83     public int NumOfVisual()\r
84     {\r
85         return _visualDictionary.Count;\r
86     }\r
87 \r
88     public void DisposeAllVisual()\r
89     {\r
90         //\r
91     }\r
92 }\r
93 }