aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libraries/winFang.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libraries/winFang.c')
-rw-r--r--src/libraries/winFang.c121
1 files changed, 49 insertions, 72 deletions
diff --git a/src/libraries/winFang.c b/src/libraries/winFang.c
index 6b15a6d..2cbd04d 100644
--- a/src/libraries/winFang.c
+++ b/src/libraries/winFang.c
@@ -21,7 +21,7 @@ printf("%s %s\n", evas_object_type_get(objs), evas_object_name_get(objs));
21 21
22static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) 22static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
23{ 23{
24 Evas_Object *img = elm_win_inlined_image_object_get(win->win), *test; 24 Evas_Object *img = win->win, *test;
25 Eina_List *objs, *this; 25 Eina_List *objs, *this;
26 Evas_Coord mw, mh; 26 Evas_Coord mw, mh;
27 int padding = 1, i = 0, overs[4][2]; 27 int padding = 1, i = 0, overs[4][2];
@@ -80,7 +80,7 @@ static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_
80 Evas_Event_Mouse_Move *ev = event_info; 80 Evas_Event_Mouse_Move *ev = event_info;
81 winFang *win = data; 81 winFang *win = data;
82 Evas_Coord x, y, w, h, dx = 0, dy = 0, dw = 0, dh = 0, mx, my; 82 Evas_Coord x, y, w, h, dx = 0, dy = 0, dw = 0, dh = 0, mx, my;
83 Evas_Object *img = elm_win_inlined_image_object_get(win->win); 83 Evas_Object *img = win->win;
84 int i; 84 int i;
85 85
86 if (!ev->buttons) return; 86 if (!ev->buttons) return;
@@ -126,7 +126,7 @@ static void _onBgMove(void *data, Evas *evas, Evas_Object *obj, void *event_info
126{ 126{
127 Evas_Event_Mouse_Move *ev = event_info; 127 Evas_Event_Mouse_Move *ev = event_info;
128 winFang *win = data; 128 winFang *win = data;
129 Evas_Object *img = elm_win_inlined_image_object_get(win->win); 129 Evas_Object *img = win->win;
130 Evas_Coord x, y, w, h; 130 Evas_Coord x, y, w, h;
131 131
132 if (1 != ev->buttons) return; 132 if (1 != ev->buttons) return;
@@ -165,8 +165,6 @@ void winFangShow(winFang *win)
165winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world) 165winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world)
166{ 166{
167 winFang *result; 167 winFang *result;
168 Evas_Object *obj, *obj1;
169 Evas *obj2;
170 char buf[PATH_MAX]; 168 char buf[PATH_MAX];
171 int i; 169 int i;
172 170
@@ -182,84 +180,81 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch
182 result->w = w; 180 result->w = w;
183 result->h = h; 181 result->h = h;
184 182
185 // In theory this should create an EWS window, in practice, I'm not seeing any difference.
186 // 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.
187// elm_config_engine_set("ews");
188 if (result->internal) 183 if (result->internal)
189 { 184 {
190 result->win = elm_win_add(parent->win, name, ELM_WIN_INLINED_IMAGE);
191 eina_clist_add_head(&parent->winFangs, &result->node); 185 eina_clist_add_head(&parent->winFangs, &result->node);
192 obj = elm_win_inlined_image_object_get(result->win); 186
193 evas_object_name_set(obj, "winFang"); 187 result->win = elm_layout_add(parent->win);
188 evas_object_name_set(result->win, "winFang");
189 evas_object_size_hint_weight_set(result->win, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
190 snprintf(buf, sizeof(buf), "%s/winFang.edj", elm_app_data_dir_get());
191 elm_layout_file_set(result->win, buf, "winFang/layout");
192 if (title)
193 elm_object_part_text_set(result->win, TITLE, title);
194
195 result->grid = elm_grid_add(parent->win);
196 elm_grid_size_set(result->grid, result->w, result->h);
197 evas_object_size_hint_weight_set(result->grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
198 evas_object_size_hint_align_set(result->grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
199 elm_object_part_content_set(result->win, SWALLOW, result->grid);
200 evas_object_show(result->grid);
201
202 evas_object_resize(result->win, result->w, result->h);
203 evas_object_move(result->win, result->x, result->y);
204 elm_layout_sizing_eval(result->win);
205 evas_object_show(result->win);
206
194 // 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. 207 // 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.
195 // According to the Elm inlined image window example, this is what's needed to. 208 // According to the Elm inlined image window example, this is what's needed to.
196 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, result); 209 evas_object_event_callback_add(result->win, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, result);
197 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, _onBgMove, result); 210 evas_object_event_callback_add(result->win, EVAS_CALLBACK_MOUSE_MOVE, _onBgMove, result);
198 elm_win_alpha_set(result->win, EINA_TRUE); 211
199 212 result->e = evas_object_evas_get(result->win);
200 // image object for win is unlinked to its pos/size - so manual control
201 // this allows also for using map and other things with it.
202 evas_object_move(obj, result->x, result->y);
203 // Odd, it needs to be resized twice. WTF?
204 evas_object_resize(obj, result->w, result->h);
205
206 obj2 = evas_object_evas_get(obj);
207 result->e = obj2;
208 // Create corner handles. 213 // Create corner handles.
209 snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get()); 214 snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get());
210 for (i = 0; i < 4; i++) 215 for (i = 0; i < 4; i++)
211 { 216 {
212 char key[32];
213 int cx = result->x, cy = result->y; 217 int cx = result->x, cy = result->y;
214 218
215 if (i == 1) cx += result->w; 219 if (i == 1) cx += result->w;
216 else if (i == 2) {cx += result->w; cy += result->h;} 220 else if (i == 2) {cx += result->w; cy += result->h;}
217 else if (i == 3) cy += result->h; 221 else if (i == 3) cy += result->h;
218 snprintf(key, sizeof(key), "h-%i\n", i); 222 result->hand[i] = eo_add(EVAS_OBJ_IMAGE_CLASS, result->e,
219 result->hand[i] = eo_add(EVAS_OBJ_IMAGE_CLASS, obj2,
220 evas_obj_image_filled_set(EINA_TRUE), 223 evas_obj_image_filled_set(EINA_TRUE),
221 evas_obj_image_file_set(buf, NULL), 224 evas_obj_image_file_set(buf, NULL),
222 evas_obj_size_set(31, 31), 225 evas_obj_size_set(31, 31),
223 evas_obj_position_set(cx - 15, cy - 15), 226 evas_obj_position_set(cx - 15, cy - 15),
224 eo_key_data_set(key, result->hand[i], NULL),
225 evas_obj_visibility_set(EINA_TRUE) 227 evas_obj_visibility_set(EINA_TRUE)
226 ); 228 );
227 evas_object_event_callback_add(result->hand[i], EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, result); 229 evas_object_event_callback_add(result->hand[i], EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, result);
228 eo_unref(result->hand[i]); 230 eo_unref(result->hand[i]);
229 } 231 }
232
230 } 233 }
231 else 234 else
232 { 235 {
233 result->win = elm_win_add(NULL, name, ELM_WIN_BASIC); 236 result->win = elm_win_add(NULL, name, ELM_WIN_BASIC);
234 evas_object_move(result->win, result->x, result->y); 237 evas_object_move(result->win, result->x, result->y);
235 evas_object_smart_callback_add(result->win, "delete,request", _on_done, NULL); 238 evas_object_smart_callback_add(result->win, "delete,request", _on_done, NULL);
236 } 239 elm_win_title_set(result->win, title);
237 240
238 elm_win_title_set(result->win, title); 241 snprintf(buf, sizeof(buf), "%s/sky_04.jpg", elm_app_data_dir_get());
239 242 result->bg = eo_add(ELM_OBJ_IMAGE_CLASS, result->win,
240 snprintf(buf, sizeof(buf), "%s/sky_04.jpg", elm_app_data_dir_get()); 243 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
241 result->bg = eo_add(ELM_OBJ_IMAGE_CLASS, result->win, 244 elm_obj_image_fill_outside_set(EINA_TRUE),
242 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), 245 elm_obj_image_file_set(buf, NULL),
243 elm_obj_image_fill_outside_set(EINA_TRUE), 246 evas_obj_color_set(50, 0, 100, 100),
244 elm_obj_image_file_set(buf, NULL), 247 evas_obj_visibility_set(EINA_TRUE)
245 evas_obj_color_set(50, 0, 100, 100), 248 );
246 evas_obj_visibility_set(EINA_TRUE) 249 elm_win_resize_object_add(result->win, result->bg);
247 ); 250 evas_object_resize(result->win, result->w, result->h);
248 elm_win_resize_object_add(result->win, result->bg); 251 }
249
250 // Every window gets a free vertical box.
251 // TODO - Any widgets created without positon and size get packed to the end.
252 result->box = eo_add(ELM_OBJ_BOX_CLASS, result->win,
253 elm_obj_box_homogeneous_set(EINA_FALSE),
254 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
255 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL)
256 );
257 elm_win_resize_object_add(result->win, result->box);
258 252
259 if (result->internal) 253 if (result->internal)
260 { 254 {
255/*
261 result->title = eo_add(ELM_OBJ_LABEL_CLASS, result->win, 256 result->title = eo_add(ELM_OBJ_LABEL_CLASS, result->win,
262 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), 257 evas_obj_size_hint_align_set(EVAS_HINT_FILL, 1.0),
263 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), 258 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0),
264 evas_obj_visibility_set(EINA_TRUE) 259 evas_obj_visibility_set(EINA_TRUE)
265 ); 260 );
@@ -268,7 +263,7 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch
268 elm_object_text_set(result->title, buf); 263 elm_object_text_set(result->title, buf);
269 elm_box_pack_end(result->box, result->title); 264 elm_box_pack_end(result->box, result->title);
270 eo_unref(result->title); 265 eo_unref(result->title);
271 266*/
272#if 0 267#if 0
273 // EPysics enable the window. 268 // EPysics enable the window.
274 if (world) 269 if (world)
@@ -284,25 +279,18 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch
284 } 279 }
285#endif 280#endif
286 281
282/*
287 obj1 = eo_add(ELM_OBJ_SEPARATOR_CLASS, result->win, 283 obj1 = eo_add(ELM_OBJ_SEPARATOR_CLASS, result->win,
288 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), 284 evas_obj_size_hint_align_set(EVAS_HINT_FILL, 1.0),
289 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), 285 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0),
290 elm_obj_separator_horizontal_set(EINA_TRUE), 286 elm_obj_separator_horizontal_set(EINA_TRUE),
291 evas_obj_visibility_set(EINA_TRUE) 287 evas_obj_visibility_set(EINA_TRUE)
292 ); 288 );
293 elm_box_pack_end(result->box, obj1); 289 elm_box_pack_end(result->box, obj1);
294 eo_unref(obj1); 290 eo_unref(obj1);
295 291*/
296 result->content = eo_add(EVAS_OBJ_RECTANGLE_CLASS, result->win,
297 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL),
298 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
299 evas_obj_color_set(0, 0, 0, 0),
300 evas_obj_visibility_set(EINA_TRUE)
301 );
302 elm_box_pack_end(result->box, result->content);
303 } 292 }
304 293
305 evas_object_resize(result->win, result->w, result->h);
306 evas_object_show(result->win); 294 evas_object_show(result->win);
307 295
308 return result; 296 return result;
@@ -315,9 +303,7 @@ void winFangDel(winFang *win)
315 303
316 if (!win) return; 304 if (!win) return;
317 305
318 eo_unref(win->content); 306 if (win->bg) eo_unref(win->bg);
319 eo_unref(win->box);
320 eo_unref(win->bg);
321 EINA_CLIST_FOR_EACH_ENTRY(wf, &win->winFangs, winFang, node) 307 EINA_CLIST_FOR_EACH_ENTRY(wf, &win->winFangs, winFang, node)
322 { 308 {
323 winFangDel(wf); 309 winFangDel(wf);
@@ -333,15 +319,6 @@ void winFangDel(winFang *win)
333 evas_object_del(win->win); 319 evas_object_del(win->win);
334} 320}
335 321
336void useBox(winFang *win)
337{
338 eo_do(win->content,
339 evas_obj_visibility_set(EINA_FALSE),
340 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0),
341 evas_obj_size_set(0, 0)
342 );
343}
344
345Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title) 322Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title)
346{ 323{
347 Widget *result; 324 Widget *result;