diff options
author | David Walter Seikel | 2016-03-13 20:05:53 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-03-13 20:05:53 +1000 |
commit | 3729e986a4e1f93b0a5209d61ede1dfe59019664 (patch) | |
tree | bf487cbd960cb6bdb4c537c17abb2ca39cd31163 /src/extantz/scenri.c | |
parent | Update to new eo_* syntax. (diff) | |
download | SledjHamr-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/scenri.c | 82 |
1 files changed, 53 insertions, 29 deletions
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 | ||
139 | static void _on_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo) | 139 | static 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)); | 187 | static 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 | ||
181 | static void _on_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo) | 204 | static 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); |