add preview widget to Virtual Desktops dialog


			
			
				devs/princeamd/enlightenment-0.17-elive
			
			
		
rephorm 17 years ago committed by rephorm
parent dd71fee254
commit 7c2f28556a
  1. 3
      data/themes/Makefile.am
  2. 1
      data/themes/default.edc
  3. 58
      data/themes/default_deskpreview.edc
  4. 6
      src/bin/Makefile.am
  5. 15
      src/bin/e_bg.c
  6. 2
      src/bin/e_bg.h
  7. 2
      src/bin/e_includes.h
  8. 23
      src/bin/e_int_config_desks.c
  9. 119
      src/bin/e_widget_aspect.c
  10. 6
      src/bin/e_widget_aspect.h
  11. 183
      src/bin/e_widget_desk_preview.c
  12. 5
      src/bin/e_widget_desk_preview.h

@ -57,7 +57,8 @@ default_preview.edc \
default_cslider.edc \
default_spectrum.edc \
default_color_well.edc \
default_sys.edc
default_sys.edc \
default_deskpreview.edc
default.edj: Makefile $(EXTRA_DIST)
$(EDJE_CC) $(EDJE_FLAGS) \

@ -75,5 +75,6 @@ collections {
#include "default_spectrum.edc"
#include "default_color_well.edc"
#include "default_sys.edc"
#include "default_deskpreview.edc"
}

@ -0,0 +1,58 @@
group {
name: "e/widgets/deskpreview/desk";
parts {
part {
name: "clip";
mouse_events: 0;
type: RECT;
description {
state: "default" 0.0;
rel1 {
offset: 2 2;
}
rel2 {
offset: -3 -3;
}
color: 255 255 255 255;
}
}
part {
name: "overlay";
mouse_events: 1;
description {
state: "default" 0.0;
rel1 {
offset: 1 1;
}
rel2 {
offset: -2 -2;
}
image {
normal: "e17_pager_desk.png";
border: 2 2 2 2;
middle: 0;
}
fill {
smooth: 0;
}
color: 255 255 255 255;
}
}
part {
name: "e.swallow.desk";
mouse_events: 0;
type: SWALLOW;
clip_to: "clip";
description {
state: "default" 0.0;
rel1 {
offset: 2 2;
}
rel2 {
offset: -3 -3;
}
color: 0 0 0 0;
}
}
}
}

@ -172,7 +172,9 @@ e_fdo_menu_to_order.h \
e_sys.h \
e_obj_dialog.h \
e_int_config_transitions.h \
e_fwin.h
e_fwin.h \
e_widget_aspect.h \
e_widget_desk_preview.h
enlightenment_src = \
e_user.c \
@ -321,6 +323,8 @@ e_sys.c \
e_int_config_transitions.c \
e_obj_dialog.c \
e_fwin.c \
e_widget_aspect.c \
e_widget_desk_preview.c \
$(ENLIGHTENMENTHEADERS)
enlightenment_SOURCES = \

@ -10,22 +10,24 @@ static void _e_bg_signal(void *data, Evas_Object *obj, const char *emission, con
/* externally accessible functions */
EAPI const char *
e_bg_file_get(E_Zone *zone)
e_bg_file_get(E_Zone *zone, E_Desk *desk)
{
Evas_List *l, *ll, *entries;
int ok;
const char *bgfile = "";
if (!zone) zone = e_zone_current_get(e_container_current_get(e_manager_current_get()));
ok = 0;
for (l = e_config->desktop_backgrounds; l; l = l->next)
/* look for desk specific background. if desk is NULL this is skipped */
for (l = e_config->desktop_backgrounds; desk && l; l = l->next)
{
E_Config_Desktop_Background *cfbg;
E_Desk *desk;
cfbg = l->data;
if ((cfbg->container >= 0) && (zone->container->num != cfbg->container)) continue;
if ((cfbg->zone >= 0) && (zone->num != cfbg->zone)) continue;
desk = e_desk_current_get(zone);
if (!desk) continue;
if ((cfbg->desk_x >= 0) && (cfbg->desk_x != desk->x)) continue;
if ((cfbg->desk_y >= 0) && (cfbg->desk_y != desk->y)) continue;
entries = edje_file_collection_list(cfbg->file);
@ -44,6 +46,7 @@ e_bg_file_get(E_Zone *zone)
}
break;
}
/* fall back to default bg for zone */
if (!ok)
{
entries = edje_file_collection_list(e_config->desktop_default_background);
@ -80,7 +83,7 @@ e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition)
else if (transition == E_BG_TRANSITION_CHANGE) trans = e_config->transition_change;
if ((!trans) || (strlen(trans) < 1)) transition = E_BG_TRANSITION_NONE;
bgfile = e_bg_file_get(zone);
bgfile = e_bg_file_get(zone, e_desk_current_get(zone));
if (zone->bg_object)
{

@ -14,7 +14,7 @@ typedef enum {
#ifndef E_BG_H
#define E_BG_H
EAPI const char *e_bg_file_get(E_Zone *zone);
EAPI const char *e_bg_file_get(E_Zone *zone, E_Desk *desk);
EAPI void e_bg_zone_update(E_Zone *zone, E_Bg_Transition transition);
EAPI void e_bg_add(int container, int zone, int desk_x, int desk_y, char *file);
EAPI void e_bg_del(int container, int zone, int desk_x, int desk_y);

@ -149,3 +149,5 @@
#include "e_int_config_transitions.h"
#include "e_obj_dialog.h"
#include "e_fwin.h"
#include "e_widget_aspect.h"
#include "e_widget_desk_preview.h"

@ -10,6 +10,7 @@ static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
static int _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static void _cb_slider_change(void *data, Evas_Object *obj);
/* Actual config data we will be playing with whil the dialog is active */
struct _E_Config_Dialog_Data
@ -28,6 +29,9 @@ struct _E_Config_Dialog_Data
int flip_mode;
int flip_interp;
double flip_speed;
/*- GUI -*/
Evas_Object *preview;
};
/* a nice easy setup function that does the dirty work */
@ -186,11 +190,19 @@ _basic_create_widgets(E_Config_Dialog *cdd, Evas *evas, E_Config_Dialog_Data *cf
of = e_widget_framelist_add(evas, _("Number of Desktops"), 0);
ot = e_widget_table_add(evas, 0);
ob = e_widget_desk_preview_add(evas, cfdata->x, cfdata->y);
e_widget_table_object_append(ot, ob, 0, 0, 1, 1, 1, 1, 1, 1);
cfdata->preview = ob;
ob = e_widget_slider_add(evas, 0, 0, _("%1.0f"), 1.0, 12.0, 1.0, 0, NULL, &(cfdata->y), 150);
e_widget_on_change_hook_set(ob, _cb_slider_change, cfdata);
e_widget_table_object_append(ot, ob, 1, 0, 1, 1, 0, 1, 0, 1);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), 1.0, 12.0, 1.0, 0, NULL, &(cfdata->x), 200);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), 1.0, 12.0, 1.0, 0, NULL, &(cfdata->x), 200);
e_widget_on_change_hook_set(ob, _cb_slider_change, cfdata);
e_widget_table_object_append(ot, ob, 0, 1, 1, 1, 1, 0, 1, 0);
e_widget_framelist_object_append(of, ot);
e_widget_list_object_append(o, of, 1, 1, 0.5);
@ -253,3 +265,12 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
return o;
}
static void
_cb_slider_change(void *data, Evas_Object *obj)
{
E_Config_Dialog_Data *cfdata = data;
e_widget_desk_preview_num_desks_set(cfdata->preview, cfdata->x, cfdata->y);
}

@ -0,0 +1,119 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
/* TODO: support different preference modes ala edje */
#include "e.h"
typedef struct _E_Widget_Data E_Widget_Data;
struct _E_Widget_Data
{
Evas_Object *obj;
Evas_Object *child;
int aspect_w, aspect_h;
int aspect_preference;
};
static void
_e_wid_del_hook(Evas_Object *obj)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
if (!wd) return;
free(wd);
}
static void
_e_wid_reconfigure(E_Widget_Data *wd)
{
int px, py, pw, ph;
int cx, cy, cw, ch;
double ap, ad;
if (!wd->obj || !wd->child) return;
evas_object_geometry_get(wd->obj, &px, &py, &pw, &ph);
ap = (double)pw / ph;
ad = (double)(wd->aspect_w) / wd->aspect_h;
if (ap >= ad)
{
ch = ph;
cw = (ch * wd->aspect_w) / wd->aspect_h;
}
else
{
cw = pw;
ch = (cw * wd->aspect_h) / wd->aspect_w;
}
cx = px + ((pw - cw) / 2);
cy = py + ((ph - ch) / 2);
evas_object_resize(wd->child, cw, ch);
evas_object_move(wd->child, cx, cy);
}
static void
_e_wid_resize_intercept(void *data, Evas_Object *obj, int w, int h)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
if (!wd) return;
evas_object_resize(obj, w, h);
_e_wid_reconfigure(wd);
}
Evas_Object *
e_widget_aspect_add(Evas *evas, int w, int h)
{
Evas_Object *obj;
E_Widget_Data *wd;
obj = e_widget_add(evas);
wd = calloc(1, sizeof(E_Widget_Data));
wd->obj = obj;
e_widget_data_set(obj, wd);
e_widget_del_hook_set(obj, _e_wid_del_hook);
evas_object_intercept_resize_callback_add(obj, _e_wid_resize_intercept, wd);
e_widget_aspect_aspect_set(obj, w, h);
return obj;
}
void
e_widget_aspect_aspect_set(Evas_Object *obj, int w, int h)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
if (!wd) return;
wd->aspect_w = w;
wd->aspect_h = h;
_e_wid_reconfigure(wd);
}
void
e_widget_aspect_child_set(Evas_Object *obj, Evas_Object *child)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
if (!wd) return;
wd->child = child;
_e_wid_reconfigure(wd);
}

@ -0,0 +1,6 @@
#ifndef E_WIDGET_ASPECT_H
#define E_WIDGET_ASPECT_H
Evas_Object *e_widget_aspect_add(Evas *evas, int w, int h);
void e_widget_aspect_aspect_set(Evas_Object *obj, int w, int h);
void e_widget_aspect_child_set(Evas_Object *obj, Evas_Object *child);
#endif

@ -0,0 +1,183 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "e.h"
typedef struct _E_Widget_Data E_Widget_Data;
struct _E_Widget_Data
{
Evas_Object *obj;
Evas_Object *aspect;
Evas_Object *table;
Evas_List *desks;
int w, h;
int desk_count_x, desk_count_y;
};
static void
_e_wid_desks_free(E_Widget_Data *wd)
{
Evas_List *l;
for (l = wd->desks; l; l = l->next)
{
Evas_Object *desk = l->data;
e_widget_sub_object_del(wd->obj, desk);
evas_object_del(desk);
}
evas_list_free(wd->desks);
wd->desks = NULL;
if (wd->table)
{
e_widget_sub_object_del(wd->obj, wd->table);
evas_object_del(wd->table);
}
wd->table = NULL;
if (wd->aspect)
{
e_widget_sub_object_del(wd->obj, wd->aspect);
evas_object_del(wd->aspect);
}
wd->aspect = NULL;
}
static void
_e_wid_del_hook(Evas_Object *obj)
{
E_Widget_Data *wd;
wd = e_widget_data_get(obj);
if (!wd) return;
_e_wid_desks_free(wd);
free(wd);
}
/*
* XXX break this into num_desks_set and _reconfigure calls
* XXX don't completely redraw on change just add/del rows/columns and update min sizes
*/
void
e_widget_desk_preview_num_desks_set(Evas_Object *obj, int nx, int ny)
{
E_Widget_Data *wd;
Evas_Object *o;
int x, y;
int aw, ah; /* available */
int mw, mh; /* min size for each desk */
int tw, th; /* size to thumb at */
E_Zone *zone;
wd = e_widget_data_get(obj);
if (!wd) return;
wd->desk_count_x = nx;
wd->desk_count_y = ny;
_e_wid_desks_free(wd);
zone = e_zone_current_get(e_container_current_get(e_manager_current_get()));
o = e_widget_aspect_add(evas_object_evas_get(obj), zone->w * nx, zone->h * ny);
e_widget_resize_object_set(obj, o);
e_widget_sub_object_add(obj, o);
evas_object_show(o);
wd->aspect = o;
o = e_widget_table_add(evas_object_evas_get(obj), 1);
e_widget_sub_object_add(obj, o);
evas_object_show(o);
e_widget_aspect_child_set(wd->aspect, o);
wd->table = o;
evas_object_geometry_get(wd->aspect, NULL, NULL, &aw, &ah);
if (ny > nx)
{
mh = ah / ny;
mw = (mh * zone->w) / zone->h;
}
else
{
mw = aw / nx;
mh = (mw * zone->h) / zone->w;
}
/* this happens when aw == 0 */
if (!mw)
{
mw = 10;
mh = (mw * zone->h) / zone->w;
}
e_widget_aspect_aspect_set(wd->aspect, mw * nx, mh * ny);
if (mw < 50)
tw = 50;
else if (mw < 150)
tw = 150;
else
tw = 300;
th = (tw * zone->h) / zone->w;
for (y = 0; y < ny; y++)
{
for (x = 0; x < nx; x++)
{
Evas_Object *overlay;
Evas_Object *dw;
const char *bgfile;
E_Desk *desk = NULL;
if (x < zone->desk_x_count && y < zone->desk_y_count)
desk = zone->desks[x + (y * zone->desk_x_count)];
bgfile = e_bg_file_get(zone, desk);
/* wrap desks in a widget (to set min size) */
dw = e_widget_add(evas_object_evas_get(obj));
e_widget_min_size_set(dw, mw, mh);
o = edje_object_add(evas_object_evas_get(obj));
e_theme_edje_object_set(o, "base/theme/widgets", "e/widgets/deskpreview/desk");
e_widget_resize_object_set(dw, o);
e_widget_sub_object_add(dw, o);
evas_object_show(o);
e_widget_sub_object_add(dw, o);
overlay = o;
o = e_thumb_icon_add(evas_object_evas_get(obj));
e_icon_fill_inside_set(o, 0);
e_thumb_icon_file_set(o, bgfile, "e/desktop/background");
e_thumb_icon_size_set(o, tw, th);
edje_object_part_swallow(overlay, "e.swallow.desk", o);
e_thumb_icon_begin(o);
evas_object_show(o);
e_widget_sub_object_add(dw, o);
e_widget_table_object_append(wd->table, dw, x, y, 1, 1, 1, 1, 1, 1);
wd->desks = evas_list_append(wd->desks, dw);
}
}
}
Evas_Object *
e_widget_desk_preview_add(Evas *evas, int nx, int ny)
{
Evas_Object *obj, *o;
E_Widget_Data *wd;
Evas_Coord iw, ih;
obj = e_widget_add(evas);
wd = calloc(1, sizeof(E_Widget_Data));
wd->obj = obj;
e_widget_data_set(obj, wd);
e_widget_del_hook_set(obj, _e_wid_del_hook);
e_widget_desk_preview_num_desks_set(obj, nx, ny);
return obj;
}

@ -0,0 +1,5 @@
#ifndef E_WIDGET_DESK_PREVIEW_H
#define E_WIDGET_DESK_PREVIEW_H
Evas_Object *e_widget_desk_preview_add(Evas *evas, int nx, int ny);
void e_widget_desk_preview_num_desks_set(Evas_Object *obj, int nx, int ny);
#endif
Loading…
Cancel
Save