AnimationBetween() parameter changed and more
[platform/core/csapi/nui.git] / NUISamples / NUISamples.TizenTV / examples / transition.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 Tizen.NUI;\r
21 using Tizen.NUI.Constants;\r
22 \r
23 namespace MyCSharpExample\r
24 {\r
25     // A spin control (for continously changing values when users can easily predict a set of values)\r
26     class Example\r
27     {\r
28         private Application _application;\r
29         private ContentView _contentView;\r
30         private TextLabel _title;\r
31         private PushButton _shadowButton;\r
32         private bool _active = false;\r
33         \r
34         //Visual High level class\r
35         private ContentView myContentView;\r
36         private PushButton myButtonTest;\r
37         private int myCount;\r
38 \r
39         public Example(Application application)\r
40         {\r
41             _application = application;\r
42             _application.Initialized += Initialize;\r
43         }\r
44 \r
45         public void Initialize(object source, NUIApplicationInitEventArgs e)\r
46         {\r
47             Stage stage = Stage.Instance;\r
48             stage.BackgroundColor = Color.White;\r
49 \r
50             TableView contentLayout = new TableView(4, 1);\r
51             contentLayout.Name = ("ContentLayout");\r
52             contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent;\r
53             contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent;\r
54             contentLayout.ParentOrigin = ParentOrigin.TopLeft;\r
55             contentLayout.AnchorPoint = AnchorPoint.TopLeft;\r
56             contentLayout.SetCellPadding(new Size2D(0.0f, 5.0f));\r
57             contentLayout.BackgroundColor = new Color(0.949f, 0.949f, 0.949f, 1.0f);\r
58 \r
59             stage.GetDefaultLayer().Add(contentLayout);\r
60 \r
61             _title = new TextLabel("Custom Control Transition Example");\r
62             _title.Name = ("Title");\r
63             _title.StyleName = ("Title");\r
64             _title.WidthResizePolicy = ResizePolicyType.FillToParent;\r
65             _title.HeightResizePolicy = ResizePolicyType.UseNaturalSize;\r
66             _title.HorizontalAlignment = "CENTER";\r
67             _title.BackgroundColor = Color.Yellow;\r
68             contentLayout.Add(_title);\r
69             contentLayout.SetFitHeight(0);\r
70 \r
71             TableView buttonLayout = new TableView(3, 3);\r
72             buttonLayout.WidthResizePolicy = ResizePolicyType.FillToParent;\r
73             buttonLayout.HeightResizePolicy = ResizePolicyType.FillToParent;\r
74             buttonLayout.SetFixedHeight(1, 100);\r
75             buttonLayout.SetFixedHeight(0, 100);\r
76             buttonLayout.SetFixedWidth(1, 500);\r
77             contentLayout.Add(buttonLayout);\r
78 \r
79             _shadowButton = new PushButton();\r
80             _shadowButton.LabelText = "Toggle Transition";\r
81             _shadowButton.Name = ("ToggleTransition");\r
82             _shadowButton.ParentOrigin = ParentOrigin.Center;\r
83             _shadowButton.AnchorPoint = AnchorPoint.Center;\r
84             _shadowButton.Clicked += (obj, ev) =>\r
85             {\r
86                 _active = !_active;\r
87                 _contentView.ActiveContent = _active;\r
88                 return true;\r
89             };\r
90             _shadowButton.WidthResizePolicy = ResizePolicyType.FillToParent;\r
91             _shadowButton.HeightResizePolicy = ResizePolicyType.FillToParent;\r
92             buttonLayout.AddChild(_shadowButton, new TableView.CellPosition(1, 1));\r
93 \r
94             // Create a conttent view\r
95             _contentView = new ContentView();\r
96             _contentView.WidthResizePolicy = ResizePolicyType.Fixed;\r
97             _contentView.HeightResizePolicy = ResizePolicyType.Fixed;\r
98             _contentView.Size = new Size(250.0f, 250.0f, 0.0f);\r
99             _contentView.IconVisual = "/home/owner/apps_rw/NUISamples.TizenTV/res/images/application-icon-0.png";\r
100 \r
101             PropertyMap background = new PropertyMap();\r
102             background.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));\r
103             background.Insert(ImageVisualProperty.URL, new PropertyValue("/home/owner/apps_rw/NUISamples.TizenTV/res/images/background-blocks.jpg"));\r
104             _contentView.Background = background;\r
105             contentLayout.Add(_contentView);\r
106 \r
107 \r
108             // Visual High level class\r
109             myContentView = new ContentView();\r
110             myContentView.WidthResizePolicy = ResizePolicyType.Fixed;\r
111             myContentView.HeightResizePolicy = ResizePolicyType.Fixed;\r
112             myContentView.Size = new Size(250.0f, 250.0f, 0.0f);\r
113             contentLayout.Add(myContentView);\r
114 \r
115 \r
116             myButtonTest = new PushButton();\r
117             myButtonTest.LabelText = "Make Visual";\r
118             myButtonTest.Name = ("MakeVisual");\r
119             myButtonTest.ParentOrigin = ParentOrigin.Center;\r
120             myButtonTest.AnchorPoint = AnchorPoint.Center;\r
121             myButtonTest.Clicked += (obj, ev) =>\r
122             {\r
123                 if (++myCount > 5) myCount = 0;\r
124 \r
125                 ImageVisualMap _imageViewMap = new ImageVisualMap();\r
126                 _imageViewMap.URL = "/home/owner/apps_rw/NUISamples.TizenTV/res/images/gallery-" + myCount + ".jpg";\r
127                 _imageViewMap.FittingMode = FittingModeType.ShrinkToFit;\r
128                 _imageViewMap.DepthIndex = 0;\r
129 \r
130                 TextVisualMap _textVisualMap = new TextVisualMap();\r
131                 _textVisualMap.Text = "TEXT-" + myCount;\r
132                 _textVisualMap.PointSize = 20.0f; //20 + 2 * myCount;\r
133                 _textVisualMap.TextColor = new Color(1.0f, 1.0f, 1.0f, 1.0f);\r
134                 _textVisualMap.DepthIndex = 1;\r
135 \r
136                 myContentView.ImageVisual = _imageViewMap;\r
137                 //myContentView.TextVisual = _textVisualMap;\r
138                 return true;\r
139             };\r
140             myButtonTest.WidthResizePolicy = ResizePolicyType.FillToParent;\r
141             myButtonTest.HeightResizePolicy = ResizePolicyType.FillToParent;\r
142             buttonLayout.AddChild(myButtonTest, new TableView.CellPosition(0, 1));\r
143 \r
144 \r
145         }\r
146 \r
147         public void MainLoop()\r
148         {\r
149             _application.MainLoop();\r
150         }\r
151 \r
152         /// <summary>\r
153         /// The main entry point for the application.\r
154         /// </summary>\r
155         [STAThread]\r
156         static void Main(string[] args)\r
157         {\r
158             Example example = new Example(Application.NewApplication("/home/owner/apps_rw/NUISamples.TizenTV/res/json/style-example-theme-one.json"));\r
159             example.MainLoop();\r
160         }\r
161     }\r
162 }