File: test-script.cs

package info (click to toggle)
clutter-sharp 1.0.0~alpha3~git20090817.r1.349dba6-8
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 4,104 kB
  • ctags: 2,193
  • sloc: xml: 23,456; cs: 9,946; sh: 3,393; perl: 1,213; makefile: 270; awk: 50; sed: 13
file content (99 lines) | stat: -rw-r--r-- 4,316 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;
using Clutter;

public class ShaderTest
{
	static string test_behaviour = "[" + 
		"{"									 + 
		"    \"id\" : \"main-timeline\","                                        + 
		"    \"type\" : \"ClutterTimeline\","                                    + 
		"    \"duration\" : 5000,"                                               + 
		"    \"loop\" : true"                                                    + 
		"  },"                                                                   + 
		"  {"                                                                    + 
		"    \"id\"          : \"path-behaviour\","                              + 
		"    \"type\"        : \"ClutterBehaviourPath\","                        + 
		"    \"knots\"       : [ [ 50, 50 ], { \"x\" : 100, \"y\" : 100 } ],"    + 
		"    \"alpha\"       : {"                                                + 
		"      \"timeline\" : \"main-timeline\","                                + 
		"      \"function\" : \"ramp\""                                          + 
		"    }"                                                                  + 
		"  },"                                                                   + 
		"  {"                                                                    + 
		"    \"id\"          : \"rotate-behaviour\","                            + 
		"    \"type\"        : \"ClutterBehaviourRotate\","                      + 
		"    \"angle-start\" : 0.0,"                                             + 
		"    \"angle-end\"   : 360.0,"                                           + 
		"    \"axis\"        : \"y-axis\","                                      + 
		"    \"alpha\"       : {"                                                + 
		"      \"timeline\" : \"main-timeline\","                                + 
		"      \"function\" : \"sine\""                                          + 
		"    }"                                                                  + 
		"  },"                                                                   + 
		"  {"                                                                    + 
		"    \"id\"            : \"fade-behaviour\","                            + 
		"    \"type\"          : \"ClutterBehaviourOpacity\","                   + 
		"    \"opacity-start\" : 255,"                                           + 
		"    \"opacity-end\"   : 0,"                                             + 
		"    \"alpha\"         : {"                                              + 
		"      \"timeline\" : \"main-timeline\","                                + 
		"      \"function\" : \"ramp-inc\""                                      + 
		"    }"                                                                  + 
		"  }"                                                                    + 
		"]";

	static string test_unmerge = 
	        "{"                                  +  
		"   \"id\" : \"blue-button\",       "+ 
		"   \"type\" : \"ClutterRectangle\","+ 
		"   \"color\" : \"#0000ffff\",      "+ 
		"   \"x\" : 350,                    "+ 
		"   \"y\" : 50,                     "+ 
		"   \"width\" : 100,                "+ 
		"   \"height\" : 100,               "+ 
		"   \"visible\" : true,             "+ 
		"   \"reactive\" : true             "+ 
		" }";

	static Script script;
	static uint merge_id = 0;

	public static void Main ()
	{
		ClutterRun.Init (); 

		script = new Script ();
		script.LoadFromData (test_behaviour);
		script.LoadFromFile ("test-script.json");
		merge_id = script.LoadFromData (test_unmerge);

		Stage stage = script.GetObject<Stage>("main-stage");
		Actor blue_button = script.GetObject<Actor>("blue-button");
		Actor red_button = script.GetObject<Actor>("red-button");

		blue_button.ButtonPressEvent += delegate
		{
	 		Console.WriteLine("Unmerging");
			script.UnmergeObjects(merge_id);
		};

		red_button.ButtonPressEvent += delegate
		{
		 	Console.WriteLine ("Changing timeline state");
			Timeline timeline = script.GetObject<Timeline> ("main-timeline");

			if (!timeline.IsPlaying)
			 	timeline.Start ();
			else
			 	timeline.Pause ();
		};

		stage.Unrealized += delegate  { Clutter.Main.Quit (); };
		stage.KeyPressEvent += delegate { Clutter.Main.Quit ();	};

		stage.ShowAll ();

		ClutterRun.Main ();
	} 
}