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 ();
}
}
}
|