aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/extantz
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-01-15 06:33:14 +1000
committerDavid Walter Seikel2014-01-15 06:33:14 +1000
commit629c1449c44cdc02bd592a591cae50f2a56f3523 (patch)
tree9aba225cc0152309a4da9bc3197bfe6eb8a7af25 /ClientHamr/extantz
parentDon't start in jumping mode. (diff)
downloadSledjHamr-629c1449c44cdc02bd592a591cae50f2a56f3523.zip
SledjHamr-629c1449c44cdc02bd592a591cae50f2a56f3523.tar.gz
SledjHamr-629c1449c44cdc02bd592a591cae50f2a56f3523.tar.bz2
SledjHamr-629c1449c44cdc02bd592a591cae50f2a56f3523.tar.xz
Major changes, things where too fragile while I made them, so it's all one commit blob.
Sorted out top level menu and toolbar. Sorted out most focus issues. Sorted out resizing issues. Sorted out event issues. Sorted out camera issues. Added a window to cover the GL surface and act as it's UI event catcher. Added generic window and menu creation functions. Added a chat window. Moved cthe old window to it's own function, renamed it woMan. Re arranged some stuff. More comments. Clean ups. Probably other bits and pieces I forgot to mention. Starting to look real now. A little bit.
Diffstat (limited to 'ClientHamr/extantz')
-rw-r--r--ClientHamr/extantz/extantz.c582
-rw-r--r--ClientHamr/extantz/extantz.h3
2 files changed, 380 insertions, 205 deletions
diff --git a/ClientHamr/extantz/extantz.c b/ClientHamr/extantz/extantz.c
index 0c39b66..1a6669c 100644
--- a/ClientHamr/extantz/extantz.c
+++ b/ClientHamr/extantz/extantz.c
@@ -384,73 +384,43 @@ static void gears_init(GLData *gld)
384 gld->gearsInited = EINA_TRUE; 384 gld->gearsInited = EINA_TRUE;
385} 385}
386 386
387static void _cb_mouse_down_GL(void *data, Evas *evas, Evas_Object *obj, void *event_info)
388{
389 GLData *gld = data;
390 Evas_Event_Mouse_Down *ev = event_info;
391
392 if (1 == ev->button)
393 {
394 gld->camFocus = 1;
395 // TODO, figure out how to unfocus elm.
396 }
397}
398
399static void _cb_mouse_down_elm(void *data, Evas *evas, Evas_Object *obj, void *event_info)
400{
401 GLData *gld = data;
402 Evas_Event_Mouse_Down *ev = event_info;
403
404 if (1 == ev->button)
405 {
406 gld->camFocus = 0;
407 // TODO - Yes we really DO need to figure out what was clicked on and set focus to it. sigh
408// elm_object_focus_set(gld->bx, EINA_TRUE);
409 }
410}
411
412// These do not work as elm callbacks, coz Elm is grabbing the Left, Right, Up, and Down KEY_DOWNs. Something else is messing up Home + PgUp / PgDn.
413// It's a purely Evas object anyway.
414static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) 387static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
415{ 388{
416 GLData *gld = data; 389 GLData *gld = data;
417 Evas_Event_Key_Down *ev = event_info; 390 Evas_Event_Key_Down *ev = event_info;
418 391
419 if (gld->camFocus) 392 if (gld->move)
420 { 393 {
421 if (gld->move) 394 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
422 {
423 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
424 395
425 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ... 396 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ...
426 // TODO - make this a hash lookup dammit. 397 // TODO - make this a hash lookup dammit.
427 if (0 == strcmp(ev->key, "Escape")) 398 if (0 == strcmp(ev->key, "Escape"))
428 { 399 {
429 }
430 else if (0 == strcmp(ev->key, "Left"))
431 gld->move->r = 1.0;
432 else if (0 == strcmp(ev->key, "Right"))
433 gld->move->r = -1.0;
434 else if (0 == strcmp(ev->key, "Up"))
435 gld->move->x = 1.0;
436 else if (0 == strcmp(ev->key, "Down"))
437 gld->move->x = -1.0;
438 else if (0 == strcmp(ev->key, "Prior"))
439 ;
440 else if (0 == strcmp(ev->key, "Next"))
441 ;
442 else if (0 == strcmp(ev->key, "Home"))
443 ;
444 else if (0 == strcmp(ev->key, "End"))
445 ;
446 else if (0 == strcmp(ev->key, "space"))
447 gld->move->jump = 1.0;
448 else
449 printf("Unexpected down keystroke - %s\n", ev->key);
450 } 400 }
401 else if (0 == strcmp(ev->key, "Left"))
402 gld->move->r = 2.0;
403 else if (0 == strcmp(ev->key, "Right"))
404 gld->move->r = -2.0;
405 else if (0 == strcmp(ev->key, "Up"))
406 gld->move->x = 2.0;
407 else if (0 == strcmp(ev->key, "Down"))
408 gld->move->x = -2.0;
409// else if (0 == strcmp(ev->key, "Prior"))
410// ;
411// else if (0 == strcmp(ev->key, "Next"))
412// ;
413// else if (0 == strcmp(ev->key, "Home"))
414// ;
415// else if (0 == strcmp(ev->key, "End"))
416// ;
417 else if (0 == strcmp(ev->key, "space"))
418 gld->move->jump = 1.0;
451 else 419 else
452 printf("Camera input not ready\n"); 420 printf("Unexpected down keystroke - %s\n", ev->key);
453 } 421 }
422 else
423 printf("Camera input not ready\n");
454} 424}
455 425
456/* SL / OS camera controls 426/* SL / OS camera controls
@@ -511,6 +481,8 @@ static void _on_camera_input_down(void *data, Evas *evas, Evas_Object *obj, void
511 * A joystick could be set to range over -2.0 to 2.0, and just set it's part directly. 481 * A joystick could be set to range over -2.0 to 2.0, and just set it's part directly.
512 * A mouse look rotate, well will come to that when we need to. B-) 482 * A mouse look rotate, well will come to that when we need to. B-)
513 * Setting the x or y to be the DIFFERENCE in window position of the mouse (-1.0 to 1.0) since the last frame. 483 * Setting the x or y to be the DIFFERENCE in window position of the mouse (-1.0 to 1.0) since the last frame.
484 *
485 * TODO - In the Elm_glview version, 2.0 seems to be correct speed for walking, but I thought 1.0 was in Evas_GL.
514 */ 486 */
515 487
516static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info) 488static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *event_info)
@@ -518,49 +490,96 @@ static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *
518 GLData *gld = data; 490 GLData *gld = data;
519 Evas_Event_Key_Up *ev = event_info; 491 Evas_Event_Key_Up *ev = event_info;
520 492
521 if (gld->camFocus) 493 if (gld->move)
522 { 494 {
523 if (gld->move) 495 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
524 {
525 // TODO - Careful, gld->move MIGHT be read at the other end by another thread. MIGHT, coz I really don't know at what point the camera animate routine is actually called.
526 496
527 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ... 497 // Yes, we are dealing with the horrid Evas keyboard handling FUCKING STRING COMPARES! Soooo ...
528 // TODO - make this a hash lookup dammit. 498 // TODO - make this a hash lookup dammit.
529 if (0 == strcmp(ev->key, "Escape")) 499 if (0 == strcmp(ev->key, "Escape"))
530 { 500 {
531 }
532 else if (0 == strcmp(ev->key, "Left"))
533 gld->move->r = 0.0;
534 else if (0 == strcmp(ev->key, "Right"))
535 gld->move->r = 0.0;
536 else if (0 == strcmp(ev->key, "Up"))
537 gld->move->x = 0.0;
538 else if (0 == strcmp(ev->key, "Down"))
539 gld->move->x = 0.0;
540 else if (0 == strcmp(ev->key, "Prior"))
541 ;
542 else if (0 == strcmp(ev->key, "Next"))
543 ;
544 else if (0 == strcmp(ev->key, "Home"))
545 ;
546 else if (0 == strcmp(ev->key, "End"))
547 ;
548 else if (0 == strcmp(ev->key, "space"))
549 gld->move->jump = 0.0;
550 else
551 printf("Unexpected up keystroke - %s\n", ev->key);
552 } 501 }
502 else if (0 == strcmp(ev->key, "Left"))
503 gld->move->r = 0.0;
504 else if (0 == strcmp(ev->key, "Right"))
505 gld->move->r = 0.0;
506 else if (0 == strcmp(ev->key, "Up"))
507 gld->move->x = 0.0;
508 else if (0 == strcmp(ev->key, "Down"))
509 gld->move->x = 0.0;
510// else if (0 == strcmp(ev->key, "Prior"))
511// ;
512// else if (0 == strcmp(ev->key, "Next"))
513// ;
514// else if (0 == strcmp(ev->key, "Home"))
515// ;
516// else if (0 == strcmp(ev->key, "End"))
517// ;
518 else if (0 == strcmp(ev->key, "space"))
519 gld->move->jump = 0.0;
553 else 520 else
554 printf("Camera input not ready\n"); 521 printf("Unexpected up keystroke - %s\n", ev->key);
522 }
523 else
524 printf("Camera input not ready\n");
525}
526
527// Elm style event callback.
528static Eina_Bool _cb_event_GL(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info)
529{
530 GLData *gld = data;
531 Eina_Bool processed = EINA_FALSE;
532
533 switch (type)
534 {
535 case EVAS_CALLBACK_KEY_DOWN :
536 {
537 _on_camera_input_down(gld, evas_object_evas_get(obj), obj, event_info);
538 processed = EINA_TRUE;
539 break;
540 }
541
542 case EVAS_CALLBACK_KEY_UP :
543 {
544 _on_camera_input_up(gld, evas_object_evas_get(obj), obj, event_info);
545 processed = EINA_TRUE;
546 break;
547 }
548
549 default :
550 printf("Unknown GL input event.\n");
555 } 551 }
552
553 return processed;
556} 554}
557 555
556// Elm inlined image windows needs this to change focus on mouse click.
557// Evas style event callback.
558static void _cb_mouse_down_elm(void *data, Evas *evas, Evas_Object *obj, void *event_info)
559{
560 GLData *gld = data;
561 Evas_Event_Mouse_Down *ev = event_info;
562
563 if (1 == ev->button)
564 elm_object_focus_set(obj, EINA_TRUE);
565}
566
567static void _resize_winwin(GLData *gld)
568{
569 Evas_Coord x, y, w, h;
570
571 evas_object_geometry_get(gld->elmGl, &x, &y, &w, &h);
572 evas_object_move(elm_win_inlined_image_object_get (gld->winwin), x, y);
573 evas_object_resize(elm_win_inlined_image_object_get(gld->winwin), w, h);
574}
558 575
559// Called from on_pixels (), or the Elm_gliew resize callback. 576// Called from on_pixels (), or the Elm_gliew resize callback.
560static void _resize(GLData *gld) 577static void _resize(GLData *gld)
561{ 578{
562 Evas_GL_API *gl = gld->glApi; 579 Evas_GL_API *gl = gld->glApi;
563 580
581 _resize_winwin(gld);
582
564#if DO_GEARS 583#if DO_GEARS
565 GLfloat ar, m[16] = { 584 GLfloat ar, m[16] = {
566 1.0, 0.0, 0.0, 0.0, 585 1.0, 0.0, 0.0, 0.0,
@@ -580,6 +599,7 @@ static void _resize(GLData *gld)
580 m[5] = 0.1 * ar / gld->img_h; 599 m[5] = 0.1 * ar / gld->img_h;
581 memcpy(gld->proj, m, sizeof gld->proj); 600 memcpy(gld->proj, m, sizeof gld->proj);
582#endif 601#endif
602
583 gl->glViewport(0, 0, (GLint) gld->img_w, (GLint) gld->img_h); 603 gl->glViewport(0, 0, (GLint) gld->img_w, (GLint) gld->img_h);
584} 604}
585 605
@@ -808,18 +828,19 @@ static void init_evas_gl(GLData *gld)
808 elm_glview_render_policy_set(gld->elmGl, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND); 828 elm_glview_render_policy_set(gld->elmGl, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND);
809// elm_glview_render_policy_set(gld->elmGl, ELM_GLVIEW_RENDER_POLICY_ALWAYS); 829// elm_glview_render_policy_set(gld->elmGl, ELM_GLVIEW_RENDER_POLICY_ALWAYS);
810 // These get called in the render thread I think. 830 // These get called in the render thread I think.
831 // None let me pass data, so this is why we are adding "gld" data to the object below.
832 // Maybe we can use elm_object_signal_callback_add or elm_object_item_signal_callback_add (edje signals)?
811 //elm_glview_init_func_set(gld->elmGl, _init_gl); // Not actually needed, it gets done in on_pixels. 833 //elm_glview_init_func_set(gld->elmGl, _init_gl); // Not actually needed, it gets done in on_pixels.
812 elm_glview_del_func_set(gld->elmGl, _del_gl); 834 elm_glview_del_func_set(gld->elmGl, _del_gl);
813 elm_glview_resize_func_set(gld->elmGl, _resize_gl); 835 elm_glview_resize_func_set(gld->elmGl, _resize_gl);
814 elm_glview_render_func_set(gld->elmGl, (Elm_GLView_Func_Cb) _draw_gl); 836 elm_glview_render_func_set(gld->elmGl, (Elm_GLView_Func_Cb) _draw_gl);
815 837
816 elm_box_pack_end(gld->bx, gld->elmGl); 838 // Not needed, the resize callback above deals with that.
817 elm_win_resize_object_add(gld->win, gld->elmGl); 839 //elm_win_resize_object_add(gld->win, gld->elmGl);
818 evas_object_show(gld->elmGl);
819
820 elm_object_focus_set(gld->elmGl, EINA_TRUE);
821 gld->glApi = elm_glview_gl_api_get(gld->elmGl); 840 gld->glApi = elm_glview_gl_api_get(gld->elmGl);
822 evas_object_data_set(gld->elmGl, "gld", gld); 841 evas_object_data_set(gld->elmGl, "gld", gld);
842 evas_object_show(gld->elmGl);
843 elm_box_pack_end(gld->bx, gld->elmGl);
823#else 844#else
824 // get the evas gl handle for doing gl things 845 // get the evas gl handle for doing gl things
825 gld->evasGl = evas_gl_new(gld->canvas); 846 gld->evasGl = evas_gl_new(gld->canvas);
@@ -875,14 +896,11 @@ static void init_evas_gl(GLData *gld)
875 evas_object_show(gld->r1); 896 evas_object_show(gld->r1);
876 elm_box_pack_end(gld->bx, gld->r1); 897 elm_box_pack_end(gld->bx, gld->r1);
877 898
878// evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_GL, gld); 899 evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_GL, gld);
900// evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, gld);
901// evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, gld);
879#endif 902#endif
880 903
881 // In this code, we are making our own camera, so grab it's input when we are focused.
882 evas_object_event_callback_add(gld->win, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, gld);
883 evas_object_event_callback_add(gld->win, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, gld);
884 gld->camFocus = 1; // Start with the GL camera focused.
885
886 // NOTE: if you delete r1, this animator will keep running trying to access 904 // NOTE: if you delete r1, this animator will keep running trying to access
887 // r1 so you'd better delete this animator with ecore_animator_del() or 905 // r1 so you'd better delete this animator with ecore_animator_del() or
888 // structure how you do animation differently. you can also attach it like 906 // structure how you do animation differently. you can also attach it like
@@ -1012,12 +1030,98 @@ static void _grid_sel_cb(void *data, Evas_Object *obj, void *event_info)
1012// system(buf); 1030// system(buf);
1013} 1031}
1014 1032
1015static void fill(GLData *gld, Evas_Object *win) 1033static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1016{ 1034{
1017 Evas_Object *bg, *bx, *ic, *bb, *av, *en, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu; 1035 Evas_Event_Mouse_Move *ev = event_info;
1018 Elm_Object_Item *tb_it, *menu_it, *tab_it; 1036 Evas_Object *orig = data;
1019 char buf[PATH_MAX]; 1037 Evas_Coord x, y;
1020 int i; 1038 Evas_Map *p;
1039 int i, w, h;
1040
1041 if (!ev->buttons) return;
1042 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1043 evas_object_move(obj,
1044 x + (ev->cur.canvas.x - ev->prev.output.x),
1045 y + (ev->cur.canvas.y - ev->prev.output.y));
1046 evas_object_image_size_get(orig, &w, &h);
1047 p = evas_map_new(4);
1048 evas_object_map_enable_set(orig, EINA_TRUE);
1049// evas_object_raise(orig);
1050 for (i = 0; i < 4; i++)
1051 {
1052 Evas_Object *hand;
1053 char key[32];
1054
1055 snprintf(key, sizeof(key), "h-%i\n", i);
1056 hand = evas_object_data_get(orig, key);
1057 evas_object_raise(hand);
1058 evas_object_geometry_get(hand, &x, &y, NULL, NULL);
1059 x += 15;
1060 y += 15;
1061 evas_map_point_coord_set(p, i, x, y, 0);
1062 if (i == 0) evas_map_point_image_uv_set(p, i, 0, 0);
1063 else if (i == 1) evas_map_point_image_uv_set(p, i, w, 0);
1064 else if (i == 2) evas_map_point_image_uv_set(p, i, w, h);
1065 else if (i == 3) evas_map_point_image_uv_set(p, i, 0, h);
1066 }
1067 evas_object_map_set(orig, p);
1068 evas_map_free(p);
1069}
1070
1071static void create_handles(Evas_Object *obj)
1072{
1073 int i;
1074 Evas_Coord x, y, w, h;
1075
1076 evas_object_geometry_get(obj, &x, &y, &w, &h);
1077 for (i = 0; i < 4; i++)
1078 {
1079 Evas_Object *hand;
1080 char buf[PATH_MAX];
1081 char key[32];
1082
1083 hand = evas_object_image_filled_add(evas_object_evas_get(obj));
1084 evas_object_resize(hand, 31, 31);
1085 snprintf(buf, sizeof(buf), "%s/images/pt.png", elm_app_data_dir_get());
1086 evas_object_image_file_set(hand, buf, NULL);
1087 if (i == 0) evas_object_move(hand, x - 15, y - 15);
1088 else if (i == 1) evas_object_move(hand, x + w - 15, y - 15);
1089 else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15);
1090 else if (i == 3) evas_object_move(hand, x - 15, y + h - 15);
1091 evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
1092 evas_object_show(hand);
1093 snprintf(key, sizeof(key), "h-%i\n", i);
1094 evas_object_data_set(obj, key, hand);
1095 }
1096}
1097
1098static Evas_Object *_toolbar_menu_add(Evas_Object *win, Evas_Object *tb, char *label)
1099{
1100 Evas_Object *menu= NULL;
1101 Elm_Object_Item *tb_it, *menu_it;
1102
1103 tb_it = elm_toolbar_item_append(tb, NULL, label, NULL, NULL);
1104 elm_toolbar_item_menu_set(tb_it, EINA_TRUE);
1105 // Priority is for when toolbar items are set to hide or menu when there are too many of them. They get hidden or put on the menu based on priority.
1106 elm_toolbar_item_priority_set(tb_it, 9999);
1107 elm_toolbar_menu_parent_set(tb, win);
1108 menu = elm_toolbar_item_menu_get(tb_it);
1109
1110 return menu;
1111}
1112
1113static Evas_Object *fang_win_add(GLData *gld)
1114{
1115 Evas_Object *win, *bg;
1116
1117 // In theory this should create an EWS window, in practice, I'm not seeing any difference.
1118 // 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.
1119// elm_config_engine_set("ews");
1120 win = elm_win_add(gld->win, "inlined", ELM_WIN_INLINED_IMAGE);
1121 // 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.
1122 // According to the Elm inlined image window example, this is what's needed to.
1123 evas_object_event_callback_add(elm_win_inlined_image_object_get(win), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld);
1124 elm_win_alpha_set(win, EINA_TRUE);
1021 1125
1022 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle. 1126 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle.
1023 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle. 1127 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle.
@@ -1027,6 +1131,109 @@ static void fill(GLData *gld, Evas_Object *win)
1027 elm_win_resize_object_add(win, bg); 1131 elm_win_resize_object_add(win, bg);
1028 evas_object_show(bg); 1132 evas_object_show(bg);
1029 1133
1134 return win;
1135}
1136
1137static void fang_win_complete(GLData *gld, Evas_Object *win, int x, int y, int w, int h)
1138{
1139 // image object for win is unlinked to its pos/size - so manual control
1140 // this allows also for using map and other things with it.
1141 evas_object_move(elm_win_inlined_image_object_get(win), x, y);
1142 // Odd, it needs to be resized twice. WTF?
1143 evas_object_resize(win, w, h);
1144 evas_object_resize(elm_win_inlined_image_object_get(win), w, h);
1145 evas_object_show(win);
1146 create_handles(elm_win_inlined_image_object_get(win));
1147}
1148
1149static void overlay_add(GLData *gld)
1150{
1151 Evas_Object *bg, *bx, *tb, *menu;
1152 Elm_Object_Item *tb_it, *menu_it;
1153
1154 // There many are reasons for this window.
1155 // The first is to cover the GL and provide something to click on to change focus.
1156 // 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.
1157 // So we can probably avoid the following issue -
1158 // How to do click through? evas_object_pass_events_set(rectangle, EINA_TRUE), and maybe need to do that to the underlaying window to?
1159 // Though if the rectangle is entirely transparent, or even hidden, events might pass through anyway.
1160 // Gotta have click through on the parts where there's no other window.
1161 // The third is to have the other windows live here.
1162 // This idea doesn't work, as it breaks the damn focus again.
1163 // Don't think it's needed anyway.
1164 // While on the subject of layers, need a HUD layer of some sort, but Irrlicht might support that itself.
1165
1166 gld->winwin = elm_win_add(gld->win, "inlined", ELM_WIN_INLINED_IMAGE);
1167 // 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.
1168 // According to the Elm inlined image window example, this is what's needed to.
1169 evas_object_event_callback_add(elm_win_inlined_image_object_get(gld->winwin), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld);
1170 // In this code, we are making our own camera, so grab it's input when we are focused.
1171 evas_object_event_callback_add(gld->winwin, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, gld);
1172 evas_object_event_callback_add(gld->winwin, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, gld);
1173 elm_object_event_callback_add(gld->winwin, _cb_event_GL, gld);
1174
1175 elm_win_alpha_set(gld->winwin, EINA_TRUE);
1176 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle.
1177 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle.
1178 bg = evas_object_rectangle_add(evas_object_evas_get(gld->winwin));
1179 evas_object_color_set(bg, 0, 0, 0, 0);
1180 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1181 elm_win_resize_object_add(gld->winwin, bg);
1182 evas_object_show(bg);
1183
1184 // image object for win is unlinked to its pos/size - so manual control
1185 // this allows also for using map and other things with it.
1186 evas_object_move(elm_win_inlined_image_object_get(gld->winwin), 0, 0);
1187 // Odd, it needs to be resized twice. WTF?
1188 evas_object_resize(gld->winwin, gld->win_w, gld->win_h);
1189 evas_object_resize(elm_win_inlined_image_object_get(gld->winwin), gld->win_w, gld->win_h);
1190 evas_object_show(gld->winwin);
1191}
1192
1193static void chat_add(GLData *gld)
1194{
1195 Evas_Object *win, *bx, *en;
1196
1197 win = fang_win_add(gld);
1198
1199 bx = elm_box_add(win);
1200 elm_win_resize_object_add(win, bx);
1201 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1202 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1203
1204 en = elm_entry_add(win);
1205 elm_entry_scrollable_set(en, EINA_TRUE);
1206 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1207 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
1208 elm_object_text_set(en, "History is shown here");
1209 elm_entry_editable_set(en, EINA_FALSE);
1210 evas_object_show(en);
1211 elm_box_pack_end(bx, en);
1212
1213 en = elm_entry_add(win);
1214 elm_entry_scrollable_set(en, EINA_TRUE);
1215 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1216 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
1217 elm_object_text_set(en, "");
1218 elm_entry_editable_set(en, EINA_TRUE);
1219 evas_object_show(en);
1220 elm_box_pack_end(bx, en);
1221
1222 evas_object_show(bx);
1223
1224 fang_win_complete(gld, win, 30, 500, gld->win_w / 3, gld->win_h / 3);
1225}
1226
1227
1228static void woMan_add(GLData *gld)
1229{
1230 Evas_Object *win, *bg, *bx, *ic, *bb, *av, *en, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu;
1231 Elm_Object_Item *tb_it, *menu_it, *tab_it;
1232 char buf[PATH_MAX];
1233 int i;
1234
1235 win = fang_win_add(gld);
1236
1030 bx = elm_box_add(win); 1237 bx = elm_box_add(win);
1031 elm_win_resize_object_add(win, bx); 1238 elm_win_resize_object_add(win, bx);
1032 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1239 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -1046,19 +1253,13 @@ static void fill(GLData *gld, Evas_Object *win)
1046 elm_toolbar_menu_parent_set(tb, win); 1253 elm_toolbar_menu_parent_set(tb, win);
1047 menu = elm_toolbar_item_menu_get(tb_it); 1254 menu = elm_toolbar_item_menu_get(tb_it);
1048 1255
1049 elm_menu_item_add(menu, NULL, NULL, "preferences", NULL, NULL); 1256 menu_it = elm_menu_item_add(menu, NULL, NULL, "edit", NULL, NULL);
1257 elm_menu_item_add(menu, menu_it, NULL, "preferences", NULL, NULL);
1258 menu_it = elm_menu_item_add(menu, NULL, NULL, "help", NULL, NULL);
1259 elm_menu_item_add(menu, menu_it, NULL, "about woMan", NULL, NULL);
1260 elm_menu_item_separator_add(menu, NULL);
1050 menu_it = elm_menu_item_add(menu, NULL, NULL, "advanced", NULL, NULL); 1261 menu_it = elm_menu_item_add(menu, NULL, NULL, "advanced", NULL, NULL);
1051 elm_menu_item_add(menu, menu_it, NULL, "debug settings", NULL, NULL); 1262 elm_menu_item_add(menu, menu_it, NULL, "debug settings", NULL, NULL);
1052 elm_menu_item_separator_add(menu, NULL);
1053 menu_it = elm_menu_item_add(menu, NULL, NULL, "help", NULL, NULL);
1054 elm_menu_item_add(menu, menu_it, NULL, "grid help", NULL, NULL);
1055 elm_menu_item_separator_add(menu, menu_it);
1056 elm_menu_item_add(menu, menu_it, NULL, "extantz blogs", NULL, NULL);
1057 elm_menu_item_add(menu, menu_it, NULL, "extantz forum", NULL, NULL);
1058 elm_menu_item_separator_add(menu, menu_it);
1059 elm_menu_item_add(menu, menu_it, NULL, "about extantz", NULL, NULL);
1060 elm_menu_item_separator_add(menu, menu_it);
1061 elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, gld);
1062 1263
1063 // The toolbar needs to be packed into the box AFTER the menus are added. 1264 // The toolbar needs to be packed into the box AFTER the menus are added.
1064 elm_box_pack_end(bx, tb); 1265 elm_box_pack_end(bx, tb);
@@ -1164,78 +1365,15 @@ static void fill(GLData *gld, Evas_Object *win)
1164#endif 1365#endif
1165// evas_object_smart_callback_add(bt, "clicked", NULL, NULL); 1366// evas_object_smart_callback_add(bt, "clicked", NULL, NULL);
1166 elm_box_pack_end(bx, bt); 1367 elm_box_pack_end(bx, bt);
1368 evas_object_show(bx);
1167 1369
1168 evas_object_show(bx); 1370 fang_win_complete(gld, win, 30, 30, gld->win_w / 3, gld->win_h / 3);
1169}
1170
1171static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1172{
1173 Evas_Event_Mouse_Move *ev = event_info;
1174 Evas_Object *orig = data;
1175 Evas_Coord x, y;
1176 Evas_Map *p;
1177 int i, w, h;
1178
1179 if (!ev->buttons) return;
1180 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1181 evas_object_move(obj,
1182 x + (ev->cur.canvas.x - ev->prev.output.x),
1183 y + (ev->cur.canvas.y - ev->prev.output.y));
1184 evas_object_image_size_get(orig, &w, &h);
1185 p = evas_map_new(4);
1186 evas_object_map_enable_set(orig, EINA_TRUE);
1187// evas_object_raise(orig);
1188 for (i = 0; i < 4; i++)
1189 {
1190 Evas_Object *hand;
1191 char key[32];
1192
1193 snprintf(key, sizeof(key), "h-%i\n", i);
1194 hand = evas_object_data_get(orig, key);
1195 evas_object_raise(hand);
1196 evas_object_geometry_get(hand, &x, &y, NULL, NULL);
1197 x += 15;
1198 y += 15;
1199 evas_map_point_coord_set(p, i, x, y, 0);
1200 if (i == 0) evas_map_point_image_uv_set(p, i, 0, 0);
1201 else if (i == 1) evas_map_point_image_uv_set(p, i, w, 0);
1202 else if (i == 2) evas_map_point_image_uv_set(p, i, w, h);
1203 else if (i == 3) evas_map_point_image_uv_set(p, i, 0, h);
1204 }
1205 evas_object_map_set(orig, p);
1206 evas_map_free(p);
1207}
1208
1209static void create_handles(Evas_Object *obj)
1210{
1211 int i;
1212 Evas_Coord x, y, w, h;
1213
1214 evas_object_geometry_get(obj, &x, &y, &w, &h);
1215 for (i = 0; i < 4; i++)
1216 {
1217 Evas_Object *hand;
1218 char buf[PATH_MAX];
1219 char key[32];
1220
1221 hand = evas_object_image_filled_add(evas_object_evas_get(obj));
1222 evas_object_resize(hand, 31, 31);
1223 snprintf(buf, sizeof(buf), "%s/images/pt.png", elm_app_data_dir_get());
1224 evas_object_image_file_set(hand, buf, NULL);
1225 if (i == 0) evas_object_move(hand, x - 15, y - 15);
1226 else if (i == 1) evas_object_move(hand, x + w - 15, y - 15);
1227 else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15);
1228 else if (i == 3) evas_object_move(hand, x - 15, y + h - 15);
1229 evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
1230 evas_object_show(hand);
1231 snprintf(key, sizeof(key), "h-%i\n", i);
1232 evas_object_data_set(obj, key, hand);
1233 }
1234} 1371}
1235 1372
1236EAPI_MAIN int elm_main(int argc, char **argv) 1373EAPI_MAIN int elm_main(int argc, char **argv)
1237{ 1374{
1238 Evas_Object *bg, *win3; 1375 Evas_Object *bg, *menu, *bt, *tb;
1376 Elm_Object_Item *tb_it, *menu_it;
1239 EPhysics_Body *boundary; 1377 EPhysics_Body *boundary;
1240 EPhysics_World *world; 1378 EPhysics_World *world;
1241 EPhysics_Body *box_body1, *box_body2; 1379 EPhysics_Body *box_body1, *box_body2;
@@ -1283,6 +1421,7 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1283 1421
1284 // Get the screen size. 1422 // Get the screen size.
1285 elm_win_screen_size_get(gld->win, &gld->win_x, &gld->win_y, &gld->scr_w, &gld->scr_h); 1423 elm_win_screen_size_get(gld->win, &gld->win_x, &gld->win_y, &gld->scr_w, &gld->scr_h);
1424 gld->win_x = gld->win_x + (gld->scr_w / 3);
1286 gld->win_w = gld->scr_w / 2; 1425 gld->win_w = gld->scr_w / 2;
1287 gld->win_h = gld->scr_h - 30; 1426 gld->win_h = gld->scr_h - 30;
1288 1427
@@ -1304,25 +1443,64 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1304 elm_win_resize_object_add(gld->win, gld->bx); 1443 elm_win_resize_object_add(gld->win, gld->bx);
1305 evas_object_show(gld->bx); 1444 evas_object_show(gld->bx);
1306 1445
1307// TODO - add the main menu here, in a toolbar, in the box. The windows still need their own menus, just different from the ones we have now. 1446 overlay_add(gld);
1447 woMan_add(gld);
1448 chat_add(gld);
1308 1449
1309#if 1 1450 // Gotta do this after adding the windows, otherwise the menu renders under the window.
1310 // In theory this should create an EWS window, in practice, I'm not seeing any difference. 1451 // This sucks, gotta redefine this menu each time we create a new window?
1311 // 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. 1452 // Also, GL focus gets lost when any menu is used. sigh
1312// elm_config_engine_set("ews"); 1453
1313 win3 = elm_win_add(gld->win, "inlined", ELM_WIN_INLINED_IMAGE); 1454 // A toolbar thingy.
1314 evas_object_event_callback_add(elm_win_inlined_image_object_get(win3), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld); 1455 tb = elm_toolbar_add(gld->win);
1315 elm_win_alpha_set(win3, EINA_TRUE); 1456 evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
1316 fill(gld, win3); 1457 evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
1317 // image object for win3 is unlinked to its pos/size - so manual control 1458 elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_SCROLL);
1318 // this allows also for using map and other things with it. 1459 elm_toolbar_align_set(tb, 0.0);
1319 evas_object_move(elm_win_inlined_image_object_get(win3), 13, 13); 1460
1320 // Odd, it needs to be resized twice. WTF? 1461 // Menus.
1321 evas_object_resize(win3, gld->win_w / 3, gld->win_h / 3); 1462 menu = _toolbar_menu_add(gld->win, tb, "file");
1322 evas_object_resize(elm_win_inlined_image_object_get(win3), gld->win_w / 3, gld->win_h / 3); 1463 elm_menu_item_add(menu, menu_it, NULL, "quit", _on_done, gld);
1323 evas_object_show(win3); 1464
1324 create_handles(elm_win_inlined_image_object_get(win3)); 1465 menu = _toolbar_menu_add(gld->win, tb, "edit");
1325#endif 1466 elm_menu_item_add(menu, menu_it, NULL, "preferences", NULL, NULL);
1467
1468 menu = _toolbar_menu_add(gld->win, tb, "view");
1469 menu = _toolbar_menu_add(gld->win, tb, "world");
1470 menu = _toolbar_menu_add(gld->win, tb, "tools");
1471
1472 menu = _toolbar_menu_add(gld->win, tb, "help");
1473 elm_menu_item_add(menu, menu_it, NULL, "grid help", NULL, NULL);
1474 elm_menu_item_separator_add(menu, menu_it);
1475 elm_menu_item_add(menu, menu_it, NULL, "extantz blogs", NULL, NULL);
1476 elm_menu_item_add(menu, menu_it, NULL, "extantz forum", NULL, NULL);
1477 elm_menu_item_separator_add(menu, menu_it);
1478 elm_menu_item_add(menu, menu_it, NULL, "about extantz", NULL, NULL);
1479
1480 menu = _toolbar_menu_add(gld->win, tb, "advanced");
1481 elm_menu_item_add(menu, menu_it, NULL, "debug settings", NULL, NULL);
1482
1483 menu = _toolbar_menu_add(gld->win, tb, "god");
1484
1485 // Other stuff in the toolbar.
1486 tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
1487 elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
1488 tb_it = elm_toolbar_item_append(tb, NULL, "restriction icons", NULL, NULL);
1489 tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
1490 elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
1491 tb_it = elm_toolbar_item_append(tb, NULL, "hop://localhost/Anarchadia 152, 155, 51 - Lost plot (Adult)", NULL, NULL);
1492 tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
1493 elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
1494 tb_it = elm_toolbar_item_append(tb, NULL, "date time:o'clock", NULL, NULL);
1495
1496 // The toolbar needs to be packed into the box AFTER the menus are added.
1497 evas_object_show(tb);
1498 elm_box_pack_start(gld->bx, tb);
1499
1500 // This does elm_box_pack_end(), so needs to be after the others.
1501 init_evas_gl(gld);
1502
1503 evas_object_show(gld->bx);
1326 1504
1327#if USE_PHYSICS 1505#if USE_PHYSICS
1328 // ePhysics stuff. 1506 // ePhysics stuff.
@@ -1376,14 +1554,12 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1376 ephysics_world_gravity_set(world, 0, 0, 0); 1554 ephysics_world_gravity_set(world, 0, 0, 0);
1377#endif 1555#endif
1378 1556
1379 // This does a elm_box_pack_end(), so needs to be after the others.
1380 init_evas_gl(gld);
1381 evas_object_show(gld->win);
1382
1383 evas_object_move(gld->win, gld->win_x, gld->win_y); 1557 evas_object_move(gld->win, gld->win_x, gld->win_y);
1384 evas_object_resize(gld->win, gld->win_w, gld->win_h); 1558 evas_object_resize(gld->win, gld->win_w, gld->win_h);
1385 evas_object_show(gld->win); 1559 evas_object_show(gld->win);
1386 1560
1561 _resize_winwin(gld);
1562
1387 elm_run(); 1563 elm_run();
1388 1564
1389#if USE_PHYSICS 1565#if USE_PHYSICS
diff --git a/ClientHamr/extantz/extantz.h b/ClientHamr/extantz/extantz.h
index af0c1d3..afb94af 100644
--- a/ClientHamr/extantz/extantz.h
+++ b/ClientHamr/extantz/extantz.h
@@ -147,7 +147,7 @@ struct _Gear
147// GL related data here. 147// GL related data here.
148struct _GLData 148struct _GLData
149{ 149{
150 Evas_Object *win; 150 Evas_Object *win, *winwin;
151 151
152 Ecore_Evas *ee; 152 Ecore_Evas *ee;
153 Evas *canvas; 153 Evas *canvas;
@@ -173,7 +173,6 @@ struct _GLData
173 int doneIrr : 1; 173 int doneIrr : 1;
174 int gearsInited : 1; 174 int gearsInited : 1;
175 int resized : 1; 175 int resized : 1;
176 int camFocus : 1;
177 176
178 Evas_Object *bx, *r1; 177 Evas_Object *bx, *r1;
179 Ecore_Animator *animator; 178 Ecore_Animator *animator;