Revision 324
corrected some more things
menu.c | ||
---|---|---|
8 | 8 |
#include "proj_macros.h" |
9 | 9 |
#include "errors.h" |
10 | 10 |
|
11 |
const int W = 400; |
|
12 |
const int H = 60; |
|
13 |
const int W1 = 40; |
|
14 |
const int H1 = 40; |
|
15 |
const int H2 = 20; |
|
11 |
static const int W = 400;
|
|
12 |
static const int H = 60;
|
|
13 |
static const int W1 = 40;
|
|
14 |
static const int H1 = 40;
|
|
15 |
static const int H2 = 20;
|
|
16 | 16 |
|
17 | 17 |
struct menu { |
18 | 18 |
const font_t *fnt; |
... | ... | |
23 | 23 |
}; |
24 | 24 |
|
25 | 25 |
static int menu_recalculate(menu_t *menu){ |
26 |
const int Wtotal = 2*W1+W;
|
|
27 |
const int Htotal = 2*H1+menu->sz*H+(menu->sz-1)*H2;
|
|
28 |
int x = graph_get_XRes()/2-Wtotal/2; |
|
29 |
int y = graph_get_YRes()/2-Htotal/2; |
|
26 |
const uint16_t Wtotal = 2*W1+W;
|
|
27 |
const uint16_t Htotal = (uint16_t)(2*H1+menu->sz*H+(menu->sz-1)*H2);
|
|
28 |
int16_t x = graph_get_XRes()/2-Wtotal/2;
|
|
29 |
int16_t y = graph_get_YRes()/2-Htotal/2;
|
|
30 | 30 |
rectangle_set_pos (menu->frame, x, y); |
31 | 31 |
rectangle_set_size(menu->frame, Wtotal, Htotal); |
32 | 32 |
x += W1; y += H1; |
... | ... | |
86 | 86 |
if(!click) return -1; |
87 | 87 |
for(size_t i = 0; i < menu->sz; ++i) |
88 | 88 |
if(rectangle_collide_point(menu->r[i], *get_mouse_X(), *get_mouse_Y())) |
89 |
return i; |
|
89 |
return (int)i;
|
|
90 | 90 |
return -1; |
91 | 91 |
} |
92 | 92 |
|
Also available in: Unified diff