bg now allows transitions when changing the bg. also a first step to allow

different bg's per desk - not implemented yet tho, but some infrastructure
for it


SVN revision: 15568
This commit is contained in:
Carsten Haitzler 2005-06-29 14:28:47 +00:00
parent 63fb8f4a12
commit e314c2cc04
12 changed files with 253 additions and 58 deletions

View File

@ -62,7 +62,8 @@ e_msg.h \
e_winlist.h \
e_alert.h \
e_maximize.h \
e_grabinput.h
e_grabinput.h \
e_bg.h
enlightenment_SOURCES = \
e_main.c \
@ -115,6 +116,7 @@ e_winlist.c \
e_alert.c \
e_maximize.c \
e_grabinput.c \
e_bg.c \
$(ENLIGHTENMENTHEADERS)
enlightenment_LDFLAGS = -export-dynamic @e_libs@ @x_libs@ @dlopen_libs@

View File

@ -15,6 +15,7 @@
#include <sys/time.h>
#include <sys/param.h>
#include <dlfcn.h>
#include <math.h>
#include <Evas.h>
#include <Ecore.h>

153
src/bin/e_bg.c Normal file
View File

@ -0,0 +1,153 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
/* local subsystem functions */
static int _e_bg_animator(void *data);
/* local subsystem globals */
/* externally accessible functions */
void
e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition)
{
Evas_Object *o;
if (transition == E_BG_TRANSITION_START)
{
zone->bg_transition_mode = e_config->desktop_bg_start_transition;
zone->bg_transition_time = e_config->desktop_bg_start_transition_time;
}
else if (transition == E_BG_TRANSITION_DESK)
{
zone->bg_transition_mode = e_config->desktop_bg_desk_transition;
zone->bg_transition_time = e_config->desktop_bg_desk_transition_time;
}
else if (transition == E_BG_TRANSITION_CHANGE)
{
zone->bg_transition_mode = e_config->desktop_bg_change_transition;
zone->bg_transition_time = e_config->desktop_bg_change_transition_time;
}
if ((zone->bg_transition_mode == E_BG_TRANSITION_MODE_NONE) ||
(zone->bg_transition_time == 0.0))
transition = E_BG_TRANSITION_NONE;
if (zone->bg_transition_mode == E_BG_TRANSITION_MODE_RANDOM)
{
zone->bg_transition_mode =
(rand() % (E_BG_TRANSITION_MODE_LAST - E_BG_TRANSITION_MODE_RANDOM))
+ E_BG_TRANSITION_MODE_RANDOM + 1;
if (zone->bg_transition_mode <= E_BG_TRANSITION_MODE_RANDOM)
zone->bg_transition_mode = E_BG_TRANSITION_MODE_RANDOM + 1;
else if (zone->bg_transition_mode >= E_BG_TRANSITION_MODE_LAST)
zone->bg_transition_mode = E_BG_TRANSITION_MODE_LAST - 1;
}
if (transition == E_BG_TRANSITION_NONE)
{
if (zone->bg_object)
{
evas_object_del(zone->bg_object);
zone->bg_object = NULL;
}
}
if (transition != E_BG_TRANSITION_NONE)
{
if (zone->bg_object)
{
if (zone->prev_bg_object)
evas_object_del(zone->prev_bg_object);
zone->prev_bg_object = zone->bg_object;
zone->bg_object = NULL;
}
}
o = edje_object_add(zone->container->bg_evas);
zone->bg_object = o;
evas_object_data_set(o, "e_zone", zone);
evas_object_move(o, zone->x, zone->y);
evas_object_resize(o, zone->w, zone->h);
/* FIXME: check config and look for a special bg for the current desk */
if (!edje_object_file_set(o,
e_config->desktop_default_background,
"desktop/background"))
{
e_theme_edje_object_set(o, "base/theme/background",
"desktop/background");
}
evas_object_layer_set(o, -1);
evas_object_lower(o);
evas_object_clip_set(o, zone->bg_clip_object);
evas_object_show(o);
if (zone->prev_bg_object)
{
const char *pfile = "", *pgroup = "", *file = "", *group = "";
edje_object_file_get(zone->prev_bg_object, &pfile, &pgroup);
edje_object_file_get(zone->bg_object, &file, &group);
if ((pfile) && (file) && (!strcmp(pfile, file)) &&
(pgroup) && (group) && (!strcmp(pgroup, group)))
{
evas_object_del(zone->prev_bg_object);
zone->prev_bg_object = NULL;
return;
}
}
if (transition != E_BG_TRANSITION_NONE)
{
if (!zone->bg_animator)
zone->bg_animator= ecore_animator_add(_e_bg_animator, zone);
zone->bg_set_time = ecore_time_get();
}
}
/* local subsystem functions */
static int
_e_bg_animator(void *data)
{
E_Zone *zone;
double t;
int a;
zone = data;
/* t is an animating INDEX 0.0 - 1.0, it is used as a lookup into
* the effect. 1.0 == finished */
t = (ecore_time_get() - zone->bg_set_time) / zone->bg_transition_time;
if (t < 0.0) t = 0.0;
else if (t > 1.0) t = 1.0;
if (zone->bg_transition_mode == E_BG_TRANSITION_MODE_FADE)
{
a = (1.0 - t) * 255.0;
if (a < 0) a = 0;
else if (a > 255) a = 255;
evas_object_color_set(zone->prev_bg_object,
255, 255, 255, a);
}
else if (zone->bg_transition_mode == E_BG_TRANSITION_MODE_SINUSOUDAL_FADE)
{
double t2;
t2 = (1.0 - cos(t * M_PI)) / 2.0;
a = (1.0 - t2) * 255.0;
if (a < 0) a = 0;
else if (a > 255) a = 255;
evas_object_color_set(zone->prev_bg_object,
255, 255, 255, a);
}
/* if we still animate.. */
if (t < 1.0) return 1;
if (zone->prev_bg_object)
{
evas_object_del(zone->prev_bg_object);
zone->prev_bg_object = NULL;
}
zone->bg_animator = NULL;
return 0;
}

27
src/bin/e_bg.h Normal file
View File

@ -0,0 +1,27 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#ifdef E_TYPEDEFS
typedef enum {
E_BG_TRANSITION_NONE,
E_BG_TRANSITION_START,
E_BG_TRANSITION_DESK,
E_BG_TRANSITION_CHANGE
} E_Bg_Transition;
typedef enum {
E_BG_TRANSITION_MODE_NONE,
E_BG_TRANSITION_MODE_RANDOM,
E_BG_TRANSITION_MODE_FADE,
E_BG_TRANSITION_MODE_SINUSOUDAL_FADE,
E_BG_TRANSITION_MODE_LAST
} E_Bg_Transition_Mode;
#else
#ifndef E_BG_H
#define E_BG_H
void e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition);
#endif
#endif

View File

@ -175,6 +175,12 @@ e_config_init(void)
E_CONFIG_VAL(D, T, kill_timer_wait, DOUBLE);
E_CONFIG_VAL(D, T, ping_clients, INT);
E_CONFIG_VAL(D, T, ping_clients_wait, DOUBLE);
E_CONFIG_VAL(D, T, desktop_bg_start_transition, INT);
E_CONFIG_VAL(D, T, desktop_bg_start_transition_time, DOUBLE);
E_CONFIG_VAL(D, T, desktop_bg_desk_transition, INT);
E_CONFIG_VAL(D, T, desktop_bg_desk_transition_time, DOUBLE);
E_CONFIG_VAL(D, T, desktop_bg_change_transition, INT);
E_CONFIG_VAL(D, T, desktop_bg_change_transition_time, DOUBLE);
e_config = e_config_domain_load("e", _e_config_edd);
if (e_config)
@ -213,7 +219,7 @@ e_config_init(void)
e_config = E_NEW(E_Config, 1);
e_config->config_version = E_CONFIG_FILE_VERSION;
e_config->show_splash = 1;
e_config->desktop_default_background = strdup(PACKAGE_DATA_DIR"/data/themes/default.edj");
e_config->desktop_default_background = strdup("");
e_config->menus_scroll_speed = 1000.0;
e_config->menus_fast_mouse_move_threshhold = 300.0;
e_config->menus_click_drag_timeout = DEF_MENUCLICK;
@ -272,6 +278,12 @@ e_config_init(void)
e_config->kill_timer_wait = 10.0;
e_config->ping_clients = 1;
e_config->ping_clients_wait = 10.0;
e_config->desktop_bg_start_transition = E_BG_TRANSITION_MODE_NONE;
e_config->desktop_bg_start_transition_time = 1.0;
e_config->desktop_bg_desk_transition = E_BG_TRANSITION_MODE_SINUSOUDAL_FADE;
e_config->desktop_bg_desk_transition_time = 0.5;
e_config->desktop_bg_change_transition = E_BG_TRANSITION_MODE_SINUSOUDAL_FADE;
e_config->desktop_bg_change_transition_time = 1.0;
{
E_Config_Module *em;
@ -802,6 +814,12 @@ e_config_init(void)
E_CONFIG_LIMIT(e_config->kill_timer_wait, 0.0, 120.0);
E_CONFIG_LIMIT(e_config->ping_clients, 0, 1);
E_CONFIG_LIMIT(e_config->ping_clients_wait, 0.0, 120.0);
E_CONFIG_LIMIT(e_config->desktop_bg_start_transition, E_BG_TRANSITION_MODE_NONE, E_BG_TRANSITION_MODE_LAST);
E_CONFIG_LIMIT(e_config->desktop_bg_start_transition_time, 0.01, 60.0);
E_CONFIG_LIMIT(e_config->desktop_bg_desk_transition, E_BG_TRANSITION_MODE_NONE, E_BG_TRANSITION_MODE_LAST);
E_CONFIG_LIMIT(e_config->desktop_bg_desk_transition_time, 0.01, 60.0);
E_CONFIG_LIMIT(e_config->desktop_bg_change_transition, E_BG_TRANSITION_MODE_NONE, E_BG_TRANSITION_MODE_LAST);
E_CONFIG_LIMIT(e_config->desktop_bg_change_transition_time, 0.01, 60.0);
/* apply lang config - exception because config is loaded after intl setup */

View File

@ -46,7 +46,7 @@ typedef Eet_Data_Descriptor E_Config_DD;
* defaults for e to work - started at 100 when we introduced this config
* versioning feature
*/
#define E_CONFIG_FILE_VERSION 115
#define E_CONFIG_FILE_VERSION 116
#define E_EVAS_ENGINE_DEFAULT 0
#define E_EVAS_ENGINE_SOFTWARE_X11 1
@ -129,9 +129,14 @@ struct _E_Config
double kill_timer_wait;
int ping_clients;
double ping_clients_wait;
int desktop_bg_start_transition;
double desktop_bg_start_transition_time;
int desktop_bg_desk_transition;
double desktop_bg_desk_transition_time;
int desktop_bg_change_transition;
double desktop_bg_change_transition_time;
};
/* FIXME: all of thsie needs to become eet lumps for enmcode/decode */
struct _E_Config_Module
{
char *name;

View File

@ -71,7 +71,7 @@ void
e_desk_show(E_Desk *desk)
{
E_Border_List *bl;
int x, y;
int x, y, was_zone = 0;
E_Event_Desk_Show *ev;
E_Border *bd;
@ -80,6 +80,7 @@ e_desk_show(E_Desk *desk)
if (desk->visible) return;
bl = e_container_border_list_first(desk->zone->container);
if (desk->zone->bg_object) was_zone = 1;
while ((bd = e_container_border_list_next(bl)))
{
if ((bd->desk->zone == desk->zone) && (!bd->iconic))
@ -114,10 +115,16 @@ e_desk_show(E_Desk *desk)
evas_object_show(desk->bg_black_object);
desk->visible = 1;
if (was_zone)
e_bg_zone_update(desk->zone, E_BG_TRANSITION_CHANGE);
else
e_bg_zone_update(desk->zone, E_BG_TRANSITION_START);
ev = E_NEW(E_Event_Desk_Show, 1);
ev->desk = desk;
e_object_ref(E_OBJECT(desk));
ecore_event_add(E_EVENT_DESK_SHOW, ev, _e_border_event_desk_show_free, NULL);
}
void

View File

@ -50,3 +50,4 @@
#include "e_alert.h"
#include "e_maximize.h"
#include "e_grabinput.h"
#include "e_bg.h"

View File

@ -379,6 +379,13 @@ main(int argc, char **argv)
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_app_shutdown);
/* init theme system */
if (!e_theme_init())
{
e_error_message_show(_("Enlightenment cannot set up its theme system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_theme_shutdown);
/* manage the root window */
if (!_e_main_screens_init())
{
@ -390,13 +397,6 @@ main(int argc, char **argv)
e_container_all_freeze();
_e_main_shutdown_push(_e_main_screens_shutdown);
/* init theme system */
if (!e_theme_init())
{
e_error_message_show(_("Enlightenment cannot set up its theme system."));
_e_main_shutdown(-1);
}
_e_main_shutdown_push(e_theme_shutdown);
/* tell the error system that it can use gui dialogs now */

View File

@ -49,6 +49,7 @@ e_theme_init(void)
*
* other possible categories...
* e_theme_file_set("base/theme/borders", "default.edj");
* e_theme_file_set("base/theme/background", "default.edj");
* e_theme_file_set("base/theme/menus", "default.edj");
* e_theme_file_set("base/theme/error", "default.edj");
* e_theme_file_set("base/theme/gadman", "default.edj");

View File

@ -47,6 +47,7 @@ e_zone_new(E_Container *con, int num, int x, int y, int w, int h)
{
E_Zone *zone;
char name[40];
Evas_Object *o;
zone = E_OBJECT_ALLOC(E_Zone, E_ZONE_TYPE, _e_zone_free);
if (!zone) return NULL;
@ -80,44 +81,24 @@ e_zone_new(E_Container *con, int num, int x, int y, int w, int h)
con->zones = evas_list_append(con->zones, zone);
if (1)
{
char name[40];
Evas_Object *o;
o = evas_object_rectangle_add(con->bg_evas);
zone->bg_clip_object = o;
evas_object_move(o, x, y);
evas_object_resize(o, w, h);
evas_object_color_set(o, 255, 255, 255, 255);
evas_object_repeat_events_set(o, 1);
evas_object_show(o);
o = evas_object_rectangle_add(con->bg_evas);
zone->bg_clip_object = o;
evas_object_move(o, x, y);
evas_object_resize(o, w, h);
evas_object_color_set(o, 255, 255, 255, 255);
evas_object_repeat_events_set(o, 1);
evas_object_show(o);
o = edje_object_add(con->bg_evas);
zone->bg_object = o;
evas_object_layer_set(o, -1);
snprintf(name, sizeof(name), "desktop/background/%d", zone->num);
evas_object_name_set(o, name);
evas_object_data_set(o, "e_zone", zone);
evas_object_move(o, x, y);
evas_object_resize(o, w, h);
edje_object_file_set(o,
e_config->desktop_default_background,
"desktop/background");
evas_object_clip_set(o, zone->bg_clip_object);
evas_object_show(o);
o = evas_object_rectangle_add(con->bg_evas);
zone->bg_event_object = o;
evas_object_clip_set(o, zone->bg_clip_object);
evas_object_move(o, x, y);
evas_object_resize(o, w, h);
evas_object_color_set(o, 255, 255, 255, 0);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_zone_cb_bg_mouse_down, zone);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _e_zone_cb_bg_mouse_up, zone);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _e_zone_cb_bg_mouse_move, zone);
}
o = evas_object_rectangle_add(con->bg_evas);
zone->bg_event_object = o;
evas_object_clip_set(o, zone->bg_clip_object);
evas_object_move(o, x, y);
evas_object_resize(o, w, h);
evas_object_color_set(o, 255, 255, 255, 0);
evas_object_show(o);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_zone_cb_bg_mouse_down, zone);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _e_zone_cb_bg_mouse_up, zone);
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_MOVE, _e_zone_cb_bg_mouse_move, zone);
zone->desk_x_count = 0;
zone->desk_y_count = 0;
@ -239,17 +220,9 @@ e_zone_current_get(E_Container *con)
void
e_zone_bg_reconfigure(E_Zone *zone)
{
Evas_Object *o;
E_OBJECT_CHECK(zone);
E_OBJECT_TYPE_CHECK(zone, E_ZONE_TYPE);
o = zone->bg_object;
evas_object_hide(o);
edje_object_file_set(o,
e_config->desktop_default_background,
"desktop/background");
evas_object_layer_set(o, -1);
evas_object_show(o);
e_bg_zone_update(zone, E_BG_TRANSITION_CHANGE);
}
void
@ -569,6 +542,8 @@ _e_zone_free(E_Zone *zone)
evas_object_del(zone->bg_event_object);
evas_object_del(zone->bg_clip_object);
evas_object_del(zone->bg_object);
if (zone->prev_bg_object) evas_object_del(zone->prev_bg_object);
if (zone->bg_animator) ecore_animator_del(zone->bg_animator);
/* free desks */
for (x = 0; x < zone->desk_x_count; x++)
{

View File

@ -28,6 +28,11 @@ struct _E_Zone
Evas_Object *bg_object;
Evas_Object *bg_event_object;
Evas_Object *bg_clip_object;
Evas_Object *prev_bg_object;
Ecore_Animator *bg_animator;
double bg_set_time;
double bg_transition_time;
E_Bg_Transition_Mode bg_transition_mode;
int desk_x_count, desk_y_count;
int desk_x_current, desk_y_current;