GP: New Canvas offset parameters
authorAntonioya <blendergit@gmail.com>
Mon, 8 Oct 2018 21:21:44 +0000 (23:21 +0200)
committerAntonioya <blendergit@gmail.com>
Mon, 8 Oct 2018 21:21:44 +0000 (23:21 +0200)
Now the canvas can me moved in X/Y axis.

release/scripts/startup/bl_ui/properties_data_gpencil.py
source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
source/blender/makesdna/DNA_gpencil_types.h
source/blender/makesrna/intern/rna_gpencil.c

index 627d9c4349f6237d54e2ae1dc9a83acaf0fb2da7..72d493297eb687933ec498a3002c967ba6a15329 100644 (file)
@@ -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")
index 8957e641e99047a5c86bcbed828dab51c06eeb3e..8e7d16e60bab620f0ab66b3d4a0db987a47f82c2 100644 (file)
@@ -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);
index 8465d1634a448ae1de09574e5812bc50fc29ad12..6223e45624175f4234c16348c14db2a340c9c936 100644 (file)
@@ -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;
index d5717a06eda74076c8bcfe493cfa2925c59dc1d1..a02868622e4cef9720469ca9e0429181b5ff5673 100644 (file)
@@ -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);