Browse code

Modularize menu handling

Dario Rodriguez authored on 16/02/2025 18:01:21
Showing 1 changed files
... ...
@@ -7,6 +7,7 @@
7 7
  *      20250119 Creation. Menu bar.
8 8
  *      20250123 Load font.
9 9
  *      20250213 Support sticky drop-down menus.
10
+ *      20250216 Modularize menu handling.
10 11
  *
11 12
  * Author: Dario Rodriguez dario@darionomono.com
12 13
  * (c) Dario Rodriguez 2025
... ...
@@ -47,6 +48,12 @@ typedef struct xywh_t {
47 48
         int h;
48 49
 } xywh_t;
49 50
 
51
+typedef struct font_t {
52
+        Font font;
53
+        int height;
54
+} font_t;
55
+
56
+
50 57
 typedef struct menudata_t {
51 58
         char *title;
52 59
         xywh_t xywh;
... ...
@@ -58,29 +65,40 @@ typedef struct menudata_t {
58 65
         int currentoption;
59 66
 } menudata_t;
60 67
 
68
+typedef struct menubar_t {
69
+        int sizemenudata;
70
+        menudata_t **menudata;
71
+} menubar_t;
72
+
61 73
 typedef struct dirdata_t {
62 74
         int height;
63 75
         char *dirname;
64 76
 } dirdata_t;
65 77
 
66 78
 typedef struct im_t {
79
+        int windowinit;
67 80
         int w;
68 81
         int h;
69
-        int sizemenudata;
70
-        menudata_t **menudata;
71 82
         int sizedirdata;
72 83
         dirdata_t **dirdata;
73 84
         int currentdirdata;
74 85
         int leftscrollpos;
75 86
         int rightscrollpos;
76
-        Font font;
77
-        int font_height;
87
+        menubar_t *menubar;
88
+        font_t *font;
78 89
 } im_t;
79 90
 
80 91
 im_t *im_init(char *menus);
81 92
 void im_free(im_t *im);
82 93
 
83
-int imdraw_menus(im_t *im);
94
+font_t *im_font_init(void);
95
+void im_font_free(font_t *font);
96
+
97
+menubar_t *im_menubar_init(char *menus);
98
+void im_menubar_free(menubar_t *menubar);
99
+
100
+int im_menubar_mouse(menubar_t *menubar, Vector2 mousepos, int lmbpressed, int lmbreleased, int lmbdown, int *click_avail, char **sel_menu, char **sel_submenu);
101
+int im_menubar_draw(menubar_t *menubar, font_t *font, int windowwidth, int windowheight);
84 102
 
85 103
 int imutil_menu_count(char *menus);
86 104
 char *imutil_menu_get(char *menus, int targetn, int *len);
... ...
@@ -97,9 +115,9 @@ main(int argc, char *argv[])
97 115
         im_t *im;
98 116
         Vector2 mousepos;
99 117
         int flag_ignorelmb;
100
-        int i,j;
101 118
         int lmbpressed,lmbreleased,lmbdown;
102
-        int flag_outsideall;
119
+        int click_avail;
120
+        char *sel_menu,*sel_submenu;
103 121
         if((im=im_init("Fichero\nAjustes\nSalir\n\nEditar\nNuevo directorio\n\nAyuda\nInformación sobre el programa\n\n"))==NULL) {
104 122
                 return(1);
105 123
         }
... ...
@@ -109,69 +127,21 @@ main(int argc, char *argv[])
109 127
                 lmbpressed=IsMouseButtonPressed(0);
110 128
                 lmbreleased=IsMouseButtonReleased(0);
111 129
                 lmbdown=IsMouseButtonDown(0);
112
-                /* check if we have to open a menu */
113
-                flag_outsideall=1;
114
-                for(i=0;i<im->sizemenudata;i++) {
115
-                        int insidetitle,currentoption;
116
-                        insidetitle=is_imutil_insidexywh(mousepos,&(im->menudata[i]->xywh));
117
-                        currentoption=menudata_pos2option(im->menudata[i],mousepos);
118
-                        flag_outsideall=(currentoption!=-1 || insidetitle)?0:flag_outsideall;
119
-                        if(lmbreleased && insidetitle) {
120
-                                for(j=0;j<im->sizemenudata;j++) {
121
-                                        im->menudata[j]->flag_stickyopen=(j==i)?1:0;
122
-                                        im->menudata[j]->flag_open=0;
123
-                                        im->menudata[j]->currentoption=-1;
124
-                                }
125
-                        } else if((lmbpressed || lmbdown) && insidetitle) {
126
-                                for(j=0;j<im->sizemenudata;j++) {
127
-                                        im->menudata[j]->flag_open=(j==i)?1:0;
128
-                                        im->menudata[j]->flag_stickyopen=0;
129
-                                        im->menudata[j]->currentoption=-1;
130
-                                }
131
-                        } else if((lmbdown || im->menudata[i]->flag_stickyopen) && currentoption!=-1) {
132
-                                for(j=0;j<im->sizemenudata;j++) {
133
-                                        if(lmbreleased==0 || j!=i || im->menudata[i]->flag_stickyopen==0) {
134
-                                                im->menudata[j]->flag_open=(j==i)?im->menudata[i]->flag_open:0;
135
-                                                im->menudata[j]->flag_stickyopen=(j==i)?im->menudata[i]->flag_stickyopen:0;
136
-                                                im->menudata[j]->currentoption=(j==i)?currentoption:-1;
137
-                                        } else {
138
-                                                im->menudata[j]->flag_open=0;
139
-                                                im->menudata[j]->flag_stickyopen=0;
140
-                                                im->menudata[j]->currentoption=-1;
130
+                click_avail=1;
131
+                /* process clicks on menus */
132
+                if(click_avail) {
133
+                        sel_menu=sel_submenu=NULL;
134
+                        im_menubar_mouse(im->menubar, mousepos, lmbpressed, lmbreleased, lmbdown, &click_avail, &sel_menu, &sel_submenu);
135
+                        if(sel_menu!=NULL && sel_submenu!=NULL) {
141 136
 #if 1
142
-fprintf(stderr,"SELECTED: \"%s\"->\"%s\"\n",im->menudata[i]->title,im->menudata[i]->options[currentoption]);
137
+fprintf(stderr,"SELECTED: \"%s\"->\"%s\"\n",sel_menu,sel_submenu);
143 138
 #endif
144
-                                        }
145
-                                }
146
-                        } else if(im->menudata[i]->flag_stickyopen && currentoption==-1) {
147
-                                if(lmbreleased) {
148
-                                        im->menudata[i]->flag_open=0;
149
-                                        im->menudata[i]->flag_stickyopen=0;
150
-                                }
151
-                                im->menudata[i]->currentoption=-1;
152
-                        } else if(lmbreleased && currentoption!=-1) {
153
-                                for(j=0;j<im->sizemenudata;j++) {
154
-                                        im->menudata[j]->flag_open=0;
155
-                                        im->menudata[j]->flag_stickyopen=0;
156
-                                        im->menudata[j]->currentoption=-1;
157
-                                }
158
-#if 1
159
-fprintf(stderr,"SELECTED: \"%s\"->\"%s\"\n",im->menudata[i]->title,im->menudata[i]->options[currentoption]);
160
-#endif
161
-                        } else if(lmbdown==0) {
162
-                                im->menudata[i]->flag_open=0;
163
-                                im->menudata[i]->flag_stickyopen=0;
164
-                                im->menudata[i]->currentoption=-1;
165
-                        }
166
-                }
167
-                if(flag_outsideall) {
168
-                        for(j=0;j<im->sizemenudata;j++) {
169
-                                im->menudata[j]->currentoption=-1;
170 139
                         }
171 140
                 }
141
+                /* draw screen contents */
172 142
                 BeginDrawing();
173 143
                 ClearBackground(RAYWHITE);
174
-                imdraw_menus(im);
144
+                im_menubar_draw(im->menubar,im->font,im->w,im->h);
175 145
                 EndDrawing();
176 146
         }
177 147
         CloseWindow();
... ...
@@ -183,51 +153,118 @@ im_t *
183 153
 im_init(char *menus)
184 154
 {
185 155
         im_t *im;
156
+        if(menus==NULL)
157
+                return(NULL); /* sanity check failed */
158
+        if((im=calloc(1,sizeof(im_t)))==NULL
159
+          || (im->menubar=im_menubar_init(menus))==NULL
160
+        ) {
161
+                im_free(im),im=NULL;
162
+                return(NULL); /* insuf. mem. */
163
+        }
164
+        /* init window */
165
+        SetTraceLogLevel(LOG_ERROR);
166
+        InitWindow((im->w=DEFAULTWIDTH),(im->h=DEFAULTHEIGHT),"Image Mover");
167
+        im->windowinit=1;
168
+        SetTargetFPS(30);
169
+        /* init font */
170
+        if((im->font=im_font_init())==NULL) {
171
+                im_free(im),im=NULL;
172
+                return(NULL); /* insuf. mem. */
173
+        }
174
+        return(im);
175
+}
176
+
177
+void
178
+im_free(im_t *im)
179
+{
180
+        int i;
181
+        if(im==NULL)
182
+                return;
183
+        if(im->menubar!=NULL)
184
+                im_menubar_free(im->menubar),im->menubar=NULL;
185
+        if(im->dirdata!=NULL) {
186
+                dirdata_t *dirdata;
187
+                for(i=0;i<im->sizedirdata;i++) {
188
+                        if((dirdata=im->dirdata[i])==NULL)
189
+                                continue;
190
+                        if(dirdata->dirname!=NULL)
191
+                                free(dirdata->dirname),dirdata->dirname=NULL;
192
+                }
193
+                free(im->dirdata),im->dirdata=NULL,im->sizedirdata=0;
194
+        }
195
+        if(im->font!=NULL)
196
+                im_font_free(im->font),im->font=NULL;
197
+#if 0 /* not working as intended */
198
+        if(im->windowinit)
199
+                CloseWindow(),im->windowinit=0;
200
+#endif
201
+        free(im),im=NULL;
202
+        return;
203
+}
204
+
205
+font_t *
206
+im_font_init(void)
207
+{
208
+        font_t *font;
209
+        int sizecodepoints;
210
+        int *codepoints;
211
+        if((font=calloc(1,sizeof(font_t)))==NULL)
212
+                return(NULL); /* insuf. mem. */
213
+        font->height=18;
214
+        codepoints=getcodepoints(&sizecodepoints);
215
+        font->font=LoadFontFromMemory(".ttf",(const unsigned char *)roboto_regular,sizeof(roboto_regular)-1,font->height,codepoints,sizecodepoints);
216
+        return(font);
217
+}
218
+
219
+void
220
+im_font_free(font_t *font)
221
+{
222
+        if(font==NULL)
223
+                return;
224
+#if 0 /* not working as intended */
225
+        UnloadFont(font->font);
226
+#endif
227
+        free(font),font=NULL;
228
+        return;
229
+}
230
+
231
+menubar_t *
232
+im_menubar_init(char *menus)
233
+{
186 234
         int i,j;
187 235
         char *str,*substr;
188 236
         int len,sublen;
237
+        menubar_t *menubar;
189 238
         menudata_t *menudata;
190 239
         if(menus==NULL)
191 240
                 return(NULL); /* sanity check failed */
192
-        if((im=calloc(1,sizeof(im_t)))==NULL
193
-          || (im->sizemenudata=imutil_menu_count(menus))<=0
194
-          || (im->menudata=calloc(im->sizemenudata,sizeof(menudata_t)))==NULL
241
+        if((menubar=calloc(1,sizeof(menubar_t)))==NULL
242
+          || (menubar->sizemenudata=imutil_menu_count(menus))<=0
243
+          || (menubar->menudata=calloc(menubar->sizemenudata,sizeof(menudata_t)))==NULL
195 244
         ) {
196
-                im_free(im),im=NULL;
245
+                im_menubar_free(menubar),menubar=NULL;
197 246
                 return(NULL); /* insuf. mem. */
198 247
         }
199 248
         /* init menus */
200
-        for(i=0;i<im->sizemenudata;i++) {
201
-                if((menudata=im->menudata[i]=calloc(1,sizeof(menudata_t)))==NULL
249
+        for(i=0;i<menubar->sizemenudata;i++) {
250
+                if((menudata=menubar->menudata[i]=calloc(1,sizeof(menudata_t)))==NULL
202 251
                   || (str=imutil_menu_get(menus,i,&len))==NULL
203 252
                   || (menudata->title=imutil_strduplen(str,len))==NULL
204 253
                   || (menudata->sizeoptions=imutil_submenu_count(str))<=0
205 254
                   || (menudata->options=calloc(menudata->sizeoptions,sizeof(char *)))==NULL
206 255
                 ) {
207
-                        im_free(im),im=NULL;
256
+                        im_menubar_free(menubar),menubar=NULL;
208 257
                         return(NULL); /* insuf. mem. */
209 258
                 }
210 259
                 for(j=0;j<menudata->sizeoptions;j++) {
211 260
                         if((substr=imutil_submenu_get(str,j,&sublen))==NULL
212 261
                           || (menudata->options[j]=imutil_strduplen(substr,sublen))==NULL
213 262
                         ) {
214
-                                im_free(im),im=NULL;
263
+                                im_menubar_free(menubar),menubar=NULL;
215 264
                                 return(NULL); /* insuf. mem. */
216 265
                         }
217 266
                 }
218 267
         }
219
-        /* init window */
220
-        SetTraceLogLevel(LOG_ERROR);
221
-        InitWindow((im->w=DEFAULTWIDTH),(im->h=DEFAULTHEIGHT),"Image Mover");
222
-        SetTargetFPS(30);
223
-        /* init font */
224
-        {
225
-                int sizecodepoints;
226
-                int *codepoints;
227
-                im->font_height=18;
228
-                codepoints=getcodepoints(&sizecodepoints);
229
-                im->font=LoadFontFromMemory(".ttf",(const unsigned char *)roboto_regular,sizeof(roboto_regular)-1,im->font_height,codepoints,sizecodepoints);
230
-        }
231 268
 #if 0
232 269
         /* test imutil_menu_xxx */
233 270
         int n,m,l,ml,len,mlen;
... ...
@@ -248,26 +285,26 @@ im_init(char *menus)
248 285
 #endif
249 286
 #if 0
250 287
         /* test menudata */
251
-        for(i=0;i<im->sizemenudata;i++) {
252
-                fprintf(stderr,"menu[%i]:\"%s\"->",i,im->menudata[i]->title);
253
-                for(j=0;j<im->menudata[i]->sizeoptions;j++)
254
-                        fprintf(stderr,"|\"%s\"",im->menudata[i]->options[j]);
288
+        for(i=0;i<menubar->sizemenudata;i++) {
289
+                fprintf(stderr,"menu[%i]:\"%s\"->",i,menubar->menudata[i]->title);
290
+                for(j=0;j<menubar->menudata[i]->sizeoptions;j++)
291
+                        fprintf(stderr,"|\"%s\"",menubar->menudata[i]->options[j]);
255 292
                 fprintf(stderr,"\n");
256 293
         }
257 294
 #endif
258
-        return(im);
295
+        return(menubar);
259 296
 }
260 297
 
261 298
 void
262
-im_free(im_t *im)
299
+im_menubar_free(menubar_t *menubar)
263 300
 {
264 301
         int i,j;
265
-        if(im==NULL)
302
+        menudata_t *menudata;
303
+        if(menubar==NULL)
266 304
                 return;
267
-        if(im->menudata!=NULL) {
268
-                menudata_t *menudata;
269
-                for(i=0;i<im->sizemenudata;i++) {
270
-                        if((menudata=im->menudata[i])==NULL)
305
+        if(menubar->menudata!=NULL) {
306
+                for(i=0;i<menubar->sizemenudata;i++) {
307
+                        if((menudata=menubar->menudata[i])==NULL)
271 308
                                 continue;
272 309
                         if(menudata->title!=NULL)
273 310
                                 free(menudata->title),menudata->title=NULL;
... ...
@@ -278,41 +315,114 @@ im_free(im_t *im)
278 315
                                 }
279 316
                                 free(menudata->options),menudata->options=NULL,menudata->sizeoptions=0;
280 317
                         }
281
-                        free(im->menudata[i]),im->menudata[i]=NULL,menudata=NULL;
318
+                        free(menubar->menudata[i]),menubar->menudata[i]=NULL,menudata=NULL;
282 319
                 }
283
-                free(im->menudata),im->menudata=NULL,im->sizemenudata=0;
320
+                free(menubar->menudata),menubar->menudata=NULL,menubar->sizemenudata=0;
284 321
         }
285
-        if(im->dirdata!=NULL) {
286
-                dirdata_t *dirdata;
287
-                for(i=0;i<im->sizedirdata;i++) {
288
-                        if((dirdata=im->dirdata[i])==NULL)
289
-                                continue;
290
-                        if(dirdata->dirname!=NULL)
291
-                                free(dirdata->dirname),dirdata->dirname=NULL;
322
+        free(menubar),menubar=NULL;
323
+        return;
324
+}
325
+
326
+int
327
+im_menubar_mouse(menubar_t *menubar, Vector2 mousepos, int lmbpressed, int lmbreleased, int lmbdown, int *click_avail, char **sel_menu, char **sel_submenu)
328
+{
329
+        int flag_outsideall;
330
+        int i,j;
331
+        if(menubar==NULL || click_avail==NULL || sel_menu==NULL || sel_submenu==NULL)
332
+                return(-1);
333
+        *click_avail=1;
334
+        *sel_menu=NULL;
335
+        *sel_submenu=NULL;
336
+        flag_outsideall=1;
337
+        for(i=0;i<menubar->sizemenudata;i++) {
338
+                int insidetitle,currentoption;
339
+                insidetitle=is_imutil_insidexywh(mousepos,&(menubar->menudata[i]->xywh));
340
+                currentoption=menudata_pos2option(menubar->menudata[i],mousepos);
341
+                flag_outsideall=(currentoption!=-1 || insidetitle)?0:flag_outsideall;
342
+                if(lmbreleased && insidetitle) {
343
+                        for(j=0;j<menubar->sizemenudata;j++) {
344
+                                menubar->menudata[j]->flag_stickyopen=(j==i)?1:0;
345
+                                menubar->menudata[j]->flag_open=0;
346
+                                menubar->menudata[j]->currentoption=-1;
347
+                        }
348
+                } else if((lmbpressed || lmbdown) && insidetitle) {
349
+                        for(j=0;j<menubar->sizemenudata;j++) {
350
+                                menubar->menudata[j]->flag_open=(j==i)?1:0;
351
+                                menubar->menudata[j]->flag_stickyopen=0;
352
+                                menubar->menudata[j]->currentoption=-1;
353
+                        }
354
+                } else if((lmbdown || menubar->menudata[i]->flag_stickyopen) && currentoption!=-1) {
355
+                        for(j=0;j<menubar->sizemenudata;j++) {
356
+                                if(lmbreleased==0 || j!=i || menubar->menudata[i]->flag_stickyopen==0) {
357
+                                        menubar->menudata[j]->flag_open=(j==i)?menubar->menudata[i]->flag_open:0;
358
+                                        menubar->menudata[j]->flag_stickyopen=(j==i)?menubar->menudata[i]->flag_stickyopen:0;
359
+                                        menubar->menudata[j]->currentoption=(j==i)?currentoption:-1;
360
+                                } else {
361
+                                        menubar->menudata[j]->flag_open=0;
362
+                                        menubar->menudata[j]->flag_stickyopen=0;
363
+                                        menubar->menudata[j]->currentoption=-1;
364
+                                        /* has selected this submenu */
365
+                                        *click_avail=0;
366
+                                        *sel_menu=menubar->menudata[j]->title;
367
+                                        *sel_submenu=menubar->menudata[j]->options[currentoption];
368
+                                }
369
+                        }
370
+                } else if(menubar->menudata[i]->flag_stickyopen && currentoption==-1) {
371
+                        if(lmbreleased) {
372
+                                menubar->menudata[i]->flag_open=0;
373
+                                menubar->menudata[i]->flag_stickyopen=0;
374
+                        }
375
+                        menubar->menudata[i]->currentoption=-1;
376
+                } else if(lmbreleased && currentoption!=-1) {
377
+                        for(j=0;j<menubar->sizemenudata;j++) {
378
+                                menubar->menudata[j]->flag_open=0;
379
+                                menubar->menudata[j]->flag_stickyopen=0;
380
+                                menubar->menudata[j]->currentoption=-1;
381
+                        }
382
+                        /* has selected this submenu */
383
+                        *click_avail=0;
384
+                        *sel_menu=menubar->menudata[i]->title;
385
+                        *sel_submenu=menubar->menudata[i]->options[currentoption];
386
+                } else if(lmbdown==0) {
387
+                        menubar->menudata[i]->flag_open=0;
388
+                        menubar->menudata[i]->flag_stickyopen=0;
389
+                        menubar->menudata[i]->currentoption=-1;
292 390
                 }
293
-                free(im->dirdata),im->dirdata=NULL,im->sizedirdata=0;
294 391
         }
295
-        free(im),im=NULL;
296
-        return;
392
+        if(flag_outsideall) {
393
+                for(j=0;j<menubar->sizemenudata;j++) {
394
+                        menubar->menudata[j]->currentoption=-1;
395
+                }
396
+        }
397
+        /* update click_avail */
398
+        for(j=0;j<menubar->sizemenudata;j++) {
399
+                if(menubar->menudata[j]->flag_open || menubar->menudata[j]->flag_stickyopen) {
400
+                        *click_avail=0;
401
+                        break;
402
+                }
403
+        }
404
+        return(0);
297 405
 }
298 406
 
299 407
 int
300
-imdraw_menus(im_t *im)
408
+im_menubar_draw(menubar_t *menubar, font_t *font, int windowwidth, int windowheight)
301 409
 {
302 410
         int i,j,k,x;
303 411
         menudata_t *menudata;
304
-        DrawRectangle(0,0,im->w, im->font_height+im->font_height/2, (Color){ 235, 235, 235, 235 } );
305
-        for(i=0,x=0;i<im->sizemenudata;i++) {
412
+        if(menubar==NULL || font==NULL)
413
+                return(-1); /* sanity check failed */
414
+        DrawRectangle(0,0,windowwidth, font->height+font->height/2, (Color){ 235, 235, 235, 235 } );
415
+        for(i=0,x=0;i<menubar->sizemenudata;i++) {
306 416
                 Vector2 v2;
307
-                menudata=im->menudata[i];
308
-                v2=MeasureTextEx(im->font,menudata->title,im->font_height,0);
309
-                FILLXYWH(menudata->xywh,x,0,((int)v2.x)+im->font_height,im->font_height+im->font_height/2);
310
-                v2.x=(float) (menudata->xywh.x+im->font_height/2);
311
-                v2.y=(float) (menudata->xywh.y+im->font_height/4);
312
-                DrawTextEx(im->font
417
+                menudata=menubar->menudata[i];
418
+                v2=MeasureTextEx(font->font,menudata->title,font->height,0);
419
+                FILLXYWH(menudata->xywh,x,0,((int)v2.x)+font->height,font->height+font->height/2);
420
+                v2.x=(float) (menudata->xywh.x+font->height/2);
421
+                v2.y=(float) (menudata->xywh.y+font->height/4);
422
+                DrawTextEx(font->font
313 423
                   ,menudata->title
314 424
                   ,v2
315
-                  ,im->font_height
425
+                  ,font->height
316 426
                   ,0
317 427
                   ,(Color){ 45, 45, 45, 255 }
318 428
                 );
... ...
@@ -321,12 +431,12 @@ imdraw_menus(im_t *im)
321 431
                         int maxw;
322 432
                         DrawRectangle(menudata->xywh.x,menudata->xywh.y+menudata->xywh.h-underline_height,menudata->xywh.w,underline_height, (Color){ 53,132,228,255 } );
323 433
                         for(j=0,maxw=0;j<menudata->sizeoptions;j++) {
324
-                                v2=MeasureTextEx(im->font,menudata->options[j],im->font_height,0);
434
+                                v2=MeasureTextEx(font->font,menudata->options[j],font->height,0);
325 435
                                 maxw=(((int)(v2.x))>maxw)?((int)(v2.x)):maxw;
326 436
                         }
327
-                        maxw=(maxw<(menudata->xywh.w+im->font_height))?(menudata->xywh.w+im->font_height):maxw;
328
-                        maxw+=im->font_height;
329
-                        FILLXYWH(menudata->optionsxywh,menudata->xywh.x+1,menudata->xywh.y+menudata->xywh.h+2,maxw,(im->font_height+im->font_height/2)*menudata->sizeoptions);
437
+                        maxw=(maxw<(menudata->xywh.w+font->height))?(menudata->xywh.w+font->height):maxw;
438
+                        maxw+=font->height;
439
+                        FILLXYWH(menudata->optionsxywh,menudata->xywh.x+1,menudata->xywh.y+menudata->xywh.h+2,maxw,(font->height+font->height/2)*menudata->sizeoptions);
330 440
                         DrawLine(menudata->optionsxywh.x-1,menudata->optionsxywh.y-2,menudata->optionsxywh.x+menudata->optionsxywh.w+2,menudata->optionsxywh.y-2,(Color){ 255,255,255,255 } );
331 441
                         DrawLine(menudata->optionsxywh.x-1,menudata->optionsxywh.y,menudata->optionsxywh.x-1,menudata->optionsxywh.y+menudata->optionsxywh.h+1,(Color){ 255,255,255,255 } );
332 442
                         DrawLine(menudata->optionsxywh.x+menudata->optionsxywh.w+2,menudata->optionsxywh.y,menudata->optionsxywh.x+menudata->optionsxywh.w+2,menudata->optionsxywh.y+menudata->optionsxywh.h+1,(Color){ 192,192,192,255 } );
... ...
@@ -336,13 +446,13 @@ imdraw_menus(im_t *im)
336 446
                                 Color c;
337 447
                                 c=(k==menudata->currentoption)?((Color){ 255,255,255,255 }):((Color){ 45, 45, 45, 255 });
338 448
                                 if(k==menudata->currentoption)
339
-                                        DrawRectangle(menudata->optionsxywh.x+1,menudata->optionsxywh.y+(im->font_height+(im->font_height/2))*k,menudata->optionsxywh.w-2,im->font_height+im->font_height/2,(Color){ 53,132,228,255 });
340
-                                v2.x=(float) (menudata->optionsxywh.x+im->font_height/2);
341
-                                v2.y=(float) (menudata->optionsxywh.y+(im->font_height/4)+(im->font_height+(im->font_height/2))*k);
342
-                                DrawTextEx(im->font
449
+                                        DrawRectangle(menudata->optionsxywh.x+1,menudata->optionsxywh.y+(font->height+(font->height/2))*k,menudata->optionsxywh.w-2,font->height+font->height/2,(Color){ 53,132,228,255 });
450
+                                v2.x=(float) (menudata->optionsxywh.x+font->height/2);
451
+                                v2.y=(float) (menudata->optionsxywh.y+(font->height/4)+(font->height+(font->height/2))*k);
452
+                                DrawTextEx(font->font
343 453
                                   ,menudata->options[k]
344 454
                                   ,v2
345
-                                  ,im->font_height
455
+                                  ,font->height
346 456
                                   ,0
347 457
                                   ,c
348 458
                                 );
... ...
@@ -352,7 +462,6 @@ imdraw_menus(im_t *im)
352 462
                 }
353 463
                 x=menudata->xywh.x+menudata->xywh.w;
354 464
         }
355
-#warning TODO
356 465
         return(0);
357 466
 }
358 467