Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2021-08-04 09:58:19 +0300
committerJeroen Bakker <jeroen@blender.org>2021-08-04 09:58:39 +0300
commiteffc0487106bc74590acf35a61541597b1149daa (patch)
tree893cd6d82930879d3e0e2734ce66243f4042f72d /source/blender/editors/object/object_relations.c
parentcd92b2350fc20f6c91128881b5fd20dd173d2308 (diff)
T90371: Asset: Drop Material Tooltip.
This patch changes the drop named material tooltip to give feedback to the user what is going to happen when they invoke the change. There are 3 states: * "": Operator will be canceled as not all data is present (dropping on background.) * "Drop <named material> on <object name> (slot <slot number>, replacing <current material in slot>). * "Drop <named material> on <object name> (slot <slot number). Reviewed By: Severin Maniphest Tasks: T90371 Differential Revision: https://developer.blender.org/D12106
Diffstat (limited to 'source/blender/editors/object/object_relations.c')
-rw-r--r--source/blender/editors/object/object_relations.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index f576c0c8517..92d0deb49d0 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2723,6 +2723,35 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot)
/** \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);
+
+ char name[MAX_ID_NAME - 2];
+ RNA_string_get(properties, "name", name);
+
+ if (base == 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);
+
+ char *result;
+ if (prev_mat) {
+ const char *tooltip = TIP_("Drop %s on %s (slot %d, replacing %s).");
+ result = 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).");
+ result = BLI_sprintfN(tooltip, name, ob->id.name + 2, active_mat_slot);
+ }
+ return result;
+}
+
static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Main *bmain = CTX_data_main(C);