win: be able to drag'n'drop tabs over the tabbar

This commit is contained in:
Boris Faure 2020-01-19 18:02:18 +01:00
parent 15e2921b14
commit a90cb8e84e
Signed by: borisfaure
GPG Key ID: 35C0410516166BE8
4 changed files with 59 additions and 10 deletions

View File

@ -6,6 +6,8 @@ Changes since 1.6.0:
-------------------- --------------------
* In group "terminology/tabbar_back", add signal "bell,off" from "terminology" * In group "terminology/tabbar_back", add signal "bell,off" from "terminology"
to unmark a tab as having missed the bell. to unmark a tab as having missed the bell.
* In group "terminology/background", signals "tab,drag" and "tab,drag,stop"
are emitted when the current tab is dragged.
Changes since 1.5.0: Changes since 1.5.0:
-------------------- --------------------

View File

@ -84,6 +84,10 @@ Whether to display a tab bar. Default is off.
### `tab_btn,off` and `tab_btn,on` ### `tab_btn,off` and `tab_btn,on`
Whether to display a tab button to easily navigate through tabs. Default is off. Whether to display a tab button to easily navigate through tabs. Default is off.
## Signal emitted
### `tab,drag` and `tab,drage,stop`
To notify that the current tab is being dragged.
# `terminology/about` # `terminology/about`

View File

@ -1769,6 +1769,40 @@ collections {
visible: 1; visible: 1;
} }
} }
program {
signal: "mouse,up,1"; source: "tabmiddle";
action: SIGNAL_EMIT "tab,drag,stop" "terminology";
}
program {
signal: "mouse,move"; source: "tabmiddle";
script {
new y, h, drag_x, drag_w;
if (!get_mouse_buttons())
return;
get_geometry(PART:"tabdrag", drag_x, y, drag_w, h);
if (drag_w > 0) {
new m_x, m_y;
new Float:mid;
new Float:d;
new Float:v1;
new Float:v2;
new Float:n;
get_mouse(m_x, m_y);
mid = m_x - drag_x;
mid = mid / drag_w;
get_drag(PART:"terminology.tabl", v1, n);
get_drag(PART:"terminology.tabr", v2, n);
d = (v2 - v1) / 2;
set_drag(PART:"terminology.tabl", mid - d, 0.0);
set_drag(PART:"terminology.tabr", mid + d, 0.0);
emit("tab,drag", "terminology");
}
}
}
program { program {
signal: "mouse,down,1,double"; source: "tabmiddle"; signal: "mouse,down,1,double"; source: "tabmiddle";
action: SIGNAL_EMIT "tab,title" "terminology"; action: SIGNAL_EMIT "tab,title" "terminology";

View File

@ -2828,6 +2828,8 @@ _tabbar_clear(Term *term)
evas_object_del(term->tab_spacer); evas_object_del(term->tab_spacer);
term->tab_spacer = NULL; term->tab_spacer = NULL;
} }
if (term->tab_inactive)
evas_object_hide(term->tab_inactive);
} }
static void static void
@ -2907,7 +2909,7 @@ _tabs_recompute_drag(Tabs *tabs)
{ {
v1 = (double)(idx) / (double)n; v1 = (double)(idx) / (double)n;
v2 = (double)(idx+1) / (double)n; v2 = (double)(idx+1) / (double)n;
tabs->hysteresis_step = 0.67 / (n - 1); tabs->hysteresis_step = 0.67 / (double)n;
} }
tabs->v1_orig = v1; tabs->v1_orig = v1;
tabs->v2_orig = v2; tabs->v2_orig = v2;
@ -2925,7 +2927,10 @@ _tabs_on_drag_stop(void *data,
Term *term = data; Term *term = data;
Tabs *tabs = evas_object_data_get(term->bg, "tabs"); Tabs *tabs = evas_object_data_get(term->bg, "tabs");
_tabs_recompute_drag(tabs); edje_object_part_drag_value_set(term->bg_edj, "terminology.tabl",
tabs->v1_orig, 0.0);
edje_object_part_drag_value_set(term->bg_edj, "terminology.tabr",
tabs->v2_orig, 0.0);
} }
static void static void
@ -2935,7 +2940,6 @@ _tabs_on_drag(void *data,
const char *source EINA_UNUSED) const char *source EINA_UNUSED)
{ {
Eina_List *l, *next, *prev; Eina_List *l, *next, *prev;
double val;
int tab_active_idx; int tab_active_idx;
int n; int n;
Tabs *tabs; Tabs *tabs;
@ -2962,10 +2966,12 @@ _tabs_on_drag(void *data,
term = solo->term; term = solo->term;
edje_object_part_drag_value_get(term->bg_edj, "terminology.tabl", edje_object_part_drag_value_get(term->bg_edj, "terminology.tabl",
&val, NULL); &v1, NULL);
edje_object_part_drag_value_get(term->bg_edj, "terminology.tabr",
&v2, NULL);
while ((tab_active_idx < n - 1) && while ((tab_active_idx < n - 1) &&
((val > tabs->v1_orig + tabs->hysteresis_step) || ((v2 > tabs->v2_orig + tabs->hysteresis_step) ||
(val > 1 - tabs->hysteresis_step))) (v2 > 1 - tabs->hysteresis_step)))
{ {
/* To the right */ /* To the right */
l = eina_list_nth_list(tabs->tabs, tab_active_idx); l = eina_list_nth_list(tabs->tabs, tab_active_idx);
@ -2973,7 +2979,7 @@ _tabs_on_drag(void *data,
item_moved = next->data; item_moved = next->data;
term_moved = _tab_item_to_term(item_moved); term_moved = _tab_item_to_term(item_moved);
elm_box_unpack(term->tabbar.r.box, term_moved->tab_inactive); elm_box_unpack(term->tabbar.r.box, term_moved->tab_inactive);
elm_box_pack_start(term->tabbar.l.box, term_moved->tab_inactive); elm_box_pack_end(term->tabbar.l.box, term_moved->tab_inactive);
tabs->tabs = eina_list_remove_list(tabs->tabs, l); tabs->tabs = eina_list_remove_list(tabs->tabs, l);
tabs->tabs = eina_list_append_relative_list(tabs->tabs, tabs->tabs = eina_list_append_relative_list(tabs->tabs,
@ -2983,8 +2989,8 @@ _tabs_on_drag(void *data,
return; return;
} }
while ((tab_active_idx > 0) && while ((tab_active_idx > 0) &&
((val < tabs->v1_orig - tabs->hysteresis_step) || ((v1 < tabs->v1_orig - tabs->hysteresis_step) ||
(val < tabs->hysteresis_step))) (v1 < tabs->hysteresis_step)))
{ {
/* To the left */ /* To the left */
l = eina_list_nth_list(tabs->tabs, tab_active_idx); l = eina_list_nth_list(tabs->tabs, tab_active_idx);
@ -2992,7 +2998,7 @@ _tabs_on_drag(void *data,
item_moved = prev->data; item_moved = prev->data;
term_moved = _tab_item_to_term(item_moved); term_moved = _tab_item_to_term(item_moved);
elm_box_unpack(term->tabbar.l.box, term_moved->tab_inactive); elm_box_unpack(term->tabbar.l.box, term_moved->tab_inactive);
elm_box_pack_end(term->tabbar.r.box, term_moved->tab_inactive); elm_box_pack_start(term->tabbar.r.box, term_moved->tab_inactive);
tabs->tabs = eina_list_remove_list(tabs->tabs, prev); tabs->tabs = eina_list_remove_list(tabs->tabs, prev);
tabs->tabs = eina_list_append_relative_list(tabs->tabs, tabs->tabs = eina_list_append_relative_list(tabs->tabs,
@ -4084,6 +4090,9 @@ _tabs_recreate(Tabs *tabs)
solo = (Solo*) tab_item->tc; solo = (Solo*) tab_item->tc;
term = solo->term; term = solo->term;
if (term->tab_inactive)
evas_object_hide(term->tab_inactive);
if (term->missed_bell) if (term->missed_bell)
missed++; missed++;
} }