aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-02 05:31:03 +1000
committerDavid Walter Seikel2014-05-02 05:31:03 +1000
commit612b61537c59a9844532519fc0d6190f381dd921 (patch)
treecde7d1e8482b0b741fb61ef038137eeec0dc93af /src
parentUse Elm resizing, which removes a bunch of stuff. (diff)
downloadSledjHamr-612b61537c59a9844532519fc0d6190f381dd921.zip
SledjHamr-612b61537c59a9844532519fc0d6190f381dd921.tar.gz
SledjHamr-612b61537c59a9844532519fc0d6190f381dd921.tar.bz2
SledjHamr-612b61537c59a9844532519fc0d6190f381dd921.tar.xz
Add tooltips for 3D objects.
Diffstat (limited to '')
-rw-r--r--src/GuiLua/GuiLua.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c
index 239a1b7..e01da80 100644
--- a/src/GuiLua/GuiLua.c
+++ b/src/GuiLua/GuiLua.c
@@ -152,6 +152,7 @@ static const char *globName = "ourGlobals";
152 152
153typedef struct _Scene_Data 153typedef struct _Scene_Data
154{ 154{
155 Evas_Object *image; // Our Elm image.
155 Evas_3D_Scene *scene; 156 Evas_3D_Scene *scene;
156 Evas_3D_Node *root_node; 157 Evas_3D_Node *root_node;
157 Evas_3D_Node *camera_node; 158 Evas_3D_Node *camera_node;
@@ -782,9 +783,48 @@ static void _on_click(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
782 } 783 }
783} 784}
784 785
786static void _on_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo)
787{
788 Scene_Data *scene = data;
789 Evas_Event_Mouse_Move *ev = einfo;
790 Evas_Coord x, y, w, h;
791 Evas_Coord obj_x, obj_y;
792 int scene_w, scene_h;
793 Evas_Real scene_x, scene_y;
794 Evas_Real s, t;
795 Evas_3D_Node *n;
796 Evas_3D_Mesh *m;
797 Eina_Bool pick;
798 char *name = NULL;
799
800 evas_object_geometry_get(o, &x, &y, &w, &h);
801
802 obj_x = ev->cur.canvas.x - x;
803 obj_y = ev->cur.canvas.y - y;
804
805 eo_do(scene->scene, evas_3d_scene_size_get(&scene_w, &scene_h));
806
807 scene_x = obj_x * scene_w / (Evas_Real)w;
808 scene_y = obj_y * scene_h / (Evas_Real)h;
809
810 eo_do(scene->scene, pick = evas_3d_scene_pick(scene_x, scene_y, &n, &m, &s, &t));
811 if (pick)
812 name = evas_object_data_get(n, "Name");
813 // This is a raw Evas callback, on the Elm image internal Evas_Object.
814 // So we need to get the Elm Image back from the raw Evas_Object.
815 // Which is why we stuffed it in the scene structure.
816 if (name)
817 {
818 elm_object_tooltip_text_set(scene->image, name);
819 elm_object_tooltip_show(scene->image);
820 }
821 else
822 elm_object_tooltip_hide(scene->image);
823}
824
785static void _on_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo) 825static void _on_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo)
786{ 826{
787// globals *ourGlobals = data; 827 Scene_Data *scene = data;
788 Evas_Event_Mouse_Down *ev = einfo; 828 Evas_Event_Mouse_Down *ev = einfo;
789 Evas_Coord x, y, w, h; 829 Evas_Coord x, y, w, h;
790 Evas_Coord obj_x, obj_y; 830 Evas_Coord obj_x, obj_y;
@@ -801,12 +841,12 @@ static void _on_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void
801 obj_x = ev->canvas.x - x; 841 obj_x = ev->canvas.x - x;
802 obj_y = ev->canvas.y - y; 842 obj_y = ev->canvas.y - y;
803 843
804 eo_do(ourScene.scene, evas_3d_scene_size_get(&scene_w, &scene_h)); 844 eo_do(scene->scene, evas_3d_scene_size_get(&scene_w, &scene_h));
805 845
806 scene_x = obj_x * scene_w / (Evas_Real)w; 846 scene_x = obj_x * scene_w / (Evas_Real)w;
807 scene_y = obj_y * scene_h / (Evas_Real)h; 847 scene_y = obj_y * scene_h / (Evas_Real)h;
808 848
809 eo_do(ourScene.scene, pick = evas_3d_scene_pick(scene_x, scene_y, &n, &m, &s, &t)); 849 eo_do(scene->scene, pick = evas_3d_scene_pick(scene_x, scene_y, &n, &m, &s, &t));
810 if (pick) 850 if (pick)
811 { 851 {
812 name = evas_object_data_get(n, "Name"); 852 name = evas_object_data_get(n, "Name");
@@ -953,6 +993,7 @@ static int window(lua_State *L)
953 993
954 // Add an image object for 3D scene rendering. 994 // Add an image object for 3D scene rendering.
955 obj = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals->win); 995 obj = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals->win);
996 ourScene.image = obj;
956 eo_do(obj, 997 eo_do(obj,
957 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), 998 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
958 elm_obj_image_fill_outside_set(EINA_TRUE), 999 elm_obj_image_fill_outside_set(EINA_TRUE),
@@ -963,7 +1004,11 @@ static int window(lua_State *L)
963 eo_do(temp, 1004 eo_do(temp,
964 evas_obj_image_scene_set(ourScene.scene) 1005 evas_obj_image_scene_set(ourScene.scene)
965 ); 1006 );
966 evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, &ourGlobals); 1007 elm_object_tooltip_text_set(obj, "");
1008 elm_object_tooltip_hide(obj);
1009 // Elm can't seem to be able to tell us WHERE an image was clicked, so use raw Evas calbacks instead.
1010 evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move, &ourScene);
1011 evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, &ourScene);
967 elm_win_resize_object_add(ourGlobals->win, obj); 1012 elm_win_resize_object_add(ourGlobals->win, obj);
968 eo_unref(obj); 1013 eo_unref(obj);
969 1014