Add in slant changes.

This commit is contained in:
neeasade 2015-04-12 07:47:54 -05:00
parent ebb625b529
commit 3cfcb13694
2 changed files with 63 additions and 3 deletions

BIN
lemonbar Executable file

Binary file not shown.

View File

@ -96,6 +96,10 @@ static int bu = 1; // Underline height
static rgba_t fgc, bgc, ugc;
static rgba_t dfgc, dbgc;
static area_stack_t astack;
static int slant;
static int slant_width;
static int full_slant_width;
static int slant_height;
void
update_gc (void)
@ -184,7 +188,7 @@ xcb_void_cookie_t xcb_poly_text_16_simple(xcb_connection_t * c,
}
int
draw_char (monitor_t *mon, font_t *cur_font, int x, int align, uint16_t ch)
draw_char (monitor_t *mon, font_t *cur_font, int x, int align, uint16_t ch, int slant)
{
int ch_width = cur_font->width_lut[ch - cur_font->char_min].character_width;
@ -203,10 +207,55 @@ draw_char (monitor_t *mon, font_t *cur_font, int x, int align, uint16_t ch)
x, bh);
x = mon->width - ch_width;
break;
}
// Draw the background first
fill_rect(mon->pixmap, gc[GC_CLEAR], x, 0, ch_width, bh);
if(slant_width)
{
//odd = slant left, even = slant right
// if > 20, upslant.
int left=slant%2;
int i=0;
int cur_height=0;
if(!full_slant_width)
{
full_slant_width = slant_width * ch_width;
}
for(i=0; i<ch_width; i++)
{
//handles int division better:
int height_calc = (!bh%full_slant_width ? bh/full_slant_width : (bh/full_slant_width) + 1);
cur_height = height_calc*(i) + height_calc;
cur_height+=slant_height;
if(i == ch_width - 1)
{
slant_height=cur_height;
}
if(! left){
cur_height = bh - cur_height;
}
if(slant > 20)
{
cur_height*=-1;
}
fill_rect(mon->pixmap, gc[GC_CLEAR], x+i, cur_height, 1, bh);
}
slant_width--;
}
else
{
fill_rect(mon->pixmap, gc[GC_CLEAR], x, 0, ch_width, bh);
}
// xcb accepts string in UCS-2 BE, so swap
ch = (ch >> 8) | (ch << 8);
@ -510,6 +559,17 @@ parse (char *text)
case 'F': fgc = parse_color(p, &p, dfgc); update_gc(); break;
case 'U': ugc = parse_color(p, &p, dbgc); update_gc(); break;
case 'E':
case 'e':
case 'D':
case 'd':
slant = *(p-1) - 'A'; // 4,36,5,37
slant_width = (*p++)-'0';
slant_height = 0;
full_slant_width=0;
break;
case 'S':
if (*p == '+' && cur_mon->next)
{ cur_mon = cur_mon->next; }
@ -593,7 +653,7 @@ parse (char *text)
xcb_change_gc(c, gc[GC_DRAW] , XCB_GC_FONT, (const uint32_t []){ cur_font->ptr });
int w = draw_char(cur_mon, cur_font, pos_x, align, ucs);
int w = draw_char(cur_mon, cur_font, pos_x, align, ucs, slant);
pos_x += w;
area_shift(cur_mon->window, align, w);