tizen 2.4 release
[framework/uifw/e17-mod-tizen-comp.git] / data / common / comp-script.edc
1 /* ----------------------------------------------------------------------------*/
2 /* embryo script for logger and rotation                                       */
3 /* ----------------------------------------------------------------------------*/
4 script {
5
6 #if USE_LOGGER
7    public logger_enable = 0;
8    public logno = 0;
9
10    public set_logging(on) {
11       set_int(logger_enable, on);
12    }
13
14    public log_msg(Msg_Type:type, ...) {
15       if (get_int(logger_enable) == 1) {
16          if (type == MSG_STRING) {
17             new msg[200];
18             getsarg(1, msg, 200);
19             strcat(msg, "<br>");
20
21             new logno_str[10];
22             new no = get_int(logno);
23             snprintf(logno_str, 10, "[%i] ", no);
24             strprep(msg, logno_str);
25
26             new str[1024];
27             get_text(PART:"logger", str, 1024);
28
29             strprep(str, msg);
30             set_text(PART:"logger", str);
31
32             set_int(logno, no+1);
33          }
34       }
35    }
36 #endif /* end of USE_LOGGER */
37
38    public prev_window_ang = 0;
39    public curr_window_ang = 0;
40
41    public set_curr_window_ang(ang) {
42       set_int(curr_window_ang, ang);
43    }
44
45    public window_rotation(do_effect) {
46       new prev_ang;
47       new curr_ang;
48       new diff_ang;
49       new x, y, w, h;
50       new rect_w, rect_h;
51
52       prev_ang = get_int(prev_window_ang);
53       curr_ang = get_int(curr_window_ang);
54
55       get_geometry(PART:"shower", x, y, w, h);
56
57 #if USE_LOGGER
58       new str[200];
59       snprintf(str, 200, "window_rotation() %i,%i %ix%i %i->%i", x, y, w, h, prev_ang, curr_ang);
60       log_msg(MSG_STRING, str);
61 #endif /* end of USE_LOGGER */
62
63       diff_ang = prev_ang - curr_ang;
64
65       if (diff_ang == 180 || diff_ang == -180) {
66          rect_w = w;
67          rect_h = h;
68       }
69       else if (diff_ang == 0) {
70          rect_w = w;
71          rect_h = h;
72       }
73       else {
74          rect_w = h;
75          rect_h = w;
76       }
77
78       custom_state(PART:"shower", "default", 0.0);
79       set_state_val(PART:"shower", STATE_MIN, rect_w, rect_h);
80       set_state_val(PART:"shower", STATE_MAX, rect_w, rect_h);
81       set_state_val(PART:"shower", STATE_MAP_ROT_Z, curr_ang*1.0);
82       set_state(PART:"shower", "custom", 0.0);
83
84       custom_state(PART:"e.swallow.content", "default", 0.0);
85       if (do_effect) {
86          set_state_val(PART:"e.swallow.content", STATE_MAP_ROT_Z, prev_ang*1.0);
87       }
88       else {
89          set_state_val(PART:"e.swallow.content", STATE_MAP_ROT_Z, curr_ang*1.0);
90       }
91       set_state(PART:"e.swallow.content", "custom", 0.0);
92
93       set_int(prev_window_ang, curr_ang);
94    }
95
96 } /* end of script */