[Bf-blender-cvs] [44b4ced] wiggly-widgets: Correctly center the widget in node space
Antony Riakiotakis
noreply at git.blender.org
Fri Nov 21 16:48:44 CET 2014
Commit: 44b4ced395131534843412997ccea36780727296
Author: Antony Riakiotakis
Date: Fri Nov 21 16:48:33 2014 +0100
Branches: wiggly-widgets
https://developer.blender.org/rB44b4ced395131534843412997ccea36780727296
Correctly center the widget in node space
===================================================================
M source/blender/editors/space_node/node_draw.c
M source/blender/editors/space_node/space_node.c
M source/blender/windowmanager/intern/wm_generic_widgets.c
===================================================================
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 70da0d7..fd4719a 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -1341,10 +1341,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
glPushMatrix();
glaDefine2DArea(&ar->winrct);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
+ wmOrtho2_pixelspace(ar->winx, ar->winy);
WM_widgets_draw(C, ar);
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 6841972..b1764eb 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -864,13 +864,13 @@ static void WIDGETGROUP_node_transform_update(struct wmWidgetGroup *wgroup, cons
float origin[3];
float xsize, ysize;
- xsize = snode->zoom * ibuf->x / ar->winx;
- ysize = snode->zoom * ibuf->y / ar->winy;
+ xsize = snode->zoom * ibuf->x;
+ ysize = snode->zoom * ibuf->y;
origin[0] = (ar->winx - xsize) / 2 + snode->xof;
origin[1] = (ar->winy - ysize) / 2 + snode->yof;
- WIDGET_cage_bounds_set(cage, 2.0 * xsize, 2.0 * ysize);
+ WIDGET_cage_bounds_set(cage, xsize, ysize);
WM_widget_set_origin(cage, origin);
WM_widget_set_draw(cage, true);
}
diff --git a/source/blender/windowmanager/intern/wm_generic_widgets.c b/source/blender/windowmanager/intern/wm_generic_widgets.c
index 4a055da..5ab0b3b 100644
--- a/source/blender/windowmanager/intern/wm_generic_widgets.c
+++ b/source/blender/windowmanager/intern/wm_generic_widgets.c
@@ -657,6 +657,10 @@ static void widget_cage_draw(struct wmWidget *widget, const struct bContext *UNU
CageWidget *cage = (CageWidget *)widget;
float w = BLI_rctf_size_x(&cage->bound);
float h = BLI_rctf_size_y(&cage->bound);
+ float aspx = 1.0f, aspy = 1.0f;
+
+ glPushMatrix();
+ glTranslatef(widget->origin[0], widget->origin[1], 0.0f);
glColor4f(1.0f, 0.6f, 0.0f, 0.1f);
@@ -664,15 +668,24 @@ static void widget_cage_draw(struct wmWidget *widget, const struct bContext *UNU
// glRectf(cage->bound.xmin, cage->bound.ymin, cage->bound.xmax, cage->bound.ymax);
// glDisable(GL_BLEND);
+ if (w > h)
+ aspx = h / w;
+ else if (w < h)
+ aspy = w / h;
+ w = aspx * w / 8.0f;
+ h = aspy * h / 8.0f;
+
/* corner widgets */
glColor3f(0.0, 0.0, 0.0);
glLineWidth(3.0);
- cage_draw_corners(&cage->bound, w/8.0f, h/8.0f);
+ cage_draw_corners(&cage->bound, w, h);
/* corner widgets */
glColor3f(1.0, 1.0, 1.0);
glLineWidth(1.0);
- cage_draw_corners(&cage->bound, w/8.0f, h/8.0f);
+ cage_draw_corners(&cage->bound, w, h);
+
+ glPopMatrix();
}
static int widget_cage_intersect(struct bContext *UNUSED(C), const struct wmEvent *event, struct wmWidget *widget)
@@ -715,10 +728,10 @@ void WIDGET_cage_bind_to_rotation(struct wmWidget *widget, float rotation)
void WIDGET_cage_bounds_set(struct wmWidget *widget, float w, float h)
{
CageWidget *cage = (CageWidget *)widget;
- cage->bound.xmax = w/2;
- cage->bound.ymax = h/2;
- cage->bound.xmin = -w/2;
- cage->bound.ymin = -h/2;
+ cage->bound.xmax = w;
+ cage->bound.ymax = h;
+ cage->bound.xmin = 0.0;
+ cage->bound.ymin = 0.0;
}
More information about the Bf-blender-cvs
mailing list