UDIM: Move UDIM grid controls to the Overlay panel
This change moves the grid panel UI from the View tab up into the Overlay panel. Reasons to move to the Overlay panel include: - Consistency with the grid options in the 3D viewport - The grid has been drawn as an Overlay for quite some time already Additional changes that now make sense to have: - The grid responds to the main Overlay show/hide toggle - Adds a toggle to show/hide the grid which is consistent with overlays in general As before, these grid controls are only available for active UV edit sessions. Differential Revision: https://developer.blender.org/D11862
This commit is contained in:
parent
502d16e667
commit
92c89d7b87
Notes:
blender-bot
2023-02-13 19:09:32 +01:00
Referenced by issue #90913, UDIM grid changes and enhancements Referenced by issue #86873, UV Editor UDIM GRID disappear when add new image
|
@ -1453,58 +1453,6 @@ class IMAGE_PT_uv_cursor(Panel):
|
|||
col.prop(sima, "cursor_location", text="Location")
|
||||
|
||||
|
||||
class IMAGE_PT_udim_grid(Panel):
|
||||
bl_space_type = 'IMAGE_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
bl_category = "View"
|
||||
bl_label = "UDIM Grid"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sima = context.space_data
|
||||
|
||||
return sima.show_uvedit
|
||||
|
||||
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, "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'
|
||||
bl_region_type = 'HEADER'
|
||||
|
@ -1515,6 +1463,49 @@ class IMAGE_PT_overlay(Panel):
|
|||
pass
|
||||
|
||||
|
||||
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_el = row.column()
|
||||
row_el.prop(overlay, "show_grid_background", text="Grid")
|
||||
|
||||
if overlay.show_grid_background:
|
||||
layout.use_property_split = True
|
||||
col = layout.column(align=False, heading="Fixed Subdivisions")
|
||||
col.use_property_decorate = False
|
||||
|
||||
row = col.row(align=True)
|
||||
sub = row.row(align=True)
|
||||
sub.prop(uvedit, "use_custom_grid", text="")
|
||||
sub = sub.row(align=True)
|
||||
sub.active = uvedit.use_custom_grid
|
||||
sub.prop(uvedit, "custom_grid_subdivisions", text="")
|
||||
|
||||
row = layout.row()
|
||||
row.use_property_split = True
|
||||
row.use_property_decorate = False
|
||||
row.prop(uvedit, "tile_grid_shape", text="Tiles")
|
||||
|
||||
|
||||
class IMAGE_PT_overlay_uv_edit(Panel):
|
||||
bl_space_type = 'IMAGE_EDITOR'
|
||||
bl_region_type = 'HEADER'
|
||||
|
@ -1689,9 +1680,8 @@ classes = (
|
|||
IMAGE_PT_scope_sample,
|
||||
IMAGE_PT_uv_cursor,
|
||||
IMAGE_PT_annotation,
|
||||
IMAGE_PT_udim_grid,
|
||||
IMAGE_PT_custom_grid,
|
||||
IMAGE_PT_overlay,
|
||||
IMAGE_PT_overlay_guides,
|
||||
IMAGE_PT_overlay_uv_edit,
|
||||
IMAGE_PT_overlay_uv_edit_geometry,
|
||||
IMAGE_PT_overlay_texture_paint,
|
||||
|
|
|
@ -25,7 +25,7 @@ extern "C" {
|
|||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 11
|
||||
#define BLENDER_FILE_SUBVERSION 12
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and show a warning if the file
|
||||
|
|
|
@ -2567,9 +2567,7 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 302, 10)) {
|
||||
/* While vertex-colors were experimental the smear tool became corrupt due
|
||||
* to bugs in the wm_toolsystem API (auto-creation of sculpt brushes
|
||||
* was broken). Go through and reset all smear brushes. */
|
||||
|
@ -2637,17 +2635,18 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
* \note Be sure to check when bumping the version:
|
||||
* - "versioning_userdef.c", #blo_do_versions_userdef
|
||||
* - "versioning_userdef.c", #do_versions_theme
|
||||
*
|
||||
* \note Keep this message at the bottom of the function.
|
||||
*/
|
||||
{
|
||||
/* Keep this block, even when empty. */
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 302, 12)) {
|
||||
/* UV/Image show background grid option. */
|
||||
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
|
||||
if (space->spacetype == SPACE_IMAGE) {
|
||||
SpaceImage *sima = (SpaceImage *)space;
|
||||
sima->overlay.flag |= SI_OVERLAY_SHOW_GRID_BACKGROUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Add node storage for the merge by distance node. */
|
||||
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
|
||||
|
@ -2666,4 +2665,17 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
FOREACH_NODETREE_END;
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
* \note Be sure to check when bumping the version:
|
||||
* - "versioning_userdef.c", #blo_do_versions_userdef
|
||||
* - "versioning_userdef.c", #do_versions_theme
|
||||
*
|
||||
* \note Keep this message at the bottom of the function.
|
||||
*/
|
||||
{
|
||||
/* Keep this block, even when empty. */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,20 +49,29 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata)
|
|||
if (pd->space_type == SPACE_IMAGE) {
|
||||
SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;
|
||||
View2D *v2d = &draw_ctx->region->v2d;
|
||||
if (sima->mode == SI_MODE_UV || !ED_space_image_has_buffer(sima)) {
|
||||
shd->grid_flag = GRID_BACK | PLANE_IMAGE | SHOW_GRID;
|
||||
}
|
||||
else {
|
||||
shd->grid_flag = 0;
|
||||
|
||||
/* Only UV Edit mode has the various Overlay options for now. */
|
||||
const bool is_uv_edit = sima->mode == SI_MODE_UV;
|
||||
|
||||
const bool background_enabled = is_uv_edit ? (!pd->hide_overlays &&
|
||||
(sima->overlay.flag &
|
||||
SI_OVERLAY_SHOW_GRID_BACKGROUND) != 0) :
|
||||
true;
|
||||
if (background_enabled) {
|
||||
shd->grid_flag = GRID_BACK | PLANE_IMAGE;
|
||||
}
|
||||
|
||||
if (sima->flag & SI_CUSTOM_GRID) {
|
||||
shd->grid_flag |= CUSTOM_GRID;
|
||||
const bool draw_grid = is_uv_edit || !ED_space_image_has_buffer(sima);
|
||||
if (background_enabled && draw_grid) {
|
||||
shd->grid_flag |= SHOW_GRID;
|
||||
if (is_uv_edit && (sima->flag & SI_CUSTOM_GRID) != 0) {
|
||||
shd->grid_flag |= CUSTOM_GRID;
|
||||
}
|
||||
}
|
||||
|
||||
shd->grid_distance = 1.0f;
|
||||
copy_v3_fl3(shd->grid_size, 1.0f, 1.0f, 1.0f);
|
||||
if (sima->mode == SI_MODE_UV) {
|
||||
if (is_uv_edit) {
|
||||
shd->grid_size[0] = (float)sima->tile_grid_shape[0];
|
||||
shd->grid_size[1] = (float)sima->tile_grid_shape[1];
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ static SpaceLink *image_create(const ScrArea *UNUSED(area), const Scene *UNUSED(
|
|||
simage->lock = true;
|
||||
simage->flag = SI_SHOW_GPENCIL | SI_USE_ALPHA | SI_COORDFLOATS;
|
||||
simage->uv_opacity = 1.0f;
|
||||
simage->overlay.flag = SI_OVERLAY_SHOW_OVERLAYS;
|
||||
simage->overlay.flag = SI_OVERLAY_SHOW_OVERLAYS | SI_OVERLAY_SHOW_GRID_BACKGROUND;
|
||||
|
||||
BKE_imageuser_default(&simage->iuser);
|
||||
simage->iuser.flag = IMA_SHOW_STEREO | IMA_ANIM_ALWAYS | IMA_SHOW_MAX_RESOLUTION;
|
||||
|
|
|
@ -1318,6 +1318,7 @@ typedef enum eSpaceImage_Flag {
|
|||
|
||||
typedef enum eSpaceImageOverlay_Flag {
|
||||
SI_OVERLAY_SHOW_OVERLAYS = (1 << 0),
|
||||
SI_OVERLAY_SHOW_GRID_BACKGROUND = (1 << 1),
|
||||
} eSpaceImageOverlay_Flag;
|
||||
|
||||
/** Keep in sync with `STEPS_LEN` in `grid_frag.glsl`. */
|
||||
|
|
|
@ -3497,7 +3497,7 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Display Faces", "Display faces over the image");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "tile_grid_shape", PROP_INT, PROP_NONE);
|
||||
prop = RNA_def_property(srna, "tile_grid_shape", PROP_INT, PROP_XYZ);
|
||||
RNA_def_property_int_sdna(prop, NULL, "tile_grid_shape");
|
||||
RNA_def_property_array(prop, 2);
|
||||
RNA_def_property_int_default(prop, 1);
|
||||
|
@ -5264,6 +5264,11 @@ static void rna_def_space_image_overlay(BlenderRNA *brna)
|
|||
prop = RNA_def_property(srna, "show_overlays", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", SI_OVERLAY_SHOW_OVERLAYS);
|
||||
RNA_def_property_ui_text(prop, "Show Overlays", "Display overlays like UV Maps and Metadata");
|
||||
|
||||
prop = RNA_def_property(srna, "show_grid_background", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", SI_OVERLAY_SHOW_GRID_BACKGROUND);
|
||||
RNA_def_property_ui_text(prop, "Display Background", "Show the grid background and borders");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
|
||||
}
|
||||
|
||||
static void rna_def_space_image(BlenderRNA *brna)
|
||||
|
|
Loading…
Reference in New Issue