aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz/fangWin.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-05 00:55:37 +1000
committerDavid Walter Seikel2014-05-05 00:55:37 +1000
commitd5d869e9ec2c54db9e3ff25c518d0b57ee362c1e (patch)
treec86a3c2b51216270a447652174b7c1b54a59d6b4 /src/extantz/fangWin.c
parentMinor clean up. (diff)
downloadSledjHamr-d5d869e9ec2c54db9e3ff25c518d0b57ee362c1e.zip
SledjHamr-d5d869e9ec2c54db9e3ff25c518d0b57ee362c1e.tar.gz
SledjHamr-d5d869e9ec2c54db9e3ff25c518d0b57ee362c1e.tar.bz2
SledjHamr-d5d869e9ec2c54db9e3ff25c518d0b57ee362c1e.tar.xz
fangWin -> winFang and related changes.
Diffstat (limited to 'src/extantz/fangWin.c')
-rw-r--r--src/extantz/fangWin.c196
1 files changed, 0 insertions, 196 deletions
diff --git a/src/extantz/fangWin.c b/src/extantz/fangWin.c
deleted file mode 100644
index 88a5c00..0000000
--- a/src/extantz/fangWin.c
+++ /dev/null
@@ -1,196 +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 create_handles(Evas_Object *obj)
53{
54 int i;
55 Evas_Coord x, y, w, h;
56
57 evas_object_geometry_get(obj, &x, &y, &w, &h);
58 for (i = 0; i < 4; i++)
59 {
60 Evas_Object *hand;
61 char buf[PATH_MAX];
62 char key[32];
63
64 hand = evas_object_image_filled_add(evas_object_evas_get(obj));
65 evas_object_resize(hand, 31, 31);
66 snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get());
67 evas_object_image_file_set(hand, buf, NULL);
68 if (i == 0) evas_object_move(hand, x - 15, y - 15);
69 else if (i == 1) evas_object_move(hand, x + w - 15, y - 15);
70 else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15);
71 else if (i == 3) evas_object_move(hand, x - 15, y + h - 15);
72 evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
73 evas_object_show(hand);
74 snprintf(key, sizeof(key), "h-%i\n", i);
75 evas_object_data_set(obj, key, hand);
76 }
77}
78
79fangWin *fang_win_add(globals *ourGlobals)
80{
81 fangWin *result;
82 Evas_Object *bg;
83
84 result = calloc(1, sizeof(fangWin));
85 eina_clist_init(&result->widgets);
86
87 // In theory this should create an EWS window, in practice, I'm not seeing any difference.
88 // 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.
89// elm_config_engine_set("ews");
90 result->win = elm_win_add(ourGlobals->win, "inlined", ELM_WIN_INLINED_IMAGE);
91 // 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.
92 // According to the Elm inlined image window example, this is what's needed to.
93 evas_object_event_callback_add(elm_win_inlined_image_object_get(result->win), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, NULL);
94 elm_win_alpha_set(result->win, EINA_TRUE);
95
96 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle.
97 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle.
98 bg = evas_object_rectangle_add(evas_object_evas_get(result->win));
99 evas_object_color_set(bg, 50, 0, 100, 100);
100 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
101 elm_win_resize_object_add(result->win, bg);
102 evas_object_show(bg);
103
104 return result;
105}
106
107void fang_win_complete(globals *ourGlobals, fangWin *win, int x, int y, int w, int h)
108{
109 // image object for win is unlinked to its pos/size - so manual control
110 // this allows also for using map and other things with it.
111 evas_object_move(elm_win_inlined_image_object_get(win->win), x, y);
112 // Odd, it needs to be resized twice. WTF?
113 evas_object_resize(win->win, w, h);
114 evas_object_resize(elm_win_inlined_image_object_get(win->win), w, h);
115 evas_object_show(win->win);
116 create_handles(elm_win_inlined_image_object_get(win->win));
117}
118
119void fang_win_del(globals *ourGlobals, fangWin *win)
120{
121 Widget *wid;
122
123 if (!win) return;
124
125 // Elm will delete our widgets, but if we are using eo, we need to unref them.
126 EINA_CLIST_FOR_EACH_ENTRY(wid, &win->widgets, Widget, node)
127 {
128 if (wid->on_del) wid->on_del(wid, wid->obj, NULL);
129 eo_unref(wid->obj);
130 }
131 if (win->on_del) win->on_del(win, win->win, NULL);
132 evas_object_del(win->win);
133}
134
135void overlay_add(globals *ourGlobals)
136{
137 GLData *gld = &ourGlobals->gld;
138 Evas_Object *bg;
139
140 // There are many reasons for this window.
141 // The first is to cover the GL and provide something to click on to change focus.
142 // The second is to provide something to click on for all the GL type clicking stuff that needs to be done. In other words, no click through, we catch the clicks here.
143 // So we can probably avoid the following issue -
144 // How to do click through? evas_object_pass_events_set(rectangle, EINA_TRUE), and maybe need to do that to the underlaying window to?
145 // Though if the rectangle is entirely transparent, or even hidden, events might pass through anyway.
146 // Gotta have click through on the parts where there's no other window.
147 // The third is to have the other windows live here.
148 // This idea doesn't work, as it breaks the damn focus again.
149 // Don't think it's needed anyway.
150 // While on the subject of layers, need a HUD layer of some sort, but Irrlicht might support that itself.
151
152 gld->winwin = elm_win_add(ourGlobals->win, "inlined", ELM_WIN_INLINED_IMAGE);
153 // 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.
154 // According to the Elm inlined image window example, this is what's needed to.
155 evas_object_event_callback_add(elm_win_inlined_image_object_get(gld->winwin), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, NULL);
156 // In this code, we are making our own camera, so grab it's input when we are focused.
157 cameraAdd(ourGlobals, gld->winwin);
158
159 elm_win_alpha_set(gld->winwin, EINA_TRUE);
160 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle.
161 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle.
162 bg = evas_object_rectangle_add(evas_object_evas_get(gld->winwin));
163 evas_object_color_set(bg, 0, 0, 0, 0);
164 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
165 elm_win_resize_object_add(gld->winwin, bg);
166 evas_object_show(bg);
167
168 // image object for win is unlinked to its pos/size - so manual control
169 // this allows also for using map and other things with it.
170 evas_object_move(elm_win_inlined_image_object_get(gld->winwin), 0, 0);
171 // Odd, it needs to be resized twice. WTF?
172 evas_object_resize(gld->winwin, ourGlobals->win_w, ourGlobals->win_h);
173 evas_object_resize(elm_win_inlined_image_object_get(gld->winwin), ourGlobals->win_w, ourGlobals->win_h);
174 evas_object_show(gld->winwin);
175}
176
177Widget *widgetAdd(fangWin *win, const Eo_Class *klass, Evas_Object *parent, char *title)
178{
179 Widget *result;
180
181 result = calloc(1, sizeof(Widget));
182 strcpy(result->magic, "Widget");
183 eina_clist_add_head(&win->widgets, &result->node);
184
185 if (parent)
186 {
187 result->obj = eo_add(klass, parent,
188 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
189 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL),
190 evas_obj_visibility_set(EINA_TRUE)
191 );
192 if (title) elm_object_text_set(result->obj, title);
193 }
194
195 return result;
196}