WINGs/wview_wl: implement wl_balloon_draw for tooltip rendering
This commit is contained in:
parent
b52ca0747c
commit
b7fb4725c4
|
|
@ -612,7 +612,45 @@ static void wl_text_init(void *vctx, W_View *view, void *stipple_gc_out)
|
|||
static void wl_balloon_draw(void *vctx, W_View *view, int x, int y,
|
||||
int w, int h, const char *text)
|
||||
{
|
||||
(void)vctx; (void)view; (void)x; (void)y; (void)w; (void)h; (void)text;
|
||||
(void)vctx;
|
||||
if (!view || !text || !text[0]) return;
|
||||
|
||||
W_Screen *scr = view->screen;
|
||||
WMFont *font = scr->normalFont;
|
||||
int textWidth = WMWidthOfString(font, text, strlen(text));
|
||||
int bw = textWidth + 16;
|
||||
int bh = WMFontHeight(font) + 8;
|
||||
if (bw < bh) bw = bh;
|
||||
|
||||
int bx = x + w / 2 - bw / 2;
|
||||
int by = y - bh - 4;
|
||||
if (by < 0) by = y + h + 4;
|
||||
if (bx < 0) bx = 0;
|
||||
|
||||
W_ResizeView(view, bw, bh);
|
||||
W_MoveView(view, bx, by);
|
||||
|
||||
if (!view->flags.mapped)
|
||||
W_MapView(view);
|
||||
|
||||
pixman_image_t *img = (pixman_image_t *)W_GetViewBacking(view->window);
|
||||
if (!img) return;
|
||||
|
||||
pixman_color_t yellow = {0xFFFF, 0xFFFF, 0x8888, 0xFFFF};
|
||||
pixman_image_fill_rectangles(PIXMAN_OP_SRC, img, &yellow,
|
||||
1, &(pixman_rectangle16_t){0, 0, bw, bh});
|
||||
|
||||
pixman_color_t black = {0, 0, 0, 0xFFFF};
|
||||
pixman_image_fill_rectangles(PIXMAN_OP_SRC, img, &black, 4,
|
||||
(pixman_rectangle16_t[]){
|
||||
{0, 0, bw, 1},
|
||||
{0, bh - 1, bw, 1},
|
||||
{0, 0, 1, bh},
|
||||
{bw - 1, 0, 1, bh}
|
||||
});
|
||||
|
||||
WMDrawString(scr, (WMDrawable)view->window, scr->black, font,
|
||||
8, (bh - WMFontHeight(font)) / 2, text, strlen(text));
|
||||
}
|
||||
|
||||
static void wl_drag_begin(void *vctx, W_View *view, WMEvent *event)
|
||||
|
|
|
|||
Loading…
Reference in New Issue