From bf06f76be6316be92a4655a41391e163d2fb1221 Mon Sep 17 00:00:00 2001 From: Siddhartha Jejurkar Date: Wed, 29 Sep 2021 17:47:32 +1000 Subject: UV Editor: Grid and snapping improvements Implements T89789, T89792, custom grid (described as dynamic grid in T78389) and UV grid snapping (T78391) Replaces the default UV editor grid with 2 new types of grid : * Custom grid: Allows the user to create an NxN grid, where the value of N is specified by the user. * Subdividing grid: Subdivides the UV editor grid when the user zooms in the viewport and vice versa when zooming out. UV snapping improvements : * Increment snapping: Increment values for snapping are calculated based on which grid type is being used in the UV editor (subdividing or custom). In general the increment value is equal to the distance between 2 visible grid lines. * Absolute grid snap: New toggle added to increment snapping option in the UV editor, allows UV grid snapping during translation. Reviewed By: campbellbarton Ref D12684 --- release/scripts/startup/bl_ui/space_image.py | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'release/scripts/startup/bl_ui/space_image.py') diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 3ee668888f3..797d0c62b72 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -934,6 +934,10 @@ class IMAGE_PT_snapping(Panel): row = col.row(align=True) row.prop(tool_settings, "snap_target", expand=True) + col.separator() + if 'INCREMENT' in tool_settings.snap_uv_element: + col.prop(tool_settings, "use_snap_uv_grid_absolute") + col.label(text="Affect") row = col.row(align=True) row.prop(tool_settings, "use_snap_translate", text="Move", toggle=True) @@ -1467,6 +1471,33 @@ class IMAGE_PT_udim_grid(Panel): col = layout.column() col.prop(uvedit, "tile_grid_shape", text="Grid Shape") +class IMAGE_PT_custom_grid(Panel): + bl_space_type = 'IMAGE_EDITOR' + bl_region_type = 'UI' + bl_category = "View" + bl_label = "Custom Grid" + + @classmethod + def poll(cls, context): + sima = context.space_data + return sima.show_uvedit + + def draw_header(self, context): + sima = context.space_data + uvedit = sima.uv_editor + self.layout.prop(uvedit, "use_custom_grid", text="") + + def draw(self, context): + layout = self.layout + + sima = context.space_data + uvedit = sima.uv_editor + + layout.use_property_split = True + layout.use_property_decorate = False + + col = layout.column() + col.prop(uvedit, "custom_grid_subdivisions", text="Subdivisions") class IMAGE_PT_overlay(Panel): bl_space_type = 'IMAGE_EDITOR' @@ -1652,6 +1683,7 @@ classes = ( IMAGE_PT_uv_cursor, IMAGE_PT_annotation, IMAGE_PT_udim_grid, + IMAGE_PT_custom_grid, IMAGE_PT_overlay, IMAGE_PT_overlay_uv_edit, IMAGE_PT_overlay_uv_edit_geometry, -- cgit v1.2.3