38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
#define BUTTON_HEIGHT 39
|
|
#define TEXTURE_POSITION_BUTTON_NORMAL 132
|
|
#define TEXTURE_POSITION_BUTTON_HIGHLIGHTED 172
|
|
#define TEXTURE_POSITION_BUTTON_DESACTIVATED 92
|
|
|
|
#include <gint/display.h>
|
|
|
|
/* shows a button
|
|
@state :
|
|
0 : desactivated
|
|
1 : normal
|
|
2 : highlighted
|
|
*/
|
|
void show_button(int x, int y, int size, char const *text, bopti_image_t *img_widgets, int state) {
|
|
if (size > 300) {
|
|
size = 300;
|
|
}
|
|
|
|
int texture_position = 0;
|
|
|
|
if (state == 0) {
|
|
texture_position = TEXTURE_POSITION_BUTTON_DESACTIVATED;
|
|
} else if (state == 1) {
|
|
texture_position = TEXTURE_POSITION_BUTTON_NORMAL;
|
|
} else {
|
|
texture_position = TEXTURE_POSITION_BUTTON_HIGHLIGHTED;
|
|
}
|
|
|
|
// left border
|
|
dsubimage(x, y, img_widgets, 0, texture_position, 4, BUTTON_HEIGHT, 0x01);
|
|
// middle
|
|
dsubimage(x + 4, y, img_widgets, 4, texture_position, size - 8, BUTTON_HEIGHT, 0x01);
|
|
// right border
|
|
dsubimage(x + size - 4, y, img_widgets, 296, texture_position, 4, BUTTON_HEIGHT, 0x01);
|
|
//text
|
|
dtext_opt(x + (size / 2), y + (BUTTON_HEIGHT / 2) - 3, C_WHITE, -1, 1, 0, text, 14);
|
|
}
|