예제 #1
0
static void tab_misc_init(multirom_theme_data *t, tab_data_misc *d, int color_scheme)
{
    int i;
    int x = fb_width/2 - (MISCBTN_W + 30*DPI_MUL);
    int y = HEADER_HEIGHT + ((fb_height - HEADER_HEIGHT)/2 - 2*(MISCBTN_H + 30*DPI_MUL));
    fb_rect *shadow;

    y += MISCBTN_H + 30*DPI_MUL;

    button *b = mzalloc(sizeof(button));
    b->x = x;
    b->y = y;
    b->w = MISCBTN_W;
    b->h = MISCBTN_H;
    b->clicked = &multirom_ui_tab_misc_copy_log;
    shadow = fb_add_rect_lvl(LEVEL_RECT, b->x + BTN_SHADOW_OFF, b->y + BTN_SHADOW_OFF, b->w, b->h, C_BTN_FAKE_SHADOW);
    button_init_ui(b, "COPY LOG TO /SDCARD", SIZE_NORMAL);
    list_add(&d->buttons, b);
    list_add(&d->ui_elements, shadow);
    tabview_add_item(t->tabs, TAB_MISC, b->text);
    tabview_add_item(t->tabs, TAB_MISC, b->rect);
    tabview_add_item(t->tabs, TAB_MISC, b);

    const int max_colors = colors_count();
    x += (MISCBTN_W/2 - (max_colors*(CLRBTN_TOTAL+CLRBTN_MARGIN))/2);
    y += MISCBTN_H+30*DPI_MUL + (MISCBTN_H/2 - CLRBTN_TOTAL/2);
    fb_rect *r;
    for(i = 0; i < max_colors; ++i)
    {
        const struct mrom_color_theme *th = colors_get(i);

        r = fb_add_rect(x, y, CLRBTN_TOTAL, CLRBTN_TOTAL, i == color_scheme ? 0xFFFFCC00 : WHITE);
        list_add(&d->ui_elements, r);

        r = fb_add_rect(x+CLRBTN_B/2, y+CLRBTN_B/2, CLRBTN_W, CLRBTN_W, th->highlight_bg);
        list_add(&d->ui_elements, r);

        b = mzalloc(sizeof(button));
        b->x = x;
        b->y = y;
        b->w = CLRBTN_TOTAL;
        b->h = CLRBTN_TOTAL;
        b->clicked_data = malloc(sizeof(int));
        *((int*)b->clicked_data) = i;
        b->clicked = &multirom_ui_tab_misc_change_clr;
        button_init_ui(b, NULL, 0);
        list_add(&d->buttons, b);
        tabview_add_item(t->tabs, TAB_MISC, b);

        x += CLRBTN_TOTAL + CLRBTN_MARGIN;
    }

    x = fb_width/2 - (MISCBTN_W + 30*DPI_MUL) + MISCBTN_W + 30*DPI_MUL;
    y = HEADER_HEIGHT + ((fb_height - HEADER_HEIGHT)/2 - 2*(MISCBTN_H + 30*DPI_MUL));

    static const char *texts[] =
    {
        "REBOOT",               // 0
        "REBOOT TO RECOVERY",   // 1
        "REBOOT TO BOOTLOADER", // 2
        "SHUTDOWN",             // 3
        NULL
    };

    static const int exit_codes[] = {
        UI_EXIT_REBOOT, UI_EXIT_REBOOT_RECOVERY,
        UI_EXIT_REBOOT_BOOTLOADER, UI_EXIT_SHUTDOWN
    };

    for(i = 0; texts[i]; ++i)
    {
        b = mzalloc(sizeof(button));
        b->x = x;
        b->y = y;
        b->w = MISCBTN_W;
        b->h = MISCBTN_H;
        b->clicked_data = malloc(sizeof(int));
        *((int*)b->clicked_data) = exit_codes[i];
        b->clicked = &multirom_ui_reboot_btn;
        shadow = fb_add_rect_lvl(LEVEL_RECT, b->x + BTN_SHADOW_OFF, b->y + BTN_SHADOW_OFF, b->w, b->h, C_BTN_FAKE_SHADOW);
        button_init_ui(b, texts[i], SIZE_NORMAL);
        list_add(&d->buttons, b);
        list_add(&d->ui_elements, shadow);
        tabview_add_item(t->tabs, TAB_MISC, b->text);
        tabview_add_item(t->tabs, TAB_MISC, b->rect);
        tabview_add_item(t->tabs, TAB_MISC, b);

        y += MISCBTN_H+30*DPI_MUL;
    }

    fb_text *text = fb_add_text(5*DPI_MUL, 0, C_TEXT_SECONDARY, SIZE_SMALL, "MultiROM v%d"VERSION_DEV_FIX" with trampoline v%d.",
                               VERSION_MULTIROM, multirom_get_trampoline_ver());
    text->y = fb_height - text->h;
    list_add(&d->ui_elements, text);

    text = fb_add_text(0, 0, C_TEXT_SECONDARY, SIZE_SMALL, "Battery: %d%%", multirom_get_battery());
    text->x = fb_width - text->w - 5*DPI_MUL;
    text->y = fb_height - text->h;
    list_add(&d->ui_elements, text);

    for(i = 0; d->buttons[i]; ++i)
        keyaction_add(d->buttons[i], button_keyaction_call, d->buttons[i]);

    tabview_add_items(t->tabs, TAB_MISC, d->ui_elements);
}
예제 #2
0
static void tab_misc_init(multirom_theme_data *t, tab_data_misc *d, int color_scheme)
{
    int x = fb_width/2 - MISCBTN_W/2;
    int y = 270*DPI_MUL;

    button *b = mzalloc(sizeof(button));
    b->x = x;
    b->y = y;
    b->w = MISCBTN_W;
    b->h = MISCBTN_H;
    b->clicked = &multirom_ui_tab_misc_copy_log;
    button_init_ui(b, "Copy log to /sdcard", SIZE_BIG);
    list_add(&d->buttons, b);
    tabview_add_item(t->tabs, TAB_MISC, b->text);
    tabview_add_item(t->tabs, TAB_MISC, b->rect);
    tabview_add_item(t->tabs, TAB_MISC, b);

    y += MISCBTN_H+70*DPI_MUL;

    static const char *texts[] =
    {
        "Reboot",               // 0
        "Reboot to recovery",   // 1
        "Reboot to bootloader", // 2
        "Shutdown",             // 3
        NULL
    };

    static const int exit_codes[] = {
        UI_EXIT_REBOOT, UI_EXIT_REBOOT_RECOVERY,
        UI_EXIT_REBOOT_BOOTLOADER, UI_EXIT_SHUTDOWN
    };

    int i;
    for(i = 0; texts[i]; ++i)
    {
        b = mzalloc(sizeof(button));
        b->x = x;
        b->y = y;
        b->w = MISCBTN_W;
        b->h = MISCBTN_H;
        b->action = exit_codes[i];
        b->clicked = &multirom_ui_reboot_btn;
        button_init_ui(b, texts[i], SIZE_BIG);
        list_add(&d->buttons, b);
        tabview_add_item(t->tabs, TAB_MISC, b->text);
        tabview_add_item(t->tabs, TAB_MISC, b->rect);
        tabview_add_item(t->tabs, TAB_MISC, b);

        y += MISCBTN_H+20*DPI_MUL;
        if(i == 2)
            y += 50*DPI_MUL;
    }

    fb_text *text = fb_add_text(5*DPI_MUL, 0, C_TEXT_SECONDARY, SIZE_SMALL, "MultiROM v%d"VERSION_DEV_FIX" with trampoline v%d.",
                               VERSION_MULTIROM, multirom_get_trampoline_ver());
    text->y = fb_height - text->h;
    list_add(&d->ui_elements, text);

    text = fb_add_text(0, 0, C_TEXT_SECONDARY, SIZE_SMALL, "Battery: %d%%", multirom_get_battery());
    text->x = fb_width - text->w - 5*DPI_MUL;
    text->y = fb_height - text->h;
    list_add(&d->ui_elements, text);

    const int max_colors = multirom_ui_get_color_theme_count();
    x = fb_width/2 - (max_colors*(CLRBTN_TOTAL+CLRBTN_MARGIN))/2;
    fb_rect *r;
    for(i = 0; i < max_colors; ++i)
    {
        const struct multirom_color_theme *th = multirom_ui_get_color_theme(i);

        r = fb_add_rect(x, CLRBTN_Y, CLRBTN_TOTAL, CLRBTN_TOTAL, i == color_scheme ? 0xFFFFCC00 : WHITE);
        list_add(&d->ui_elements, r);

        r = fb_add_rect(x+CLRBTN_B/2, CLRBTN_Y+CLRBTN_B/2, CLRBTN_W, CLRBTN_W, th->highlight_bg);
        list_add(&d->ui_elements, r);

        b = mzalloc(sizeof(button));
        b->x = x;
        b->y = CLRBTN_Y;
        b->w = CLRBTN_TOTAL;
        b->h = CLRBTN_TOTAL;
        b->action = i;
        b->clicked = &multirom_ui_tab_misc_change_clr;
        button_init_ui(b, NULL, 0);
        list_add(&d->buttons, b);
        tabview_add_item(t->tabs, TAB_MISC, b);

        x += CLRBTN_TOTAL + CLRBTN_MARGIN;
    }

    for(i = 0; d->buttons[i]; ++i)
        keyaction_add(d->buttons[i], button_keyaction_call, d->buttons[i]);

    tabview_add_items(t->tabs, TAB_MISC, d->ui_elements);
}