aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-03-13 20:05:53 +1000
committerDavid Walter Seikel2016-03-13 20:05:53 +1000
commit3729e986a4e1f93b0a5209d61ede1dfe59019664 (patch)
treebf487cbd960cb6bdb4c537c17abb2ca39cd31163 /src
parentUpdate to new eo_* syntax. (diff)
downloadSledjHamr-3729e986a4e1f93b0a5209d61ede1dfe59019664.zip
SledjHamr-3729e986a4e1f93b0a5209d61ede1dfe59019664.tar.gz
SledjHamr-3729e986a4e1f93b0a5209d61ede1dfe59019664.tar.bz2
SledjHamr-3729e986a4e1f93b0a5209d61ede1dfe59019664.tar.xz
Different way of dealing with object popups, run a timer, check for mouse inactivity.
Diffstat (limited to '')
-rw-r--r--src/extantz/extantz.c8
-rw-r--r--src/extantz/extantz.h7
-rw-r--r--src/extantz/scenri.c82
3 files changed, 68 insertions, 29 deletions
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c
index b5f272e..d20edb5 100644
--- a/src/extantz/extantz.c
+++ b/src/extantz/extantz.c
@@ -226,6 +226,7 @@ static void _on_resize(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA
226{ 226{
227 globals *ourGlobals = data; 227 globals *ourGlobals = data;
228 GLData *gld = &ourGlobals->gld; 228 GLData *gld = &ourGlobals->gld;
229 Scene_Data *scene = ourGlobals->scene;
229 Evas_Coord h; 230 Evas_Coord h;
230 231
231 efl_gfx_size_get(ourGlobals->win, &ourGlobals->win_w, &ourGlobals->win_h); 232 efl_gfx_size_get(ourGlobals->win, &ourGlobals->win_w, &ourGlobals->win_h);
@@ -237,6 +238,13 @@ static void _on_resize(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA
237 efl_gfx_size_set(ourGlobals->win, ourGlobals->win_w, h); 238 efl_gfx_size_set(ourGlobals->win, ourGlobals->win_w, h);
238 // Stop internal windows going under the toolbar. 239 // Stop internal windows going under the toolbar.
239 evas_object_resize(ourGlobals->mainWindow->layout, ourGlobals->win_w, h); 240 evas_object_resize(ourGlobals->mainWindow->layout, ourGlobals->win_w, h);
241
242 if (scene)
243 {
244 evas_object_geometry_get(scene->image_e, &scene->x, &scene->y, &scene->w, &scene->h);
245 evas_canvas3d_scene_size_get(scene->scene, &scene->scene_w, &scene->scene_h);
246 }
247
240#if USE_EPHYSICS 248#if USE_EPHYSICS
241 if (ourGlobals->world) 249 if (ourGlobals->world)
242 ephysics_world_render_geometry_set(ourGlobals->world, 0, 0, -50, ourGlobals->win_w, ourGlobals->win_h, 100); 250 ephysics_world_render_geometry_set(ourGlobals->world, 0, 0, -50, ourGlobals->win_w, ourGlobals->win_h, 100);
diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h
index ea22879..2930642 100644
--- a/src/extantz/extantz.h
+++ b/src/extantz/extantz.h
@@ -139,6 +139,13 @@ typedef struct _Scene_Data
139{ 139{
140 Evas *evas; 140 Evas *evas;
141 Evas_Object *image, *image_e; // Our Elm image, and it's Evas image. 141 Evas_Object *image, *image_e; // Our Elm image, and it's Evas image.
142
143 Evas_Coord x, y, w, h; // Position and size of our render image.
144 int scene_w, scene_h; // Size of the scene.
145
146 int tick; // For tracking mouse movements for tooltips.
147 Evas_Coord mouse_x, mouse_y;
148
142 Eo *scene; 149 Eo *scene;
143 Eo *root_node; 150 Eo *root_node;
144 Eo *camera_node; 151 Eo *camera_node;
diff --git a/src/extantz/scenri.c b/src/extantz/scenri.c
index a487d47..7662a96 100644
--- a/src/extantz/scenri.c
+++ b/src/extantz/scenri.c
@@ -136,46 +136,69 @@ Eina_Bool animateScene(globals *ourGlobals)
136 return EINA_TRUE; 136 return EINA_TRUE;
137} 137}
138 138
139static void _on_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo) 139static Eina_Bool _tourGuide(void *data)
140{ 140{
141 Scene_Data *scene = data; 141 Scene_Data *scene = data;
142 Evas_Event_Mouse_Move *ev = einfo;
143 Evas_Coord x, y, w, h;
144 Evas_Coord obj_x, obj_y;
145 int scene_w, scene_h;
146 Evas_Real scene_x, scene_y;
147 Evas_Real s, t;
148 Eo *n;
149 Eo *m;
150 Eina_Bool pick;
151 char *name = NULL;
152 142
153 evas_object_geometry_get(o, &x, &y, &w, &h); 143 if (0 < scene->tick) // Mouse has moved since last time we checked.
144 scene->tick = 0;
145 else if (0 == scene->tick) // Mouse has not moved since last time we checked.
146 {
147 Evas_Coord obj_x, obj_y;
148 Evas_Real scene_x, scene_y;
149 Evas_Real s, t;
150 Eo *n;
151 Eo *m;
152 Eina_Bool pick;
153 char *name = NULL;
154
155 scene->tick--; // Only do this once.
156
157 // Subtract image position from mouse coords. Cancel any offset.
158 obj_x = scene->mouse_x - scene->x;
159 obj_y = scene->mouse_y - scene->y;
160
161 // Multiply the adjusted mouse coords by the ratio of widths.
162 scene_x = obj_x * scene->scene_w / (Evas_Real)scene->w;
163 scene_y = obj_y * scene->scene_h / (Evas_Real)scene->h;
164
165 // Figure out what that points to.
166 pick = evas_canvas3d_scene_pick(scene->scene, scene_x, scene_y, &n, &m, &s, &t);
167 if (pick)
168 name = evas_object_data_get(n, "Name");
169 // This is a raw Evas callback, on the Elm image internal Evas_Object.
170 // So we need to get the Elm Image back from the raw Evas_Object.
171 // Which is why we stuffed it in the scene structure.
172 if (name)
173 {
174 elm_object_tooltip_text_set(scene->image, name);
175 elm_object_tooltip_show(scene->image);
176 }
177 else
178 {
179 elm_object_tooltip_text_set(scene->image, "");
180 elm_object_tooltip_hide(scene->image);
181 }
182 }
154 183
155 obj_x = ev->cur.canvas.x - x; 184 return ECORE_CALLBACK_RENEW;
156 obj_y = ev->cur.canvas.y - y; 185}
157 186
158 eo_do(scene->scene, evas_canvas3d_scene_size_get(&scene_w, &scene_h)); 187static void _on_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo)
188{
189 Scene_Data *scene = data;
190 Evas_Event_Mouse_Move *ev = einfo;
159 191
160 scene_x = obj_x * scene_w / (Evas_Real)w; 192 scene->mouse_x = ev->cur.canvas.x;
161 scene_y = obj_y * scene_h / (Evas_Real)h; 193 scene->mouse_y = ev->cur.canvas.y;
162 194
163 eo_do(scene->scene, pick = evas_canvas3d_scene_pick(scene_x, scene_y, &n, &m, &s, &t)); 195 if (0 == scene->tick) // First move.
164 if (pick)
165 name = evas_object_data_get(n, "Name");
166 // This is a raw Evas callback, on the Elm image internal Evas_Object.
167 // So we need to get the Elm Image back from the raw Evas_Object.
168 // Which is why we stuffed it in the scene structure.
169 if (name)
170 {
171 elm_object_tooltip_text_set(scene->image, name);
172 elm_object_tooltip_show(scene->image);
173 }
174 else
175 { 196 {
176 elm_object_tooltip_text_set(scene->image, ""); 197 elm_object_tooltip_text_set(scene->image, "");
177 elm_object_tooltip_hide(scene->image); 198 elm_object_tooltip_hide(scene->image);
178 } 199 }
200 // Mark mouse as having moved.
201 scene->tick++;
179} 202}
180 203
181static void _on_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo) 204static void _on_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo)
@@ -456,6 +479,7 @@ Scene_Data *scenriAdd(Evas_Object *win)
456 // Action? 479 // Action?
457 elm_object_tooltip_text_set(scene->image, ""); 480 elm_object_tooltip_text_set(scene->image, "");
458 elm_object_tooltip_hide(scene->image); 481 elm_object_tooltip_hide(scene->image);
482 ecore_timer_add(0.2, _tourGuide, scene);
459 483
460#if USE_ELM_IMG 484#if USE_ELM_IMG
461 evas_obj_image_scene_set(scene->image_e, scene->scene); 485 evas_obj_image_scene_set(scene->image_e, scene->scene);