[grits] Use rounded corners for GritsPoly
- From: Andy Spencer <andys src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grits] Use rounded corners for GritsPoly
- Date: Tue, 3 Jan 2012 01:19:44 +0000 (UTC)
commit f54436e90fe38ef17e85dbdfea64a8916ceae872
Author: Andy Spencer <andy753421 gmail com>
Date: Thu Oct 27 07:28:47 2011 +0000
Use rounded corners for GritsPoly
src/objects/grits-poly.c | 42 +++++++++++++++++++++++++++++++++++++++---
src/plugins/test.c | 2 +-
2 files changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/src/objects/grits-poly.c b/src/objects/grits-poly.c
index 720e3b1..e33ca2d 100644
--- a/src/objects/grits-poly.c
+++ b/src/objects/grits-poly.c
@@ -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();
}
diff --git a/src/plugins/test.c b/src/plugins/test.c
index 44e39d0..b7435ab 100644
--- a/src/plugins/test.c
+++ b/src/plugins/test.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]