Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface/view2d.c')
-rw-r--r--source/blender/editors/interface/view2d.c31
1 files changed, 28 insertions, 3 deletions
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 8a6de9a549b..fe7e6d01955 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1368,7 +1368,7 @@ void UI_view2d_constant_grid_draw(View2D *v2d)
}
/* Draw a multi-level grid in given 2d-region */
-void UI_view2d_multi_grid_draw(View2D *v2d, float step, int level_size, int totlevels)
+void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_size, int totlevels)
{
int offset = -10;
float lstep = step;
@@ -1378,7 +1378,7 @@ void UI_view2d_multi_grid_draw(View2D *v2d, float step, int level_size, int totl
int i;
float start;
- UI_ThemeColorShade(TH_BACK, offset);
+ UI_ThemeColorShade(colorid, offset);
i = (v2d->cur.xmin >= 0.0f ? -(int)(-v2d->cur.xmin / lstep) : (int)(v2d->cur.xmin / lstep));
start = i * lstep;
@@ -1402,7 +1402,7 @@ void UI_view2d_multi_grid_draw(View2D *v2d, float step, int level_size, int totl
}
/* X and Y axis */
- UI_ThemeColorShade(TH_BACK, offset - 8);
+ UI_ThemeColorShade(colorid, offset - 8);
glVertex2f(0.0f, v2d->cur.ymin);
glVertex2f(0.0f, v2d->cur.ymax);
glVertex2f(v2d->cur.xmin, 0.0f);
@@ -2075,6 +2075,31 @@ void UI_view2d_getscale_inverse(View2D *v2d, float *x, float *y)
if (y) *y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
}
+/* Simple functions for consistent center offset access.
+ * Used by node editor to shift view center for each individual node tree.
+ */
+void UI_view2d_getcenter(struct View2D *v2d, float *x, float *y)
+{
+ /* get center */
+ if (x) *x = 0.5f*(v2d->cur.xmin + v2d->cur.xmax);
+ if (y) *y = 0.5f*(v2d->cur.ymin + v2d->cur.ymax);
+}
+void UI_view2d_setcenter(struct View2D *v2d, float x, float y)
+{
+ /* get delta from current center */
+ float dx = x - 0.5f*(v2d->cur.xmin + v2d->cur.xmax);
+ float dy = y - 0.5f*(v2d->cur.ymin + v2d->cur.ymax);
+
+ /* add to cur */
+ v2d->cur.xmin += dx;
+ v2d->cur.xmax += dx;
+ v2d->cur.ymin += dy;
+ v2d->cur.ymax += dy;
+
+ /* make sure that 'cur' rect is in a valid state as a result of these changes */
+ UI_view2d_curRect_validate(v2d);
+}
+
/* Check if mouse is within scrollers
* - Returns appropriate code for match
* 'h' = in horizontal scroller