Page MenuHome

UV: Add grid shape source to the UV editor, and add new "pixel" option.
ClosedPublic

Authored by Chris Blackbourn (chrisbblend) on Oct 9 2022, 1:57 AM.

Details

Summary

This change is part of a wider set of changes to implement Grid and Pixel snapping in the UV Editor. This particular change adds a new third option, pixel grid, to the previous grid options, dynamic grid and fixed grid.

Maniphest Tasks : T78391
--8<---
Reviewer notes:

  • I can't get the layout in space_image.py to align correctly. See also: D16040
  • Can you also double check the change to versioning_300.cc

Diff Detail

Repository
rB Blender

Event Timeline

Chris Blackbourn (chrisbblend) requested review of this revision.Oct 9 2022, 1:57 AM
Chris Blackbourn (chrisbblend) created this revision.
Chris Blackbourn (chrisbblend) edited the summary of this revision. (Show Details)

Generally LGTM, the UI layout was a bit odd, suggested 2 alternatives.

Accepting as with minor requests.

release/scripts/startup/bl_ui/space_image.py
1521–1557

The layout feels like an awkward mix with use_property_split used in some places but not others.

class IMAGE_PT_overlay_guides(Panel):
    bl_space_type = 'IMAGE_EDITOR'
    bl_region_type = 'HEADER'
    bl_label = "Guides"
    bl_parent_id = 'IMAGE_PT_overlay'

    @classmethod
    def poll(cls, context):
        sima = context.space_data

        return sima.show_uvedit

    def draw(self, context):
        layout = self.layout

        sima = context.space_data
        overlay = sima.overlay
        uvedit = sima.uv_editor

        layout.active = overlay.show_overlays

        row = layout.row()
        row.prop(overlay, "show_grid_background", text="Grid")

        if overlay.show_grid_background:
            sub = row.row()
            sub.prop(uvedit, "show_grid_over_image", text="Over Image")
            sub.active = sima.image is not None

            layout.row().prop(uvedit, "grid_shape_source", expand=True)

            layout.use_property_split = True
            layout.use_property_decorate = False

            row = layout.row()
            row.prop(uvedit, "custom_grid_subdivisions", text="Fixed Subdivisions")
            row.active = uvedit.grid_shape_source == 'FIXED'

            layout.prop(uvedit, "tile_grid_shape", text="Tiles")

This expands the "Shape Source" vertically, using more space (I'd prefer the previous version but both are OK).

class IMAGE_PT_overlay_guides(Panel):
    bl_space_type = 'IMAGE_EDITOR'
    bl_region_type = 'HEADER'
    bl_label = "Guides"
    bl_parent_id = 'IMAGE_PT_overlay'

    @classmethod
    def poll(cls, context):
        sima = context.space_data

        return sima.show_uvedit

    def draw(self, context):
        layout = self.layout

        sima = context.space_data
        overlay = sima.overlay
        uvedit = sima.uv_editor

        layout.active = overlay.show_overlays

        row = layout.row()
        row.prop(overlay, "show_grid_background", text="Grid")

        if overlay.show_grid_background:
            sub = row.row()
            sub.prop(uvedit, "show_grid_over_image", text="Over Image")
            sub.active = sima.image is not None

            layout.use_property_split = True
            layout.use_property_decorate = False

            layout.prop(uvedit, "grid_shape_source", expand=True, text="Shape Source")

            row = layout.row()
            row.prop(uvedit, "custom_grid_subdivisions", text="Fixed Subdivisions")
            row.active = uvedit.grid_shape_source == 'FIXED'

            row = layout.row()
            row.prop(uvedit, "tile_grid_shape", text="Tiles")
source/blender/draw/engines/overlay/overlay_grid.cc
62

grid_shape_source should be compared with SI_GRID_SHAPE_DYNAMIC for clarity.

This revision is now accepted and ready to land.Oct 11 2022, 3:18 AM

While testing this patch I noticed an issue. Currently pixel with "Over Image" enabled entirely covers the image when viewed 1:1. While it makes sense I don't think it's useful behavior. Perhaps as the zoom level approaches 1:1, the grid could fade out.

Whatever the case I don't consider it a blocking issue, users who enable this most likely work zoomed in, even so... showing 100% grey when zoomed out is a bit odd.