Index: shape_dialog.c =================================================================== --- shape_dialog.c (revision 16651) +++ shape_dialog.c (revision 16652) @@ -8,8 +8,6 @@ pcb_any_obj_t *obj; /* tab management */ - int but_regpoly, but_roundrect, but_circle; - int tab_regpoly, tab_roundrect, tab_circle; int tab; /* regpoly */ @@ -26,47 +24,6 @@ /* Last open non-modal shape dialog */ static ctx_t *shape_active = NULL; -static void shp_tab_update(void *hid_ctx, ctx_t *shp) -{ - int but, tab; - pcb_gui->attr_dlg_widget_hide(hid_ctx, shp->tab_regpoly, pcb_true); - pcb_gui->attr_dlg_widget_hide(hid_ctx, shp->tab_roundrect, pcb_true); - pcb_gui->attr_dlg_widget_hide(hid_ctx, shp->tab_circle, pcb_true); - pcb_gui->attr_dlg_widget_state(hid_ctx, shp->but_regpoly, pcb_true); - pcb_gui->attr_dlg_widget_state(hid_ctx, shp->but_roundrect, pcb_true); - pcb_gui->attr_dlg_widget_state(hid_ctx, shp->but_circle, pcb_true); - - switch(shp->tab) { - case 0: but = shp->but_regpoly; tab = shp->tab_regpoly; break; - case 1: but = shp->but_roundrect; tab = shp->tab_roundrect; break; - case 2: but = shp->but_circle; tab = shp->tab_circle; break; - } - - pcb_gui->attr_dlg_widget_hide(hid_ctx, tab, pcb_false); - pcb_gui->attr_dlg_widget_state(hid_ctx, but, pcb_false); -} - -static void shp_tab0(void *hid_ctx, void *caller_data, pcb_hid_attribute_t *attr) -{ - ctx_t *shp = caller_data; - shp->tab = 0; - shp_tab_update(hid_ctx, shp); -} - -static void shp_tab1(void *hid_ctx, void *caller_data, pcb_hid_attribute_t *attr) -{ - ctx_t *shp = caller_data; - shp->tab = 1; - shp_tab_update(hid_ctx, shp); -} - -static void shp_tab2(void *hid_ctx, void *caller_data, pcb_hid_attribute_t *attr) -{ - ctx_t *shp = caller_data; - shp->tab = 2; - shp_tab_update(hid_ctx, shp); -} - static void shp_close_cb(void *caller_data, pcb_hid_attr_ev_t ev) { ctx_t *shp = caller_data; @@ -155,12 +112,14 @@ static void shape_layer_chg(void *user_data, int argc, pcb_event_arg_t argv[]) { void *hid_ctx; + int tab; if (shape_active == NULL) return; hid_ctx = shape_active->dlg_hid_ctx; - switch(shape_active->tab) { + tab = shape_active->dlg[shape_active->tab].default_val.int_value; + switch(tab) { case 0: shp_chg_regpoly(hid_ctx, shape_active, NULL); break; case 1: shp_chg_roundrect(hid_ctx, shape_active, NULL); break; case 2: shp_chg_circle(hid_ctx, shape_active, NULL); break; @@ -173,27 +132,18 @@ ctx_t *shp = calloc(sizeof(ctx_t), 1); pcb_coord_t mm2 = PCB_MM_TO_COORD(2); pcb_coord_t maxr = PCB_MM_TO_COORD(1000); + const char *tabs[] = {"Regular polygon", "Round rectangle", "Filled circle", NULL}; + shp->pcb = pcb; shp->data = data; shp->layer = layer; - PCB_DAD_BEGIN_VBOX(shp->dlg); - /* tabs */ - PCB_DAD_BEGIN_HBOX(shp->dlg); - PCB_DAD_BUTTON(shp->dlg, "Regular polygon"); - shp->but_regpoly = PCB_DAD_CURRENT(shp->dlg); - PCB_DAD_CHANGE_CB(shp->dlg, shp_tab0); - PCB_DAD_BUTTON(shp->dlg, "Round rectangle"); - shp->but_roundrect = PCB_DAD_CURRENT(shp->dlg); - PCB_DAD_CHANGE_CB(shp->dlg, shp_tab1); - PCB_DAD_BUTTON(shp->dlg, "Filled circle"); - shp->but_circle = PCB_DAD_CURRENT(shp->dlg); - PCB_DAD_CHANGE_CB(shp->dlg, shp_tab2); - PCB_DAD_END(shp->dlg); + PCB_DAD_BEGIN_TABBED(shp->dlg, tabs); +/* shp->tab = PCB_DAD_CURRENT(shp->dlg); + PCB_DAD_CHANGE_CB(shp->dlg, shp_tab);*/ /* regpoly tab */ PCB_DAD_BEGIN_VBOX(shp->dlg); - shp->tab_regpoly = PCB_DAD_CURRENT(shp->dlg); PCB_DAD_LABEL(shp->dlg, "Generate regular polygon"); PCB_DAD_BEGIN_TABLE(shp->dlg, 2); PCB_DAD_LABEL(shp->dlg, "Number of corners"); @@ -267,7 +217,6 @@ /* roundrect tab */ PCB_DAD_BEGIN_VBOX(shp->dlg); - shp->tab_roundrect = PCB_DAD_CURRENT(shp->dlg); PCB_DAD_LABEL(shp->dlg, "Generate rectange with rounded corners"); PCB_DAD_BEGIN_TABLE(shp->dlg, 2); @@ -359,7 +308,6 @@ /* circle tab */ PCB_DAD_BEGIN_VBOX(shp->dlg); - shp->tab_circle = PCB_DAD_CURRENT(shp->dlg); PCB_DAD_LABEL(shp->dlg, "Generate filled circle"); PCB_DAD_BEGIN_HBOX(shp->dlg); PCB_DAD_LABEL(shp->dlg, "Diameter:"); @@ -391,7 +339,6 @@ PCB_DAD_END(shp->dlg); PCB_DAD_NEW(shp->dlg, "dlg_shape", "Generate shapes", shp, modal, shp_close_cb); - shp_tab_update(shp->dlg_hid_ctx, shp); shp_chg_circle(shp->dlg_hid_ctx, shp, NULL); shp_chg_roundrect(shp->dlg_hid_ctx, shp, NULL); shp_chg_regpoly(shp->dlg_hid_ctx, shp, NULL); /* has to be the last */