{
class Application
{
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
[STAThread]
static void Main(string[] args)
{
+ new ImageViewUserShaderTest2.Test().Run(args);
+ //new ImageViewUserShaderTest.Test().Run(args);
+ //new ScreenPositionTest.Test().Run(args);
+ //new ImageViewOrientationCorrectionTest.Test().Run(args);
+ //new VisaulAnimationExample.Example().Run(args);
+
//new ControlDashboard.Example().Run(args);
//new DatePickerTest.Example().Run(args);
//new DatePickerUsingJson.Example().Run(args);
//new FlexContainerTest.SampleMain().Run(args);
//new DaliTest.Example().Run(args);
//new RelativeVectorTest.Example().Run(args);
- //new VisaulAnimationExample.Example().Run(args);
//new VisaulAnimationExample.Example2().Run(args);
//new VisaulAnimationExample.Example3().Run(args);
//new VisualViewTest.Example().Run(args);
//new WidgetViewTest.Example().Run(args);
//new DisposeTest.Example().Run(args);
//new SvgTest.Program().Run(args);
- new ImageViewOrientationCorrectionTest.Program().Run(args);
}
}
}
</PropertyGroup>
<ItemGroup>
- <Folder Include="lib\"/>
- <Folder Include="res\"/>
+ <Folder Include="lib\" />
+ <Folder Include="res\" />
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Tizen.NET" Version="4.0.0" >
- <ExcludeAssets>Runtime</ExcludeAssets>
- </PackageReference>
+ <PackageReference Include="Tizen.NET" Version="4.0.1-preview1-00018" />
<PackageReference Include="Tizen.NET.Sdk" Version="1.0.0" />
</ItemGroup>
namespace ImageViewOrientationCorrectionTest
{
- class Program : NUIApplication
+ class Test : NUIApplication
{
- //private static string resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
- string testUrl0 = "/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/test-image.png";
- string testUrl1 = "/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/test-image2.png";
- string testUrl3 = "/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/test-image3.jpg";
- string testUrl4 = "/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/test-image4.jpg";
+ private static string resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+ static string testUrl0 = resourcePath + "/images/test-image0.png";
+ static string testUrl1 = resourcePath + "/images/test-image1.png";
+ static string testUrl3 = resourcePath + "/images/test-image2.jpg";
+ static string testUrl4 = resourcePath + "/images/test-image3.jpg";
+
+ string TAG = "NUI";
protected override void OnCreate()
{
void Initialize()
{
- //NUILog.Debug($"ImageViewOrientationCorrectionTest => Initialize()");
-
Window window = Window.Instance;
window.BackgroundColor = Color.White;
Vector2 dpi = new Vector2();
dpi = window.Dpi;
- //NUILog.Debug($"Window.Dpi X={dpi.X}, Y={dpi.Y}");
+ Tizen.Log.Fatal(TAG, $"Window.Dpi X={dpi.X}, Y={dpi.Y}");
textField[0] = new TextField();
textField[0].Size2D = new Size2D(350 * resol, 64 * resol);
window.Add(textField[2]);
window.Add(textField[3]);
- //PropertyMap map0 = new PropertyMap();
- //map0.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
- //map0.Add(ImageVisualProperty.URL, new PropertyValue(testUrl0));
- //map0.Add(ImageVisualProperty.CropToMask + 3, new PropertyValue(false));
- //imageView[0] = new ImageView();
- //imageView[0].Image = map0;
+ //Tizen.Log.Fatal(TAG, $"imageView[0].ResourceUrl={imageView[0].ResourceUrl}");
+
imageView[0] = new ImageView();
imageView[0].ResourceUrl = testUrl0;
- //imageView[0].OrientationCorrection = false;
+ imageView[0].OrientationCorrection = false;
imageView[0].Size2D = new Size2D(300 * resol, 400 * resol);
imageView[0].Position2D = new Position2D(10 * resol, 20 * resol);
imageView[0].PivotPoint = PivotPoint.TopLeft;
imageView[0].BackgroundColor = Color.Black;
window.Add(imageView[0]);
- //PropertyMap map1 = new PropertyMap();
- //map1.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
- //map1.Add(ImageVisualProperty.URL, new PropertyValue(testUrl1));
- //map1.Add(ImageVisualProperty.CropToMask + 3, new PropertyValue(true));
- //imageView[1] = new ImageView();
- //imageView[1].Image = map1;
imageView[1] = new ImageView();
imageView[1].ResourceUrl = testUrl1;
- //imageView[1].OrientationCorrection = true;
+ imageView[1].OrientationCorrection = true;
imageView[1].Size2D = new Size2D(300 * resol, 400 * resol);
imageView[1].Position2D = new Position2D(400 * resol, 20 * resol);
imageView[1].PivotPoint = PivotPoint.TopLeft;
imageView[1].BackgroundColor = Color.Black;
window.Add(imageView[1]);
- //PropertyMap map2 = new PropertyMap();
- //map2.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
- //map2.Add(ImageVisualProperty.URL, new PropertyValue(testUrl3));
- //map2.Add(ImageVisualProperty.CropToMask + 3, new PropertyValue(false));
- //imageView[2] = new ImageView();
- //imageView[2].Image = map2;
imageView[2] = new ImageView();
imageView[2].ResourceUrl = testUrl3;
- //imageView[2].OrientationCorrection = false;
+ imageView[2].OrientationCorrection = false;
imageView[2].Size2D = new Size2D(300 * resol, 400 * resol);
imageView[2].Position2D = new Position2D(750 * resol, 20 * resol);
imageView[2].PivotPoint = PivotPoint.TopLeft;
imageView[2].BackgroundColor = Color.Black;
window.Add(imageView[2]);
- //PropertyMap map3 = new PropertyMap();
- //map3.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image));
- //map3.Add(ImageVisualProperty.URL, new PropertyValue(testUrl4));
- //map3.Add(ImageVisualProperty.CropToMask + 3, new PropertyValue(true));
- //imageView[3] = new ImageView();
- //imageView[3].Image = map3;
imageView[3] = new ImageView();
imageView[3].ResourceUrl = testUrl4;
- //imageView[3].OrientationCorrection = true;
+ imageView[3].OrientationCorrection = true;
imageView[3].Size2D = new Size2D(300 * resol, 400 * resol);
imageView[3].Position2D = new Position2D(1100 * resol, 20 * resol);
imageView[3].PivotPoint = PivotPoint.TopLeft;
imageView[3].BackgroundColor = Color.Black;
window.Add(imageView[3]);
}
-
- static void _Main(string[] args)
- {
- var app = new Program();
- app.Run(args);
- }
}
}
--- /dev/null
+using System;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+
+namespace ImageViewUserShaderTest
+{
+ class Test : NUIApplication
+ {
+ public Test() : base("", WindowMode.Transparent)
+ {
+ }
+
+ protected override void OnCreate()
+ {
+ base.OnCreate();
+ Initialize();
+ }
+ static string TAG = "NUI";
+ static readonly string vertexShaderSource =
+ "attribute mediump vec2 aPosition;\n" +
+ "uniform mediump mat4 uMvpMatrix;\n" +
+ "uniform mediump vec3 uSize;\n" +
+ "varying mediump vec2 vTexCoord;\n" +
+ "\n" +
+ "void main()\n" +
+ "{\n" +
+ " mediump vec4 position = vec4( aPosition, 0.0, 1.0 );\n" +
+ " position.xyz *= uSize;\n" +
+ " gl_Position = uMvpMatrix * position;\n" +
+ " vTexCoord = aPosition + vec2( 0.5 );\n" +
+ "}\n";
+
+ static readonly string fragmentShaderSource =
+ "varying mediump vec2 vTexCoord;\n" +
+ "uniform lowp vec4 uColor;\n" +
+ "uniform sampler2D sTexture;\n" +
+ "\n" +
+ "void main()\n" +
+ "{\n" +
+ " lowp vec4 color = texture2D( sTexture, vTexCoord ) * uColor;\n" +
+ " gl_FragColor = vec4(vec3(1.0) - color.rgb, color.a);\n" +
+ "}\n";
+
+ Timer timer;
+ Window window;
+ ImageView imageView, imageView2;
+ private static string resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+ static string url_shader = resourcePath + "/images/image-2.jpg";
+ void Initialize()
+ {
+ window = Window.Instance;
+ window.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
+
+ Tizen.Log.Fatal(TAG, $"url_shader={url_shader}");
+ imageView = new ImageView(url_shader);
+ imageView.PositionUsesPivotPoint = true;
+ imageView.PivotPoint = PivotPoint.Center;
+ imageView.ParentOrigin = ParentOrigin.Center;
+ imageView.Size2D = new Size2D(500, 500);
+ Tizen.Log.Fatal(TAG, $"#1 imageView.LoadingStatus={imageView.LoadingStatus}");
+ window.Add(imageView);
+
+ map = new PropertyMap();
+ customShader = new PropertyMap();
+ customShader.Add("vertexShader", new PropertyValue(vertexShaderSource));
+ customShader.Add("fragmentShader", new PropertyValue(fragmentShaderSource));
+ map.Add("shader", new PropertyValue(customShader));
+ imageView.Image = map;
+
+ Tizen.Log.Fatal(TAG, $"#2 imageView.LoadingStatus={imageView.LoadingStatus}");
+
+ timer = new Timer(1000);
+ timer.Tick += Timer_Tick;
+ timer.Start();
+
+ string url = " ";
+ imageView2 = new ImageView(url);
+ imageView2.PositionUsesPivotPoint = true;
+ imageView2.PivotPoint = PivotPoint.BottomCenter;
+ imageView2.ParentOrigin = ParentOrigin.BottomCenter;
+ imageView2.Size2D = new Size2D(300, 300);
+ Tizen.Log.Fatal(TAG, $"###1 imageView2.LoadingStatus={imageView2.LoadingStatus}");
+ window.Add(imageView2);
+ Tizen.Log.Fatal(TAG, $"###2 imageView2.LoadingStatus={imageView2.LoadingStatus}");
+ }
+
+ int cnt;
+ PropertyMap map;
+ PropertyMap customShader;
+ private bool Timer_Tick(object source, Timer.TickEventArgs e)
+ {
+ Tizen.Log.Fatal(TAG, $"#3 imageView.LoadingStatus={imageView?.LoadingStatus}");
+ Tizen.Log.Fatal(TAG, $"###3 imageView2.LoadingStatus={imageView2?.LoadingStatus}");
+ Tizen.Log.Fatal(TAG, $"Timer_Tick() comes!");
+
+ if (cnt++ % 2 == 0)
+ {
+ map.Clear();
+ customShader.Clear();
+ map.Add("shader", new PropertyValue(customShader));
+ imageView.Image = map;
+ }
+ else
+ {
+ map.Clear();
+ customShader.Clear();
+ customShader.Add("vertexShader", new PropertyValue(vertexShaderSource));
+ customShader.Add("fragmentShader", new PropertyValue(fragmentShaderSource));
+ map.Add("shader", new PropertyValue(customShader));
+ imageView.Image = map;
+ }
+
+ Tizen.Log.Fatal(TAG, $"#4 imageView.LoadingStatus={imageView.LoadingStatus}");
+
+ if (cnt % 3 == 0)
+ {
+ window.SetTransparency(false);
+ Random rand = new Random();
+ float value = rand.Next(0, 255) / 255.0f;
+ window.BackgroundColor = new Color(value, value, 1 - value, 1.0f);
+ }
+ else
+ {
+ window.SetTransparency(true);
+ window.BackgroundColor = new Color(0, 0, 0, 0);
+ }
+
+ string url1 = resourcePath + "/images/image-" + (cnt % 3 + 1) + ".jpg";
+ Tizen.Log.Fatal(TAG, $"url1={url1}");
+ imageView2?.Dispose();
+ imageView2 = null;
+ imageView2 = new ImageView(url1);
+ imageView2.PositionUsesPivotPoint = true;
+ imageView2.PivotPoint = PivotPoint.BottomCenter;
+ imageView2.ParentOrigin = ParentOrigin.BottomCenter;
+ imageView2.Size2D = new Size2D(300, 300);
+ Tizen.Log.Fatal(TAG, $"###4 imageView2.LoadingStatus={imageView2.LoadingStatus}");
+ window.Add(imageView2);
+
+ Tizen.Log.Fatal(TAG, $"#5 imageView.LoadingStatus={imageView.LoadingStatus}");
+ Tizen.Log.Fatal(TAG, $"###5 imageView2.LoadingStatus={imageView2.LoadingStatus}");
+ return true;
+ }
+ }
+}
--- /dev/null
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+
+namespace ImageViewUserShaderTest2
+{
+ internal class Test : NUIApplication
+ {
+ private string vertexShader =
+ "attribute mediump vec2 aPosition;\n" +
+ "uniform mediump mat4 uMvpMatrix;\n" +
+ "uniform mediump vec3 uSize;\n" +
+ "varying mediump vec2 vTexCoord;\n" +
+ "\n" +
+ "void main()\n" +
+ "{\n" +
+ " mediump vec4 position = vec4( aPosition, 0.0, 1.0 );\n" +
+ " position.xyz *= uSize;\n" +
+ " gl_Position = uMvpMatrix * position;\n" +
+ " vTexCoord = aPosition + vec2( 0.5 );\n" +
+ "}\n";
+
+ private readonly string fragmentShader =
+
+ "varying mediump vec2 vTexCoord;\n" +
+ "uniform lowp vec4 uColor;\n" +
+ "uniform sampler2D sTexture;\n" +
+ "uniform mediump vec4 userColor;\n" +
+ "\n" +
+ "void main()\n" +
+ "{\n" +
+ " mediump vec4 blend_color = userColor;\n" +
+ " mediump vec4 fColor = vec4(1.0, 1.0, 1.0, texture2D( sTexture, vTexCoord ).a);\n" +
+ " gl_FragColor = blend_color * fColor * uColor;\n" +
+ "}\n";
+
+
+ private View myView;
+ private ImageView myImageView;
+ private int count = 0;
+ private bool changeImgResource = true;
+
+ protected override void OnCreate()
+ {
+ base.OnCreate();
+
+ Window.Instance.BackgroundColor = Color.White;
+
+ //Create a View instance and add it to the stage
+ myView = new View();
+ myView.Focusable = true;
+ myView.KeyEvent += MyView_KeyEvent;
+
+ Window.Instance.GetDefaultLayer().Add(myView);
+
+ myImageView = new ImageView();
+ myImageView.Size2D = new Size2D(96, 96);
+ myImageView.Position2D = new Position2D(400, 400);
+
+ ChangePropertyMap(Color.Red, @"/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/mask.png");
+
+ Window.Instance.GetDefaultLayer().Add(myImageView);
+
+ FocusManager.Instance.SetCurrentFocusView(myView);
+ }
+
+ private bool MyView_KeyEvent(object source, View.KeyEventArgs e)
+ {
+ if (e.Key.State == Key.StateType.Down)
+ {
+ if (e.Key.KeyPressedName == "Right")
+ {
+ switch (count++ % 2)
+ {
+ case 0:
+ if (changeImgResource)
+ {
+ //myImageView.SetImage(@"/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/mask.png");
+ }
+ ChangePropertyMap(Color.Blue, @"/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/mask.png");
+ break;
+ case 1:
+ if (changeImgResource)
+ {
+ //myImageView.SetImage(@"/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/star-dim.png");
+ }
+ ChangePropertyMap(Color.Yellow, @"/home/owner/apps_rw/org.tizen.example.NUITestSample/res/images/star-dim.png");
+ break;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private void ChangePropertyMap(Color color, string url)
+ {
+ PropertyMap shaderMap = new PropertyMap();
+ shaderMap.Add("vertexShader", new PropertyValue(vertexShader));
+ shaderMap.Add("fragmentShader", new PropertyValue(fragmentShader));
+
+ PropertyMap imageMap = new PropertyMap();
+ imageMap.Add("url", new PropertyValue(url));
+ imageMap.Add("shader", new PropertyValue(shaderMap));
+ myImageView.Image = imageMap;
+
+ myImageView.RegisterProperty("userColor", new PropertyValue(color));
+ }
+
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+
+namespace ScreenPositionTest
+{
+ class Test : NUIApplication
+ {
+ protected override void OnCreate()
+ {
+ base.OnCreate();
+ StartTest();
+ }
+ const string TAG = "NUI";
+ public class MyView
+ {
+ public TextLabel textLabelName;
+ public TextLabel textLabelPosition;
+ public TextLabel textLabelScreenPosition;
+ public View myView;
+ public MyView(string name, Size2D mySize, View parent, int textSize)
+ {
+ myView = new View();
+ myView.Name = name;
+
+ textLabelName = new TextLabel($"{name} size=({mySize.Width},{mySize.Height}) parent name={parent?.Name} ");
+ textLabelName.PositionUsesPivotPoint = true;
+ textLabelName.ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft;
+ textLabelName.PivotPoint = Tizen.NUI.PivotPoint.TopLeft;
+ textLabelName.PixelSize = textSize;
+ myView.Add(textLabelName);
+
+ textLabelPosition = new TextLabel("Not Set");
+ textLabelPosition.PositionUsesPivotPoint = true;
+ textLabelPosition.ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft;
+ textLabelPosition.PivotPoint = Tizen.NUI.PivotPoint.CenterLeft;
+ textLabelPosition.PixelSize = textSize;
+ myView.Add(textLabelPosition);
+
+ textLabelScreenPosition = new TextLabel("Not Available");
+ textLabelScreenPosition.PositionUsesPivotPoint = true;
+ textLabelScreenPosition.ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft;
+ textLabelScreenPosition.PivotPoint = Tizen.NUI.PivotPoint.BottomLeft;
+ textLabelScreenPosition.PixelSize = textSize;
+ myView.Add(textLabelScreenPosition);
+
+ myView.Size2D = mySize;
+ Random rand = new Random();
+ float col = rand.Next(1, 255) / 255.0f;
+ myView.BackgroundColor = new Color(col, 1 - col, col, 1.0f);
+
+ if (parent == null)
+ {
+ Window.Instance.Add(myView);
+ }
+ else
+ {
+ parent.Add(myView);
+ }
+
+ myView.Focusable = true;
+ Tizen.Log.Fatal(TAG, $"myView constructor! name={name}");
+ }
+ Position2D myPos;
+ public Position2D MyPosition
+ {
+ set
+ {
+ myPos = value;
+ myView.Position2D = myPos;
+ }
+ get
+ {
+ return myPos;
+ }
+ }
+ int updatedCnt = 0;
+ public void UpdateMe()
+ {
+ textLabelPosition.Text = $"position=({(int)myView.Position2D.X},{(int)myView.Position2D.Y}) updated count={updatedCnt++} ";
+ textLabelScreenPosition.Text = $"screen position=({(int)myView.ScreenPosition.X},{(int)myView.ScreenPosition.Y}) ";
+ //Tizen.Log.Fatal(TAG, $"### now UpdateMe()!");
+ }
+ }
+
+ MyView myView1, myView2, myView3;
+ TextLabel parent;
+ Animation ani;
+ Timer timer;
+ void ScreenPositionTest()
+ {
+ parent = new TextLabel("This is parent view: Position(100,100) ParentOrigin & PivotPoint are all TopLeft, Push OK button! then Grid coordinate will be updated!");
+ parent.PixelSize = 17;
+ parent.Size2D = new Size2D(1000, 50);
+ parent.Position2D = new Position2D(100, 100);
+ parent.Name = "parent view";
+ parent.BackgroundColor = Color.Yellow;
+ Window.Instance.Add(parent);
+
+ myView1 = new MyView("my view1", new Size2D(500, 100), parent, 20);
+ myView1.MyPosition = new Position2D(100, 100);
+
+ myView2 = new MyView("my view2", new Size2D(500, 100), myView1.myView, 20);
+ myView2.MyPosition = new Position2D(100, 100);
+
+ myView3 = new MyView("my view3", new Size2D(500, 100), myView2.myView, 20);
+ myView3.MyPosition = new Position2D(100, 100);
+
+ timer = new Timer(300);
+ timer.Tick += Timer_Tick;
+ timer.Start();
+
+ ani = new Animation();
+ ani.AnimateTo(myView1.myView, "Position", new Position(1000, 100, 0), 1000, 50000);
+ ani.AnimateTo(myView2.myView, "Position", new Position(100, 1000, 0), 1000, 50000);
+ ani.AnimateTo(myView3.myView, "Position", new Position(-800, 100, 0), 1000, 50000);
+ ani.EndAction = Animation.EndActions.Discard;
+ ani.Looping = true;
+ ani.Play();
+ }
+ private bool Timer_Tick(object source, Timer.TickEventArgs e)
+ {
+ myView1.UpdateMe();
+ myView2.UpdateMe();
+ myView3.UpdateMe();
+ return true;
+ }
+
+ public class MyGrid
+ {
+ public TextLabel textLabel;
+ public View myGrid;
+ public MyGrid(Position2D myPosition, Size2D mySize, View parent, int textSize)
+ {
+ myGrid = new View();
+ myGrid.Position2D = myPosition;
+ myGrid.Size2D = mySize;
+ Random rand = new Random();
+ float col = rand.Next(1, 255) / 255.0f;
+ myGrid.BackgroundColor = new Color(col, 1 - col, col, 1.0f);
+
+ textLabel = new TextLabel($"({myGrid.ScreenPosition?.X},{myGrid.ScreenPosition?.Y})");
+ textLabel.PixelSize = textSize;
+ textLabel.Position2D = new Position2D(10, 10);
+ textLabel.Size2D = new Size2D(100, 100);
+ myGrid.Add(textLabel);
+
+ if (parent == null)
+ {
+ Window.Instance.Add(myGrid);
+ }
+ else
+ {
+ parent.Add(myGrid);
+ }
+ }
+ public void UpdateMe()
+ {
+ textLabel.Text = $"({ myGrid.ScreenPosition.X},{ myGrid.ScreenPosition.Y})";
+ }
+ }
+
+ MyGrid[] gridVertical = new MyGrid[20];
+ MyGrid[] gridHorizontal = new MyGrid[11];
+ void DrawGrid()
+ {
+ gridVertical[0] = new MyGrid(new Position2D(0, 0), new Size2D(2, 1100), null, 10);
+ for (int i = 1; i < 20; i++)
+ {
+ gridVertical[i] = new MyGrid(new Position2D(100, 0), new Size2D(2, 1100), gridVertical[i - 1].myGrid, 10);
+ }
+
+ gridHorizontal[0] = new MyGrid(new Position2D(0, 0), new Size2D(2000, 2), null, 10);
+ for (int i = 1; i < 11; i++)
+ {
+ gridHorizontal[i] = new MyGrid(new Position2D(0, 100), new Size2D(2000, 2), gridHorizontal[i - 1].myGrid, 10);
+ }
+ }
+
+ TextLabel title;
+ public void StartTest()
+ {
+ Window window = Window.Instance;
+ window.BackgroundColor = Color.White;
+ window.KeyEvent += OnWindowKeyEvent;
+
+ title = new TextLabel("ScreenPosition Test");
+ title.Position2D = new Position2D(10, 10);
+ title.PixelSize = 40.0f;
+ window.Add(title);
+
+ DrawGrid();
+ ScreenPositionTest();
+ }
+
+ public void OnWindowKeyEvent(object sender, Window.KeyEventArgs e)
+ {
+ Tizen.Log.Fatal("NUI", "e.Key.KeyPressedName=" + e.Key.KeyPressedName);
+
+ if (e.Key.State == Key.StateType.Down)
+ {
+ if (e.Key.KeyPressedName == "Up")
+ {
+ }
+ else if (e.Key.KeyPressedName == "Down")
+ {
+ }
+ else if (e.Key.KeyPressedName == "Return")
+ {
+ for (int i = 0; i < 20; i++)
+ {
+ gridVertical[i].UpdateMe();
+ }
+ for (int i = 0; i < 11; i++)
+ {
+ gridHorizontal[i].UpdateMe();
+ }
+ }
+ else if (e.Key.KeyPressedName == "XF86Exit" || e.Key.KeyPressedName == "XF86Back")
+ {
+ Exit();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+using Tizen.NUI;
+using Tizen.NUI.UIComponents;
+using Tizen.NUI.BaseComponents;
+
+namespace VisaulAnimationExample
+{
+ class Example : NUIApplication
+ {
+ public Example() : base("", WindowMode.Opaque)
+ {
+ }
+ protected override void OnCreate()
+ {
+ base.OnCreate();
+ CreateLayout();
+ ScreenPositionTest();
+ }
+
+ const string TAG = "NUI";
+
+ #region screen position test
+ Timer timer;
+ void ScreenPositionTest()
+ {
+ timer = new Timer(1000);
+ timer.Tick += Timer_Tick;
+ timer.Start();
+ }
+ private bool Timer_Tick(object source, Timer.TickEventArgs e)
+ {
+ Tizen.Log.Fatal(TAG, $"button1 position=({button1?.Position2D.X},{button1?.Position2D.Y}), screen position=({button1?.ScreenPosition.X},{button1?.ScreenPosition.Y})");
+ Tizen.Log.Fatal(TAG, $"button2 position=({button2?.Position2D.X},{button2?.Position2D.Y}), screen position=({button2?.ScreenPosition.X},{button2?.ScreenPosition.Y})");
+ Tizen.Log.Fatal(TAG, $"contentView position=({contentView?.Position2D.X},{contentView?.Position2D.Y}), screen position=({contentView?.ScreenPosition.X},{contentView?.ScreenPosition.Y})");
+ return true;
+ }
+ #endregion
+
+ #region visual view animation test
+ VisualView contentView;
+ TextLabel title;
+ PushButton button1, button2, button3;
+ bool active = false;
+ static readonly string _resPath = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+
+ Animation animation1;
+ bool transitionInProgress = false;
+ int cnt1, cnt2;
+
+ SVGVisual svgVisual;
+ AnimatedImageVisual gifVisual;
+ ImageVisual icon;
+
+ Window window;
+ TableView titleLayout, contentLayout;
+ VisualView visualView1, visualView2;
+ void CreateLayout()
+ {
+ window = Window.Instance;
+ window.SetTransparency(true);
+ window.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.7f);
+
+ titleLayout = new TableView(2, 1);
+ titleLayout.Name = ("TitleLayout");
+ titleLayout.PositionUsesPivotPoint = true;
+ titleLayout.ParentOrigin = ParentOrigin.Center;
+ titleLayout.PivotPoint = PivotPoint.Center;
+ var layoutSizeWidth = window.Size.Width * 0.7f;
+ var layoutSizeHeight = window.Size.Height * 0.7f;
+ titleLayout.Size2D = new Size2D((int)(layoutSizeWidth), (int)(layoutSizeHeight));
+ titleLayout.SetCellPadding(new Size2D(10, 10));
+ titleLayout.BackgroundColor = Color.Cyan;
+ window.Add(titleLayout);
+
+ title = new TextLabel("Visual Transition / SVG / AGIF Example");
+ title.Name = ("Title");
+ title.SetStyleName("Title");
+ title.WidthResizePolicy = ResizePolicyType.FillToParent;
+ title.HeightResizePolicy = ResizePolicyType.UseNaturalSize;
+ title.HorizontalAlignment = HorizontalAlignment.Center;
+ titleLayout.AddChild(title, new TableView.CellPosition(0, 0));
+ titleLayout.SetFitHeight(0);
+
+ contentLayout = new TableView(3, 2);
+ contentLayout.Name = ("ContentLayout");
+ contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent;
+ contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent;
+ contentLayout.PivotPoint = PivotPoint.TopLeft;
+ contentLayout.SetCellPadding(new Size2D(10, 10));
+ contentLayout.BackgroundColor = Color.Magenta;
+ titleLayout.AddChild(contentLayout, new TableView.CellPosition(1, 0));
+
+ //////////////////////////////////////////////////////////////////////
+ // Create a content view
+ contentView = new VisualView();
+ contentView.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent;
+ contentView.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent;
+ //contentView.Size2D = new Size2D(250, 250);
+ contentView.BackgroundImage = _resPath + "/images/background-blocks.jpg";
+
+ icon = new ImageVisual();
+ icon.URL = _resPath + "/images/application-icon-0.png";
+ icon.DepthIndex = 1;
+ icon.Size = new Size2D(50, 50);
+ icon.SizePolicy = VisualTransformPolicyType.Absolute;
+ icon.Position = new Position2D(5, 5);
+ icon.PositionPolicy = VisualTransformPolicyType.Absolute;
+ icon.Origin = Visual.AlignType.TopBegin;
+ icon.AnchorPoint = Visual.AlignType.TopBegin;
+ icon.MixColor = new Color(0, 1, 0, 0.5f);
+ icon.Opacity = 0.5f;
+ contentView.AddVisual("icon_visual1", icon);
+
+ contentLayout.AddChild(contentView, new TableView.CellPosition(0, 0));
+
+ button1 = new PushButton();
+ button1.LabelText = "Toggle Transition";
+ button1.Name = ("ToggleTransition");
+ button1.ParentOrigin = ParentOrigin.Center;
+ button1.PivotPoint = PivotPoint.Center;
+ button1.Clicked += (obj, ev) =>
+ {
+ active = !active;
+ StartTransition(active);
+ return true;
+ };
+ button1.WidthResizePolicy = ResizePolicyType.FillToParent;
+ button1.HeightResizePolicy = ResizePolicyType.FillToParent;
+ button1.Focusable = true;
+ button1.UpFocusableView = button3;
+ button1.DownFocusableView = button2;
+ contentLayout.AddChild(button1, new TableView.CellPosition(0, 1));
+
+ //////////////////////////////////////////////////////////////////////
+ // make NPatch visual test
+ NPatchVisual npatch1 = new NPatchVisual();
+ npatch1.URL = _resPath + "/images/gallery-2.jpg";
+ npatch1.Size = new Size2D(400, 400);
+ npatch1.SizePolicy = VisualTransformPolicyType.Absolute;
+ npatch1.Position = new Position2D(400, 0);
+ npatch1.PositionPolicy = VisualTransformPolicyType.Absolute;
+ npatch1.Origin = Visual.AlignType.TopBegin;
+ npatch1.AnchorPoint = Visual.AlignType.TopBegin;
+ npatch1.Border = new Rectangle(100, 100, 100, 100);
+ npatch1.DepthIndex = 2;
+ npatch1.MixColor = new Color(1, 0, 0, 1);
+ npatch1.Opacity = 0.5f;
+ contentView.AddVisual("npatchImageVisual1", npatch1);
+
+ //////////////////////////////////////////////////////////////////////
+ // make SVG visual test
+ visualView1 = new VisualView();
+ visualView1.WidthResizePolicy = ResizePolicyType.FillToParent;
+ visualView1.HeightResizePolicy = ResizePolicyType.FillToParent;
+ visualView1.BackgroundColor = Color.Black;
+ contentLayout.AddChild(visualView1, new TableView.CellPosition(1, 0));
+
+ svgVisual = new SVGVisual();
+ svgVisual.URL = _resPath + "/images/Kid1.svg";
+ svgVisual.Size = new Size2D(300, 300);
+ svgVisual.SizePolicy = VisualTransformPolicyType.Absolute;
+ svgVisual.Position = new Position2D(0, 0);
+ svgVisual.PositionPolicy = VisualTransformPolicyType.Absolute;
+ svgVisual.Origin = Visual.AlignType.TopBegin;
+ svgVisual.AnchorPoint = Visual.AlignType.TopBegin;
+ visualView1.AddVisual("svg_visual1", svgVisual);
+
+ button2 = new PushButton();
+ button2.LabelText = "SVG Visual Test";
+ button2.Name = ("svg_visual_test");
+ button2.PivotPoint = PivotPoint.Center;
+ button2.WidthResizePolicy = ResizePolicyType.FillToParent;
+ button2.HeightResizePolicy = ResizePolicyType.FillToParent;
+ button2.Clicked += (obj, ev) =>
+ {
+ cnt1++;
+ if (cnt1 % 2 == 0)
+ {
+ svgVisual.URL = _resPath + "/images/World.svg";
+ }
+ else
+ {
+ svgVisual.URL = _resPath + "/images/Mail.svg";
+ }
+ Tizen.Log.Fatal(TAG, "svg button clicked!");
+ return true;
+ };
+ button2.Focusable = true;
+ button2.UpFocusableView = button1;
+ button2.DownFocusableView = button2;
+ contentLayout.AddChild(button2, new TableView.CellPosition(1, 1));
+
+ //////////////////////////////////////////////////////////////////////
+ // make AnimatedImage visual test
+ visualView2 = new VisualView();
+ visualView2.WidthResizePolicy = ResizePolicyType.FillToParent;
+ visualView2.HeightResizePolicy = ResizePolicyType.FillToParent;
+ visualView2.BackgroundColor = Color.Blue;
+ contentLayout.AddChild(visualView2, new TableView.CellPosition(2, 0));
+
+ gifVisual = new AnimatedImageVisual();
+ gifVisual.URL = _resPath + "/images/dog-anim.gif";
+ gifVisual.Size = new Size2D(200, 200);
+ gifVisual.SizePolicy = VisualTransformPolicyType.Absolute;
+ gifVisual.Position = new Position2D(0, 0);
+ gifVisual.PositionPolicy = VisualTransformPolicyType.Absolute;
+ gifVisual.Origin = Visual.AlignType.TopBegin;
+ gifVisual.AnchorPoint = Visual.AlignType.TopBegin;
+ visualView2.AddVisual("gif_visual", gifVisual);
+
+ button3 = new PushButton();
+ button3.LabelText = "AnimatedImage Visual Test";
+ button3.Name = ("gif_visual_test");
+ button3.PivotPoint = PivotPoint.Center;
+ button3.WidthResizePolicy = ResizePolicyType.FillToParent;
+ button3.HeightResizePolicy = ResizePolicyType.FillToParent;
+ button3.Clicked += (obj, ev) =>
+ {
+ Tizen.Log.Fatal(TAG, "gif button clicked!");
+ cnt2++;
+ int gifNum = cnt2 % 15;
+ gifVisual.URL = _resPath + "/images/anim-gif/" + gifNum + ".gif";
+ button3.LabelText = "file:" + gifNum + ".gif";
+ return true;
+ };
+ button3.Focusable = true;
+ button3.DownFocusableView = button1;
+ button3.UpFocusableView = button2;
+ contentLayout.AddChild(button3, new TableView.CellPosition(2, 1));
+
+ FocusManager.Instance.SetCurrentFocusView(button1);
+ }
+
+ private void StartTransition(bool activate)
+ {
+ if (animation1)
+ {
+ animation1.Stop();
+ animation1.Finished += OnTransitionFinished1;
+ }
+
+ if (activate)
+ {
+ contentView.AnimateVisualAdd(icon, "Size", new Size2D(150, 150), 0, 1000, AlphaFunction.BuiltinFunctions.Linear);
+ contentView.AnimateVisualAdd(icon, "Position", new Position2D(40, 40), 0, 1000);
+ animation1 = contentView.AnimateVisualAddFinish();
+ }
+ else
+ {
+ contentView.AnimateVisualAdd(icon, "Size", new Position2D(50, 50), 0, 1000, AlphaFunction.BuiltinFunctions.Linear);
+ contentView.AnimateVisualAdd(icon, "Position", new Position2D(5, 5), 0, 1000);
+ animation1 = contentView.AnimateVisualAddFinish();
+ }
+
+ if (animation1)
+ {
+ animation1.Finished += OnTransitionFinished1;
+ transitionInProgress = true;
+ animation1.Play();
+ }
+ }
+ private void OnTransitionFinished1(object sender, EventArgs e)
+ {
+ transitionInProgress = false;
+ if (animation1)
+ {
+ animation1.Finished += OnTransitionFinished1;
+ animation1.Reset();
+ }
+ }
+ #endregion
+
+ }
+}
return;
}
-
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
-
[STAThread]
static void _Main(string[] args)
{
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.Runtime.InteropServices;
-using Tizen.NUI;
-using Tizen.NUI.UIComponents;
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Constants;
-
-namespace VisaulAnimationExample
-{
- class Example : NUIApplication
- {
- private VisualView _contentView;
- private TextLabel _title;
- private PushButton _shadowButton;
- private bool _active = false;
- private const string _resPath = "/home/owner/apps_rw/NUISamples.TizenTV/res"; //for tizen
- //private const string _resPath = "./res"; //for ubuntu
-
- private Animation _animation1;
- private bool _transitionInProgress = false;
- private int cnt1, cnt2;
-
- private SVGVisual svgVisual;
- private AnimatedImageVisual gifVisual;
- private ImageVisual _icon;
-
- protected override void OnCreate()
- {
- base.OnCreate();
- Initialize();
- }
-
- public void Initialize()
- {
- Window window = Window.Instance;
- window.BackgroundColor = Color.White;
-
- TableView titleLayout = new TableView(2, 1);
- titleLayout.Name = ("TitleLayout");
- titleLayout.PivotPoint = PivotPoint.TopLeft;
- titleLayout.Position2D = new Position2D(10, 10);
- titleLayout.Size2D = new Size2D((int)(window.Size.Width * 0.9f), (int)(window.Size.Height * 0.9f));
- titleLayout.SetCellPadding(new Size2D(10, 10));
- titleLayout.BackgroundColor = Color.Cyan;
- window.Add(titleLayout);
-
- _title = new TextLabel("Visual Transition / SVG / AGIF Example");
- _title.Name = ("Title");
- _title.SetStyleName("Title");
- _title.WidthResizePolicy = ResizePolicyType.FillToParent;
- _title.HeightResizePolicy = ResizePolicyType.UseNaturalSize;
- _title.HorizontalAlignment = HorizontalAlignment.Center;
- titleLayout.AddChild(_title, new TableView.CellPosition(0, 0));
- titleLayout.SetFitHeight(0);
-
- TableView contentLayout = new TableView(3, 2);
- contentLayout.Name = ("ContentLayout");
- contentLayout.WidthResizePolicy = ResizePolicyType.FillToParent;
- contentLayout.HeightResizePolicy = ResizePolicyType.FillToParent;
- contentLayout.PivotPoint = PivotPoint.TopLeft;
- contentLayout.SetCellPadding(new Size2D(10, 10));
- contentLayout.BackgroundColor = Color.Magenta;
- titleLayout.AddChild(contentLayout, new TableView.CellPosition(1, 0));
-
- //////////////////////////////////////////////////////////////////////
- // Create a conttent view
- _contentView = new VisualView();
- _contentView.WidthResizePolicy = ResizePolicyType.SizeRelativeToParent;
- _contentView.HeightResizePolicy = ResizePolicyType.SizeRelativeToParent;
- //_contentView.Size2D = new Size2D(250, 250);
- _contentView.BackgroundImage = _resPath + "/images/background-blocks.jpg";
-
- _icon = new ImageVisual();
- _icon.URL = _resPath + "/images/application-icon-0.png";
- _icon.DepthIndex = 1;
- _icon.Size = new Size2D(50, 50);
- _icon.SizePolicy = VisualTransformPolicyType.Absolute;
- _icon.Position = new Position2D(5, 5);
- _icon.PositionPolicy = VisualTransformPolicyType.Absolute;
- _icon.Origin = Visual.AlignType.TopBegin;
- _icon.AnchorPoint = Visual.AlignType.TopBegin;
- _icon.MixColor = new Color(0, 1, 0, 0.5f);
- _icon.Opacity = 0.5f;
- _contentView.AddVisual("icon_visual1", _icon);
-
- contentLayout.AddChild(_contentView, new TableView.CellPosition(0, 0));
-
- _shadowButton = new PushButton();
- _shadowButton.LabelText = "Toggle Transition";
- _shadowButton.Name = ("ToggleTransition");
- _shadowButton.ParentOrigin = ParentOrigin.Center;
- _shadowButton.PivotPoint = PivotPoint.Center;
- _shadowButton.Clicked += (obj, ev) =>
- {
- _active = !_active;
- StartTransition(_active);
- return true;
- };
- _shadowButton.WidthResizePolicy = ResizePolicyType.FillToParent;
- _shadowButton.HeightResizePolicy = ResizePolicyType.FillToParent;
- contentLayout.AddChild(_shadowButton, new TableView.CellPosition(0, 1));
-
- //////////////////////////////////////////////////////////////////////
- // make NPatch visual test
- NPatchVisual npatch1 = new NPatchVisual();
- npatch1.URL = _resPath + "/images/gallery-2.jpg";
- npatch1.Size = new Size2D(400, 400);
- npatch1.SizePolicy = VisualTransformPolicyType.Absolute;
- npatch1.Position = new Position2D(400, 0);
- npatch1.PositionPolicy = VisualTransformPolicyType.Absolute;
- npatch1.Origin = Visual.AlignType.TopBegin;
- npatch1.AnchorPoint = Visual.AlignType.TopBegin;
- npatch1.Border = new Rectangle(100, 100, 100, 100);
- npatch1.DepthIndex = 2;
- npatch1.MixColor = new Color(1, 0, 0, 1);
- npatch1.Opacity = 0.5f;
- _contentView.AddVisual("npatchImageVisual1", npatch1);
-
- //////////////////////////////////////////////////////////////////////
- // make SVG visual test
- VisualView VisualView1 = new VisualView();
- VisualView1.WidthResizePolicy = ResizePolicyType.FillToParent;
- VisualView1.HeightResizePolicy = ResizePolicyType.FillToParent;
- VisualView1.BackgroundColor = Color.Black;
- contentLayout.AddChild(VisualView1, new TableView.CellPosition(1, 0));
-
- svgVisual = new SVGVisual();
- svgVisual.URL = _resPath + "/images/Kid1.svg";
- svgVisual.Size = new Size2D(300, 300);
- svgVisual.SizePolicy = VisualTransformPolicyType.Absolute;
- svgVisual.Position = new Position2D(0, 0);
- svgVisual.PositionPolicy = VisualTransformPolicyType.Absolute;
- svgVisual.Origin = Visual.AlignType.TopBegin;
- svgVisual.AnchorPoint = Visual.AlignType.TopBegin;
- VisualView1.AddVisual("svg_visual1", svgVisual);
-
- PushButton svgButton = new PushButton();
- svgButton.LabelText = "SVG Visual Test";
- svgButton.Name = ("svg_visual_test");
- svgButton.PivotPoint = PivotPoint.Center;
- svgButton.WidthResizePolicy = ResizePolicyType.FillToParent;
- svgButton.HeightResizePolicy = ResizePolicyType.FillToParent;
- svgButton.Clicked += (obj, ev) =>
- {
- cnt1++;
- if (cnt1 % 2 == 0)
- {
- svgVisual.URL = _resPath + "/images/World.svg";
- }
- else
- {
- svgVisual.URL = _resPath + "/images/Mail.svg";
- }
- Tizen.Log.Debug("NUI", "svg button clicked!");
- return true;
- };
- contentLayout.AddChild(svgButton, new TableView.CellPosition(1, 1));
-
- //////////////////////////////////////////////////////////////////////
- // make AnimatedImage visual test
- VisualView VisualView2 = new VisualView();
- VisualView2.WidthResizePolicy = ResizePolicyType.FillToParent;
- VisualView2.HeightResizePolicy = ResizePolicyType.FillToParent;
- VisualView2.BackgroundColor = Color.Blue;
- contentLayout.AddChild(VisualView2, new TableView.CellPosition(2, 0));
-
- gifVisual = new AnimatedImageVisual();
- gifVisual.URL = _resPath + "/images/dog-anim.gif";
- gifVisual.Size = new Size2D(200, 200);
- gifVisual.SizePolicy = VisualTransformPolicyType.Absolute;
- gifVisual.Position = new Position2D(0, 0);
- gifVisual.PositionPolicy = VisualTransformPolicyType.Absolute;
- gifVisual.Origin = Visual.AlignType.TopBegin;
- gifVisual.AnchorPoint = Visual.AlignType.TopBegin;
- VisualView2.AddVisual("gif_visual", gifVisual);
-
- PushButton gifButton = new PushButton();
- gifButton.LabelText = "AnimatedImage Visual Test";
- gifButton.Name = ("gif_visual_test");
- gifButton.PivotPoint = PivotPoint.Center;
- gifButton.WidthResizePolicy = ResizePolicyType.FillToParent;
- gifButton.HeightResizePolicy = ResizePolicyType.FillToParent;
- gifButton.Clicked += (obj, ev) =>
- {
- Tizen.Log.Debug("NUI", "gif button clicked!");
- cnt2++;
- int gifNum = cnt2 % 15;
- gifVisual.URL = _resPath + "/images/anim-gif/" + gifNum + ".gif";
- gifButton.LabelText = "file:" + gifNum + ".gif";
- return true;
- };
- contentLayout.AddChild(gifButton, new TableView.CellPosition(2, 1));
- }
-
- private void StartTransition(bool activate)
- {
- if (_animation1)
- {
- _animation1.Stop();
- _animation1.Finished += OnTransitionFinished1;
- }
-
- if (activate)
- {
- _contentView.AnimateVisualAdd(_icon, "Size", new Size2D(150, 150), 0, 1000, AlphaFunction.BuiltinFunctions.Linear);
- _contentView.AnimateVisualAdd(_icon, "Position", new Position2D(40, 40), 0, 1000);
- _animation1 = _contentView.AnimateVisualAddFinish();
- }
- else
- {
- _contentView.AnimateVisualAdd(_icon, "Size", new Position2D(50, 50), 0, 1000, AlphaFunction.BuiltinFunctions.Linear);
- _contentView.AnimateVisualAdd(_icon, "Position", new Position2D(5, 5), 0, 1000);
- _animation1 = _contentView.AnimateVisualAddFinish();
- }
-
- if (_animation1)
- {
- _animation1.Finished += OnTransitionFinished1;
- _transitionInProgress = true;
- _animation1.Play();
- }
- }
- private void OnTransitionFinished1(object sender, EventArgs e)
- {
- _transitionInProgress = false;
- if (_animation1)
- {
- _animation1.Finished += OnTransitionFinished1;
- _animation1.Reset();
- }
- }
-
-
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void _Main(string[] args)
- {
- Example example = new Example();
- example.Run(args);
- }
-
-
- }
-}