File: test-scroll-actor.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 (64 lines) | stat: -rw-r--r-- 1,298 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
using System;
using Clutter;

namespace ClutterTest
{
	public class ScrollActor : Clutter.Rectangle
	{
		private int scroll_offset;

		public ScrollActor (Clutter.Color color)
			: this (color, 20)
		{  }

		public ScrollActor (Clutter.Color color, int scroll_offset)
			: base (color)
		{
			this.scroll_offset = scroll_offset;
			Reactive = true; 
		}

		protected override bool OnScrollEvent (Clutter.ScrollEvent evnt) 
		{
		 	switch (evnt.Direction)
			{
				case ScrollDirection.Up:
					base.Depth += scroll_offset; 
					break;
				case ScrollDirection.Down:
					base.Depth -= scroll_offset;
					break;
				default:
					break;
			}
		 	
			return base.OnScrollEvent (evnt);
		}
	}

	public class Test
	{
		static Color stage_color = new Color (0x00, 0x00, 0x00, 0xff);
		static Color actor_color = new Color (0x33, 0xdd, 0xff, 0xff);
		static Rectangle actor;
 
	 	public static void Main ()
		{
		 	ClutterRun.Init ();

			Stage stage = Stage.Default;
			stage.SetSize (200, 200);
			stage.Color = stage_color;
			stage.Title = "Override Test";

			actor = new ScrollActor (actor_color, 20);
			actor.SetSize (100, 100);
			actor.AnchorPointFromGravity = Gravity.Center;
			actor.SetPosition (100, 100);
			stage.AddActor (actor);

			stage.ShowAll ();
			ClutterRun.Main ();
		}
	} 
}