...
|
...
|
@@ -20,6 +20,7 @@
|
20
|
20
|
* Preserve aspect ratio of big image.
|
21
|
21
|
* 20250305 Scrollable left pane.
|
22
|
22
|
* 20250308 Show statustooltip on image hover.
|
|
23
|
+ * Scrollwheel support for leftside.
|
23
|
24
|
*
|
24
|
25
|
* Author: Dario Rodriguez dario@darionomono.com
|
25
|
26
|
* (c) Dario Rodriguez 2025
|
...
|
...
|
@@ -51,6 +52,8 @@
|
51
|
52
|
#define FONTBIGSIZE 32
|
52
|
53
|
#define FONTHUGESIZE 48
|
53
|
54
|
|
|
55
|
+#define WHEELSTEP LEFTIMAGESIDELEN
|
|
56
|
+
|
54
|
57
|
#define ROOTDIR "/var/www/default/animeshot/"
|
55
|
58
|
|
56
|
59
|
#define SEP "/"
|
...
|
...
|
@@ -148,6 +151,7 @@ typedef struct listing_t {
|
148
|
151
|
char *buf;
|
149
|
152
|
int has_leftxywh;
|
150
|
153
|
int has_rightxywh;
|
|
154
|
+ xywh_t lastleftxywh;
|
151
|
155
|
} listing_t;
|
152
|
156
|
|
153
|
157
|
typedef struct dirdata_t {
|
...
|
...
|
@@ -206,7 +210,7 @@ void im_body_free(body_t *body);
|
206
|
210
|
|
207
|
211
|
int im_body_add(body_t *body,char *dir);
|
208
|
212
|
|
209
|
|
-int im_body_mouse(body_t *body, Vector2 mousepos, int lmbpressed, int lmbreleased, int lmbdown, int *click_avail);
|
|
213
|
+int im_body_mouse(body_t *body, Vector2 mousepos, Vector2 wheel, int lmbpressed, int lmbreleased, int lmbdown, int *click_avail);
|
210
|
214
|
int im_body_draw(body_t *body, Vector2 mousepos, int lmbdown, int windowwidth, int windowheight);
|
211
|
215
|
|
212
|
216
|
int listing_get(listing_t *listing, char *pathprefix, char *path, int flag_sort);
|
...
|
...
|
@@ -228,7 +232,7 @@ int
|
228
|
232
|
main(int argc, char *argv[])
|
229
|
233
|
{
|
230
|
234
|
im_t *im;
|
231
|
|
- Vector2 mousepos;
|
|
235
|
+ Vector2 mousepos,wheel;
|
232
|
236
|
int flag_ignorelmb;
|
233
|
237
|
int lmbpressed,lmbreleased,lmbdown;
|
234
|
238
|
int click_avail;
|
...
|
...
|
@@ -239,6 +243,7 @@ main(int argc, char *argv[])
|
239
|
243
|
flag_ignorelmb=0;
|
240
|
244
|
while(!WindowShouldClose()) {
|
241
|
245
|
mousepos=GetMousePosition();
|
|
246
|
+ wheel=GetMouseWheelMoveV();
|
242
|
247
|
lmbpressed=IsMouseButtonPressed(0);
|
243
|
248
|
lmbreleased=IsMouseButtonReleased(0);
|
244
|
249
|
lmbdown=IsMouseButtonDown(0);
|
...
|
...
|
@@ -254,7 +259,7 @@ fprintf(stderr,"SELECTED: \"%s\"->\"%s\"\n",sel_menu,sel_submenu);
|
254
|
259
|
}
|
255
|
260
|
}
|
256
|
261
|
if(click_avail)
|
257
|
|
- im_body_mouse(im->body, mousepos, lmbpressed, lmbreleased, lmbdown, &click_avail);
|
|
262
|
+ im_body_mouse(im->body, mousepos, wheel, lmbpressed, lmbreleased, lmbdown, &click_avail);
|
258
|
263
|
|
259
|
264
|
|
260
|
265
|
/* draw screen contents */
|
...
|
...
|
@@ -707,7 +712,7 @@ im_body_add(body_t *body,char *dir)
|
707
|
712
|
}
|
708
|
713
|
|
709
|
714
|
int
|
710
|
|
-im_body_mouse(body_t *body, Vector2 mousepos, int lmbpressed, int lmbreleased, int lmbdown, int *click_avail)
|
|
715
|
+im_body_mouse(body_t *body, Vector2 mousepos, Vector2 wheel, int lmbpressed, int lmbreleased, int lmbdown, int *click_avail)
|
711
|
716
|
{
|
712
|
717
|
int i;
|
713
|
718
|
char *ptr;
|
...
|
...
|
@@ -715,9 +720,15 @@ im_body_mouse(body_t *body, Vector2 mousepos, int lmbpressed, int lmbreleased, i
|
715
|
720
|
listingdata_t *ld;
|
716
|
721
|
if(body==NULL || click_avail==NULL || body->currentdirdata<0 || body->currentdirdata>=body->sizedirdata || body->dirdata[body->currentdirdata]==NULL)
|
717
|
722
|
return(-1); /* sanity check error */
|
718
|
|
- if(*click_avail==0 || lmbreleased==0)
|
719
|
|
- return(0); /* nothing to do */
|
720
|
723
|
dirdata=body->dirdata[body->currentdirdata];
|
|
724
|
+ /* wheel */
|
|
725
|
+ body->leftscrollpos-=(int)wheel.y*WHEELSTEP;
|
|
726
|
+ body->leftscrollpos=(body->leftscrollpos<0)?0:body->leftscrollpos;
|
|
727
|
+ if(body->leftscrollpos>dirdata->listing.lastleftxywh.y)
|
|
728
|
+ body->leftscrollpos=dirdata->listing.lastleftxywh.y;
|
|
729
|
+ /* check if we have to process a click */
|
|
730
|
+ if(*click_avail==0 || lmbreleased==0)
|
|
731
|
+ return(0); /* nothing else to do */
|
721
|
732
|
/* leftside backbutton */
|
722
|
733
|
if(is_imutil_insidexywh(mousepos,&(body->backxywh))) {
|
723
|
734
|
static char sep[]={SEP};
|
...
|
...
|
@@ -729,6 +740,7 @@ im_body_mouse(body_t *body, Vector2 mousepos, int lmbpressed, int lmbreleased, i
|
729
|
740
|
dirdata->dirname[0]='\0';
|
730
|
741
|
}
|
731
|
742
|
listing_get(&(dirdata->listing),body->rootdir,dirdata->dirname,1);
|
|
743
|
+ body->leftscrollpos=0;
|
732
|
744
|
*click_avail=0;
|
733
|
745
|
return(0);
|
734
|
746
|
}
|
...
|
...
|
@@ -737,7 +749,7 @@ im_body_mouse(body_t *body, Vector2 mousepos, int lmbpressed, int lmbreleased, i
|
737
|
749
|
ld=dirdata->listing.elems+i;
|
738
|
750
|
if(ld->name[0]!='d')
|
739
|
751
|
continue;
|
740
|
|
- if(is_imutil_insidexywh(mousepos,&(ld->left.xywh))) {
|
|
752
|
+ if(is_imutil_insidexywh(mousepos,&(ld->left.screenxywh))) {
|
741
|
753
|
char *newname,*oldprefix;
|
742
|
754
|
int l,l0,l1;
|
743
|
755
|
static char sep[]={SEP};
|
...
|
...
|
@@ -756,6 +768,7 @@ im_body_mouse(body_t *body, Vector2 mousepos, int lmbpressed, int lmbreleased, i
|
756
|
768
|
free(dirdata->dirname),dirdata->dirname=NULL;
|
757
|
769
|
dirdata->dirname=newname;
|
758
|
770
|
listing_get(&(dirdata->listing),body->rootdir,dirdata->dirname,1);
|
|
771
|
+ body->leftscrollpos=0;
|
759
|
772
|
*click_avail=0;
|
760
|
773
|
return(0);
|
761
|
774
|
}
|
...
|
...
|
@@ -780,17 +793,6 @@ im_body_draw(body_t *body, Vector2 mousepos, int lmbdown, int windowwidth, int w
|
780
|
793
|
char statustooltip[1024];
|
781
|
794
|
if(body==NULL)
|
782
|
795
|
return(-1);
|
783
|
|
-#if 1
|
784
|
|
-#warning TESTING LEFTSCROLL
|
785
|
|
-body->leftscrollpos=(int) mousepos.y;
|
786
|
|
-{
|
787
|
|
- static int lastlsp=-1;
|
788
|
|
- if(body->leftscrollpos!=lastlsp) {
|
789
|
|
- lastlsp=body->leftscrollpos;
|
790
|
|
- fprintf(stderr,"leftscrollpos:%i\n",body->leftscrollpos);
|
791
|
|
- }
|
792
|
|
-}
|
793
|
|
-#endif
|
794
|
796
|
font=body->ptrfont;
|
795
|
797
|
fontbig=body->ptrfontbig;
|
796
|
798
|
fonthuge=body->ptrfonthuge;
|
...
|
...
|
@@ -1368,6 +1370,8 @@ listing_fillxywh(listing_t *listing, font_t *font, int w, int sidelen, int is_le
|
1368
|
1370
|
if(listing==NULL || font==NULL)
|
1369
|
1371
|
return(-1); /* sanity check failed */
|
1370
|
1372
|
margin=font->height/4;
|
|
1373
|
+ if(is_leftside)
|
|
1374
|
+ memset(&(listing->lastleftxywh),0,sizeof(listing->lastleftxywh));
|
1371
|
1375
|
/* directories */
|
1372
|
1376
|
if(is_leftside) {
|
1373
|
1377
|
x0=font->height/2;
|
...
|
...
|
@@ -1391,6 +1395,8 @@ listing_fillxywh(listing_t *listing, font_t *font, int w, int sidelen, int is_le
|
1391
|
1395
|
continue;
|
1392
|
1396
|
}
|
1393
|
1397
|
FILLXYWH(thumb->xywh,x,y,margin*2+m2.x,margin*2+font->height);
|
|
1398
|
+ if(is_leftside && (thumb->xywh.y+thumb->xywh.h)>(listing->lastleftxywh.y+listing->lastleftxywh.h))
|
|
1399
|
+ memcpy(&(listing->lastleftxywh),&(thumb->xywh),sizeof(xywh_t));
|
1394
|
1400
|
x+=margin*2+m2.x+font->height/4;
|
1395
|
1401
|
}
|
1396
|
1402
|
y+=((x==x0)?0:font->height+margin*2+font->height/4);
|
...
|
...
|
@@ -1415,6 +1421,8 @@ listing_fillxywh(listing_t *listing, font_t *font, int w, int sidelen, int is_le
|
1415
|
1421
|
continue;
|
1416
|
1422
|
}
|
1417
|
1423
|
FILLXYWH(thumb->xywh,x,y,sidelen,sidelen);
|
|
1424
|
+ if(is_leftside && (thumb->xywh.y+thumb->xywh.h)>(listing->lastleftxywh.y+listing->lastleftxywh.h))
|
|
1425
|
+ memcpy(&(listing->lastleftxywh),&(thumb->xywh),sizeof(xywh_t));
|
1418
|
1426
|
x+=margin*2+sidelen;
|
1419
|
1427
|
}
|
1420
|
1428
|
return(0);
|