cleanup item drawing, this means we can now disable any item we want at
any time (just don't forget to call drawmenu)
This commit is contained in:
parent
327636b0ee
commit
d455c3a3f2
|
@ -58,10 +58,6 @@ spmenu.type: 1
|
||||||
spmenu.class: spmenu
|
spmenu.class: spmenu
|
||||||
spmenu.leftarrow: <
|
spmenu.leftarrow: <
|
||||||
spmenu.rightarrow: >
|
spmenu.rightarrow: >
|
||||||
spmenu.hidematchcount: 0
|
|
||||||
spmenu.hidehighlight: 0
|
|
||||||
spmenu.hidemode: 0
|
|
||||||
spmenu.hideimage: 0
|
|
||||||
spmenu.imagewidth: 86
|
spmenu.imagewidth: 86
|
||||||
spmenu.imageheight: 86
|
spmenu.imageheight: 86
|
||||||
spmenu.imagegaps: 0
|
spmenu.imagegaps: 0
|
||||||
|
@ -69,6 +65,14 @@ spmenu.imageposition: 0
|
||||||
spmenu.generatecache: 0
|
spmenu.generatecache: 0
|
||||||
spmenu.mode: 0
|
spmenu.mode: 0
|
||||||
spmenu.fast: 0
|
spmenu.fast: 0
|
||||||
|
spmenu.hidematchcount: 0
|
||||||
|
spmenu.hidemode: 0
|
||||||
|
spmenu.hidelarrow: 0
|
||||||
|
spmenu.hiderarrow: 0
|
||||||
|
spmenu.hideprompt: 0
|
||||||
|
spmenu.hidecursor: 0
|
||||||
|
spmenu.hidehighlight: 0
|
||||||
|
spmenu.hideimage: 0
|
||||||
spmenu.normtext: Normal
|
spmenu.normtext: Normal
|
||||||
spmenu.instext: Insert
|
spmenu.instext: Insert
|
||||||
spmenu.pango_item: 1
|
spmenu.pango_item: 1
|
||||||
|
|
44
libs/draw.c
44
libs/draw.c
|
@ -126,8 +126,8 @@ drawmenu(void)
|
||||||
int modeWidth = 0;
|
int modeWidth = 0;
|
||||||
int larrowWidth = 0;
|
int larrowWidth = 0;
|
||||||
int rarrowWidth = 0;
|
int rarrowWidth = 0;
|
||||||
|
int itemWidth = 0;
|
||||||
|
|
||||||
if (!hidematchcount) numberWidth = TEXTW(numbers);
|
|
||||||
if (!hidemode) modeWidth = TEXTW(modetext);
|
if (!hidemode) modeWidth = TEXTW(modetext);
|
||||||
if (!hidelarrow) larrowWidth = TEXTW(leftarrow);
|
if (!hidelarrow) larrowWidth = TEXTW(leftarrow);
|
||||||
if (!hiderarrow) rarrowWidth = TEXTW(rightarrow);
|
if (!hiderarrow) rarrowWidth = TEXTW(rightarrow);
|
||||||
|
@ -142,7 +142,7 @@ drawmenu(void)
|
||||||
/* draw input field */
|
/* draw input field */
|
||||||
w = (lines > 0 || !matches) ? mw - x : inputw;
|
w = (lines > 0 || !matches) ? mw - x : inputw;
|
||||||
drw_setscheme(drw, scheme[SchemeInput]);
|
drw_setscheme(drw, scheme[SchemeInput]);
|
||||||
if (passwd) {
|
if (passwd && !hideprompt) {
|
||||||
censort = ecalloc(1, sizeof(text));
|
censort = ecalloc(1, sizeof(text));
|
||||||
memset(censort, '.', strlen(text));
|
memset(censort, '.', strlen(text));
|
||||||
|
|
||||||
|
@ -151,28 +151,36 @@ drawmenu(void)
|
||||||
|
|
||||||
curpos = TEXTW(censort) - TEXTW(&text[cursor]);
|
curpos = TEXTW(censort) - TEXTW(&text[cursor]);
|
||||||
free(censort);
|
free(censort);
|
||||||
} else if (!passwd) {
|
} else if (!passwd && !hideprompt) {
|
||||||
apply_fribidi(text);
|
apply_fribidi(text);
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, isrtl ? fribidi_text : text, 0, pango_input ? True : False);
|
drw_text(drw, x, 0, w, bh, lrpad / 2, isrtl ? fribidi_text : text, 0, pango_input ? True : False);
|
||||||
curpos = TEXTW(text) - TEXTW(&text[cursor]);
|
curpos = TEXTW(text) - TEXTW(&text[cursor]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((curpos += lrpad / 2 - 1) < w) {
|
if ((curpos += lrpad / 2 - 1) < w && !hidecursor && !hideprompt) {
|
||||||
drw_setscheme(drw, scheme[SchemeCaret]);
|
drw_setscheme(drw, scheme[SchemeCaret]);
|
||||||
drw_rect(drw, x + curpos, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0);
|
drw_rect(drw, x + curpos, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get match count */
|
/* get match count */
|
||||||
if (!hidematchcount) recalculatenumbers();
|
if (!hidematchcount) {
|
||||||
|
recalculatenumbers();
|
||||||
|
numberWidth = TEXTW(numbers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* draw stuff */
|
||||||
if (lines > 0) {
|
if (lines > 0) {
|
||||||
|
|
||||||
|
/* draw image first */
|
||||||
#if USEIMAGE
|
#if USEIMAGE
|
||||||
if (!hideimage && longestedge != 0) {
|
if (!hideimage && longestedge != 0) {
|
||||||
x += imagegaps + imagewidth;
|
x += imagegaps + imagewidth;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* draw grid */
|
/* draw grid */
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (item = curr; item != next; item = item->right, i++)
|
for (item = curr; item != next; item = item->right, i++)
|
||||||
drawitem(
|
drawitem(
|
||||||
item,
|
item,
|
||||||
|
@ -183,38 +191,36 @@ drawmenu(void)
|
||||||
} else if (matches) {
|
} else if (matches) {
|
||||||
/* draw horizontal list */
|
/* draw horizontal list */
|
||||||
x += inputw;
|
x += inputw;
|
||||||
w = TEXTW(leftarrow);
|
w = larrowWidth;
|
||||||
|
|
||||||
|
itemWidth = TEXTWM(item->text);
|
||||||
|
|
||||||
if (curr->left) {
|
if (curr->left) {
|
||||||
drw_setscheme(drw, scheme[SchemeLArrow]);
|
drw_setscheme(drw, scheme[SchemeLArrow]);
|
||||||
drw_text(drw, x, 0, w, bh, lrpad / 2, leftarrow, 0, pango_leftarrow ? True : False);
|
drw_text(drw, x, 0, w, bh, lrpad / 2, leftarrow, 0, pango_leftarrow ? True : False);
|
||||||
}
|
}
|
||||||
|
|
||||||
x += w;
|
x += w;
|
||||||
|
|
||||||
for (item = curr; item != next; item = item->right)
|
for (item = curr; item != next; item = item->right)
|
||||||
if (hidematchcount) {
|
x = drawitem(item, x, 0, MIN(itemWidth, mw - x - rarrowWidth - numberWidth - modeWidth));
|
||||||
x = drawitem(item, x, 0, MIN(TEXTWM(item->text), mw - x - TEXTW(rightarrow) - TEXTW(modetext)));
|
|
||||||
} else {
|
|
||||||
x = drawitem(item, x, 0, MIN(TEXTWM(item->text), mw - x - TEXTW(rightarrow) - TEXTW(numbers) - TEXTW(modetext)));
|
|
||||||
}
|
|
||||||
if (next) {
|
if (next) {
|
||||||
w = TEXTW(rightarrow);
|
w = rarrowWidth;
|
||||||
drw_setscheme(drw, scheme[SchemeRArrow]);
|
drw_setscheme(drw, scheme[SchemeRArrow]);
|
||||||
|
|
||||||
if (hidematchcount) {
|
drw_text(drw, mw - w - numberWidth - modeWidth, 0, w, bh, lrpad / 2, rightarrow, 0, pango_rightarrow ? True : False);
|
||||||
drw_text(drw, mw - w - TEXTW(modetext), 0, w, bh, lrpad / 2, rightarrow, 0, pango_rightarrow ? True : False);
|
|
||||||
} else {
|
|
||||||
drw_text(drw, mw - w - TEXTW(numbers) - TEXTW(modetext), 0, w, bh, lrpad / 2, rightarrow, 0, pango_rightarrow ? True : False);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hidematchcount) {
|
if (!hidematchcount) {
|
||||||
drw_setscheme(drw, scheme[SchemeNumber]);
|
drw_setscheme(drw, scheme[SchemeNumber]);
|
||||||
drw_text(drw, mw - TEXTW(numbers) - TEXTW(modetext), 0, TEXTW(numbers), bh, lrpad / 2, numbers, 0, pango_numbers ? True : False);
|
drw_text(drw, mw - numberWidth - modeWidth, 0, numberWidth, bh, lrpad / 2, numbers, 0, pango_numbers ? True : False);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hidemode) {
|
if (!hidemode) {
|
||||||
drw_setscheme(drw, scheme[SchemeMode]);
|
drw_setscheme(drw, scheme[SchemeMode]);
|
||||||
drw_text(drw, mw - TEXTW(modetext), 0, TEXTW(modetext), bh, lrpad / 2, modetext, 0, pango_mode ? True : False);
|
drw_text(drw, mw - modeWidth, 0, modeWidth, bh, lrpad / 2, modetext, 0, pango_mode ? True : False);
|
||||||
}
|
}
|
||||||
|
|
||||||
drw_map(drw, win, 0, 0, mw, mh);
|
drw_map(drw, win, 0, 0, mw, mh);
|
||||||
|
|
|
@ -67,6 +67,8 @@ static int hidematchcount = 0; /* Hide match count (0/1) */
|
||||||
static int hidemode = 0; /* Hide mode (0/1) */
|
static int hidemode = 0; /* Hide mode (0/1) */
|
||||||
static int hidelarrow = 0; /* Hide left arrow (0/1) */
|
static int hidelarrow = 0; /* Hide left arrow (0/1) */
|
||||||
static int hiderarrow = 0; /* Hide right arrow (0/1) */
|
static int hiderarrow = 0; /* Hide right arrow (0/1) */
|
||||||
|
static int hideprompt = 0; /* Hide prompt (0/1) */
|
||||||
|
static int hidecursor = 0; /* Hide cursor (0/1) */
|
||||||
static int hidehighlight = 0; /* Hide highlight (0/1) */
|
static int hidehighlight = 0; /* Hide highlight (0/1) */
|
||||||
static int hideimage = 0; /* Hide image (0/1) */
|
static int hideimage = 0; /* Hide image (0/1) */
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,10 @@ ResourcePref resources[] = {
|
||||||
{ "hidehighlight", INTEGER, &hidehighlight },
|
{ "hidehighlight", INTEGER, &hidehighlight },
|
||||||
{ "hidemode", INTEGER, &hidemode },
|
{ "hidemode", INTEGER, &hidemode },
|
||||||
{ "hideimage", INTEGER, &hideimage },
|
{ "hideimage", INTEGER, &hideimage },
|
||||||
|
{ "hidelarrow", INTEGER, &hidelarrow },
|
||||||
|
{ "hiderarrow", INTEGER, &hiderarrow },
|
||||||
|
{ "hideprompt", INTEGER, &hideprompt },
|
||||||
|
{ "hidecursor", INTEGER, &hidecursor },
|
||||||
{ "histnodup", INTEGER, &histnodup },
|
{ "histnodup", INTEGER, &histnodup },
|
||||||
{ "casesensitive", INTEGER, &casesensitive },
|
{ "casesensitive", INTEGER, &casesensitive },
|
||||||
{ "imagewidth", INTEGER, &imagewidth },
|
{ "imagewidth", INTEGER, &imagewidth },
|
||||||
|
|
Loading…
Reference in a new issue