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 7b83f16e4ebc205439b8c56e77dbd020b7b526d4
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Fri Oct 20 19:48:44 2023 +0100

    detailview - do more item types
---
 TODO.md                 |   9 ++--
 src/backends/table/open |  11 +++--
 src/efm/efm.c           |   1 +
 src/efm/efm_icon.c      | 108 ++++++++++++++++++++++++++++++++++--------------
 src/efm/efm_icon.h      |   1 +
 src/efm/efm_util.c      |  89 +++++++++++++++++++++++++++++++++++++--
 6 files changed, 176 insertions(+), 43 deletions(-)

diff --git a/TODO.md b/TODO.md
index 92f2139..93a9c39 100644
--- a/TODO.md
+++ b/TODO.md
@@ -59,19 +59,16 @@
 * Streamline detail mode
   * Std detail mode keep
   * Above format would be a type per col. Types to support:
-    * progressbar
-    * check
-    * slider
     * graph
       * solid
       * line
       * bars
       * multiple graphs
-    * icon (re-use efm_icon)
-    * entry
+    * slider
+    * range (slider 2 val)
+    * button
     * segmentcontrol
     * hoversel
-    * color dot (use named colorclass)
 
 ## Medium term
 
diff --git a/src/backends/table/open b/src/backends/table/open
index 03eba84..5e961df 100755
--- a/src/backends/table/open
+++ b/src/backends/table/open
@@ -126,15 +126,15 @@ D="detail-format=text,text,progress,checkview,timestamp,size"
   e_cmd "file-add path="${F}" "${M}" "${D}\
     " detail1=one detail2=two detail3=noval,55/100 detail4=0 detail5=1696332215 detail6=16384/65536"
 
-  D="detail-format=text,text,text,checkview,timestamp,size"
+  D="detail-format=icon,check,circle,checkview,timestamp,size"
   e_val_escape F ${DIR}"g h i"
   e_cmd "file-add path="${F}" "${M}" "${D}\
-    " detail1=one detail2=two detail3=three detail4=true detail5=1696322215 detail6=65535/65536"
+    " detail1=std:dialog-error detail2=true detail3=cc::selected detail4=true detail5=1696322215 detail6=65535/65536"
 
-  D="detail-format=text,text,text,checkview,timestamp,size"
+  D="detail-format=icon,check,circle,checkview,timestamp,size"
   e_val_escape F ${DIR}"z~"
   e_cmd "file-add path="${F}" "${M}" "${D}\
-    " detail1=one detail2=two detail3=three detail4=false detail5=1296332215 detail6=7823/65536"
+    " detail1=dance.gif detail2=false detail3=#ff665580 detail4=false detail5=1296332215 detail6=7823/65536"
 # end initial listing of files
   e_cmd "list-end"
 }
@@ -184,6 +184,9 @@ function handle_cmd() {
       ;;
     file-rename )
       ;;
+    file-detail-change )
+      e_err "file-detail-change" ${ARGS[0]} ${ARGS[1]} ${ARGS[2]} ${ARGS[3]} ${ARGS[4]} ${ARGS[5]}
+      ;;
   esac
 }
 
diff --git a/src/efm/efm.c b/src/efm/efm.c
index 83b76ea..8fc5c88 100644
--- a/src/efm/efm.c
+++ b/src/efm/efm.c
@@ -721,6 +721,7 @@ _add_overlay_objects(Smart_Data *sd)
                                      _cb_overlay_detail_mouse_move, sd);
 
       sd->o_list_detail_swallow[i] = o = evas_object_rectangle_add(e);
+      evas_object_pass_events_set(o, EINA_TRUE);
       snprintf(buf, sizeof(buf), "e.swallow.detail%i", i + 1);
       evas_object_size_hint_min_set(
         o, sd->config.detail_min_w[i] * _scale_get(sd), 0);
diff --git a/src/efm/efm_icon.c b/src/efm/efm_icon.c
index 0aff217..5f3e720 100644
--- a/src/efm/efm_icon.c
+++ b/src/efm/efm_icon.c
@@ -25,16 +25,17 @@ struct _Smart_Data
   Eina_Stringshare *video;        // video path
   Ecore_Timer      *anim_timer;   // timer for animation frame flipping
 
-  int                           load_size;      // the sie we want to load now
-  int                           orig_w, orig_h; // the sie of the img we loaded
-  int                           frame;          // current frame to display
-  int                           frame_count;    // number of frames in anim
-  double                        video_ratio;    // aspect ratio for videos
-  Evas_Image_Animated_Loop_Hint loop_type;      // animated loop type
-  Eina_Bool                     alpha    : 1;   // does the img have alpha
-  Eina_Bool                     svg      : 1;   // is the img a svg
-  Eina_Bool                     newfile  : 1;   // did we just set a new file
-  Eina_Bool                     animated : 1;   // is this animated?
+  int                           load_size;       // the sz we want to load now
+  int                           orig_w, orig_h;  // the sz of the img we loaded
+  int                           frame;           // current frame to display
+  int                           frame_count;     // number of frames in anim
+  double                        video_ratio;     // aspect ratio for videos
+  Evas_Image_Animated_Loop_Hint loop_type;       // animated loop type
+  Eina_Bool                     alpha       : 1; // does the img have alpha
+  Eina_Bool                     svg         : 1; // is the img a svg
+  Eina_Bool                     newfile     : 1; // did we just set a new file
+  Eina_Bool                     animated    : 1; // is this animated?
+  Eina_Bool                     keep_aspect : 1; // keep aspect within obj
   Eina_Bool vid_stream : 1; // is this video (has video frames?)
   Eina_Bool audio      : 1; // is this audio (has audo)
   Eina_Bool mono_thumb : 1; // is thumb of mono white alpha img
@@ -51,6 +52,7 @@ static void      _wakeup(Smart_Data *sd);
 static void      _image_file_set(Smart_Data *sd);
 static void      _image_thumb_set(Smart_Data *sd);
 static void      _image_resized(Smart_Data *sd);
+static void      _image_update(Smart_Data *sd);
 static Eina_Bool _cb_settle_timer(void *data);
 static void      _cb_image_preload(void *data, Evas *e EINA_UNUSED,
                                    Evas_Object *obj EINA_UNUSED,
@@ -227,6 +229,9 @@ _cb_vid_resize(void *data, Evas_Object *obj EINA_UNUSED,
     }
   else // already playing the file - not new, si resized
     evas_object_smart_callback_call(sd->o_smart, "resized", NULL);
+  _image_resized(sd);
+  _image_update(sd);
+  evas_object_smart_changed(sd->o_smart);
 }
 
 static void
@@ -407,6 +412,9 @@ _cb_image_preload(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
       else if (sd->frame_count < 2) sd->animated = EINA_FALSE;
     }
   if (sd->animated) _handle_frame(sd);
+  _image_resized(sd);
+  _image_update(sd);
+  evas_object_smart_changed(sd->o_smart);
   evas_object_show(sd->o_image);
 }
 
@@ -493,20 +501,63 @@ _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
   evas_object_smart_changed(obj);
 }
 
+static void
+_size_get(Smart_Data *sd, int *w, int *h)
+{
+  if ((sd->o_video) && (sd->video_ratio > 0.0))
+    {
+      int vid_w, vid_h;
+
+      vid_w = ((double)sd->orig_h + 0.5) * sd->video_ratio;
+      vid_h = sd->orig_h;
+      if (w) *w = vid_w;
+      if (h) *h = vid_h;
+    }
+  else
+    {
+      if (w) *w = sd->orig_w;
+      if (h) *h = sd->orig_h;
+    }
+}
+
 static void
 _smart_calculate(Evas_Object *obj)
 { // recalce position/size
+  Eina_Rectangle geom;
   ENTRY;
 
+  geom = sd->geom;
+  if (sd->keep_aspect)
+    {
+      int w, h, nw, nh;
+
+      _size_get(sd, &w, &h);
+      if ((w > 0) && (h > 0))
+        {
+          nw = (w * geom.h) / h;
+          nh = geom.h;
+          if (nw > geom.w)
+            {
+              nh = (h * geom.w) / w;
+              nw = geom.w;
+            }
+        }
+      else
+        {
+          nw = 0;
+          nh = 0;
+        }
+      geom.x = geom.x + ((geom.w - nw) / 2);
+      geom.y = geom.y + ((geom.h - nh) / 2);
+      geom.w = nw;
+      geom.h = nw;
+   }
   if (sd->o_image)
-    evas_object_geometry_set(sd->o_image, sd->geom.x, sd->geom.y, sd->geom.w,
-                             sd->geom.h);
+    evas_object_geometry_set(sd->o_image, geom.x, geom.y, geom.w, geom.h);
   if (sd->o_image2)
-    evas_object_geometry_set(sd->o_image2, sd->geom.x, sd->geom.y, sd->geom.w,
-                             sd->geom.h);
+    evas_object_geometry_set(sd->o_image2, geom.x, geom.y, geom.w, geom.h);
   if (sd->o_video)
-    evas_object_geometry_set(sd->o_video, sd->geom.x, sd->geom.y, sd->geom.w,
-                             sd->geom.h);
+    evas_object_geometry_set(sd->o_video, geom.x, geom.y, geom.w, geom.h);
   _image_update(sd);
 }
 
@@ -629,25 +680,22 @@ efm_icon_video_set(Evas_Object *obj, const char *video)
   _image_video_set(sd);
 }
 
+void
+efm_icon_keep_aspect_set(Evas_Object *obj, Eina_Bool keep_aspect)
+{
+  ENTRY;
+
+  if (sd->keep_aspect == keep_aspect) return;
+  sd->keep_aspect = keep_aspect;
+  _image_resized(sd);
+}
+
 void
 efm_icon_size_get(Evas_Object *obj, int *w, int *h)
 { // get image pixel size
   ENTRY;
 
-  if ((sd->o_video) && (sd->video_ratio > 0.0))
-    {
-      int vid_w, vid_h;
-
-      vid_w = ((double)sd->orig_h + 0.5) * sd->video_ratio;
-      vid_h = sd->orig_h;
-      if (w) *w = vid_w;
-      if (h) *h = vid_h;
-    }
-  else
-    {
-      if (w) *w = sd->orig_w;
-      if (h) *h = sd->orig_h;
-    }
+  _size_get(sd, w, h);
 }
 
 Eina_Bool
diff --git a/src/efm/efm_icon.h b/src/efm/efm_icon.h
index 7777b84..6b09580 100644
--- a/src/efm/efm_icon.h
+++ b/src/efm/efm_icon.h
@@ -8,6 +8,7 @@ void         efm_icon_orig_set(Evas_Object *obj, const char *orig);
 void         efm_icon_file_set(Evas_Object *obj, const char *file);
 void         efm_icon_thumb_set(Evas_Object *obj, const char *thumb);
 void         efm_icon_video_set(Evas_Object *obj, const char *video);
+void         efm_icon_keep_aspect_set(Evas_Object *obj, Eina_Bool keep_aspect);
 void         efm_icon_size_get(Evas_Object *obj, int *w, int *h);
 Eina_Bool    efm_icon_alpha_get(Evas_Object *obj);
 Eina_Bool    efm_icon_mono_get(Evas_Object *obj);
diff --git a/src/efm/efm_util.c b/src/efm/efm_util.c
index 2849dd3..6228d07 100644
--- a/src/efm/efm_util.c
+++ b/src/efm/efm_util.c
@@ -1196,6 +1196,7 @@ _icon_detail_rectangle_add(Icon *icon, Smart_Data *sd, Evas *e, int col,
   snprintf(buf, sizeof(buf), "e.text.detail%i", col + 1);
   if (detail) edje_object_part_text_set(icon->o_base, buf, detail);
   icon->o_list_detail_swallow[col] = o = evas_object_rectangle_add(e);
+  evas_object_pass_events_set(o, EINA_TRUE);
   evas_object_color_set(o, 0, 0, 0, 0);
   evas_object_size_hint_min_set
     (o, sd->config.detail_min_w[col] * _scale_get(sd), 0);
@@ -1232,6 +1233,7 @@ _icon_detail_grid_sub_edje_add(Icon *icon, Evas *e,
   if (icon->selected) edje_object_signal_emit(o, "e,state,selected", "e");
   else edje_object_signal_emit(o, "e,state,unselected", "e");
   elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
+  evas_object_pass_events_set(o, EINA_TRUE);
   evas_object_show(o);
   return o;
 }
@@ -1249,12 +1251,31 @@ _cb_progress_noval(double v EINA_UNUSED)
   return "";
 }
 
+static void
+_cb_icon_detail_check_changed(void *data, Evas_Object *o,
+                              void *info EINA_UNUSED)
+{
+  Icon *icon = data;
+  Eina_Strbuf *buf = cmd_strbuf_new("file-detail-change");
+  const char *state = "false";
+  char detail[32];
+  int v;
+
+  _icon_path_cmd_strbuf_append(buf, "path", icon->sd, icon);
+  v = (int)(unsigned long)evas_object_data_get(o, "detail");
+  snprintf(detail, sizeof(detail), "detail%i", v);
+  cmd_strbuf_append(buf, "detail", detail);
+  if (elm_check_state_get(o)) state = "true";
+  cmd_strbuf_append(buf, "state", state);
+  cmd_strbuf_exe_consume(buf, icon->sd->exe_open);
+}
+
 static void
 _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
                  const char *theme_edj_file, int col, const char *detail,
                  const char *format)
 {
-  Evas_Object *o;
+  Evas_Object *o, *o2;
   char buf[128];
 
   if (!detail) detail = "";
@@ -1285,7 +1306,6 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
           edje_object_part_text_set(o, "e.text.unit", buf);
           snprintf(buf, sizeof(buf), "%i", (int)size);
           edje_object_part_text_set(o, "e.text.label", buf);
-          edje_object_message_signal_process(o);
         }
       free(*plist);
       free(plist);
@@ -1309,7 +1329,7 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
                                       eina_strftime("%H:%M:%S", info));
     }
   else if (!strcmp(format, "checkview"))
-    { // format: 1284924 - time_in_seconds_since_epoch
+    { // format: true/yes/1 vs false/no/0
       o = _icon_detail_grid_add(icon, sd, col);
       o = _icon_detail_grid_sub_edje_add(icon, e, theme_edj_file, col,
                                          "e/fileman/default/check");
@@ -1324,6 +1344,7 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
 
       o = _icon_detail_grid_add(icon, sd, col);
       o = elm_progressbar_add(o);
+      evas_object_pass_events_set(o, EINA_TRUE);
       elm_progressbar_horizontal_set(o, EINA_TRUE);
       elm_progressbar_span_size_set(o, 1);
       elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
@@ -1340,6 +1361,67 @@ _icon_detail_add(Icon *icon, Smart_Data *sd, Evas *e,
       elm_progressbar_value_set(o, (double)val / (double)max);
       evas_object_show(o);
     }
+  else if (!strcmp(format, "circle"))
+    {
+      Edje_Message_String msg;
+
+      msg.str = (char *)detail;
+      o = _icon_detail_grid_add(icon, sd, col);
+      o = _icon_detail_grid_sub_edje_add(icon, e, theme_edj_file, col,
+                                         "e/fileman/default/circle");
+      edje_object_message_send(o, EDJE_MESSAGE_STRING, 1, &msg);
+      edje_object_message_signal_process(o);
+    }
+  else if (!strcmp(format, "icon"))
+    { // format: std:clock or /path/x.png or path/x.gif or x.gif
+      o = _icon_detail_grid_add(icon, sd, col);
+      if (!strncmp(detail, "std:", 4))
+        {
+          o = elm_icon_add(o);
+          evas_object_pass_events_set(o, EINA_TRUE);
+          elm_icon_standard_set(o, detail + 4);
+          elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
+          evas_object_show(o);
+        }
+      else
+        {
+          o = efm_icon_add(o);
+          efm_icon_keep_aspect_set(o, EINA_TRUE);
+          evas_object_pass_events_set(o, EINA_TRUE);
+          if (detail[0] == '/')
+            efm_icon_file_set(o, detail);
+          else
+            {
+              Eina_Strbuf *strbuf = eina_strbuf_new();
+
+              eina_strbuf_append(strbuf, sd->config.path);
+              eina_strbuf_append(strbuf, detail);
+              efm_icon_file_set(o, eina_strbuf_string_get(strbuf));
+              eina_strbuf_free(strbuf);
+            }
+          elm_grid_pack(icon->o_list_detail_swallow[col], o, 0, 0, 1, 1);
+          evas_object_show(o);
+        }
+    }
+  else if (!strcmp(format, "check"))
+    { // format: true/yes/1 vs false/no/0
+      o = _icon_detail_grid_add(icon, sd, col);
+      // use table to pack check into to force centering and put it in the grid
+      o2 = elm_table_add(o);
+      elm_grid_pack(icon->o_list_detail_swallow[col], o2, 0, 0, 1, 1);
+      o = elm_check_add(o);
+      elm_object_focus_allow_set(o, EINA_FALSE);
+      evas_object_data_set(o, "detail", (void *)(unsigned long)(col + 1));
+      evas_object_propagate_events_set(o, EINA_FALSE);
+      elm_table_pack(o2, o, 0, 0, 1, 1);
+      if ((!strcasecmp(detail, "1")) || (!strcasecmp(detail, "on"))
+          || (!strcasecmp(detail, "true")) || (!strcasecmp(detail, "yes")))
+        elm_check_state_set(o, EINA_TRUE);
+      evas_object_smart_callback_add(o, "changed",
+                                     _cb_icon_detail_check_changed, icon);
+      evas_object_show(o2);
+      evas_object_show(o);
+    }
   else fprintf(stderr,
                "Uknown format for file '%s' column %i format '%s'\n",
                icon->info.file, col, format);
@@ -1501,6 +1583,7 @@ _icon_object_add(Icon *icon, Smart_Data *sd, Evas *e,
                 o2, sd->config.detail_min_w[5] * _scale_get(sd), 0);
               edje_object_part_swallow(icon->o_base, "e.swallow.detail6", o2);
               icon->o_list_detail_swallow2[5] = o2 = edje_object_add(e);
+              evas_object_pass_events_set(o2, EINA_TRUE);
               edje_object_file_set(o2, theme_edj_file,
                                    "e/fileman/default/fileperms");
               evas_object_data_set(o2, "is_edje", o2);

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

Reply via email to