summaryrefslogtreecommitdiff
path: root/src/tests/edje/data/test_messages.edc
blob: fe5195640bf7739a29dfca7c8ab73789d20c71e9 (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
collections {
   group { "test_group";
      parts {
         rect { "bg";
            desc { "default";
               color: 0 0 0 255;
            }
         }
         text { "text";
            desc { "default";
               text {
                  font: "Sans";
                  size: 24;
                  text: "HELLO";
               }
            }
         }
      }

// Messages IDs:
    //  0. string, text string
    //  1. int, text size
    //  2. int set, bg color (4 ints)
    //  3. float, sends signal

      script {
         public message(Msg_Type:type, id, ...) {
            if ((type == MSG_STRING) && (id == 0)) {
               new str[64], buf[64];

               getsarg(2, str, sizeof(str));
               set_text(PART:"text", str);

               snprintf(buf, sizeof(buf), "str %s", str);
               emit(buf, "edc");
            }
            else if ((type == MSG_INT) && (id == 1)) {
               new i, buf[64];

               i = getarg(2);
               set_state_val(PART:"text", STATE_TEXT_SIZE, i);

               snprintf(buf, sizeof(buf), "int %d", i);
               emit(buf, "edc");
            }
            else if ((type == MSG_FLOAT) && (id == 2)) {
               new f, buf[64];

               f = getarg(2);
               snprintf(buf, sizeof(buf), "float %f", f);
               emit(buf, "edc");
            }
            else if ((type == MSG_INT_SET) && (id == 3)) {
               new r, g, b, a, buf[64];

               r = getarg(2);
               g = getarg(3);
               b = getarg(4);
               a = getarg(5);
               set_state_val(PART:"bg", STATE_COLOR, r, g, b, a);

               snprintf(buf, sizeof(buf), "int set %d %d %d %d", r, g, b, a);
               emit(buf, "edc");
            }
         }
      }
   }
}