forked from enlightenment/efl
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
This commit is contained in:
parent
525b6bb1d9
commit
40e23ca459
|
@ -272,6 +272,7 @@ void test_ui_clock(void *data, Evas_Object *obj, void *event_info);
|
|||
void test_popup(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_dayselector(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_image(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_image_scale_type(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_image_swallow_align(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_remote_image(void *data, Evas_Object *obj, void *event_info);
|
||||
void test_click_image(void *data, Evas_Object *obj, void *event_info);
|
||||
|
@ -688,6 +689,7 @@ add_tests:
|
|||
ADD_TEST(NULL, "Images", "Photo", test_photo);
|
||||
ADD_TEST(NULL, "Images", "Thumb", test_thumb);
|
||||
ADD_TEST(NULL, "Images", "Image", test_image);
|
||||
ADD_TEST(NULL, "Images", "Image Scale Type", test_image_scale_type);
|
||||
ADD_TEST(NULL, "Images", "Image Align", test_image_swallow_align);
|
||||
ADD_TEST(NULL, "Images", "Image Remote", test_remote_image);
|
||||
ADD_TEST(NULL, "Images", "Image Click", test_click_image);
|
||||
|
|
|
@ -98,6 +98,81 @@ im_align_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
|||
printf("align %.3f %.3f\n", h, v);
|
||||
}
|
||||
|
||||
static const struct {
|
||||
Efl_Ui_Image_Scale_Type scale_type;
|
||||
const char *name;
|
||||
} images_scale_type[] = {
|
||||
{ EFL_UI_IMAGE_SCALE_TYPE_NONE, "None" },
|
||||
{ EFL_UI_IMAGE_SCALE_TYPE_FILL, "Fill" },
|
||||
{ EFL_UI_IMAGE_SCALE_TYPE_FIT_INSIDE, "Fit Inside" },
|
||||
{ EFL_UI_IMAGE_SCALE_TYPE_FIT_OUTSIDE, "Fit Outside" },
|
||||
{ EFL_UI_IMAGE_SCALE_TYPE_TILE, "Tile" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static void
|
||||
my_im_scale_ch(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win = data;
|
||||
Evas_Object *im = evas_object_data_get(win, "im");
|
||||
Evas_Object *rdg = evas_object_data_get(win, "rdg");
|
||||
int v = elm_radio_value_get(rdg);
|
||||
|
||||
efl_ui_image_scale_type_set(im, images_scale_type[v].scale_type);
|
||||
fprintf(stderr, "Set %d[%s] and got %d\n",
|
||||
images_scale_type[v].scale_type, images_scale_type[v].name, efl_ui_image_scale_type_get(im));
|
||||
}
|
||||
|
||||
void
|
||||
test_image_scale_type(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *win, *box, *im, *rd, *rdg = NULL;
|
||||
int i;
|
||||
|
||||
win = elm_win_util_standard_add("image test scale type", "Image Test Scale Type");
|
||||
elm_win_autodel_set(win, EINA_TRUE);
|
||||
|
||||
box = elm_box_add(win);
|
||||
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_win_resize_object_add(win, box);
|
||||
evas_object_show(box);
|
||||
|
||||
im = efl_add(EFL_UI_IMAGE_CLASS, win);
|
||||
char buf[PATH_MAX];
|
||||
snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
|
||||
elm_image_file_set(im, buf, NULL);
|
||||
evas_object_size_hint_weight_set(im, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(im, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(box, im);
|
||||
evas_object_show(im);
|
||||
|
||||
evas_object_data_set(win, "im", im);
|
||||
|
||||
for (i = 0; images_scale_type[i].name; ++i)
|
||||
{
|
||||
rd = elm_radio_add(win);
|
||||
evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
|
||||
elm_radio_state_value_set(rd, i);
|
||||
elm_object_text_set(rd, images_scale_type[i].name);
|
||||
elm_box_pack_end(box, rd);
|
||||
evas_object_show(rd);
|
||||
evas_object_smart_callback_add(rd, "changed", my_im_scale_ch, win);
|
||||
if (!rdg)
|
||||
{
|
||||
rdg = rd;
|
||||
evas_object_data_set(win, "rdg", rdg);
|
||||
}
|
||||
else
|
||||
{
|
||||
elm_radio_group_add(rd, rdg);
|
||||
}
|
||||
}
|
||||
|
||||
evas_object_resize(win, 320, 480);
|
||||
evas_object_show(win);
|
||||
}
|
||||
|
||||
void
|
||||
test_image_swallow_align(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
|
|
|
@ -153,18 +153,18 @@ _img_new(Evas_Object *obj)
|
|||
static void
|
||||
_image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img)
|
||||
{
|
||||
Evas_Coord x = 0, y = 0, w = 1, h = 1;
|
||||
|
||||
if (efl_isa(img, EDJE_OBJECT_CLASS))
|
||||
{
|
||||
evas_object_move(img, sd->img_x, sd->img_y);
|
||||
evas_object_resize(img, sd->img_w, sd->img_h);
|
||||
|
||||
evas_object_move(sd->hit_rect, sd->img_x, sd->img_y);
|
||||
evas_object_resize(sd->hit_rect, sd->img_w, sd->img_h);
|
||||
x = sd->img_x;
|
||||
y = sd->img_y;
|
||||
w = sd->img_w;
|
||||
h = sd->img_h;
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
{
|
||||
Evas_Coord x = 0, y = 0, w = 1, h = 1;
|
||||
double alignh = 0.5, alignv = 0.5;
|
||||
int iw = 0, ih = 0, offset_x = 0, offset_y = 0;
|
||||
|
||||
|
@ -222,6 +222,13 @@ _image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img)
|
|||
h = ih;
|
||||
}
|
||||
break;
|
||||
case EFL_UI_IMAGE_SCALE_TYPE_TILE:
|
||||
x = sd->img_x;
|
||||
y = sd->img_y;
|
||||
w = sd->img_w;
|
||||
h = sd->img_h;
|
||||
evas_object_image_fill_set(img, x, y, iw, ih);
|
||||
goto done;
|
||||
}
|
||||
|
||||
//3. Calculate offset according to align value
|
||||
|
@ -259,13 +266,13 @@ _image_sizing_eval(Efl_Ui_Image_Data *sd, Evas_Object *img)
|
|||
y = sd->img_y;
|
||||
h = sd->img_h;
|
||||
}
|
||||
|
||||
evas_object_move(img, x, y);
|
||||
evas_object_resize(img, w, h);
|
||||
|
||||
evas_object_move(sd->hit_rect, x, y);
|
||||
evas_object_resize(sd->hit_rect, w, h);
|
||||
}
|
||||
done:
|
||||
evas_object_move(img, x, y);
|
||||
evas_object_resize(img, w, h);
|
||||
|
||||
evas_object_move(sd->hit_rect, x, y);
|
||||
evas_object_resize(sd->hit_rect, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -19,6 +19,7 @@ enum Efl.Ui.Image.Scale_Type
|
|||
At least one of the dimensions of the image
|
||||
should be equal to the corresponding
|
||||
dimension of the object.]]
|
||||
tile, [[Tile image at its original size.]]
|
||||
none [[Not scale the internal image]]
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue