summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Pinot <ngc891@gmail.com>2013-11-11 08:45:38 +0900
committerJerome Pinot <ngc891@gmail.com>2013-11-11 08:45:38 +0900
commit344e276fad2c0ab1ff5ab20ec972abf268063bd3 (patch)
treec29229ae40f846fe775d3a1d801ffa64ac7cf0bb
parent19ad927e091886e74b1a6b57049bb8035e26c278 (diff)
Add support to save the actual picture using the 's' shortcut. Save in
PNG.
-rw-r--r--src/callbacks.c11
-rw-r--r--src/main.c2
2 files changed, 11 insertions, 2 deletions
diff --git a/src/callbacks.c b/src/callbacks.c
index a198289..e42563e 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -36,16 +36,25 @@ quit(void)
36 36
37/* react to key press */ 37/* react to key press */
38void 38void
39key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info) 39key_down(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info)
40{ 40{
41 Evas_Event_Key_Down *ev; 41 Evas_Event_Key_Down *ev;
42 map_struct *map = (map_struct*)data;
42 char *key; 43 char *key;
44 char buf[256];
45
43 46
44 ev = (Evas_Event_Key_Down *)event_info; 47 ev = (Evas_Event_Key_Down *)event_info;
45 key = ev->keyname; 48 key = ev->keyname;
46 49
47 if (!strcmp(key, "Escape") || !strcmp(key, "q")) 50 if (!strcmp(key, "Escape") || !strcmp(key, "q"))
48 quit(); 51 quit();
52
53 if (!strcmp(key, "s"))
54 {
55 snprintf(buf, sizeof(buf), "efractal_%.4f:%.4f_%.4f:%.4f.png", map->xmin, map->ymin, map->xmax, map->ymax);
56 evas_object_image_save(win.img, buf, NULL, NULL);
57 }
49} 58}
50 59
51/* update pointer coordinate on move */ 60/* update pointer coordinate on move */
diff --git a/src/main.c b/src/main.c
index c5a188f..1e675ae 100644
--- a/src/main.c
+++ b/src/main.c
@@ -149,7 +149,7 @@ main(int argc, char **argv)
149 draw(0, NULL); 149 draw(0, NULL);
150 evas_object_show(win.txt); 150 evas_object_show(win.txt);
151 151
152 evas_object_event_callback_add(win.img, EVAS_CALLBACK_KEY_DOWN, key_down, NULL); 152 evas_object_event_callback_add(win.img, EVAS_CALLBACK_KEY_DOWN, key_down, &map);
153 evas_object_event_callback_add(win.img, EVAS_CALLBACK_MOUSE_DOWN, mouse_down, &map); 153 evas_object_event_callback_add(win.img, EVAS_CALLBACK_MOUSE_DOWN, mouse_down, &map);
154 evas_object_event_callback_add(win.img, EVAS_CALLBACK_MOUSE_MOVE, mouse_over, &map); 154 evas_object_event_callback_add(win.img, EVAS_CALLBACK_MOUSE_MOVE, mouse_over, &map);
155 155