Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_templates.c
| Show First 20 Lines • Show All 579 Lines • ▼ Show 20 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name ID Template | /** \name ID Template | ||||
| * \{ */ | * \{ */ | ||||
| /* This is for browsing and editing the ID-blocks used */ | /* This is for browsing and editing the ID-blocks used */ | ||||
| /* for new/open operators */ | |||||
| void UI_context_active_but_prop_get_templateID(bContext *C, | void UI_context_active_but_prop_get_templateID(bContext *C, | ||||
| PointerRNA *r_ptr, | PointerRNA *r_ptr, | ||||
| PropertyRNA **r_prop) | PropertyRNA **r_prop) | ||||
| { | { | ||||
| uiBut *but = UI_context_active_but_get(C); | uiBut *but = UI_context_active_but_get(C); | ||||
| memset(r_ptr, 0, sizeof(*r_ptr)); | memset(r_ptr, 0, sizeof(*r_ptr)); | ||||
| *r_prop = NULL; | *r_prop = NULL; | ||||
| ▲ Show 20 Lines • Show All 954 Lines • ▼ Show 20 Lines | ui_template_id(layout, | ||||
| cols, | cols, | ||||
| filter, | filter, | ||||
| false, | false, | ||||
| scale < 0.5f ? 0.5f : scale, | scale < 0.5f ? 0.5f : scale, | ||||
| false, | false, | ||||
| false); | false); | ||||
| } | } | ||||
| /** | |||||
| * Version of #uiTemplateID using tabs. | |||||
| */ | |||||
| void uiTemplateIDTabs(uiLayout *layout, | void uiTemplateIDTabs(uiLayout *layout, | ||||
| bContext *C, | bContext *C, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname, | const char *propname, | ||||
| const char *newop, | const char *newop, | ||||
| const char *menu, | const char *menu, | ||||
| int filter) | int filter) | ||||
| { | { | ||||
| Show All 17 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name ID Chooser Template | /** \name ID Chooser Template | ||||
| * \{ */ | * \{ */ | ||||
| /** | |||||
| * This is for selecting the type of ID-block to use, | |||||
| * and then from the relevant type choosing the block to use. | |||||
| * | |||||
| * \param propname: property identifier for property that ID-pointer gets stored to. | |||||
| * \param proptypename: property identifier for property | |||||
| * used to determine the type of ID-pointer that can be used. | |||||
| */ | |||||
| void uiTemplateAnyID(uiLayout *layout, | void uiTemplateAnyID(uiLayout *layout, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname, | const char *propname, | ||||
| const char *proptypename, | const char *proptypename, | ||||
| const char *text) | const char *text) | ||||
| { | { | ||||
| /* get properties... */ | /* get properties... */ | ||||
| PropertyRNA *propID = RNA_struct_find_property(ptr, propname); | PropertyRNA *propID = RNA_struct_find_property(ptr, propname); | ||||
| ▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | static TemplateSearch *template_search_setup(PointerRNA *ptr, | ||||
| template_search->search_data.target_ptr = *ptr; | template_search->search_data.target_ptr = *ptr; | ||||
| template_search->search_data.target_prop = prop; | template_search->search_data.target_prop = prop; | ||||
| template_search->search_data.search_ptr = *searchptr; | template_search->search_data.search_ptr = *searchptr; | ||||
| template_search->search_data.search_prop = searchprop; | template_search->search_data.search_prop = searchprop; | ||||
| return template_search; | return template_search; | ||||
| } | } | ||||
| /** | |||||
| * Search menu to pick an item from a collection. | |||||
| * A version of uiTemplateID that works for non-ID types. | |||||
| */ | |||||
| void uiTemplateSearch(uiLayout *layout, | void uiTemplateSearch(uiLayout *layout, | ||||
| bContext *C, | bContext *C, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname, | const char *propname, | ||||
| PointerRNA *searchptr, | PointerRNA *searchptr, | ||||
| const char *searchpropname, | const char *searchpropname, | ||||
| const char *newop, | const char *newop, | ||||
| const char *unlinkop) | const char *unlinkop) | ||||
| Show All 34 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name RNA Path Builder Template | /** \name RNA Path Builder Template | ||||
| * \{ */ | * \{ */ | ||||
| /* ---------- */ | /* ---------- */ | ||||
| /** | |||||
| * This is creating/editing RNA-Paths | |||||
| * | |||||
| * - ptr: struct which holds the path property | |||||
| * - propname: property identifier for property that path gets stored to | |||||
| * - root_ptr: struct that path gets built from | |||||
| */ | |||||
| void uiTemplatePathBuilder(uiLayout *layout, | void uiTemplatePathBuilder(uiLayout *layout, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname, | const char *propname, | ||||
| PointerRNA *UNUSED(root_ptr), | PointerRNA *UNUSED(root_ptr), | ||||
| const char *text) | const char *text) | ||||
| { | { | ||||
| /* check that properties are valid */ | /* check that properties are valid */ | ||||
| PropertyRNA *propPath = RNA_struct_find_property(ptr, propname); | PropertyRNA *propPath = RNA_struct_find_property(ptr, propname); | ||||
| ▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | static void bone_constraint_panel_id(void *md_link, char *r_name) | ||||
| if (cti == NULL) { | if (cti == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| strcpy(r_name, CONSTRAINT_BONE_TYPE_PANEL_PREFIX); | strcpy(r_name, CONSTRAINT_BONE_TYPE_PANEL_PREFIX); | ||||
| strcat(r_name, cti->structName); | strcat(r_name, cti->structName); | ||||
| } | } | ||||
| /** | |||||
| * Check if the constraint panels don't match the data and rebuild the panels if so. | |||||
| */ | |||||
| void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_constraints) | void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_constraints) | ||||
| { | { | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| ListBase *constraints = {NULL}; | ListBase *constraints = {NULL}; | ||||
| if (use_bone_constraints) { | if (use_bone_constraints) { | ||||
| constraints = ED_object_pose_constraint_list(C); | constraints = ED_object_pose_constraint_list(C); | ||||
| ▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | |||||
| * Function with void * argument for #uiListPanelIDFromDataFunc. | * Function with void * argument for #uiListPanelIDFromDataFunc. | ||||
| */ | */ | ||||
| static void shaderfx_panel_id(void *fx_v, char *r_idname) | static void shaderfx_panel_id(void *fx_v, char *r_idname) | ||||
| { | { | ||||
| ShaderFxData *fx = (ShaderFxData *)fx_v; | ShaderFxData *fx = (ShaderFxData *)fx_v; | ||||
| BKE_shaderfxType_panel_id(fx->type, r_idname); | BKE_shaderfxType_panel_id(fx->type, r_idname); | ||||
| } | } | ||||
| /** | |||||
| * Check if the shader effect panels don't match the data and rebuild the panels if so. | |||||
| */ | |||||
| void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C) | void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C) | ||||
| { | { | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| ListBase *shaderfx = &ob->shader_fx; | ListBase *shaderfx = &ob->shader_fx; | ||||
| const bool panels_match = UI_panel_list_matches_data(region, shaderfx, shaderfx_panel_id); | const bool panels_match = UI_panel_list_matches_data(region, shaderfx, shaderfx_panel_id); | ||||
| ▲ Show 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | RNA_STRUCT_BEGIN (&ptr, prop) { | ||||
| } | } | ||||
| } | } | ||||
| RNA_STRUCT_END; | RNA_STRUCT_END; | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| /** | |||||
| * Draw Operator property buttons for redoing execution with different settings. | |||||
| * This function does not initialize the layout, | |||||
| * functions can be called on the layout before and after. | |||||
| */ | |||||
| void uiTemplateOperatorPropertyButs( | void uiTemplateOperatorPropertyButs( | ||||
| const bContext *C, uiLayout *layout, wmOperator *op, eButLabelAlign label_align, short flag) | const bContext *C, uiLayout *layout, wmOperator *op, eButLabelAlign label_align, short flag) | ||||
| { | { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| /* If there are only checkbox items, don't use split layout by default. It looks weird if the | /* If there are only checkbox items, don't use split layout by default. It looks weird if the | ||||
| * check-boxes only use half the width. */ | * check-boxes only use half the width. */ | ||||
| if (ui_layout_operator_properties_only_booleans(C, wm, op, flag)) { | if (ui_layout_operator_properties_only_booleans(C, wm, op, flag)) { | ||||
| ▲ Show 20 Lines • Show All 952 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Icon Template | /** \name Icon Template | ||||
| * \{ */ | * \{ */ | ||||
| /** | |||||
| * \param icon_scale: Scale of the icon, 1x == button height. | |||||
| */ | |||||
| void uiTemplateIcon(uiLayout *layout, int icon_value, float icon_scale) | void uiTemplateIcon(uiLayout *layout, int icon_value, float icon_scale) | ||||
| { | { | ||||
| uiBlock *block = uiLayoutAbsoluteBlock(layout); | uiBlock *block = uiLayoutAbsoluteBlock(layout); | ||||
| uiBut *but = uiDefIconBut(block, | uiBut *but = uiDefIconBut(block, | ||||
| UI_BTYPE_LABEL, | UI_BTYPE_LABEL, | ||||
| 0, | 0, | ||||
| ICON_X, | ICON_X, | ||||
| 0, | 0, | ||||
| ▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *region, void *arg_litem) | ||||
| if (free) { | if (free) { | ||||
| MEM_freeN((void *)item); | MEM_freeN((void *)item); | ||||
| } | } | ||||
| return block; | return block; | ||||
| } | } | ||||
| /** | |||||
| * \param icon_scale: Scale of the icon, 1x == button height. | |||||
| */ | |||||
| void uiTemplateIconView(uiLayout *layout, | void uiTemplateIconView(uiLayout *layout, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname, | const char *propname, | ||||
| bool show_labels, | bool show_labels, | ||||
| float icon_scale, | float icon_scale, | ||||
| float icon_scale_popup) | float icon_scale_popup) | ||||
| { | { | ||||
| PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | ||||
| ▲ Show 20 Lines • Show All 1,551 Lines • ▼ Show 20 Lines | static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUpdateCb *cb) | ||||
| } | } | ||||
| uiItemR(layout, ptr, "use_sample_straight_edges", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "use_sample_straight_edges", 0, NULL, ICON_NONE); | ||||
| uiItemR(layout, ptr, "use_sample_even_lengths", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "use_sample_even_lengths", 0, NULL, ICON_NONE); | ||||
| UI_block_funcN_set(block, NULL, NULL, NULL); | UI_block_funcN_set(block, NULL, NULL, NULL); | ||||
| } | } | ||||
| /** | |||||
| * Template for a path creation widget intended for custom bevel profiles. | |||||
| * This section is quite similar to #uiTemplateCurveMapping, but with reduced complexity. | |||||
| */ | |||||
| void uiTemplateCurveProfile(uiLayout *layout, PointerRNA *ptr, const char *propname) | void uiTemplateCurveProfile(uiLayout *layout, PointerRNA *ptr, const char *propname) | ||||
| { | { | ||||
| PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | PropertyRNA *prop = RNA_struct_find_property(ptr, propname); | ||||
| uiBlock *block = uiLayoutGetBlock(layout); | uiBlock *block = uiLayoutGetBlock(layout); | ||||
| if (!prop) { | if (!prop) { | ||||
| RNA_warning( | RNA_warning( | ||||
| Show All 30 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name ColorPicker Template | /** \name ColorPicker Template | ||||
| * \{ */ | * \{ */ | ||||
| #define WHEEL_SIZE (5 * U.widget_unit) | #define WHEEL_SIZE (5 * U.widget_unit) | ||||
| /* This template now follows User Preference for type - name is not correct anymore... */ | |||||
| void uiTemplateColorPicker(uiLayout *layout, | void uiTemplateColorPicker(uiLayout *layout, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname, | const char *propname, | ||||
| bool value_slider, | bool value_slider, | ||||
| bool lock, | bool lock, | ||||
| bool lock_luminosity, | bool lock_luminosity, | ||||
| bool cubic) | bool cubic) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 374 Lines • ▼ Show 20 Lines | for (int i = 0; i < tot; i++) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* view3d layer change should update depsgraph (invisible object changed maybe) */ | /* view3d layer change should update depsgraph (invisible object changed maybe) */ | ||||
| /* see view3d_header.c */ | /* see view3d_header.c */ | ||||
| } | } | ||||
| /** | |||||
| * \todo for now, grouping of layers is determined by dividing up the length of | |||||
| * the array of layer bitflags | |||||
| */ | |||||
| void uiTemplateLayers(uiLayout *layout, | void uiTemplateLayers(uiLayout *layout, | ||||
| PointerRNA *ptr, | PointerRNA *ptr, | ||||
| const char *propname, | const char *propname, | ||||
| PointerRNA *used_ptr, | PointerRNA *used_ptr, | ||||
| const char *used_propname, | const char *used_propname, | ||||
| int active_layer) | int active_layer) | ||||
| { | { | ||||
| const int cols_per_group = 5; | const int cols_per_group = 5; | ||||
| ▲ Show 20 Lines • Show All 936 Lines • Show Last 20 Lines | |||||