Draw background rectangle behind the (possibly multiline) overlay text
Before this commit, the background rectangle was drawn to cover only one line of text (which was ok since multiline overlay text was not supported). Now the code correctly calculates the dimensions on the rendered text and put the rectangle of the right size under it.
This commit is contained in:
parent
a810b71f14
commit
5e36d10afc
30
src/imv.c
30
src/imv.c
|
@ -1343,27 +1343,35 @@ static void render_window(struct imv *imv)
|
||||||
|
|
||||||
/* if the overlay needs to be drawn, draw that too */
|
/* if the overlay needs to be drawn, draw that too */
|
||||||
if (imv->overlay.enabled) {
|
if (imv->overlay.enabled) {
|
||||||
const int height = imv->overlay.font.size * 1.2;
|
char overlay_text[1024];
|
||||||
imv_canvas_color(imv->canvas,
|
generate_env_text(imv, overlay_text, sizeof overlay_text, imv->overlay.text);
|
||||||
imv->overlay.background_color.r / 255.f,
|
PangoLayout *layout = imv_canvas_make_layout(imv->canvas, overlay_text);
|
||||||
imv->overlay.background_color.g / 255.f,
|
|
||||||
imv->overlay.background_color.b / 255.f,
|
int width, height;
|
||||||
imv->overlay.background_alpha / 255.f);
|
pango_layout_get_pixel_size(layout, &width, &height);
|
||||||
int y = 0 ;
|
|
||||||
|
int y = 0;
|
||||||
const int bottom_offset = 5;
|
const int bottom_offset = 5;
|
||||||
if (imv->overlay.position_at_bottom)
|
if (imv->overlay.position_at_bottom)
|
||||||
{
|
{
|
||||||
y = wh - height - bottom_offset;
|
y = wh - height - bottom_offset;
|
||||||
}
|
}
|
||||||
imv_canvas_fill_rectangle(imv->canvas, 0, y, ww, height + bottom_offset);
|
|
||||||
|
imv_canvas_color(imv->canvas,
|
||||||
|
imv->overlay.background_color.r / 255.f,
|
||||||
|
imv->overlay.background_color.g / 255.f,
|
||||||
|
imv->overlay.background_color.b / 255.f,
|
||||||
|
imv->overlay.background_alpha / 255.f);
|
||||||
|
imv_canvas_fill_rectangle(imv->canvas, 0, y, width, height + bottom_offset);
|
||||||
|
|
||||||
imv_canvas_color(imv->canvas,
|
imv_canvas_color(imv->canvas,
|
||||||
imv->overlay.text_color.r / 255.f,
|
imv->overlay.text_color.r / 255.f,
|
||||||
imv->overlay.text_color.g / 255.f,
|
imv->overlay.text_color.g / 255.f,
|
||||||
imv->overlay.text_color.b / 255.f,
|
imv->overlay.text_color.b / 255.f,
|
||||||
imv->overlay.text_alpha / 255.f);
|
imv->overlay.text_alpha / 255.f);
|
||||||
char overlay_text[1024];
|
imv_canvas_show_layout(imv->canvas, 0, y, layout);
|
||||||
generate_env_text(imv, overlay_text, sizeof overlay_text, imv->overlay.text);
|
|
||||||
imv_canvas_printf(imv->canvas, 0, y, "%s", overlay_text);
|
g_object_unref(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw command entry bar if needed */
|
/* draw command entry bar if needed */
|
||||||
|
|
Loading…
Reference in a new issue