Elm_Photo:

- Add a way to display a photo by keeping the ratio AND the theme can display something around the photo (border ...). The way I use is maybe a bit crappy (embryo, offset ...) but I do not know a better way.
 - Add a new style (with a shadow). The default style has no changes
 If you do not like my way, revert the commit and commit your way :)
 
Elm_Slideshow:
 - Use elm_photo in the test
 - Add a black background

SVN revision: 50248
This commit is contained in:
Jonathan Atton 2010-07-14 14:48:21 +00:00
parent b8e248f29c
commit a05015145d
13 changed files with 188 additions and 30 deletions

View File

@ -40,6 +40,8 @@ icon_21.png \
icon_22.png \
icon_23.png \
bubble.png \
bubble_sh.png
bubble_sh.png \
mystrale.jpg \
mystrale_2.jpg
EXTRA_DIST = $(files_DATA)

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

View File

@ -187,7 +187,9 @@ emo-wink.png \
emo-worried.png \
emo-wtf.png \
map_item.png \
map_item_2.png
map_item_2.png \
shadow.png \
black.png
default.edj: Makefile $(EXTRA_DIST)
$(EDJE_CC) $(EDJE_FLAGS) \

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 B

View File

@ -7023,6 +7023,78 @@ collections {
}
}
}
group { name: "elm/photo/base/shadow";
images {
image: "shadow.png" COMP;
image: "black.png" COMP;
}
script {
public message(Msg_Type:type, id, ...) {
if( (type==MSG_INT_SET) && (id==0) )
{
new w;
new h;
custom_state(PART:"size", "default", 0.0);
w = getarg(2);
h = getarg(3);
set_state_val(PART:"size", STATE_REL1_OFFSET, - w/2, - h/2);
set_state_val(PART:"size", STATE_REL2_OFFSET, w/2 + 1, h/2 + 1);
set_state(PART:"size", "custom", 0.0);
}
}
}
parts {
part { name: "size";
type: SWALLOW;
description { state: "default" 0.0;
rel1.relative: 0.5 0.5;
rel2.relative: 0.5 0.5;
}
}
part {
name: "shadow";
type: IMAGE;
repeat_events: 1;
description {
state: "default" 0.0;
rel1.to: "size";
rel2.to: "size";
rel1.relative: -0.06 -0.06;
rel2.relative: 1.07 1.07;
image.normal: "shadow.png";
}
}
part { name: "elm.swallow.content";
type: SWALLOW;
description { state: "default" 0.0;
rel1.offset: 3 3;
rel2.offset: -3 -3;
fixed: 1 1;
}
}
part {
name: "border";
type: IMAGE;
repeat_events: 1;
description {
state: "default" 0.0;
visible: 1;
color: 0 0 0 255;
rel1.to: "size";
rel2.to: "size";
image.normal: "black.png";
image.border: 1 1 1 1;
image.middle: 0;
}
}
}
}
///////////////////////////////////////////////////////////////////////////////
group { name: "elm/thumb/base/default";
@ -8432,10 +8504,11 @@ collections {
}
parts {
part { name: "whole";
type: RECT;
description {
state: "default" 0.0;
visible: 1;
color: 0 0 0 0;
color: 20 20 20 255;
}
}
part { name: "image_1_whole";

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -8,13 +8,13 @@ test_photo(void *data, Evas_Object *obj, void *event_info)
char buf[PATH_MAX];
const char *img[9] =
{
"panel_01.jpg",
"plant_01.jpg",
"rock_01.jpg",
"panel_01.jpg",
"mystrale.jpg",
"mystrale_2.jpg",
"rock_02.jpg",
"sky_01.jpg",
"sky_02.jpg",
"sky_03.jpg",
"sky_01.jpg",
"sky_02.jpg",
"sky_03.jpg",
"sky_04.jpg",
"wood_01.jpg"
};
@ -47,6 +47,10 @@ test_photo(void *data, Evas_Object *obj, void *event_info)
evas_object_size_hint_align_set(ph, EVAS_HINT_FILL,
EVAS_HINT_FILL);
elm_photo_size_set(ph, 80);
if(n == 2 || n == 3) {
elm_photo_fill_inside_set(ph, EINA_TRUE);
elm_widget_style_set(ph, "shadow");
}
elm_table_pack(tb, ph, i, j, 1, 1);
evas_object_show(ph);
}

View File

@ -13,6 +13,8 @@ static char *img4 = PACKAGE_DATA_DIR"/images/rock_02.jpg";
static char *img5 = PACKAGE_DATA_DIR"/images/sky_01.jpg";
static char *img6 = PACKAGE_DATA_DIR"/images/sky_04.jpg";
static char *img7 = PACKAGE_DATA_DIR"/images/wood_01.jpg";
static char *img8 = PACKAGE_DATA_DIR"/images/mystrale.jpg";
static char *img9 = PACKAGE_DATA_DIR"/images/mystrale_2.jpg";
static void
_notify_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
@ -93,6 +95,8 @@ _get(void *data, Evas_Object *obj)
Evas_Object *photo = elm_photo_add(obj);
elm_photo_file_set(photo, data);
elm_photo_fill_inside_set(photo, EINA_TRUE);
elm_widget_style_set(photo, "shadow");
return photo;
}
@ -128,9 +132,11 @@ test_slideshow(void *data, Evas_Object *obj, void *event_info)
elm_slideshow_item_add(slideshow, &itc, img2);
elm_slideshow_item_add(slideshow, &itc, img3);
elm_slideshow_item_add(slideshow, &itc, img4);
elm_slideshow_item_add(slideshow, &itc, img9);
elm_slideshow_item_add(slideshow, &itc, img5);
elm_slideshow_item_add(slideshow, &itc, img6);
elm_slideshow_item_add(slideshow, &itc, img7);
elm_slideshow_item_add(slideshow, &itc, img8);
notify = elm_notify_add(win);
elm_notify_orient_set(notify, ELM_NOTIFY_ORIENT_BOTTOM);

View File

@ -871,10 +871,11 @@ extern "C" {
EAPI void elm_bubble_corner_set(Evas_Object *obj, const char *corner);
/* smart callbacks called:
*/
EAPI Evas_Object *elm_photo_add(Evas_Object *parent);
EAPI Eina_Bool elm_photo_file_set(Evas_Object *obj, const char *file);
EAPI void elm_photo_size_set(Evas_Object *obj, int size);
EAPI void elm_photo_fill_inside_set(Evas_Object *obj, Eina_Bool fill);
/* smart callbacks called:
* "clicked" - the user clicked the icon
*/

View File

@ -20,6 +20,7 @@ struct _Widget_Data
Evas_Object *frm;
Evas_Object *img;
int size;
Eina_Bool fill;
};
static const char *widtype = NULL;
@ -41,6 +42,8 @@ _theme_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
_elm_theme_object_set(obj, wd->frm, "photo", "base", elm_widget_style_get(obj));
edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->img);
edje_object_scale_set(wd->frm, elm_widget_scale_get(obj) * _elm_config->scale);
_sizing_eval(obj);
}
@ -51,19 +54,42 @@ _sizing_eval(Evas_Object *obj)
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
if (!wd) return;
evas_object_size_hint_min_set(wd->img,
wd->size * elm_widget_scale_get(obj) * _elm_config->scale,
wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->img);
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
edje_object_size_min_restricted_calc(wd->frm, &minw, &minh, minw, minh);
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
maxw = minw;
maxh = minh;
evas_object_size_hint_min_set(obj, minw, minh);
evas_object_size_hint_max_set(obj, maxw, maxh);
if(wd->size > 0) {
evas_object_size_hint_min_set(wd->img,
wd->size * elm_widget_scale_get(obj) * _elm_config->scale,
wd->size * elm_widget_scale_get(obj) * _elm_config->scale);
edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->img);
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
edje_object_size_min_restricted_calc(wd->frm, &minw, &minh, minw, minh);
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
maxw = minw;
maxh = minh;
evas_object_size_hint_min_set(obj, minw, minh);
evas_object_size_hint_max_set(obj, maxw, maxh);
}
}
static void
_icon_move_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Coord w, h;
Widget_Data *wd = elm_widget_data_get(data);
if (!wd) return;
if(wd->fill) {
Evas_Object *icon = _els_smart_icon_object_get(wd->img);
evas_object_geometry_get(icon, NULL, NULL, &w, &h);
Edje_Message_Int_Set *msg = alloca(sizeof(Edje_Message_Int_Set) + (sizeof(int)));
msg->count=2;
msg->val[0] = (int)w;
msg->val[1] = (int)h;
edje_object_message_send(wd->frm, EDJE_MESSAGE_INT_SET, 0, msg);
}
}
static void
_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
@ -84,6 +110,7 @@ elm_photo_add(Evas_Object *parent)
Evas_Object *obj;
Evas *e;
Widget_Data *wd;
Evas_Object *icon;
wd = ELM_NEW(Widget_Data);
e = evas_object_evas_get(parent);
@ -105,6 +132,8 @@ elm_photo_add(Evas_Object *parent)
_els_smart_icon_scale_down_set(wd->img, 1);
_els_smart_icon_smooth_scale_set(wd->img, 1);
_els_smart_icon_fill_inside_set(wd->img, 0);
_els_smart_icon_scale_size_set(wd->img, 0);
wd->fill = EINA_FALSE;
_els_smart_icon_scale_set(wd->img, elm_widget_scale_get(obj) * _elm_config->scale);
evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_UP,
_mouse_up, obj);
@ -113,8 +142,12 @@ elm_photo_add(Evas_Object *parent)
evas_object_show(wd->img);
elm_widget_sub_object_add(obj, wd->img);
wd->size = 40;
icon = _els_smart_icon_object_get(wd->img);
evas_object_event_callback_add(icon, EVAS_CALLBACK_MOVE,
_icon_move_resize, obj);
evas_object_event_callback_add(icon, EVAS_CALLBACK_RESIZE,
_icon_move_resize, obj);
_sizing_eval(obj);
return obj;
}
@ -132,13 +165,15 @@ elm_photo_add(Evas_Object *parent)
EAPI Eina_Bool
elm_photo_file_set(Evas_Object *obj, const char *file)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
if (!_els_smart_icon_file_key_set(wd->img, file, NULL))
return EINA_FALSE;
_sizing_eval(obj);
return EINA_TRUE;
Evas_Object *icon;
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
if (!_els_smart_icon_file_key_set(wd->img, file, NULL))
return EINA_FALSE;
_sizing_eval(obj);
return EINA_TRUE;
}
/**
@ -155,7 +190,32 @@ elm_photo_size_set(Evas_Object *obj, int size)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (size < 0) size = 0;
wd->size = size;
if(size >= 0)
_els_smart_icon_scale_size_set(wd->img, size);
else
_els_smart_icon_scale_size_set(wd->img, 0);
_sizing_eval(obj);
}
/**
* Set if the photo should be completely visible or not.
*
* @param obj The photo object
* @param fill if true the photo will be completely visible
*
* @ingroup Photo
*/
EAPI void
elm_photo_fill_inside_set(Evas_Object *obj, Eina_Bool fill)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
_els_smart_icon_fill_inside_set(wd->img, fill);
wd->fill = fill;
_sizing_eval(obj);
}

View File

@ -88,6 +88,15 @@ _els_smart_icon_smooth_scale_set(Evas_Object *obj, int smooth)
evas_object_image_smooth_scale_set(sd->obj, smooth);
}
Evas_Object *
_els_smart_icon_object_get(Evas_Object *obj)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
return sd->obj;
}
void
_els_smart_icon_size_get(Evas_Object *obj, int *w, int *h)
{

View File

@ -2,6 +2,7 @@ Evas_Object *_els_smart_icon_add (Evas *evas);
Eina_Bool _els_smart_icon_file_key_set (Evas_Object *obj, const char *file, const char *key);
Eina_Bool _els_smart_icon_file_edje_set (Evas_Object *obj, const char *file, const char *part);
void _els_smart_icon_smooth_scale_set (Evas_Object *obj, int smooth);
Evas_Object *_els_smart_icon_object_get(Evas_Object *obj);
void _els_smart_icon_size_get (Evas_Object *obj, int *w, int *h);
void _els_smart_icon_fill_inside_set (Evas_Object *obj, int fill_inside);
void _els_smart_icon_scale_up_set (Evas_Object *obj, int scale_up);