From: Enlightenment S. <no-...@en...> - 2011-02-23 15:53:29
|
Log: e-modules/comp-scale: added layout options per mode fix type use_w -> use_h, now grow option does not cause overlap anymore cleanups Author: jeffdameth Date: 2011-02-23 07:53:20 -0800 (Wed, 23 Feb 2011) New Revision: 57266 Trac: http://trac.enlightenment.org/e/changeset/57266 Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c 2011-02-23 13:03:55 UTC (rev 57265) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_config.c 2011-02-23 15:53:20 UTC (rev 57266) @@ -3,17 +3,21 @@ struct _E_Config_Dialog_Data { + int layout_mode; + double duration; + double spacing; int grow; int tight; - double duration; - double spacing; + + int desks_layout_mode; double desks_duration; double desks_spacing; + int desks_grow; + int desks_tight; + int fade_popups; int fade_desktop; int fade_windows; - int layout_mode; - int desks_layout_mode; }; @@ -82,6 +86,9 @@ cfdata->fade_desktop = scale_conf->fade_desktop; cfdata->layout_mode = scale_conf->layout_mode; cfdata->desks_layout_mode = scale_conf->desks_layout_mode; + cfdata->desks_tight = scale_conf->desks_tight; + cfdata->desks_grow = scale_conf->desks_grow; + } static void @@ -101,6 +108,8 @@ scale_conf->fade_desktop = cfdata->fade_desktop; scale_conf->layout_mode = cfdata->layout_mode; scale_conf->desks_layout_mode = cfdata->desks_layout_mode; + scale_conf->desks_grow = cfdata->desks_grow; + scale_conf->desks_tight = cfdata->desks_tight; scale_run(e_manager_current_get()); } @@ -128,10 +137,6 @@ e_widget_framelist_object_append (of, ow); ow = e_widget_check_add(evas, D_("Slotted Layout"), &(cfdata->layout_mode)); e_widget_framelist_object_append(of, ow); - - e_widget_list_object_append(o, of, 1, 1, 0.5); - - of = e_widget_framelist_add(evas, D_("Layout Options"), 0); e_widget_framelist_content_align_set(of, 0.0, 0.0); ow = e_widget_check_add(evas, D_("Grow more!"), &(cfdata->grow)); e_widget_framelist_object_append(of, ow); @@ -140,7 +145,6 @@ e_widget_list_object_append(o, of, 1, 1, 0.5); e_widget_table_object_append(ot, o, 0, 0, 1, 1, 1, 1, 0, 0); - o = e_widget_list_add(evas, 0, 0); of = e_widget_framelist_add(evas, D_("Show All Desktops"), 0); ow = e_widget_label_add (evas, D_("Minimum space between windows")); @@ -154,25 +158,27 @@ ow = e_widget_slider_add (evas, 1, 0, D_("%1.2f"), 0.1, 3.0, 0.01, 0, &(cfdata->desks_duration), NULL,100); e_widget_framelist_object_append (of, ow); + ow = e_widget_check_add(evas, D_("Slotted Layout"), &(cfdata->desks_layout_mode)); + e_widget_framelist_object_append(of, ow); + ow = e_widget_check_add(evas, D_("Grow more!"), &(cfdata->desks_grow)); + e_widget_framelist_object_append(of, ow); + ow = e_widget_check_add(evas, D_("Keep it tight!"), &(cfdata->desks_tight)); + e_widget_framelist_object_append(of, ow); ow = e_widget_check_add(evas, D_("Fade in windows"), &(cfdata->fade_windows)); e_widget_framelist_object_append(of, ow); - ow = e_widget_check_add(evas, D_("Slotted Layout"), &(cfdata->desks_layout_mode)); - e_widget_framelist_object_append(of, ow); - e_widget_list_object_append(o, of, 1, 1, 0.5); + e_widget_table_object_append(ot, o, 1, 0, 1, 1, 1, 1, 0, 0); - of = e_widget_framelist_add(evas, D_(""), 0); + of = e_widget_framelist_add(evas, D_(""), 1); ow = e_widget_check_add(evas, D_("Fade out shelves and popups"), &(cfdata->fade_popups)); e_widget_framelist_object_append(of, ow); ow = e_widget_check_add(evas, D_("Darken desktop"), &(cfdata->fade_desktop)); e_widget_framelist_object_append(of, ow); - e_widget_list_object_append(o, of, 1, 1, 0.5); + ow = e_widget_button_add(evas, D_("Test"), NULL, _cb_test, cfdata, NULL); + e_widget_framelist_object_append(of, ow); + e_widget_table_object_append(ot, of, 0, 1, 2, 1, 1, 1, 0, 0); - e_widget_table_object_append(ot, o, 1, 0, 1, 1, 1, 1, 0, 0); - ow = e_widget_button_add(evas, D_("Test"), NULL, _cb_test, cfdata, NULL); - e_widget_table_object_append(ot, ow, 0, 1, 2, 1, 0, 0, 0, 0); - return ot; } @@ -191,6 +197,8 @@ scale_conf->fade_desktop = cfdata->fade_desktop; scale_conf->layout_mode = cfdata->layout_mode; scale_conf->desks_layout_mode = cfdata->desks_layout_mode; + scale_conf->desks_grow = cfdata->desks_grow; + scale_conf->desks_tight = cfdata->desks_tight; e_config_save_queue(); return 1; Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-02-23 13:03:55 UTC (rev 57265) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.c 2011-02-23 15:53:20 UTC (rev 57266) @@ -7,10 +7,10 @@ // while scale is active? // -/* #define DBG(...) */ -#define DBG(...) printf(__VA_ARGS__) +#define DBG(...) +/* #define DBG(...) printf(__VA_ARGS__) */ -#define SPACING 32 +#define OFFSET 32 #define PLACE_RUNS 10000 #define GROW_RUNS 1000 #define SHRINK_RUNS 2000 @@ -99,6 +99,7 @@ static int max_x, max_y, min_x, min_y; static int use_x, use_y, use_w, use_h; static int max_width, max_height; +static int spacing; static int step_count; static Item *background = NULL; static Item *selected_item = NULL; @@ -479,14 +480,9 @@ Eina_List *l, *ll; int cont = 0; - int overlap, off; + int overlap; double grow_l, grow_r, grow_d, grow_u; - if (show_all_desks) - off = scale_conf->desks_spacing; - else - off = scale_conf->spacing; - /* double mean = 0; */ /* EINA_LIST_FOREACH(items, l, it) * mean += it->scale; @@ -534,26 +530,26 @@ { if (it == ot) continue; - if (grow_l && E_INTERSECTS(it->x - grow_l - off ,it->y, - it->w + off*2, it->h + off*2, + if (grow_l && E_INTERSECTS(it->x - grow_l - spacing ,it->y, + it->w + spacing*2, it->h + spacing*2, ot->x, ot->y, ot->w, ot->h)) grow_l = 0; - if (grow_r && E_INTERSECTS(it->x - off, it->y - off, - it->w + grow_r + off*2, it->h + off*2, + if (grow_r && E_INTERSECTS(it->x - spacing, it->y - spacing, + it->w + grow_r + spacing*2, it->h + spacing*2, ot->x, ot->y, ot->w, ot->h)) grow_r = 0; if ((grow_l == 0) && (grow_r == 0) && (overlap = 1)) break; - if (grow_u && E_INTERSECTS(it->x - off, it->y - off - grow_u, - it->w + off*2, it->h + off*2, + if (grow_u && E_INTERSECTS(it->x - spacing, it->y - spacing - grow_u, + it->w + spacing*2, it->h + spacing*2, ot->x, ot->y, ot->w, ot->h)) grow_u = 0; - if (grow_d && E_INTERSECTS(it->x - off, it->y - off, - it->w + off*2, it->h + grow_d + off*2, + if (grow_d && E_INTERSECTS(it->x - spacing, it->y - spacing, + it->w + spacing*2, it->h + grow_d + spacing*2, ot->x, ot->y, ot->w, ot->h)) grow_d = 0; @@ -582,7 +578,6 @@ it->w = it->h * (double)it->bd->w / (double)it->bd->h; } - it->x -= grow_l; it->y -= grow_u; @@ -807,27 +802,15 @@ Eina_List *l, *ll; Item *it, *ot; int shrunk = 0; - int off; double move_x; double move_y; - int min_x = zone->w; - int min_y = zone->h; - int max_x = 0; - int max_y = 0; - - if (show_all_desks) - off = scale_conf->desks_spacing; - else - off = scale_conf->spacing; - - EINA_LIST_REVERSE_FOREACH(items, l, it) { if (show_all_desks) { - move_x = ((it->x + it->w/2.0) - (max_x - min_x)/2) / 5.0; - move_y = ((it->y + it->h/2.0) - (max_y - min_y)/2) / 5.0; + move_x = ((it->x + it->w/2.0) - zone->w/2.0) / 5.0; + move_y = ((it->y + it->h/2.0) - zone->h/2.0) / 5.0; } else { @@ -845,7 +828,8 @@ while(move_x) { if (E_INTERSECTS(it->x - move_x, it->y, it->w, it->h, - ot->x - off, ot->y - off, ot->w + off*2, ot->h + off*2)) + ot->x - spacing, ot->y - spacing, + ot->w + spacing*2, ot->h + spacing*2)) move_x = move_x / 2.0; else break; } @@ -853,7 +837,8 @@ while(move_y) { if (E_INTERSECTS(it->x, it->y - move_y, it->w, it->h, - ot->x - off, ot->y - off, ot->w + off*2, ot->h + off*2)) + ot->x - spacing, ot->y - spacing, + ot->w + spacing*2, ot->h + spacing*2)) move_y = move_y / 2.0; else break; } @@ -867,7 +852,6 @@ if (move_y > 1 || move_x > 1) shrunk++; } - printf("shrunk___ %d\n",shrunk); return shrunk; } @@ -905,6 +889,7 @@ int rows, cols, cnt, x, y, w, h; int fast = 0; int cont = 0; + double min_x, max_x, min_y, max_y; cnt = eina_list_count(items); @@ -922,7 +907,6 @@ DBG("%d rows, %d cols -- cnt %d\n", rows, cols, cnt); - double min_x, max_x, min_y, max_y; max_x = max_y = 0; min_x = min_y = 100000; @@ -942,13 +926,13 @@ { for (x = 0; x < cols; x++) { + if (fast && !l) break; + slot = E_NEW(Slot, 1); slot->x = min_x + x * w; slot->y = min_y + y * h; slot->w = w; slot->h = h; - slot->items = eina_list_clone(items); - cur_slot = slot; if (fast) { @@ -957,12 +941,14 @@ } else { + cur_slot = slot; + slot->items = eina_list_clone(items); slot->items = eina_list_sort(slot->items, cnt, _cb_sort_nearest); slot->it = eina_list_data_get(slot->items); slot->items = eina_list_remove_list(slot->items, slot->items); + slot->min = _slot_dist(slot->it, slot); } - slot->min = _slot_dist(slot->it, slot); slots = eina_list_append(slots, slot); DBG("add slot: %dx%d, \t%f -> %d:%d\n", slot->x, slot->y, slot->min, @@ -992,33 +978,35 @@ Item *it1 = eina_list_data_get(slot->items); Item *it2 = eina_list_data_get(slot2->items); - if (it1 && it2) - { - double d1 = _slot_dist(it1, slot); - double d2 = _slot_dist(it2, slot2); + if (!it1 || !it2) + continue; - cont = 1; + double d1 = _slot_dist(it1, slot); + double d2 = _slot_dist(it2, slot2); - DBG("%dx%d - compare:\n\ts1: %dx%d (%dx%d:%f),\n\ts2 %dx%d (%dx%d:%f)\n", - (int)slot->it->x, (int)slot->it->y, - slot->x, slot->y, (int)it1->x, (int)it1->y, d1, - slot2->x, slot2->y, (int)it2->x, (int)it2->y, d2); + cont = 1; - if (slot->it->in_slots > 1 && slot->min + d1 >= slot2->min + d2) - { + DBG("%dx%d - compare:\n\ts1: %dx%d (%dx%d:%f),\n\ts2 %dx%d (%dx%d:%f)\n", + (int)slot->it->x, (int)slot->it->y, + slot->x, slot->y, (int)it1->x, (int)it1->y, d1, + slot2->x, slot2->y, (int)it2->x, (int)it2->y, d2); - slot->it->in_slots--; - slot->it = it1; - slot->min = d1; - slot->items = eina_list_remove_list(slot->items, slot->items); - break; - } + if (slot->it->in_slots > 1 && slot->min + d1 >= slot2->min + d2) + { + slot->it->in_slots--; + slot->it = it1; + slot->min = d1; + slot->items = eina_list_remove_list(slot->items, slot->items); + break; } } } } - do { + cont = 1; + + while (fast && cont) + { cont = 0; EINA_LIST_FOREACH(slots, l, slot) { @@ -1031,7 +1019,6 @@ if (d1 > d2) { it = slot->it; - slot->it = slot2->it; slot2->it = it; cont = 1; @@ -1039,7 +1026,6 @@ } } } - while (fast && cont); EINA_LIST_FOREACH(slots, l, slot) { @@ -1080,7 +1066,6 @@ l = eina_list_next(l); } } - int spacing = scale_conf->spacing; EINA_LIST_FOREACH(slots, l, slot) { @@ -1098,11 +1083,12 @@ it->h = slot->h - spacing; it->w = it->h * (double)it->bd->w / (double)it->bd->h; } - it->x = slot->x + (slot->w - it->w)/2.0; - it->y = slot->y + (slot->h - it->h)/2.0; - /* printf("place: %d:%d %dx%d -> %d:%d %dx%d\n", - * (int)it->bd_x, (int)it->bd_y, (int)it->bd->w, (int)it->bd->h, - * (int)it->x, (int)it->y, (int)it->w, (int)it->h); */ + it->x = slot->x + ((slot->w - spacing) - it->w)/2.0; + it->y = slot->y + ((slot->h - spacing) - it->h)/2.0; + + DBG("place: %d:%d %dx%d -> %d:%d %dx%d\n", + (int)it->bd_x, (int)it->bd_y, (int)it->bd->w, (int)it->bd->h, + (int)it->x, (int)it->y, (int)it->w, (int)it->h); } EINA_LIST_FREE(slot->items, it); @@ -1132,7 +1118,7 @@ _scale_place_natural() { Eina_List *l; - int spacing, i = 0; + int offset, i = 0; Item *it; max_width = zone->w; @@ -1146,20 +1132,17 @@ items = eina_list_sort(items, eina_list_count(items), _cb_sort_center); - if (show_all_desks) - spacing = scale_conf->desks_spacing; - else - spacing = scale_conf->spacing; + offset = spacing; - if (scale_conf->grow && (spacing < SPACING)) - spacing = SPACING; - if (scale_conf->tight && (spacing < SPACING)) - spacing = SPACING; + if (scale_conf->grow && (spacing < OFFSET)) + offset = OFFSET; + if (scale_conf->tight && (spacing < OFFSET)) + offset = OFFSET; step_count = 0; while ((i++ < PLACE_RUNS) && - (_scale_place(spacing) || + (_scale_place(offset) || (min_x < use_x) || (min_y < use_y) || (max_x > use_w) || @@ -1189,8 +1172,6 @@ if ((max_y > use_h) && (it->dy > 0) && it->y > zone->h) it->y -= 4.0; } } - - DBG("place %d\n", i); } void @@ -1199,7 +1180,7 @@ Eina_List *l; E_Manager_Comp_Source *src; Evas *e; - int i, spacing; + int i; Item *it; zone = e_util_zone_current_get(e_manager_current_get()); @@ -1245,16 +1226,16 @@ if (!scale_conf->fade_popups) { e_zone_useful_geometry_get(zone, &use_x, &use_y, &use_w, &use_h); - use_x += spacing; - use_y += spacing; use_w += use_x - spacing*2; use_h += use_y - spacing*2; + use_x += spacing; + use_y += spacing; } else { - use_x = use_y = spacing; use_w = zone->w - spacing*2; use_h = zone->h - spacing*2; + use_x = use_y = spacing; } min_x = -zone->w * zone->desk_x_current; @@ -1262,6 +1243,7 @@ max_x = zone->w + zone->w * ((zone->desk_x_count - 1) - zone->desk_x_current); max_y = zone->h + zone->h * ((zone->desk_y_count - 1) - zone->desk_y_current); + /* scale all windows down to be next to each other on one zone */ if (show_all_desks) { if (scale_conf->desks_layout_mode) @@ -1279,25 +1261,34 @@ min_x = use_x; min_y = use_y; - max_x = use_h; - max_y = use_w; + max_x = use_w; + max_y = use_h; - if (scale_conf->grow) + if ((scale_conf->grow && !show_all_desks) || + (scale_conf->desks_grow && show_all_desks)) { i = 0; while (i++ < GROW_RUNS && _scale_grow()); DBG("grow %d", i); } - if (scale_conf->tight) + if ((scale_conf->tight && !show_all_desks) || + (scale_conf->desks_tight && show_all_desks)) { items = eina_list_sort(items, eina_list_count(items), _cb_sort_center); i = 0; while (i++ < SHRINK_RUNS && _scale_shrink()); DBG("shrunk %d", i); + + if (scale_conf->grow) + { + i = 0; + while (i++ < GROW_RUNS && _scale_grow()); + DBG("grow %d", i); + } } - if (show_all_desks) + if (show_all_desks)//&& !scale_conf->desks_layout_mode) { /* center and move windows near visible desk * to make the sliding smoother */ @@ -1317,8 +1308,8 @@ EINA_LIST_FOREACH(items, l, it) { - it->x = it->x - min_x + ((use_x + use_w) - (max_x - min_x))/2; - it->y = it->y - min_y + ((use_y + use_h) - (max_y - min_y))/2; + it->x = (it->x - min_x) + use_x + (use_w - max_x)/2; + it->y = (it->y - min_y) + use_y + (use_h - max_y)/2; if (it->dx > 0) it->bd_x = zone->w + it->bd->x/4; if (it->dy > 0) it->bd_y = zone->h + it->bd->y/4; @@ -1576,18 +1567,22 @@ #define T Config #define D conf_edd E_CONFIG_VAL(D, T, version, INT); - E_CONFIG_VAL(D, T, grow, UCHAR); - E_CONFIG_VAL(D, T, tight, UCHAR); E_CONFIG_VAL(D, T, fade_popups, UCHAR); E_CONFIG_VAL(D, T, fade_desktop, UCHAR); - E_CONFIG_VAL(D, T, fade_windows, UCHAR); - E_CONFIG_VAL(D, T, fade_desktop, UCHAR); + + E_CONFIG_VAL(D, T, layout_mode, INT); + E_CONFIG_VAL(D, T, grow, UCHAR); + E_CONFIG_VAL(D, T, tight, UCHAR); E_CONFIG_VAL(D, T, scale_duration, DOUBLE); E_CONFIG_VAL(D, T, spacing, DOUBLE); + + E_CONFIG_VAL(D, T, desks_layout_mode, INT); + E_CONFIG_VAL(D, T, desks_grow, UCHAR); + E_CONFIG_VAL(D, T, desks_tight, UCHAR); E_CONFIG_VAL(D, T, desks_duration, DOUBLE); E_CONFIG_VAL(D, T, desks_spacing, DOUBLE); - E_CONFIG_VAL(D, T, layout_mode, INT); - E_CONFIG_VAL(D, T, desks_layout_mode, INT); + E_CONFIG_VAL(D, T, fade_windows, UCHAR); + E_CONFIG_LIST(D, T, conf_items, conf_item_edd); scale_conf = e_config_domain_load("module.scale", conf_edd); Modified: trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h =================================================================== --- trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h 2011-02-23 13:03:55 UTC (rev 57265) +++ trunk/E-MODULES-EXTRA/comp-scale/src/e_mod_main.h 2011-02-23 15:53:20 UTC (rev 57266) @@ -22,27 +22,29 @@ E_Config_Dialog *cfd; const char *theme_path; + int layout_mode; unsigned char tight; unsigned char grow; - unsigned char fade_popups; - unsigned char fade_windows; - unsigned char fade_desktop; double scale_duration; double spacing; + + int desks_layout_mode; + unsigned char desks_tight; + unsigned char desks_grow; double desks_duration; double desks_spacing; - int layout_mode; - int desks_layout_mode; + unsigned char fade_windows; + + unsigned char fade_popups; + unsigned char fade_desktop; }; - struct _Config_Item { const char *id; int switch2; }; - struct _E_Comp_Win { EINA_INLIST; |