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:
authorMatt Ebb <matt@mke3.net>2010-01-06 07:52:13 +0300
committerMatt Ebb <matt@mke3.net>2010-01-06 07:52:13 +0300
commit0c64d6d71e8688ad94cacb51d75cf11006ed0639 (patch)
tree2081c4f2ec966141d9d888a9668dc980ca1df21f /source/blender/windowmanager/intern/wm_gesture.c
parent169626fa92f667bdfa98c53553c43bd0950dbaa0 (diff)
Small tweaks to gesture drawing to show the filled selectable area.
Gives nice feedback for what will be selected, especially with lasso.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_gesture.c')
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c76
1 files changed, 71 insertions, 5 deletions
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index b95d171c1b0..d297c6ce171 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -149,8 +149,18 @@ static void wm_gesture_draw_rect(wmWindow *win, wmGesture *gt)
{
rcti *rect= (rcti *)gt->customdata;
+ glEnable(GL_BLEND);
+ glColor4f(1.0, 1.0, 1.0, 0.05);
+ glBegin(GL_QUADS);
+ glVertex2s(rect->xmax, rect->ymin);
+ glVertex2s(rect->xmax, rect->ymax);
+ glVertex2s(rect->xmin, rect->ymax);
+ glVertex2s(rect->xmin, rect->ymin);
+ glEnd();
+ glDisable(GL_BLEND);
+
glEnable(GL_LINE_STIPPLE);
- glColor3ub(0, 0, 0);
+ glColor3ub(96, 96, 96);
glLineStipple(1, 0xCCCC);
sdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
glColor3ub(255, 255, 255);
@@ -164,7 +174,7 @@ static void wm_gesture_draw_line(wmWindow *win, wmGesture *gt)
rcti *rect= (rcti *)gt->customdata;
glEnable(GL_LINE_STIPPLE);
- glColor3ub(0, 0, 0);
+ glColor3ub(96, 96, 96);
glLineStipple(1, 0xAAAA);
sdrawline(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
glColor3ub(255, 255, 255);
@@ -181,8 +191,13 @@ static void wm_gesture_draw_circle(wmWindow *win, wmGesture *gt)
glTranslatef((float)rect->xmin, (float)rect->ymin, 0.0f);
+ glEnable(GL_BLEND);
+ glColor4f(1.0, 1.0, 1.0, 0.05);
+ glutil_draw_filled_arc(0.0, M_PI*2.0, rect->xmax, 40);
+ glDisable(GL_BLEND);
+
glEnable(GL_LINE_STIPPLE);
- glColor3ub(0, 0, 0);
+ glColor3ub(96, 96, 96);
glLineStipple(1, 0xAAAA);
glutil_draw_lined_arc(0.0, M_PI*2.0, rect->xmax, 40);
glColor3ub(255, 255, 255);
@@ -194,15 +209,66 @@ static void wm_gesture_draw_circle(wmWindow *win, wmGesture *gt)
}
+/* more than 64 intersections will just leak.. not much and not a likely scenario */
+typedef struct TessData { int num; short *intersections[64]; } TessData;
+
+static void combine_cb(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], void **dataOut, void *data)
+{
+ short *vertex;
+ TessData *td = (TessData *)data;
+ vertex = (short *)malloc(2*sizeof(short));
+ vertex[0] = (short)coords[0];
+ vertex[1] = (short)coords[1];
+ *dataOut = vertex;
+
+ if (td->num < 64) {
+ td->intersections[td->num++] = vertex;
+ }
+}
+
+static void free_tess_data(GLUtesselator *tess, TessData *td)
+{
+ int i;
+ for (i=0; i<td->num; i++) {
+ free(td->intersections[i]);
+ }
+ MEM_freeN(td);
+ td = NULL;
+ gluDeleteTess(tess);
+}
+
static void wm_gesture_draw_lasso(wmWindow *win, wmGesture *gt)
{
short *lasso= (short *)gt->customdata;
int i;
+ TessData *data=MEM_callocN(sizeof(TessData), "tesselation data");
+ GLUtesselator *tess = gluNewTess();
+
+ /* use GLU tesselator to draw a filled lasso shape */
+ gluTessCallback(tess, GLU_TESS_BEGIN, glBegin);
+ gluTessCallback(tess, GLU_TESS_VERTEX, glVertex2sv);
+ gluTessCallback(tess, GLU_TESS_END, glEnd);
+ gluTessCallback(tess, GLU_TESS_COMBINE_DATA, combine_cb);
+
+ glEnable(GL_BLEND);
+ glColor4f(1.0, 1.0, 1.0, 0.05);
+ gluTessBeginPolygon (tess, data);
+ gluTessBeginContour (tess);
+ for (i=0; i<gt->points; i++, lasso+=2) {
+ GLdouble d_lasso[2] = {(GLdouble)lasso[0], (GLdouble)lasso[1]};
+ gluTessVertex (tess, d_lasso, lasso);
+ }
+ gluTessEndContour (tess);
+ gluTessEndPolygon (tess);
+ glDisable(GL_BLEND);
+
+ free_tess_data(tess, data);
glEnable(GL_LINE_STIPPLE);
- glColor3ub(0, 0, 0);
+ glColor3ub(96, 96, 96);
glLineStipple(1, 0xAAAA);
glBegin(GL_LINE_STRIP);
+ lasso= (short *)gt->customdata;
for(i=0; i<gt->points; i++, lasso+=2)
glVertex2sv(lasso);
if(gt->type==WM_GESTURE_LASSO)
@@ -228,7 +294,7 @@ static void wm_gesture_draw_cross(wmWindow *win, wmGesture *gt)
rcti *rect= (rcti *)gt->customdata;
glEnable(GL_LINE_STIPPLE);
- glColor3ub(0, 0, 0);
+ glColor3ub(96, 96, 96);
glLineStipple(1, 0xCCCC);
sdrawline(rect->xmin - win->sizex, rect->ymin, rect->xmin + win->sizex, rect->ymin);
sdrawline(rect->xmin, rect->ymin - win->sizey, rect->xmin, rect->ymin + win->sizey);