aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz
diff options
context:
space:
mode:
Diffstat (limited to 'src/extantz')
-rwxr-xr-xsrc/extantz/build.lua4
-rw-r--r--src/extantz/winFang.c205
-rw-r--r--src/extantz/winFang.h39
3 files changed, 1 insertions, 247 deletions
diff --git a/src/extantz/build.lua b/src/extantz/build.lua
index 261c96f..d3c983a 100755
--- a/src/extantz/build.lua
+++ b/src/extantz/build.lua
@@ -18,12 +18,10 @@ LDFLAGS = LDFLAGS .. ' -L../../libraries/irrlicht-1.8.1/lib/Linux'
18libs = libs .. ' -lIrrlicht -lGL -lbz2' 18libs = libs .. ' -lIrrlicht -lGL -lbz2'
19 19
20removeFiles(dir, {'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'Evas_3D_demo.o', '../../media/extantz.edj'}) 20removeFiles(dir, {'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'Evas_3D_demo.o', '../../media/extantz.edj'})
21removeFiles(dir, {'../../extantz', 'camera.o', 'winFang.o', lib_d .. '/libwinFang.so', 'chat.o', 'files.o', 'woMan.o'}) 21removeFiles(dir, {'../../extantz', 'camera.o', 'chat.o', 'files.o', 'woMan.o'})
22 22
23runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' extantz.edc ../../media/extantz.edj') 23runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' extantz.edc ../../media/extantz.edj')
24runCommand('Irrlicht files', dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c crappisspuke.cpp -o crappisspuke.o ' .. LDFLAGS) 24runCommand('Irrlicht files', dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c crappisspuke.cpp -o crappisspuke.o ' .. LDFLAGS)
25runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c CDemo.cpp -o CDemo.o ' .. LDFLAGS) 25runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c CDemo.cpp -o CDemo.o ' .. LDFLAGS)
26runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c extantzCamera.cpp -o extantzCamera.o ' .. LDFLAGS) 26runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c extantzCamera.cpp -o extantzCamera.o ' .. LDFLAGS)
27runCommand('C libraries', dir, 'gcc ' .. CFLAGS .. ' -fPIC -c winFang.c')
28runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libwinFang.so -o ' .. lib_d .. '/libwinFang.so winFang.o')
29compileFiles('../../extantz', dir, {'gears', 'ephysics_demo', 'camera', 'Evas_3D_demo', 'chat', 'files', 'woMan', 'extantz'}, 'crappisspuke.o CDemo.o extantzCamera.o -lwinFang') 27compileFiles('../../extantz', dir, {'gears', 'ephysics_demo', 'camera', 'Evas_3D_demo', 'chat', 'files', 'woMan', 'extantz'}, 'crappisspuke.o CDemo.o extantzCamera.o -lwinFang')
diff --git a/src/extantz/winFang.c b/src/extantz/winFang.c
deleted file mode 100644
index a38845a..0000000
--- a/src/extantz/winFang.c
+++ /dev/null
@@ -1,205 +0,0 @@
1#include "extantz.h"
2
3
4// Elm inlined image windows needs this to change focus on mouse click.
5// Evas style event callback.
6static void _cb_mouse_down_elm(void *data, Evas *evas, Evas_Object *obj, void *event_info)
7{
8 Evas_Event_Mouse_Down *ev = event_info;
9
10 if (1 == ev->button)
11 elm_object_focus_set(obj, EINA_TRUE);
12}
13
14static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info)
15{
16 Evas_Event_Mouse_Move *ev = event_info;
17 Evas_Object *orig = data;
18 Evas_Coord x, y;
19 Evas_Map *p;
20 int i, w, h;
21
22 if (!ev->buttons) return;
23 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
24 evas_object_move(obj,
25 x + (ev->cur.canvas.x - ev->prev.output.x),
26 y + (ev->cur.canvas.y - ev->prev.output.y));
27 evas_object_image_size_get(orig, &w, &h);
28 p = evas_map_new(4);
29 evas_object_map_enable_set(orig, EINA_TRUE);
30// evas_object_raise(orig);
31 for (i = 0; i < 4; i++)
32 {
33 Evas_Object *hand;
34 char key[32];
35
36 snprintf(key, sizeof(key), "h-%i\n", i);
37 hand = evas_object_data_get(orig, key);
38 evas_object_raise(hand);
39 evas_object_geometry_get(hand, &x, &y, NULL, NULL);
40 x += 15;
41 y += 15;
42 evas_map_point_coord_set(p, i, x, y, 0);
43 if (i == 0) evas_map_point_image_uv_set(p, i, 0, 0);
44 else if (i == 1) evas_map_point_image_uv_set(p, i, w, 0);
45 else if (i == 2) evas_map_point_image_uv_set(p, i, w, h);
46 else if (i == 3) evas_map_point_image_uv_set(p, i, 0, h);
47 }
48 evas_object_map_set(orig, p);
49 evas_map_free(p);
50}
51
52static void _on_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
53{
54 elm_exit();
55}
56
57void winFangHide(winFang *win)
58{
59 int i;
60
61 evas_object_hide(win->win);
62 for (i = 0; i < 4; i++)
63 evas_object_hide(win->hand[i]);
64}
65
66void winFangShow(winFang *win)
67{
68 int i;
69
70 evas_object_show(win->win);
71 for (i = 0; i < 4; i++)
72 evas_object_show(win->hand[i]);
73}
74
75winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h, char *title, char *name)
76{
77 winFang *result;
78 Evas_Object *obj, *obj2, *bg;
79 char buf[PATH_MAX];
80 int i;
81
82 result = calloc(1, sizeof(winFang));
83 eina_clist_init(&result->widgets);
84
85 if (parent) result->internal = EINA_TRUE;
86
87 result->x = x;
88 result->y = y;
89 result->w = w;
90 result->h = h;
91
92 // In theory this should create an EWS window, in practice, I'm not seeing any difference.
93 // Guess I'll have to implement my own internal window manager. I don't think a basic one will be that hard. Famous last words.
94// elm_config_engine_set("ews");
95 if (result->internal)
96 {
97 result->win = elm_win_add(parent, name, ELM_WIN_INLINED_IMAGE);
98 obj = elm_win_inlined_image_object_get(result->win);
99 // On mouse down we try to shift focus to the backing image, this seems to be the correct thing to force focus onto it's widgets.
100 // According to the Elm inlined image window example, this is what's needed to.
101 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, NULL);
102 elm_win_alpha_set(result->win, EINA_TRUE);
103
104 // image object for win is unlinked to its pos/size - so manual control
105 // this allows also for using map and other things with it.
106 evas_object_move(obj, result->x, result->y);
107 // Odd, it needs to be resized twice. WTF?
108 evas_object_resize(obj, result->w, result->h);
109
110 obj2 = evas_object_evas_get(obj);
111 // Create corner handles.
112 snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get());
113 for (i = 0; i < 4; i++)
114 {
115 char key[32];
116 int cx = result->x, cy = result->y;
117
118 if (i == 1) cx += result->w;
119 else if (i == 2) {cx += result->w; cy += result->h;}
120 else if (i == 3) cy += result->h;
121 snprintf(key, sizeof(key), "h-%i\n", i);
122#if 1
123 result->hand[i] = evas_object_image_filled_add(obj2);
124 evas_object_image_file_set(result->hand[i], buf, NULL);
125 evas_object_resize(result->hand[i], 31, 31);
126 evas_object_move(result->hand[i], cx - 15, cy - 15);
127 evas_object_data_set(obj, key, result->hand[i]);
128 evas_object_show(result->hand[i]);
129 evas_object_event_callback_add(result->hand[i], EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
130#else
131// TODO - No idea why, but using this version makes the window vanish when you click on a handle.
132 result->hand[i] = eo_add(EVAS_OBJ_IMAGE_CLASS, obj2,
133 evas_obj_image_filled_set(EINA_TRUE),
134 evas_obj_image_file_set(buf, NULL),
135 evas_obj_size_set(31, 31),
136 evas_obj_position_set(cx - 15, cy - 15),
137 eo_key_data_set(key, result->hand[i], NULL),
138 evas_obj_visibility_set(EINA_TRUE)
139 );
140 evas_object_event_callback_add(result->hand[i], EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
141 eo_unref(result->hand[i]);
142#endif
143 }
144 }
145 else
146 {
147 elm_config_preferred_engine_set("opengl_x11");
148 result->win = elm_win_add(parent, name, ELM_WIN_BASIC);
149 evas_object_move(result->win, result->x, result->y);
150 evas_object_smart_callback_add(result->win, "delete,request", _on_done, NULL);
151 }
152
153 elm_win_title_set(result->win, title);
154 // Apparently transparent is not good enough for ELM backgrounds, so make it an Evas rectangle.
155 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle.
156 bg = eo_add(EVAS_OBJ_RECTANGLE_CLASS, evas_object_evas_get(result->win),
157 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
158 evas_obj_color_set(50, 0, 100, 100),
159 evas_obj_visibility_set(EINA_TRUE)
160 );
161 elm_win_resize_object_add(result->win, bg);
162 eo_unref(bg);
163
164 evas_object_resize(result->win, result->w, result->h);
165 evas_object_show(result->win);
166
167 return result;
168}
169
170void winFangDel(winFang *win)
171{
172 Widget *wid;
173
174 if (!win) return;
175
176 // Elm will delete our widgets, but if we are using eo, we need to unref them.
177 EINA_CLIST_FOR_EACH_ENTRY(wid, &win->widgets, Widget, node)
178 {
179 if (wid->on_del) wid->on_del(wid, wid->obj, NULL);
180 eo_unref(wid->obj);
181 }
182 if (win->on_del) win->on_del(win, win->win, NULL);
183 evas_object_del(win->win);
184}
185
186Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title)
187{
188 Widget *result;
189
190 result = calloc(1, sizeof(Widget));
191 strcpy(result->magic, "Widget");
192 eina_clist_add_head(&win->widgets, &result->node);
193
194 if (parent)
195 {
196 result->obj = eo_add(klass, parent,
197 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
198 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL),
199 evas_obj_visibility_set(EINA_TRUE)
200 );
201 if (title) elm_object_text_set(result->obj, title);
202 }
203
204 return result;
205}
diff --git a/src/extantz/winFang.h b/src/extantz/winFang.h
deleted file mode 100644
index 6ae26e4..0000000
--- a/src/extantz/winFang.h
+++ /dev/null
@@ -1,39 +0,0 @@
1#include <Elementary.h>
2
3
4typedef struct _winFang
5{
6 Evas_Object *win;
7 Eina_Clist widgets;
8 int x, y, w, h;
9 Eina_Bool internal;
10
11 Evas_Object *hand[4];
12
13 Eina_Clist node;
14 void *data;
15 Evas_Smart_Cb on_del;
16} winFang;
17
18typedef struct _Widget
19{
20 char magic[8];
21 Evas_Object *obj;
22
23 char *label, *look, *action, *help;
24 // foreground / background colour
25 // thing
26 // types {}
27 // skangCoord x, y, w, h
28
29 Eina_Clist node;
30 void *data;
31 Evas_Smart_Cb on_del;
32} Widget;
33
34winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h, char *title, char *name);
35void winFangHide(winFang *win);
36void winFangShow(winFang *win);
37void winFangDel(winFang *win);
38
39Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title);