static void uiCollada_importSettings(uiLayout *layout, PointerRNA *imfptr) { uiLayout *box, *row; /* Import Options: */ box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Import Data Options:"), ICON_MESH_DATA); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "import_units", 0, NULL, ICON_NONE); box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Armature Options:"), ICON_MESH_DATA); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "fix_orientation", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "find_chains", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "min_chain_length", 0, NULL, ICON_NONE); }
static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete) { SpaceFile *sfile = CTX_wm_space_file(C); uiBlock *block; uiBut *but; uiLayout *box, *col; struct FSMenu *fsmenu = fsmenu_get(); int i, nentries = fsmenu_get_nentries(fsmenu, category); /* reset each time */ *nr = -1; /* hide if no entries */ if (nentries == 0) return; /* layout */ uiLayoutSetAlignment(pa->layout, UI_LAYOUT_ALIGN_LEFT); block = uiLayoutGetBlock(pa->layout); box = uiLayoutBox(pa->layout); col = uiLayoutColumn(box, TRUE); for (i = 0; i < nentries; ++i) { char dir[FILE_MAX]; char temp[FILE_MAX]; uiLayout *layout = uiLayoutRow(col, FALSE); char *entry; entry = fsmenu_get_entry(fsmenu, category, i); /* set this list item as active if we have a match */ if (sfile->params) { if (BLI_path_cmp(sfile->params->dir, entry) == 0) { *nr = i; } } /* create nice bookmark name, shows last directory in the full path currently */ BLI_strncpy(temp, entry, FILE_MAX); BLI_add_slash(temp); BLI_getlastdir(temp, dir, FILE_MAX); BLI_del_slash(dir); if (dir[0] == 0) BLI_strncpy(dir, entry, FILE_MAX); /* create list item */ but = uiDefIconTextButS(block, LISTROW, 0, icon, dir, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, nr, 0, i, 0, 0, entry); uiButSetFunc(but, file_panel_cb, entry, NULL); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ uiButSetFlag(but, UI_ICON_LEFT | UI_TEXT_LEFT); /* create delete button */ if (allow_delete && fsmenu_can_save(fsmenu, category, i)) { uiBlockSetEmboss(block, UI_EMBOSSN); uiItemIntO(layout, "", ICON_X, "FILE_OT_delete_bookmark", "index", i); uiBlockSetEmboss(block, UI_EMBOSS); } } }
static void ui_alembic_import_settings(uiLayout *layout, PointerRNA *imfptr) { uiLayout *box = uiLayoutBox(layout); uiLayout *row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "scale", 0, NULL, ICON_NONE); box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Options:"), ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "set_frame_range", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "is_sequence", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "validate_meshes", 0, NULL, ICON_NONE); }
void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifiers, FModifier *fcm) { FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); uiLayout *box, *row, *sub, *col; uiBlock *block; uiBut *but; short width = 314; PointerRNA ptr; /* init the RNA-pointer */ RNA_pointer_create(id, &RNA_FModifier, fcm, &ptr); /* draw header */ { /* get layout-row + UI-block for this */ box = uiLayoutBox(layout); row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(row); // err... /* left-align -------------------------------------------- */ sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); uiBlockSetEmboss(block, UI_EMBOSSN); /* expand */ uiItemR(sub, &ptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* checkbox for 'active' status (for now) */ uiItemR(sub, &ptr, "active", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* name */ if (fmi) uiItemL(sub, IFACE_(fmi->name), ICON_NONE); else uiItemL(sub, IFACE_("<Unknown Modifier>"), ICON_NONE); /* right-align ------------------------------------------- */ sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); /* 'mute' button */ uiItemR(sub, &ptr, "mute", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); uiBlockSetEmboss(block, UI_EMBOSSN); /* delete button */ but = uiDefIconBut(block, BUT, B_REDR, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete F-Curve Modifier")); uiButSetFunc(but, delete_fmodifier_cb, modifiers, fcm); uiBlockSetEmboss(block, UI_EMBOSS); } /* when modifier is expanded, draw settings */ if (fcm->flag & FMODIFIER_FLAG_EXPANDED) { /* set up the flexible-box layout which acts as the backdrop for the modifier settings */ box = uiLayoutBox(layout); /* draw settings for individual modifiers */ switch (fcm->type) { case FMODIFIER_TYPE_GENERATOR: /* Generator */ draw_modifier__generator(box, id, fcm, width); break; case FMODIFIER_TYPE_FN_GENERATOR: /* Built-In Function Generator */ draw_modifier__fn_generator(box, id, fcm, width); break; case FMODIFIER_TYPE_CYCLES: /* Cycles */ draw_modifier__cycles(box, id, fcm, width); break; case FMODIFIER_TYPE_ENVELOPE: /* Envelope */ draw_modifier__envelope(box, id, fcm, width); break; case FMODIFIER_TYPE_LIMITS: /* Limits */ draw_modifier__limits(box, id, fcm, width); break; case FMODIFIER_TYPE_NOISE: /* Noise */ draw_modifier__noise(box, id, fcm, width); break; case FMODIFIER_TYPE_STEPPED: /* Stepped */ draw_modifier__stepped(box, id, fcm, width); break; default: /* unknown type */ break; } /* one last panel below this: FModifier range */ // TODO: experiment with placement of this { box = uiLayoutBox(layout); /* restricted range ----------------------------------------------------- */ col = uiLayoutColumn(box, TRUE); /* top row: use restricted range */ row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "use_restricted_range", 0, NULL, ICON_NONE); if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) { /* second row: settings */ row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "frame_start", 0, IFACE_("Start"), ICON_NONE); uiItemR(row, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE); /* third row: blending influence */ row = uiLayoutRow(col, TRUE); uiItemR(row, &ptr, "blend_in", 0, IFACE_("In"), ICON_NONE); uiItemR(row, &ptr, "blend_out", 0, IFACE_("Out"), ICON_NONE); } /* influence -------------------------------------------------------------- */ col = uiLayoutColumn(box, TRUE); /* top row: use influence */ uiItemR(col, &ptr, "use_influence", 0, NULL, ICON_NONE); if (fcm->flag & FMODIFIER_FLAG_USEINFLUENCE) { /* second row: influence value */ uiItemR(col, &ptr, "influence", 0, NULL, ICON_NONE); } } } }
/* driver settings for active F-Curve (only for 'Drivers' mode) */ static void graph_panel_drivers(const bContext *C, Panel *pa) { bAnimListElem *ale; FCurve *fcu; ChannelDriver *driver; DriverVar *dvar; PointerRNA driver_ptr; uiLayout *col; uiBlock *block; uiBut *but; /* Get settings from context */ if (!graph_panel_context(C, &ale, &fcu)) return; driver = fcu->driver; /* set event handler for panel */ block = uiLayoutGetBlock(pa->layout); // xxx? uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL); /* general actions - management */ col = uiLayoutColumn(pa->layout, FALSE); block = uiLayoutGetBlock(col); but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10 * UI_UNIT_X, 22, NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies")); uiButSetFunc(but, driver_update_flags_cb, fcu, NULL); but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Remove Driver"), 0, 0, 10 * UI_UNIT_X, 18, NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver")); uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL); /* driver-level settings - type, expressions, and errors */ RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr); col = uiLayoutColumn(pa->layout, TRUE); block = uiLayoutGetBlock(col); uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE); /* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */ if (driver->type == DRIVER_TYPE_PYTHON) { /* expression */ uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE); /* errors? */ if (driver->flag & DRIVER_FLAG_INVALID) uiItemL(col, IFACE_("ERROR: invalid Python expression"), ICON_ERROR); } else { /* errors? */ if (driver->flag & DRIVER_FLAG_INVALID) uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR); } col = uiLayoutColumn(pa->layout, TRUE); /* debug setting */ uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE); /* value of driver */ if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { uiLayout *row = uiLayoutRow(col, TRUE); char valBuf[32]; uiItemL(row, IFACE_("Driver Value:"), ICON_NONE); BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval); uiItemL(row, valBuf, ICON_NONE); } /* add driver variables */ col = uiLayoutColumn(pa->layout, FALSE); block = uiLayoutGetBlock(col); but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver")); uiButSetFunc(but, driver_add_var_cb, driver, NULL); /* loop over targets, drawing them */ for (dvar = driver->variables.first; dvar; dvar = dvar->next) { PointerRNA dvar_ptr; uiLayout *box, *row; /* sub-layout column for this variable's settings */ col = uiLayoutColumn(pa->layout, TRUE); /* header panel */ box = uiLayoutBox(col); /* first row context info for driver */ RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr); row = uiLayoutRow(box, FALSE); block = uiLayoutGetBlock(row); /* variable name */ uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE); /* remove button */ uiBlockSetEmboss(block, UI_EMBOSSN); but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable")); uiButSetFunc(but, driver_delete_var_cb, driver, dvar); uiBlockSetEmboss(block, UI_EMBOSS); /* variable type */ row = uiLayoutRow(box, FALSE); uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE); /* variable type settings */ box = uiLayoutBox(col); /* controls to draw depends on the type of variable */ switch (dvar->type) { case DVAR_TYPE_SINGLE_PROP: /* single property */ graph_panel_driverVar__singleProp(box, ale->id, dvar); break; case DVAR_TYPE_ROT_DIFF: /* rotational difference */ graph_panel_driverVar__rotDiff(box, ale->id, dvar); break; case DVAR_TYPE_LOC_DIFF: /* location difference */ graph_panel_driverVar__locDiff(box, ale->id, dvar); break; case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */ graph_panel_driverVar__transChan(box, ale->id, dvar); break; } /* value of variable */ if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { char valBuf[32]; box = uiLayoutBox(col); row = uiLayoutRow(box, TRUE); uiItemL(row, IFACE_("Value:"), ICON_NONE); BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); uiItemL(row, valBuf, ICON_NONE); } } /* cleanup */ MEM_freeN(ale); }
static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) { uiLayout *box, *row, *col, *split; /* Export Options: */ box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA); row = uiLayoutRow(box, false); split = uiLayoutSplit(row, 0.6f, UI_LAYOUT_ALIGN_RIGHT); col = uiLayoutColumn(split, false); uiItemR(col, imfptr, "apply_modifiers", 0, NULL, ICON_NONE); col = uiLayoutColumn(split, false); uiItemR(col, imfptr, "export_mesh_type_selection", 0, "", ICON_NONE); uiLayoutSetEnabled(col, RNA_boolean_get(imfptr, "apply_modifiers")); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "include_children", 0, NULL, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "include_shapekeys", 0, NULL, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); /* Texture options */ box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Texture Options:"), ICON_TEXTURE_DATA); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "active_uv_only", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "include_uv_textures", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "include_material_textures", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "use_texture_copies", 1, NULL, ICON_NONE); /* Armature options */ box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Armature Options:"), ICON_ARMATURE_DATA); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "deform_bones_only", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "open_sim", 0, NULL, ICON_NONE); /* Collada options: */ box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Collada Options:"), ICON_MODIFIER); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "triangulate", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "use_object_instantiation", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); split = uiLayoutSplit(row, 0.6f, UI_LAYOUT_ALIGN_RIGHT); uiItemL(split, IFACE_("Transformation Type"), ICON_NONE); uiItemR(split, imfptr, "export_transformation_type_selection", 0, "", ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE); }
/* draw the controls for a given layer */ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, const short is_v3d) { uiLayout *box = NULL, *split = NULL; uiLayout *col = NULL; uiLayout *row = NULL, *sub = NULL; uiBlock *block; uiBut *but; PointerRNA ptr; int icon; /* make pointer to layer data */ RNA_pointer_create((ID *)gpd, &RNA_GPencilLayer, gpl, &ptr); /* unless button has own callback, it adds this callback to button */ block = uiLayoutGetBlock(layout); uiBlockSetFunc(block, gp_ui_activelayer_cb, gpd, gpl); /* draw header ---------------------------------- */ /* get layout-row + UI-block for header */ box = uiLayoutBox(layout); row = uiLayoutRow(box, FALSE); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND); block = uiLayoutGetBlock(row); /* err... */ uiBlockSetEmboss(block, UI_EMBOSSN); /* left-align ............................... */ sub = uiLayoutRow(row, FALSE); /* active */ block = uiLayoutGetBlock(sub); icon = (gpl->flag & GP_LAYER_ACTIVE) ? ICON_RADIOBUT_ON : ICON_RADIOBUT_OFF; but = uiDefIconButBitI(block, TOG, GP_LAYER_ACTIVE, 0, icon, 0, 0, UI_UNIT_X, UI_UNIT_Y, &gpl->flag, 0.0, 0.0, 0.0, 0.0, TIP_("Set active layer")); uiButSetFunc(but, gp_ui_activelayer_cb, gpd, gpl); /* locked */ icon = (gpl->flag & GP_LAYER_LOCKED) ? ICON_LOCKED : ICON_UNLOCKED; uiItemR(sub, &ptr, "lock", 0, "", icon); /* when layer is locked or hidden, only draw header */ if (gpl->flag & (GP_LAYER_LOCKED | GP_LAYER_HIDE)) { char name[256]; /* gpl->info is 128, but we need space for 'locked/hidden' as well */ /* visibility button (only if hidden but not locked!) */ if ((gpl->flag & GP_LAYER_HIDE) && !(gpl->flag & GP_LAYER_LOCKED)) uiItemR(sub, &ptr, "hide", 0, "", ICON_RESTRICT_VIEW_ON); /* name */ if (gpl->flag & GP_LAYER_HIDE) BLI_snprintf(name, sizeof(name), IFACE_("%s (Hidden)"), gpl->info); else BLI_snprintf(name, sizeof(name), IFACE_("%s (Locked)"), gpl->info); uiItemL(sub, name, ICON_NONE); /* delete button (only if hidden but not locked!) */ if ((gpl->flag & GP_LAYER_HIDE) && !(gpl->flag & GP_LAYER_LOCKED)) { /* right-align ............................... */ sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); block = uiLayoutGetBlock(sub); /* XXX... err... */ but = uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete layer")); uiButSetFunc(but, gp_ui_dellayer_cb, gpd, gpl); } uiBlockSetEmboss(block, UI_EMBOSS); } else { /* draw rest of header -------------------------------- */ /* visibility button */ uiItemR(sub, &ptr, "hide", 0, "", ICON_RESTRICT_VIEW_OFF); /* frame locking */ /* TODO: this needs its own icons... */ icon = (gpl->flag & GP_LAYER_FRAMELOCK) ? ICON_RENDER_STILL : ICON_RENDER_ANIMATION; uiItemR(sub, &ptr, "lock_frame", 0, "", icon); uiBlockSetEmboss(block, UI_EMBOSS); /* name */ uiItemR(sub, &ptr, "info", 0, "", ICON_NONE); /* move up/down */ uiBlockBeginAlign(block); if (gpl->prev) { but = uiDefIconBut(block, BUT, 0, ICON_TRIA_UP, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Move layer up")); uiButSetFunc(but, gp_ui_layer_up_cb, gpd, gpl); } if (gpl->next) { but = uiDefIconBut(block, BUT, 0, ICON_TRIA_DOWN, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Move layer down")); uiButSetFunc(but, gp_ui_layer_down_cb, gpd, gpl); } uiBlockEndAlign(block); /* delete 'button' */ uiBlockSetEmboss(block, UI_EMBOSSN); /* right-align ............................... */ sub = uiLayoutRow(row, TRUE); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); block = uiLayoutGetBlock(sub); /* XXX... err... */ but = uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete layer")); uiButSetFunc(but, gp_ui_dellayer_cb, gpd, gpl); uiBlockSetEmboss(block, UI_EMBOSS); /* new backdrop ----------------------------------- */ box = uiLayoutBox(layout); split = uiLayoutSplit(box, 0.5f, FALSE); /* draw settings ---------------------------------- */ /* left column ..................... */ col = uiLayoutColumn(split, FALSE); /* color */ sub = uiLayoutColumn(col, TRUE); uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); uiItemR(sub, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE); /* stroke thickness */ uiItemR(col, &ptr, "line_width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); /* debugging options */ if (G.debug & G_DEBUG) { uiItemR(col, &ptr, "show_points", 0, NULL, ICON_NONE); } /* right column ................... */ col = uiLayoutColumn(split, FALSE); /* onion-skinning */ sub = uiLayoutColumn(col, TRUE); uiItemR(sub, &ptr, "use_onion_skinning", 0, NULL, ICON_NONE); uiItemR(sub, &ptr, "ghost_range_max", 0, IFACE_("Frames"), ICON_NONE); /* 3d-view specific drawing options */ if (is_v3d) { uiItemR(col, &ptr, "show_x_ray", 0, NULL, ICON_NONE); } } }
/* driver settings for active F-Curve (only for 'Drivers' mode) */ static void graph_panel_drivers(const bContext *C, Panel *pa) { bAnimListElem *ale; FCurve *fcu; ChannelDriver *driver; DriverVar *dvar; PointerRNA driver_ptr; uiLayout *col; uiBlock *block; uiBut *but; /* Get settings from context */ if (!graph_panel_context(C, &ale, &fcu)) return; driver = fcu->driver; /* set event handler for panel */ block = uiLayoutGetBlock(pa->layout); // xxx? uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL); /* general actions - management */ col = uiLayoutColumn(pa->layout, false); block = uiLayoutGetBlock(col); but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_FILE_REFRESH, IFACE_("Update Dependencies"), 0, 0, 10 * UI_UNIT_X, 22, NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies")); uiButSetFunc(but, driver_update_flags_cb, fcu, NULL); but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_ZOOMOUT, IFACE_("Remove Driver"), 0, 0, 10 * UI_UNIT_X, 18, NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver")); uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL); /* driver-level settings - type, expressions, and errors */ RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr); col = uiLayoutColumn(pa->layout, true); block = uiLayoutGetBlock(col); uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE); /* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */ if (driver->type == DRIVER_TYPE_PYTHON) { bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != NULL); bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != NULL); /* expression */ uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE); /* errors? */ if ((G.f & G_SCRIPT_AUTOEXEC) == 0) { uiItemL(col, IFACE_("ERROR: Python auto-execution disabled"), ICON_CANCEL); } else if (driver->flag & DRIVER_FLAG_INVALID) { uiItemL(col, IFACE_("ERROR: Invalid Python expression"), ICON_CANCEL); } /* Explicit bpy-references are evil. Warn about these to prevent errors */ /* TODO: put these in a box? */ if (bpy_data_expr_error || bpy_ctx_expr_error) { uiItemL(col, IFACE_("WARNING: Driver expression may not work correctly"), ICON_HELP); if (bpy_data_expr_error) { uiItemL(col, IFACE_("TIP: Use variables instead of bpy.data paths (see below)"), ICON_ERROR); } if (bpy_ctx_expr_error) { uiItemL(col, IFACE_("TIP: bpy.context is not safe for renderfarm usage"), ICON_ERROR); } } } else { /* errors? */ if (driver->flag & DRIVER_FLAG_INVALID) uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR); /* Warnings about a lack of variables * NOTE: The lack of variables is generally a bad thing, since it indicates * that the driver doesn't work at all. This particular scenario arises * primarily when users mistakenly try to use drivers for procedural * property animation */ if (BLI_listbase_is_empty(&driver->variables)) { uiItemL(col, IFACE_("ERROR: Driver is useless without any inputs"), ICON_ERROR); if (!BLI_listbase_is_empty(&fcu->modifiers)) { uiItemL(col, IFACE_("TIP: Use F-Curves for procedural animation instead"), ICON_INFO); uiItemL(col, IFACE_("F-Modifiers can generate curves for those too"), ICON_INFO); } } } col = uiLayoutColumn(pa->layout, true); /* debug setting */ uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE); /* value of driver */ if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { uiLayout *row = uiLayoutRow(col, true); char valBuf[32]; uiItemL(row, IFACE_("Driver Value:"), ICON_NONE); BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval); uiItemL(row, valBuf, ICON_NONE); } /* add driver variables */ col = uiLayoutColumn(pa->layout, false); block = uiLayoutGetBlock(col); but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_ZOOMIN, IFACE_("Add Variable"), 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, TIP_("Driver variables ensure that all dependencies will be accounted for and that drivers will update correctly")); uiButSetFunc(but, driver_add_var_cb, driver, NULL); /* loop over targets, drawing them */ for (dvar = driver->variables.first; dvar; dvar = dvar->next) { PointerRNA dvar_ptr; uiLayout *box, *row; /* sub-layout column for this variable's settings */ col = uiLayoutColumn(pa->layout, true); /* header panel */ box = uiLayoutBox(col); /* first row context info for driver */ RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr); row = uiLayoutRow(box, false); block = uiLayoutGetBlock(row); /* variable name */ uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE); /* remove button */ uiBlockSetEmboss(block, UI_EMBOSSN); but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable")); uiButSetFunc(but, driver_delete_var_cb, driver, dvar); uiBlockSetEmboss(block, UI_EMBOSS); /* variable type */ row = uiLayoutRow(box, false); uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE); /* variable type settings */ box = uiLayoutBox(col); /* controls to draw depends on the type of variable */ switch (dvar->type) { case DVAR_TYPE_SINGLE_PROP: /* single property */ graph_panel_driverVar__singleProp(box, ale->id, dvar); break; case DVAR_TYPE_ROT_DIFF: /* rotational difference */ graph_panel_driverVar__rotDiff(box, ale->id, dvar); break; case DVAR_TYPE_LOC_DIFF: /* location difference */ graph_panel_driverVar__locDiff(box, ale->id, dvar); break; case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */ graph_panel_driverVar__transChan(box, ale->id, dvar); break; } /* value of variable */ if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { char valBuf[32]; box = uiLayoutBox(col); row = uiLayoutRow(box, true); uiItemL(row, IFACE_("Value:"), ICON_NONE); if ((dvar->type == DVAR_TYPE_ROT_DIFF) || (dvar->type == DVAR_TYPE_TRANSFORM_CHAN && dvar->targets[0].transChan >= DTAR_TRANSCHAN_ROTX && dvar->targets[0].transChan < DTAR_TRANSCHAN_SCALEX)) { BLI_snprintf(valBuf, sizeof(valBuf), "%.3f (%4.1f°)", dvar->curval, RAD2DEGF(dvar->curval)); } else { BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); } uiItemL(row, valBuf, ICON_NONE); } } /* cleanup */ MEM_freeN(ale); }
static int wm_alembic_export_exec(bContext *C, wmOperator *op) { if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; } char filename[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filename); struct AlembicExportParams params = { .frame_start = RNA_int_get(op->ptr, "start"), .frame_end = RNA_int_get(op->ptr, "end"), .frame_samples_xform = RNA_int_get(op->ptr, "xsamples"), .frame_samples_shape = RNA_int_get(op->ptr, "gsamples"), .shutter_open = RNA_float_get(op->ptr, "sh_open"), .shutter_close = RNA_float_get(op->ptr, "sh_close"), .selected_only = RNA_boolean_get(op->ptr, "selected"), .uvs = RNA_boolean_get(op->ptr, "uvs"), .normals = RNA_boolean_get(op->ptr, "normals"), .vcolors = RNA_boolean_get(op->ptr, "vcolors"), .apply_subdiv = RNA_boolean_get(op->ptr, "apply_subdiv"), .flatten_hierarchy = RNA_boolean_get(op->ptr, "flatten"), .visible_layers_only = RNA_boolean_get(op->ptr, "visible_layers_only"), .renderable_only = RNA_boolean_get(op->ptr, "renderable_only"), .face_sets = RNA_boolean_get(op->ptr, "face_sets"), .use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema"), .export_hair = RNA_boolean_get(op->ptr, "export_hair"), .export_particles = RNA_boolean_get(op->ptr, "export_particles"), .compression_type = RNA_enum_get(op->ptr, "compression_type"), .packuv = RNA_boolean_get(op->ptr, "packuv"), .triangulate = RNA_boolean_get(op->ptr, "triangulate"), .quad_method = RNA_enum_get(op->ptr, "quad_method"), .ngon_method = RNA_enum_get(op->ptr, "ngon_method"), .global_scale = RNA_float_get(op->ptr, "global_scale"), }; /* Take some defaults from the scene, if not specified explicitly. */ Scene *scene = CTX_data_scene(C); if (params.frame_start == INT_MIN) { params.frame_start = SFRA; } if (params.frame_end == INT_MIN) { params.frame_end = EFRA; } const bool as_background_job = RNA_boolean_get(op->ptr, "as_background_job"); bool ok = ABC_export(scene, C, filename, ¶ms, as_background_job); return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr) { uiLayout *box; uiLayout *row; uiLayout *col; #ifdef WITH_ALEMBIC_HDF5 box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Archive Options:"), ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "compression_type", 0, NULL, ICON_NONE); #endif box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "global_scale", 0, NULL, ICON_NONE); /* Scene Options */ box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Scene Options:"), ICON_SCENE_DATA); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "start", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "end", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "xsamples", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "gsamples", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "sh_open", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "sh_close", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "renderable_only", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "visible_layers_only", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "flatten", 0, NULL, ICON_NONE); /* Object Data */ box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Object Options:"), ICON_OBJECT_DATA); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "uvs", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "packuv", 0, NULL, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "uvs")); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "normals", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "vcolors", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "face_sets", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "subdiv_schema", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "apply_subdiv", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "triangulate", 0, NULL, ICON_NONE); const bool triangulate = RNA_boolean_get(imfptr, "triangulate"); row = uiLayoutRow(box, false); uiLayoutSetEnabled(row, triangulate); uiItemR(row, imfptr, "quad_method", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiLayoutSetEnabled(row, triangulate); uiItemR(row, imfptr, "ngon_method", 0, NULL, ICON_NONE); /* Object Data */ box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Particle Systems:"), ICON_PARTICLE_DATA); col = uiLayoutColumn(box, true); uiItemR(col, imfptr, "export_hair", 0, NULL, ICON_NONE); uiItemR(col, imfptr, "export_particles", 0, NULL, ICON_NONE); }
static int wm_alembic_export_exec(bContext *C, wmOperator *op) { if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; } char filename[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filename); const struct AlembicExportParams params = { .frame_start = RNA_int_get(op->ptr, "start"), .frame_end = RNA_int_get(op->ptr, "end"), .frame_step_xform = 1.0 / (double)RNA_int_get(op->ptr, "xsamples"), .frame_step_shape = 1.0 / (double)RNA_int_get(op->ptr, "gsamples"), .shutter_open = RNA_float_get(op->ptr, "sh_open"), .shutter_close = RNA_float_get(op->ptr, "sh_close"), .selected_only = RNA_boolean_get(op->ptr, "selected"), .uvs = RNA_boolean_get(op->ptr, "uvs"), .normals = RNA_boolean_get(op->ptr, "normals"), .vcolors = RNA_boolean_get(op->ptr, "vcolors"), .apply_subdiv = RNA_boolean_get(op->ptr, "apply_subdiv"), .flatten_hierarchy = RNA_boolean_get(op->ptr, "flatten"), .visible_layers_only = RNA_boolean_get(op->ptr, "visible_layers_only"), .renderable_only = RNA_boolean_get(op->ptr, "renderable_only"), .face_sets = RNA_boolean_get(op->ptr, "face_sets"), .use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema"), .compression_type = RNA_enum_get(op->ptr, "compression_type"), .packuv = RNA_boolean_get(op->ptr, "packuv"), .triangulate = RNA_boolean_get(op->ptr, "triangulate"), .quad_method = RNA_enum_get(op->ptr, "quad_method"), .ngon_method = RNA_enum_get(op->ptr, "ngon_method"), .global_scale = RNA_float_get(op->ptr, "global_scale"), }; ABC_export(CTX_data_scene(C), C, filename, ¶ms); return OPERATOR_FINISHED; } static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr) { uiLayout *box; uiLayout *row; #ifdef WITH_ALEMBIC_HDF5 box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Archive Options:"), ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "compression_type", 0, NULL, ICON_NONE); #endif box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "global_scale", 0, NULL, ICON_NONE); /* Scene Options */ box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Scene Options:"), ICON_SCENE_DATA); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "start", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "end", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "xsamples", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "gsamples", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "sh_open", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "sh_close", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "renderable_only", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "visible_layers_only", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "flatten", 0, NULL, ICON_NONE); /* Object Data */ box = uiLayoutBox(layout); row = uiLayoutRow(box, false); uiItemL(row, IFACE_("Object Options:"), ICON_OBJECT_DATA); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "uvs", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "packuv", 0, NULL, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "uvs")); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "normals", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "vcolors", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "face_sets", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "subdiv_schema", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "apply_subdiv", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiItemR(row, imfptr, "triangulate", 0, NULL, ICON_NONE); const bool triangulate = RNA_boolean_get(imfptr, "triangulate"); row = uiLayoutRow(box, false); uiLayoutSetEnabled(row, triangulate); uiItemR(row, imfptr, "quad_method", 0, NULL, ICON_NONE); row = uiLayoutRow(box, false); uiLayoutSetEnabled(row, triangulate); uiItemR(row, imfptr, "ngon_method", 0, NULL, ICON_NONE); }
void ANIM_uiTemplate_fmodifier_draw (uiLayout *layout, ID *id, ListBase *modifiers, FModifier *fcm) { FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); uiLayout *box, *row, *subrow; uiBlock *block; uiBut *but; short width= 314; PointerRNA ptr; /* init the RNA-pointer */ RNA_pointer_create(id, &RNA_FModifier, fcm, &ptr); /* draw header */ { /* get layout-row + UI-block for this */ box= uiLayoutBox(layout); row= uiLayoutRow(box, 0); block= uiLayoutGetBlock(row); // err... /* left-align -------------------------------------------- */ subrow= uiLayoutRow(row, 0); uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT); uiBlockSetEmboss(block, UI_EMBOSSN); /* expand */ uiItemR(subrow, &ptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* checkbox for 'active' status (for now) */ uiItemR(subrow, &ptr, "active", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* name */ if (fmi) uiItemL(subrow, fmi->name, ICON_NONE); else uiItemL(subrow, "<Unknown Modifier>", ICON_NONE); /* right-align ------------------------------------------- */ subrow= uiLayoutRow(row, 0); uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT); /* 'mute' button */ uiItemR(subrow, &ptr, "mute", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); uiBlockSetEmboss(block, UI_EMBOSSN); /* delete button */ but= uiDefIconBut(block, BUT, B_REDR, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Delete F-Curve Modifier."); uiButSetFunc(but, delete_fmodifier_cb, modifiers, fcm); uiBlockSetEmboss(block, UI_EMBOSS); } /* when modifier is expanded, draw settings */ if (fcm->flag & FMODIFIER_FLAG_EXPANDED) { /* set up the flexible-box layout which acts as the backdrop for the modifier settings */ box= uiLayoutBox(layout); /* draw settings for individual modifiers */ switch (fcm->type) { case FMODIFIER_TYPE_GENERATOR: /* Generator */ draw_modifier__generator(box, id, fcm, width); break; case FMODIFIER_TYPE_FN_GENERATOR: /* Built-In Function Generator */ draw_modifier__fn_generator(box, id, fcm, width); break; case FMODIFIER_TYPE_CYCLES: /* Cycles */ draw_modifier__cycles(box, id, fcm, width); break; case FMODIFIER_TYPE_ENVELOPE: /* Envelope */ draw_modifier__envelope(box, id, fcm, width); break; case FMODIFIER_TYPE_LIMITS: /* Limits */ draw_modifier__limits(box, id, fcm, width); break; case FMODIFIER_TYPE_NOISE: /* Noise */ draw_modifier__noise(box, id, fcm, width); break; case FMODIFIER_TYPE_STEPPED: /* Stepped */ draw_modifier__stepped(box, id, fcm, width); break; default: /* unknown type */ break; } } }