...
|
...
|
@@ -29,6 +29,7 @@
|
29
|
29
|
* Scroll by finger. Big image on double click.
|
30
|
30
|
* 20250319 Add-dirdata button.
|
31
|
31
|
* 20250320 Fix add-dirdata button appearance.
|
|
32
|
+ * Dirdata colors. Select dirdata.
|
32
|
33
|
*
|
33
|
34
|
* Author: Dario Rodriguez dario@darionomono.com
|
34
|
35
|
* (c) Dario Rodriguez 2025
|
...
|
...
|
@@ -192,6 +193,7 @@ typedef struct dirdata_t {
|
192
|
193
|
int height;
|
193
|
194
|
char *dirname;
|
194
|
195
|
listing_t listing;
|
|
196
|
+ int leftscrollpos;
|
195
|
197
|
} dirdata_t;
|
196
|
198
|
|
197
|
199
|
typedef struct texture_t {
|
...
|
...
|
@@ -212,7 +214,6 @@ typedef struct body_t {
|
212
|
214
|
int sizedirdata;
|
213
|
215
|
dirdata_t **dirdata;
|
214
|
216
|
int currentdirdata;
|
215
|
|
- int leftscrollpos;
|
216
|
217
|
int rightscrollpos;
|
217
|
218
|
font_t *ptrfont;
|
218
|
219
|
font_t *ptrfontbig;
|
...
|
...
|
@@ -323,7 +324,7 @@ main(int argc, char *argv[])
|
323
|
324
|
if(lmbdown==1 && oldlmbdown==0 && scrollstart==0 && mousepos.y>im->body->xywh.y) {
|
324
|
325
|
scrollstart=imutil_milliseconds();
|
325
|
326
|
scrollstartpos=mousepos;
|
326
|
|
- leftscrollposstart=im->body->leftscrollpos;
|
|
327
|
+ leftscrollposstart=im->body->dirdata[im->body->currentdirdata]->leftscrollpos;
|
327
|
328
|
}
|
328
|
329
|
if(scrollstart!=0 && lmbdown==0) {
|
329
|
330
|
scrollstart=0;
|
...
|
...
|
@@ -351,12 +352,12 @@ main(int argc, char *argv[])
|
351
|
352
|
tdif=tcur-scrolllast;
|
352
|
353
|
ycur=scrollstartpos.y-mousepos.y;
|
353
|
354
|
scrollspeed=(tdif>0)?(oldmousepos.y-mousepos.y)*100000/tdif:0;
|
354
|
|
- im->body->leftscrollpos=leftscrollposstart+ycur;
|
|
355
|
+ im->body->dirdata[im->body->currentdirdata]->leftscrollpos=leftscrollposstart+ycur;
|
355
|
356
|
scrolllast=tcur;
|
356
|
357
|
}
|
357
|
358
|
if(is_scrolling==0 && scrollspeed!=0) {
|
358
|
359
|
scrollspeed=scrollspeed*4/5;
|
359
|
|
- im->body->leftscrollpos+=scrollspeed;
|
|
360
|
+ im->body->dirdata[im->body->currentdirdata]->leftscrollpos+=scrollspeed;
|
360
|
361
|
}
|
361
|
362
|
/* process clicks on menus */
|
362
|
363
|
if(click_avail) {
|
...
|
...
|
@@ -840,10 +841,10 @@ im_body_mouse(body_t *body, Vector2 mousepos, Vector2 wheel, int lmbpressed, int
|
840
|
841
|
return(-1); /* sanity check error */
|
841
|
842
|
dirdata=body->dirdata[body->currentdirdata];
|
842
|
843
|
/* wheel */
|
843
|
|
- body->leftscrollpos-=(int)wheel.y*WHEELSTEP;
|
844
|
|
- body->leftscrollpos=(body->leftscrollpos<0)?0:body->leftscrollpos;
|
845
|
|
- if(body->leftscrollpos>dirdata->listing.lastleftxywh.y)
|
846
|
|
- body->leftscrollpos=dirdata->listing.lastleftxywh.y;
|
|
844
|
+ body->dirdata[body->currentdirdata]->leftscrollpos-=(int)wheel.y*WHEELSTEP;
|
|
845
|
+ body->dirdata[body->currentdirdata]->leftscrollpos=(body->dirdata[body->currentdirdata]->leftscrollpos<0)?0:body->dirdata[body->currentdirdata]->leftscrollpos;
|
|
846
|
+ if(body->dirdata[body->currentdirdata]->leftscrollpos>dirdata->listing.lastleftxywh.y)
|
|
847
|
+ body->dirdata[body->currentdirdata]->leftscrollpos=dirdata->listing.lastleftxywh.y;
|
847
|
848
|
/* check if we have to process a click */
|
848
|
849
|
if(*click_avail==0 || lmbreleased==0)
|
849
|
850
|
return(0); /* nothing else to do */
|
...
|
...
|
@@ -869,7 +870,7 @@ im_body_mouse(body_t *body, Vector2 mousepos, Vector2 wheel, int lmbpressed, int
|
869
|
870
|
dirdata->dirname[0]='\0';
|
870
|
871
|
}
|
871
|
872
|
listing_get(&(dirdata->listing),body->rootdir,dirdata->dirname,1);
|
872
|
|
- body->leftscrollpos=0;
|
|
873
|
+ body->dirdata[body->currentdirdata]->leftscrollpos=0;
|
873
|
874
|
*click_avail=0;
|
874
|
875
|
return(0);
|
875
|
876
|
}
|
...
|
...
|
@@ -897,13 +898,25 @@ im_body_mouse(body_t *body, Vector2 mousepos, Vector2 wheel, int lmbpressed, int
|
897
|
898
|
free(dirdata->dirname),dirdata->dirname=NULL;
|
898
|
899
|
dirdata->dirname=newname;
|
899
|
900
|
listing_get(&(dirdata->listing),body->rootdir,dirdata->dirname,1);
|
900
|
|
- body->leftscrollpos=0;
|
|
901
|
+ body->dirdata[body->currentdirdata]->leftscrollpos=0;
|
901
|
902
|
*click_avail=0;
|
902
|
903
|
return(0);
|
903
|
904
|
}
|
904
|
905
|
}
|
905
|
906
|
/* dirdata select */
|
906
|
|
-#warning TODO
|
|
907
|
+ if(mousepos.x>body->leftsize && mousepos.y>body->xywh.y) {
|
|
908
|
+ int righty;
|
|
909
|
+ for(righty=body->xywh.y,i=0;i<body->sizedirdata;i++) {
|
|
910
|
+ if(body->dirdata[i]==NULL)
|
|
911
|
+ continue;
|
|
912
|
+ if(mousepos.y>=righty && mousepos.y<(righty+body->dirdata[i]->height) && i!=body->currentdirdata) {
|
|
913
|
+ body->currentdirdata=i;
|
|
914
|
+ *click_avail=0;
|
|
915
|
+ return(0);
|
|
916
|
+ }
|
|
917
|
+ righty+=body->dirdata[i]->height;
|
|
918
|
+ }
|
|
919
|
+ }
|
907
|
920
|
/* detect click on "add dirdata" button */
|
908
|
921
|
if(is_imutil_insidexywh(mousepos,&(body->dirdataadd),0)) {
|
909
|
922
|
im_body_add(body,body->dirdata[body->currentdirdata]->dirname);
|
...
|
...
|
@@ -989,7 +1002,7 @@ im_body_draw(body_t *body, Vector2 mousepos, int lmbdown, int rmbdown, int windo
|
989
|
1002
|
if(is_leftside && !(dirdata->dirname[0]=='\0' || strcmp(dirdata->dirname,SEP)==0)) {
|
990
|
1003
|
m2=MeasureTextEx(fontbig->font,UTF8DOWNARROW,fontbig->height,0);
|
991
|
1004
|
v2.x=(float) (body->xywh.x+fontbig->height/2);
|
992
|
|
- v2.y=(float) (body->xywh.y+fontbig->height/4+(fontbig->height-v2.x)/2)-body->leftscrollpos;
|
|
1005
|
+ v2.y=(float) (body->xywh.y+fontbig->height/4+(fontbig->height-v2.x)/2)-body->dirdata[body->currentdirdata]->leftscrollpos;
|
993
|
1006
|
FILLXYWH(body->backxywh,v2.x-fontbig->height/4,v2.y-fontbig->height/8,m2.x+fontbig->height/4,m2.x+fontbig->height/4);
|
994
|
1007
|
#if 0
|
995
|
1008
|
DrawTexture(fontbig->font.texture, 0, 0, WHITE); /* font glyphs -- see https://github.com/raysan5/raylib/issues/2022 */
|
...
|
...
|
@@ -1000,7 +1013,7 @@ DrawRectangle(UNROLLXYWH(body->backxywh),((Color){ 0,255,0,255 })); /* hit zone
|
1000
|
1013
|
}
|
1001
|
1014
|
if(is_leftside) {
|
1002
|
1015
|
/* ...dirname */
|
1003
|
|
- v2.y=(float) (body->xywh.y+fontbig->height/4-body->leftscrollpos);
|
|
1016
|
+ v2.y=(float) (body->xywh.y+fontbig->height/4-body->dirdata[body->currentdirdata]->leftscrollpos);
|
1004
|
1017
|
if((v2.y+fontbig->height)>=0) {
|
1005
|
1018
|
m2=MeasureTextEx(fontbig->font,dirdata->dirname,fontbig->height,0);
|
1006
|
1019
|
v2.x=(float) (body->xywh.x+fontbig->height/2)+(body->leftsize-(body->xywh.x+fontbig->height)-m2.x)/2;
|
...
|
...
|
@@ -1023,12 +1036,12 @@ DrawRectangle(UNROLLXYWH(body->backxywh),((Color){ 0,255,0,255 })); /* hit zone
|
1023
|
1036
|
,(Vector2) {body->xywh.x+body->leftsize+fontbig->height/2,righty+fontbig->height/4}
|
1024
|
1037
|
,fontbig->height
|
1025
|
1038
|
,0
|
1026
|
|
- ,(Color){ 240, 240, 240, 255 }
|
|
1039
|
+ ,(i==body->currentdirdata)?((Color){ 240, 240, 240, 255 }):((Color){ 65, 65, 65, 255 })
|
1027
|
1040
|
);
|
1028
|
1041
|
}
|
1029
|
1042
|
/* directories */
|
1030
|
1043
|
xoff=((is_leftside)?0:body->leftsize);
|
1031
|
|
- yoff=((is_leftside)?body->xywh.y:righty)+fontbig->height/4+fontbig->height+font->height/4-(is_leftside?body->leftscrollpos:0);
|
|
1044
|
+ yoff=((is_leftside)?body->xywh.y:righty)+fontbig->height/4+fontbig->height+font->height/4-(is_leftside?body->dirdata[body->currentdirdata]->leftscrollpos:0);
|
1032
|
1045
|
if(is_leftside && dirdata->dirname[0]=='\0')
|
1033
|
1046
|
yoff-=fontbig->height/4+fontbig->height;
|
1034
|
1047
|
for(k=0,lastx=lasty=0;k<dirdata->listing.usedelems;k++) {
|