[NUI] Merge branch 'devel/nui'
[platform/core/csapi/tizenfx.git] / NUIsamples / NUIsamples / src / examples / sibling-order-test.cs
1 // Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15
16 using System;
17 using Tizen.NUI;
18 using Tizen.NUI.UIComponents;
19 using Tizen.NUI.BaseComponents;
20 using System.Collections.Generic;
21
22
23 // 1) sibling order test
24 namespace SiblingOrderTest
25 {
26     class Example : NUIApplication
27     {
28         public Example() : base()
29         {
30         }
31
32         public Example(string stylesheet) : base(stylesheet)
33         {
34         }
35
36         public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
37         {
38         }
39
40         protected override void OnCreate()
41         {
42             base.OnCreate();
43             Initialize();
44         }
45
46         Window _window;
47
48         public void Initialize()
49         {
50             _window = Window.Instance;
51             _window.BackgroundColor = Color.White;
52
53             // sibling order test
54             // By default, the SiblingOrder is 0.
55             SiblingTest1();
56
57             // sibling order test
58             // Set the SiblingOrder 0 -> 9
59             SiblingTest2();
60
61             // sibling order test
62             // Set the SiblingOrder 10 -> 1
63             SiblingTest3();
64
65             // sibling order test
66             // Set the SiblingOrder 5 -> 1 & 0 -> 4
67             SiblingTest4();
68
69             // sibling order test
70             // Set the SiblingOrder 0 -> 4 & 5 -> 1
71             SiblingTest5();
72         }
73
74         public void SiblingTest1()
75         {
76             Position2D _myPos = new Position2D(100, 30);
77
78             for (int i = 0; i < 10; i++)
79             {
80                 PushButton _view = new PushButton();
81
82                 _view.Name = "sibling" + i;
83                 _view.LabelText = "view" + i;
84                 _view.MinimumSize = new Size2D(100, 50);
85                 _view.ParentOrigin = ParentOrigin.TopLeft;
86                 _view.PivotPoint = PivotPoint.TopLeft;
87                 _view.Position2D = _myPos + new Position2D(20 * i, 10 * i);
88
89                 _window.Add(_view);
90             }
91         }
92
93         public void SiblingTest2()
94         {
95             Position2D _myPos = new Position2D(100, 180);
96
97             for (int i = 0; i < 10; i++)
98             {
99                 PushButton _view = new PushButton();
100
101                 _view.Name = "sibling" + i;
102                 _view.LabelText = "view" + i;
103                 _view.MinimumSize = new Size2D(100, 50);
104                 _view.ParentOrigin = ParentOrigin.TopLeft;
105                 _view.PivotPoint = PivotPoint.TopLeft;
106                 _view.Position2D = _myPos + new Position2D(20 * i, 10 * i);
107
108                 _window.Add(_view);
109                 _view.SiblingOrder = i;
110             }
111         }
112
113         public void SiblingTest3()
114         {
115             Position2D _myPos = new Position2D(100, 330);
116
117             for (int i = 0; i < 10; i++)
118             {
119                 PushButton _view = new PushButton();
120
121                 _view.Name = "sibling" + i;
122                 _view.LabelText = "view" + i;
123                 _view.MinimumSize = new Size2D(100, 50);
124                 _view.ParentOrigin = ParentOrigin.TopLeft;
125                 _view.PivotPoint = PivotPoint.TopLeft;
126                 _view.Position2D = _myPos + new Position2D(20 * i, 10 * i);
127
128                 _window.Add(_view);
129                 _view.SiblingOrder = 10-i;
130             }
131         }
132
133         public void SiblingTest4()
134         {
135             Position2D _myPos = new Position2D(100, 480);
136
137             for (int i = 0; i < 10; i++)
138             {
139                 PushButton _view = new PushButton();
140
141                 _view.Name = "sibling" + i;
142                 _view.LabelText = "view" + i;
143                 _view.MinimumSize = new Size2D(100, 50);
144                 _view.ParentOrigin = ParentOrigin.TopLeft;
145                 _view.PivotPoint = PivotPoint.TopLeft;
146                 _view.Position2D = _myPos + new Position2D(20 * i, 10 * i);
147
148                 _window.Add(_view);
149
150                 if (i<5)
151                 {
152                     _view.SiblingOrder = 5-i;
153                 }
154                 else
155                 {
156                     _view.SiblingOrder = i-5;
157                 }
158             }
159         }
160
161         public void SiblingTest5()
162         {
163             Position2D _myPos = new Position2D(100, 630);
164
165             for (int i = 0; i < 10; i++)
166             {
167                 PushButton _view = new PushButton();
168
169                 _view.Name = "sibling" + i;
170                 _view.LabelText = "view" + i;
171                 _view.MinimumSize = new Size2D(100, 50);
172                 _view.ParentOrigin = ParentOrigin.TopLeft;
173                 _view.PivotPoint = PivotPoint.TopLeft;
174                 _view.Position2D = _myPos + new Position2D(20 * i, 10 * i);
175
176                 _window.Add(_view);
177
178                 if (i<5)
179                 {
180                     _view.SiblingOrder = i;
181                 }
182                 else
183                 {
184                     _view.SiblingOrder = 10-i;
185                 }
186             }
187         }
188
189         static void _Main(string[] args)
190         {
191             Example example = new Example();
192             example.Run(args);
193         }
194     }
195 }