int elem_rel_to_abs(int type, int idx) { int nxt = -1; for(int i = 0; i < idx+1; i++) nxt = MAINPAGE_FindNextElem(type, nxt+1); return nxt; }
int elem_get_count(int type) { int nxt = -1; for (int i = 0; i < NUM_ELEMS; i++) { nxt = MAINPAGE_FindNextElem(type, nxt+1); if (nxt == -1) return i; } return 0; }
static int row_cb(int absrow, int relrow, int y, void *data) { int num_elems = (long)data; int y_ts = y; //show elements in order int row = -1; #if HAS_LAYOUT_EDITOR if (absrow == num_elems + NUM_QUICKPAGES) { GUI_CreateTextSelectPlate(&gui->value[relrow], NEWTEXTSEL_X, y_ts, NEWTEXTSEL_W, LINE_HEIGHT, &TEXTSEL_FONT, NULL, newelem_cb, NULL); GUI_CreateButtonPlateText(&gui->col1[relrow].button, NEWBUTTON_X, y, NEWBUTTON_W, LINE_HEIGHT, &BUTTON_FONT, add_dlgbut_str_cb, newelem_press_cb, (void *)1); return 2; } #endif if (absrow >= num_elems + NUM_QUICKPAGES) { GUI_CreateButtonPlateText(&gui->col1[relrow].button, QPBUTTON_X, y, QPBUTTON_W, LINE_HEIGHT, &BUTTON_FONT, add_dlgbut_str_cb, add_dlgbut_cb, (void *)0); return 1; } if (absrow >= num_elems && absrow < num_elems + NUM_QUICKPAGES) { GUI_CreateLabelBox(&gui->col1[relrow].label, MENULABEL_X, y, MENULABEL_W, LINE_HEIGHT, &LABEL_FONT, menulabel_cb, NULL, (void *)(long)(absrow - num_elems)); GUI_CreateTextSelectPlate(&gui->value[relrow], MENUTEXT_X, y + LINE_HEIGHT * LINE_OFFSET, MENUTEXT_W, LINE_HEIGHT, &TEXTSEL_FONT, NULL, menusel_cb, (void *)(long)(absrow - num_elems)); return 1; } for(int type = 0; type < ELEM_LAST; type++) { if (type == ELEM_BIGBOX || type == ELEM_HTRIM) continue; long nxt = -1; long item = -1; while((nxt = MAINPAGE_FindNextElem(type, nxt+1)) >= 0) { item = nxt; row++; if(row == absrow) break; } if (nxt == -1) continue; int selectable = 1; if (type == ELEM_TOGGLE) { GUI_CreateButtonPlateText(&gui->col1[relrow].button, ELEMBUT_X, y, ELEMBUT_W, LINE_HEIGHT, &BUTTON_FONT, cfglabel_cb, switchicon_press_cb, (void *)item); selectable = 2; } else GUI_CreateLabelBox(&gui->col1[relrow].label, ELEMLBL_X, y, ELEMLBL_W, LINE_HEIGHT, &LABEL_FONT, cfglabel_cb, NULL, (void *)item); GUI_CreateTextSelectPlate(&gui->value[relrow], ELEMTXT_X, y_ts, ELEMTXT_W, LINE_HEIGHT, &TEXTSEL_FONT, (void(*)(guiObject_t *, void *))dlgbut_cb, dlgts1_cb, (void *)item); return selectable; } return 0; }
int elem_abs_to_rel(int idx) { unsigned type = ELEM_TYPE(pc.elem[idx]); int nxt = -1; for (int i = 0; i < NUM_ELEMS-1; i++) { nxt = MAINPAGE_FindNextElem(type, nxt+1); if (nxt == idx) return i; } return 0; }
static void dlgbut_cb(struct guiObject *obj, const void *data) { (void)obj; int idx = (long)data; int i; //Remove object int type = ELEM_TYPE(pc.elem[idx]); for(i = idx+1; i < NUM_ELEMS; i++) { if (! ELEM_USED(pc.elem[i])) break; pc.elem[i-1] = pc.elem[i]; } ELEM_SET_Y(pc.elem[i-1], 0); idx = MAINPAGE_FindNextElem(type, 0); set_selected_for_move(idx); //close the dialog and reopen with new elements show_config(); }