コード例 #1
0
    public static void Main()
    {
        random = new Random();

        ClutterRun.Init();

        Stage stage = Stage.Default;

        stage.Fullscreen = true;

        stage.Color = new Clutter.Color(0x10, 0x10, 0x10, 0xff);
        flowers     = new Flower[N_FLOWERS];


        for (int i = 0; i < N_FLOWERS; i++)
        {
            flowers[i]    = new Flower();
            flowers[i].x  = (int)(rand() % stage.Width - (PETAL_MIN + PETAL_VAR) * 2);
            flowers[i].y  = (int)(rand() % stage.Height);
            flowers[i].rv = rand() % 5 + 1;
            flowers[i].v  = rand() % 10 + 2;

            stage.AddActor(flowers[i].ctex);
            flowers[i].ctex.SetPosition(flowers[i].x, flowers[i].y);
        }

        GLib.Timeout.Add(50, new GLib.TimeoutHandler(Tick));

        stage.ShowAll();
        stage.KeyPressEvent += HandleKeyPress;

        ClutterRun.Main();
    }
コード例 #2
0
        public static void Main()
        {
            ClutterRun.Init();

            Stage stage = Stage.Default;

            stage.SetSize(800, 600);
            stage.Color = stage_color;
            stage.Title = "ClutterEntry Test";

            entry = new Entry("Sans 14",
                              "Type something, be sure to use the " +
                              "left/right arrow keys to move the " +
                              "cursor position.");

            entry.Color = entry_color;
            entry.SetSize(600, 50);
            entry.SetPosition(100, 100);

            stage.KeyFocus = entry;
            stage.AddActor(entry);
            stage.ShowAll();

            ClutterRun.Main();
        }
コード例 #3
0
ファイル: test-scale.cs プロジェクト: Dynalon/clutter-sharp
    static void Main()
    {
        ClutterRun.Init();
        Stage stage = Stage.Default;

        stage.SetSize(200, 200);

        template = new EffectTemplate(new Timeline(90, 120), Sine.Func);

        rect = new Rectangle();
        Clutter.Color rect_bg_color = new Clutter.Color(0x33, 0x22, 0x22, 0xff);
        rect.Color       = rect_bg_color;
        rect.BorderWidth = 10;

        rect.Reactive = true;
        rect.SetSize(100, 100);
        rect.AnchorPointFromGravity = Gravity.Center;
        rect.SetPosition(100, 100);
        rect.ButtonPressEvent += delegate { ScaleRect(); };

        stage.AddActor(rect);
        stage.ShowAll();

        ClutterRun.Main();
    }
コード例 #4
0
ファイル: test-threads.cs プロジェクト: Dynalon/clutter-sharp
        static void Main()
        {
            if (!GLib.Thread.Supported)
            {
                GLib.Thread.Init();
            }

            Clutter.Threads.Init();
            Clutter.Threads.Enter();

            ClutterRun.Init();

            stage       = Stage.Default;
            stage.Color = stage_color;
            stage.SetSize(800, 600);

            count_label = new Label("Mono 16", "Counter");
            count_label.SetPosition(350, 50);
            count_label.Show();

            label = new Label("Mono 16", "Press 's' to start");
            label.SetPosition(50, 50);
            label.Show();

            rect = new Rectangle(rect_color);
            rect.SetPosition(150, 150);
            rect.SetSize(25, 25);
            rect.Show();

            timeline      = new Timeline(150, 50);
            timeline.Loop = true;

            alpha     = new Alpha(timeline, Sine.Func);
            behaviour = new BehaviourRotate(alpha,
                                            RotateAxis.ZAxis,
                                            RotateDirection.Cw,
                                            0.0,
                                            360.0);
            behaviour.Apply(rect);

            stage.AddActor(rect);
            stage.AddActor(count_label);
            stage.AddActor(label);

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

            stage.ShowAll();

            ClutterRun.Main();
            Clutter.Threads.Leave();
        }
コード例 #5
0
        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();
        }
コード例 #6
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();
    }
コード例 #7
0
ファイル: test-shaders.cs プロジェクト: Dynalon/clutter-sharp
    public static void Main()
    {
        ClutterRun.Init();

        Stage stage = Stage.Default;

        stage.SetSize(512, 384);

        Shader shader = new Shader();

        shader.FragmentSource = shader_sources[current_shader];
        shader.Compile();

        stage.Title = "Shader Test";
        stage.Color = new Clutter.Color(0x61, 0x64, 0x8c, 0xff);

        Timeline timeline = new Timeline(360, 60);

        timeline.Loop = true;

        stage.AddActor(new Label("Mono 16", "Press the Hand"));

        Texture actor = new Texture("redhand.png");

        actor.SetShader(shader);
        actor.Reactive          = true;
        actor.ButtonPressEvent += HandleActorButtonPress;
        stage.AddActor(actor);
        actor.SetShaderParam("brightness", 0.4f);
        actor.SetShaderParam("contrast", -1.9f);
        actor.SetPosition(0, 20);

        stage.ShowAll();
        timeline.Start();

        ClutterRun.Main();
    }
コード例 #8
0
    public static void Main()
    {
        app = new EventApp();

        ClutterRun.Init();
        Gtk.Application.Init();

        Gtk.Window window = new Gtk.Window(WindowType.Toplevel);
        window.Title        = "Gtk-Clutter Interaction Demo";
        window.Resizable    = true;
        window.BorderWidth  = 12;
        window.DeleteEvent += HandleDelete;
        app.window          = window;

        Gtk.VBox vbox = new Gtk.VBox(false, 12);
        window.Add(vbox);

        Gtk.Entry gtk_entry = new Gtk.Entry();
        app.gtk_entry      = gtk_entry;
        gtk_entry.Text     = "Enter some text";
        gtk_entry.Changed += delegate { app.clutter_entry.Text = app.gtk_entry.Text; };
        vbox.PackStart(gtk_entry, false, false, 0);

        Gtk.HBox hbox = new Gtk.HBox(false, 12);
        vbox.PackStart(hbox, true, true, 0);

        /* Clutter stage */
        Embed widget = new Embed();

        hbox.PackStart(widget, true, true, 0);
        app.stage       = widget.Stage as Stage;
        app.stage.Color = new Clutter.Color(125, 125, 125, 255);

        /* Main texture*/
        Texture texture = new Texture("redhand.png");

        app.hand = texture;
        app.stage.AddActor(texture);
        uint width, height;

        texture.GetSize(out width, out height);
        texture.SetPosition((int)((app.stage.Width / 2) - (width / 2)), (int)((app.stage.Height / 2) - (height / 2)));

        /* Clutter entry */
        app.clutter_entry = new Clutter.Entry("Sans 10", "", new Clutter.Color(255, 255, 255, 255));
        app.stage.AddActor(app.clutter_entry);
        app.clutter_entry.SetPosition(0, 0);
        app.clutter_entry.SetSize(500, 20);

        /* Adjustment widgets */
        vbox = new Gtk.VBox(false, 6);
        hbox.PackStart(vbox, false, false, 0);

        Gtk.VBox box = new Gtk.VBox(true, 6);
        vbox.PackStart(box, false, true, 0);

        Gtk.Label x_label = new Gtk.Label("Rotate x-axis");
        box.PackStart(x_label, true, true, 0);
        Gtk.SpinButton x_button = new Gtk.SpinButton(0, 360, 1);
        box.PackStart(x_button, true, true, 0);
        x_button.ValueChanged += delegate { app.hand.SetRotation(RotateAxis.XAxis,
                                                                 (float)app.x_button.Value,
                                                                 (int)app.hand.Height, 0, 0); };
        app.x_button = x_button;

        Gtk.Label y_label = new Gtk.Label("Rotate y-axis");
        box.PackStart(y_label, true, true, 0);
        Gtk.SpinButton y_button = new Gtk.SpinButton(0, 360, 1);
        box.PackStart(y_button, true, true, 0);
        y_button.ValueChanged += delegate { app.hand.SetRotation(RotateAxis.YAxis,
                                                                 (float)app.y_button.Value,
                                                                 0, (int)app.hand.Width / 2, 0); };
        app.y_button = y_button;

        Gtk.Label z_label = new Gtk.Label("Rotate z-axis");
        box.PackStart(z_label, true, true, 0);
        Gtk.SpinButton z_button = new Gtk.SpinButton(0, 360, 1);
        box.PackStart(z_button, true, true, 0);
        z_button.ValueChanged += delegate { app.hand.SetRotation(RotateAxis.ZAxis,
                                                                 (float)app.z_button.Value,
                                                                 (int)app.hand.Width / 2, (int)app.hand.Height / 2, 0); };
        app.z_button = z_button;

        Gtk.Label op_label = new Gtk.Label("Adjust opacity");
        box.PackStart(op_label, true, true, 0);
        Gtk.SpinButton op_button = new Gtk.SpinButton(0, 255, 1);
        op_button.Value = 255;
        box.PackStart(op_button, true, true, 0);
        op_button.ValueChanged += delegate { app.hand.Opacity = (byte)app.op_button.Value; };
        app.op_button           = op_button;

        app.stage.ShowAll();
        app.window.SetDefaultSize(800, 600);
        app.window.ShowAll();

        Gtk.Application.Run();
    }
コード例 #9
0
    public static void Main()
    {
        ClutterRun.Init();
        Gtk.Application.Init();

        Gtk.Window window = new Gtk.Window(WindowType.Toplevel);
        window.DeleteEvent += HandleDelete;
        Toplevel            = window;

        Gtk.VBox vbox = new Gtk.VBox(false, 6);
        window.Add(vbox);

        Embed clutter = new Embed();

        vbox.Add(clutter);

        Stage stage = clutter.Stage as Stage;

        Gtk.Label label = new Gtk.Label("This is a label");
        vbox.PackStart(label, false, false, 0);

        Gtk.Button button = Gtk.Button.NewWithLabel("This is a button...clicky");
        button.Clicked += HandleClickity;
        vbox.PackStart(button, false, false, 0);

        button          = new Gtk.Button(Gtk.Stock.Quit);
        button.Clicked += delegate { Gtk.Application.Quit(); };

        vbox.PackEnd(button, false, false, 0);

        stage.Color = new Clutter.Color(0x61, 0x64, 0x8c, 0xff);

        uint radius = stage.Width / n_hands / 2;

        SuperOH oh = new SuperOH();

        CurrentOH = oh;
        oh.Group  = new Group();
        oh.Hands  = new Actor[n_hands];

        for (int i = 0; i < n_hands; i++)
        {
            Texture hand_text = new Texture("redhand.png");
            uint    w         = hand_text.Width;
            uint    h         = hand_text.Height;

            oh.Hands[i] = hand_text;

            int x = (int)(stage.Width / 2
                          + radius
                          * Math.Cos(i * Math.PI / (n_hands / 2))
                          - w / 2);
            int y = (int)(stage.Height / 2
                          + radius
                          * Math.Sin(i * Math.PI / (n_hands / 2))
                          - h / 2);

            oh.Hands[i].SetPosition(x, y);

            oh.Group.AddActor(oh.Hands[i]);
        }

        oh.Group.ShowAll();

        oh.FadeTimeline      = new Timeline(2000);
        oh.FadeTimeline.Loop = true;
        BehaviourOpacity behaviour = new BehaviourOpacity(new Alpha(oh.FadeTimeline, Sine.Func), 0xff, 0x00);

        behaviour.Apply(oh.Group);

        stage.AddActor(oh.Group);
        stage.ButtonPressEvent += HandleButtonPress;
        stage.KeyPressEvent    += HandleKeyPress;

        stage.ShowAll();

        timeline      = new Timeline(360, 90);
        timeline.Loop = true;

        timeline.NewFrame += HandleNewFrame;

        window.ExposeEvent += delegate { timeline.Start(); };

        window.SetDefaultSize(400, 600);
        window.ShowAll();

        Gtk.Application.Run();
    }