2 * Copyright (c) 2017 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.
19 using System.Runtime.InteropServices;
21 using Tizen.NUI.Constants;
22 using Tizen.NUI.BaseComponents;
24 namespace VisualViewTest3
26 // An example of Visual View control.
27 class Example : NUIApplication
29 private VisualView _visualView = null;
30 private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res";
31 private Window _window;
33 public Example() : base()
37 public Example(string stylesheet) : base(stylesheet)
41 public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
45 protected override void OnCreate()
51 private ImageVisual imageVisualMap1;
52 private ImageVisual imageVisualMap2;
55 public void Initialize()
57 Window window = Window.Instance;
59 /* Create a visual view. */
60 _visualView = new VisualView();
61 _visualView.ParentOrigin = ParentOrigin.TopLeft;
62 _visualView.PivotPoint = PivotPoint.TopLeft;
63 _visualView.Size2D = new Size2D(window.Size.Width, window.Size.Height);
66 ColorVisual colorVisualMap1 = new ColorVisual();
67 colorVisualMap1.Color = Color.Green;
68 _visualView.Background = colorVisualMap1.OutputVisualMap;
70 window.Add(_visualView);
72 /* image visual 1. No transform setting case. */
73 imageVisualMap1 = new ImageVisual();
74 imageVisualMap1.URL = resources + "/images/image-1.jpg";
75 imageVisualMap1.DepthIndex = 1;
76 //_visualView.AddVisual("imageVisual1", imageVisualMap1);
78 /* image visual 2. Using RelativePosition and SizePolicyWidth setting case. */
79 imageVisualMap2 = new ImageVisual();
80 imageVisualMap2.URL = resources + "/images/image-2.jpg";
81 /* Using Size, you can set SizePolicyWidth and SizePolicyHeight separately, default by relative. */
82 imageVisualMap2.Size = new Vector2(400.0f, 0.3f);
83 /* Using RelativePosition, then PositionPolicyX and PositionPolicyY will be relative. */
84 imageVisualMap2.RelativePosition = new Vector2(0.1f, 0.1f);
85 imageVisualMap2.SizePolicyWidth = VisualTransformPolicyType.Absolute;
86 imageVisualMap2.Origin = Visual.AlignType.TopBegin;
87 imageVisualMap2.AnchorPoint = Visual.AlignType.TopBegin;
88 /* Ensure imageVisual show */
89 imageVisualMap2.DepthIndex = 9;
90 _visualView.AddVisual("imageVisual2", imageVisualMap2);
91 /* If imageVisual2 added first, the it will be covered by imageVisual1.
92 so, we need to set their depth index to ensure they all can be showed.
94 _visualView.AddVisual("imageVisual1", imageVisualMap1);
96 _window = Window.Instance;
97 _window.FocusChanged += (sender, ee) =>
100 Tizen.Log.Debug("NUI", "[WindowFocusTest] WindowFocusChanged event comes! focus gained=" + ee.FocusGained);
103 Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable());
104 _window.SetAcceptFocus(false);
105 Tizen.Log.Debug("NUI", "[WindowFocusTest] set focus acceptable=false!!!");
106 Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable());
107 _window.SetAcceptFocus(true);
108 Tizen.Log.Debug("NUI", "[WindowFocusTest] set focus acceptable=true!!!");
109 Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable());
113 static void _Main(string[] args)
115 Example example = new Example();