static void act_editmenu(bContext *C, uiLayout *layout, void *arg_unused) { uiItemMenuF(layout, "Transform", 0, act_edit_transformmenu, NULL); uiItemMenuEnumO(layout, "Snap", 0, "ACT_OT_snap", "type"); uiItemMenuEnumO(layout, "Mirror", 0, "ACT_OT_mirror", "type"); uiItemS(layout); uiItemO(layout, NULL, 0, "ACT_OT_insert_keyframe"); uiItemS(layout); uiItemO(layout, NULL, 0, "ACT_OT_duplicate"); uiItemO(layout, NULL, 0, "ACT_OT_delete"); uiItemS(layout); uiItemMenuEnumO(layout, "Keyframe Type", 0, "ACT_OT_keyframe_type", "type"); uiItemMenuEnumO(layout, "Handle Type", 0, "ACT_OT_handle_type", "type"); uiItemMenuEnumO(layout, "Interpolation Type", 0, "ACT_OT_interpolation_type", "type"); uiItemMenuEnumO(layout, "Extrapolation Type", 0, "ACT_OT_extrapolation_type", "type"); uiItemS(layout); uiItemO(layout, NULL, 0, "ACT_OT_clean"); uiItemO(layout, NULL, 0, "ACT_OT_sample"); uiItemS(layout); uiItemO(layout, NULL, 0, "ACT_OT_copy"); uiItemO(layout, NULL, 0, "ACT_OT_paste"); }
/* active node */ static void active_node_panel(const bContext *C, Panel *pa) { SpaceNode *snode= CTX_wm_space_node(C); bNodeTree *ntree= (snode) ? snode->edittree : NULL; bNode *node = (ntree) ? nodeGetActive(ntree) : NULL; // xxx... for editing group nodes uiLayout *layout= pa->layout; uiBlock *block; PointerRNA ptr; /* verify pointers, and create RNA pointer for the node */ if ELEM(NULL, ntree, node) return; //if (node->id) /* for group nodes */ // RNA_pointer_create(node->id, &RNA_Node, node, &ptr); //else RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); /* set update callback */ // xxx is this really needed block= uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_node_region_buttons, NULL); /* draw this node's name, etc. */ uiItemR(layout, &ptr, "label", 0, NULL, ICON_NODE); uiItemS(layout); uiItemR(layout, &ptr, "name", 0, NULL, ICON_NODE); uiItemS(layout); /* draw this node's settings */ if (node->typeinfo && node->typeinfo->uifuncbut) node->typeinfo->uifuncbut(layout, (bContext *)C, &ptr); else if (node->typeinfo && node->typeinfo->uifunc) node->typeinfo->uifunc(layout, (bContext *)C, &ptr); }
static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree; int nodeclass = GET_INT_FROM_POINTER(arg_nodeclass); int event, compatibility = 0; ntree = snode->nodetree; if (!ntree) { uiItemS(layout); return; } if (ntree->type == NTREE_SHADER) { if (BKE_scene_use_new_shading_nodes(scene)) compatibility = NODE_NEW_SHADING; else compatibility = NODE_OLD_SHADING; } if (nodeclass == NODE_CLASS_GROUP) { bNodeTree *ngroup; uiLayoutSetFunc(layout, do_node_add_group, NULL); /* XXX hack: negative numbers used for empty group types */ if (node_tree_has_type(ntree->type, NODE_GROUP)) uiItemV(layout, IFACE_("New Group"), 0, -NODE_GROUP); uiItemS(layout); for (ngroup = bmain->nodetree.first, event = 0; ngroup; ngroup = ngroup->id.next, ++event) { /* only use group trees */ if (ngroup->type == ntree->type && ngroup->nodetype == NODE_GROUP) { uiItemV(layout, ngroup->id.name + 2, 0, event); } } } else { bNodeType *ntype; uiLayoutSetFunc(layout, do_node_add_static, NULL); for (ntype = ntreeGetType(ntree->type)->node_types.first; ntype; ntype = ntype->next) { if (ntype->nclass == nodeclass && ntype->name) { if (!compatibility || (ntype->compatibility & compatibility)) { uiItemV(layout, IFACE_(ntype->name), 0, ntype->type); } } } } }
static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) { Main *bmain= CTX_data_main(C); SpaceNode *snode= CTX_wm_space_node(C); bNodeTree *ntree; int nodeclass= GET_INT_FROM_POINTER(arg_nodeclass); int event; ntree = snode->nodetree; if(!ntree) { uiItemS(layout); return; } if (nodeclass==NODE_CLASS_GROUP) { bNodeTree *ngroup; uiLayoutSetFunc(layout, do_node_add_group, NULL); /* XXX hack: negative numbers used for empty group types */ if (node_tree_has_type(ntree->type, NODE_GROUP)) uiItemV(layout, "New Group", 0, -NODE_GROUP); if (node_tree_has_type(ntree->type, NODE_FORLOOP)) uiItemV(layout, "New For Loop", 0, -NODE_FORLOOP); if (node_tree_has_type(ntree->type, NODE_WHILELOOP)) uiItemV(layout, "New While Loop", 0, -NODE_WHILELOOP); uiItemS(layout); for(ngroup=bmain->nodetree.first, event=0; ngroup; ngroup= ngroup->id.next, ++event) { /* only use group trees */ if (ngroup->type==ntree->type && ELEM3(ngroup->nodetype, NODE_GROUP, NODE_FORLOOP, NODE_WHILELOOP)) { uiItemV(layout, ngroup->id.name+2, 0, event); } } } else if (nodeclass==NODE_DYNAMIC) { /* disabled */ } else { bNodeType *ntype; uiLayoutSetFunc(layout, do_node_add_static, NULL); for (ntype=ntreeGetType(ntree->type)->node_types.first; ntype; ntype=ntype->next) { if(ntype->nclass==nodeclass && ntype->name) uiItemV(layout, ntype->name, 0, ntype->type); } } }
static void act_channelmenu(bContext *C, uiLayout *layout, void *arg_unused) { uiItemO(layout, NULL, 0, "ANIM_OT_channels_setting_toggle"); uiItemO(layout, NULL, 0, "ANIM_OT_channels_setting_enable"); uiItemO(layout, NULL, 0, "ANIM_OT_channels_setting_disable"); uiItemS(layout); uiItemO(layout, NULL, 0, "ANIM_OT_channels_editable_toggle"); uiItemS(layout); uiItemO(layout, NULL, 0, "ANIM_OT_channels_expand"); uiItemO(layout, NULL, 0, "ANIM_OT_channels_collapse"); }
static int vertex_group_menu_exec(bContext *C, wmOperator *op) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; uiPopupMenu *pup; uiLayout *layout; pup= uiPupMenuBegin(C, "Vertex Groups", 0); layout= uiPupMenuLayout(pup); uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN); if(vgroup_object_in_edit_mode(ob)) { uiItemBooleanO(layout, "Assign to New Group", 0, "OBJECT_OT_vertex_group_assign", "new", 1); if(BLI_countlist(&ob->defbase) && ob->actdef) { uiItemO(layout, "Assign to Group", 0, "OBJECT_OT_vertex_group_assign"); uiItemO(layout, "Remove from Group", 0, "OBJECT_OT_vertex_group_remove_from"); uiItemBooleanO(layout, "Remove from All", 0, "OBJECT_OT_vertex_group_remove_from", "all", 1); } } if(BLI_countlist(&ob->defbase) && ob->actdef) { if(vgroup_object_in_edit_mode(ob)) uiItemS(layout); uiItemO(layout, "Set Active Group", 0, "OBJECT_OT_vertex_group_set_active"); uiItemO(layout, "Remove Group", 0, "OBJECT_OT_vertex_group_remove"); uiItemBooleanO(layout, "Remove All Groups", 0, "OBJECT_OT_vertex_group_remove", "all", 1); } uiPupMenuEnd(C, pup); return OPERATOR_FINISHED; }
static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt) { void **rnd_data = rnd_pt; uiBlock *block = uiLayoutGetBlock(layout); RenderResult *rr = rnd_data[0]; ImageUser *iuser = rnd_data[1]; RenderLayer *rl; RenderLayer rl_fake = {NULL}; const char *fake_name; int nr; uiBlockSetCurLayout(block, layout); uiLayoutColumn(layout, false); uiDefBut(block, LABEL, 0, IFACE_("Layer"), 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiItemS(layout); nr = BLI_countlist(&rr->layers) - 1; fake_name = ui_imageuser_layer_fake_name(rr); if (fake_name) { BLI_strncpy(rl_fake.name, fake_name, sizeof(rl_fake.name)); nr += 1; } for (rl = rr->layers.last; rl; rl = rl->prev, nr--) { final: uiDefButS(block, BUTM, B_NOP, IFACE_(rl->name), 0, 0, UI_UNIT_X * 5, UI_UNIT_X, &iuser->layer, (float) nr, 0.0, 0, -1, ""); }
/* active AnimData */ static void nla_panel_animdata(const bContext *C, Panel *pa) { PointerRNA adt_ptr; /* AnimData *adt; */ uiLayout *layout = pa->layout; uiLayout *row; uiBlock *block; /* check context and also validity of pointer */ if (!nla_panel_context(C, &adt_ptr, NULL, NULL)) return; /* adt = adt_ptr.data; */ block = uiLayoutGetBlock(layout); UI_block_func_handle_set(block, do_nla_region_buttons, NULL); /* AnimData Source Properties ----------------------------------- */ /* icon + id-block name of block where AnimData came from to prevent * accidentally changing the properties of the wrong action */ if (adt_ptr.id.data) { ID *id = adt_ptr.id.data; PointerRNA id_ptr; RNA_id_pointer_create(id, &id_ptr); /* ID-block name > AnimData */ row = uiLayoutRow(layout, true); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); uiItemL(row, id->name + 2, RNA_struct_ui_icon(id_ptr.type)); /* id-block (src) */ uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC); /* expander */ uiItemL(row, IFACE_("Animation Data"), ICON_ANIM_DATA); /* animdata */ uiItemS(layout); } /* Active Action Properties ------------------------------------- */ /* action */ row = uiLayoutRow(layout, true); uiTemplateID( row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, "NLA_OT_action_unlink", UI_TEMPLATE_ID_FILTER_ALL); /* extrapolation */ row = uiLayoutRow(layout, true); uiItemR(row, &adt_ptr, "action_extrapolation", 0, NULL, ICON_NONE); /* blending */ row = uiLayoutRow(layout, true); uiItemR(row, &adt_ptr, "action_blend_type", 0, NULL, ICON_NONE); /* influence */ row = uiLayoutRow(layout, true); uiItemR(row, &adt_ptr, "action_influence", 0, NULL, ICON_NONE); }
static void act_selectmenu(bContext *C, uiLayout *layout, void *arg_unused) { uiItemO(layout, NULL, 0, "ACT_OT_select_all_toggle"); uiItemBooleanO(layout, "Invert All", 0, "ACT_OT_select_all_toggle", "invert", 1); uiItemS(layout); uiItemO(layout, NULL, 0, "ACT_OT_select_border"); uiItemBooleanO(layout, "Border Axis Range", 0, "ACT_OT_select_border", "axis_range", 1); uiItemS(layout); uiItemEnumO(layout, "Columns on Selected Keys", 0, "ACT_OT_select_column", "mode", ACTKEYS_COLUMNSEL_KEYS); uiItemEnumO(layout, "Column on Current Frame", 0, "ACT_OT_select_column", "mode", ACTKEYS_COLUMNSEL_CFRA); uiItemEnumO(layout, "Columns on Selected Markers", 0, "ACT_OT_select_column", "mode", ACTKEYS_COLUMNSEL_MARKERS_COLUMN); uiItemEnumO(layout, "Between Selected Markers", 0, "ACT_OT_select_column", "mode", ACTKEYS_COLUMNSEL_MARKERS_BETWEEN); }
/* invoke callback which presents a list of bone-groups for the user to choose from */ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { Object *ob = ED_pose_object_from_context(C); bPose *pose; PropertyRNA *prop = RNA_struct_find_property(op->ptr, "type"); uiPopupMenu *pup; uiLayout *layout; bActionGroup *grp; int i; /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; pose = ob->pose; /* If group index is set, try to use it! */ if (RNA_property_is_set(op->ptr, prop)) { const int num_groups = BLI_listbase_count(&pose->agroups); const int group = RNA_property_int_get(op->ptr, prop); /* just use the active group index, and call the exec callback for the calling operator */ if (group > 0 && group <= num_groups) { return op->type->exec(C, op); } } /* if there's no active group (or active is invalid), create a new menu to find it */ if (pose->active_group <= 0) { /* create a new menu, and start populating it with group names */ pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE); layout = UI_popup_menu_layout(pup); /* special entry - allow to create new group, then use that * (not to be used for removing though) */ if (strstr(op->idname, "assign")) { uiItemIntO(layout, "New Group", ICON_NONE, op->idname, "type", 0); uiItemS(layout); } /* add entries for each group */ for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++) uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i); /* finish building the menu, and process it (should result in calling self again) */ UI_popup_menu_end(C, pup); return OPERATOR_INTERFACE; } else { /* just use the active group index, and call the exec callback for the calling operator */ RNA_int_set(op->ptr, "type", pose->active_group); return op->type->exec(C, op); } }
static void workspace_add_menu(bContext *C, uiLayout *layout, void *template_v) { Main *bmain = CTX_data_main(C); const char *app_template = template_v; bool has_startup_items = false; wmOperatorType *ot_append = WM_operatortype_find("WORKSPACE_OT_append_activate", true); WorkspaceConfigFileData *startup_config = workspace_config_file_read(app_template); WorkspaceConfigFileData *builtin_config = workspace_system_file_read(app_template); if (startup_config) { for (WorkSpace *workspace = startup_config->workspaces.first; workspace; workspace = workspace->id.next) { uiLayout *row = uiLayoutRow(layout, false); if (BLI_findstring(&bmain->workspaces, workspace->id.name, offsetof(ID, name))) { uiLayoutSetActive(row, false); } workspace_append_button(row, ot_append, workspace, startup_config->main); has_startup_items = true; } } if (builtin_config) { bool has_title = false; for (WorkSpace *workspace = builtin_config->workspaces.first; workspace; workspace = workspace->id.next) { if (startup_config && BLI_findstring(&startup_config->workspaces, workspace->id.name, offsetof(ID, name))) { continue; } if (!has_title) { if (has_startup_items) { uiItemS(layout); } has_title = true; } uiLayout *row = uiLayoutRow(layout, false); if (BLI_findstring(&bmain->workspaces, workspace->id.name, offsetof(ID, name))) { uiLayoutSetActive(row, false); } workspace_append_button(row, ot_append, workspace, builtin_config->main); } } if (startup_config) { BKE_blendfile_workspace_config_data_free(startup_config); } if (builtin_config) { BKE_blendfile_workspace_config_data_free(builtin_config); } }
/* Create (and show) a menu containing all the Keying Sets which can be used in the current context */ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op_name[]) { Scene *scene= CTX_data_scene(C); KeyingSet *ks; uiPopupMenu *pup; uiLayout *layout; int i = 0; pup= uiPupMenuBegin(C, title, ICON_NONE); layout= uiPupMenuLayout(pup); /* active Keying Set * - only include entry if it exists */ if (scene->active_keyingset) { uiItemIntO(layout, "Active Keying Set", ICON_NONE, op_name, "type", i++); uiItemS(layout); } else i++; /* user-defined Keying Sets * - these are listed in the order in which they were defined for the active scene */ if (scene->keyingsets.first) { for (ks= scene->keyingsets.first; ks; ks=ks->next, i++) { if (ANIM_keyingset_context_ok_poll(C, ks)) uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i); } uiItemS(layout); } /* builtin Keying Sets */ i= -1; for (ks= builtin_keyingsets.first; ks; ks=ks->next, i--) { /* only show KeyingSet if context is suitable */ if (ANIM_keyingset_context_ok_poll(C, ks)) uiItemEnumO_value(layout, ks->name, ICON_NONE, op_name, "type", i); } uiPupMenuEnd(C, pup); }
static void act_viewmenu(bContext *C, uiLayout *layout, void *arg_unused) { bScreen *sc= CTX_wm_screen(C); ScrArea *sa= CTX_wm_area(C); SpaceAction *sact= CTX_wm_space_action(C); PointerRNA spaceptr; /* retrieve state */ RNA_pointer_create(&sc->id, &RNA_SpaceDopeSheetEditor, sact, &spaceptr); /* create menu */ //uiItemO(layout, NULL, ICON_MENU_PANEL, "ACT_OT_properties"); //uiItemS(layout); uiItemR(layout, NULL, 0, &spaceptr, "show_cframe_indicator", 0); uiItemR(layout, NULL, 0, &spaceptr, "show_sliders", 0); uiItemR(layout, NULL, 0, &spaceptr, "automerge_keyframes", 0); if (sact->flag & SACTION_DRAWTIME) uiItemO(layout, "Show Frames", 0, "ANIM_OT_time_toggle"); else uiItemO(layout, "Show Seconds", 0, "ANIM_OT_time_toggle"); uiItemS(layout); uiItemO(layout, NULL, 0, "ANIM_OT_previewrange_set"); uiItemO(layout, NULL, 0, "ANIM_OT_previewrange_clear"); uiItemO(layout, NULL, 0, "ACT_OT_previewrange_set"); uiItemS(layout); uiItemO(layout, NULL, 0, "ACT_OT_frame_jump"); uiItemO(layout, NULL, 0, "ACT_OT_view_all"); if (sa->full) uiItemO(layout, NULL, 0, "SCREEN_OT_screen_full_area"); // "Tile Window", Ctrl UpArrow else uiItemO(layout, NULL, 0, "SCREEN_OT_screen_full_area"); // "Maximize Window", Ctrl DownArrow }
static void node_tree_interface_panel(const bContext *C, Panel *pa) { SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = (snode) ? snode->edittree : NULL; bNodeSocket *sock; int in_out; uiLayout *layout = pa->layout, *row, *split, *col; PointerRNA ptr, sockptr, opptr; if (!ntree) return; RNA_id_pointer_create((ID *)ntree, &ptr); node_tree_find_active_socket(ntree, &sock, &in_out); RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, sock, &sockptr); row = uiLayoutRow(layout, false); split = uiLayoutRow(row, true); col = uiLayoutColumn(split, true); uiItemL(col, IFACE_("Inputs:"), ICON_NONE); uiTemplateList(col, (bContext *)C, "NODE_UL_interface_sockets", "inputs", &ptr, "inputs", &ptr, "active_input", NULL, 0, 0, 0, 0); opptr = uiItemFullO(col, "NODE_OT_tree_socket_add", "", ICON_PLUS, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&opptr, "in_out", SOCK_IN); col = uiLayoutColumn(split, true); uiItemL(col, IFACE_("Outputs:"), ICON_NONE); uiTemplateList(col, (bContext *)C, "NODE_UL_interface_sockets", "outputs", &ptr, "outputs", &ptr, "active_output", NULL, 0, 0, 0, 0); opptr = uiItemFullO(col, "NODE_OT_tree_socket_add", "", ICON_PLUS, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&opptr, "in_out", SOCK_OUT); col = uiLayoutColumn(row, true); opptr = uiItemFullO(col, "NODE_OT_tree_socket_move", "", ICON_TRIA_UP, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&opptr, "direction", 1); opptr = uiItemFullO(col, "NODE_OT_tree_socket_move", "", ICON_TRIA_DOWN, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&opptr, "direction", 2); if (sock) { row = uiLayoutRow(layout, true); uiItemR(row, &sockptr, "name", 0, NULL, ICON_NONE); uiItemO(row, "", ICON_X, "NODE_OT_tree_socket_remove"); if (sock->typeinfo->interface_draw) { uiItemS(layout); sock->typeinfo->interface_draw((bContext *)C, layout, &sockptr); } } }
static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *image_p) { uiBlock *block = uiLayoutGetBlock(layout); Image *image = image_p; int slot_id; uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("Slot"), 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiItemS(layout); slot_id = BLI_listbase_count(&image->renderslots) - 1; for (RenderSlot *slot = image->renderslots.last; slot; slot = slot->prev) { char str[64]; if (slot->name[0] != '\0') { BLI_strncpy(str, slot->name, sizeof(str)); } else { BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot_id + 1); } uiDefButS(block, UI_BTYPE_BUT_MENU, B_NOP, str, 0, 0, UI_UNIT_X * 5, UI_UNIT_X, &image->render_slot, (float)slot_id, 0.0, 0, -1, ""); slot_id--; } }
static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *render_slot_p) { uiBlock *block = uiLayoutGetBlock(layout); short *render_slot = render_slot_p; int slot; uiDefBut(block, LABEL, 0, IFACE_("Slot"), 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiItemS(layout); slot = IMA_MAX_RENDER_SLOT; while (slot--) { char str[32]; BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot + 1); uiDefButS(block, BUTM, B_NOP, str, 0, 0, UI_UNIT_X * 5, UI_UNIT_X, render_slot, (float) slot, 0.0, 0, -1, ""); } }
static void ui_imageuser_layer_menu(bContext *UNUSED(C), uiLayout *layout, void *rnd_pt) { void **rnd_data = rnd_pt; uiBlock *block = uiLayoutGetBlock(layout); Image *image = rnd_data[0]; ImageUser *iuser = rnd_data[1]; Scene *scene = iuser->scene; RenderResult *rr; RenderLayer *rl; RenderLayer rl_fake = {NULL}; const char *fake_name; int nr; /* may have been freed since drawing */ rr = BKE_image_acquire_renderresult(scene, image); if (UNLIKELY(rr == NULL)) { return; } UI_block_layout_set_current(block, layout); uiLayoutColumn(layout, false); uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("Layer"), 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiItemS(layout); nr = BLI_listbase_count(&rr->layers) - 1; fake_name = ui_imageuser_layer_fake_name(rr); if (fake_name) { BLI_strncpy(rl_fake.name, fake_name, sizeof(rl_fake.name)); nr += 1; } for (rl = rr->layers.last; rl; rl = rl->prev, nr--) { final: uiDefButS(block, UI_BTYPE_BUT_MENU, B_NOP, rl->name, 0, 0, UI_UNIT_X * 5, UI_UNIT_X, &iuser->layer, (float) nr, 0.0, 0, -1, ""); }
static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *image_p) { uiBlock *block = uiLayoutGetBlock(layout); Image *image = image_p; int slot; uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("Slot"), 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiItemS(layout); slot = IMA_MAX_RENDER_SLOT; while (slot--) { char str[64]; if (image->render_slots[slot].name[0] != '\0') { BLI_strncpy(str, image->render_slots[slot].name, sizeof(str)); } else { BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot + 1); } uiDefButS(block, UI_BTYPE_BUT_MENU, B_NOP, str, 0, 0, UI_UNIT_X * 5, UI_UNIT_X, &image->render_slot, (float) slot, 0.0, 0, -1, ""); } }
void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, int compact) { #define MAX_INFO_LEN 128 PropertyRNA *prop; PointerRNA imaptr; RNAUpdateCb *cb; Image *ima; ImageUser *iuser; Scene *scene = CTX_data_scene(C); uiLayout *row, *split, *col; uiBlock *block; char str[MAX_INFO_LEN]; void *lock; if (!ptr->data) return; prop = RNA_struct_find_property(ptr, propname); if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } if (RNA_property_type(prop) != PROP_POINTER) { printf("%s: expected pointer property for %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } block = uiLayoutGetBlock(layout); imaptr = RNA_property_pointer_get(ptr, prop); ima = imaptr.data; iuser = userptr->data; BKE_image_user_check_frame_calc(iuser, (int)scene->r.cfra, 0); cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); cb->ptr = *ptr; cb->prop = prop; cb->iuser = iuser; uiLayoutSetContextPointer(layout, "edit_image", &imaptr); uiLayoutSetContextPointer(layout, "edit_image_user", userptr); if (!compact) uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL); if (ima) { uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL); if (ima->source == IMA_SRC_VIEWER) { ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str, MAX_INFO_LEN); BKE_image_release_ibuf(ima, ibuf, lock); uiItemL(layout, ima->id.name + 2, ICON_NONE); uiItemL(layout, str, ICON_NONE); if (ima->type == IMA_TYPE_COMPOSITE) { // XXX not working yet #if 0 iuser = ntree_get_active_iuser(scene->nodetree); if (iuser) { uiBlockBeginAlign(block); uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10, 120, 100, 20, 0, 0, 0, 0, 0, ""); uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110, 120, 100, 20, 0, 0, 0, 0, 0, ""); but = uiDefBut(block, BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, ""); uiButSetFunc(but, image_freecache_cb, ima, NULL); if (iuser->frames) BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr); else strcpy(str, "Frames:"); uiBlockBeginAlign(block); uiDefButI(block, NUM, imagechanged, str, 10, 90, 150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use"); uiDefButI(block, NUM, imagechanged, "StartFr:", 160, 90, 150, 20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Global starting frame of the movie"); } #endif } else if (ima->type == IMA_TYPE_R_RESULT) { /* browse layer/passes */ RenderResult *rr; /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ rr = BKE_image_acquire_renderresult(scene, ima); uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot); BKE_image_release_renderresult(scene, ima); } } else { uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE); if (ima->source != IMA_SRC_GENERATED) { row = uiLayoutRow(layout, TRUE); if (ima->packedfile) uiItemO(row, "", ICON_PACKAGE, "image.unpack"); else uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); row = uiLayoutRow(row, TRUE); uiLayoutSetEnabled(row, ima->packedfile == NULL); uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "image.reload"); } // XXX what was this for? #if 0 /* check for re-render, only buttons */ if (imagechanged == B_IMAGECHANGED) { if (iuser->flag & IMA_ANIM_REFRESHED) { iuser->flag &= ~IMA_ANIM_REFRESHED; WM_event_add_notifier(C, NC_IMAGE, ima); } } #endif /* multilayer? */ if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) { uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL); } else if (ima->source != IMA_SRC_GENERATED) { if (compact == 0) { ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str, MAX_INFO_LEN); BKE_image_release_ibuf(ima, ibuf, lock); uiItemL(layout, str, ICON_NONE); } } col = uiLayoutColumn(layout, FALSE); uiTemplateColorspaceSettings(col, &imaptr, "colorspace_settings"); uiItemR(col, &imaptr, "use_view_as_render", 0, NULL, ICON_NONE); if (ima->source != IMA_SRC_GENERATED) { if (compact == 0) { /* background image view doesnt need these */ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL); int has_alpha = TRUE; if (ibuf) { int imtype = BKE_ftype_to_imtype(ibuf->ftype); char valid_channels = BKE_imtype_valid_channels(imtype); has_alpha = valid_channels & IMA_CHAN_FLAG_ALPHA; BKE_image_release_ibuf(ima, ibuf, NULL); } if (has_alpha) { col = uiLayoutColumn(layout, FALSE); uiItemR(col, &imaptr, "use_alpha", 0, NULL, ICON_NONE); uiItemR(col, &imaptr, "alpha_mode", 0, "Alpha", ICON_NONE); } uiItemS(layout); split = uiLayoutSplit(layout, 0.0f, FALSE); col = uiLayoutColumn(split, FALSE); /* XXX Why only display fields_per_frame only for video image types? * And why allow fields for non-video image types at all??? */ if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { uiLayout *subsplit = uiLayoutSplit(col, 0.0f, FALSE); uiLayout *subcol = uiLayoutColumn(subsplit, FALSE); uiItemR(subcol, &imaptr, "use_fields", 0, NULL, ICON_NONE); subcol = uiLayoutColumn(subsplit, FALSE); uiLayoutSetActive(subcol, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(subcol, userptr, "fields_per_frame", 0, IFACE_("Fields"), ICON_NONE); } else uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE); row = uiLayoutRow(col, FALSE); uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } } if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { uiItemS(layout); split = uiLayoutSplit(layout, 0.0f, FALSE); col = uiLayoutColumn(split, FALSE); BLI_snprintf(str, sizeof(str), IFACE_("(%d) Frames"), iuser->framenr); uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE); uiItemR(col, userptr, "frame_start", 0, IFACE_("Start"), ICON_NONE); uiItemR(col, userptr, "frame_offset", 0, NULL, ICON_NONE); col = uiLayoutColumn(split, FALSE); uiItemO(col, NULL, ICON_NONE, "IMAGE_OT_match_movie_length"); uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE); uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE); } else if (ima->source == IMA_SRC_GENERATED) { split = uiLayoutSplit(layout, 0.0f, FALSE); col = uiLayoutColumn(split, TRUE); uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE); uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } } uiBlockSetNFunc(block, NULL, NULL, NULL); } MEM_freeN(cb); #undef MAX_INFO_LEN }
static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth) { PointerRNA inputptr, nodeptr; uiBlock *block = uiLayoutGetBlock(layout); uiBut *bt; uiLayout *split, *row, *col; bNode *lnode; char label[UI_MAX_NAME_STR]; int indent = (depth > 1) ? 2 * (depth - 1) : 0; int dependency_loop; if (input->flag & SOCK_UNAVAIL) return; /* to avoid eternal loops on cyclic dependencies */ node->flag |= NODE_TEST; lnode = (input->link) ? input->link->fromnode : NULL; dependency_loop = (lnode && (lnode->flag & NODE_TEST)); if (dependency_loop) lnode = NULL; /* socket RNA pointer */ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, input, &inputptr); RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr); /* indented label */ memset(label, ' ', indent); label[indent] = '\0'; BLI_snprintf(label, UI_MAX_NAME_STR, "%s%s:", label, IFACE_(input->name)); /* split in label and value */ split = uiLayoutSplit(layout, 0.35f, false); row = uiLayoutRow(split, true); if (depth > 0) { UI_block_emboss_set(block, UI_EMBOSS_NONE); if (lnode && (lnode->inputs.first || (lnode->typeinfo->draw_buttons && lnode->type != NODE_GROUP))) { int icon = (input->flag & SOCK_COLLAPSED) ? ICON_DISCLOSURE_TRI_RIGHT : ICON_DISCLOSURE_TRI_DOWN; uiItemR(row, &inputptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", icon); } else uiItemL(row, "", ICON_BLANK1); bt = block->buttons.last; bt->rect.xmax = UI_UNIT_X / 2; UI_block_emboss_set(block, UI_EMBOSS); } uiItemL(row, label, ICON_NONE); bt = block->buttons.last; bt->drawflag = UI_BUT_TEXT_LEFT; if (dependency_loop) { row = uiLayoutRow(split, false); uiItemL(row, IFACE_("Dependency Loop"), ICON_ERROR); } else if (lnode) { /* input linked to a node */ uiTemplateNodeLink(split, ntree, node, input); if (depth == 0 || !(input->flag & SOCK_COLLAPSED)) { if (depth == 0) uiItemS(layout); ui_node_draw_node(layout, C, ntree, lnode, depth); } } else { /* input not linked, show value */ if (!(input->flag & SOCK_HIDE_VALUE)) { switch (input->type) { case SOCK_FLOAT: case SOCK_INT: case SOCK_BOOLEAN: case SOCK_RGBA: case SOCK_STRING: row = uiLayoutRow(split, true); uiItemR(row, &inputptr, "default_value", 0, "", ICON_NONE); break; case SOCK_VECTOR: row = uiLayoutRow(split, false); col = uiLayoutColumn(row, false); uiItemR(col, &inputptr, "default_value", 0, "", ICON_NONE); break; default: row = uiLayoutRow(split, false); break; } } else row = uiLayoutRow(split, false); uiTemplateNodeLink(row, ntree, node, input); } /* clear */ node->flag &= ~NODE_TEST; }
void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *userptr, int compact) { PropertyRNA *prop; PointerRNA imaptr; RNAUpdateCb *cb; Image *ima; ImageUser *iuser; ImBuf *ibuf; Scene *scene = CTX_data_scene(C); uiLayout *row, *split, *col; uiBlock *block; uiBut *but; char str[128]; void *lock; if (!ptr->data) return; prop = RNA_struct_find_property(ptr, propname); if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } if (RNA_property_type(prop) != PROP_POINTER) { printf("%s: expected pointer property for %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } block = uiLayoutGetBlock(layout); imaptr = RNA_property_pointer_get(ptr, prop); ima = imaptr.data; iuser = userptr->data; cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); cb->ptr = *ptr; cb->prop = prop; cb->iuser = iuser; uiLayoutSetContextPointer(layout, "edit_image", &imaptr); if (!compact) uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL); if (ima) { uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL); if (ima->source == IMA_SRC_VIEWER) { ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str); BKE_image_release_ibuf(ima, lock); uiItemL(layout, ima->id.name + 2, ICON_NONE); uiItemL(layout, str, ICON_NONE); if (ima->type == IMA_TYPE_COMPOSITE) { // XXX not working yet #if 0 iuser = ntree_get_active_iuser(scene->nodetree); if (iuser) { uiBlockBeginAlign(block); uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10, 120, 100, 20, 0, 0, 0, 0, 0, ""); uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110, 120, 100, 20, 0, 0, 0, 0, 0, ""); but = uiDefBut(block, BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, ""); uiButSetFunc(but, image_freecache_cb, ima, NULL); if (iuser->frames) BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr); else strcpy(str, "Frames:"); uiBlockBeginAlign(block); uiDefButI(block, NUM, imagechanged, str, 10, 90, 150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use"); uiDefButI(block, NUM, imagechanged, "StartFr:", 160, 90, 150, 20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Global starting frame of the movie"); } #endif } else if (ima->type == IMA_TYPE_R_RESULT) { /* browse layer/passes */ Render *re = RE_GetRender(scene->id.name); RenderResult *rr = RE_AcquireResultRead(re); uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot); RE_ReleaseResult(re); } } else { uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE); if (ima->source != IMA_SRC_GENERATED) { row = uiLayoutRow(layout, 1); if (ima->packedfile) uiItemO(row, "", ICON_PACKAGE, "image.unpack"); else uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); row = uiLayoutRow(row, 0); uiLayoutSetEnabled(row, ima->packedfile == NULL); uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE); uiItemO(row, "", ICON_FILE_REFRESH, "image.reload"); } // XXX what was this for? #if 0 /* check for re-render, only buttons */ if (imagechanged == B_IMAGECHANGED) { if (iuser->flag & IMA_ANIM_REFRESHED) { iuser->flag &= ~IMA_ANIM_REFRESHED; WM_event_add_notifier(C, NC_IMAGE, ima); } } #endif /* multilayer? */ if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) { uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL); } else if (ima->source != IMA_SRC_GENERATED) { if (compact == 0) { ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str); BKE_image_release_ibuf(ima, lock); uiItemL(layout, str, ICON_NONE); } } if (ima->source != IMA_SRC_GENERATED) { if (compact == 0) { /* background image view doesnt need these */ uiItemS(layout); split = uiLayoutSplit(layout, 0, 0); col = uiLayoutColumn(split, 0); uiItemR(col, &imaptr, "use_fields", 0, NULL, ICON_NONE); row = uiLayoutRow(col, 0); uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(row, &imaptr, "field_order", UI_ITEM_R_EXPAND, NULL, ICON_NONE); row = uiLayoutRow(layout, 0); uiItemR(row, &imaptr, "use_premultiply", 0, NULL, ICON_NONE); uiItemR(row, &imaptr, "use_color_unpremultiply", 0, NULL, ICON_NONE); } } if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { uiItemS(layout); split = uiLayoutSplit(layout, 0, 0); col = uiLayoutColumn(split, 0); BLI_snprintf(str, sizeof(str), "(%d) Frames", iuser->framenr); uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE); if (ima->anim) { block = uiLayoutGetBlock(col); but = uiDefBut(block, BUT, 0, "Match Movie Length", 0, 0, UI_UNIT_X * 2, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Set the number of frames to match the movie or sequence"); uiButSetFunc(but, set_frames_cb, ima, iuser); } uiItemR(col, userptr, "frame_start", 0, "Start", ICON_NONE); uiItemR(col, userptr, "frame_offset", 0, NULL, ICON_NONE); col = uiLayoutColumn(split, 0); row = uiLayoutRow(col, 0); uiLayoutSetActive(row, RNA_boolean_get(&imaptr, "use_fields")); uiItemR(row, userptr, "fields_per_frame", 0, "Fields", ICON_NONE); uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE); uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE); } else if (ima->source == IMA_SRC_GENERATED) { split = uiLayoutSplit(layout, 0, 0); col = uiLayoutColumn(split, 1); uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE); uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); } } uiBlockSetNFunc(block, NULL, NULL, NULL); } MEM_freeN(cb); }