Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_relations.c
| Show First 20 Lines • Show All 2,717 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* ------------------------------------------------------------------- */ | /* ------------------------------------------------------------------- */ | ||||
| /** \name Drop Named Material on Object Operator | /** \name Drop Named Material on Object Operator | ||||
| * \{ */ | * \{ */ | ||||
| char *ED_object_ot_drop_named_material_tooltip(bContext *C, | |||||
| PointerRNA *properties, | |||||
| const wmEvent *event) | |||||
| { | |||||
| Base *base = ED_view3d_give_base_under_cursor(C, event->mval); | |||||
| Main *bmain = CTX_data_main(C); | |||||
| char name[MAX_ID_NAME - 2]; | |||||
| RNA_string_get(properties, "name", name); | |||||
| Material *ma = (Material *)BKE_libblock_find_name(bmain, ID_MA, name); | |||||
Severin: Can we just return `NULL` here? | |||||
Done Inline ActionsThat would display the operator name but we could ask feedback from users jbakker: That would display the operator name but we could ask feedback from users | |||||
| if (base == NULL || ma == NULL) { | |||||
| return BLI_strdup(""); | |||||
| } | |||||
| Object *ob = base->object; | |||||
| int active_mat_slot = max_ii(ob->actcol, 1); | |||||
| Material *prev_mat = BKE_object_material_get(ob, active_mat_slot); | |||||
| if (prev_mat) { | |||||
| const char *tooltip = TIP_("Drop %s on %s (slot %d, replacing %s)."); | |||||
| return BLI_sprintfN(tooltip, name, ob->id.name + 2, active_mat_slot, prev_mat->id.name + 2); | |||||
| } | |||||
| else { | |||||
| const char *tooltip = TIP_("Drop %s on %s (slot %d)."); | |||||
| return BLI_sprintfN(tooltip, name, ob->id.name + 2, active_mat_slot); | |||||
| } | |||||
| } | |||||
| static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Base *base = ED_view3d_give_base_under_cursor(C, event->mval); | Base *base = ED_view3d_give_base_under_cursor(C, event->mval); | ||||
| Material *ma; | Material *ma; | ||||
| char name[MAX_ID_NAME - 2]; | char name[MAX_ID_NAME - 2]; | ||||
| RNA_string_get(op->ptr, "name", name); | RNA_string_get(op->ptr, "name", name); | ||||
| ▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines | |||||
Can we just return NULL here?