summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2008-04-21 13:05:38 +0200
committerGuillaume Seguin <guillaume@segu.in>2008-04-21 13:05:38 +0200
commit58d3cd2b47decd13c3b59829565a4c729134fd6e (patch)
tree4de6f2e97f3aa7e754fe3d0357c98fde4591b490
parent82850f5e693fa6644b99269a125b71ccc073042f (diff)
downloadworkspacenames-58d3cd2b47decd13c3b59829565a4c729134fd6e.tar.gz
workspacenames-58d3cd2b47decd13c3b59829565a4c729134fd6e.tar.bz2
Use Cairo-based text background drawing
-rw-r--r--workspacenames.c59
1 files changed, 7 insertions, 52 deletions
diff --git a/workspacenames.c b/workspacenames.c
index fc23504..1b7e29b 100644
--- a/workspacenames.c
+++ b/workspacenames.c
@@ -118,8 +118,15 @@ wsnamesRenderNameText (CompScreen *s)
tA.color[3] = workspacenamesGetFontColorAlpha (s);
tA.style = (workspacenamesGetBoldText (s)) ?
TEXT_STYLE_BOLD : TEXT_STYLE_NORMAL;
+ tA.style |= TEXT_STYLE_BACKGROUND;
tA.family = "Sans";
tA.ellipsize = TRUE;
+ tA.backgroundHMargin = 15;
+ tA.backgroundVMargin = 15;
+ tA.backgroundColor[0] = workspacenamesGetBackColorRed (s);
+ tA.backgroundColor[1] = workspacenamesGetBackColorGreen (s);
+ tA.backgroundColor[2] = workspacenamesGetBackColorBlue (s);
+ tA.backgroundColor[3] = workspacenamesGetBackColorAlpha (s);
tA.renderMode = TextRenderNormal;
tA.data = (void *) name;
@@ -151,7 +158,6 @@ wsnamesDrawText (CompScreen *s)
GLfloat alpha;
float width, height, border;
int ox1, ox2, oy1, oy2;
- int k;
float x, y;
WSNAMES_SCREEN(s);
@@ -204,57 +210,6 @@ wsnamesDrawText (CompScreen *s)
else
alpha = 1.0f;
- glColor4us (workspacenamesGetBackColorRed (s),
- workspacenamesGetBackColorGreen (s),
- workspacenamesGetBackColorBlue (s),
- workspacenamesGetBackColorAlpha (s) * alpha);
-
- glPushMatrix ();
-
- glTranslatef (x, y - height, 0.0f);
- glRectf (0.0f, height, width, 0.0f);
- glRectf (0.0f, 0.0f, width, -border);
- glRectf (0.0f, height + border, width, height);
- glRectf (-border, height, 0.0f, 0.0f);
- glRectf (width, height, width + border, 0.0f);
- glTranslatef (-border, -border, 0.0f);
-
-#define CORNER(a,b) \
- for (k = a; k < b; k++) \
- {\
- float rad = k * (PI / 180.0f);\
- glVertex2f (0.0f, 0.0f);\
- glVertex2f (cos (rad) * border, sin (rad) * border);\
- glVertex2f (cos ((k - 1) * (PI / 180.0f)) * border, \
- sin ((k - 1) * (PI / 180.0f)) * border);\
- }
-
- /* Rounded corners */
-
- glTranslatef (border, border, 0.0f);
- glBegin (GL_TRIANGLES);
- CORNER (180, 270) glEnd ();
- glTranslatef (-border, -border, 0.0f);
-
- glTranslatef (width + border, border, 0.0f);
- glBegin (GL_TRIANGLES);
- CORNER (270, 360) glEnd ();
- glTranslatef (-(width + border), -border, 0.0f);
-
- glTranslatef (border, height + border, 0.0f);
- glBegin (GL_TRIANGLES);
- CORNER (90, 180) glEnd ();
- glTranslatef (-border, -(height + border), 0.0f);
-
- glTranslatef (width + border, height + border, 0.0f);
- glBegin (GL_TRIANGLES);
- CORNER (0, 90) glEnd ();
- glTranslatef (-(width + border), -(height + border), 0.0f);
-
- glPopMatrix ();
-
-#undef CORNER
-
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor4f (alpha, alpha, alpha, alpha);