update logic to allow setting fg and bg, align to static vars, spruce demo a bit
This commit is contained in:
parent
e83eeb92f1
commit
5c1a24cb4a
38
lemonbar.c
38
lemonbar.c
|
@ -97,11 +97,16 @@ static int bu = 1; // Underline height
|
||||||
static rgba_t fgc, bgc, ugc;
|
static rgba_t fgc, bgc, ugc;
|
||||||
static rgba_t dfgc, dbgc, dugc;
|
static rgba_t dfgc, dbgc, dugc;
|
||||||
static area_stack_t area_stack;
|
static area_stack_t area_stack;
|
||||||
|
|
||||||
|
// slant vars
|
||||||
static int slant;
|
static int slant;
|
||||||
|
static int right;
|
||||||
static int slant_width;
|
static int slant_width;
|
||||||
static int full_slant_width;
|
static int full_slant_width;
|
||||||
static int slant_counter;
|
static int slant_counter;
|
||||||
static int upslant;
|
static int upslant;
|
||||||
|
static int fg_height;
|
||||||
|
static int bg_height;
|
||||||
|
|
||||||
void
|
void
|
||||||
update_gc (void)
|
update_gc (void)
|
||||||
|
@ -220,10 +225,6 @@ draw_char (monitor_t *mon, font_t *cur_font, int x, int align, uint16_t ch, int
|
||||||
// Draw the background first
|
// Draw the background first
|
||||||
if(slant_width)
|
if(slant_width)
|
||||||
{
|
{
|
||||||
// even = slant left, odd = slant right
|
|
||||||
int right = slant % 2;
|
|
||||||
int cur_height = 0;
|
|
||||||
|
|
||||||
if(!full_slant_width)
|
if(!full_slant_width)
|
||||||
full_slant_width = slant_width * ch_width;
|
full_slant_width = slant_width * ch_width;
|
||||||
|
|
||||||
|
@ -231,15 +232,25 @@ draw_char (monitor_t *mon, font_t *cur_font, int x, int align, uint16_t ch, int
|
||||||
{
|
{
|
||||||
slant_counter++;
|
slant_counter++;
|
||||||
if (right)
|
if (right)
|
||||||
cur_height = (bh * (full_slant_width - slant_counter)) / full_slant_width;
|
{
|
||||||
else
|
fg_height = (bh * (full_slant_width - slant_counter)) / full_slant_width;
|
||||||
cur_height = (slant_counter * bh) / full_slant_width;
|
bg_height = (slant_counter * bh) / full_slant_width;
|
||||||
|
|
||||||
if (!upslant)
|
|
||||||
cur_height *= -1;
|
|
||||||
|
|
||||||
fill_rect(mon->pixmap, gc[GC_CLEAR], x+i, cur_height, 1, bh);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fg_height = (slant_counter * bh) / full_slant_width;
|
||||||
|
bg_height = (bh * (full_slant_width - slant_counter)) / full_slant_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (upslant)
|
||||||
|
bg_height *= -1;
|
||||||
|
else
|
||||||
|
fg_height *= -1;
|
||||||
|
|
||||||
|
fill_rect(mon->pixmap, gc[GC_DRAW], x+i, fg_height, 1, bh);
|
||||||
|
fill_rect(mon->pixmap, gc[GC_CLEAR], x+i, bg_height, 1, bh);
|
||||||
|
}
|
||||||
|
slant_width--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -561,7 +572,10 @@ parse (char *text)
|
||||||
case 'd':
|
case 'd':
|
||||||
slant = *(p-1) - 'A'; // 4,36,5,37
|
slant = *(p-1) - 'A'; // 4,36,5,37
|
||||||
slant_width = (*p++) - '0';
|
slant_width = (*p++) - '0';
|
||||||
|
right = slant % 2;
|
||||||
full_slant_width = 0;
|
full_slant_width = 0;
|
||||||
|
fg_height = 0;
|
||||||
|
bg_height = 0;
|
||||||
slant_counter = 0;
|
slant_counter = 0;
|
||||||
upslant = slant > 20 ? 1 : 0;
|
upslant = slant > 20 ? 1 : 0;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3,9 +3,12 @@
|
||||||
# demonstrate slant flags and what they look like
|
# demonstrate slant flags and what they look like
|
||||||
|
|
||||||
Len=2
|
Len=2
|
||||||
geom=200x20+10+10
|
geom=400x20+10+10
|
||||||
bg='%{B#ff000000}'
|
slant_fg='#a7a7a7'
|
||||||
sbg='%{B#ff00ff00}'
|
slant_bg='#3e3e3e'
|
||||||
|
colors="%{F${slant_fg}}%{B${slant_bg}}"
|
||||||
|
|
||||||
|
reset='%{B-}%{F-}'
|
||||||
|
|
||||||
space()
|
space()
|
||||||
{
|
{
|
||||||
|
@ -13,8 +16,10 @@ space()
|
||||||
}
|
}
|
||||||
|
|
||||||
echo " \
|
echo " \
|
||||||
${sbg}%{E${Len}}$(space)${bg} - \
|
${colors}%{E${Len}}$(space)${reset} - \
|
||||||
${sbg}%{e${Len}}$(space)${bg} - \
|
${colors}%{e${Len}}$(space)${reset} - \
|
||||||
${sbg}%{D${Len}}$(space)${bg} - \
|
${colors}%{D${Len}}$(space)${reset} - \
|
||||||
${sbg}%{d${Len}}$(space)${bg} " \
|
${colors}%{d${Len}}$(space)${reset} \
|
||||||
| ./lemonbar -g $geom -p -B "#000000"
|
${colors}%{d${Len}}$(space)%{B${slant_fg}}%{F${slant_bg}} ~ slants and shit ~ \
|
||||||
|
${colors}%{E${Len}}$(space)${reset}" \
|
||||||
|
| ./lemonbar -g $geom -p -B "$slant_bg" -F "#FFFFFF"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user