[beryl-commits] r1552 - branches/beryl-group-with-tab-plugin
roico at server.beryl-project.org
roico at server.beryl-project.org
Tue Dec 5 18:43:02 CET 2006
Author: roico
Date: 2006-12-05 18:42:09 +0100 (Tue, 05 Dec 2006)
New Revision: 1552
Modified:
branches/beryl-group-with-tab-plugin/group.c
Log:
rounded corners added...
Modified: branches/beryl-group-with-tab-plugin/group.c
===================================================================
--- branches/beryl-group-with-tab-plugin/group.c 2006-12-05 17:05:16 UTC (rev 1551)
+++ branches/beryl-group-with-tab-plugin/group.c 2006-12-05 17:42:09 UTC (rev 1552)
@@ -39,6 +39,7 @@
#include <math.h>
#define PI 3.1415926535897
+#define NUM_CORNER_POINTS 25
/*
* Defaults
@@ -211,7 +212,9 @@
int animatedGroup;
Bool ignoreMode;
-
+
+ float cornerPointsX[NUM_CORNER_POINTS];
+ float cornerPointsY[NUM_CORNER_POINTS];
} GroupDisplay;
/*
@@ -1742,15 +1745,37 @@
#define THUMB_SIZE 128
#define SPACING 20
#define BORDER_COLOR 0.0f, 0.0f, 0.0f, 1.0f
-#define BAR_COLOR 0.8f, 0.8f, 0.8f, 0.5f
+#define BAR_COLOR 0.8f, 0.8f, 0.8f, 0.3f
#define BORDER_WIDTH 5
-#define CIRCLE_POINTS 25
+#define BORDER_RADIUS 10
#define REAL_POSITION(x, s) ( (x >= 0)? x: x + (s)->hsize * (s)->width )
#define VIEWPORT(x, s) ( ( REAL_POSITION(x, s) / (s)->width ) % (s)->hsize )
/*
+ * groupTabBarVertices
+ *
+ */
+static void
+groupTabBarVertices (GroupDisplay* gd, int x, int y, int width, int height)
+{
+ int i;
+
+ for (i = 0; i < NUM_CORNER_POINTS; i++)
+ glVertex2f(BORDER_RADIUS * gd->cornerPointsX[i] + x + width - BORDER_RADIUS, -BORDER_RADIUS * gd->cornerPointsY[i] + BORDER_RADIUS + y);
+
+ for (i = NUM_CORNER_POINTS - 1; i >= 0; i--)
+ glVertex2f(-BORDER_RADIUS * gd->cornerPointsX[i] + x + BORDER_RADIUS, -BORDER_RADIUS * gd->cornerPointsY[i] + BORDER_RADIUS + y);
+
+ for (i = 0; i < NUM_CORNER_POINTS; i++)
+ glVertex2f(-BORDER_RADIUS * gd->cornerPointsX[i] + x + BORDER_RADIUS, BORDER_RADIUS * gd->cornerPointsY[i] + y + height - BORDER_RADIUS);
+
+ for (i = NUM_CORNER_POINTS - 1; i >= 0; i--)
+ glVertex2f(BORDER_RADIUS * gd->cornerPointsX[i] + x + width - BORDER_RADIUS, BORDER_RADIUS * gd->cornerPointsY[i] + y + height - BORDER_RADIUS);
+}
+
+/*
* groupPaintThumb - taken from switcher and modified for tab bar
*
*/
@@ -1800,8 +1825,11 @@
static void
groupPaintTabBar (GroupSelection* group)
{
- CompScreen* s = group->topTab->screen;
- GROUP_SCREEN (s);
+ CompScreen* s = group->topTab->screen;
+ CompDisplay* d = s->display;
+
+ GROUP_SCREEN (s);
+ GROUP_DISPLAY (d);
if(VIEWPORT(group->topTab->attrib.x, s))
return;
@@ -1817,14 +1845,17 @@
x2 = x1 + width;
y2 = y1 + height;
- // for testing use the option of select
- glColor4usv (gs->opt[GROUP_SCREEN_OPTION_SELECTION_COLOR].value.c);
- glBegin (GL_QUADS);
- glVertex2i (x1, y1);
- glVertex2i (x1, y2);
- glVertex2i (x2, y2);
- glVertex2i (x2, y1);
- glEnd ();
+ glColor4f(BAR_COLOR);
+
+ glBegin(GL_POLYGON);
+ groupTabBarVertices(gd, x1, y1, width, height);
+ glEnd();
+
+ glColor4f(BORDER_COLOR);
+
+ glBegin(GL_LINE_LOOP);
+ groupTabBarVertices(gd, x1, y1, width, height);
+ glEnd();
glColor4usv (defaultColor);
glDisable (GL_BLEND);
@@ -2070,6 +2101,25 @@
}
/*
+ * reloadCornerPoints
+ *
+ */
+static void
+initCornerPoints(GroupDisplay* gd)
+{
+ int i;
+ float angle;
+
+ for (i = 0; i < NUM_CORNER_POINTS; i++)
+ {
+ angle = (PI / 2) * ((float)i/(NUM_CORNER_POINTS - 1));
+
+ gd->cornerPointsY[i] = sin(angle);
+ gd->cornerPointsX[i] = cos(angle);
+ }
+}
+
+/*
* groupDisplayInitOptions
*
*/
@@ -2348,7 +2398,9 @@
gd->ignoreMode = FALSE;
groupDisplayInitOptions (gd);
-
+
+ initCornerPoints(gd);
+
WRAP (gd, d, handleEvent, groupHandleEvent);
d->privates[displayPrivateIndex].ptr = gd;
More information about the commits
mailing list