formatting

SVN revision: 73220
This commit is contained in:
Mike Blumenkrantz 2012-07-03 10:01:37 +00:00
parent f23a7afa40
commit 398a773208
1 changed files with 234 additions and 229 deletions

View File

@ -5,36 +5,40 @@ typedef struct _E_Box_Item E_Box_Item;
struct _E_Smart_Data struct _E_Smart_Data
{ {
Evas_Coord x, y, w, h; Evas_Coord x, y, w, h;
Evas_Object *obj; Evas_Object *obj;
Evas_Object *clip; Evas_Object *clip;
int frozen; int frozen;
unsigned char changed : 1; unsigned char changed : 1;
unsigned char horizontal : 1; unsigned char horizontal : 1;
unsigned char homogenous : 1; unsigned char homogenous : 1;
Eina_List *items; Eina_List *items;
struct { struct
Evas_Coord w, h; {
Evas_Coord w, h;
} min, max; } min, max;
struct { struct
double x, y; {
double x, y;
} align; } align;
}; };
struct _E_Box_Item struct _E_Box_Item
{ {
E_Smart_Data *sd; E_Smart_Data *sd;
unsigned char fill_w : 1; unsigned char fill_w : 1;
unsigned char fill_h : 1; unsigned char fill_h : 1;
unsigned char expand_w : 1; unsigned char expand_w : 1;
unsigned char expand_h : 1; unsigned char expand_h : 1;
struct { struct
Evas_Coord w, h; {
Evas_Coord w, h;
} min, max; } min, max;
struct { struct
double x, y; {
double x, y;
} align; } align;
Evas_Object *obj; Evas_Object *obj;
}; };
/* local subsystem functions */ /* local subsystem functions */
@ -44,16 +48,16 @@ static void _e_box_smart_item_del_hook(void *data, Evas *e, Evas_Object *
static void _e_box_smart_reconfigure(E_Smart_Data *sd); static void _e_box_smart_reconfigure(E_Smart_Data *sd);
static void _e_box_smart_extents_calculate(E_Smart_Data *sd); static void _e_box_smart_extents_calculate(E_Smart_Data *sd);
static void _e_box_smart_init(void); static void _e_box_smart_init(void);
static void _e_box_smart_add(Evas_Object *obj); static void _e_box_smart_add(Evas_Object *obj);
static void _e_box_smart_del(Evas_Object *obj); static void _e_box_smart_del(Evas_Object *obj);
static void _e_box_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y); static void _e_box_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
static void _e_box_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h); static void _e_box_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
static void _e_box_smart_show(Evas_Object *obj); static void _e_box_smart_show(Evas_Object *obj);
static void _e_box_smart_hide(Evas_Object *obj); static void _e_box_smart_hide(Evas_Object *obj);
static void _e_box_smart_color_set(Evas_Object *obj, int r, int g, int b, int a); static void _e_box_smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
static void _e_box_smart_clip_set(Evas_Object *obj, Evas_Object *clip); static void _e_box_smart_clip_set(Evas_Object *obj, Evas_Object *clip);
static void _e_box_smart_clip_unset(Evas_Object *obj); static void _e_box_smart_clip_unset(Evas_Object *obj);
/* local subsystem globals */ /* local subsystem globals */
static Evas_Smart *_e_smart = NULL; static Evas_Smart *_e_smart = NULL;
@ -178,8 +182,8 @@ e_box_pack_before(Evas_Object *obj, Evas_Object *child, Evas_Object *before)
sd->items = eina_list_prepend_relative(sd->items, child, before); sd->items = eina_list_prepend_relative(sd->items, child, before);
EINA_LIST_FOREACH(sd->items, l, item) EINA_LIST_FOREACH(sd->items, l, item)
{ {
if (item == child) break; if (item == child) break;
i++; i++;
} }
sd->changed = 1; sd->changed = 1;
if (sd->frozen <= 0) _e_box_smart_reconfigure(sd); if (sd->frozen <= 0) _e_box_smart_reconfigure(sd);
@ -202,8 +206,8 @@ e_box_pack_after(Evas_Object *obj, Evas_Object *child, Evas_Object *after)
sd->items = eina_list_append_relative(sd->items, child, after); sd->items = eina_list_append_relative(sd->items, child, after);
EINA_LIST_FOREACH(sd->items, l, item) EINA_LIST_FOREACH(sd->items, l, item)
{ {
if (item == child) break; if (item == child) break;
i++; i++;
} }
sd->changed = 1; sd->changed = 1;
if (sd->frozen <= 0) _e_box_smart_reconfigure(sd); if (sd->frozen <= 0) _e_box_smart_reconfigure(sd);
@ -385,7 +389,7 @@ _e_box_smart_adopt(E_Smart_Data *sd, Evas_Object *obj)
evas_object_smart_member_add(obj, bi->sd->obj); evas_object_smart_member_add(obj, bi->sd->obj);
evas_object_data_set(obj, "e_box_data", bi); evas_object_data_set(obj, "e_box_data", bi);
evas_object_event_callback_add(obj, EVAS_CALLBACK_FREE, evas_object_event_callback_add(obj, EVAS_CALLBACK_FREE,
_e_box_smart_item_del_hook, NULL); _e_box_smart_item_del_hook, NULL);
if ((!evas_object_visible_get(sd->clip)) && if ((!evas_object_visible_get(sd->clip)) &&
(evas_object_visible_get(sd->obj))) (evas_object_visible_get(sd->obj)))
evas_object_show(sd->clip); evas_object_show(sd->clip);
@ -401,12 +405,12 @@ _e_box_smart_disown(Evas_Object *obj)
if (!bi) return; if (!bi) return;
if (!bi->sd->items) if (!bi->sd->items)
{ {
if (evas_object_visible_get(bi->sd->clip)) if (evas_object_visible_get(bi->sd->clip))
evas_object_hide(bi->sd->clip); evas_object_hide(bi->sd->clip);
} }
evas_object_event_callback_del(obj, evas_object_event_callback_del(obj,
EVAS_CALLBACK_FREE, EVAS_CALLBACK_FREE,
_e_box_smart_item_del_hook); _e_box_smart_item_del_hook);
evas_object_smart_member_del(obj); evas_object_smart_member_del(obj);
evas_object_clip_unset(obj); evas_object_clip_unset(obj);
evas_object_data_del(obj, "e_box_data"); evas_object_data_del(obj, "e_box_data");
@ -442,42 +446,42 @@ _e_box_smart_reconfigure(E_Smart_Data *sd)
expand = 0; expand = 0;
if (w < minw) if (w < minw)
{ {
x = x + ((w - minw) * (1.0 - sd->align.x)); x = x + ((w - minw) * (1.0 - sd->align.x));
w = minw; w = minw;
} }
if (h < minh) if (h < minh)
{ {
y = y + ((h - minh) * (1.0 - sd->align.y)); y = y + ((h - minh) * (1.0 - sd->align.y));
h = minh; h = minh;
} }
EINA_LIST_FOREACH(sd->items, l, obj) EINA_LIST_FOREACH(sd->items, l, obj)
{ {
E_Box_Item *bi; E_Box_Item *bi;
bi = evas_object_data_get(obj, "e_box_data"); bi = evas_object_data_get(obj, "e_box_data");
if (bi) if (bi)
{ {
if (sd->horizontal) if (sd->horizontal)
{ {
if (bi->expand_w) expand++; if (bi->expand_w) expand++;
} }
else else
{ {
if (bi->expand_h) expand++; if (bi->expand_h) expand++;
} }
} }
} }
if (expand == 0) if (expand == 0)
{ {
if (sd->horizontal) if (sd->horizontal)
{ {
x += (double)(w - minw) * sd->align.x; x += (double)(w - minw) * sd->align.x;
w = minw; w = minw;
} }
else else
{ {
y += (double)(h - minh) * sd->align.y; y += (double)(h - minh) * sd->align.y;
h = minh; h = minh;
} }
} }
wdif = w - minw; wdif = w - minw;
hdif = h - minh; hdif = h - minh;
@ -485,106 +489,106 @@ _e_box_smart_reconfigure(E_Smart_Data *sd)
yy = y; yy = y;
EINA_LIST_FOREACH(sd->items, l, obj) EINA_LIST_FOREACH(sd->items, l, obj)
{ {
E_Box_Item *bi; E_Box_Item *bi;
bi = evas_object_data_get(obj, "e_box_data"); bi = evas_object_data_get(obj, "e_box_data");
if (bi) if (bi)
{ {
if (sd->horizontal) if (sd->horizontal)
{ {
if (sd->homogenous) if (sd->homogenous)
{ {
Evas_Coord ww, hh, ow, oh; Evas_Coord ww, hh, ow, oh;
ww = (w / (Evas_Coord)count); ww = (w / (Evas_Coord)count);
hh = h; hh = h;
ow = bi->min.w; ow = bi->min.w;
if (bi->fill_w) ow = ww; if (bi->fill_w) ow = ww;
if ((bi->max.w >= 0) && (bi->max.w < ow)) if ((bi->max.w >= 0) && (bi->max.w < ow))
ow = bi->max.w; ow = bi->max.w;
oh = bi->min.h; oh = bi->min.h;
if (bi->fill_h) oh = hh; if (bi->fill_h) oh = hh;
if ((bi->max.h >= 0) && (bi->max.h < oh)) if ((bi->max.h >= 0) && (bi->max.h < oh))
oh = bi->max.h; oh = bi->max.h;
evas_object_move(obj, evas_object_move(obj,
xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x), xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y)); yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
evas_object_resize(obj, ow, oh); evas_object_resize(obj, ow, oh);
xx += ww; xx += ww;
} }
else else
{ {
Evas_Coord ww, hh, ow, oh; Evas_Coord ww, hh, ow, oh;
ww = bi->min.w; ww = bi->min.w;
if ((expand > 0) && (bi->expand_w)) if ((expand > 0) && (bi->expand_w))
{ {
if (expand == 1) ow = wdif; if (expand == 1) ow = wdif;
else ow = (w - minw) / expand; else ow = (w - minw) / expand;
wdif -= ow; wdif -= ow;
ww += ow; ww += ow;
} }
hh = h; hh = h;
ow = bi->min.w; ow = bi->min.w;
if (bi->fill_w) ow = ww; if (bi->fill_w) ow = ww;
if ((bi->max.w >= 0) && (bi->max.w < ow)) ow = bi->max.w; if ((bi->max.w >= 0) && (bi->max.w < ow)) ow = bi->max.w;
oh = bi->min.h; oh = bi->min.h;
if (bi->fill_h) oh = hh; if (bi->fill_h) oh = hh;
if ((bi->max.h >= 0) && (bi->max.h < oh)) oh = bi->max.h; if ((bi->max.h >= 0) && (bi->max.h < oh)) oh = bi->max.h;
evas_object_move(obj, evas_object_move(obj,
xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x), xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y)); yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
evas_object_resize(obj, ow, oh); evas_object_resize(obj, ow, oh);
xx += ww; xx += ww;
} }
} }
else else
{ {
if (sd->homogenous) if (sd->homogenous)
{ {
Evas_Coord ww, hh, ow, oh; Evas_Coord ww, hh, ow, oh;
ww = w; ww = w;
hh = (h / (Evas_Coord)count); hh = (h / (Evas_Coord)count);
ow = bi->min.w; ow = bi->min.w;
if (bi->fill_w) ow = ww; if (bi->fill_w) ow = ww;
if ((bi->max.w >= 0) && (bi->max.w < ow)) ow = bi->max.w; if ((bi->max.w >= 0) && (bi->max.w < ow)) ow = bi->max.w;
oh = bi->min.h; oh = bi->min.h;
if (bi->fill_h) oh = hh; if (bi->fill_h) oh = hh;
if ((bi->max.h >= 0) && (bi->max.h < oh)) oh = bi->max.h; if ((bi->max.h >= 0) && (bi->max.h < oh)) oh = bi->max.h;
evas_object_move(obj, evas_object_move(obj,
xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x), xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y)); yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
evas_object_resize(obj, ow, oh); evas_object_resize(obj, ow, oh);
yy += hh; yy += hh;
} }
else else
{ {
Evas_Coord ww, hh, ow, oh; Evas_Coord ww, hh, ow, oh;
ww = w; ww = w;
hh = bi->min.h; hh = bi->min.h;
if ((expand > 0) && (bi->expand_h)) if ((expand > 0) && (bi->expand_h))
{ {
if (expand == 1) oh = hdif; if (expand == 1) oh = hdif;
else oh = (h - minh) / expand; else oh = (h - minh) / expand;
hdif -= oh; hdif -= oh;
hh += oh; hh += oh;
} }
ow = bi->min.w; ow = bi->min.w;
if (bi->fill_w) ow = ww; if (bi->fill_w) ow = ww;
if ((bi->max.w >= 0) && (bi->max.w < ow)) ow = bi->max.w; if ((bi->max.w >= 0) && (bi->max.w < ow)) ow = bi->max.w;
oh = bi->min.h; oh = bi->min.h;
if (bi->fill_h) oh = hh; if (bi->fill_h) oh = hh;
if ((bi->max.h >= 0) && (bi->max.h < oh)) oh = bi->max.h; if ((bi->max.h >= 0) && (bi->max.h < oh)) oh = bi->max.h;
evas_object_move(obj, evas_object_move(obj,
xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x), xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y)); yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
evas_object_resize(obj, ow, oh); evas_object_resize(obj, ow, oh);
yy += hh; yy += hh;
} }
} }
} }
} }
sd->changed = 0; sd->changed = 0;
} }
@ -604,43 +608,43 @@ _e_box_smart_extents_calculate(E_Smart_Data *sd)
minh = 0; minh = 0;
if (sd->homogenous) if (sd->homogenous)
{ {
EINA_LIST_FOREACH(sd->items, l, obj) EINA_LIST_FOREACH(sd->items, l, obj)
{ {
E_Box_Item *bi; E_Box_Item *bi;
bi = evas_object_data_get(obj, "e_box_data"); bi = evas_object_data_get(obj, "e_box_data");
if (bi) if (bi)
{ {
if (minh < bi->min.h) minh = bi->min.h; if (minh < bi->min.h) minh = bi->min.h;
if (minw < bi->min.w) minw = bi->min.w; if (minw < bi->min.w) minw = bi->min.w;
} }
} }
if (sd->horizontal) if (sd->horizontal)
minw *= eina_list_count(sd->items); minw *= eina_list_count(sd->items);
else else
minh *= eina_list_count(sd->items); minh *= eina_list_count(sd->items);
} }
else else
{ {
EINA_LIST_FOREACH(sd->items, l, obj) EINA_LIST_FOREACH(sd->items, l, obj)
{ {
E_Box_Item *bi; E_Box_Item *bi;
bi = evas_object_data_get(obj, "e_box_data"); bi = evas_object_data_get(obj, "e_box_data");
if (bi) if (bi)
{ {
if (sd->horizontal) if (sd->horizontal)
{ {
if (minh < bi->min.h) minh = bi->min.h; if (minh < bi->min.h) minh = bi->min.h;
minw += bi->min.w; minw += bi->min.w;
} }
else else
{ {
if (minw < bi->min.w) minw = bi->min.w; if (minw < bi->min.w) minw = bi->min.w;
minh += bi->min.h; minh += bi->min.h;
} }
} }
} }
} }
sd->min.w = minw; sd->min.w = minw;
sd->min.h = minh; sd->min.h = minh;
@ -650,30 +654,30 @@ static void
_e_box_smart_init(void) _e_box_smart_init(void)
{ {
if (_e_smart) return; if (_e_smart) return;
{ {
static const Evas_Smart_Class sc = static const Evas_Smart_Class sc =
{ {
"e_box", "e_box",
EVAS_SMART_CLASS_VERSION, EVAS_SMART_CLASS_VERSION,
_e_box_smart_add, _e_box_smart_add,
_e_box_smart_del, _e_box_smart_del,
_e_box_smart_move, _e_box_smart_move,
_e_box_smart_resize, _e_box_smart_resize,
_e_box_smart_show, _e_box_smart_show,
_e_box_smart_hide, _e_box_smart_hide,
_e_box_smart_color_set, _e_box_smart_color_set,
_e_box_smart_clip_set, _e_box_smart_clip_set,
_e_box_smart_clip_unset, _e_box_smart_clip_unset,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL NULL
}; };
_e_smart = evas_smart_class_new(&sc); _e_smart = evas_smart_class_new(&sc);
} }
} }
static void static void
@ -711,10 +715,10 @@ _e_box_smart_del(Evas_Object *obj)
e_box_freeze(obj); e_box_freeze(obj);
while (sd->items) while (sd->items)
{ {
Evas_Object *child; Evas_Object *child;
child = eina_list_data_get(sd->items); child = eina_list_data_get(sd->items);
e_box_unpack(child); e_box_unpack(child);
} }
e_box_thaw(obj); e_box_thaw(obj);
evas_object_del(sd->clip); evas_object_del(sd->clip);
@ -731,21 +735,21 @@ _e_box_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
sd = evas_object_smart_data_get(obj); sd = evas_object_smart_data_get(obj);
if (!sd) return; if (!sd) return;
if ((x == sd->x) && (y == sd->y)) return; if ((x == sd->x) && (y == sd->y)) return;
{ {
Eina_List *l; Eina_List *l;
Evas_Object *item; Evas_Object *item;
Evas_Coord dx, dy; Evas_Coord dx, dy;
dx = x - sd->x; dx = x - sd->x;
dy = y - sd->y; dy = y - sd->y;
EINA_LIST_FOREACH(sd->items, l, item) EINA_LIST_FOREACH(sd->items, l, item)
{ {
Evas_Coord ox, oy; Evas_Coord ox, oy;
evas_object_geometry_get(item, &ox, &oy, NULL, NULL); evas_object_geometry_get(item, &ox, &oy, NULL, NULL);
evas_object_move(item, ox + dx, oy + dy); evas_object_move(item, ox + dx, oy + dy);
} }
} }
sd->x = x; sd->x = x;
sd->y = y; sd->y = y;
} }
@ -813,3 +817,4 @@ _e_box_smart_clip_unset(Evas_Object *obj)
if (!sd) return; if (!sd) return;
evas_object_clip_unset(sd->clip); evas_object_clip_unset(sd->clip);
} }