[Bf-blender-cvs] [19db478bc5b] temp-udim-images: Add tiled grid drawing option when no image is loaded
Lukas Stockner
noreply at git.blender.org
Wed Jun 27 23:53:22 CEST 2018
Commit: 19db478bc5b7f49dd803720d7a2de390f68702f3
Author: Lukas Stockner
Date: Thu Jun 28 00:59:30 2018 +0200
Branches: temp-udim-images
https://developer.blender.org/rB19db478bc5b7f49dd803720d7a2de390f68702f3
Add tiled grid drawing option when no image is loaded
===================================================================
M release/scripts/startup/bl_ui/space_image.py
M source/blender/blenloader/intern/versioning_280.c
M source/blender/editors/space_image/image_draw.c
M source/blender/editors/space_image/space_image.c
M source/blender/makesdna/DNA_space_types.h
M source/blender/makesrna/intern/rna_space.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index 6ce8c361f6d..182a796543c 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -724,6 +724,10 @@ class IMAGE_PT_view_properties(Panel):
row.active = uvedit.show_other_objects
row.prop(uvedit, "other_uv_filter", text="Filter")
+ if ima is None:
+ row = layout.row()
+ row.prop(uvedit, "tile_grid_shape", text="Grid Shape")
+
class IMAGE_UL_render_slots(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 6f132b14ab1..14686800d15 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1539,6 +1539,20 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
BLI_addtail(&ima->tiles, tile);
}
}
+
+ if (!DNA_struct_elem_find(fd->filesdna, "SpaceImage", "int", "tile_grid_shape[2]")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_IMAGE) {
+ SpaceImage *sima = (SpaceImage *)sl;
+ sima->tile_grid_shape[0] = 1;
+ sima->tile_grid_shape[1] = 1;
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 22fc843d7db..6091b4587cb 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -656,11 +656,9 @@ static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scen
}
static void draw_udim_tile_grid(unsigned int pos_attr, unsigned int color_attr,
- ARegion *ar, int tile_number,
+ ARegion *ar, int x, int y,
float stepx, float stepy, const float color[3])
{
- int x = tile_number % 10;
- int y = tile_number / 10;
float x1, y1;
UI_view2d_view_to_region_fl(&ar->v2d, x, y, &x1, &y1);
int gridpos[5][2] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}};
@@ -672,42 +670,58 @@ static void draw_udim_tile_grid(unsigned int pos_attr, unsigned int color_attr,
}
}
-static bool draw_image_udim_grid(ARegion *ar, SpaceImage *sima, float zoomx, float zoomy, bool draw_tilegrids)
+static void draw_image_tiles(ARegion *ar, SpaceImage *sima, Image *ima)
{
- Image *ima = ED_space_image(sima);
-
- float stepx = BLI_rcti_size_x(&ar->v2d.mask) / BLI_rctf_size_x(&ar->v2d.cur);
- float stepy = BLI_rcti_size_y(&ar->v2d.mask) / BLI_rctf_size_y(&ar->v2d.cur);
+ int num_tiles;
+ if (ima) {
+ num_tiles = BLI_listbase_count(&ima->tiles);
+ }
+ else {
+ num_tiles = sima->tile_grid_shape[0] * sima->tile_grid_shape[1];
+ }
- if (draw_tilegrids) {
- LISTBASE_FOREACH(ImageTile*, tile, &ima->tiles) {
- int x = tile->tile_number % 10;
- int y = tile->tile_number / 10;
- ED_region_grid_draw(ar, zoomx, zoomy, x, y);
- }
+ if (num_tiles == 1) {
+ return;
}
+ float stepx = BLI_rcti_size_x(&ar->v2d.mask) / BLI_rctf_size_x(&ar->v2d.cur);
+ float stepy = BLI_rcti_size_y(&ar->v2d.mask) / BLI_rctf_size_y(&ar->v2d.cur);
+
Gwn_VertFormat *format = immVertexFormat();
unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
unsigned color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- int num_tiles = BLI_listbase_count(&ima->tiles);
- immBegin(GWN_PRIM_LINES, 8*(num_tiles + 1));
+ immBegin(GWN_PRIM_LINES, 8*num_tiles);
float theme_color[3], selected_color[3];
- UI_GetThemeColorShade3fv(TH_BACK, 20.0f, theme_color);
+ UI_GetThemeColorShade3fv(TH_BACK, 60.0f, theme_color);
UI_GetThemeColor3fv(TH_FACE_SELECT, selected_color);
- LISTBASE_FOREACH(ImageTile*, tile, &ima->tiles) {
- draw_udim_tile_grid(pos, color, ar, tile->tile_number, stepx, stepy, theme_color);
- }
- draw_udim_tile_grid(pos, color, ar, sima->curtile, stepx, stepy, selected_color);
+ if (ima) {
+ LISTBASE_FOREACH(ImageTile*, tile, &ima->tiles) {
+ int x = tile->tile_number % 10;
+ int y = tile->tile_number / 10;
+ draw_udim_tile_grid(pos, color, ar, x, y, stepx, stepy, theme_color);
+ }
+ }
+ else {
+ for (int y = 0; y < sima->tile_grid_shape[1]; y++) {
+ for (int x = 0; x < sima->tile_grid_shape[0]; x++) {
+ draw_udim_tile_grid(pos, color, ar, x, y, stepx, stepy, theme_color);
+ }
+ }
+ }
+
+ if (num_tiles > 1) {
+ int cur_x = sima->curtile % 10, cur_y = sima->curtile / 10;
+ draw_udim_tile_grid(pos, color, ar, cur_x, cur_y, stepx, stepy, selected_color);
+ }
immEnd();
immUnbindProgram();
- return true;
+ return;
}
/* draw main image region */
@@ -776,11 +790,19 @@ void draw_image_main(const bContext *C, ARegion *ar)
/* draw the image or grid */
if (ibuf == NULL) {
- if (ima && ima->source == IMA_SRC_TILED) {
- draw_image_udim_grid(ar, sima, zoomx, zoomy, true);
+ if (ima) {
+ LISTBASE_FOREACH(ImageTile*, tile, &ima->tiles) {
+ int x = tile->tile_number % 10;
+ int y = tile->tile_number / 10;
+ ED_region_grid_draw(ar, zoomx, zoomy, x, y);
+ }
}
else {
- ED_region_grid_draw(ar, zoomx, zoomy, 0.0f, 0.0f);
+ for (int y = 0; y < sima->tile_grid_shape[1]; y++) {
+ for (int x = 0; x < sima->tile_grid_shape[0]; x++) {
+ ED_region_grid_draw(ar, zoomx, zoomy, x, y);
+ }
+ }
}
}
else {
@@ -819,9 +841,10 @@ void draw_image_main(const bContext *C, ARegion *ar)
}
ED_space_image_release_buffer(sima, ibuf, lock);
}
- draw_image_udim_grid(ar, sima, zoomx, zoomy, false);
}
+ draw_image_tiles(ar, sima, ima);
+
/* paint helpers */
if (show_paint)
draw_image_paint_helpers(C, ar, scene, zoomx, zoomy);
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 56de78049a4..13564db1dd2 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -182,6 +182,9 @@ static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(sce
scopes_new(&simage->scopes);
simage->sample_line_hist.height = 100;
+ simage->tile_grid_shape[0] = 1;
+ simage->tile_grid_shape[1] = 1;
+
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for image");
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index bbfbf660774..d02cb8fc422 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -930,6 +930,8 @@ typedef struct SpaceImage {
int flag;
+ int tile_grid_shape[2];
+
MaskSpaceInfo mask_info;
} SpaceImage;
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 2ab77d1dda8..b8512db9b8b 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2179,6 +2179,14 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Draw Modified Edges", "Draw edges after modifiers are applied");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
+ prop = RNA_def_property(srna, "tile_grid_shape", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "tile_grid_shape");
+ RNA_def_property_array(prop, 2);
+ RNA_def_property_int_default(prop, 1);
+ RNA_def_property_range(prop, 1, 10);
+ RNA_def_property_ui_text(prop, "Tile Grid Shape", "How many tiles will be shown in the background");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
+
prop = RNA_def_property(srna, "show_other_objects", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_OTHER);
RNA_def_property_ui_text(prop, "Draw Other Objects", "Draw other selected objects that share the same image");
More information about the Bf-blender-cvs
mailing list