1. types declared as int, not uchar. thansk rbdpgn! :)

2. you can query the REAL minimum size of an edje too.


SVN revision: 7168
This commit is contained in:
Carsten Haitzler 2003-07-15 08:26:06 +00:00
parent 181da0cf37
commit 565c76645a
7 changed files with 182 additions and 85 deletions

View File

@ -24,6 +24,7 @@ struct _Demo_Edje
Evas_Object *title;
Evas_Object *title_clip;
Evas_Object *image;
double minw, minh;
int down_top : 1;
int down_bottom : 1;
int hdir;
@ -304,6 +305,7 @@ bottom_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
if (de->down_bottom)
{
double x, y, w, h, tw, th;
double minw, minh;
int hdir, vdir;
evas_object_geometry_get(de->edje, &x, &y, &w, &h);
@ -313,34 +315,36 @@ bottom_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
y -= 20;
w += 20;
h += 30;
minw = 20 + de->minw;
minh = 30 + de->minh;
if (hdir > 0)
{
w += ev->cur.canvas.x - ev->prev.canvas.x;
if (w < 20) w = 20;
if (w < minw) w = minw;
}
else
{
w -= ev->cur.canvas.x - ev->prev.canvas.x;
x += ev->cur.canvas.x - ev->prev.canvas.x;
if (w < 20)
if (w < minw)
{
x += w - 20;
w = 20;
x += w - minw;
w = minw;
}
}
if (vdir > 0)
{
h += ev->cur.canvas.y - ev->prev.canvas.y;
if (h < 30) h = 30;
if (h < minh) h = minh;
}
else
{
h -= ev->cur.canvas.y - ev->prev.canvas.y;
y += ev->cur.canvas.y - ev->prev.canvas.y;
if (h < 30)
if (h < minh)
{
y += h - 30;
h = 30;
y += h - minh;
h = minh;
}
}
evas_object_move(de->left, x, y + 20);
@ -459,6 +463,7 @@ test_setup(char *file, char *name)
evas_object_move(o, 10 + 10, 10 + 20);
evas_object_resize(o, 200, 240);
evas_object_show(o);
edje_object_size_min_get(o, &(de->minw), &(de->minh));
de->edje = o;
/* test swallowing */

View File

@ -32,7 +32,8 @@ extern "C" {
void edje_object_part_swallow (Evas_Object *o, const char *part, Evas_Object *o_swallow);
void edje_object_part_unswallow (Evas_Object *o, Evas_Object *o_swallow);
Evas_Object *edje_object_part_swallow_get (Evas_Object *o, const char *part);
void edje_object_size_min_get (Evas_Object *o, double *minw, double *minh);
#ifdef __cplusplus
}
#endif

View File

@ -171,7 +171,7 @@ _edje_recalc(Edje *ed)
if (ed->freeze)
{
ed->recalc = 1;
return;
if (!ed->calc_only) return;
}
for (l = ed->parts; l; l = l->next)
{
@ -188,7 +188,7 @@ _edje_recalc(Edje *ed)
if (!ep->calculated) _edje_part_recalc(ed, ep);
}
ed->dirty = 0;
ed->recalc = 0;
if (!ed->calc_only) ed->recalc = 0;
}
static void
@ -361,6 +361,11 @@ _edje_part_recalc_single(Edje *ed,
_edje_text_styles[ep->part->effect].pad.b;
}
}
/* rememebr what our size is BEFORE we go limit it */
params->req.x = params->x;
params->req.y = params->y;
params->req.w = params->w;
params->req.h = params->h;
/* adjust for min size */
if (minw >= 0)
{
@ -538,6 +543,11 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep)
p3.y = (p1.y * (1.0 - pos)) + (p2.y * (pos));
p3.w = (p1.w * (1.0 - pos)) + (p2.w * (pos));
p3.h = (p1.h * (1.0 - pos)) + (p2.h * (pos));
p3.req.x = (p1.req.x * (1.0 - pos)) + (p2.req.x * (pos));
p3.req.y = (p1.req.y * (1.0 - pos)) + (p2.req.y * (pos));
p3.req.w = (p1.req.w * (1.0 - pos)) + (p2.req.w * (pos));
p3.req.h = (p1.req.h * (1.0 - pos)) + (p2.req.h * (pos));
p3.fill.x = (p1.fill.x * (1.0 - pos)) + (p2.fill.x * (pos));
p3.fill.y = (p1.fill.y * (1.0 - pos)) + (p2.fill.y * (pos));
@ -588,64 +598,65 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep)
p3.color3.a = (((int)cc->a3 + 1) * p3.color3.a) >> 8;
}
}
if (ep->part->type == EDJE_PART_TYPE_RECTANGLE)
{
evas_object_move(ep->object, ed->x + p3.x, ed->y + p3.y);
evas_object_resize(ep->object, p3.w, p3.h);
evas_object_color_set(ep->object, p3.color.r, p3.color.g, p3.color.b, p3.color.a);
if (p3.visible) evas_object_show(ep->object);
else evas_object_hide(ep->object);
}
else if (ep->part->type == EDJE_PART_TYPE_TEXT)
{
_edje_text_recalc_apply(ed, ep, &p3, chosen_desc);
}
else if (ep->part->type == EDJE_PART_TYPE_IMAGE)
{
char buf[4096];
int image_id;
int image_count, image_num;
// printf("loc %3.3f %3.3f %3.3fx%3.3f\n", p3.x, p3.y, p3.w, p3.h);
evas_object_move(ep->object, ed->x + p3.x, ed->y + p3.y);
evas_object_resize(ep->object, p3.w, p3.h);
evas_object_image_fill_set(ep->object, p3.fill.x, p3.fill.y, p3.fill.w, p3.fill.h);
evas_object_image_smooth_scale_set(ep->object, p3.smooth);
// printf("fill %3.3f %3.3f %3.3fx%3.3f\n", p3.fill.x, p3.fill.y, p3.fill.w, p3.fill.h);
evas_object_image_border_set(ep->object, p3.border.l, p3.border.r, p3.border.t, p3.border.b);
image_id = ep->param1.description->image.id;
image_count = 2;
if (ep->param2.description)
image_count += evas_list_count(ep->param2.description->image.tween_list);
image_num = (pos * ((double)image_count - 0.5));
if (image_num > (image_count - 1))
image_num = image_count - 1;
if (image_num == 0)
image_id = ep->param1.description->image.id;
else if (image_num == (image_count - 1))
image_id = ep->param2.description->image.id;
else
if (!ed->calc_only)
{
if (ep->part->type == EDJE_PART_TYPE_RECTANGLE)
{
Edje_Part_Image_Id *imid;
imid = evas_list_nth(ep->param2.description->image.tween_list, image_num - 1);
if (imid) image_id = imid->id;
evas_object_move(ep->object, ed->x + p3.x, ed->y + p3.y);
evas_object_resize(ep->object, p3.w, p3.h);
evas_object_color_set(ep->object, p3.color.r, p3.color.g, p3.color.b, p3.color.a);
if (p3.visible) evas_object_show(ep->object);
else evas_object_hide(ep->object);
}
else if (ep->part->type == EDJE_PART_TYPE_TEXT)
{
_edje_text_recalc_apply(ed, ep, &p3, chosen_desc);
}
else if (ep->part->type == EDJE_PART_TYPE_IMAGE)
{
char buf[4096];
int image_id;
int image_count, image_num;
evas_object_move(ep->object, ed->x + p3.x, ed->y + p3.y);
evas_object_resize(ep->object, p3.w, p3.h);
evas_object_image_fill_set(ep->object, p3.fill.x, p3.fill.y, p3.fill.w, p3.fill.h);
evas_object_image_smooth_scale_set(ep->object, p3.smooth);
evas_object_image_border_set(ep->object, p3.border.l, p3.border.r, p3.border.t, p3.border.b);
image_id = ep->param1.description->image.id;
image_count = 2;
if (ep->param2.description)
image_count += evas_list_count(ep->param2.description->image.tween_list);
image_num = (pos * ((double)image_count - 0.5));
if (image_num > (image_count - 1))
image_num = image_count - 1;
if (image_num == 0)
image_id = ep->param1.description->image.id;
else if (image_num == (image_count - 1))
image_id = ep->param2.description->image.id;
else
{
Edje_Part_Image_Id *imid;
imid = evas_list_nth(ep->param2.description->image.tween_list, image_num - 1);
if (imid) image_id = imid->id;
}
snprintf(buf, sizeof(buf), "images/%i", image_id);
evas_object_image_file_set(ep->object, ed->file->path, buf);
evas_object_color_set(ep->object, p3.color.r, p3.color.g, p3.color.b, p3.color.a);
if (p3.visible) evas_object_show(ep->object);
else evas_object_hide(ep->object);
}
if (ep->swallowed_object)
{
evas_object_move(ep->swallowed_object, ed->x + p3.x, ed->y + p3.y);
evas_object_resize(ep->swallowed_object, p3.w, p3.h);
if (p3.visible) evas_object_show(ep->swallowed_object);
else evas_object_hide(ep->swallowed_object);
}
snprintf(buf, sizeof(buf), "images/%i", image_id);
evas_object_image_file_set(ep->object, ed->file->path, buf);
evas_object_color_set(ep->object, p3.color.r, p3.color.g, p3.color.b, p3.color.a);
if (p3.visible) evas_object_show(ep->object);
else evas_object_hide(ep->object);
}
if (ep->swallowed_object)
{
evas_object_move(ep->swallowed_object, ed->x + p3.x, ed->y + p3.y);
evas_object_resize(ep->swallowed_object, p3.w, p3.h);
if (p3.visible) evas_object_show(ep->swallowed_object);
else evas_object_hide(ep->swallowed_object);
}
ep->x = p3.x;

View File

@ -136,25 +136,25 @@ _edje_edd_setup(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "fill.pos_abs_y", fill.pos_abs_y, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "fill.rel_y", fill.rel_y, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "fill.abs_y", fill.abs_y, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color.r", color.r, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color.g", color.g, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color.b", color.b, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color.a", color.a, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color2.r", color2.r, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color2.g", color2.g, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color2.b", color2.b, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color2.a", color2.a, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color3.r", color3.r, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color3.g", color3.g, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color3.b", color3.b, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color3.a", color3.a, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color.r", color.r, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color.g", color.g, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color.b", color.b, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color.a", color.a, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color2.r", color2.r, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color2.g", color2.g, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color2.b", color2.b, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color2.a", color2.a, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color3.r", color3.r, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color3.g", color3.g, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color3.b", color3.b, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "color3.a", color3.a, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.text", text.text, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.font", text.font, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.size", text.size, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.fit_x", text.fit_x, EET_T_CHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.fit_y", text.fit_y, EET_T_CHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.min_x", text.min_x, EET_T_CHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.min_y", text.min_y, EET_T_CHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.fit_x", text.fit_x, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.fit_y", text.fit_y, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.min_x", text.min_x, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.min_y", text.min_y, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.align.x", text.align.x, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "text.align.y", text.align.y, EET_T_DOUBLE);

View File

@ -32,6 +32,7 @@ edje_object_file_set(Evas_Object *obj, const char *file, const char *part)
Edje_Real_Part *rp;
char buf[256];
printf("PART!\n");
ep = l->data;
rp = calloc(1, sizeof(Edje_Real_Part));
if (!rp) return;
@ -45,6 +46,10 @@ edje_object_file_set(Evas_Object *obj, const char *file, const char *part)
rp->object = evas_object_image_add(ed->evas);
else if (ep->type == EDJE_PART_TYPE_TEXT)
rp->object = evas_object_text_add(ed->evas);
else
{
printf("FIXME: ERROR! wrong part type!\n");
}
evas_object_smart_member_add(rp->object, ed->obj);
if (ep->mouse_events)
{

View File

@ -25,8 +25,8 @@
* drag vals should be 0.0 -> 1.0 if drag is confined. "rest" pos = 0.0.
* query dragable for its relative pos value
*
* real part size and "before min/max limit" sizes need to be stored per part
* need to be able to calculate min & max size of a whole edje
* need to be able to query "state" of an edje part
* need to be able to set callback on part state change
*
* swallowed objects need to be able to advertise min/max size
*
@ -39,8 +39,11 @@
* need to detect clip_to part loops
* need to detect confine_to part loops
*
* ? programs need to be able to "toggle" part states given a list of states
* ? programs could be extended further
* ? reduce linked list walking and list_nth calls
* ? add containering (hbox, vbox, table, wrapping multi-line hbox & vbox)
* ? text entry widget (single line)
* ? add numeric params to conditions for progs (ranges etc.)
* ? key/value pair config values per colelction and per edje file
*/
@ -316,6 +319,9 @@ struct _Edje
int layer;
double x, y, w, h;
struct {
double w, h;
} min;
unsigned short dirty : 1;
unsigned short recalc : 1;
unsigned short walking_callbacks : 1;
@ -324,6 +330,7 @@ struct _Edje
unsigned short have_objects : 1;
unsigned short paused : 1;
unsigned short no_anim : 1;
unsigned short calc_only : 1;
double paused_at;
Evas *evas; /* the evas this edje belongs to */
Evas_Object *obj; /* the smart object */
@ -343,6 +350,9 @@ struct _Edje
struct _Edje_Real_Part
{
int x, y, w, h;
struct {
int x, y, w, h;
} req;
struct {
int x, y;
} offset;
@ -401,6 +411,9 @@ struct _Edje_Signal_Callback
struct _Edje_Calc_Params
{
double x, y, w, h;
struct {
double x, y, w, h;
} req;
char visible : 1;
char smooth : 1;
struct {

View File

@ -278,7 +278,69 @@ edje_object_part_swallow_get(Evas_Object *obj, const char *part)
return rp->swallowed_object;
}
void
edje_object_size_min_get(Evas_Object *obj, double *minw, double *minh)
{
Edje *ed;
double pw, ph;
int maxw, maxh;
int ok;
ed = _edje_fetch(obj);
ed->calc_only = 1;
pw = ed->w;
ph = ed->h;
ed->w = 0;
ed->h = 0;
maxw = 0;
maxh = 0;
ok = 1;
while (ok)
{
Evas_List *l;
ok = 0;
ed->dirty = 1;
_edje_recalc(ed);
for (l = ed->parts; l; l = l->next)
{
Edje_Real_Part *ep;
int w, h;
ep = l->data;
w = ep->w - ep->req.w;
h = ep->h - ep->req.h;
if (w > maxw)
{
maxw = w;
ok = 1;
}
if (h > maxh)
{
maxh = h;
ok = 1;
}
}
if (ok)
{
ed->w += maxw;
ed->h += maxh;
}
}
ed->min.w = ed->w;
ed->min.h = ed->h;
if (minw) *minw = ed->min.w;
if (minh) *minh = ed->min.h;
ed->w = pw;
ed->h = ph;
ed->dirty = 1;
_edje_recalc(ed);
ed->calc_only = 0;
}