Browse code

Show statustooltip on image hover

Dario Rodriguez authored on 08/03/2025 19:39:08
Showing 1 changed files
... ...
@@ -19,6 +19,7 @@
19 19
  *               Show big image on hover.
20 20
  *               Preserve aspect ratio of big image.
21 21
  *      20250305 Scrollable left pane.
22
+ *      20250308 Show statustooltip on image hover.
22 23
  *
23 24
  * Author: Dario Rodriguez dario@darionomono.com
24 25
  * (c) Dario Rodriguez 2025
... ...
@@ -776,6 +777,7 @@ im_body_draw(body_t *body, Vector2 mousepos, int lmbdown, int windowwidth, int w
776 777
         int flag_skiprightside;
777 778
         int xoff,yoff;
778 779
         thumb_t *thumb;
780
+        char statustooltip[1024];
779 781
         if(body==NULL)
780 782
                 return(-1);
781 783
 #if 1
... ...
@@ -814,6 +816,7 @@ body->leftscrollpos=(int) mousepos.y;
814 816
         /* draw right side background */
815 817
         DrawRectangle(body->xywh.x+body->leftsize,body->xywh.y,body->xywh.w-body->leftsize, body->xywh.h, (Color){ 227, 227, 227, 255 } );
816 818
         /* first pass, draw leftside, second pass, draw all of rightside */
819
+        statustooltip[0]='\0';
817 820
         for(is_leftside=1,flag_skiprightside=0;is_leftside>=0 && flag_skiprightside==0;is_leftside--) {
818 821
                 for(i=(is_leftside)?body->currentdirdata:0,righty=body->xywh.y;(is_leftside && i==body->currentdirdata) || (!is_leftside && i<body->sizedirdata);i++) {
819 822
                         int sidelen;
... ...
@@ -911,6 +914,10 @@ DrawRectangle(UNROLLXYWH(body->backxywh),((Color){ 0,255,0,255 })); /* hit zone
911 914
 #warning TODO: if !is_leftside, draw "..." in huge font using lastx,lasty as reference
912 915
                                         break;
913 916
                                 }
917
+                                if(is_leftside && is_imutil_insidexywh(mousepos,&(thumb->screenxywh))) {
918
+                                        strncpy(statustooltip,elem->name+1,sizeof(statustooltip));
919
+                                        statustooltip[sizeof(statustooltip)-1]='\0';
920
+                                }
914 921
                                 /* show image */
915 922
                                 has_imagedrawn=0;
916 923
 #if 1
... ...
@@ -1032,6 +1039,11 @@ fprintf(stderr,"Loaded %s\n",fullpath);
1032 1039
                         }
1033 1040
                 }
1034 1041
         }
1042
+        if(statustooltip[0]!='\0') {
1043
+                m2=MeasureTextEx(font->font,statustooltip,font->height,0);
1044
+                DrawRectangle(0,windowheight-1-margin*2-font->height,m2.x+margin*2,font->height+margin*2,((Color){0,0,0,96}));
1045
+                DrawTextEx(font->font,statustooltip,(Vector2){margin,windowheight-1-margin-font->height},font->height,0,(Color){ 255,255,255,128 });
1046
+        }
1035 1047
         return(0);
1036 1048
 }
1037 1049