2 * Copyright (c) 2016 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;
23 namespace VisualViewTest3
25 // An example of Visual View control.
26 class Example : NUIApplication
28 private VisualView _visualView = null;
29 //private const string resources = "/home/owner/apps_rw/NUISamples.TizenTV/res";
30 private Window _window;
32 public Example() : base()
36 public Example(string stylesheet) : base(stylesheet)
40 public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
44 protected override void OnCreate()
50 private ImageVisual imageVisualMap1;
51 private ImageVisual imageVisualMap2;
54 public void Initialize()
56 Stage stage = Stage.Instance;
58 /* Create a visual view. */
59 _visualView = new VisualView();
60 _visualView.ParentOrigin = ParentOrigin.TopLeft;
61 _visualView.AnchorPoint = AnchorPoint.TopLeft;
62 _visualView.Size = new Size(stage.Size.Width, stage.Size.Height, 0.0f);
65 ColorVisual colorVisualMap1 = new ColorVisual();
66 colorVisualMap1.Color = Color.Green;
67 _visualView.Background = colorVisualMap1.OutputVisualMap;
69 stage.GetDefaultLayer().Add(_visualView);
71 /* image visual 1. No transform setting case. */
72 imageVisualMap1 = new ImageVisual();
73 imageVisualMap1.URL = resources + "/images/image-1.jpg";
74 imageVisualMap1.DepthIndex = 1.0f;
75 //_visualView.AddVisual("imageVisual1", imageVisualMap1);
77 /* image visual 2. Using RelativePosition and SizePolicyWidth setting case. */
78 imageVisualMap2 = new ImageVisual();
79 imageVisualMap2.URL = resources + "/images/image-2.jpg";
80 /* Using Size, you can set SizePolicyWidth and SizePolicyHeight separately, default by relative. */
81 imageVisualMap2.Size = new Vector2(400.0f, 0.3f);
82 /* Using RelativePosition, then PositionPolicyX and PositionPolicyY will be relative. */
83 imageVisualMap2.RelativePosition = new Vector2(0.1f, 0.1f);
84 imageVisualMap2.SizePolicyWidth = VisualTransformPolicyType.Absolute;
85 imageVisualMap2.Origin = Visual.AlignType.TopBegin;
86 imageVisualMap2.AnchorPoint = Visual.AlignType.TopBegin;
87 /* Ensure imageVisual show */
88 imageVisualMap2.DepthIndex = 9.0f;
89 _visualView.AddVisual("imageVisual2", imageVisualMap2);
90 /* If imageVisual2 added first, the it will be covered by imageVisual1.
91 so, we need to set their depth index to ensure they all can be showed.
93 _visualView.AddVisual("imageVisual1", imageVisualMap1);
95 _window = this.Window;
96 _window.WindowFocusChanged += (sender, ee) =>
99 Tizen.Log.Debug("NUI", "[WindowFocusTest] WindowFocusChanged event comes! focus gained=" + ee.FocusGained);
102 Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable());
103 _window.SetAcceptFocus(false);
104 Tizen.Log.Debug("NUI", "[WindowFocusTest] set focus acceptable=false!!!");
105 Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable());
106 _window.SetAcceptFocus(true);
107 Tizen.Log.Debug("NUI", "[WindowFocusTest] set focus acceptable=true!!!");
108 Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable());
112 static void _Main(string[] args)
114 Example example = new Example();