summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_image.c75
-rw-r--r--src/lib/elementary/efl_ui_image.c35
-rw-r--r--src/lib/elementary/efl_ui_widget_image.h2
4 files changed, 96 insertions, 18 deletions
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 114cd7927a..7484a2545d 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -285,6 +285,7 @@ void test_dayselector(void *data, Evas_Object *obj, void *event_info);
285void test_image(void *data, Evas_Object *obj, void *event_info); 285void test_image(void *data, Evas_Object *obj, void *event_info);
286void test_image_scale_type(void *data, Evas_Object *obj, void *event_info); 286void test_image_scale_type(void *data, Evas_Object *obj, void *event_info);
287void test_image_swallow_align(void *data, Evas_Object *obj, void *event_info); 287void test_image_swallow_align(void *data, Evas_Object *obj, void *event_info);
288void test_image_prescale(void *data, Evas_Object *obj, void *event_info);
288void test_remote_image(void *data, Evas_Object *obj, void *event_info); 289void test_remote_image(void *data, Evas_Object *obj, void *event_info);
289void test_click_image(void *data, Evas_Object *obj, void *event_info); 290void test_click_image(void *data, Evas_Object *obj, void *event_info);
290void test_load_image(void *data, Evas_Object *obj, void *event_info); 291void test_load_image(void *data, Evas_Object *obj, void *event_info);
@@ -773,6 +774,7 @@ add_tests:
773 ADD_TEST(NULL, "Images", "Image Remote", test_remote_image); 774 ADD_TEST(NULL, "Images", "Image Remote", test_remote_image);
774 ADD_TEST(NULL, "Images", "Image Click", test_click_image); 775 ADD_TEST(NULL, "Images", "Image Click", test_click_image);
775 ADD_TEST(NULL, "Images", "Image Async Load", test_load_image); 776 ADD_TEST(NULL, "Images", "Image Async Load", test_load_image);
777 ADD_TEST(NULL, "Images", "Image Prescale", test_image_prescale);
776 ADD_TEST(NULL, "Images", "Slideshow", test_slideshow); 778 ADD_TEST(NULL, "Images", "Slideshow", test_slideshow);
777 ADD_TEST(NULL, "Images", "Video", test_video); 779 ADD_TEST(NULL, "Images", "Video", test_video);
778 780
diff --git a/src/bin/elementary/test_image.c b/src/bin/elementary/test_image.c
index 08232dff20..0dbdbef0b0 100644
--- a/src/bin/elementary/test_image.c
+++ b/src/bin/elementary/test_image.c
@@ -658,3 +658,78 @@ test_load_image(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve
658 evas_object_resize(win, 320, 480); 658 evas_object_resize(win, 320, 480);
659 evas_object_show(win); 659 evas_object_show(win);
660} 660}
661
662static void
663_cb_prescale_radio_changed(void *data, Evas_Object *obj, void *event EINA_UNUSED)
664{
665 Evas_Object *o_bg = data;
666 int size;
667 size = elm_radio_value_get((Evas_Object *)obj);
668 elm_image_prescale_set(o_bg, size);
669}
670
671void
672test_image_prescale(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
673{
674 Evas_Object *win, *im;
675 Evas_Object *box, *hbox;
676 Evas_Object *rd, *rdg;
677 char buf[PATH_MAX];
678
679
680 win = elm_win_util_standard_add("image-prescale", "Image Prescale Test");
681 elm_win_autodel_set(win, EINA_TRUE);
682
683 box = elm_box_add(win);
684 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
685 elm_win_resize_object_add(win, box);
686 evas_object_show(box);
687
688 im = elm_image_add(win);
689 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
690 elm_image_file_set(im, buf, NULL);
691 evas_object_size_hint_weight_set(im, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
692 evas_object_size_hint_align_set(im, EVAS_HINT_FILL, EVAS_HINT_FILL);
693 elm_box_pack_end(box, im);
694 evas_object_show(im);
695
696 hbox = elm_box_add(win);
697 elm_box_horizontal_set(hbox, EINA_TRUE);
698 evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
699 evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
700
701 rd = elm_radio_add(win);
702 elm_radio_state_value_set(rd, 50);
703 elm_object_text_set(rd, "50");
704 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
705 evas_object_smart_callback_add(rd, "changed", _cb_prescale_radio_changed, im);
706 elm_box_pack_end(hbox, rd);
707 evas_object_show(rd);
708 rdg = rd;
709
710 rd = elm_radio_add(win);
711 elm_radio_state_value_set(rd, 100);
712 elm_radio_group_add(rd, rdg);
713 elm_object_text_set(rd, "100");
714 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
715 evas_object_smart_callback_add(rd, "changed", _cb_prescale_radio_changed, im);
716 elm_box_pack_end(hbox, rd);
717 evas_object_show(rd);
718
719 rd = elm_radio_add(win);
720 elm_radio_state_value_set(rd, 200);
721 elm_radio_group_add(rd, rdg);
722 elm_object_text_set(rd, "200");
723 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
724 evas_object_smart_callback_add(rd, "changed", _cb_prescale_radio_changed, im);
725 elm_box_pack_end(hbox, rd);
726 evas_object_show(rd);
727
728 elm_radio_value_set(rdg, 200);
729
730 elm_box_pack_end(box, hbox);
731 evas_object_show(hbox);
732
733 evas_object_resize(win, 320, 320);
734 evas_object_show(win);
735}
diff --git a/src/lib/elementary/efl_ui_image.c b/src/lib/elementary/efl_ui_image.c
index 696413df8e..35ee4e7c37 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -578,7 +578,7 @@ _efl_ui_image_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Image_Data *priv)
578 priv->smooth = EINA_TRUE; 578 priv->smooth = EINA_TRUE;
579 priv->fill_inside = EINA_TRUE; 579 priv->fill_inside = EINA_TRUE;
580 priv->aspect_fixed = EINA_TRUE; 580 priv->aspect_fixed = EINA_TRUE;
581 priv->load_size = 0; 581 priv->load_size = EINA_SIZE2D(0, 0);
582 priv->scale = 1.0; 582 priv->scale = 1.0;
583 priv->scale_up = EINA_TRUE; 583 priv->scale_up = EINA_TRUE;
584 priv->scale_down = EINA_TRUE; 584 priv->scale_down = EINA_TRUE;
@@ -810,6 +810,16 @@ _efl_ui_image_sizing_eval(Evas_Object *obj)
810} 810}
811 811
812static void 812static void
813_efl_ui_image_load_size_set_internal(Evas_Object *obj, Efl_Ui_Image_Data *sd)
814{
815 Eina_Size2D sz = sd->load_size;
816
817 if ((sz.w <= 0) || (sz.h <= 0))
818 sz = efl_gfx_view_size_get(obj);
819 evas_object_image_load_size_set(sd->img, sz.w, sz.h);
820}
821
822static void
813_efl_ui_image_file_set_do(Evas_Object *obj) 823_efl_ui_image_file_set_do(Evas_Object *obj)
814{ 824{
815 Evas_Object *pclip = NULL; 825 Evas_Object *pclip = NULL;
@@ -831,13 +841,7 @@ _efl_ui_image_file_set_do(Evas_Object *obj)
831 841
832 sd->edje = EINA_FALSE; 842 sd->edje = EINA_FALSE;
833 843
834 if (sd->load_size > 0) 844 _efl_ui_image_load_size_set_internal(obj, sd);
835 evas_object_image_load_size_set(sd->img, sd->load_size, sd->load_size);
836 else
837 {
838 Eina_Size2D sz = efl_gfx_view_size_get(obj);
839 evas_object_image_load_size_set(sd->img, sz.w, sz.h);
840 }
841} 845}
842 846
843static void 847static void
@@ -1283,30 +1287,27 @@ elm_image_prescale_set(Evas_Object *obj,
1283} 1287}
1284 1288
1285EOLIAN static void 1289EOLIAN static void
1286_efl_ui_image_efl_image_load_load_size_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, Eina_Size2D sz) 1290_efl_ui_image_efl_image_load_load_size_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Size2D sz)
1287{ 1291{
1288 // FIXME: This should handle both dimensions! 1292 sd->load_size = sz;
1289 if (sz.w > sz.h) 1293 _efl_ui_image_load_size_set_internal(obj, sd);
1290 sd->load_size = sz.w;
1291 else
1292 sd->load_size = sz.h;
1293} 1294}
1294 1295
1295EAPI int 1296EAPI int
1296elm_image_prescale_get(const Evas_Object *obj) 1297elm_image_prescale_get(const Evas_Object *obj)
1297{ 1298{
1298 Eina_Size2D sz; 1299 Eina_Size2D sz;
1299
1300 EFL_UI_IMAGE_CHECK(obj) 0; 1300 EFL_UI_IMAGE_CHECK(obj) 0;
1301 1301
1302 sz = efl_image_load_size_get(obj); 1302 sz = efl_image_load_size_get(obj);
1303 return sz.w; 1303
1304 return MAX(sz.w, sz.h);
1304} 1305}
1305 1306
1306EOLIAN static Eina_Size2D 1307EOLIAN static Eina_Size2D
1307_efl_ui_image_efl_image_load_load_size_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd) 1308_efl_ui_image_efl_image_load_load_size_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
1308{ 1309{
1309 return EINA_SIZE2D(sd->load_size, sd->load_size); 1310 return sd->load_size;
1310} 1311}
1311 1312
1312EOLIAN static void 1313EOLIAN static void
diff --git a/src/lib/elementary/efl_ui_widget_image.h b/src/lib/elementary/efl_ui_widget_image.h
index 88759c4a13..e5c45eb225 100644
--- a/src/lib/elementary/efl_ui_widget_image.h
+++ b/src/lib/elementary/efl_ui_widget_image.h
@@ -61,7 +61,7 @@ struct _Efl_Ui_Image_Data
61 61
62 Evas_Coord img_x, img_y, img_w, img_h; 62 Evas_Coord img_x, img_y, img_w, img_h;
63 63
64 int load_size; 64 Eina_Size2D load_size;
65 int frame_count; 65 int frame_count;
66 int cur_frame; 66 int cur_frame;
67 67