summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSungtaek Hong <sth253.hong@samsung.com>2017-09-19 17:32:09 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-09-19 18:18:07 +0900
commit40e23ca4593358574b2d9cfb62873fda7dce1c1c (patch)
tree10dd8a1b2d181ced3e519534c4128287cefade99
parent525b6bb1d9cca01b100f8aedb533f3ffda190437 (diff)
efl_ui_image: add new scale type: EFL_UI_IMAGE_SCALE_TYPE_TILE
Summary: Tile is common type which can be used eg: background. This is added to scale type which can be set/get by efl_ui_image_scale_type_set/get() @feature Test Plan: Run elementary test Run Image Scale Type Check radio "Tile". Reviewers: jpeg, cedric, woohyun Differential Revision: https://phab.enlightenment.org/D5119
-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.c31
-rw-r--r--src/lib/elementary/efl_ui_image.eo1
4 files changed, 97 insertions, 12 deletions
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 93282b5b02..87bd979330 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -272,6 +272,7 @@ void test_ui_clock(void *data, Evas_Object *obj, void *event_info);
272void test_popup(void *data, Evas_Object *obj, void *event_info); 272void test_popup(void *data, Evas_Object *obj, void *event_info);
273void test_dayselector(void *data, Evas_Object *obj, void *event_info); 273void test_dayselector(void *data, Evas_Object *obj, void *event_info);
274void test_image(void *data, Evas_Object *obj, void *event_info); 274void test_image(void *data, Evas_Object *obj, void *event_info);
275void test_image_scale_type(void *data, Evas_Object *obj, void *event_info);
275void test_image_swallow_align(void *data, Evas_Object *obj, void *event_info); 276void test_image_swallow_align(void *data, Evas_Object *obj, void *event_info);
276void test_remote_image(void *data, Evas_Object *obj, void *event_info); 277void test_remote_image(void *data, Evas_Object *obj, void *event_info);
277void test_click_image(void *data, Evas_Object *obj, void *event_info); 278void test_click_image(void *data, Evas_Object *obj, void *event_info);
@@ -688,6 +689,7 @@ add_tests:
688 ADD_TEST(NULL, "Images", "Photo", test_photo); 689 ADD_TEST(NULL, "Images", "Photo", test_photo);
689 ADD_TEST(NULL, "Images", "Thumb", test_thumb); 690 ADD_TEST(NULL, "Images", "Thumb", test_thumb);
690 ADD_TEST(NULL, "Images", "Image", test_image); 691 ADD_TEST(NULL, "Images", "Image", test_image);
692 ADD_TEST(NULL, "Images", "Image Scale Type", test_image_scale_type);
691 ADD_TEST(NULL, "Images", "Image Align", test_image_swallow_align); 693 ADD_TEST(NULL, "Images", "Image Align", test_image_swallow_align);
692 ADD_TEST(NULL, "Images", "Image Remote", test_remote_image); 694 ADD_TEST(NULL, "Images", "Image Remote", test_remote_image);
693 ADD_TEST(NULL, "Images", "Image Click", test_click_image); 695 ADD_TEST(NULL, "Images", "Image Click", test_click_image);
diff --git a/src/bin/elementary/test_image.c b/src/bin/elementary/test_image.c
index 922a8a98fe..8f4f2e9c4b 100644
--- a/src/bin/elementary/test_image.c
+++ b/src/bin/elementary/test_image.c
@@ -98,6 +98,81 @@ im_align_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
98 printf("align %.3f %.3f\n", h, v); 98 printf("align %.3f %.3f\n", h, v);
99} 99}
100 100
101static const struct {
102 Efl_Ui_Image_Scale_Type scale_type;
103 const char *name;
104} images_scale_type[] = {
105 { EFL_UI_IMAGE_SCALE_TYPE_NONE, "None" },
106 { EFL_UI_IMAGE_SCALE_TYPE_FILL, "Fill" },
107 { EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE, "Fit Inside" },
108 { EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE, "Fit Outside" },
109 { EFL_UI_IMAGE_SCALE_TYPE_TILE, "Tile" },
110 { 0, NULL }
111};
112
113static void
114my_im_scale_ch(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
115{
116 Evas_Object *win = data;
117 Evas_Object *im = evas_object_data_get(win, "im");
118 Evas_Object *rdg = evas_object_data_get(win, "rdg");
119 int v = elm_radio_value_get(rdg);
120
121 efl_ui_image_scale_type_set(im, images_scale_type[v].scale_type);
122 fprintf(stderr, "Set %d[%s] and got %d\n",
123 images_scale_type[v].scale_type, images_scale_type[v].name, efl_ui_image_scale_type_get(im));
124}
125
126void
127test_image_scale_type(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
128{
129 Evas_Object *win, *box, *im, *rd, *rdg = NULL;
130 int i;
131
132 win = elm_win_util_standard_add("image test scale type", "Image Test Scale Type");
133 elm_win_autodel_set(win, EINA_TRUE);
134
135 box = elm_box_add(win);
136 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
137 elm_win_resize_object_add(win, box);
138 evas_object_show(box);
139
140 im = efl_add(EFL_UI_IMAGE_CLASS, win);
141 char buf[PATH_MAX];
142 snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
143 elm_image_file_set(im, buf, NULL);
144 evas_object_size_hint_weight_set(im, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
145 evas_object_size_hint_align_set(im, EVAS_HINT_FILL, EVAS_HINT_FILL);
146 elm_box_pack_end(box, im);
147 evas_object_show(im);
148
149 evas_object_data_set(win, "im", im);
150
151 for (i = 0; images_scale_type[i].name; ++i)
152 {
153 rd = elm_radio_add(win);
154 evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, EVAS_HINT_FILL);
155 evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
156 elm_radio_state_value_set(rd, i);
157 elm_object_text_set(rd, images_scale_type[i].name);
158 elm_box_pack_end(box, rd);
159 evas_object_show(rd);
160 evas_object_smart_callback_add(rd, "changed", my_im_scale_ch, win);
161 if (!rdg)
162 {
163 rdg = rd;
164 evas_object_data_set(win, "rdg", rdg);
165 }
166 else
167 {
168 elm_radio_group_add(rd, rdg);
169 }
170 }
171
172 evas_object_resize(win, 320, 480);
173 evas_object_show(win);
174}
175
101void 176void
102test_image_swallow_align(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 177test_image_swallow_align(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
103{ 178{
diff --git a/src/lib/elementary/efl_ui_image.c b/src/lib/elementary/efl_ui_image.c
index f27daba6db..c68b52aff7 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -153,18 +153,18 @@ _img_new(Evas_Object *obj)
153static void 153static void
154_image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img) 154_image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img)
155{ 155{
156 Evas_Coord x = 0, y = 0, w = 1, h = 1;
156 157
157 if (efl_isa(img, EDJE_OBJECT_CLASS)) 158 if (efl_isa(img, EDJE_OBJECT_CLASS))
158 { 159 {
159 evas_object_move(img, sd->img_x, sd->img_y); 160 x = sd->img_x;
160 evas_object_resize(img, sd->img_w, sd->img_h); 161 y = sd->img_y;
161 162 w = sd->img_w;
162 evas_object_move(sd->hit_rect, sd->img_x, sd->img_y); 163 h = sd->img_h;
163 evas_object_resize(sd->hit_rect, sd->img_w, sd->img_h); 164 goto done;
164 } 165 }
165 else 166 else
166 { 167 {
167 Evas_Coord x = 0, y = 0, w = 1, h = 1;
168 double alignh = 0.5, alignv = 0.5; 168 double alignh = 0.5, alignv = 0.5;
169 int iw = 0, ih = 0, offset_x = 0, offset_y = 0; 169 int iw = 0, ih = 0, offset_x = 0, offset_y = 0;
170 170
@@ -222,6 +222,13 @@ _image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img)
222 h = ih; 222 h = ih;
223 } 223 }
224 break; 224 break;
225 case EFL_UI_IMAGE_SCALE_TYPE_TILE:
226 x = sd->img_x;
227 y = sd->img_y;
228 w = sd->img_w;
229 h = sd->img_h;
230 evas_object_image_fill_set(img, x, y, iw, ih);
231 goto done;
225 } 232 }
226 233
227 //3. Calculate offset according to align value 234 //3. Calculate offset according to align value
@@ -259,13 +266,13 @@ _image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img)
259 y = sd->img_y; 266 y = sd->img_y;
260 h = sd->img_h; 267 h = sd->img_h;
261 } 268 }
262
263 evas_object_move(img, x, y);
264 evas_object_resize(img, w, h);
265
266 evas_object_move(sd->hit_rect, x, y);
267 evas_object_resize(sd->hit_rect, w, h);
268 } 269 }
270done:
271 evas_object_move(img, x, y);
272 evas_object_resize(img, w, h);
273
274 evas_object_move(sd->hit_rect, x, y);
275 evas_object_resize(sd->hit_rect, w, h);
269} 276}
270 277
271static void 278static void
diff --git a/src/lib/elementary/efl_ui_image.eo b/src/lib/elementary/efl_ui_image.eo
index 5810e5508a..124c51854c 100644
--- a/src/lib/elementary/efl_ui_image.eo
+++ b/src/lib/elementary/efl_ui_image.eo
@@ -19,6 +19,7 @@ enum Efl.Ui.Image.Scale_Type
19 At least one of the dimensions of the image 19 At least one of the dimensions of the image
20 should be equal to the corresponding 20 should be equal to the corresponding
21 dimension of the object.]] 21 dimension of the object.]]
22 tile, [[Tile image at its original size.]]
22 none [[Not scale the internal image]] 23 none [[Not scale the internal image]]
23} 24}
24 25