patches applied as per emails :)

SVN revision: 28302
This commit is contained in:
Carsten Haitzler 2007-02-10 17:23:09 +00:00
parent c8fa2c7bbf
commit 087af991d6
7 changed files with 1126 additions and 0 deletions

12
TODO
View File

@ -8,6 +8,16 @@ Some of the things (in very short form) that need to be done to E17...
BUGS / FIXES
-------------------------------------------------------------------------------
* shelves seem to get confused with their contents if you have 3 shelves over
2 screens/zones - when you go back to 1 screen form 2, one of the shelves
gts the contents from the now non-existant shelf.
* gkrellm options to "dont show in pager or taskber" only work if gkrellem is
moved to one monitor and back again - doesn't seem to work on e boot/start
if it is started at e start time
* pane flip animation doesn't work right - left screen slides diagonally
instead of in a straight line
* exebuf on other zones doesn't allow mouse to work properly (only
zone/screen 0 works properly)
* sometimes file monitoring for file changes, adds, deletes on a dir stops
working all of a sudden - unknown what causes it and why right now.
* e_apps wont pick up changes in favorite menu dirs made by the applications
@ -22,6 +32,8 @@ Some of the things (in very short form) that need to be done to E17...
ESSENTIAL FEATURES
-------------------------------------------------------------------------------
* fm2 needs its fops to become async (in slave process and ipc to it)
* fm2 needs its file listing/stat()ing etc. to go into slave proc
* fm2 needs a right-click file properties dialog
* fm2 needs to display symlink info on files somehow
* fm2 needs to display more than 1 file being dragged (if more than 1 is being

View File

@ -43,6 +43,7 @@ e_menu.h \
e_object.h \
e_icon.h \
e_box.h \
e_flowlayout.h \
e_int_menus.h \
e_module.h \
e_apps.h \
@ -199,6 +200,7 @@ e_menu.c \
e_object.c \
e_icon.c \
e_box.c \
e_flowlayout.c \
e_int_menus.c \
e_module.c \
e_apps.c \

View File

@ -727,6 +727,90 @@ ACT_FN_GO(window_resize_by)
}
}
/***************************************************************************/
ACT_FN_GO(window_push)
{
if (!obj) obj = E_OBJECT(e_border_focused_get());
if (!obj) return;
if (obj->type != E_BORDER_TYPE)
{
obj = E_OBJECT(e_border_focused_get());
if (!obj) return;
}
if (params)
{
E_Border *bd, *cur;
E_Border_List *bd_list;
E_Direction dir;
int x, y;
if (strcmp(params, "left") == 0)
dir = E_DIRECTION_LEFT;
else if (strcmp(params, "right") == 0)
dir = E_DIRECTION_RIGHT;
else if (strcmp(params, "up") == 0)
dir = E_DIRECTION_UP;
else if (strcmp(params, "down") == 0)
dir = E_DIRECTION_DOWN;
else
return;
bd = (E_Border *)obj;
/* Target x and y. */
x = bd->x;
y = bd->y;
if (dir == E_DIRECTION_LEFT)
x = 0;
else if (dir == E_DIRECTION_RIGHT)
x = bd->zone->w - bd->w;
else if (dir == E_DIRECTION_UP)
y = 0;
else // dir == E_DIRECTION_DOWN
y = bd->zone->h - bd->h;
bd_list = e_container_border_list_first(bd->zone->container);
cur = e_container_border_list_next(bd_list);
while (cur != NULL)
{
if ((bd->desk == cur->desk) && (bd != cur))
{
if ((dir == E_DIRECTION_LEFT)
&& (cur->x + cur->w < bd->x)
&& (E_SPANS_COMMON(bd->y, bd->h, cur->y, cur->h)))
x = MAX(x, cur->x + cur->w);
else if ((dir == E_DIRECTION_RIGHT)
&& (cur->x > bd->x + bd->w)
&& (E_SPANS_COMMON(bd->y, bd->h, cur->y, cur->h)))
x = MIN(x, cur->x - bd->w);
else if ((dir == E_DIRECTION_UP)
&& (cur->y + cur->h < bd->y)
&& (E_SPANS_COMMON(bd->x, bd->w, cur->x, cur->w)))
y = MAX(y, cur->y + cur->h);
else if ((dir == E_DIRECTION_DOWN)
&& (cur->y > bd->y + bd->h)
&& (E_SPANS_COMMON(bd->x, bd->w, cur->x, cur->w)))
y = MIN(y, cur->y - bd->h);
}
cur = e_container_border_list_next(bd_list);
}
e_container_border_list_free(bd_list);
if ((x != bd->x) || (y != bd->y))
{
e_border_move(bd, x, y);
if (e_config->focus_policy != E_FOCUS_CLICK)
ecore_x_pointer_warp(bd->zone->container->win,
bd->x + (bd->w / 2),
bd->y + (bd->h / 2));
}
}
}
/***************************************************************************/
ACT_FN_GO(window_drag_icon)
{
@ -1950,6 +2034,11 @@ e_actions_init(void)
e_action_predef_name_set(_("Window : Actions"), "Resize By...", "window_resize_by", NULL,
"syntax: W H, example: 100 150", 1);
/* window_push */
ACT_GO(window_push);
e_action_predef_name_set(_("Window : Actions"), "Push in Direction...", "window_push", NULL,
"syntax: direction, example: up, down, left, right", 1);
/* window_drag_icon */
ACT_GO(window_drag_icon);
e_action_predef_name_set(_("Window : Actions"), "Drag Icon...", "window_drag_icon", NULL,

972
src/bin/e_flowlayout.c Normal file
View File

@ -0,0 +1,972 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
#include <math.h>
typedef struct _E_Smart_Data E_Smart_Data;
typedef struct _E_Flowlayout_Item E_Flowlayout_Item;
struct _E_Smart_Data
{
Evas_Coord x, y, w, h;
Evas_Object *obj;
Evas_Object *clip;
int frozen;
unsigned char changed : 1;
unsigned char horizontal : 1;
unsigned char homogenous : 1;
unsigned char fill : 1;
unsigned char flowright : 1;
unsigned char flowbottom : 1;
Evas_List *items;
struct {
Evas_Coord w, h;
} min, max;
struct {
double x, y;
} align;
int rows;
int cols;
};
struct _E_Flowlayout_Item
{
E_Smart_Data *sd;
unsigned char fill_w : 1;
unsigned char fill_h : 1;
unsigned char expand_w : 1;
unsigned char expand_h : 1;
struct {
Evas_Coord w, h;
} min, max;
struct {
double x, y;
} align;
Evas_Object *obj;
};
/* local subsystem functions */
static E_Flowlayout_Item *_e_flowlayout_smart_adopt(E_Smart_Data *sd, Evas_Object *obj);
static void _e_flowlayout_smart_disown(Evas_Object *obj);
static void _e_flowlayout_smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _e_flowlayout_smart_reconfigure(E_Smart_Data *sd);
static void _e_flowlayout_smart_extents_calcuate(E_Smart_Data *sd);
static void _e_flowlayout_smart_init(void);
static void _e_flowlayout_smart_add(Evas_Object *obj);
static void _e_flowlayout_smart_del(Evas_Object *obj);
static void _e_flowlayout_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
static void _e_flowlayout_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
static void _e_flowlayout_smart_show(Evas_Object *obj);
static void _e_flowlayout_smart_hide(Evas_Object *obj);
static void _e_flowlayout_smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
static void _e_flowlayout_smart_clip_set(Evas_Object *obj, Evas_Object *clip);
static void _e_flowlayout_smart_clip_unset(Evas_Object *obj);
/* local subsystem globals */
static Evas_Smart *_e_smart = NULL;
/* externally accessible functions */
EAPI Evas_Object *
e_flowlayout_add(Evas *evas)
{
_e_flowlayout_smart_init();
return evas_object_smart_add(evas, _e_smart);
}
EAPI int
e_flowlayout_freeze(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
sd->frozen++;
return sd->frozen;
}
EAPI int
e_flowlayout_thaw(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
sd->frozen--;
if (sd->frozen <= 0) _e_flowlayout_smart_reconfigure(sd);
return sd->frozen;
}
EAPI void
e_flowlayout_orientation_set(Evas_Object *obj, int horizontal)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (((sd->horizontal) && (horizontal)) ||
((!sd->horizontal) && (!horizontal))) return;
sd->horizontal = horizontal;
sd->changed = 1;
if (sd->frozen <= 0) _e_flowlayout_smart_reconfigure(sd);
}
EAPI int
e_flowlayout_orientation_get(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
return sd->horizontal;
}
EAPI void
e_flowlayout_flowdirection_set(Evas_Object *obj, int right, int bottom)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if ((((sd->flowbottom) && (bottom)) ||
((!sd->flowbottom) && (!bottom))) &&
(((sd->flowright) && (right)) ||
((!sd->flowright) && (!right)))) return;
sd->flowright = right;
sd->flowbottom = bottom;
sd->changed = 1;
if (sd->frozen <= 0) _e_flowlayout_smart_reconfigure(sd);
}
EAPI void
e_flowlayout_flowdirection_get(Evas_Object *obj, int *right, int *bottom)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
if (right) *right = sd->flowright;
if (bottom) *bottom = sd->flowright;
}
EAPI void
e_flowlayout_homogenous_set(Evas_Object *obj, int homogenous)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (sd->homogenous == homogenous) return;
sd->homogenous = homogenous;
sd->changed = 1;
if (sd->frozen <= 0) _e_flowlayout_smart_reconfigure(sd);
}
EAPI int
e_flowlayout_homogenous_get(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
return sd->homogenous;
}
EAPI void
e_flowlayout_fill_set(Evas_Object *obj, int fill)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (sd->fill == fill) return;
sd->fill = fill;
sd->changed = 1;
if (sd->frozen <= 0) _e_flowlayout_smart_reconfigure(sd);
}
EAPI int
e_flowlayout_fill_get(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
return sd->fill;
}
EAPI int
e_flowlayout_pack_start(Evas_Object *obj, Evas_Object *child)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
_e_flowlayout_smart_adopt(sd, child);
sd->items = evas_list_prepend(sd->items, child);
sd->changed = 1;
if (sd->frozen <= 0) _e_flowlayout_smart_reconfigure(sd);
return 0;
}
EAPI int
e_flowlayout_pack_end(Evas_Object *obj, Evas_Object *child)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
_e_flowlayout_smart_adopt(sd, child);
sd->items = evas_list_append(sd->items, child);
sd->changed = 1;
if (sd->frozen <= 0) _e_flowlayout_smart_reconfigure(sd);
return evas_list_count(sd->items) - 1;
}
EAPI int
e_flowlayout_pack_before(Evas_Object *obj, Evas_Object *child, Evas_Object *before)
{
E_Smart_Data *sd;
int i = 0;
Evas_List *l;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
_e_flowlayout_smart_adopt(sd, child);
sd->items = evas_list_prepend_relative(sd->items, child, before);
for (i = 0, l = sd->items; l; l = l->next, i++)
{
if (l->data == child) break;
}
sd->changed = 1;
if (sd->frozen <= 0) _e_flowlayout_smart_reconfigure(sd);
return i;
}
EAPI int
e_flowlayout_pack_after(Evas_Object *obj, Evas_Object *child, Evas_Object *after)
{
E_Smart_Data *sd;
int i = 0;
Evas_List *l;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
_e_flowlayout_smart_adopt(sd, child);
sd->items = evas_list_append_relative(sd->items, child, after);
for (i = 0, l = sd->items; l; l = l->next, i++)
{
if (l->data == child) break;
}
sd->changed = 1;
if (sd->frozen <= 0) _e_flowlayout_smart_reconfigure(sd);
return i;
}
EAPI int
e_flowlayout_pack_count_get(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
return evas_list_count(sd->items);
}
EAPI Evas_Object *
e_flowlayout_pack_object_nth(Evas_Object *obj, int n)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return NULL;
return evas_list_nth(sd->items, n);
}
EAPI Evas_Object *
e_flowlayout_pack_object_first(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return NULL;
return evas_list_data(sd->items);
}
EAPI Evas_Object *
e_flowlayout_pack_object_last(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return NULL;
return evas_list_data(evas_list_last(sd->items));
}
EAPI void
e_flowlayout_pack_options_set(Evas_Object *obj, int fill_w, int fill_h, int expand_w, int expand_h, double align_x, double align_y, Evas_Coord min_w, Evas_Coord min_h, Evas_Coord max_w, Evas_Coord max_h)
{
E_Flowlayout_Item *bi;
bi = evas_object_data_get(obj, "e_flowlayout_data");
if (!bi) return;
bi->fill_w = fill_w;
bi->fill_h = fill_h;
bi->expand_w = expand_w;
bi->expand_h = expand_h;
bi->align.x = align_x;
bi->align.y = align_y;
bi->min.w = min_w;
bi->min.h = min_h;
bi->max.w = max_w;
bi->max.h = max_h;
bi->sd->changed = 1;
if (bi->sd->frozen <= 0) _e_flowlayout_smart_reconfigure(bi->sd);
}
EAPI void
e_flowlayout_unpack(Evas_Object *obj)
{
E_Flowlayout_Item *bi;
E_Smart_Data *sd;
bi = evas_object_data_get(obj, "e_flowlayout_data");
if (!bi) return;
sd = bi->sd;
if (!sd) return;
sd->items = evas_list_remove(sd->items, obj);
_e_flowlayout_smart_disown(obj);
sd->changed = 1;
if (sd->frozen <= 0) _e_flowlayout_smart_reconfigure(sd);
}
EAPI void
e_flowlayout_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (sd->changed) _e_flowlayout_smart_extents_calcuate(sd);
if (minw) *minw = sd->min.w;
if (minh) *minh = sd->min.h;
}
EAPI void
e_flowlayout_max_size_get(Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (sd->changed) _e_flowlayout_smart_extents_calcuate(sd);
if (maxw) *maxw = sd->max.w;
if (maxh) *maxh = sd->max.h;
}
EAPI int
e_flowlayout_max_children(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return -1;
if (!sd->homogenous) return -1;
return (sd->rows * sd->cols);
}
EAPI void
e_flowlayout_align_get(Evas_Object *obj, double *ax, double *ay)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (ax) *ax = sd->align.x;
if (ay) *ay = sd->align.y;
}
EAPI void
e_flowlayout_align_set(Evas_Object *obj, double ax, double ay)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if ((sd->align.x == ax) && (sd->align.y == ay)) return;
sd->align.x = ax;
sd->align.y = ay;
sd->changed = 1;
if (sd->frozen <= 0) _e_flowlayout_smart_reconfigure(sd);
}
/* local subsystem functions */
static E_Flowlayout_Item *
_e_flowlayout_smart_adopt(E_Smart_Data *sd, Evas_Object *obj)
{
E_Flowlayout_Item *bi;
bi = calloc(1, sizeof(E_Flowlayout_Item));
if (!bi) return NULL;
bi->sd = sd;
bi->obj = obj;
/* defaults */
bi->fill_w = 0;
bi->fill_h = 0;
bi->expand_w = 0;
bi->expand_h = 0;
bi->align.x = 0.5;
bi->align.y = 0.5;
bi->min.w = 0;
bi->min.h = 0;
bi->max.w = 0;
bi->max.h = 0;
evas_object_clip_set(obj, sd->clip);
evas_object_smart_member_add(obj, bi->sd->obj);
evas_object_data_set(obj, "e_flowlayout_data", bi);
evas_object_event_callback_add(obj, EVAS_CALLBACK_FREE,
_e_flowlayout_smart_item_del_hook, NULL);
if ((!evas_object_visible_get(sd->clip)) &&
(evas_object_visible_get(sd->obj)))
evas_object_show(sd->clip);
return bi;
}
static void
_e_flowlayout_smart_disown(Evas_Object *obj)
{
E_Flowlayout_Item *bi;
bi = evas_object_data_get(obj, "e_flowlayout_data");
if (!bi) return;
if (!bi->sd->items)
{
if (evas_object_visible_get(bi->sd->clip))
evas_object_hide(bi->sd->clip);
}
evas_object_event_callback_del(obj,
EVAS_CALLBACK_FREE,
_e_flowlayout_smart_item_del_hook);
evas_object_smart_member_del(obj);
evas_object_clip_unset(obj);
evas_object_data_del(obj, "e_flowlayout_data");
free(bi);
}
static void
_e_flowlayout_smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
e_flowlayout_unpack(obj);
}
static void
_e_flowlayout_smart_reconfigure(E_Smart_Data *sd)
{
Evas_Coord x, y, w, h, xx, yy, cr, cc;
Evas_List *l;
int minw, minh, wdif, hdif;
int count, expand;
if (!sd->changed) return;
// local variables
x = sd->x;
y = sd->y;
w = sd->w;
h = sd->h;
// Calculate extents
_e_flowlayout_smart_extents_calcuate(sd);
minw = sd->min.w;
minh = sd->min.h;
count = evas_list_count(sd->items);
expand = 0;
// Too small? move a little
if (w < minw)
{
x = x + ((w - minw) * (1.0 - sd->align.x));
w = minw;
}
if (h < minh)
{
y = y + ((h - minh) * (1.0 - sd->align.y));
h = minh;
}
// Some odd expanding counter
for (l = sd->items; l; l = l->next)
{
E_Flowlayout_Item *bi;
Evas_Object *obj;
obj = l->data;
bi = evas_object_data_get(obj, "e_flowlayout_data");
if (bi)
{
if (sd->horizontal)
{
if (bi->expand_w) expand++;
}
else
{
if (bi->expand_h) expand++;
}
}
}
// If no expansion, w is minw, h is minh
if (expand == 0)
{
if (sd->horizontal)
{
x += (double)(w - minw) * sd->align.x;
w = minw;
}
else
{
y += (double)(h - minh) * sd->align.y;
h = minh;
}
}
// Some calculations
wdif = w - minw;
hdif = h - minh;
if (sd->flowright)
xx = x;
else
xx = x + w;
if (sd->flowbottom)
yy = y;
else
yy = y + h;
cr = 0;
cc = 0;
// Now for the real deal
for (l = sd->items; l; l = l->next)
{
E_Flowlayout_Item *bi;
Evas_Object *obj;
obj = l->data;
bi = evas_object_data_get(obj, "e_flowlayout_data");
if (bi)
{
// Horiziontal
if (sd->horizontal)
{
// Homogenous
if (sd->homogenous)
{
Evas_Coord ww, hh, ow, oh;
ww = w / sd->cols;
hh = h / sd->rows;
if (sd->fill)
{
int num = count - (cr)*(sd->cols);
if (num < sd->cols)
{
ww = w / num;
}
}
ow = bi->min.w;
if (bi->fill_w) ow = ww;
if ((bi->max.w >= 0) && (bi->max.w < ow)) ow = bi->max.w;
oh = bi->min.h;
if (bi->fill_h) oh = hh;
if ((bi->max.h >= 0) && (bi->max.h < oh)) oh = bi->max.h;
if (sd->flowright)
{
if (sd->flowbottom)
{
evas_object_move(obj,
xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
}
else
{
evas_object_move(obj,
xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
yy - hh + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
}
evas_object_resize(obj, ow, oh);
xx += ww;
}
else
{
if (sd->flowbottom)
{
evas_object_move(obj,
xx - ww + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
}
else
{
evas_object_move(obj,
xx - ww + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
yy - hh + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
}
evas_object_resize(obj, ow, oh);
xx -= ww;
}
cc++;
if (cc >= sd->cols)
{
cc = 0;
cr++;
if (sd->flowright)
xx = x;
else
xx = x + w;
if (sd->flowbottom)
yy += hh;
else
yy -= hh;
}
}
/* TODO Nonhomogenous Horizontal */
else
{
}
}
// Vertical
else
{
if (sd->homogenous)
{
Evas_Coord ww, hh, ow, oh;
ww = w / sd->cols;
hh = h / sd->rows;
if (sd->fill)
{
int num = count - (cc)*(sd->rows);
if (num < sd->rows)
{
hh = h / num;
}
}
oh = bi->min.h;
if (bi->fill_h) oh = hh;
if ((bi->max.h >= 0) && (bi->max.h < oh)) oh = bi->max.h;
ow = bi->min.w;
if (bi->fill_w) ow = ww;
if ((bi->max.w >= 0) && (bi->max.w < ow)) ow = bi->max.w;
if (sd->flowbottom)
{
if (sd->flowright)
{
evas_object_move(obj,
xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
}
else
{
evas_object_move(obj,
xx - ww + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
yy + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
}
evas_object_resize(obj, ow, oh);
yy += hh;
}
else
{
if (sd->flowright)
{
evas_object_move(obj,
xx + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
yy - hh + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
}
else
{
evas_object_move(obj,
xx - ww + (Evas_Coord)(((double)(ww - ow)) * bi->align.x),
yy - hh + (Evas_Coord)(((double)(hh - oh)) * bi->align.y));
}
evas_object_resize(obj, ow, oh);
yy -= hh;
}
cr++;
if (cr >= sd->rows)
{
cr = 0;
cc++;
if (sd->flowbottom)
yy = y;
else
yy = y + h;
if (sd->flowright)
xx += ww;
else
xx -= ww;
}
}
/* TODO Nonhomogeneous Vertical */
else
{
}
}
}
}
sd->changed = 0;
}
static void
_e_flowlayout_smart_extents_calcuate(E_Smart_Data *sd)
{
Evas_List *l;
int minw, minh, totalw, totalh, count;
/* FIXME: need to calc max */
sd->max.w = -1; /* max < 0 == unlimited */
sd->max.h = -1;
minw = 1;
minh = 1;
if (sd->homogenous)
{
for (l = sd->items; l; l = l->next)
{
E_Flowlayout_Item *bi;
Evas_Object *obj;
obj = l->data;
bi = evas_object_data_get(obj, "e_flowlayout_data");
if (bi)
{
if (sd->horizontal)
{
if (minh < bi->min.h) minh = bi->min.h;
if (minw < bi->min.w) minw = bi->min.w;
}
else
{
if (minw < bi->min.w) minw = bi->min.w;
if (minh < bi->min.h) minh = bi->min.h;
}
}
}
if (sd->horizontal)
{
sd->rows = sd->h/minh;
if (sd->rows<1)
sd->rows = 1;
count = evas_list_count(sd->items);
sd->cols = sd->w/minw;
}
else
{
sd->cols = sd->w/minw;
if (sd->cols<1)
sd->cols = 1;
count = evas_list_count(sd->items);
sd->rows = sd->h/minh;
}
minw *= sd->cols;
minh *= sd->rows;
}
/* TODO nonhomogenous */
else
{
for (l = sd->items; l; l = l->next)
{
E_Flowlayout_Item *bi;
Evas_Object *obj;
obj = l->data;
bi = evas_object_data_get(obj, "e_flowlayout_data");
if (bi)
{
if (sd->horizontal)
{
if (minh < bi->min.h) minh = bi->min.h*sd->rows;
minw += bi->min.w;
}
else
{
if (minw < bi->min.w) minw = bi->min.w*sd->cols;
minh += bi->min.h;
}
}
}
if (sd->horizontal)
{
sd->rows = sd->h/minh;
minh *= sd->rows;
sd->cols = -1;
minw = minw/sd->cols + 0.2*minw;
}
else
{
sd->cols = sd->w/minw;
minw *= sd->cols;
sd->rows = -1;
minh = minh/sd->cols + 0.2*minh;
}
}
sd->min.w = minw;
sd->min.h = minh;
if (sd->rows < 1)
sd->rows = 1;
if (sd->cols < 1)
sd->cols = 1;
}
static void
_e_flowlayout_smart_init(void)
{
if (_e_smart) return;
_e_smart = evas_smart_new("e_flowlayout",
_e_flowlayout_smart_add,
_e_flowlayout_smart_del,
NULL, NULL, NULL, NULL, NULL,
_e_flowlayout_smart_move,
_e_flowlayout_smart_resize,
_e_flowlayout_smart_show,
_e_flowlayout_smart_hide,
_e_flowlayout_smart_color_set,
_e_flowlayout_smart_clip_set,
_e_flowlayout_smart_clip_unset,
NULL);
}
static void
_e_flowlayout_smart_add(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = calloc(1, sizeof(E_Smart_Data));
if (!sd) return;
sd->obj = obj;
sd->x = 0;
sd->y = 0;
sd->w = 0;
sd->h = 0;
sd->align.x = 0.5;
sd->align.y = 0.5;
sd->clip = evas_object_rectangle_add(evas_object_evas_get(obj));
evas_object_smart_member_add(sd->clip, obj);
evas_object_move(sd->clip, -100004, -100004);
evas_object_resize(sd->clip, 200008, 200008);
evas_object_color_set(sd->clip, 255, 255, 255, 255);
evas_object_smart_data_set(obj, sd);
}
static void
_e_flowlayout_smart_del(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
/* FIXME: this gets into an infinite loop when changin basic->advanced on
* ibar config dialog
*/
while (sd->items)
{
Evas_Object *child;
child = sd->items->data;
e_flowlayout_unpack(child);
}
evas_object_del(sd->clip);
free(sd);
}
static void
_e_flowlayout_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if ((x == sd->x) && (y == sd->y)) return;
{
Evas_List *l;
Evas_Coord dx, dy;
dx = x - sd->x;
dy = y - sd->y;
for (l = sd->items; l; l = l->next)
{
Evas_Coord ox, oy;
evas_object_geometry_get(l->data, &ox, &oy, NULL, NULL);
evas_object_move(l->data, ox + dx, oy + dy);
}
}
sd->x = x;
sd->y = y;
}
static void
_e_flowlayout_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if ((w == sd->w) && (h == sd->h)) return;
sd->w = w;
sd->h = h;
sd->changed = 1;
_e_flowlayout_smart_reconfigure(sd);
}
static void
_e_flowlayout_smart_show(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (sd->items) evas_object_show(sd->clip);
}
static void
_e_flowlayout_smart_hide(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_hide(sd->clip);
}
static void
_e_flowlayout_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_color_set(sd->clip, r, g, b, a);
}
static void
_e_flowlayout_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_clip_set(sd->clip, clip);
}
static void
_e_flowlayout_smart_clip_unset(Evas_Object *obj)
{
E_Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_clip_unset(sd->clip);
}

37
src/bin/e_flowlayout.h Normal file
View File

@ -0,0 +1,37 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef E_TYPEDEFS
#else
#ifndef E_FLOWLAYOUT_H
#define E_FLOWLAYOUT_H
EAPI Evas_Object *e_flowlayout_add (Evas *evas);
EAPI int e_flowlayout_freeze (Evas_Object *obj);
EAPI int e_flowlayout_thaw (Evas_Object *obj);
EAPI void e_flowlayout_orientation_set (Evas_Object *obj, int horizontal);
EAPI int e_flowlayout_orientation_get (Evas_Object *obj);
EAPI void e_flowlayout_flowdirection_set (Evas_Object *obj, int right, int bottom);
EAPI void e_flowlayout_flowdirection_get (Evas_Object *obj, int *right, int *bottom);
EAPI void e_flowlayout_homogenous_set (Evas_Object *obj, int homogenous);
EAPI int e_flowlayout_fill_get (Evas_Object *obj);
EAPI void e_flowlayout_fill_set (Evas_Object *obj, int fill);
EAPI int e_flowlayout_pack_start (Evas_Object *obj, Evas_Object *child);
EAPI int e_flowlayout_pack_end (Evas_Object *obj, Evas_Object *child);
EAPI int e_flowlayout_pack_before (Evas_Object *obj, Evas_Object *child, Evas_Object *before);
EAPI int e_flowlayout_pack_after (Evas_Object *obj, Evas_Object *child, Evas_Object *after);
EAPI int e_flowlayout_pack_count_get (Evas_Object *obj);
EAPI Evas_Object *e_flowlayout_pack_object_nth (Evas_Object *obj, int n);
EAPI Evas_Object *e_flowlayout_pack_object_first (Evas_Object *obj);
EAPI Evas_Object *e_flowlayout_pack_object_last (Evas_Object *obj);
EAPI void e_flowlayout_pack_options_set (Evas_Object *obj, int fill_w, int fill_h, int expand_w, int expand_h, double align_x, double align_y, Evas_Coord min_w, Evas_Coord min_h, Evas_Coord max_w, Evas_Coord max_h);
EAPI void e_flowlayout_unpack (Evas_Object *obj);
EAPI void e_flowlayout_min_size_get (Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh);
EAPI void e_flowlayout_max_size_get (Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh);
EAPI void e_flowlayout_align_get (Evas_Object *obj, double *ax, double *ay);
EAPI void e_flowlayout_align_set (Evas_Object *obj, double ax, double ay);
// This function only works if homogenous is set
EAPI int e_flowlayout_max_children (Evas_Object *obj);
#endif
#endif

View File

@ -17,6 +17,7 @@
#include "e_menu.h"
#include "e_icon.h"
#include "e_box.h"
#include "e_flowlayout.h"
#include "e_editable.h"
#include "e_entry.h"
#include "e_init.h"

View File

@ -783,6 +783,7 @@ e_util_file_time_get(time_t ftime)
}
static char *prev_ld_library_path = NULL;
static char *prev_path = NULL;
EAPI void
e_util_library_path_strip(void)
@ -798,6 +799,15 @@ e_util_library_path_strip(void)
if (p2) p2++;
e_util_env_set("LD_LIBRARY_PATH", p2);
}
p = getenv("PATH");
E_FREE(prev_path);
if (p)
{
prev_path = strdup(p);
p2 = strchr(p, ':');
if (p2) p2++;
e_util_env_set("PATH", p2);
}
}
EAPI void
@ -806,6 +816,9 @@ e_util_library_path_restore(void)
if (!prev_ld_library_path) return;
e_util_env_set("LD_LIBRARY_PATH", prev_ld_library_path);
E_FREE(prev_ld_library_path);
if (!prev_path) return;
e_util_env_set("PATH", prev_path);
E_FREE(prev_path);
}
/* local subsystem functions */