This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efm2.

View the commit online.

commit 2b5b29c842525bb35ceaebf94c6e7db095994a8c
Author: Carsten Haitzler (Rasterman) <[email protected]>
AuthorDate: Sat Dec 6 13:39:39 2025 +0000

    order sorting - stage 1 implementation - can load and sort and dnd\
    
    the dnd shows where youw ant to drop it... but won't actually re-order
    files yet, but you can load order files and backend handles it and
    front end sorts usijng the index etc. and you have an order
    option/flag ...
    
    so still have to handle the actual change in order on drop and write
    out of the order change.
---
 src/efm/efm_dnd.c     | 74 ++++++++++++++++++++++++++++++++++++++++++++-------
 src/efm/efm_structs.h | 19 +++++++------
 src/efm/efm_util.c    | 64 +++++++++++++++++++++++++++++++++++++++++++-
 src/efm/efm_util.h    |  1 +
 4 files changed, 140 insertions(+), 18 deletions(-)

diff --git a/src/efm/efm_dnd.c b/src/efm/efm_dnd.c
index b6f9579..2c9cfe1 100644
--- a/src/efm/efm_dnd.c
+++ b/src/efm/efm_dnd.c
@@ -8,6 +8,8 @@
 #include "efm_private.h"
 #include "esc.h"
 
+#define COORD_INVALID -999999
+
 // utils for draga and drop handling
 static Eina_Bool
 _cb_dnd_scroll_timer(void *data)
@@ -62,16 +64,65 @@ _dnd_scroll_end_handle(Smart_Data *sd)
 }
 
 static void
-_dnd_over(Icon *icon)
+_dnd_hovering(Smart_Data *sd, Evas_Coord x, Evas_Coord y)
+{
+  Icon *icon = sd->dnd_over_icon;
+  // -1 == nowhere (end of list), 0 == before, 1 = over, 2 == after
+  int before_after_end = -1;
+
+  if (!(sd->config.sort_mode & EFM_SORT_MODE_ORDER)) return;
+  if (icon)
+    {
+      Evas_Coord p, plen;
+
+      if ((sd->config.view_mode == EFM_VIEW_MODE_LIST)
+          || (sd->config.view_mode == EFM_VIEW_MODE_LIST_DETAILED)
+          || (sd->config.view_mode == EFM_VIEW_MODE_ICONS_VERTICAL))
+        { // if over top half - before over_icon, otherwise after over_icon
+          p  = y - icon->geom.y;
+          plen = icon->geom.h;
+        }
+      else if (sd->config.view_mode == EFM_VIEW_MODE_ICONS)
+        { // if over left half - before over_icon, otherwise after over_icon
+          p    = x - icon->geom.x;
+          plen = icon->geom.w;
+        }
+      else return; // only do reorder in above vbiew modes
+      // point p is between p1 and p2 - or beyone p1 or p2 beyond range
+      // 0 ...p ......... plen
+      if (icon->info.dir)
+        { // can be before, over or in: 0%->33%->66%->100%
+          if (p < ((plen * 1) / 3)) before_after_end = 0;
+          else if (p < ((plen * 2) / 3)) before_after_end = 1;
+          else before_after_end = 2;
+        }
+      else
+        { // can be beofre or after: 0%->50%->100%
+          if (p < (plen / 2)) before_after_end = 0;
+          else before_after_end = 2;
+        }
+    }
+  if (before_after_end == -1)
+    { // default: must be at the end if in list mode ... or anything else
+      printf("DND: %i %i add to end\n", x, y);
+    }
+  // set up sd->o_over and emit telling it above/below/before/after
+  // or the default of in....
+  // then it's before, inn or after an icon -only dirs can be in
+  else _icon_over_order_on(icon, before_after_end);
+}
+
+static void _dnd_over(Icon *icon)
 {
   _icon_over_on(icon);
 }
 
 static void
-_dnd_over_none_handle(Smart_Data *sd)
+_dnd_over_none_handle(Smart_Data *sd, Evas_Coord x, Evas_Coord y)
 {
   if (sd->over_icon) _icon_over_off(sd->over_icon);
   sd->over_icon = NULL;
+  sd->dnd_over_icon = NULL;
 }
 
 static void
@@ -88,10 +139,11 @@ _dnd_over_handle(Smart_Data *sd, Evas_Coord x, Evas_Coord y)
     {
       if (!eina_rectangle_coords_inside(&(icon->geom), x, y)) continue;
       _dnd_over(icon);
+      sd->dnd_over_icon = icon;
       return;
     }
   }
-  _dnd_over_none_handle(sd);
+  _dnd_over_none_handle(sd, x, y);
 }
 
 // drop handling
@@ -100,7 +152,7 @@ _cb_drop_in(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED)
 {
   //   Smart_Data *sd = data;
   printf("XXX: drop in.....\n");
-  // XXX: call drop in smart callback}
+  // XXX: call drop in smart callback
 }
 
 static void
@@ -108,9 +160,9 @@ _cb_drop_out(void *data, Evas_Object *o EINA_UNUSED)
 {
   Smart_Data *sd = data;
   _dnd_scroll_end_handle(sd);
-  _dnd_over_none_handle(sd);
+  _dnd_over_none_handle(sd, COORD_INVALID, COORD_INVALID);
   printf("XXX: drop out.....\n");
-  // XXX: call drop out smart callback}
+  // XXX: call drop out smart callback
 }
 
 void
@@ -119,7 +171,7 @@ _cb_drop_pos(void *data, Evas_Object *o EINA_UNUSED, Evas_Coord x, Evas_Coord y,
 {
   Smart_Data *sd = data;
   Evas_Coord  fmx, fmy, fmw, fmh;
-  Evas_Coord  sx, sy, sw, sh;
+  Evas_Coord  sx, sy, sw, sh, dx = COORD_INVALID, dy = COORD_INVALID;
 
   sd->dnd_action = action;
   evas_object_geometry_get(sd->o_smart, &fmx, &fmy, &fmw, &fmh);
@@ -128,10 +180,14 @@ _cb_drop_pos(void *data, Evas_Object *o EINA_UNUSED, Evas_Coord x, Evas_Coord y,
   sd->dnd_y = y - fmy;
   _dnd_scroll_handle(sd, x - sx, y - sy);
   if (((x - sx) > 0) && ((y - sy) > 0) && ((x - sx) < sw) && ((y - sy) < sh))
-    _dnd_over_handle(sd, x - fmx, y - fmy);
-  else _dnd_over_none_handle(sd);
+    {
+      dx = x - fmx;
+      dy = y - fmy;
+    }
+  _dnd_over_handle(sd, dx, dy);
   if (sd->over_icon) sd->drop_over = sd->over_icon;
   else sd->drop_over = NULL;
+  _dnd_hovering(sd, dx, dy);
 }
 
 static void
diff --git a/src/efm/efm_structs.h b/src/efm/efm_structs.h
index f73b3f6..21c8582 100644
--- a/src/efm/efm_structs.h
+++ b/src/efm/efm_structs.h
@@ -77,6 +77,7 @@ struct _Smart_Data
   Icon      *over_icon;
   Icon      *drop_over;
   Icon      *rename_icon;
+  Icon      *dnd_over_icon;
 
   Evas_Coord      icon_min_w, icon_min_h;
   Evas_Coord      list_min_w, list_min_h;
@@ -196,14 +197,16 @@ struct _Icon
   File_Info      info;
   Evas_Coord     down_x, down_y, down_rel_x, down_rel_y;
   Evas_Coord     last_x, last_y;
-  Eina_Bool      realized : 1;
-  Eina_Bool      selected : 1;
-  Eina_Bool      down     : 1;
-  Eina_Bool      over     : 1;
-  Eina_Bool      changed  : 1;
-  Eina_Bool      edje     : 1;
-  Eina_Bool      renaming : 1;
-  Eina_Bool      drag     : 1;
+  Eina_Bool      realized    : 1;
+  Eina_Bool      selected    : 1;
+  Eina_Bool      down        : 1;
+  Eina_Bool      changed     : 1;
+  Eina_Bool      edje        : 1;
+  Eina_Bool      renaming    : 1;
+  Eina_Bool      drag        : 1;
+  Eina_Bool      over        : 1;
+  Eina_Bool      over_before : 1;
+  Eina_Bool      over_after  : 1;
 };
 
 typedef struct _Pending_Exe_Del Pending_Exe_Del;
diff --git a/src/efm/efm_util.c b/src/efm/efm_util.c
index 02a38dc..03a542d 100644
--- a/src/efm/efm_util.c
+++ b/src/efm/efm_util.c
@@ -972,6 +972,8 @@ _icon_over_off(Icon *icon)
 void
 _icon_over_on(Icon *icon)
 {
+  // if we handle ordering then this over icon will be done later
+  if (icon->sd->config.sort_mode & EFM_SORT_MODE_ORDER) return;
   if (icon->over) return;
   if (icon->sd->over_icon)
     {
@@ -979,6 +981,7 @@ _icon_over_on(Icon *icon)
       icon->sd->over_icon = NULL;
     }
   if (!icon->info.dir) return;
+  // we're dnding icon over itself - don't care
   if ((icon->sd->drag_icon) && (icon->info.file)
       && (icon->sd->drag_icon->info.file)
       && (!strcmp(icon->sd->drag_icon->info.file, icon->info.file)))
@@ -987,8 +990,10 @@ _icon_over_on(Icon *icon)
     ecore_timer_del(icon->sd->dnd_over_open_timer);
   icon->sd->dnd_over_open_timer
     = ecore_timer_add(DND_OVER_OPEN_TIMER, _cb_dnd_over_open_timer, icon->sd);
-  icon->sd->over_icon = icon;
   icon->over          = EINA_TRUE;
+  icon->over_before   = EINA_FALSE;
+  icon->over_after    = EINA_FALSE;
+  icon->sd->over_icon = icon;
   edje_object_signal_emit(icon->sd->o_over, "e,state,selected", "e");
   evas_object_raise(icon->sd->o_over);
   evas_object_show(icon->sd->o_over);
@@ -997,6 +1002,62 @@ _icon_over_on(Icon *icon)
                            icon->geom.h);
 }
 
+void
+_icon_over_order_on(Icon *icon, int before_over_after)
+{
+  const char *emission = "";
+
+  if (before_over_after == 0)
+    {
+      if ((icon->over_before) && (icon == icon->sd->over_icon)) return;
+      printf("DND: before %s\n", icon->info.file);
+      icon->over        = EINA_FALSE;
+      icon->over_before = EINA_TRUE;
+      icon->over_after  = EINA_FALSE;
+      if ((icon->sd->config.view_mode == EFM_VIEW_MODE_LIST)
+          || (icon->sd->config.view_mode == EFM_VIEW_MODE_LIST_DETAILED))
+        emission = "e,state,between,top";
+      else emission = "e,state,between,left";
+    }
+  else if (before_over_after == 1)
+    {
+      if ((icon->over) && (icon == icon->sd->over_icon)) return;
+      printf("DND: in %s\n", icon->info.file);
+      if ((icon->sd->drag_icon) && (icon->info.file)
+          && (icon->sd->drag_icon->info.file)
+          && (!strcmp(icon->sd->drag_icon->info.file, icon->info.file)))
+        return;
+      if (icon->sd->dnd_over_open_timer)
+        ecore_timer_del(icon->sd->dnd_over_open_timer);
+      icon->sd->dnd_over_open_timer = ecore_timer_add(
+        DND_OVER_OPEN_TIMER, _cb_dnd_over_open_timer, icon->sd);
+      icon->sd->over_icon = icon;
+      icon->over          = EINA_TRUE;
+      icon->over_before = EINA_FALSE;
+      icon->over_after  = EINA_FALSE;
+      emission            = "e,state,selected";
+    }
+  else if (before_over_after == 2)
+    {
+      if ((icon->over_after) && (icon == icon->sd->over_icon)) return;
+      printf("DND: after %s\n", icon->info.file);
+      icon->over        = EINA_FALSE;
+      icon->over_before = EINA_FALSE;
+      icon->over_after  = EINA_TRUE;
+      if ((icon->sd->config.view_mode == EFM_VIEW_MODE_LIST)
+          || (icon->sd->config.view_mode == EFM_VIEW_MODE_LIST_DETAILED))
+        emission = "e,state,between,bottom";
+      else emission = "e,state,between,right";
+    }
+  icon->sd->over_icon = icon;
+  edje_object_signal_emit(icon->sd->o_over, emission, "e");
+  evas_object_raise(icon->sd->o_over);
+  evas_object_show(icon->sd->o_over);
+  evas_object_geometry_set(icon->sd->o_over, icon->sd->geom.x + icon->geom.x,
+                           icon->sd->geom.y + icon->geom.y, icon->geom.w,
+                           icon->geom.h);
+}
+
 void
 _icon_select(Icon *icon)
 {
@@ -2477,6 +2538,7 @@ _icon_free(Icon *icon)
           _icon_over_off(icon);
           icon->sd->over_icon = NULL;
         }
+      if (icon->sd->dnd_over_icon == icon) icon->sd->dnd_over_icon = NULL;
       if (icon->sd->drop_over == icon) icon->sd->drop_over = NULL;
       if (icon->sd->rename_icon == icon) _icon_rename_end(icon);
       // XXX: this is going to be not very optimal...
diff --git a/src/efm/efm_util.h b/src/efm/efm_util.h
index 4397fff..247c9e2 100644
--- a/src/efm/efm_util.h
+++ b/src/efm/efm_util.h
@@ -32,6 +32,7 @@ void           _file_list_cmd_strbuf_append(Eina_Strbuf *strbuf, const char *key
                                             const char *urilist);
 void           _icon_over_off(Icon *icon);
 void           _icon_over_on(Icon *icon);
+void           _icon_over_order_on(Icon *icon, int before_over_after);
 void           _icon_select(Icon *icon);
 void           _icon_unselect(Icon *icon);
 Eina_Bool      _unselect_all(Smart_Data *sd);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to