diff options
-rw-r--r-- | release/scripts/startup/bl_ui/space_node.py | 5 | ||||
-rw-r--r-- | source/blender/editors/include/UI_view2d.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 48 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_draw.c | 4 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 5 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 2 |
6 files changed, 63 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index 70f0f300f86..d7f25a597ed 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -32,6 +32,7 @@ class NODE_HT_header(Header): snode = context.space_data snode_id = snode.id id_from = snode.id_from + toolsettings = context.tool_settings row = layout.row(align=True) row.template_header() @@ -86,6 +87,10 @@ class NODE_HT_header(Header): layout.separator() + # Snap + row = layout.row(align=True) + row.prop(toolsettings, "use_snap", text="") + layout.template_running_jobs() diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 469388219d6..5039a30b61a 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -166,6 +166,7 @@ void UI_view2d_view_restore(const struct bContext *C); View2DGrid *UI_view2d_grid_calc(struct Scene *scene, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp, int winx, int winy); void UI_view2d_grid_draw(struct View2D *v2d, View2DGrid *grid, int flag); void UI_view2d_constant_grid_draw(struct View2D *v2d); +void UI_view2d_multi_grid_draw(struct View2D *v2d, float step, int level_size, int totlevels); void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy); void UI_view2d_grid_free(View2DGrid *grid); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 51e1b30f0bf..9a783b461a0 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1328,6 +1328,54 @@ void UI_view2d_constant_grid_draw(View2D *v2d) glEnd(); } +/* Draw a multi-level grid in given 2d-region */ +void UI_view2d_multi_grid_draw(View2D *v2d, float step, int level_size, int totlevels) +{ + int offset = -10; + float lstep = step; + int level; + + for (level = 0; level < totlevels; ++level) { + int i; + float start; + + UI_ThemeColorShade(TH_BACK, offset); + + i = (v2d->cur.xmin >= 0.0f ? -(int)(-v2d->cur.xmin / lstep) : (int)(v2d->cur.xmin / lstep)); + start = i * lstep; + + glBegin(GL_LINES); + for (; start < v2d->cur.xmax; start += lstep, ++i) { + if (i == 0 || (level < totlevels-1 && i % level_size == 0)) + continue; + glVertex2f(start, v2d->cur.ymin); + glVertex2f(start, v2d->cur.ymax); + } + + i = (v2d->cur.ymin >= 0.0f ? -(int)(-v2d->cur.ymin / lstep) : (int)(v2d->cur.ymin / lstep)); + start = i * lstep; + + for (; start < v2d->cur.ymax; start += lstep, ++i) { + if (i == 0 || (level < totlevels-1 && i % level_size == 0)) + continue; + glVertex2f(v2d->cur.xmin, start); + glVertex2f(v2d->cur.xmax, start); + } + + /* X and Y axis */ + UI_ThemeColorShade(TH_BACK, offset-8); + glVertex2f(0.0f, v2d->cur.ymin); + glVertex2f(0.0f, v2d->cur.ymax); + glVertex2f(v2d->cur.xmin, 0.0f); + glVertex2f(v2d->cur.xmax, 0.0f); + + glEnd(); + + lstep *= level_size; + offset -= 6; + } +} + /* the price we pay for not exposting structs :( */ void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy) { diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index c65bbd6e15f..f9aa0dfd582 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -1095,7 +1095,9 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) snode->aspect= (v2d->cur.xmax - v2d->cur.xmin)/((float)ar->winx); // XXX snode->curfont= uiSetCurFont_ext(snode->aspect); - UI_view2d_constant_grid_draw(v2d); + /* grid */ + UI_view2d_multi_grid_draw(v2d, 25.0f, 5, 2); + /* backdrop */ draw_nodespace_back_pix(ar, snode, color_manage); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 9965214af6f..4dee3514142 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -3542,6 +3542,11 @@ void initTranslation(TransInfo *t) t->snap[1] = 0.125f; t->snap[2] = 0.0625f; } + else if (t->spacetype == SPACE_NODE) { + t->snap[0] = 0.0f; + t->snap[1] = 125.0f; + t->snap[2] = 25.0f; + } else { t->snap[0] = 0.0f; t->snap[1] = t->snap[2] = 1.0f; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 90b67951614..d485b886ea7 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -459,7 +459,7 @@ void initSnapping(TransInfo *t, wmOperator *op) } /* use scene defaults only when transform is modal */ else if (t->flag & T_MODAL) { - if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) { + if (ELEM3(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) { if (ts->snap_flag & SCE_SNAP) { t->modifiers |= MOD_SNAP; } |