diff options
author | David Walter Seikel | 2013-01-15 22:46:10 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-15 22:46:10 +1000 |
commit | 950a9b5a47f1fad663e0868b308906ba353ec47e (patch) | |
tree | 2e9e41a4ebe9efe92e81a844e8eac75000dae5ae /ClientHamr/extantz | |
parent | Move camera and model around until it's properly visible. (diff) | |
download | SledjHamr-950a9b5a47f1fad663e0868b308906ba353ec47e.zip SledjHamr-950a9b5a47f1fad663e0868b308906ba353ec47e.tar.gz SledjHamr-950a9b5a47f1fad663e0868b308906ba353ec47e.tar.bz2 SledjHamr-950a9b5a47f1fad663e0868b308906ba353ec47e.tar.xz |
Move all the GUI stuff into an inlined window.
Oddly enough, this stops the flicker. shrugs
Diffstat (limited to 'ClientHamr/extantz')
-rw-r--r-- | ClientHamr/extantz/extantz.c | 248 |
1 files changed, 176 insertions, 72 deletions
diff --git a/ClientHamr/extantz/extantz.c b/ClientHamr/extantz/extantz.c index 096df16..387c64f 100644 --- a/ClientHamr/extantz/extantz.c +++ b/ClientHamr/extantz/extantz.c | |||
@@ -742,75 +742,33 @@ static void _grid_sel_cb(void *data, Evas_Object *obj, void *event_info) | |||
742 | system(buf); | 742 | system(buf); |
743 | } | 743 | } |
744 | 744 | ||
745 | EAPI_MAIN int elm_main(int argc, char **argv) | 745 | static void |
746 | fill(Evas_Object *win) | ||
746 | { | 747 | { |
747 | Evas_Object *bg, *tb, *bt, *menu, *nf, *tab, *gridList, *viewerList; | 748 | Evas_Object *bg, *bx, *ic, *bb, *av, *en, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu; |
748 | Elm_Object_Item *tb_it, *menu_it, *tab_it; | 749 | Elm_Object_Item *tb_it, *menu_it, *tab_it; |
749 | EPhysics_Body *boundary; | ||
750 | EPhysics_World *world; | ||
751 | EPhysics_Body *box_body1, *box_body2; | ||
752 | Evas_Object *box1, *box2; | ||
753 | GLData *gld = NULL; | ||
754 | char buf[PATH_MAX]; | 750 | char buf[PATH_MAX]; |
755 | int i; | 751 | int i; |
756 | Eina_Bool gotWebKit = elm_need_web(); // Initialise ewebkit if it exists, or return EINA_FALSE if it don't. | ||
757 | |||
758 | // If you want efl to handle finding your bin/lib/data dirs, you must do this below. | ||
759 | elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR); | ||
760 | elm_app_compile_data_dir_set(PACKAGE_DATA_DIR); | ||
761 | elm_app_info_set(elm_main, "datadir", "images/sky_03.jpg"); | ||
762 | fprintf(stdout, "prefix was set to: %s\n", elm_app_prefix_dir_get()); | ||
763 | fprintf(stdout, "data directory is: %s\n", elm_app_data_dir_get()); | ||
764 | fprintf(stdout, "library directory is: %s\n", elm_app_lib_dir_get()); | ||
765 | fprintf(stdout, "locale directory is: %s\n", elm_app_locale_dir_get()); | ||
766 | |||
767 | // These are set via the elementary_config tool, which is hard to find. | ||
768 | elm_config_finger_size_set(0); | ||
769 | elm_config_scale_set(1.0); | ||
770 | |||
771 | // alloc a data struct to hold our relevant gl info in | ||
772 | if (!(gld = calloc(1, sizeof(GLData)))) return; | ||
773 | gldata_init(gld); | ||
774 | |||
775 | // Set the engine to opengl_x11 | ||
776 | if (gld->useEGL) | ||
777 | elm_config_preferred_engine_set("opengl_x11"); | ||
778 | else | ||
779 | elm_config_preferred_engine_set("software_x11"); | ||
780 | gld->win = elm_win_util_standard_add("extantz", "GLView"); | ||
781 | // Set preferred engine back to default from config | ||
782 | elm_config_preferred_engine_set(NULL); | ||
783 | |||
784 | if (!ephysics_init()) | ||
785 | return 1; | ||
786 | |||
787 | elm_win_title_set(gld->win, "extantz virtual world manager"); | ||
788 | evas_object_smart_callback_add(gld->win, "delete,request", _on_done, NULL); | ||
789 | |||
790 | elm_win_screen_size_get(gld->win, &x, &y, &w, &h); | ||
791 | w = w / 5; | ||
792 | h = h - 30; | ||
793 | 752 | ||
794 | bg = elm_bg_add(gld->win); | 753 | // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle. |
795 | elm_bg_load_size_set(bg, w, h); | 754 | // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle. |
796 | elm_bg_option_set(bg, ELM_BG_OPTION_CENTER); | 755 | bg = evas_object_rectangle_add(evas_object_evas_get(win)); |
797 | snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", elm_app_data_dir_get()); | 756 | evas_object_color_set(bg, 200, 0, 200, 200); |
798 | elm_bg_file_set(bg, buf, NULL); | ||
799 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | 757 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); |
800 | elm_win_resize_object_add(gld->win, bg); | 758 | elm_win_resize_object_add(win, bg); |
801 | evas_object_show(bg); | 759 | evas_object_show(bg); |
802 | 760 | ||
803 | gld->bx = elm_box_add(gld->win); | 761 | bx = elm_box_add(win); |
804 | elm_win_resize_object_add(gld->win, gld->bx); | 762 | elm_win_resize_object_add(win, bx); |
805 | evas_object_size_hint_weight_set(gld->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | 763 | evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); |
806 | evas_object_size_hint_align_set(gld->bx, EVAS_HINT_FILL, EVAS_HINT_FILL); | 764 | evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL); |
807 | evas_object_show(gld->bx); | ||
808 | 765 | ||
809 | // A tab thingy. | 766 | // A tab thingy. |
810 | tb = elm_toolbar_add(gld->win); | 767 | tb = elm_toolbar_add(win); |
811 | evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0); | 768 | evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0); |
812 | evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL); | 769 | evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL); |
813 | evas_object_show(tb); | 770 | evas_object_show(tb); |
771 | elm_box_pack_end(bx, tb); | ||
814 | 772 | ||
815 | // Menu. | 773 | // Menu. |
816 | evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0); | 774 | evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0); |
@@ -828,11 +786,10 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
828 | elm_menu_item_separator_add(menu, menu_it); | 786 | elm_menu_item_separator_add(menu, menu_it); |
829 | elm_menu_item_add(menu, menu_it, NULL, "about extantz", NULL, NULL); | 787 | elm_menu_item_add(menu, menu_it, NULL, "about extantz", NULL, NULL); |
830 | elm_menu_item_separator_add(menu, menu_it); | 788 | elm_menu_item_separator_add(menu, menu_it); |
831 | elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, gld->win); | 789 | elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, win); |
832 | elm_toolbar_menu_parent_set(tb, gld->win); | 790 | elm_toolbar_menu_parent_set(tb, win); |
833 | 791 | ||
834 | // Grids stuff | 792 | gridList = elm_genlist_add(win); |
835 | gridList = elm_genlist_add(gld->win); | ||
836 | grids = eina_hash_stringshared_new(free); | 793 | grids = eina_hash_stringshared_new(free); |
837 | 794 | ||
838 | grid_gic = elm_genlist_item_class_new(); | 795 | grid_gic = elm_genlist_item_class_new(); |
@@ -880,7 +837,7 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
880 | } | 837 | } |
881 | 838 | ||
882 | // Viewers stuff | 839 | // Viewers stuff |
883 | viewerList = elm_genlist_add(gld->win); | 840 | viewerList = elm_genlist_add(win); |
884 | viewer_gic = elm_genlist_item_class_new(); | 841 | viewer_gic = elm_genlist_item_class_new(); |
885 | viewer_gic->item_style = "double_label"; | 842 | viewer_gic->item_style = "double_label"; |
886 | viewer_gic->func.text_get = _viewer_label_get; | 843 | viewer_gic->func.text_get = _viewer_label_get; |
@@ -902,20 +859,175 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
902 | } | 859 | } |
903 | 860 | ||
904 | // Toolbar pages | 861 | // Toolbar pages |
905 | nf = elm_naviframe_add(gld->win); | 862 | nf = elm_naviframe_add(win); |
906 | evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | 863 | evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); |
907 | evas_object_size_hint_align_set(nf, EVAS_HINT_FILL, EVAS_HINT_FILL); | 864 | evas_object_size_hint_align_set(nf, EVAS_HINT_FILL, EVAS_HINT_FILL); |
908 | evas_object_show(nf); | 865 | evas_object_show(nf); |
909 | tab = viewerList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_visible_set(tab_it, EINA_FALSE); elm_toolbar_item_append(tb, NULL, "Viewers", _promote, tab_it); | 866 | tab = viewerList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_visible_set(tab_it, EINA_FALSE); elm_toolbar_item_append(tb, NULL, "Viewers", _promote, tab_it); |
910 | tab = _content_image_new(gld->win, img3); tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_visible_set(tab_it, EINA_FALSE); elm_toolbar_item_append(tb, NULL, "Landmarks", _promote, tab_it); | 867 | tab = _content_image_new(win, img3); tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_visible_set(tab_it, EINA_FALSE); elm_toolbar_item_append(tb, NULL, "Landmarks", _promote, tab_it); |
911 | tab = gridList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_visible_set(tab_it, EINA_FALSE); elm_toolbar_item_append(tb, NULL, "Grids", _promote, tab_it); | 868 | tab = gridList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_visible_set(tab_it, EINA_FALSE); elm_toolbar_item_append(tb, NULL, "Grids", _promote, tab_it); |
869 | elm_box_pack_end(bx, nf); | ||
912 | 870 | ||
913 | bt = elm_button_add(gld->win); | 871 | bt = elm_button_add(win); |
914 | elm_object_text_set(bt, "Login"); | 872 | elm_object_text_set(bt, "Login"); |
915 | evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); | 873 | evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); |
916 | evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); | 874 | evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); |
917 | evas_object_show(bt); | 875 | evas_object_show(bt); |
918 | // evas_object_smart_callback_add(bt, "clicked", NULL, NULL); | 876 | // evas_object_smart_callback_add(bt, "clicked", NULL, NULL); |
877 | elm_box_pack_end(bx, bt); | ||
878 | |||
879 | evas_object_show(bx); | ||
880 | } | ||
881 | |||
882 | static void | ||
883 | cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) | ||
884 | { | ||
885 | Evas_Event_Mouse_Down *ev = event_info; | ||
886 | |||
887 | if (ev->button == 1) elm_object_focus_set(obj, EINA_TRUE); | ||
888 | } | ||
889 | |||
890 | static void | ||
891 | cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info) | ||
892 | { | ||
893 | Evas_Event_Mouse_Move *ev = event_info; | ||
894 | Evas_Object *orig = data; | ||
895 | Evas_Coord x, y; | ||
896 | Evas_Map *p; | ||
897 | int i, w, h; | ||
898 | |||
899 | if (!ev->buttons) return; | ||
900 | evas_object_geometry_get(obj, &x, &y, NULL, NULL); | ||
901 | evas_object_move(obj, | ||
902 | x + (ev->cur.canvas.x - ev->prev.output.x), | ||
903 | y + (ev->cur.canvas.y - ev->prev.output.y)); | ||
904 | evas_object_image_size_get(orig, &w, &h); | ||
905 | p = evas_map_new(4); | ||
906 | evas_object_map_enable_set(orig, EINA_TRUE); | ||
907 | // evas_object_raise(orig); | ||
908 | for (i = 0; i < 4; i++) | ||
909 | { | ||
910 | Evas_Object *hand; | ||
911 | char key[32]; | ||
912 | |||
913 | snprintf(key, sizeof(key), "h-%i\n", i); | ||
914 | hand = evas_object_data_get(orig, key); | ||
915 | evas_object_raise(hand); | ||
916 | evas_object_geometry_get(hand, &x, &y, NULL, NULL); | ||
917 | x += 15; | ||
918 | y += 15; | ||
919 | evas_map_point_coord_set(p, i, x, y, 0); | ||
920 | if (i == 0) evas_map_point_image_uv_set(p, i, 0, 0); | ||
921 | else if (i == 1) evas_map_point_image_uv_set(p, i, w, 0); | ||
922 | else if (i == 2) evas_map_point_image_uv_set(p, i, w, h); | ||
923 | else if (i == 3) evas_map_point_image_uv_set(p, i, 0, h); | ||
924 | } | ||
925 | evas_object_map_set(orig, p); | ||
926 | evas_map_free(p); | ||
927 | } | ||
928 | |||
929 | static void | ||
930 | create_handles(Evas_Object *obj) | ||
931 | { | ||
932 | int i; | ||
933 | Evas_Coord x, y, w, h; | ||
934 | |||
935 | evas_object_geometry_get(obj, &x, &y, &w, &h); | ||
936 | for (i = 0; i < 4; i++) | ||
937 | { | ||
938 | Evas_Object *hand; | ||
939 | char buf[PATH_MAX]; | ||
940 | char key[32]; | ||
941 | |||
942 | hand = evas_object_image_filled_add(evas_object_evas_get(obj)); | ||
943 | evas_object_resize(hand, 31, 31); | ||
944 | snprintf(buf, sizeof(buf), "%s/images/pt.png", elm_app_data_dir_get()); | ||
945 | evas_object_image_file_set(hand, buf, NULL); | ||
946 | if (i == 0) evas_object_move(hand, x - 15, y - 15); | ||
947 | else if (i == 1) evas_object_move(hand, x + w - 15, y - 15); | ||
948 | else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15); | ||
949 | else if (i == 3) evas_object_move(hand, x - 15, y + h - 15); | ||
950 | evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj); | ||
951 | evas_object_show(hand); | ||
952 | snprintf(key, sizeof(key), "h-%i\n", i); | ||
953 | evas_object_data_set(obj, key, hand); | ||
954 | } | ||
955 | } | ||
956 | |||
957 | EAPI_MAIN int elm_main(int argc, char **argv) | ||
958 | { | ||
959 | Evas_Object *bg, *win3; | ||
960 | EPhysics_Body *boundary; | ||
961 | EPhysics_World *world; | ||
962 | EPhysics_Body *box_body1, *box_body2; | ||
963 | Evas_Object *box1, *box2; | ||
964 | GLData *gld = NULL; | ||
965 | char buf[PATH_MAX]; | ||
966 | int i; | ||
967 | Eina_Bool gotWebKit = elm_need_web(); // Initialise ewebkit if it exists, or return EINA_FALSE if it don't. | ||
968 | |||
969 | // If you want efl to handle finding your bin/lib/data dirs, you must do this below. | ||
970 | elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR); | ||
971 | elm_app_compile_data_dir_set(PACKAGE_DATA_DIR); | ||
972 | elm_app_info_set(elm_main, "datadir", "images/sky_03.jpg"); | ||
973 | fprintf(stdout, "prefix was set to: %s\n", elm_app_prefix_dir_get()); | ||
974 | fprintf(stdout, "data directory is: %s\n", elm_app_data_dir_get()); | ||
975 | fprintf(stdout, "library directory is: %s\n", elm_app_lib_dir_get()); | ||
976 | fprintf(stdout, "locale directory is: %s\n", elm_app_locale_dir_get()); | ||
977 | |||
978 | // These are set via the elementary_config tool, which is hard to find. | ||
979 | elm_config_finger_size_set(0); | ||
980 | elm_config_scale_set(1.0); | ||
981 | |||
982 | // alloc a data struct to hold our relevant gl info in | ||
983 | if (!(gld = calloc(1, sizeof(GLData)))) return; | ||
984 | gldata_init(gld); | ||
985 | |||
986 | // Set the engine to opengl_x11 | ||
987 | if (gld->useEGL) | ||
988 | elm_config_preferred_engine_set("opengl_x11"); | ||
989 | else | ||
990 | elm_config_preferred_engine_set("software_x11"); | ||
991 | gld->win = elm_win_util_standard_add("extantz", "GLView"); | ||
992 | // Set preferred engine back to default from config | ||
993 | elm_config_preferred_engine_set(NULL); | ||
994 | |||
995 | if (!ephysics_init()) | ||
996 | return 1; | ||
997 | |||
998 | elm_win_title_set(gld->win, "extantz virtual world manager"); | ||
999 | evas_object_smart_callback_add(gld->win, "delete,request", _on_done, NULL); | ||
1000 | |||
1001 | elm_win_screen_size_get(gld->win, &x, &y, &w, &h); | ||
1002 | w = w / 5; | ||
1003 | h = h - 30; | ||
1004 | |||
1005 | bg = elm_bg_add(gld->win); | ||
1006 | elm_bg_load_size_set(bg, w, h); | ||
1007 | elm_bg_option_set(bg, ELM_BG_OPTION_CENTER); | ||
1008 | snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", elm_app_data_dir_get()); | ||
1009 | elm_bg_file_set(bg, buf, NULL); | ||
1010 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
1011 | elm_win_resize_object_add(gld->win, bg); | ||
1012 | evas_object_show(bg); | ||
1013 | |||
1014 | gld->bx = elm_box_add(gld->win); | ||
1015 | elm_win_resize_object_add(gld->win, gld->bx); | ||
1016 | evas_object_size_hint_weight_set(gld->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
1017 | evas_object_size_hint_align_set(gld->bx, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
1018 | evas_object_show(gld->bx); | ||
1019 | |||
1020 | win3 = elm_win_add(gld->win, "inlined", ELM_WIN_INLINED_IMAGE); | ||
1021 | elm_win_title_set(win3, "world manager"); | ||
1022 | evas_object_event_callback_add(elm_win_inlined_image_object_get(win3), EVAS_CALLBACK_MOUSE_DOWN, cb_mouse_down, NULL); | ||
1023 | elm_win_alpha_set(win3, EINA_TRUE); | ||
1024 | fill(win3); | ||
1025 | // Odd, it needs to be resized twice? | ||
1026 | evas_object_resize(win3, w - 26, h / 4); | ||
1027 | evas_object_move(elm_win_inlined_image_object_get(win3), 13, 13); | ||
1028 | evas_object_resize(elm_win_inlined_image_object_get(win3), w - 26, h / 4); | ||
1029 | evas_object_show(win3); | ||
1030 | create_handles(elm_win_inlined_image_object_get(win3)); | ||
919 | 1031 | ||
920 | #if USE_PHYSICS | 1032 | #if USE_PHYSICS |
921 | // ePhysics stuff. | 1033 | // ePhysics stuff. |
@@ -969,17 +1081,9 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
969 | ephysics_world_gravity_set(world, 0, 0, 0); | 1081 | ephysics_world_gravity_set(world, 0, 0, 0); |
970 | #endif | 1082 | #endif |
971 | 1083 | ||
972 | elm_box_pack_end(gld->bx, tb); | ||
973 | elm_box_pack_end(gld->bx, nf); | ||
974 | elm_box_pack_end(gld->bx, bt); | ||
975 | |||
976 | // This does an elm_box_pack_end(), so needs to be after the others. | 1084 | // This does an elm_box_pack_end(), so needs to be after the others. |
977 | init_evas_gl(gld, w, h); | 1085 | init_evas_gl(gld, w, h); |
978 | 1086 | ||
979 | // Menu should be above everything else. | ||
980 | // Which apparently wont work. | ||
981 | evas_object_raise(menu); | ||
982 | |||
983 | evas_object_move(gld->win, x, y); | 1087 | evas_object_move(gld->win, x, y); |
984 | evas_object_resize(gld->win, w, h); | 1088 | evas_object_resize(gld->win, w, h); |
985 | evas_object_show(gld->win); | 1089 | evas_object_show(gld->win); |