summaryrefslogtreecommitdiff
path: root/unsorted/evas/evas_mono_image.cs
blob: ff84db5d9a6a753c097a83a36a1b64f71eaf7c2c (plain) (blame)
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
using System;
using System.Runtime.CompilerServices;

class TestMain
{
    static int WIDTH = 320;
    static int HEIGHT = 240;

    evas.Image image;


    static string ImagePath([CallerFilePath] string folder="")
    {
        return System.IO.Path.GetDirectoryName(folder);
    }

    public TestMain(evas.Image image)
    {
        this.image = image;
    }

    static void Main(string[] args)
    {
        efl.All.Init();

        efl.Loop loop = new efl.LoopConcrete();

        EcoreEvas ecore_evas = new EcoreEvas();
        eina.Size2D size = new eina.Size2D();
        
        efl.canvas.Object canvas = ecore_evas.canvas;
        canvas.SetVisible(true);

        efl.Object parent = canvas.GetParent();
        System.Diagnostics.Debug.Assert(parent.raw_handle != IntPtr.Zero);
        
        efl.canvas.Rectangle bg = new efl.canvas.RectangleConcrete(canvas);
        bg.SetColor(255, 255, 255, 255);
        size.W = WIDTH;
        size.H = HEIGHT;
        bg.SetSize(size);
        bg.SetVisible(true);

        string valid_path = args[0];
        evas.Image image = new evas.ImageConcrete(canvas);
        image.SetFile(valid_path, null);

        /* FIXME evas-image uses error handling code from
         * evas_object_image_load_error_get, which seems to be not available
         * efl.image.load.State state = image.load_error_get(); */

        // FIXME missing move
        eina.Rect rect = new eina.Rect();

        rect.X = 0;
        rect.Y = 0;
        rect.W = WIDTH / 2;
        rect.H = HEIGHT / 2;
        image.SetFill(rect);

        size.W = WIDTH / 2;
        size.H = HEIGHT / 2;
        image.SetSize(size);
        image.SetVisible(true);

        rect = image.GetFill();
        rect.Y -= 50;
        rect.W += 100;
        image.SetFill(rect);

        TestMain listener = new TestMain(image);

        // TODO handle key events in order to alter the image like the C
        // example. Meanwhile, just set some w fill
        /* EventListener callback = new EventListener(); */

        /* bg.key_focus_set(true); */
        /* bg.event_callback_priority_add(evas.Callback_Type.Key_down, */ 
        /*         efl.Callback_Priority.Default, */
        /*         callback, null); */

        loop.Begin();

        efl.All.Shutdown();
    }

    public void on_key_down(object sender, EventArgs e)
    {
        Console.WriteLine("on_key_down called");
    }
}