]> Pileus Git - grits/commitdiff
Use rounded corners for GritsPoly
authorAndy Spencer <andy753421@gmail.com>
Thu, 27 Oct 2011 07:28:47 +0000 (07:28 +0000)
committerAndy Spencer <andy753421@gmail.com>
Thu, 27 Oct 2011 07:54:25 +0000 (07:54 +0000)
src/objects/grits-poly.c
src/plugins/test.c

index 720e3b1bed37ea29f5af2d7c94104b8a6d539eb9..e33ca2d1cd25014d03cfbbe81d185c7fa73e0d9b 100644 (file)
@@ -88,18 +88,54 @@ static void grits_poly_draw(GritsObject *_poly, GritsOpenGL *opengl)
        glDisable(GL_ALPHA_TEST);
        glDisable(GL_CULL_FACE);
        glDisable(GL_LIGHTING);
+
        glEnable(GL_POLYGON_OFFSET_FILL);
-       glPolygonOffset(1, 1);
+       glEnable(GL_POLYGON_OFFSET_LINE);
+       glEnable(GL_POLYGON_OFFSET_POINT);
+
        if (poly->color[3]) {
+               /* Draw background farthest back */
+               glPolygonOffset(3, 3);
                glColor4dv(poly->color);
+               glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
                grits_poly_runlist(poly, 0, grits_poly_tess);
        }
-       glLineWidth(poly->width);
-       glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+       glEnable(GL_POLYGON_SMOOTH);
+       glEnable(GL_LINE_SMOOTH);
+       glEnable(GL_POINT_SMOOTH);
+
+       if (!poly->color[3] && poly->border[3] && poly->width > 1) {
+               /* Draw line border in the middle */
+               glColor4d(0,0,0,1);
+
+               glPointSize(poly->width*2);
+               glLineWidth(poly->width*2);
+
+               glPolygonOffset(2, 2);
+
+               glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
+               grits_poly_runlist(poly, 1, grits_poly_outline);
+               glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+               grits_poly_runlist(poly, 1, grits_poly_outline);
+       }
+
        if (poly->border[3]) {
+               /* Draw border front-most */
                glColor4dv(poly->border);
+
+               glPointSize(poly->width);
+               glLineWidth(poly->width);
+
+               glPolygonOffset(1, 1);
+               if (poly->width > 1) {
+                       glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
+                       grits_poly_runlist(poly, 1, grits_poly_outline);
+               }
+               glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
                grits_poly_runlist(poly, 1, grits_poly_outline);
        }
+
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        glPopAttrib();
 }
index 44e39d0898253fb90139d1bbb928adaf442c7b57..b7435ab3f8b521bd6bc91594d914bb270287cdae 100644 (file)
@@ -125,7 +125,7 @@ void _load_poly(GritsPluginTest *test)
        test->poly->color[2]  = test->poly->border[2] = 0;
        test->poly->color[3]  = 0.2;
        test->poly->border[3] = 1;
-       test->poly->width     = 10;
+       test->poly->width     = 6;
        grits_viewer_add(test->viewer, GRITS_OBJECT(test->poly),  GRITS_LEVEL_OVERLAY, TRUE);
        g_signal_connect(test->poly, "enter",        G_CALLBACK(on_poly_enter),  NULL);
        g_signal_connect(test->poly, "leave",        G_CALLBACK(on_poly_leave),  NULL);