Fix keyaction frame color, add hover to tab buttons, misc fixes
This commit is contained in:
		
							
								
								
									
										9
									
								
								button.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								button.c
									
									
									
									
									
								
							@@ -39,8 +39,11 @@ void button_init_ui(button *b, const char *text, int size)
 | 
			
		||||
        b->c[CLR_CHECK][0] = C_HIGHLIGHT_BG;
 | 
			
		||||
        b->c[CLR_CHECK][1] = C_HIGHLIGHT_TEXT;
 | 
			
		||||
 | 
			
		||||
        b->rect = fb_add_rect(b->x, b->y, b->w, b->h, b->c[CLR_NORMAL][0]);
 | 
			
		||||
        b->text = fb_add_text(0, 0, b->c[CLR_NORMAL][1], size, text);
 | 
			
		||||
        b->rect = fb_add_rect_lvl(b->level_off + LEVEL_RECT, b->x, b->y, b->w, b->h, b->c[CLR_NORMAL][0]);
 | 
			
		||||
 | 
			
		||||
        fb_text_proto *p = fb_text_create(0, 0, b->c[CLR_NORMAL][1], size, text);
 | 
			
		||||
        p->level = b->level_off + LEVEL_TEXT;
 | 
			
		||||
        b->text = fb_text_finalize(p);
 | 
			
		||||
        center_text(b->text, b->x, b->y, b->w, b->h);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
@@ -193,7 +196,7 @@ int button_keyaction_call(void *data, int act)
 | 
			
		||||
        {
 | 
			
		||||
            if(act != KEYACT_CLEAR && b->keyact_frame == NULL)
 | 
			
		||||
            {
 | 
			
		||||
                fb_add_rect_notfilled(b->x, b->y, b->w, b->h, KEYACT_FRAME_CLR, KEYACT_FRAME_W, &b->keyact_frame);
 | 
			
		||||
                fb_add_rect_notfilled(b->level_off + LEVEL_RECT, b->x, b->y, b->w, b->h, C_KEYACT_FRAME, KEYACT_FRAME_W, &b->keyact_frame);
 | 
			
		||||
                fb_request_draw();
 | 
			
		||||
                return 0;
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								button.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								button.h
									
									
									
									
									
								
							@@ -45,6 +45,7 @@ typedef struct
 | 
			
		||||
    fb_img *text;
 | 
			
		||||
    fb_rect *rect;
 | 
			
		||||
    fb_rect **keyact_frame;
 | 
			
		||||
    int level_off;
 | 
			
		||||
 | 
			
		||||
    uint32_t c[CLR_MAX][2];
 | 
			
		||||
 
 | 
			
		||||
 
 | 
			
		||||
@@ -718,23 +718,23 @@ fb_rect *fb_add_rect_lvl(int level, int x, int y, int w, int h, uint32_t color)
 | 
			
		||||
    return r;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void fb_add_rect_notfilled(int x, int y, int w, int h, uint32_t color, int thickness, fb_rect ***list)
 | 
			
		||||
void fb_add_rect_notfilled(int level, int x, int y, int w, int h, uint32_t color, int thickness, fb_rect ***list)
 | 
			
		||||
{
 | 
			
		||||
    fb_rect *r;
 | 
			
		||||
    // top
 | 
			
		||||
    r = fb_add_rect(x, y, w, thickness, color);
 | 
			
		||||
    r = fb_add_rect_lvl(level, x, y, w, thickness, color);
 | 
			
		||||
    list_add(r, list);
 | 
			
		||||
 | 
			
		||||
    // right
 | 
			
		||||
    r = fb_add_rect(x + w - thickness, y, thickness, h, color);
 | 
			
		||||
    r = fb_add_rect_lvl(level, x + w - thickness, y, thickness, h, color);
 | 
			
		||||
    list_add(r, list);
 | 
			
		||||
 | 
			
		||||
    // bottom
 | 
			
		||||
    r = fb_add_rect(x, y + h - thickness, w, thickness, color);
 | 
			
		||||
    r = fb_add_rect_lvl(level, x, y + h - thickness, w, thickness, color);
 | 
			
		||||
    list_add(r, list);
 | 
			
		||||
 | 
			
		||||
    // left
 | 
			
		||||
    r = fb_add_rect(x, y, thickness, h, color);
 | 
			
		||||
    r = fb_add_rect_lvl(level, x, y, thickness, h, color);
 | 
			
		||||
    list_add(r, list);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -257,7 +257,7 @@ void fb_text_destroy(fb_img *i);
 | 
			
		||||
 | 
			
		||||
fb_rect *fb_add_rect_lvl(int level, int x, int y, int w, int h, uint32_t color);
 | 
			
		||||
#define fb_add_rect(x, y, w, h, color) fb_add_rect_lvl(LEVEL_RECT, x, y, w, h, color)
 | 
			
		||||
void fb_add_rect_notfilled(int x, int y, int w, int h, uint32_t color, int thickness, fb_rect ***list);
 | 
			
		||||
void fb_add_rect_notfilled(int level, int x, int y, int w, int h, uint32_t color, int thickness, fb_rect ***list);
 | 
			
		||||
 | 
			
		||||
fb_img *fb_add_img(int level, int x, int y, int w, int h, int img_type, px_type *data);
 | 
			
		||||
fb_img *fb_add_png_img_lvl(int level, int x, int y, int w, int h, const char *path);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								input.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								input.h
									
									
									
									
									
								
							@@ -69,7 +69,6 @@ enum
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define KEYACT_FRAME_W (8*DPI_MUL)
 | 
			
		||||
#define KEYACT_FRAME_CLR (0xFFFF0000)
 | 
			
		||||
 | 
			
		||||
typedef int (*keyaction_call)(void *, int); // data, action
 | 
			
		||||
void keyaction_add(int x, int y, keyaction_call call, void *data);
 | 
			
		||||
 
 | 
			
		||||
@@ -132,7 +132,7 @@ int multirom_ui(struct multirom_status *s, struct multirom_rom **to_boot)
 | 
			
		||||
    workers_start();
 | 
			
		||||
    anim_init();
 | 
			
		||||
 | 
			
		||||
    multirom_ui_init_theme();
 | 
			
		||||
    multirom_ui_init_theme(TAB_INTERNAL);
 | 
			
		||||
 | 
			
		||||
    add_touch_handler(&multirom_ui_touch_handler, NULL);
 | 
			
		||||
    start_input_thread();
 | 
			
		||||
@@ -194,8 +194,7 @@ int multirom_ui(struct multirom_status *s, struct multirom_rom **to_boot)
 | 
			
		||||
 | 
			
		||||
            multirom_ui_destroy_theme();
 | 
			
		||||
            multirom_ui_select_color(s->colors);
 | 
			
		||||
            multirom_ui_init_theme();
 | 
			
		||||
            multirom_ui_switch(TAB_MISC);
 | 
			
		||||
            multirom_ui_init_theme(TAB_MISC);
 | 
			
		||||
 | 
			
		||||
            fb_freeze(0);
 | 
			
		||||
            fb_request_draw();
 | 
			
		||||
@@ -259,13 +258,13 @@ int multirom_ui(struct multirom_status *s, struct multirom_rom **to_boot)
 | 
			
		||||
    return exit_ui_code;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void multirom_ui_init_theme(void)
 | 
			
		||||
void multirom_ui_init_theme(int tab)
 | 
			
		||||
{
 | 
			
		||||
    memset(themes_info->data, 0, sizeof(multirom_theme_data));
 | 
			
		||||
    themes_info->data->selected_tab = -1;
 | 
			
		||||
 | 
			
		||||
    multirom_ui_init_header();
 | 
			
		||||
    multirom_ui_switch(TAB_INTERNAL);
 | 
			
		||||
    multirom_ui_switch(tab);
 | 
			
		||||
    fb_set_background(C_BACKGROUND);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -51,7 +51,7 @@ void multirom_ui_fill_rom_list(listview *view, int mask);
 | 
			
		||||
void multirom_ui_auto_boot(void);
 | 
			
		||||
void multirom_ui_refresh_usb_handler(void);
 | 
			
		||||
void multirom_ui_start_pong(int action);
 | 
			
		||||
void multirom_ui_init_theme(void);
 | 
			
		||||
void multirom_ui_init_theme(int tab);
 | 
			
		||||
void multirom_ui_destroy_theme(void);
 | 
			
		||||
 | 
			
		||||
void *multirom_ui_tab_rom_init(int tab_type);
 | 
			
		||||
 
 | 
			
		||||
@@ -84,6 +84,7 @@ static const struct multirom_color_theme color_themes[] = {
 | 
			
		||||
        .ncard_shadow = 0xFFBEBEBE,
 | 
			
		||||
        .rom_highlight = 0xFFFFFFFF,
 | 
			
		||||
        .rom_highlight_shadow = 0xFFBEBEBE,
 | 
			
		||||
        .keyaction_frame = 0xFF0000FF,
 | 
			
		||||
    },
 | 
			
		||||
    // 1 - blue/white
 | 
			
		||||
    {
 | 
			
		||||
@@ -99,6 +100,7 @@ static const struct multirom_color_theme color_themes[] = {
 | 
			
		||||
        .ncard_shadow = 0xFFBEBEBE,
 | 
			
		||||
        .rom_highlight = 0xFFFFFFFF,
 | 
			
		||||
        .rom_highlight_shadow = 0xFFBEBEBE,
 | 
			
		||||
        .keyaction_frame = 0xFFFF0000,
 | 
			
		||||
    },
 | 
			
		||||
    // 2 - green/white
 | 
			
		||||
    {
 | 
			
		||||
@@ -114,6 +116,7 @@ static const struct multirom_color_theme color_themes[] = {
 | 
			
		||||
        .ncard_shadow = 0xFFBEBEBE,
 | 
			
		||||
        .rom_highlight = 0xFFFFFFFF,
 | 
			
		||||
        .rom_highlight_shadow = 0xFFBEBEBE,
 | 
			
		||||
        .keyaction_frame = 0xFFFF0000,
 | 
			
		||||
    },
 | 
			
		||||
    // 3 - dark blue
 | 
			
		||||
    {
 | 
			
		||||
@@ -129,6 +132,7 @@ static const struct multirom_color_theme color_themes[] = {
 | 
			
		||||
        .ncard_shadow = 0xFFBEBEBE,
 | 
			
		||||
        .rom_highlight = 0xFF607D8B,
 | 
			
		||||
        .rom_highlight_shadow = 0xFFBEBEBE,
 | 
			
		||||
        .keyaction_frame = 0xFFFF0000,
 | 
			
		||||
    },
 | 
			
		||||
    // 4 - dark blue/black
 | 
			
		||||
    {
 | 
			
		||||
@@ -144,6 +148,7 @@ static const struct multirom_color_theme color_themes[] = {
 | 
			
		||||
        .ncard_shadow = 0xFF607D8B,
 | 
			
		||||
        .rom_highlight = 0xFF263238,
 | 
			
		||||
        .rom_highlight_shadow = 0xFF607D8B,
 | 
			
		||||
        .keyaction_frame = 0xFFFF0000,
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -95,6 +95,7 @@ struct multirom_color_theme
 | 
			
		||||
    uint32_t ncard_shadow;
 | 
			
		||||
    uint32_t rom_highlight;
 | 
			
		||||
    uint32_t rom_highlight_shadow;
 | 
			
		||||
    uint32_t keyaction_frame;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern const struct multirom_color_theme *color_theme;
 | 
			
		||||
@@ -110,6 +111,7 @@ extern const struct multirom_color_theme *color_theme;
 | 
			
		||||
#define C_NCARD_SHADOW (color_theme->ncard_shadow)
 | 
			
		||||
#define C_ROM_HIGHLIGHT (color_theme->rom_highlight)
 | 
			
		||||
#define C_ROM_HIGHLIGHT_SHADOW (color_theme->rom_highlight_shadow)
 | 
			
		||||
#define C_KEYACT_FRAME (color_theme->keyaction_frame)
 | 
			
		||||
 | 
			
		||||
void multirom_ui_select_color(size_t color_theme_idx);
 | 
			
		||||
const struct multirom_color_theme *multirom_ui_get_color_theme(size_t color_theme_idx);
 | 
			
		||||
 
 | 
			
		||||
@@ -77,7 +77,7 @@ static void init_header(multirom_theme_data *t)
 | 
			
		||||
    for(i = 0; i < TAB_COUNT; ++i)
 | 
			
		||||
    {
 | 
			
		||||
        fb_text_proto *p = fb_text_create(0, 0, C_HIGHLIGHT_TEXT, SIZE_BIG, str[i]);
 | 
			
		||||
        p->level = 101;
 | 
			
		||||
        p->level = 110;
 | 
			
		||||
        tab_texts[i] = fb_text_finalize(p);
 | 
			
		||||
        maxW = imax(maxW, tab_texts[i]->w);
 | 
			
		||||
    }
 | 
			
		||||
@@ -86,7 +86,7 @@ static void init_header(multirom_theme_data *t)
 | 
			
		||||
    x = fb_width/2 - (maxW*TAB_COUNT)/2;
 | 
			
		||||
 | 
			
		||||
    snprintf(buff, sizeof(buff), ":/miri_%dx%d.png", (int)MIRI_W, (int)MIRI_W);
 | 
			
		||||
    fb_img *logo = fb_add_png_img_lvl(101, x/2 - MIRI_W/2, HEADER_HEIGHT/2 - MIRI_W/2, MIRI_W, MIRI_W, buff);
 | 
			
		||||
    fb_img *logo = fb_add_png_img_lvl(110, x/2 - MIRI_W/2, HEADER_HEIGHT/2 - MIRI_W/2, MIRI_W, MIRI_W, buff);
 | 
			
		||||
    if(logo)
 | 
			
		||||
    {
 | 
			
		||||
        pong_btn = mzalloc(sizeof(button));
 | 
			
		||||
@@ -102,15 +102,15 @@ static void init_header(multirom_theme_data *t)
 | 
			
		||||
    {
 | 
			
		||||
        center_text(tab_texts[i], x, 0, maxW, HEADER_HEIGHT);
 | 
			
		||||
 | 
			
		||||
        tab_btns[i] = malloc(sizeof(button));
 | 
			
		||||
        memset(tab_btns[i], 0, sizeof(button));
 | 
			
		||||
        tab_btns[i] = mzalloc(sizeof(button));
 | 
			
		||||
        tab_btns[i]->x = x;
 | 
			
		||||
        tab_btns[i]->y = 0;
 | 
			
		||||
        tab_btns[i]->w = maxW;
 | 
			
		||||
        tab_btns[i]->h = HEADER_HEIGHT;
 | 
			
		||||
        tab_btns[i]->action = i;
 | 
			
		||||
        tab_btns[i]->clicked = &multirom_ui_switch;
 | 
			
		||||
        button_init_ui(tab_btns[i], NULL, 0);
 | 
			
		||||
        tab_btns[i]->level_off = 100;
 | 
			
		||||
        button_init_ui(tab_btns[i], "", 0);
 | 
			
		||||
 | 
			
		||||
        keyaction_add(tab_btns[i]->x, tab_btns[i]->y, button_keyaction_call, tab_btns[i]);
 | 
			
		||||
 | 
			
		||||
@@ -125,7 +125,7 @@ static void header_select(multirom_theme_data *t, int tab)
 | 
			
		||||
 | 
			
		||||
    int dest_x = t->tab_btns[tab]->x;
 | 
			
		||||
    if(!t->selected_tab_rect)
 | 
			
		||||
        t->selected_tab_rect = fb_add_rect_lvl(101, dest_x, HEADER_HEIGHT-SELECTED_RECT_H, TAB_BTN_WIDTH, SELECTED_RECT_H, C_HIGHLIGHT_TEXT);
 | 
			
		||||
        t->selected_tab_rect = fb_add_rect_lvl(110, dest_x, HEADER_HEIGHT-SELECTED_RECT_H, TAB_BTN_WIDTH, SELECTED_RECT_H, C_HIGHLIGHT_TEXT);
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        anim_cancel_for(t->selected_tab_rect, 0);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user