summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Poole <netstar@gmail.com>2018-02-14 13:35:08 +0000
committerAl Poole <netstar@gmail.com>2018-02-14 13:35:08 +0000
commit761823773bc1a3ac13f38dc22fd01169df27b925 (patch)
tree0caf677d0a09dd1c11664479045584c1ae77160a
parentae01581e720cdec1d4af181ef951f8b135b92a7a (diff)
tab movement: not an ideal implementation, buggy too.feature/tabs_move
Ideally would get text from underlying evas object, couldn't do that so used a hack...then another one...reopening all the panels...that is too slow also. BUt maybe I hoped you could see a way forward with it. Previous commit has the tab sizing stuff in it...again pretty bogus! :)
-rw-r--r--src/bin/edi_config.c2
-rw-r--r--src/bin/edi_main.c2
-rw-r--r--src/bin/editor/edi_editor.c2
-rw-r--r--src/bin/mainview/edi_mainview_panel.c162
4 files changed, 167 insertions, 1 deletions
diff --git a/src/bin/edi_config.c b/src/bin/edi_config.c
index 8a0f5ae..72c88cd 100644
--- a/src/bin/edi_config.c
+++ b/src/bin/edi_config.c
@@ -630,6 +630,8 @@ _edi_project_config_tab_remove(const char *path, Eina_Bool windowed, int panel_i
*tabs = eina_list_remove(*tabs, tab);
_edi_project_config_save_no_notify();
+ if (!tab) return;
+
eina_stringshare_del(tab->path);
eina_stringshare_del(tab->fullpath);
if (tab->type)
diff --git a/src/bin/edi_main.c b/src/bin/edi_main.c
index f09447d..c123087 100644
--- a/src/bin/edi_main.c
+++ b/src/bin/edi_main.c
@@ -1398,7 +1398,7 @@ _edi_file_saved(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_U
return ECORE_CALLBACK_RENEW;
}
-void
+static void
_edi_open_tabs()
{
Edi_Project_Config_Panel *panel;
diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c
index da095aa..d140dd1 100644
--- a/src/bin/editor/edi_editor.c
+++ b/src/bin/editor/edi_editor.c
@@ -1303,6 +1303,8 @@ _edi_editor_config_changed(void *data, int type EINA_UNUSED, void *event EINA_UN
Elm_Code_Widget *widget;
Elm_Code *code;
+ if (!data) return ECORE_CALLBACK_RENEW;
+
widget = (Elm_Code_Widget *) data;
code = elm_code_widget_code_get(widget);
diff --git a/src/bin/mainview/edi_mainview_panel.c b/src/bin/mainview/edi_mainview_panel.c
index a6f797e..b7e4ebb 100644
--- a/src/bin/mainview/edi_mainview_panel.c
+++ b/src/bin/mainview/edi_mainview_panel.c
@@ -466,6 +466,159 @@ _edi_mainview_panel_content_create(Edi_Mainview_Item *item, Evas_Object *parent)
return container;
}
+static const char *_tab_drag_path = NULL;
+static Ecore_Timer *_drag_timer = NULL;
+
+static const char *
+_tab_is_dragging(void)
+{
+ return _tab_drag_path;
+}
+
+typedef struct {
+ Evas_Object *toolbar;
+ Evas_Object *tab;
+ Evas_Object *button;
+ const char *path;
+} Tab_Drag_Data;
+
+static void
+_tab_move_render_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+ void *event_info)
+{
+ Evas_Event_Mouse_Move *ev = event_info;
+ Tab_Drag_Data *drag = data;
+
+ if (!drag) return;
+
+ evas_object_move(drag->button, ev->cur.canvas.x, ev->cur.canvas.y);
+ evas_object_show(drag->button);
+}
+
+static Eina_Bool
+_tab_move_timer_cb(void *data EINA_UNUSED)
+{
+ Tab_Drag_Data *drag = data;
+
+ ecore_timer_del(_drag_timer);
+ _drag_timer = NULL;
+ _tab_drag_path = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static void
+_tab_move_done_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Tab_Drag_Data *drag = data;
+
+ if (!drag) return;
+
+ _drag_timer = ecore_timer_add(0.5, _tab_move_timer_cb, drag);
+
+ evas_object_del(drag->button);
+ drag->button = NULL;
+ evas_object_event_callback_del(drag->tab, EVAS_CALLBACK_MOUSE_UP, _tab_move_done_cb);
+}
+
+static void
+_tab_move_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+ void *event_info)
+
+{
+ Evas_Event_Mouse_Down *ev;
+ Tab_Drag_Data *drag = data;
+
+ if (!drag) return;
+
+ if (_tab_is_dragging()) return;
+
+ ev = event_info;
+
+ drag->button = elm_button_add(drag->toolbar);
+ evas_object_size_hint_weight_set(drag->button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(drag->button, 1.0, EVAS_HINT_FILL);
+ elm_object_text_set(drag->button, elm_object_part_text_get(drag->tab, "elm.btn.text"));
+ evas_object_move(drag->button, ev->canvas.x, ev->canvas.y);
+
+ _tab_drag_path = drag->path;
+
+ evas_object_event_callback_add(drag->toolbar, EVAS_CALLBACK_MOUSE_MOVE, _tab_move_render_cb, drag);
+ evas_object_event_callback_add(drag->tab, EVAS_CALLBACK_MOUSE_UP, _tab_move_done_cb, drag);
+}
+
+static void
+_swap(Edi_Mainview_Item *a, Edi_Mainview_Item *b)
+{
+ const void *tmp = a->path;
+
+ a->path = b->path;
+ b->path = tmp;
+}
+
+static void
+_tab_swap(const char *old, const char *new)
+{
+ Edi_Mainview_Panel *panel;
+ Edi_Mainview_Item *first, *second, *item;
+ Eina_List *l;
+
+ first = second = NULL;
+
+ if (!strcmp(old, new)) return;
+
+ int i, count = edi_mainview_panel_count();
+
+ for (i = 0; i < count; i++)
+ {
+ panel = edi_mainview_panel_by_index(i);
+ EINA_LIST_FOREACH(panel->items, l, item)
+ {
+ if (!strcmp(item->path, old))
+ {
+ first = item;
+ }
+
+ else if (!strcmp(item->path, new))
+ {
+ second = item;
+ }
+ if (first && second)
+ break;
+ }
+ }
+
+ if (!first || !second) return;
+
+ _swap(first, second);
+
+ // below isn't good...
+ for (i = 0; i < count; i++)
+ {
+ panel = edi_mainview_panel_by_index(i);
+ //edi_mainview_panel_close_nosave_all(panel);
+ edi_mainview_panel_refresh_all(panel);
+ }
+}
+
+static void
+_tab_mouse_in_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+
+{
+ const char *path;
+ Tab_Drag_Data *drag = data;
+
+ if (!drag) return;
+
+ if ((path = _tab_is_dragging()))
+ {
+ printf("replace %s with %s\n", path, drag->path);
+ _tab_swap(drag->path, path);
+ }
+}
+
static void
_edi_mainview_panel_item_tab_add(Edi_Mainview_Panel *panel, Edi_Path_Options *options, const char *mime)
{
@@ -497,6 +650,15 @@ _edi_mainview_panel_item_tab_add(Edi_Mainview_Panel *panel, Edi_Path_Options *op
elm_layout_theme_set(tab, "multibuttonentry", "btn", "default");
elm_object_part_text_set(tab, "elm.btn.text", ecore_file_file_get(options->path));
+
+ Tab_Drag_Data *drag = malloc(sizeof(Tab_Drag_Data));
+ drag->toolbar = panel->tabs;
+ drag->tab = tab;
+ drag->button = NULL;
+ drag->path = item->path;
+ evas_object_event_callback_add(tab, EVAS_CALLBACK_MOUSE_DOWN, _tab_move_cb, drag);
+ evas_object_event_callback_add(tab, EVAS_CALLBACK_MOUSE_IN, _tab_mouse_in_cb, drag);
+
/*
icon = elm_icon_add(tab);
elm_icon_standard_set(icon, provider->icon);