2001-10-17 02:53:44 -07:00
|
|
|
#include "iconbar.h"
|
2001-10-19 07:35:39 -07:00
|
|
|
#include "util.h"
|
2001-10-17 02:53:44 -07:00
|
|
|
|
2001-10-19 02:13:18 -07:00
|
|
|
static E_Config_Base_Type *cf_iconbar = NULL;
|
|
|
|
static E_Config_Base_Type *cf_iconbar_icon = NULL;
|
2001-10-17 15:34:27 -07:00
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* internal func (iconbar use only) prototypes */
|
|
|
|
|
2001-10-19 07:35:39 -07:00
|
|
|
static void ib_timeout(int val, void *data);
|
|
|
|
|
2001-10-19 02:13:18 -07:00
|
|
|
static void ib_bits_show(void *data);
|
|
|
|
static void ib_bits_hide(void *data);
|
|
|
|
static void ib_bits_move(void *data, double x, double y);
|
|
|
|
static void ib_bits_resize(void *data, double w, double h);
|
|
|
|
static void ib_bits_raise(void *data);
|
|
|
|
static void ib_bits_lower(void *data);
|
|
|
|
static void ib_bits_set_layer(void *data, int l);
|
|
|
|
static void ib_bits_set_clip(void *data, Evas_Object clip);
|
|
|
|
static void ib_bits_set_color_class(void *data, char *cc, int r, int g, int b, int a);
|
|
|
|
static void ib_bits_get_min_size(void *data, double *w, double *h);
|
|
|
|
static void ib_bits_get_max_size(void *data, double *w, double *h);
|
|
|
|
|
|
|
|
static void ib_mouse_in(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
|
|
|
|
static void ib_mouse_out(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
|
|
|
|
static void ib_mouse_down(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
|
|
|
|
static void ib_mouse_up(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
|
2001-10-17 02:53:44 -07:00
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* NB: comments here for illustration & helping people understand E's code */
|
|
|
|
/* This is a start of the comments. if you feel they are not quite good */
|
|
|
|
/* as you figure things out and if you think they could be more helpful */
|
|
|
|
/* please feel free to add to them to make them easier to read and be more */
|
|
|
|
/* helpful. */
|
|
|
|
|
|
|
|
/* init function - initialised the iconbar system */
|
2001-10-17 02:53:44 -07:00
|
|
|
void
|
2001-10-19 02:13:18 -07:00
|
|
|
e_iconbar_init()
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 03:04:48 -07:00
|
|
|
/* we set up config structure and types so the config system can just */
|
|
|
|
/* read a db and dump it right into memory - including lists of stuff */
|
|
|
|
|
|
|
|
/* a new config type - an iconbar icon */
|
2001-10-19 02:13:18 -07:00
|
|
|
cf_iconbar_icon = e_config_type_new();
|
2001-10-19 03:04:48 -07:00
|
|
|
/* this is a member of the iconbar icon struct we want the config system */
|
|
|
|
/* to get from the db for us. the key is "exec". the type is a string */
|
|
|
|
/* the struct memebr is exec. the default value is "". see the config.h */
|
|
|
|
/* header for more info */
|
2001-10-19 02:13:18 -07:00
|
|
|
E_CONFIG_NODE(cf_iconbar_icon, "exec", E_CFG_TYPE_STR, NULL, E_Iconbar_Icon, exec, 0, 0, "");
|
2001-10-19 03:04:48 -07:00
|
|
|
/* this memebr will be replaced by the relative key path in the db as a */
|
|
|
|
/* string */
|
2001-10-19 02:13:18 -07:00
|
|
|
E_CONFIG_NODE(cf_iconbar_icon, "image", E_CFG_TYPE_KEY, NULL, E_Iconbar_Icon, image_path, 0, 0, "");
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* a new config type - in this case the iconbar istelf. the only thing we */
|
|
|
|
/* want the config system to do it fill it with iconbar icon members in */
|
|
|
|
/* the list */
|
2001-10-19 02:13:18 -07:00
|
|
|
cf_iconbar = e_config_type_new();
|
|
|
|
E_CONFIG_NODE(cf_iconbar, "icons", E_CFG_TYPE_LIST, cf_iconbar_icon, E_Iconbar, icons, 0, 0, NULL);
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* how do we crate a new iconbar? well... like this! */
|
2001-10-19 02:13:18 -07:00
|
|
|
E_Iconbar *
|
|
|
|
e_iconbar_new(E_View *v)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 02:13:18 -07:00
|
|
|
Evas_List l;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
E_Iconbar *ib;
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* first we want to load the iconbar data itself - ie the config info */
|
|
|
|
/* for what icons we have and what they execute */
|
|
|
|
sprintf(buf, "%s/.e_iconbar.db", v->dir);
|
|
|
|
/* use the config system to simply load up the db and start making */
|
|
|
|
/* structs and lists and stuff for us... we told it how to in init */
|
2001-10-19 02:13:18 -07:00
|
|
|
ib = e_config_load(buf, "", cf_iconbar);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* no iconbar config loaded ? return NULL */
|
2001-10-19 02:13:18 -07:00
|
|
|
if (!ib) return NULL;
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* now that the config system has doe the loading. we need to init the */
|
|
|
|
/* object and set up ref counts and free method */
|
2001-10-19 02:13:18 -07:00
|
|
|
OBJ_INIT(ib, e_iconbar_free);
|
2001-10-19 03:04:48 -07:00
|
|
|
|
|
|
|
/* the iconbar needs to know what view it's in */
|
2001-10-19 02:13:18 -07:00
|
|
|
ib->view = v;
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* now go thru all the icons that were loaded */
|
2001-10-19 02:13:18 -07:00
|
|
|
for (l = ib->icons; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Iconbar_Icon *ic;
|
|
|
|
|
|
|
|
ic = l->data;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* and init the iocnbar icon object */
|
2001-10-19 02:13:18 -07:00
|
|
|
OBJ_INIT(ic, e_iconbar_icon_free);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* and have the iconbar icon knwo what iconbar it belongs to */
|
2001-10-19 02:13:18 -07:00
|
|
|
ic->iconbar = ib;
|
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* now we need to load up a bits file that tells us where in the view the */
|
|
|
|
/* iconbar is meant to go. same place. just a slightly different name */
|
|
|
|
sprintf(buf, "%s/.e_iconbar.bits.db", v->dir);
|
2001-10-19 02:13:18 -07:00
|
|
|
ib->bit = ebits_load(buf);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* we didn't find one? */
|
2001-10-19 02:13:18 -07:00
|
|
|
if (!ib->bit)
|
|
|
|
{
|
2001-10-19 03:04:48 -07:00
|
|
|
/* unref the iconbar (and thus it will get freed and all icons in it */
|
2001-10-19 02:13:18 -07:00
|
|
|
OBJ_UNREF(ib);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* return NULL - no iconbar worth doing here if we don't know where */
|
|
|
|
/* to put it */
|
2001-10-19 02:13:18 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-10-19 03:04:48 -07:00
|
|
|
/* aaah. our nicely constructed iconbar data struct with all the goodies */
|
|
|
|
/* we need. return it. she's ready for use. */
|
2001-10-19 02:13:18 -07:00
|
|
|
return ib;
|
|
|
|
}
|
2001-10-17 02:53:44 -07:00
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* our free method for iconbars. how do we free these pesky little urchins */
|
2001-10-19 02:13:18 -07:00
|
|
|
void
|
|
|
|
e_iconbar_free(E_Iconbar *ib)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 03:04:48 -07:00
|
|
|
/* tell the view we attached to that somehting in it changed. this way */
|
|
|
|
/* the view will now it needs to redraw */
|
2001-10-19 02:13:18 -07:00
|
|
|
ib->view->changed = 1;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* free up our ebits */
|
2001-10-19 02:13:18 -07:00
|
|
|
if (ib->bit) ebits_free(ib->bit);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* if we have any icons... */
|
2001-10-19 02:13:18 -07:00
|
|
|
if (ib->icons)
|
|
|
|
{
|
|
|
|
Evas_List l;
|
2001-10-17 15:34:27 -07:00
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* go thru the list of icon and unref each one.. ie - free it */
|
2001-10-19 02:13:18 -07:00
|
|
|
for (l = ib->icons; l; l = l->next)
|
2001-10-17 15:34:27 -07:00
|
|
|
{
|
2001-10-19 02:13:18 -07:00
|
|
|
E_Iconbar_Icon *ic;
|
|
|
|
|
|
|
|
ic = l->data;
|
|
|
|
OBJ_UNREF(ic);
|
2001-10-17 15:34:27 -07:00
|
|
|
}
|
2001-10-19 03:04:48 -07:00
|
|
|
/* free the list itself */
|
2001-10-19 02:13:18 -07:00
|
|
|
evas_list_free(ib->icons);
|
|
|
|
}
|
2001-10-19 03:04:48 -07:00
|
|
|
/* free the iconbar struct */
|
|
|
|
FREE(ib);
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* how do we free an iconbar icon... well like this */
|
2001-10-17 02:53:44 -07:00
|
|
|
void
|
2001-10-19 02:13:18 -07:00
|
|
|
e_iconbar_icon_free(E_Iconbar_Icon *ic)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 03:04:48 -07:00
|
|
|
/* if we have an imageobject. nuke it */
|
2001-10-19 02:13:18 -07:00
|
|
|
if (ic->image) evas_del_object(ic->iconbar->view->evas, ic->image);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* free strings ... if they exist */
|
2001-10-19 02:13:18 -07:00
|
|
|
IF_FREE(ic->image_path);
|
|
|
|
IF_FREE(ic->exec);
|
2001-10-19 07:35:39 -07:00
|
|
|
/* stop the timer for this icon */
|
|
|
|
if (ic->hi.timer)
|
|
|
|
{
|
|
|
|
ecore_del_event_timer(ic->hi.timer);
|
|
|
|
FREE(ic->hi.timer);
|
|
|
|
}
|
|
|
|
if (ic->hi.image) evas_del_object(ic->iconbar->view->evas, ic->hi.image);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* nuke that struct */
|
2001-10-19 02:13:18 -07:00
|
|
|
FREE(ic);
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
2001-10-19 02:13:18 -07:00
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* turn our iconbar into more than a structure of config data. actually */
|
|
|
|
/* crate evas objcts we can do something visual with */
|
2001-10-17 02:53:44 -07:00
|
|
|
void
|
2001-10-19 02:13:18 -07:00
|
|
|
e_iconbar_realize(E_Iconbar *ib)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 02:13:18 -07:00
|
|
|
Evas_List l;
|
2001-10-19 03:04:48 -07:00
|
|
|
|
|
|
|
/* go thru every icon in the iconbar */
|
2001-10-19 02:13:18 -07:00
|
|
|
for (l = ib->icons; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Iconbar_Icon *ic;
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
ic = l->data;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* set the path of the image to load to be the iconbar db plus */
|
|
|
|
/* the path of the key to the image memebr - that is actually */
|
|
|
|
/* a lump of image data inlined in the iconbar db - so the icons */
|
|
|
|
/* themselves follow the iconbar wherever it goes */
|
2001-10-19 02:13:18 -07:00
|
|
|
sprintf(buf, "%s/.e_iconbar.db:%s", ib->view->dir, ic->image_path);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* add the icon image object */
|
2001-10-19 02:13:18 -07:00
|
|
|
ic->image = evas_add_image_from_file(ib->view->evas, buf);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* set it to be semi-transparent */
|
2001-10-19 02:13:18 -07:00
|
|
|
evas_set_color(ib->view->evas, ic->image, 255, 255, 255, 128);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* set up callbacks on events - so the ib_* functions will be */
|
|
|
|
/* called when the corresponding event happens to the icon */
|
2001-10-19 02:13:18 -07:00
|
|
|
evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_IN, ib_mouse_in, ic);
|
|
|
|
evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_OUT, ib_mouse_out, ic);
|
|
|
|
evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_DOWN, ib_mouse_down, ic);
|
|
|
|
evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_UP, ib_mouse_up, ic);
|
|
|
|
}
|
2001-10-19 03:04:48 -07:00
|
|
|
/* add the ebit we loaded to the evas the iconbar exists in - now the */
|
|
|
|
/* ebit is more than just structures as well. */
|
2001-10-19 02:13:18 -07:00
|
|
|
ebits_add_to_evas(ib->bit, ib->view->evas);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* aaaaaaaaah. the magic of being able to replace a named bit in an ebit */
|
|
|
|
/* (in this case we expect a bit called "Icons" to exist - the user will */
|
|
|
|
/* have added a bti called this into the ebit to indicate where he/she */
|
|
|
|
/* wants icons to go. we basically replace this bit with a virtual set */
|
|
|
|
/* of callbacks that ebits will call if this bit is to be moved, resized */
|
|
|
|
/* shown, hidden, raised, lowered etc. we provide the callbacks. */
|
2001-10-19 02:13:18 -07:00
|
|
|
ebits_set_named_bit_replace(ib->bit, "Icons",
|
|
|
|
ib_bits_show,
|
|
|
|
ib_bits_hide,
|
|
|
|
ib_bits_move,
|
|
|
|
ib_bits_resize,
|
|
|
|
ib_bits_raise,
|
|
|
|
ib_bits_lower,
|
|
|
|
ib_bits_set_layer,
|
|
|
|
ib_bits_set_clip,
|
|
|
|
ib_bits_set_color_class,
|
|
|
|
ib_bits_get_min_size,
|
|
|
|
ib_bits_get_max_size,
|
|
|
|
ib);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* now move this ebit to a really high layer.. so its ontop of a lot */
|
2001-10-19 02:13:18 -07:00
|
|
|
ebits_set_layer(ib->bit, 10000);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* and now call "fix" - i called it fix cause it does a few things... */
|
|
|
|
/* but fixes the iconbar so its the size of the view, in the right */
|
|
|
|
/* place and arranges the icons in their right spots */
|
2001-10-19 02:13:18 -07:00
|
|
|
e_iconbar_fix(ib);
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* fix up the geometry and visibility of the iconbar gfx and icons */
|
2001-10-17 02:53:44 -07:00
|
|
|
void
|
2001-10-19 02:13:18 -07:00
|
|
|
e_iconbar_fix(E_Iconbar *ib)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 02:13:18 -07:00
|
|
|
Evas_List l;
|
|
|
|
double ix, iy, aw, ah;
|
2001-10-19 03:04:48 -07:00
|
|
|
|
|
|
|
/* move the ebit to 0,0 */
|
2001-10-19 02:13:18 -07:00
|
|
|
ebits_move(ib->bit, 0, 0);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* resize it to fill the whole view. the internal geometry of the */
|
|
|
|
/* ebit itself will determine where things woudl go. we just tell */
|
|
|
|
/* the ebit where in the canvas its allowed to exist */
|
2001-10-19 02:13:18 -07:00
|
|
|
ebits_resize(ib->bit, ib->view->size.w, ib->view->size.h);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* show it. harmless to do this all the time */
|
2001-10-19 02:13:18 -07:00
|
|
|
ebits_show(ib->bit);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* tell the view we belong to something may have changed so it can draw */
|
2001-10-19 02:13:18 -07:00
|
|
|
ib->view->changed = 1;
|
2001-10-19 03:04:48 -07:00
|
|
|
|
|
|
|
/* the callbacks set up in th ebtis replace will set up what area in */
|
|
|
|
/* the canvas icons can exist in. lets extract them here */
|
2001-10-19 02:13:18 -07:00
|
|
|
ix = ib->icon_area.x;
|
|
|
|
iy = ib->icon_area.y;
|
|
|
|
aw = ib->icon_area.w;
|
|
|
|
ah = ib->icon_area.h;
|
2001-10-19 03:04:48 -07:00
|
|
|
|
|
|
|
/* not used yet... */
|
2001-10-19 02:13:18 -07:00
|
|
|
if (aw > ah) /* horizontal */
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else /* vertical */
|
|
|
|
{
|
|
|
|
}
|
2001-10-19 03:04:48 -07:00
|
|
|
|
|
|
|
/* now go thru all the icons... */
|
2001-10-19 02:13:18 -07:00
|
|
|
for (l = ib->icons; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Iconbar_Icon *ic;
|
|
|
|
int iw, ih;
|
|
|
|
double w, h;
|
|
|
|
double ox, oy;
|
|
|
|
|
|
|
|
ic = l->data;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* find out the original image size (of the image file) */
|
2001-10-19 02:13:18 -07:00
|
|
|
evas_get_image_size(ic->iconbar->view->evas, ic->image, &iw, &ih);
|
|
|
|
w = iw;
|
|
|
|
h = ih;
|
|
|
|
ox = 0;
|
|
|
|
oy = 0;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* if the area to put icons is wider that it is tall... horizonatal */
|
|
|
|
/* layout of the icons seems smart */
|
2001-10-19 02:13:18 -07:00
|
|
|
if (aw > ah) /* horizontal */
|
|
|
|
{
|
2001-10-19 03:04:48 -07:00
|
|
|
/* if the icon height is bigger than the icon space */
|
2001-10-19 02:13:18 -07:00
|
|
|
if (h > ah)
|
|
|
|
{
|
2001-10-19 03:04:48 -07:00
|
|
|
/* scale the icon down in both directions soit fits */
|
2001-10-19 02:13:18 -07:00
|
|
|
w = (ah * w) / h;
|
|
|
|
h = ah;
|
|
|
|
}
|
2001-10-19 03:04:48 -07:00
|
|
|
/* center the icon vertically if its smaller */
|
2001-10-19 02:13:18 -07:00
|
|
|
ox = 0;
|
|
|
|
oy = (ah - h) / 2;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* now move and resize it */
|
2001-10-19 02:13:18 -07:00
|
|
|
evas_move(ic->iconbar->view->evas, ic->image, ix + ox, iy + oy);
|
|
|
|
evas_resize(ic->iconbar->view->evas, ic->image, w, h);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* advance our position counter to the next spot */
|
2001-10-19 02:13:18 -07:00
|
|
|
ix += w;
|
|
|
|
}
|
2001-10-19 03:04:48 -07:00
|
|
|
/* taller than it is wide. might be good to be vertical */
|
2001-10-19 02:13:18 -07:00
|
|
|
else /* vertical */
|
|
|
|
{
|
2001-10-19 03:04:48 -07:00
|
|
|
/* if theicon width is bigger than the icon space */
|
2001-10-19 02:13:18 -07:00
|
|
|
if (w > aw)
|
|
|
|
{
|
2001-10-19 03:04:48 -07:00
|
|
|
/* scale it down to fit */
|
2001-10-19 02:13:18 -07:00
|
|
|
h = (aw * h) / w;
|
|
|
|
w = aw;
|
|
|
|
}
|
2001-10-19 03:04:48 -07:00
|
|
|
/* center it horizontally */
|
2001-10-19 02:13:18 -07:00
|
|
|
ox = (aw - w) / 2;
|
|
|
|
oy = 0;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* now move the icona nd resize it */
|
2001-10-19 02:13:18 -07:00
|
|
|
evas_move(ic->iconbar->view->evas, ic->image, ix + ox, iy + oy);
|
|
|
|
evas_resize(ic->iconbar->view->evas, ic->image, w, h);
|
2001-10-19 03:04:48 -07:00
|
|
|
/* advance out counter to the next spot */
|
2001-10-19 02:13:18 -07:00
|
|
|
iy += h;
|
|
|
|
}
|
|
|
|
}
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* static (internal to iconbar use only) callbacks */
|
|
|
|
|
2001-10-19 07:35:39 -07:00
|
|
|
/* this timeout is responsible for doing the mouse over animation */
|
|
|
|
static void
|
|
|
|
ib_timeout(int val, void *data)
|
|
|
|
{
|
|
|
|
E_Iconbar_Icon *ic;
|
|
|
|
double t;
|
|
|
|
|
|
|
|
/* get the iconbar icon we are dealign with */
|
|
|
|
ic = (E_Iconbar_Icon *)data;
|
2001-10-19 08:56:19 -07:00
|
|
|
/* val <= 0 AND we're hilited ? first call as a timeout handler. */
|
|
|
|
if ((val <= 0) && (ic->hilited))
|
2001-10-19 07:35:39 -07:00
|
|
|
{
|
|
|
|
char *n;
|
|
|
|
|
|
|
|
/* note the "start" time */
|
|
|
|
ic->hi.start = ecore_get_time();
|
|
|
|
/* no hilite (animation) image */
|
|
|
|
if (!ic->hi.image)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
/* figure out its path */
|
|
|
|
sprintf(buf, "%s/.e_iconbar.db:%s",
|
|
|
|
ic->iconbar->view->dir, ic->image_path);
|
|
|
|
/* add it */
|
|
|
|
ic->hi.image = evas_add_image_from_file(ic->iconbar->view->evas,
|
|
|
|
buf);
|
|
|
|
/* put it high up */
|
|
|
|
evas_set_layer(ic->iconbar->view->evas, ic->hi.image, 20000);
|
|
|
|
/* dont allow it to capture any events (enter, leave etc. */
|
|
|
|
evas_set_pass_events(ic->iconbar->view->evas, ic->hi.image, 1);
|
|
|
|
/* show it */
|
|
|
|
evas_show(ic->iconbar->view->evas, ic->hi.image);
|
|
|
|
}
|
2001-10-19 08:56:19 -07:00
|
|
|
/* start at 0 */
|
|
|
|
val = 0;
|
2001-10-19 07:35:39 -07:00
|
|
|
}
|
|
|
|
/* what tame is it ? */
|
|
|
|
t = ecore_get_time();
|
|
|
|
/* if the icon is hilited */
|
|
|
|
if (ic->hilited)
|
|
|
|
{
|
|
|
|
double x, y, w, h;
|
|
|
|
double nw, nh, tt;
|
|
|
|
int a;
|
|
|
|
double speed;
|
|
|
|
|
|
|
|
/* find out where the original icon image is */
|
|
|
|
evas_get_geometry(ic->iconbar->view->evas, ic->image, &x, &y, &w, &h);
|
|
|
|
/* tt is the time since we started */
|
|
|
|
tt = t - ic->hi.start;
|
|
|
|
/* the speed to run at - the less, the faster (ie a loop is 0.5 sec) */
|
|
|
|
speed = 0.5;
|
|
|
|
/* if we are beyond the time loop.. reset the start time to now */
|
|
|
|
if (tt > speed) ic->hi.start = t;
|
|
|
|
/* limit time to max loop time */
|
|
|
|
if (tt > speed) tt = speed;
|
|
|
|
/* calculate alpha to be invers of time sizne loop start */
|
|
|
|
a = (int)(255.0 * (speed - tt));
|
|
|
|
/* size is icon size + how far in loop we are */
|
|
|
|
nw = w * ((tt / speed) + 1.0);
|
|
|
|
nh = h * ((tt / speed) + 1.0);
|
|
|
|
/* move the hilite icon to a good spot */
|
|
|
|
evas_move(ic->iconbar->view->evas, ic->hi.image,
|
|
|
|
(x + (w / 2)) - (nw / 2),
|
|
|
|
(y + (h / 2)) - (nh / 2));
|
|
|
|
/* resize it */
|
|
|
|
evas_resize(ic->iconbar->view->evas, ic->hi.image, nw, nh);
|
|
|
|
/* reset its fill so ti fills its space */
|
|
|
|
evas_set_image_fill(ic->iconbar->view->evas, ic->hi.image, 0, 0, nw, nh);
|
|
|
|
/* set its fade */
|
|
|
|
evas_set_color(ic->iconbar->view->evas, ic->hi.image, 255, 255, 255, a);
|
2001-10-19 08:56:19 -07:00
|
|
|
/* incirment our count */
|
|
|
|
val++;
|
2001-10-19 07:35:39 -07:00
|
|
|
}
|
|
|
|
/* if it snot hilited */
|
|
|
|
else
|
|
|
|
{
|
2001-10-19 08:56:19 -07:00
|
|
|
double tt;
|
|
|
|
int a;
|
|
|
|
double speed;
|
|
|
|
|
2001-10-19 07:35:39 -07:00
|
|
|
/* delete the animation object */
|
|
|
|
if (ic->hi.image) evas_del_object(ic->iconbar->view->evas, ic->hi.image);
|
|
|
|
ic->hi.image = NULL;
|
2001-10-19 08:56:19 -07:00
|
|
|
|
|
|
|
/* if we were pulsating.. reset start timer */
|
|
|
|
if (val > 0)
|
|
|
|
{
|
|
|
|
ic->hi.start = t;
|
|
|
|
/* val back to 0 */
|
|
|
|
val = 0;
|
|
|
|
}
|
|
|
|
/* speed of the ramp */
|
|
|
|
speed = 1.0;
|
|
|
|
/* position on the fade out */
|
|
|
|
tt = (t - ic->hi.start) / speed;
|
|
|
|
if (tt > 1.0) tt = 1.0;
|
|
|
|
/* alpha value caluclated on ramp position */
|
|
|
|
a = (int)((double)((1.0 - tt) * 127.0) + 128.0);
|
|
|
|
/* set alpha value */
|
|
|
|
evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, a);
|
|
|
|
/* time is at end of ramp.. kill timer */
|
|
|
|
if (tt == 1.0)
|
|
|
|
{
|
|
|
|
/* free the timer name string */
|
|
|
|
IF_FREE(ic->hi.timer);
|
|
|
|
ic->hi.timer = NULL;
|
|
|
|
}
|
|
|
|
/* decrement count */
|
|
|
|
val--;
|
2001-10-19 07:35:39 -07:00
|
|
|
}
|
|
|
|
/* if we have a timer name.. rerun the timer in 0.05 */
|
|
|
|
if (ic->hi.timer)
|
2001-10-19 08:56:19 -07:00
|
|
|
ecore_add_event_timer(ic->hi.timer, 0.05, ib_timeout, val, data);
|
2001-10-19 07:35:39 -07:00
|
|
|
/* flag the view that we changed */
|
|
|
|
ic->iconbar->view->changed = 1;
|
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* called when an ebits object bit needs to be shown */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_bits_show(void *data)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 02:13:18 -07:00
|
|
|
E_Iconbar *ib;
|
|
|
|
Evas_List l;
|
|
|
|
|
|
|
|
ib = (E_Iconbar *)data;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* show all the icons */
|
2001-10-19 02:13:18 -07:00
|
|
|
for (l = ib->icons; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Iconbar_Icon *ic;
|
|
|
|
|
|
|
|
ic = l->data;
|
|
|
|
evas_show(ic->iconbar->view->evas, ic->image);
|
|
|
|
}
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* called when an ebit object bit needs to hide */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_bits_hide(void *data)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 02:13:18 -07:00
|
|
|
E_Iconbar *ib;
|
|
|
|
Evas_List l;
|
|
|
|
|
|
|
|
ib = (E_Iconbar *)data;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* hide all the icons */
|
2001-10-19 02:13:18 -07:00
|
|
|
for (l = ib->icons; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Iconbar_Icon *ic;
|
|
|
|
|
|
|
|
ic = l->data;
|
|
|
|
evas_hide(ic->iconbar->view->evas, ic->image);
|
|
|
|
}
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* called when an ebit objetc bit needs to move */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_bits_move(void *data, double x, double y)
|
|
|
|
{
|
|
|
|
E_Iconbar *ib;
|
|
|
|
Evas_List l;
|
|
|
|
|
|
|
|
ib = (E_Iconbar *)data;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* dont do anything.. just record the geometry. we'll deal with it later */
|
2001-10-19 02:13:18 -07:00
|
|
|
ib->icon_area.x = x;
|
|
|
|
ib->icon_area.y = y;
|
|
|
|
}
|
2001-10-17 02:53:44 -07:00
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* called when an ebit object bit needs to resize */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_bits_resize(void *data, double w, double h)
|
|
|
|
{
|
|
|
|
E_Iconbar *ib;
|
|
|
|
Evas_List l;
|
|
|
|
|
|
|
|
ib = (E_Iconbar *)data;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* dont do anything.. just record the geometry. we'll deal with it later */
|
2001-10-19 02:13:18 -07:00
|
|
|
ib->icon_area.w = w;
|
|
|
|
ib->icon_area.h = h;
|
|
|
|
}
|
2001-10-17 15:34:27 -07:00
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* called when the ebits object bit needs to be raised */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_bits_raise(void *data)
|
|
|
|
{
|
|
|
|
E_Iconbar *ib;
|
|
|
|
Evas_List l;
|
|
|
|
|
|
|
|
ib = (E_Iconbar *)data;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* raise all the icons */
|
2001-10-19 02:13:18 -07:00
|
|
|
for (l = ib->icons; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Iconbar_Icon *ic;
|
|
|
|
|
|
|
|
ic = l->data;
|
|
|
|
evas_raise(ic->iconbar->view->evas, ic->image);
|
|
|
|
}
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* called when the ebits object bit needs to be lowered */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_bits_lower(void *data)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 02:13:18 -07:00
|
|
|
E_Iconbar *ib;
|
|
|
|
Evas_List l;
|
|
|
|
|
|
|
|
ib = (E_Iconbar *)data;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* lower all the icons */
|
2001-10-19 02:13:18 -07:00
|
|
|
for (l = ib->icons; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Iconbar_Icon *ic;
|
|
|
|
|
|
|
|
ic = l->data;
|
|
|
|
evas_lower(ic->iconbar->view->evas, ic->image);
|
|
|
|
}
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* called when the ebits object bit needs to change layers */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_bits_set_layer(void *data, int lay)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 02:13:18 -07:00
|
|
|
E_Iconbar *ib;
|
|
|
|
Evas_List l;
|
|
|
|
|
|
|
|
ib = (E_Iconbar *)data;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* set the layer for all the icons */
|
2001-10-19 02:13:18 -07:00
|
|
|
for (l = ib->icons; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Iconbar_Icon *ic;
|
|
|
|
|
|
|
|
ic = l->data;
|
|
|
|
evas_set_layer(ic->iconbar->view->evas, ic->image, lay);
|
|
|
|
}
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* not used... err.. ebits clips for us to the maximum allowed space of */
|
|
|
|
/* the ebit object bit - dont know why i have this here */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_bits_set_clip(void *data, Evas_Object clip)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* we arent going to recolor our icons here according to color class */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_bits_set_color_class(void *data, char *cc, int r, int g, int b, int a)
|
|
|
|
{
|
|
|
|
}
|
2001-10-17 02:53:44 -07:00
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* our minimum size for icon space is 0x0 */
|
2001-10-17 02:53:44 -07:00
|
|
|
static void
|
2001-10-19 02:13:18 -07:00
|
|
|
ib_bits_get_min_size(void *data, double *w, double *h)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 02:13:18 -07:00
|
|
|
*w = 0;
|
|
|
|
*h = 0;
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* our maximum is huge */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_bits_get_max_size(void *data, double *w, double *h)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 02:13:18 -07:00
|
|
|
*w = 999999;
|
|
|
|
*h = 999999;
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* called on events on icons */
|
|
|
|
|
|
|
|
/* called when a mouse goes in on an icon object */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_mouse_in(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|
|
|
{
|
|
|
|
E_Iconbar_Icon *ic;
|
2001-10-19 03:04:48 -07:00
|
|
|
|
|
|
|
/* get he iconbaricon pointer from the data member */
|
2001-10-19 02:13:18 -07:00
|
|
|
ic = (E_Iconbar_Icon *)data;
|
2001-10-19 07:35:39 -07:00
|
|
|
/* set hilited flag */
|
|
|
|
ic->hilited = 1;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* make it more opaque */
|
2001-10-19 02:13:18 -07:00
|
|
|
evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, 255);
|
2001-10-19 07:35:39 -07:00
|
|
|
/* if we havent started an animation timer - start one */
|
|
|
|
if (!ic->hi.timer)
|
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
|
|
|
|
/* come up with a unique name for it */
|
|
|
|
sprintf(buf, "%s/%s", ic->iconbar->view->dir, ic->image_path);
|
|
|
|
e_strdup(ic->hi.timer, buf);
|
|
|
|
/* call the timeout */
|
|
|
|
ib_timeout(0, ic);
|
|
|
|
}
|
2001-10-19 03:04:48 -07:00
|
|
|
/* tell the view the iconbar is in.. something changed that might mean */
|
|
|
|
/* a redraw is needed */
|
2001-10-19 02:13:18 -07:00
|
|
|
ic->iconbar->view->changed = 1;
|
2001-10-19 07:35:39 -07:00
|
|
|
|
2001-10-19 02:13:18 -07:00
|
|
|
}
|
2001-10-17 02:53:44 -07:00
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* called when a mouse goes out of an icon object */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_mouse_out(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
2001-10-19 02:13:18 -07:00
|
|
|
E_Iconbar_Icon *ic;
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* get he iconbaricon pointer from the data member */
|
2001-10-19 02:13:18 -07:00
|
|
|
ic = (E_Iconbar_Icon *)data;
|
2001-10-19 07:35:39 -07:00
|
|
|
/* unset hilited flag */
|
|
|
|
ic->hilited = 0;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* tell the view the iconbar is in.. something changed that might mean */
|
|
|
|
/* a redraw is needed */
|
2001-10-19 02:13:18 -07:00
|
|
|
ic->iconbar->view->changed = 1;
|
2001-10-17 02:53:44 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* called when the mouse goes down on an icon object */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_mouse_down(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|
|
|
{
|
|
|
|
E_Iconbar_Icon *ic;
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* get he iconbaricon pointer from the data member */
|
2001-10-19 02:13:18 -07:00
|
|
|
ic = (E_Iconbar_Icon *)data;
|
2001-10-19 03:04:48 -07:00
|
|
|
/* run something! */
|
|
|
|
if (ic->exec) e_exec_run(ic->exec);
|
2001-10-19 02:13:18 -07:00
|
|
|
}
|
|
|
|
|
2001-10-19 03:04:48 -07:00
|
|
|
/* called when the mouse goes up on an icon object */
|
2001-10-19 02:13:18 -07:00
|
|
|
static void
|
|
|
|
ib_mouse_up(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
2001-10-17 02:53:44 -07:00
|
|
|
{
|
|
|
|
}
|