diff options
author | Antonioya <blendergit@gmail.com> | 2018-10-09 00:21:44 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-10-09 00:21:44 +0300 |
commit | 11877e5bec4c590e51565c7e6191b33957dddc1c (patch) | |
tree | 1dd7fd16218169ac68069b779ec47eb3c665ea65 | |
parent | e1293da01404ce2ae865e8a184c444715f747431 (diff) |
GP: New Canvas offset parameters
Now the canvas can me moved in X/Y axis.
4 files changed, 22 insertions, 12 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py index 627d9c4349f..72d493297eb 100644 --- a/release/scripts/startup/bl_ui/properties_data_gpencil.py +++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py @@ -365,6 +365,7 @@ class DATA_PT_gpencil_canvas(DataButtonsPanel, Panel): col = row.column() col.prop(grid, "color") col.prop(grid, "scale") + col.prop(grid, "offset") row = layout.row(align=True) col = row.column() col.prop(grid, "lines", text="Subdivisions") diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c index 8957e641e99..8e7d16e60ba 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c @@ -703,6 +703,7 @@ GPUBatch *DRW_gpencil_get_grid(Object *ob) const float grid_h = gpd->grid.scale[1] * ED_scene_grid_scale(scene, &grid_unit); const float space_w = (grid_w / gridlines); const float space_h = (grid_h / gridlines); + const float offset[2] = { gpd->grid.offset[0], gpd->grid.offset[1] }; const uint vertex_len = 2 * (gridlines * 4 + 2); @@ -722,34 +723,34 @@ GPUBatch *DRW_gpencil_get_grid(Object *ob) const float line_w = a * space_w; const float line_h = a * space_h; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, -grid_w, -line_h, axis); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, -grid_w + offset[0], -line_h + offset[1], axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, +grid_w, -line_h, axis); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, +grid_w + offset[0], -line_h + offset[1], axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, -grid_w, +line_h, axis); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, -grid_w + offset[0], +line_h + offset[1], axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, +grid_w, +line_h, axis); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, +grid_w + offset[0], +line_h + offset[1], axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, -line_w, -grid_h, axis); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, -line_w + offset[0], -grid_h + offset[1], axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, -line_w, +grid_h, axis); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, -line_w + offset[0], +grid_h + offset[1], axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, +line_w, -grid_h, axis); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, +line_w + offset[0], -grid_h + offset[1], axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, +line_w, +grid_h, axis); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, +line_w + offset[0], +grid_h + offset[1], axis); idx++; } /* center lines */ if (do_center) { - set_grid_point(vbo, idx, col_grid, pos_id, color_id, -grid_w, 0.0f, axis); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, -grid_w + offset[0], 0.0f + offset[1], axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, +grid_w, 0.0f, axis); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, +grid_w + offset[0], 0.0f + offset[1], axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, 0.0f, -grid_h, axis); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, 0.0f + offset[0], -grid_h + offset[1], axis); idx++; - set_grid_point(vbo, idx, col_grid, pos_id, color_id, 0.0f, +grid_h, axis); + set_grid_point(vbo, idx, col_grid, pos_id, color_id, 0.0f + offset[0], +grid_h + offset[1], axis); idx++; } return GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO); diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index 8465d1634a4..6223e456241 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -328,6 +328,7 @@ typedef struct bGPdata_Runtime { typedef struct bGPgrid { float color[3]; float scale[2]; + float offset[2]; char _pad1[4]; int lines; diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index d5717a06eda..a02868622e4 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -1279,6 +1279,13 @@ static void rna_def_gpencil_grid(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Grid Subdivisions", "Number of subdivisions in each side of symmetry line"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_XYZ); + RNA_def_property_float_sdna(prop, NULL, "offset"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Offset", "Offset of the canvas"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "axis"); RNA_def_property_enum_items(prop, rna_enum_gpencil_grid_axis_items); |