Fix #123179: can't select multiple snap target elements in UV Editor
Missed after 'Set Snap Base' commit. Just like in 3D View, UV editing can also benefit from selecting multiple snap target elements. The C++ code was already done, it was only necessary to edit the interface. Pull Request: https://projects.blender.org/blender/blender/pulls/124986
This commit is contained in:
committed by
Philipp Oeser
parent
55286169c7
commit
ab6bddad4f
@@ -789,10 +789,13 @@ class IMAGE_HT_header(Header):
|
||||
tool_settings = context.tool_settings
|
||||
|
||||
# Snap.
|
||||
snap_uv_element = tool_settings.snap_uv_element
|
||||
try:
|
||||
act_snap_icon = tool_settings.bl_rna.properties["snap_uv_element"].enum_items[snap_uv_element].icon
|
||||
except KeyError:
|
||||
snap_uv_elements = tool_settings.snap_uv_element
|
||||
if len(snap_uv_elements) == 1:
|
||||
text = ""
|
||||
elem = next(iter(snap_uv_elements))
|
||||
act_snap_icon = tool_settings.bl_rna.properties["snap_uv_element"].enum_items[elem].icon
|
||||
else:
|
||||
text = iface_("Mix", i18n_contexts.id_image)
|
||||
act_snap_icon = 'NONE'
|
||||
|
||||
row = layout.row(align=True)
|
||||
@@ -802,7 +805,7 @@ class IMAGE_HT_header(Header):
|
||||
sub.popover(
|
||||
panel="IMAGE_PT_snapping",
|
||||
icon=act_snap_icon,
|
||||
text="",
|
||||
text=text,
|
||||
)
|
||||
|
||||
# Proportional Editing
|
||||
@@ -1014,10 +1017,10 @@ class IMAGE_PT_snapping(Panel):
|
||||
col.label(text="Snap Target")
|
||||
col.prop(tool_settings, "snap_uv_element", expand=True)
|
||||
|
||||
if tool_settings.snap_uv_element != 'INCREMENT':
|
||||
col.label(text="Snap Base")
|
||||
row = col.row(align=True)
|
||||
row.prop(tool_settings, "snap_target", expand=True)
|
||||
col.label(text="Snap Base")
|
||||
row = col.row(align=True)
|
||||
row.active = bool(tool_settings.snap_uv_element.difference({'INCREMENT', 'GRID'}))
|
||||
row.prop(tool_settings, "snap_target", expand=True)
|
||||
|
||||
col.separator()
|
||||
|
||||
|
||||
@@ -1240,6 +1240,7 @@ static void snap_target_uv_fn(TransInfo *t, float * /*vec*/)
|
||||
{
|
||||
t->tsnap.snap_target[0] *= t->aspect[0];
|
||||
t->tsnap.snap_target[1] *= t->aspect[1];
|
||||
t->tsnap.target_type = SCE_SNAP_TO_EDGE_ENDPOINT;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,6 +767,14 @@ static void rna_ToolSettings_snap_mode_set(PointerRNA *ptr, int value)
|
||||
}
|
||||
}
|
||||
|
||||
static void rna_ToolSettings_snap_uv_mode_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
ToolSettings *ts = static_cast<ToolSettings *>(ptr->data);
|
||||
if (value != 0) {
|
||||
ts->snap_uv_mode = value;
|
||||
}
|
||||
}
|
||||
|
||||
/* Grease Pencil update cache */
|
||||
static void rna_GPencil_update(Main * /*bmain*/, Scene *scene, PointerRNA * /*ptr*/)
|
||||
{
|
||||
@@ -3666,7 +3674,8 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
||||
/* image editor uses its own set of snap modes */
|
||||
prop = RNA_def_property(srna, "snap_uv_element", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "snap_uv_mode");
|
||||
RNA_def_property_flag(prop, PROP_DEG_SYNC_ONLY);
|
||||
RNA_def_property_flag(prop, PROP_DEG_SYNC_ONLY | PROP_ENUM_FLAG);
|
||||
RNA_def_property_enum_funcs(prop, nullptr, "rna_ToolSettings_snap_uv_mode_set", nullptr);
|
||||
RNA_def_property_enum_items(prop, snap_uv_element_items);
|
||||
RNA_def_property_ui_text(prop, "Snap UV Element", "Type of element to snap to");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, nullptr); /* header redraw */
|
||||
|
||||
Reference in New Issue
Block a user