summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorRafael Antognolli <antognolli@gmail.com>2012-08-23 19:49:48 +0000
committerRafael Antognolli <antognolli@gmail.com>2012-08-23 19:49:48 +0000
commitcc2ec4105b3ff8add959c16f400471053f541a2c (patch)
tree28bf6746a0afc339ecb4645c8b57d4f9f4426aee /legacy
parent261c7648a9fe94a98b1ec85c804ca2a21a13d1ac (diff)
evas/examples: Add map to the smart object example.
Rotating the smart object with map, adding a rectangle as child, and then rotating it again will expose a bug on mapped smart objects: it's mapped surface will be reused from cache, instead of flagged as dirty and discarded. SVN revision: 75635
Diffstat (limited to 'legacy')
-rw-r--r--legacy/evas/src/examples/evas-smart-object.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/legacy/evas/src/examples/evas-smart-object.c b/legacy/evas/src/examples/evas-smart-object.c
index 93c4d4ae88..8b65981390 100644
--- a/legacy/evas/src/examples/evas-smart-object.c
+++ b/legacy/evas/src/examples/evas-smart-object.c
@@ -39,6 +39,8 @@ static const char *commands = \
39 "\td - decrease smart object's size\n" 39 "\td - decrease smart object's size\n"
40 "\ti - increase smart object's size\n" 40 "\ti - increase smart object's size\n"
41 "\tc - change smart object's clipper color\n" 41 "\tc - change smart object's clipper color\n"
42 "\t. - rotate object to the right\n"
43 "\t, - rotate object to the left\n"
42 "\th - print help\n" 44 "\th - print help\n"
43 "\tq - quit\n" 45 "\tq - quit\n"
44; 46;
@@ -60,6 +62,7 @@ struct color_tuple
60 int r, g, b, a; 62 int r, g, b, a;
61} clipper_colors[4] = {WHITE, RED, GREEN, BLUE}; 63} clipper_colors[4] = {WHITE, RED, GREEN, BLUE};
62int cur_color = 0; 64int cur_color = 0;
65int cur_angle = 0;
63 66
64static const char * 67static const char *
65_index_to_color(int i) 68_index_to_color(int i)
@@ -443,6 +446,21 @@ evas_smart_example_set_right(Evas_Object *o,
443/* END OF example smart object's own interface */ 446/* END OF example smart object's own interface */
444 447
445static void 448static void
449_map_update(void)
450{
451 Evas_Map *m;
452 Evas_Coord x, y, w, h;
453
454 evas_object_geometry_get(d.smt, &x, &y, &w, &h);
455 m = evas_map_new(4);
456 evas_map_util_points_populate_from_object(m, d.smt);
457 evas_map_util_rotate(m, cur_angle, x + (w / 2), y + (h / 2));
458 evas_object_map_set(d.smt, m);
459 evas_object_map_enable_set(d.smt, EINA_TRUE);
460 evas_map_free(m);
461}
462
463static void
446_on_keydown(void *data __UNUSED__, 464_on_keydown(void *data __UNUSED__,
447 Evas *evas __UNUSED__, 465 Evas *evas __UNUSED__,
448 Evas_Object *o __UNUSED__, 466 Evas_Object *o __UNUSED__,
@@ -569,6 +587,7 @@ _on_keydown(void *data __UNUSED__,
569 } 587 }
570 588
571 evas_object_move(d.smt, x, y); 589 evas_object_move(d.smt, x, y);
590 _map_update();
572 591
573 return; 592 return;
574 } 593 }
@@ -584,6 +603,7 @@ _on_keydown(void *data __UNUSED__,
584 h *= 1.1; 603 h *= 1.1;
585 604
586 evas_object_resize(d.smt, w, h); 605 evas_object_resize(d.smt, w, h);
606 _map_update();
587 607
588 return; 608 return;
589 } 609 }
@@ -599,6 +619,7 @@ _on_keydown(void *data __UNUSED__,
599 h *= 0.9; 619 h *= 0.9;
600 620
601 evas_object_resize(d.smt, w, h); 621 evas_object_resize(d.smt, w, h);
622 _map_update();
602 623
603 return; 624 return;
604 } 625 }
@@ -617,6 +638,23 @@ _on_keydown(void *data __UNUSED__,
617 638
618 return; 639 return;
619 } 640 }
641
642 /* rotate object to the right */
643 if (strcmp(ev->keyname, "period") == 0)
644 {
645 cur_angle = (cur_angle + 30) % 360;
646 _map_update();
647 return;
648 }
649
650 if (strcmp(ev->keyname, "comma") == 0)
651 {
652 cur_angle = (cur_angle - 30) % 360;
653 _map_update();
654 return;
655 }
656
657 fprintf(stderr, "Invalid key: '%s'\n", ev->keyname);
620} 658}
621 659
622static void 660static void